@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.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,27 +1496,49 @@ 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
  }
1479
- function CallLogRow({ msg, meId }) {
1499
+ function CallLogRow({ msg, meId, onCallBack }) {
1480
1500
  const display = react$1.callLogDisplayFor(msg, meId);
1481
1501
  if (!display) return null;
1482
- return /* @__PURE__ */ jsxRuntime.jsx(CallLogLine, { display, insertedAt: msg.inserted_at });
1502
+ return /* @__PURE__ */ jsxRuntime.jsx(
1503
+ CallLogLine,
1504
+ {
1505
+ display,
1506
+ insertedAt: msg.inserted_at,
1507
+ ...onCallBack ? { onCallBack } : {}
1508
+ }
1509
+ );
1483
1510
  }
1484
- function CallLogLine({ display, insertedAt }) {
1511
+ function CallLogLine({
1512
+ display,
1513
+ insertedAt,
1514
+ onCallBack
1515
+ }) {
1485
1516
  const time = formatTime(insertedAt);
1486
1517
  const icon = display.media === "video" ? "video" : "phone";
1487
1518
  const label = [display.title, display.detail, time].filter(Boolean).join(", ");
1488
- return /* @__PURE__ */ jsxRuntime.jsx(
1519
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1489
1520
  "div",
1490
1521
  {
1491
1522
  className: `poolse-call-log${display.missed ? " poolse-call-log--missed" : ""}`,
1492
1523
  role: "note",
1493
1524
  "aria-label": label,
1494
- children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "poolse-call-log__chip", children: [
1495
- /* @__PURE__ */ jsxRuntime.jsx(PoolseIcon, { name: icon, size: 13, label: null, className: "poolse-call-log__icon" }),
1496
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-call-log__title", children: display.title }),
1497
- display.detail && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-call-log__detail", children: display.detail }),
1498
- time && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "poolse-call-log__time", children: time })
1499
- ] })
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
+ ]
1500
1542
  }
1501
1543
  );
1502
1544
  }
@@ -2166,7 +2208,14 @@ function ActionButton({
2166
2208
  function MessageRow(props) {
2167
2209
  const callLog = react$1.callLogDisplayFor(props.msg, props.meId);
2168
2210
  if (callLog !== void 0) {
2169
- return callLog ? /* @__PURE__ */ jsxRuntime.jsx(CallLogRow, { msg: props.msg, meId: props.meId }) : null;
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;
2170
2219
  }
2171
2220
  return /* @__PURE__ */ jsxRuntime.jsx(BubbleMessageRow, { ...props });
2172
2221
  }
@@ -2604,7 +2653,10 @@ function ConversationView({
2604
2653
  daySeparators = TRUE,
2605
2654
  senderLabels = "auto",
2606
2655
  avatars = "auto",
2607
- onMarkedRead
2656
+ onMarkedRead,
2657
+ onCallBack,
2658
+ onJoinCall,
2659
+ currentCallId = null
2608
2660
  }) {
2609
2661
  usePoolseFonts(loadFonts);
2610
2662
  const { me } = react$1.useMe();
@@ -2823,6 +2875,15 @@ function ConversationView({
2823
2875
  onDragLeave,
2824
2876
  onDrop,
2825
2877
  children: [
2878
+ onJoinCall && /* @__PURE__ */ jsxRuntime.jsx(
2879
+ JoinBanner,
2880
+ {
2881
+ conversationId,
2882
+ meId: me?.id ?? null,
2883
+ currentCallId,
2884
+ onJoin: onJoinCall
2885
+ }
2886
+ ),
2826
2887
  status !== "connected" && status !== "idle" && /* @__PURE__ */ jsxRuntime.jsxs(
2827
2888
  "div",
2828
2889
  {
@@ -2902,7 +2963,8 @@ function ConversationView({
2902
2963
  onDelete: () => void deleteMsg(msg.id),
2903
2964
  onOpenThread: () => setThreadRootId(msg.id),
2904
2965
  onQuote: () => setReplyingTo(msg),
2905
- onQuotedClick: scrollToOriginal
2966
+ onQuotedClick: scrollToOriginal,
2967
+ ...onCallBack ? { onCallBack } : {}
2906
2968
  }
2907
2969
  )
2908
2970
  ] }, msg.id);
@@ -2949,6 +3011,17 @@ function ConversationView({
2949
3011
  ) })
2950
3012
  ] });
2951
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
+ }
2952
3025
  function ChatHeader({
2953
3026
  conversationId,
2954
3027
  labelFor,
@@ -3682,6 +3755,7 @@ exports.ConversationList = ConversationList;
3682
3755
  exports.ConversationView = ConversationView;
3683
3756
  exports.EditableMessageBubble = EditableMessageBubble;
3684
3757
  exports.GroupDetailsSheet = GroupDetailsSheet;
3758
+ exports.LiveCallBanner = LiveCallBanner;
3685
3759
  exports.MemberList = MemberList;
3686
3760
  exports.MentionInput = MentionInput;
3687
3761
  exports.MessageActions = MessageActions;