@natoe/colab 0.1.31 → 0.1.36

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.mjs CHANGED
@@ -601,6 +601,7 @@ function CollabProvider({ config, apiBaseUrl, children }) {
601
601
  });
602
602
  const [unreadCounts, setUnreadCounts] = useState({});
603
603
  const [unreadCountsByOrder, setUnreadCountsByOrder] = useState({});
604
+ const [unreadUpdateSeq, setUnreadUpdateSeq] = useState(0);
604
605
  const pendingKeys = useRef(/* @__PURE__ */ new Set());
605
606
  const pendingResolvers = useRef(/* @__PURE__ */ new Map());
606
607
  const previewCache = useRef(/* @__PURE__ */ new Map());
@@ -619,6 +620,7 @@ function CollabProvider({ config, apiBaseUrl, children }) {
619
620
  setUnreadCounts(counts.conversation);
620
621
  setUnreadCountsByOrder(counts.order);
621
622
  previewCache.current.clear();
623
+ setUnreadUpdateSeq((n) => n + 1);
622
624
  });
623
625
  if (!s.isConnected()) {
624
626
  s.connect(config);
@@ -852,6 +854,7 @@ function CollabProvider({ config, apiBaseUrl, children }) {
852
854
  config,
853
855
  apiBaseUrl,
854
856
  totalUnread,
857
+ unreadUpdateSeq,
855
858
  unreadCounts,
856
859
  unreadCountsByOrder,
857
860
  requestPreview,
@@ -1639,7 +1642,7 @@ function PatientHeader({
1639
1642
  }
1640
1643
  )
1641
1644
  ] }) : null;
