@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.cjs CHANGED
@@ -1476,6 +1476,35 @@ function computeInitials(name) {
1476
1476
  const parts = name.trim().split(/\s+/).slice(0, 2);
1477
1477
  return parts.map((p) => p.charAt(0).toUpperCase()).join("").slice(0, 2) || "?";
1478
1478
  }
1479
+ function CallLogRow({ msg, meId }) {
1480
+ const display = react$1.callLogDisplayFor(msg, meId);
1481
+ if (!display) return null;
1482
+ return /* @__PURE__ */ jsxRuntime.jsx(CallLogLine, { display, insertedAt: msg.inserted_at });
1483
+ }
1484
+ function CallLogLine({ display, insertedAt }) {
1485
+ const time = formatTime(insertedAt);
1486
+ const icon = display.media === "video" ? "video" : "phone";
1487
+ const label = [display.title, display.detail, time].filter(Boolean).join(", ");
1488
+ return /* @__PURE__ */ jsxRuntime.jsx(
1489
+ "div",
1490
+ {
1491
+ className: `poolse-call-log${display.missed ? " poolse-call-log--missed" : ""}`,
1492
+ role: "note",
1493
+ "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
+ ] })
1500
+ }
1501
+ );
1502
+ }
1503
+ function formatTime(iso) {
1504
+ const d = new Date(iso);
1505
+ if (Number.isNaN(d.getTime())) return "";
1506
+ return d.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
1507
+ }
1479
1508
  function AttachmentPreview({ attachment, onClick }) {
1480
1509
  const isFullRow = "content_type" in attachment;
1481
1510
  const { url, loading, error } = react$1.useAttachmentUrl(attachment.id);
@@ -2134,7 +2163,14 @@ function ActionButton({
2134
2163
  ].filter(Boolean).join(" ");
2135
2164
  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
2165
  }
2137
- function MessageRow({
2166
+ function MessageRow(props) {
2167
+ const callLog = react$1.callLogDisplayFor(props.msg, props.meId);
2168
+ if (callLog !== void 0) {
2169
+ return callLog ? /* @__PURE__ */ jsxRuntime.jsx(CallLogRow, { msg: props.msg, meId: props.meId }) : null;
2170
+ }
2171
+ return /* @__PURE__ */ jsxRuntime.jsx(BubbleMessageRow, { ...props });
2172
+ }
2173
+ function BubbleMessageRow({
2138
2174
  msg,
2139
2175
  meId,
2140
2176
  reactions = true,
@@ -2671,6 +2707,11 @@ function ConversationView({
2671
2707
  if (el) el.scrollTop = el.scrollHeight;
2672
2708
  setNewCountWhileAway(0);
2673
2709
  };
2710
+ const meIdForFeed = me?.id ?? null;
2711
+ const visibleMessages = react.useMemo(
2712
+ () => messages.filter((m) => react$1.isMessageVisibleTo(m, meIdForFeed)),
2713
+ [messages, meIdForFeed]
2714
+ );
2674
2715
  const maxReadByOthers = react.useMemo(() => {
2675
2716
  if (!readReceipts || !me) return null;
2676
2717
  let max = 0;
@@ -2807,12 +2848,12 @@ function ConversationView({
2807
2848
  "aria-relevant": "additions",
2808
2849
  children: [
2809
2850
  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." }) : messages.map((msg, idx) => {
2851
+ 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
2852
  if (renderMessage) {
2812
2853
  return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderMessage(msg, me?.id ?? null) }, msg.id);
2813
2854
  }
2814
- const prev = idx > 0 ? messages[idx - 1] ?? null : null;
2815
- const next = idx < messages.length - 1 ? messages[idx + 1] ?? null : null;
2855
+ const prev = idx > 0 ? visibleMessages[idx - 1] ?? null : null;
2856
+ const next = idx < visibleMessages.length - 1 ? visibleMessages[idx + 1] ?? null : null;
2816
2857
  const groupPosition = grouping ? react$1.computeGroupPosition(msg, prev, next, groupingWindowMs) : "standalone";
2817
2858
  const showDaySeparator = daySeparators && (prev === null || !react$1.sameDay(msg.inserted_at, prev.inserted_at));
2818
2859
  const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
@@ -2979,6 +3020,7 @@ function ConversationList({
2979
3020
  const auto = react$1.useConversations();
2980
3021
  const { me } = react$1.useMe();
2981
3022
  const meExternalId = me?.external_id ?? null;
3023
+ const meId = me?.id ?? null;
2982
3024
  const isControlled = controlledConversations !== void 0;
2983
3025
  const conversations = isControlled ? controlledConversations : auto.conversations;
2984
3026
  const loading = isControlled ? controlledLoading ?? false : auto.loading;
@@ -3003,6 +3045,7 @@ function ConversationList({
3003
3045
  selected,
3004
3046
  unread,
3005
3047
  meExternalId,
3048
+ meId,
3006
3049
  ...labelFor ? { labelFor } : {},
3007
3050
  ...avatarFor ? { avatarFor } : {}
3008
3051
  }
@@ -3032,6 +3075,7 @@ function DefaultRow({
3032
3075
  selected: _selected,
3033
3076
  unread,
3034
3077
  meExternalId,
3078
+ meId = null,
3035
3079
  labelFor,
3036
3080
  avatarFor
3037
3081
  }) {
@@ -3041,7 +3085,7 @@ function DefaultRow({
3041
3085
  const avatarUrl = isDirect ? otherExtId ? avatarFor?.(otherExtId) ?? null : conv.avatar_url ?? null : conv.avatar_url ?? null;
3042
3086
  const time = conv.last_message_at ? formatRelative(conv.last_message_at) : "";
3043
3087
  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");
3088
+ 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
3089
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3046
3090
  /* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: avatarUrl, name: title, size: "md" }),
3047
3091
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "poolse-list__body", children: [
@@ -3630,6 +3674,7 @@ exports.AttachmentPreview = AttachmentPreview;
3630
3674
  exports.Avatar = Avatar;
3631
3675
  exports.CallControlButton = CallControlButton;
3632
3676
  exports.CallDeviceMenu = CallDeviceMenu;
3677
+ exports.CallLogRow = CallLogRow;
3633
3678
  exports.CallProvider = CallProvider;
3634
3679
  exports.CallVideoGrid = CallVideoGrid;
3635
3680
  exports.ChatHeader = ChatHeader;