@poolse/react-ui 2.21.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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { CallParticipant, CallMedia, LiveKitModule, CallDevice, CallDeviceKind, Uuid, Message, Conversation, Membership, Attachment, MessageCreateRequest } from '@poolse/sdk';
2
+ import { CallParticipant, CallMedia, LiveKitModule, CallDevice, CallDeviceKind, Uuid, Message, LiveCall, Conversation, Membership, Attachment, MessageCreateRequest } from '@poolse/sdk';
3
3
  import * as react from 'react';
4
4
  import { ReactNode, SVGProps, ReactElement } from 'react';
5
5
  import { UploadItem, ReactionMap } from '@poolse/react';
@@ -440,8 +440,22 @@ interface ConversationViewProps {
440
440
  * a single handler can switch between rooms.
441
441
  */
442
442
  onMarkedRead?: (conversationId: string) => void;
443
+ /**
444
+ * Offer "Call back" on call-log rows the viewer missed or declined,
445
+ * or placed with no answer. Receives the call's media; place the call
446
+ * on this conversation.
447
+ */
448
+ onCallBack?: (media: 'audio' | 'video') => void;
449
+ /**
450
+ * Show a "Call in progress · Join" banner while a call runs on this
451
+ * conversation that the viewer is not on. Called with the live call
452
+ * when they click Join.
453
+ */
454
+ onJoinCall?: (call: LiveCall) => void;
455
+ /** The call this client is already on, if any — its banner is hidden. */
456
+ currentCallId?: string | null;
443
457
  }
444
- declare function ConversationView({ conversationId, emptyState, renderMessage, labelFor, loadFonts, reactions, mentions, attachments, actions, threads, quotations, readReceipts, markdown, maxBodyLength, grouping, groupingWindowMs, daySeparators, senderLabels, avatars, onMarkedRead, }: ConversationViewProps): react_jsx_runtime.JSX.Element;
458
+ declare function ConversationView({ conversationId, emptyState, renderMessage, labelFor, loadFonts, reactions, mentions, attachments, actions, threads, quotations, readReceipts, markdown, maxBodyLength, grouping, groupingWindowMs, daySeparators, senderLabels, avatars, onMarkedRead, onCallBack, onJoinCall, currentCallId, }: ConversationViewProps): react_jsx_runtime.JSX.Element;
445
459
 