1642
- const settingsButton = onOpenSettings ? /* @__PURE__ */ jsxs(
1645
+ const settingsButton = onOpenSettings && !isSupportChannel ? /* @__PURE__ */ jsxs(
1643
1646
  "button",
1644
1647
  {
1645
1648
  onClick: onOpenSettings,
@@ -3931,6 +3934,7 @@ function fallbackName(role) {
3931
3934
  return "User";
3932
3935
  }
3933
3936
  }
3937
+ var FALLBACK_ROLE_COLOR = { bg: "#f1f5f9", text: "#64748b" };
3934
3938
  function RoleBadge({ role }) {
3935
3939
  const colors = {
3936
3940
  radiologist: { bg: "#eef2ff", text: "#4f46e5" },
@@ -3942,8 +3946,8 @@ function RoleBadge({ role }) {
3942
3946
  admin: { bg: "#f1f5f9", text: "#64748b" }
3943
3947
  // slate
3944
3948
  };
3945
- const color = colors[role];
3946
- return /* @__PURE__ */ jsx("span", { style: { ...styles9.roleBadge, backgroundColor: color.bg, color: color.text }, children: role });
3949
+ const color = colors[role] ?? FALLBACK_ROLE_COLOR;
3950
+ return /* @__PURE__ */ jsx("span", { style: { ...styles9.roleBadge, backgroundColor: color.bg, color: color.text }, children: fallbackName(role) });
3947
3951
  }
3948
3952
  var styles9 = {
3949
3953
  list: {
@@ -4857,6 +4861,7 @@ function CollabPopup({
4857
4861
  const previouslyFocused = useRef(null);
4858
4862
  const titleId = useId();
4859
4863
  const titleText = cleanChannelName(loadedConversation?.name) || (patientData ? buildChannelName(patientData) : "Natoe Support");
4864
+ const isSupportChannel = !patientData;
4860
4865
  const handleMouseDown = useCallback(
4861
4866
  (e) => {
4862
4867
  if (!e.target.closest("[data-drag-handle]")) return;
@@ -4975,7 +4980,7 @@ function CollabPopup({
4975
4980
  })()
4976
4981
  ] }),
4977
4982
  /* @__PURE__ */ jsxs("div", { style: styles13.titleActions, children: [
4978
- loadedConversation && /* @__PURE__ */ jsxs(
4983
+ loadedConversation && !isSupportChannel && /* @__PURE__ */ jsxs(
4979
4984
  "button",
4980
4985
  {
4981
4986
  type: "button",
@@ -5868,7 +5873,7 @@ var styles14 = {
5868
5873
  }};
5869
5874
  function useConversationList(options) {
5870
5875
  const enabled = options?.enabled ?? true;
5871
- const { fetchConversationList, config, totalUnread: serverTotalUnread } = useCollab();
5876
+ const { fetchConversationList, config, unreadUpdateSeq } = useCollab();
5872
5877
  const [conversations, setConversations] = useState([]);
5873
5878
  const [isLoading, setIsLoading] = useState(enabled);
5874
5879
  const [error, setError] = useState(null);
@@ -5906,15 +5911,16 @@ function useConversationList(options) {
5906
5911
  if (!enabled) return;
5907
5912
  refresh();
5908
5913
  }, [enabled, refresh]);
5909
- const hasHandledInitialUnreadRef = useRef(false);
5914
+ const hasHandledInitialSeqRef = useRef(false);
5910
5915
  useEffect(() => {
5911
5916
  if (!enabled) return;
5912
- if (!hasHandledInitialUnreadRef.current) {
5913
- hasHandledInitialUnreadRef.current = true;
5917
+ if (!hasHandledInitialSeqRef.current) {
5918
+ hasHandledInitialSeqRef.current = true;
5914
5919
  return;
5915
5920
  }
5916
- silentRefresh();
5917
- }, [serverTotalUnread, enabled]);
5921
+ const t = setTimeout(silentRefresh, 250);
5922
+ return () => clearTimeout(t);
5923
+ }, [unreadUpdateSeq, enabled]);
5918
5924
  const filter = useCallback(
5919
5925
  (query) => {
5920
5926
  const q = query.trim().toLowerCase();
@@ -6681,6 +6687,143 @@ var styles17 = {
6681
6687
  maxWidth: "320px"
6682
6688
  }
6683
6689
  };
6690
+ ensureGlobalStyles();
6691
+ function HelpPanel({
6692
+ conversation,
6693
+ showSeenBy = true,
6694
+ composerAccessory,
6695
+ className,
6696
+ style
6697
+ }) {
6698
+ const { config } = useCollab();
6699
+ const { handleDeepLink } = useDeepLinks();
6700
+ const messageListRef = useRef(null);
6701
+ const {
6702
+ messages,
6703
+ typingUsers,
6704
+ isLoading,
6705
+ hasMore,
6706
+ error,
6707
+ replyTo,
6708
+ setReplyTo,
6709
+ sendMessage,
6710
+ retryMessage,
6711
+ sendAudioMessage,
6712
+ sendFileMessage,
6713
+ sendTyping,
6714
+ markAsRead,
6715
+ loadMoreMessages
6716
+ } = useConversation({ conversation, kind: "help_lab" });
6717
+ return /* @__PURE__ */ jsxs(
6718
+ "div",
6719
+ {
6720
+ className: [ROOT_CLASS, className].filter(Boolean).join(" "),
6721
+ style: { ...styles18.container, ...style },
6722
+ children: [
6723
+ /* @__PURE__ */ jsxs("header", { style: styles18.header, children: [
6724
+ /* @__PURE__ */ jsx("span", { style: styles18.avatar, "aria-hidden": "true", children: "N" }),
6725
+ /* @__PURE__ */ jsxs("span", { style: styles18.headerText, children: [
6726
+ /* @__PURE__ */ jsx("span", { style: styles18.title, children: "Natoe Support" }),
6727
+ /* @__PURE__ */ jsx("span", { style: styles18.subtitle, children: "Questions about your account, billing or a case" })
6728
+ ] })
6729
+ ] }),
6730
+ error && /* @__PURE__ */ jsx("div", { style: styles18.error, role: "alert", children: error }),
6731
+ isLoading && messages.length === 0 ? /* @__PURE__ */ jsx("div", { style: styles18.loading, children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsx(
6732
+ MessageList,
6733
+ {
6734
+ ref: messageListRef,
6735
+ messages,
6736
+ currentUserId: config.userId,
6737
+ showSeenBy,
6738
+ typingUsers,
6739
+ hasMore,
6740
+ isLoading,
6741
+ onLoadMore: loadMoreMessages,
6742
+ onDeepLinkClick: handleDeepLink,
6743
+ onMessageVisible: markAsRead,
6744
+ onReply: setReplyTo,
6745
+ onRetry: retryMessage,
6746
+ pinDisabled: true
6747
+ }
6748
+ ),
6749
+ composerAccessory,
6750
+ /* @__PURE__ */ jsx(
6751
+ MessageInput,
6752
+ {
6753
+ onSendText: sendMessage,
6754
+ onSendAudio: sendAudioMessage,
6755
+ onSendFile: sendFileMessage,
6756
+ onTyping: sendTyping,
6757
+ replyTo,
6758
+ onCancelReply: () => setReplyTo(null),
6759
+ placeholder: "Ask Natoe support\u2026"
6760
+ }
6761
+ )
6762
+ ]
6763
+ }
6764
+ );
6765
+ }
6766
+ var styles18 = {
6767
+ container: {
6768
+ display: "flex",
6769
+ flexDirection: "column",
6770
+ height: "100%",
6771
+ minHeight: 0,
6772
+ fontFamily: FONT_STACK,
6773
+ background: COLOR.white
6774
+ },
6775
+ header: {
6776
+ display: "flex",
6777
+ alignItems: "center",
6778
+ gap: SPACE.S3,
6779
+ padding: `${SPACE.S3} ${SPACE.S4}`,
6780
+ borderBottom: `1px solid ${COLOR.neutral200}`,
6781
+ flex: "0 0 auto"
6782
+ },
6783
+ avatar: {
6784
+ flex: "0 0 auto",
6785
+ width: 32,
6786
+ height: 32,
6787
+ borderRadius: RADIUS.full,
6788
+ background: COLOR.primary,
6789
+ color: COLOR.white,
6790
+ display: "flex",
6791
+ alignItems: "center",
6792
+ justifyContent: "center",
6793
+ fontSize: FONT_SIZE.md,
6794
+ fontWeight: FONT_WEIGHT.semibold
6795
+ },
6796
+ headerText: {
6797
+ display: "flex",
6798
+ flexDirection: "column",
6799
+ minWidth: 0
6800
+ },
6801
+ title: {
6802
+ fontSize: FONT_SIZE.md,
6803
+ fontWeight: FONT_WEIGHT.semibold,
6804
+ color: COLOR.neutral900
6805
+ },
6806
+ subtitle: {
6807
+ fontSize: FONT_SIZE.sm,
6808
+ color: COLOR.neutral500,
6809
+ overflow: "hidden",
6810
+ textOverflow: "ellipsis",
6811
+ whiteSpace: "nowrap"
6812
+ },
6813
+ error: {
6814
+ padding: `${SPACE.S2} ${SPACE.S4}`,
6815
+ fontSize: FONT_SIZE.sm,
6816
+ color: COLOR.danger,
6817
+ background: COLOR.dangerBg,
6818
+ flex: "0 0 auto"
6819
+ },
6820
+ loading: {
6821
+ flex: "1 1 auto",
6822
+ display: "flex",
6823
+ alignItems: "center",
6824
+ justifyContent: "center"
6825
+ }
6826
+ };
6684
6827
  function useMessages({
6685
6828
  conversationId,
6686
6829
  initialLimit = MESSAGES_PAGE_SIZE
@@ -6886,6 +7029,6 @@ function usePinnedMessages({
6886
7029
  };
6887
7030
  }
6888
7031
 
6889
- export { AUDIO_MIME_TYPE, ChannelSettings, CollabInbox, CollabInline, CollabPanel, CollabPopup, CollabProvider, CollabSocket, ConversationList, ConversationListItem, DEEP_LINK_PREFIX, EVENTS, MAX_FILE_SIZE, MAX_PINNED_MESSAGES, MESSAGES_PAGE_SIZE, MESSAGE_TYPES, MessageActionsMenu, MessageBubble, MessageInput, MessageList, ParticipantsList, PatientHeader, PinnedMessagesBar, ReplyPreview, ReplyQuoteBlock, SUPPORTED_IMAGE_TYPES, SeenByIndicator, THEME_DEFAULTS, THEME_VAR, TYPING_DEBOUNCE_MS, applyThemeOverrides, isCaseKind, isHelpKind, useAudioRecorder, useChannelSettings, useCollab, useConversation, useConversationList, useDeepLinks, useInlineCollab, useMessages, usePinnedMessages, useUnreadCount };
7032
+ export { AUDIO_MIME_TYPE, ChannelSettings, CollabInbox, CollabInline, CollabPanel, CollabPopup, CollabProvider, CollabSocket, ConversationList, ConversationListItem, DEEP_LINK_PREFIX, EVENTS, HelpPanel, MAX_FILE_SIZE, MAX_PINNED_MESSAGES, MESSAGES_PAGE_SIZE, MESSAGE_TYPES, MessageActionsMenu, MessageBubble, MessageInput, MessageList, ParticipantsList, PatientHeader, PinnedMessagesBar, ReplyPreview, ReplyQuoteBlock, SUPPORTED_IMAGE_TYPES, SeenByIndicator, THEME_DEFAULTS, THEME_VAR, TYPING_DEBOUNCE_MS, applyThemeOverrides, isCaseKind, isHelpKind, useAudioRecorder, useChannelSettings, useCollab, useConversation, useConversationList, useDeepLinks, useInlineCollab, useMessages, usePinnedMessages, useUnreadCount };
6890
7033
  //# sourceMappingURL=index.mjs.map
6891
7034
  //# sourceMappingURL=index.mjs.map