@realtimexsco/live-chat 1.4.1 → 1.4.3

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
@@ -7647,6 +7647,76 @@ var HeaderSearchPopover = ({
7647
7647
  ] });
7648
7648
  };
7649
7649
  var HeaderSearchPopover_default = HeaderSearchPopover;
7650
+ var actionBtnClass = "size-8 rounded-lg text-(--chat-muted) transition-colors hover:bg-(--chat-surface) hover:text-(--chat-text)";
7651
+ var DefaultHeaderCallActions = ({
7652
+ activeChannel,
7653
+ conversationId,
7654
+ showPhoneCall = true,
7655
+ showVideoCall = true,
7656
+ onPhoneCall,
7657
+ onVideoCall,
7658
+ className
7659
+ }) => {
7660
+ const { components, slotClassName, features } = useChatCustomizationOptional();
7661
+ const PhoneSlot = components.PhoneCallButton;
7662
+ const VideoSlot = components.VideoCallButton;
7663
+ const hideInGroups = features.hideCallActionsInGroupChats ?? false;
7664
+ if (hideInGroups && activeChannel.isGroup) return null;
7665
+ if (!showPhoneCall && !showVideoCall) return null;
7666
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7667
+ showPhoneCall && (PhoneSlot ? /* @__PURE__ */ jsxRuntime.jsx(
7668
+ PhoneSlot,
7669
+ {
7670
+ activeChannel,
7671
+ conversationId,
7672
+ onPhoneCall,
7673
+ className: cn(className, slotClassName("phoneCallButton"))
7674
+ }
7675
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
7676
+ Button,
7677
+ {
7678
+ variant: "ghost",
7679
+ size: "icon",
7680
+ className: cn(actionBtnClass, className, slotClassName("phoneCallButton")),
7681
+ "aria-label": "Voice call",
7682
+ onClick: onPhoneCall,
7683
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Phone, { size: 15 })
7684
+ }
7685
+ )),
7686
+ showVideoCall && (VideoSlot ? /* @__PURE__ */ jsxRuntime.jsx(
7687
+ VideoSlot,
7688
+ {
7689
+ activeChannel,
7690
+ conversationId,
7691
+ onVideoCall,
7692
+ className: cn(className, slotClassName("videoCallButton"))
7693
+ }
7694
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
7695
+ Button,
7696
+ {
7697
+ variant: "ghost",
7698
+ size: "icon",
7699
+ className: cn(actionBtnClass, className, slotClassName("videoCallButton")),
7700
+ "aria-label": "Video call",
7701
+ onClick: onVideoCall,
7702
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Video, { size: 15 })
7703
+ }
7704
+ ))
7705
+ ] });
7706
+ };
7707
+ var HeaderCallActions = (props) => {
7708
+ const { components, slotClassName, features } = useChatCustomizationOptional();
7709
+ const Custom = components.HeaderCallActions;
7710
+ if (!Custom) {
7711
+ const hideInGroups = features.hideCallActionsInGroupChats ?? false;
7712
+ const showPhoneCall = props.showPhoneCall ?? true;
7713
+ const showVideoCall = props.showVideoCall ?? true;
7714
+ if (hideInGroups && props.activeChannel.isGroup) return null;
7715
+ if (!showPhoneCall && !showVideoCall) return null;
7716
+ }
7717
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex items-center gap-0.5", slotClassName("headerCallActions")), children: Custom ? /* @__PURE__ */ jsxRuntime.jsx(Custom, { ...props }) : /* @__PURE__ */ jsxRuntime.jsx(DefaultHeaderCallActions, { ...props }) });
7718
+ };
7719
+ var HeaderCallActions_default = HeaderCallActions;
7650
7720
  function OptionsMenuItem({
7651
7721
  icon: Icon,
7652
7722
  label,
@@ -7667,6 +7737,7 @@ function OptionsMenuItem({
7667
7737
  }
7668
7738
  var HeaderRightSide = ({
7669
7739
  activeChannel,
7740
+ conversationId,
7670
7741
  isAdmin,
7671
7742
  canViewMembers,
7672
7743
  pinnedCount,
@@ -7696,6 +7767,15 @@ var HeaderRightSide = ({
7696
7767
  }) => {
7697
7768
  const { scopeClassName, themeStyles, showColorModeToggle } = useChatTheme();
7698
7769
  const { showDateTimeSettings } = useChatLocale();
7770
+ const features = useChatFeaturesOptional();
7771
+ const showPhoneCall = features.showPhoneCall ?? defaultChatFeatures.showPhoneCall;
7772
+ const showVideoCall = features.showVideoCall ?? defaultChatFeatures.showVideoCall;
7773
+ const handlePhoneCall = () => {
7774
+ features.onPhoneCall?.({ activeChannel, conversationId });
7775
+ };
7776
+ const handleVideoCall = () => {
7777
+ features.onVideoCall?.({ activeChannel, conversationId });
7778
+ };
7699
7779
  const headerItemGapClass = "gap-0.5";
7700
7780
  const headerIconBtnClass = "inline-flex size-6 shrink-0 items-center justify-center rounded-lg p-0 text-(--chat-muted) transition-colors hover:bg-(--chat-hover) hover:text-(--chat-text) has-[>svg]:p-0";
7701
7781
  const headerCountBtnClass = "inline-flex h-7 shrink-0 items-center justify-center gap-0.5 rounded-lg px-1.5 text-(--chat-muted) transition-colors hover:bg-(--chat-hover) hover:text-(--chat-text)";
@@ -7753,26 +7833,18 @@ var HeaderRightSide = ({
7753
7833
  triggerClassName: headerIconBtnClass
7754
7834
  }
7755
7835
  ),
7756
- /* @__PURE__ */ jsxRuntime.jsx(
7757
- Button,
7758
- {
7759
- variant: "ghost",
7760
- size: "icon-xs",
7761
- className: cn(headerIconBtnClass, "hidden sm:inline-flex"),
7762
- "aria-label": "Voice call",
7763
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Phone, { size: 15 })
7764
- }
7765
- ),
7766
- /* @__PURE__ */ jsxRuntime.jsx(
7767
- Button,
7836
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "hidden sm:contents", children: /* @__PURE__ */ jsxRuntime.jsx(
7837
+ HeaderCallActions_default,
7768
7838
  {
7769
- variant: "ghost",
7770
- size: "icon-xs",
7771
- className: cn(headerIconBtnClass, "hidden sm:inline-flex"),
7772
- "aria-label": "Video call",
7773
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Video, { size: 15 })
7839
+ activeChannel,
7840
+ conversationId,
7841
+ showPhoneCall,
7842
+ showVideoCall,
7843
+ onPhoneCall: handlePhoneCall,
7844
+ onVideoCall: handleVideoCall,
7845
+ className: headerIconBtnClass
7774
7846
  }
7775
- ),
7847
+ ) }),
7776
7848
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: headerDividerClass, "aria-hidden": true }),
7777
7849
  /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