446
460
  interface ChatHeaderProps {
447
461
  /** Conversation id — used to fetch the row + members for the title / presence dot. */
@@ -632,10 +646,23 @@ interface CallLogRowProps {
632
646
  msg: Pick<Message, 'type' | 'body' | 'inserted_at'> & {
633
647
  deleted_at?: string | null;
634
648
  };
635
- /** Current user's id — decides whether a missed-call marker is shown. */
649
+ /** Current user's id — decides how the call is worded for them. */
636
650
  meId: string | null;
651
+ /**
652
+ * Offer "Call back" on calls the viewer missed or declined, or placed
653
+ * with no answer. Receives the call's media. Omit to show no action.
654
+ */
655
+ onCallBack?: (media: 'audio' | 'video') => void;
656
+ }
657
+ declare function CallLogRow({ msg, meId, onCallBack }: CallLogRowProps): react_jsx_runtime.JSX.Element | null;
658
+
659
+ interface LiveCallBannerProps {
660
+ call: LiveCall;
661
+ /** How many people are in the room right now. */
662
+ inCall: number;
663
+ onJoin: (call: LiveCall) => void;
637
664
  }
638
- declare function CallLogRow({ msg, meId }: CallLogRowProps): react_jsx_runtime.JSX.Element | null;
665
+ declare function LiveCallBanner({ call, inCall, onJoin }: LiveCallBannerProps): react_jsx_runtime.JSX.Element;
639
666
 
640
667
  interface EditableMessageBubbleProps {
641
668
  message: Message;
@@ -984,4 +1011,4 @@ declare function usePoolseFonts(enabled?: boolean): void;
984
1011
  */
985
1012
  declare function PoolseFonts(): null;
986
1013
 
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 };
1014
+ 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, LiveCallBanner, type LiveCallBannerProps, 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
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { CallParticipant, CallMedia, LiveKitModule, CallDevice, CallDeviceKind, Uuid, Message, Conversation, Membership, Attachment, MessageCreateRequest } from '@poolse/sdk';
2
+ import { CallParticipant, CallMedia, LiveKitModule, CallDevice, CallDeviceKind, Uuid, Message, LiveCall, Conversation, Membership, Attachment, MessageCreateRequest } from '@poolse/sdk';
3
3
  import * as react from 'react';
4
4
  import { ReactNode, SVGProps, ReactElement } from 'react';
5
5
  import { UploadItem, ReactionMap } from '@poolse/react';
@@ -440,8 +440,22 @@ interface ConversationViewProps {
440
440
  * a single handler can switch between rooms.
441
441
  */
442
442
  onMarkedRead?: (conversationId: string) => void;
443
+ /**
444
+ * Offer "Call back" on call-log rows the viewer missed or declined,
445
+ * or placed with no answer. Receives the call's media; place the call
446
+ * on this conversation.
447
+ */
448
+ onCallBack?: (media: 'audio' | 'video') => void;
449
+ /**
450
+ * Show a "Call in progress · Join" banner while a call runs on this
451
+ * conversation that the viewer is not on. Called with the live call
452
+ * when they click Join.
453
+ */
454
+ onJoinCall?: (call: LiveCall) => void;
455
+ /** The call this client is already on, if any — its banner is hidden. */
456
+ currentCallId?: string | null;
443
457
  }
444
- declare function ConversationView({ conversationId, emptyState, renderMessage, labelFor, loadFonts, reactions, mentions, attachments, actions, threads, quotations, readReceipts, markdown, maxBodyLength, grouping, groupingWindowMs, daySeparators, senderLabels, avatars, onMarkedRead, }: ConversationViewProps): react_jsx_runtime.JSX.Element;
458
+ declare function ConversationView({ conversationId, emptyState, renderMessage, labelFor, loadFonts, reactions, mentions, attachments, actions, threads, quotations, readReceipts, markdown, maxBodyLength, grouping, groupingWindowMs, daySeparators, senderLabels, avatars, onMarkedRead, onCallBack, onJoinCall, currentCallId, }: ConversationViewProps): react_jsx_runtime.JSX.Element;
445
459
 
446
460
  interface ChatHeaderProps {
447
461
  /** Conversation id — used to fetch the row + members for the title / presence dot. */
@@ -632,10 +646,23 @@ interface CallLogRowProps {
632
646
  msg: Pick<Message, 'type' | 'body' | 'inserted_at'> & {
633
647
  deleted_at?: string | null;
634
648
  };
635
- /** Current user's id — decides whether a missed-call marker is shown. */
649
+ /** Current user's id — decides how the call is worded for them. */
636
650
  meId: string | null;
651
+ /**
652
+ * Offer "Call back" on calls the viewer missed or declined, or placed
653
+ * with no answer. Receives the call's media. Omit to show no action.
654
+ */
655
+ onCallBack?: (media: 'audio' | 'video') => void;
656
+ }
657
+ declare function CallLogRow({ msg, meId, onCallBack }: CallLogRowProps): react_jsx_runtime.JSX.Element | null;
658
+
659
+ interface LiveCallBannerProps {
660
+ call: LiveCall;
661
+ /** How many people are in the room right now. */
662
+ inCall: number;
663
+ onJoin: (call: LiveCall) => void;
637
664
  }
638
- declare function CallLogRow({ msg, meId }: CallLogRowProps): react_jsx_runtime.JSX.Element | null;
665
+ declare function LiveCallBanner({ call, inCall, onJoin }: LiveCallBannerProps): react_jsx_runtime.JSX.Element;
639
666
 
640
667
  interface EditableMessageBubbleProps {
641
668
  message: Message;
@@ -984,4 +1011,4 @@ declare function usePoolseFonts(enabled?: boolean): void;
984
1011
  */
985
1012
  declare function PoolseFonts(): null;
986
1013
 
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 };
1014
+ 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, LiveCallBanner, type LiveCallBannerProps, 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, isMessageVisibleTo, computeGroupPosition, sameDay, formatDayLabel, formatCallLogPreview, callLogDisplayFor, useThread, useReactions, useAttachmentUrl, useCalls, useCallRoom, useVoiceRoom } from '@poolse/react';
4
+ import { useMembers, useAttachmentUpload, useMe, useConversations, useUser, useConversation, usePresence, useMessages, useTyping, useRealtimeStatus, isMessageVisibleTo, computeGroupPosition, sameDay, formatDayLabel, formatCallLogPreview, useLiveCall, 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
 
@@ -843,6 +843,26 @@ function PoolseFonts() {
843
843
  usePoolseFonts(true);
844
844
  return null;
845
845
  }
846
+ function LiveCallBanner({ call, inCall, onJoin }) {
847
+ const what = call.media === "video" ? "Video call in progress" : "Voice call in progress";
848
+ const who = inCall > 0 ? `${inCall} on the call` : "Ringing";
849
+ return /* @__PURE__ */ jsxs("div", { className: "poolse-live-call", role: "status", "aria-label": `${what}, ${who}`, children: [
850
+ /* @__PURE__ */ jsx(
851
+ PoolseIcon,
852
+ {
853
+ name: call.media === "video" ? "video" : "phone",
854
+ size: 16,
855
+ label: null,
856
+ className: "poolse-live-call__icon"
857
+ }
858
+ ),
859
+ /* @__PURE__ */ jsxs("span", { className: "poolse-live-call__text", children: [
860
+ /* @__PURE__ */ jsx("span", { className: "poolse-live-call__title", children: what }),
861
+ /* @__PURE__ */ jsx("span", { className: "poolse-live-call__meta", children: who })
862
+ ] }),
863
+ /* @__PURE__ */ jsx("button", { type: "button", className: "poolse-live-call__join", onClick: () => onJoin(call), children: "Join" })
864
+ ] });
865
+ }
846
866
 
847
867
  // src/listAutocomplete.ts
848
868
  var UNORDERED_RE = /^(\s*)([-*+]) (.*)$/;
@@ -1469,27 +1489,49 @@ function computeInitials(name) {
1469
1489
  const parts = name.trim().split(/\s+/).slice(0, 2);
1470
1490
  return parts.map((p) => p.charAt(0).toUpperCase()).join("").slice(0, 2) || "?";
1471
1491
  }
1472
- function CallLogRow({ msg, meId }) {
1492
+ function CallLogRow({ msg, meId, onCallBack }) {
1473
1493
  const display = callLogDisplayFor(msg, meId);
1474
1494
  if (!display) return null;
1475
- return /* @__PURE__ */ jsx(CallLogLine, { display, insertedAt: msg.inserted_at });
1495
+ return /* @__PURE__ */ jsx(
1496
+ CallLogLine,
1497
+ {
1498
+ display,
1499
+ insertedAt: msg.inserted_at,
1500
+ ...onCallBack ? { onCallBack } : {}
1501
+ }
1502
+ );
1476
1503
  }
1477
- function CallLogLine({ display, insertedAt }) {
1504
+ function CallLogLine({
1505
+ display,
1506
+ insertedAt,
1507
+ onCallBack
1508
+ }) {
1478
1509
  const time = formatTime(insertedAt);
1479
1510
  const icon = display.media === "video" ? "video" : "phone";
1480
1511
  const label = [display.title, display.detail, time].filter(Boolean).join(", ");
1481
- return /* @__PURE__ */ jsx(
1512
+ return /* @__PURE__ */ jsxs(
1482
1513
  "div",
1483
1514
  {
1484
1515
  className: `poolse-call-log${display.missed ? " poolse-call-log--missed" : ""}`,
1485
1516
  role: "note",
1486
1517
  "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
- ] })
1518
+ children: [
1519
+ /* @__PURE__ */ jsxs("span", { className: "poolse-call-log__chip", children: [
1520
+ /* @__PURE__ */ jsx(PoolseIcon, { name: icon, size: 13, label: null, className: "poolse-call-log__icon" }),
1521
+ /* @__PURE__ */ jsx("span", { className: "poolse-call-log__title", children: display.title }),
1522
+ display.detail && /* @__PURE__ */ jsx("span", { className: "poolse-call-log__detail", children: display.detail }),
1523
+ time && /* @__PURE__ */ jsx("span", { className: "poolse-call-log__time", children: time })
1524
+ ] }),
1525
+ display.callBack && onCallBack && /* @__PURE__ */ jsx(
1526
+ "button",
1527
+ {
1528
+ type: "button",
1529
+ className: "poolse-call-log__call-back",
1530
+ onClick: () => onCallBack(display.media),
1531
+ children: "Call back"
1532
+ }
1533
+ )
1534
+ ]
1493
1535
  }
1494
1536
  );
1495
1537
  }
@@ -2159,7 +2201,14 @@ function ActionButton({
2159
2201
  function MessageRow(props) {
2160
2202
  const callLog = callLogDisplayFor(props.msg, props.meId);
2161
2203
  if (callLog !== void 0) {
2162
- return callLog ? /* @__PURE__ */ jsx(CallLogRow, { msg: props.msg, meId: props.meId }) : null;
2204
+ return callLog ? /* @__PURE__ */ jsx(
2205
+ CallLogRow,
2206
+ {
2207
+ msg: props.msg,
2208
+ meId: props.meId,
2209
+ ...props.onCallBack ? { onCallBack: props.onCallBack } : {}
2210
+ }
2211
+ ) : null;
2163
2212
  }
2164
2213
  return /* @__PURE__ */ jsx(BubbleMessageRow, { ...props });
2165
2214
  }
@@ -2597,7 +2646,10 @@ function ConversationView({
2597
2646
  daySeparators = TRUE,
2598
2647
  senderLabels = "auto",
2599
2648
  avatars = "auto",
2600
- onMarkedRead
2649
+ onMarkedRead,
2650
+ onCallBack,
2651
+ onJoinCall,
2652
+ currentCallId = null
2601
2653
  }) {
2602
2654
  usePoolseFonts(loadFonts);
2603
2655
  const { me } = useMe();
@@ -2816,6 +2868,15 @@ function ConversationView({
2816
2868
  onDragLeave,
2817
2869
  onDrop,
2818
2870
  children: [
2871
+ onJoinCall && /* @__PURE__ */ jsx(
2872
+ JoinBanner,
2873
+ {
2874
+ conversationId,
2875
+ meId: me?.id ?? null,
2876
+ currentCallId,
2877
+ onJoin: onJoinCall
2878
+ }
2879
+ ),
2819
2880
  status !== "connected" && status !== "idle" && /* @__PURE__ */ jsxs(
2820
2881
  "div",
2821
2882
  {
@@ -2895,7 +2956,8 @@ function ConversationView({
2895
2956
  onDelete: () => void deleteMsg(msg.id),
2896
2957
  onOpenThread: () => setThreadRootId(msg.id),
2897
2958
  onQuote: () => setReplyingTo(msg),
2898
- onQuotedClick: scrollToOriginal
2959
+ onQuotedClick: scrollToOriginal,
2960
+ ...onCallBack ? { onCallBack } : {}
2899
2961
  }
2900
2962
  )
2901
2963
  ] }, msg.id);
@@ -2942,6 +3004,17 @@ function ConversationView({
2942
3004
  ) })
2943
3005
  ] });
2944
3006
  }
3007
+ function JoinBanner({
3008
+ conversationId,
3009
+ meId,
3010
+ currentCallId,
3011
+ onJoin
3012
+ }) {
3013
+ const { call, participantIds } = useLiveCall(conversationId);
3014
+ if (!call || call.id === currentCallId) return null;
3015
+ if (meId !== null && participantIds.includes(meId)) return null;
3016
+ return /* @__PURE__ */ jsx(LiveCallBanner, { call, inCall: participantIds.length, onJoin });
3017
+ }
2945
3018
  function ChatHeader({
2946
3019
  conversationId,
2947
3020
  labelFor,
@@ -3663,6 +3736,6 @@ function PoolseLogo({
3663
3736
  );
3664
3737
  }
3665
3738
 
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 };
3739
+ export { AttachmentPreview, Avatar, CallControlButton, CallDeviceMenu, CallLogRow, CallProvider, CallVideoGrid, ChatHeader, ConversationList, ConversationView, EditableMessageBubble, GroupDetailsSheet, LiveCallBanner, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, PoolseFonts, PoolseIcon, PoolseInbox, PoolseLogo, ReactionPicker, ReactionStrip, ThreadView, TypingIndicator, UploadQueueStrip, UserName, UserPickerSheet, useCallInvite, useDisplayName, usePoolseFonts };
3667
3740
  //# sourceMappingURL=index.js.map
3668
3741
  //# sourceMappingURL=index.js.map