7778
7850
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "ghost", size: "icon-xs", className: headerIconBtnClass, "aria-label": "More options", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreVertical, { size: 15 }) }) }),
@@ -12910,6 +12982,7 @@ var ChannelHeaderView = (props) => {
12910
12982
  HeaderRightSideSlot,
12911
12983
  {
12912
12984
  activeChannel,
12985
+ conversationId,
12913
12986
  isAdmin,
12914
12987
  canViewMembers,
12915
12988
  pinnedCount,
@@ -17671,76 +17744,6 @@ var ChannelListItem2 = (props) => {
17671
17744
  return /* @__PURE__ */ jsxRuntime.jsx(ItemSlot, { ...props });
17672
17745
  };
17673
17746
  var ChannelListItem_default = ChannelListItem2;
17674
- var actionBtnClass = "size-8 rounded-lg text-(--chat-muted) transition-colors hover:bg-(--chat-surface) hover:text-(--chat-text)";
17675
- var DefaultHeaderCallActions = ({
17676
- activeChannel,
17677
- conversationId,
17678
- showPhoneCall = true,
17679
- showVideoCall = true,
17680
- onPhoneCall,
17681
- onVideoCall,
17682
- className
17683
- }) => {
17684
- const { components, slotClassName, features } = useChatCustomizationOptional();
17685
- const PhoneSlot = components.PhoneCallButton;
17686
- const VideoSlot = components.VideoCallButton;
17687
- const hideInGroups = features.hideCallActionsInGroupChats ?? false;
17688
- if (hideInGroups && activeChannel.isGroup) return null;
17689
- if (!showPhoneCall && !showVideoCall) return null;
17690
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
17691
- showPhoneCall && (PhoneSlot ? /* @__PURE__ */ jsxRuntime.jsx(
17692
- PhoneSlot,
17693
- {
17694
- activeChannel,
17695
- conversationId,
17696
- onPhoneCall,
17697
- className: cn(className, slotClassName("phoneCallButton"))
17698
- }
17699
- ) : /* @__PURE__ */ jsxRuntime.jsx(
17700
- Button,
17701
- {
17702
- variant: "ghost",
17703
- size: "icon",
17704
- className: cn(actionBtnClass, className, slotClassName("phoneCallButton")),
17705
- "aria-label": "Voice call",
17706
- onClick: onPhoneCall,
17707
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Phone, { size: 15 })
17708
- }
17709
- )),
17710
- showVideoCall && (VideoSlot ? /* @__PURE__ */ jsxRuntime.jsx(
17711
- VideoSlot,
17712
- {
17713
- activeChannel,
17714
- conversationId,
17715
- onVideoCall,
17716
- className: cn(className, slotClassName("videoCallButton"))
17717
- }
17718
- ) : /* @__PURE__ */ jsxRuntime.jsx(
17719
- Button,
17720
- {
17721
- variant: "ghost",
17722
- size: "icon",
17723
- className: cn(actionBtnClass, className, slotClassName("videoCallButton")),
17724
- "aria-label": "Video call",
17725
- onClick: onVideoCall,
17726
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Video, { size: 15 })
17727
- }
17728
- ))
17729
- ] });
17730
- };
17731
- var HeaderCallActions = (props) => {
17732
- const { components, slotClassName, features } = useChatCustomizationOptional();
17733
- const Custom = components.HeaderCallActions;
17734
- if (!Custom) {
17735
- const hideInGroups = features.hideCallActionsInGroupChats ?? false;
17736
- const showPhoneCall = props.showPhoneCall ?? true;
17737
- const showVideoCall = props.showVideoCall ?? true;
17738
- if (hideInGroups && props.activeChannel.isGroup) return null;
17739
- if (!showPhoneCall && !showVideoCall) return null;
17740
- }
17741
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: slotClassName("headerCallActions"), children: Custom ? /* @__PURE__ */ jsxRuntime.jsx(Custom, { ...props }) : /* @__PURE__ */ jsxRuntime.jsx(DefaultHeaderCallActions, { ...props }) });
17742
- };
17743
- var HeaderCallActions_default = HeaderCallActions;
17744
17747
 
17745
17748
  // src/chat/packageDefaultComponents.ts
17746
17749
  var packageDefaultComponents = {
@@ -17781,36 +17784,33 @@ var packageDefaultComponents = {
17781
17784
  init_client();
17782
17785
  var PUSH_TOKEN_STORAGE_KEY = "realtimex-push-token";
17783
17786
  var SERVICE_WORKER_PATH = "/firebase-messaging-sw.js";
17784
- var v2Url = (path) => {
17785
- const base = (exports.getChatBaseUrl() || String(apiClient.defaults.baseURL || "")).replace(/\/$/, "").replace(/\/v1$/, "/v2");
17786
- return `${base}${path}`;
17787
- };
17787
+ var v2Url = "https://realtimex.softwareco.com/api/v2";
17788
17788
  var apiGetPushConfig = async () => {
17789
- const { data } = await apiClient.get(v2Url("/notifications/push/config"));
17789
+ const { data } = await apiClient.get(`${v2Url}/notifications/push/config`);
17790
17790
  return data?.data;
17791
17791
  };
17792
17792
  var apiRegisterPushToken = async (token, deviceLabel) => {
17793
- const { data } = await apiClient.post(v2Url("/notifications/push/token"), {
17793
+ const { data } = await apiClient.post(`${v2Url}/notifications/push/token`, {
17794
17794
  token,
17795
17795
  deviceLabel
17796
17796
  });
17797
17797
  return data?.data;
17798
17798
  };
17799
17799
  var apiRemovePushToken = async (token) => {
17800
- const { data } = await apiClient.delete(v2Url("/notifications/push/token"), {
17800
+ const { data } = await apiClient.delete(`${v2Url}/notifications/push/token`, {
17801
17801
  data: { token }
17802
17802
  });
17803
17803
  return data;
17804
17804
  };
17805
17805
  var apiGetPushPreference = async () => {
17806
17806
  const { data } = await apiClient.get(
17807
- v2Url("/notifications/push/preference")
17807
+ `${v2Url}/notifications/push/preference`
17808
17808
  );
17809
17809
  return data?.data;
17810
17810
  };
17811
17811
  var apiUpdatePushPreference = async (enabled) => {
17812
17812
  const { data } = await apiClient.patch(
17813
- v2Url("/notifications/push/preference"),
17813
+ `${v2Url}/notifications/push/preference`,
17814
17814
  { enabled }
17815
17815
  );
17816
17816
  return data?.data;