@sawport/react-sdk 1.2.5-beta.9 → 1.3.0-alpha.2

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.js CHANGED
@@ -104354,49 +104354,50 @@ Step 4: Click the blue "Join" button to start the meeting.`,
104354
104354
  /* @__PURE__ */ jsx(
104355
104355
  Tooltip2,
104356
104356
  {
104357
- title: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 min-w-[160px]", children: [
104357
+ title: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 min-w-[160px] bg-white rounded-lg", children: [
104358
104358
  /* @__PURE__ */ jsxs(
104359
104359
  "a",
104360
104360
  {
104361
- className: "flex items-center gap-2 px-3 py-2 rounded hover:bg-gray-100 transition",
104361
+ className: "flex items-center gap-2 px-3 py-2 rounded hover:bg-gray-100 transition text-gray-800",
104362
104362
  href: (_a = eventProviders.google) == null ? void 0 : _a.render(),
104363
104363
  target: "_blank",
104364
104364
  rel: "noreferrer",
104365
104365
  children: [
104366
104366
  /* @__PURE__ */ jsx(SvgGcal, { width: 22, height: 22 }),
104367
- /* @__PURE__ */ jsx("span", { className: "font-medium text-gray-800", children: "Google" })
104367
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: "Google" })
104368
104368
  ]
104369
104369
  }
104370
104370
  ),
104371
104371
  /* @__PURE__ */ jsxs(
104372
104372
  "a",
104373
104373
  {
104374
- className: "flex items-center gap-2 px-3 py-2 rounded hover:bg-gray-100 transition",
104374
+ className: "flex items-center gap-2 px-3 py-2 rounded hover:bg-gray-100 transition text-gray-800",
104375
104375
  href: (_b = eventProviders.yahoo) == null ? void 0 : _b.render(),
104376
104376
  target: "_blank",
104377
104377
  rel: "noreferrer",
104378
104378
  children: [
104379
104379
  /* @__PURE__ */ jsx(SvgYahoo, { width: 22, height: 22 }),
104380
- /* @__PURE__ */ jsx("span", { className: "font-medium text-gray-800", children: "Yahoo" })
104380
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: "Yahoo" })
104381
104381
  ]
104382
104382
  }
104383
104383
  ),
104384
104384
  /* @__PURE__ */ jsxs(
104385
104385
  "a",
104386
104386
  {
104387
- className: "flex items-center gap-2 px-3 py-2 rounded hover:bg-gray-100 transition",
104387
+ className: "flex items-center gap-2 px-3 py-2 rounded hover:bg-gray-100 transition text-gray-800",
104388
104388
  href: (_c = eventProviders.outlook) == null ? void 0 : _c.render(),
104389
104389
  target: "_blank",
104390
104390
  rel: "noreferrer",
104391
104391
  children: [
104392
104392
  /* @__PURE__ */ jsx(SvgOutlookCalendar, { width: 22, height: 22 }),
104393
- /* @__PURE__ */ jsx("span", { className: "font-medium text-gray-800", children: "Outlook" })
104393
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: "Outlook" })
104394
104394
  ]
104395
104395
  }
104396
104396
  )
104397
104397
  ] }),
104398
104398
  trigger: "click",
104399
- overlayClassName: "modern-calendar-tooltip",
104399
+ overlayStyle: { background: "transparent", boxShadow: "none" },
104400
+ overlayInnerStyle: { background: "transparent", padding: "0" },
104400
104401
  children: /* @__PURE__ */ jsx(
104401
104402
  Button,
104402
104403
  {
@@ -104409,7 +104410,7 @@ Step 4: Click the blue "Join" button to start the meeting.`,
104409
104410
  fontSize: 18,
104410
104411
  boxShadow: "0 2px 8px rgba(0,0,0,0.07)"
104411
104412
  },
104412
- className: "mt-2 p-6 border-none text-white shadow-lg hover:brightness-110 focus:outline-none focus:ring-2 focus:ring-blue-300 transition-all",
104413
+ className: "mt-2 p-6 border-none text-white shadow-lg focus:outline-none focus:ring-2 focus:ring-blue-300 transition-all",
104413
104414
  children: "Add to calendar"
104414
104415
  }
104415
104416
  )
@@ -105919,14 +105920,14 @@ function WidgetInitForm({
105919
105920
  {
105920
105921
  className: "bg-white font-bold text-gray-900",
105921
105922
  style: { padding: "2px 8px" },
105922
- children: String(key) === "bvn" ? "ID No" : fields[key].label || capitalizeFirstLetters(key)
105923
+ children: String(key) === "bvn" ? "ID No." : fields[key].label || capitalizeFirstLetters(key)
105923
105924
  }
105924
105925
  ) }) }),
105925
105926
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
105926
105927
  PhoneInput,
105927
105928
  {
105928
105929
  id: "phone-input",
105929
- placeholder: fields[key].placeholder || `Enter ${key}`,
105930
+ placeholder: String(key) === "bvn" ? "Enter ID No." : fields[key].placeholder || `Enter ${key}`,
105930
105931
  value: {
105931
105932
  phoneNumber: formik.values[key],
105932
105933
  countryCode: formik.values.calling_code || state.calling_code || ""
@@ -105956,7 +105957,7 @@ function WidgetInitForm({
105956
105957
  name: key,
105957
105958
  required: fields[key].required,
105958
105959
  type: fields[key].type,
105959
- placeholder: fields[key].placeholder || `Enter ${key}`,
105960
+ placeholder: String(key) === "bvn" ? "Enter ID No." : fields[key].placeholder || `Enter ${key}`,
105960
105961
  onChange: formik.handleChange,
105961
105962
  style: { borderRadius: 8, fontSize: 16 },
105962
105963
  onBlur: formik.handleBlur,
@@ -106671,16 +106672,12 @@ const FilePreview = memo(function({ file, onRemove }) {
106671
106672
  }, [file, onRemove]);
106672
106673
  return preview;
106673
106674
  });
106674
- function ChatWidgetScreen({
106675
- welcome_message,
106676
- callUtilsRef,
106677
- company,
106678
- isOngoingChat
106679
- }) {
106675
+ function ChatWidgetScreen({ welcome_message, company, isOngoingChat }) {
106680
106676
  var _a, _b, _c, _d, _e, _f, _g;
106681
106677
  const { dataRef, setChatClose, chatInit, chatClose } = useChatStore();
106682
106678
  const { socket: socket2 } = useSocket();
106683
106679
  const timeoutRef = useRef$1(null);
106680
+ const audioRef = useRef$1(new Audio());
106684
106681
  const [{ pdfModal, selectedPdfURL }, setPDFstate] = useState({
106685
106682
  pdfModal: false,
106686
106683
  selectedPdfURL: ""
@@ -106724,25 +106721,32 @@ function ChatWidgetScreen({
106724
106721
  [`message.new.${(_a2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _a2.conversation.id}`]: async ({
106725
106722
  message
106726
106723
  }) => {
106727
- var _a3, _b3, _c3, _d3, _e3, _f2, _g2, _h;
106724
+ var _a3, _b3, _c3, _d3, _e3, _f2, _g2;
106728
106725
  const sender = ((_a3 = message.user) == null ? void 0 : _a3.id) || message.user;
106729
106726
  const customer = dataRef == null ? void 0 : dataRef.customer;
106730
106727
  const isSender = ((_b3 = customer == null ? void 0 : customer.user) == null ? void 0 : _b3.id) === (((_c3 = message.user) == null ? void 0 : _c3.id) || message.user);
106731
106728
  message.isSender = isSender;
106732
- if (!isSender)
106733
- (_d3 = callUtilsRef.current) == null ? void 0 : _d3.playSound(
106734
- messageSound,
106735
- (sound) => sound.loop = false
106736
- );
106729
+ if (!isSender) {
106730
+ try {
106731
+ const audio = audioRef.current;
106732
+ audio.src = messageSound;
106733
+ audio.loop = false;
106734
+ audio.play().catch((err) => {
106735
+ console.warn("Message sound autoplay prevented:", err);
106736
+ });
106737
+ } catch (err) {
106738
+ console.error("Error playing message sound:", err);
106739
+ }
106740
+ }
106737
106741
  setState((s2) => {
106738
106742
  s2.data.data.unshift(message);
106739
106743
  return s2;
106740
106744
  });
106741
- if (sender !== ((_e3 = customer == null ? void 0 : customer.user) == null ? void 0 : _e3.id)) {
106745
+ if (sender !== ((_d3 = customer == null ? void 0 : customer.user) == null ? void 0 : _d3.id)) {
106742
106746
  t.emit("agent-joined", message.user);
106743
106747
  }
106744
106748
  if (!isSender) {
106745
- readConversation((_g2 = (_f2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _f2.conversation) == null ? void 0 : _g2.id, (_h = message.user) == null ? void 0 : _h.id);
106749
+ readConversation((_f2 = (_e3 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _e3.conversation) == null ? void 0 : _f2.id, (_g2 = message.user) == null ? void 0 : _g2.id);
106746
106750
  }
106747
106751
  },
106748
106752
  [`message.updated.${(_b2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _b2.conversation.id}`]: async ({
@@ -120725,7 +120729,7 @@ const VideoChat = ({
120725
120729
  ]
120726
120730
  }
120727
120731
  ),
120728
- useGrid ? /* @__PURE__ */ jsx(VideoGrid, { participants }) : /* @__PURE__ */ jsxs(Fragment, { children: [
120732
+ useGrid ? /* @__PURE__ */ jsx(VideoGrid, { participants, userId }) : /* @__PURE__ */ jsxs(Fragment, { children: [
120729
120733
  /* @__PURE__ */ jsx(RemoteVideo, { remoteParticipant }),
120730
120734
  /* @__PURE__ */ jsx(LocalVideo, { localParticipant, screenShared })
120731
120735
  ] }),
@@ -120806,7 +120810,7 @@ const LocalVideo = ({ localParticipant, screenShared }) => {
120806
120810
  playsInline: true
120807
120811
  }
120808
120812
  ),
120809
- localParticipant && /* @__PURE__ */ jsx("span", { className: "absolute bottom-2 left-2 text-white text-xs bg-black/40 px-2 py-1 rounded z-10", children: getParticipantDisplayName(localParticipant) || "You" })
120813
+ localParticipant && /* @__PURE__ */ jsx("span", { className: "absolute bottom-2 left-2 text-white text-xs bg-black/40 px-2 py-1 rounded z-10", children: "You" })
120810
120814
  ] });
120811
120815
  };
120812
120816
  const VideoOffCard = ({ className, style: style2 }) => /* @__PURE__ */ jsx(
@@ -120826,7 +120830,8 @@ const ActionBtn = ({ children, ...props }) => /* @__PURE__ */ jsx(
120826
120830
  children
120827
120831
  }
120828
120832
  );
120829
- const VideoGrid = ({ participants }) => {
120833
+ const VideoGrid = ({ participants, userId }) => {
120834
+ var _a;
120830
120835
  const agent = participants.find((p2) => p2.user.user_type === "agent");
120831
120836
  const others = participants.filter((p2) => p2.user.user_type !== "agent");
120832
120837
  if (participants.length === 4) {
@@ -120842,8 +120847,15 @@ const VideoGrid = ({ participants }) => {
120842
120847
  padding: "0px"
120843
120848
  },
120844
120849
  children: participants.slice(0, 4).map((participant) => {
120845
- var _a;
120846
- return /* @__PURE__ */ jsx(VideoTile, { participant }, (_a = participant == null ? void 0 : participant.user) == null ? void 0 : _a.id);
120850
+ var _a2, _b;
120851
+ return /* @__PURE__ */ jsx(
120852
+ VideoTile,
120853
+ {
120854
+ participant,
120855
+ isLocal: ((_a2 = participant == null ? void 0 : participant.user) == null ? void 0 : _a2.id) === String(userId)
120856
+ },
120857
+ (_b = participant == null ? void 0 : participant.user) == null ? void 0 : _b.id
120858
+ );
120847
120859
  })
120848
120860
  }
120849
120861
  );
@@ -120858,7 +120870,7 @@ const VideoGrid = ({ participants }) => {
120858
120870
  padding: "0px"
120859
120871
  },
120860
120872
  children: [
120861
- agent && /* @__PURE__ */ jsx("div", { style: { flex: "1", minWidth: 0 }, children: /* @__PURE__ */ jsx(VideoTile, { participant: agent }) }),
120873
+ agent && /* @__PURE__ */ jsx("div", { style: { flex: "1", minWidth: 0 }, children: /* @__PURE__ */ jsx(VideoTile, { participant: agent, isLocal: ((_a = agent == null ? void 0 : agent.user) == null ? void 0 : _a.id) === String(userId) }) }),
120862
120874
  others.length > 0 && /* @__PURE__ */ jsx(
120863
120875
  "div",
120864
120876
  {
@@ -120870,8 +120882,14 @@ const VideoGrid = ({ participants }) => {
120870
120882
  gap: "0px"
120871
120883
  },
120872
120884
  children: others.map((participant) => {
120873
- var _a;
120874
- return /* @__PURE__ */ jsx("div", { style: { flex: "1", minHeight: 0 }, children: /* @__PURE__ */ jsx(VideoTile, { participant }) }, (_a = participant.user) == null ? void 0 : _a.id);
120885
+ var _a2, _b;
120886
+ return /* @__PURE__ */ jsx("div", { style: { flex: "1", minHeight: 0 }, children: /* @__PURE__ */ jsx(
120887
+ VideoTile,
120888
+ {
120889
+ participant,
120890
+ isLocal: ((_a2 = participant == null ? void 0 : participant.user) == null ? void 0 : _a2.id) === String(userId)
120891
+ }
120892
+ ) }, (_b = participant.user) == null ? void 0 : _b.id);
120875
120893
  })
120876
120894
  }
120877
120895
  ),
@@ -120885,8 +120903,15 @@ const VideoGrid = ({ participants }) => {
120885
120903
  gridAutoRows: "1fr"
120886
120904
  },
120887
120905
  children: participants.slice(0, 4).map((participant) => {
120888
- var _a;
120889
- return /* @__PURE__ */ jsx(VideoTile, { participant }, (_a = participant.user) == null ? void 0 : _a.id);
120906
+ var _a2, _b;
120907
+ return /* @__PURE__ */ jsx(
120908
+ VideoTile,
120909
+ {
120910
+ participant,
120911
+ isLocal: ((_a2 = participant == null ? void 0 : participant.user) == null ? void 0 : _a2.id) === String(userId)
120912
+ },
120913
+ (_b = participant.user) == null ? void 0 : _b.id
120914
+ );
120890
120915
  })
120891
120916
  }
120892
120917
  )
@@ -120894,7 +120919,7 @@ const VideoGrid = ({ participants }) => {
120894
120919
  }
120895
120920
  );
120896
120921
  };
120897
- const VideoTile = ({ participant }) => {
120922
+ const VideoTile = ({ participant, isLocal: isLocal2 }) => {
120898
120923
  const ref2 = useRef$1(null);
120899
120924
  useEffect(() => {
120900
120925
  if (ref2.current && (participant == null ? void 0 : participant.stream)) {
@@ -120906,7 +120931,7 @@ const VideoTile = ({ participant }) => {
120906
120931
  return /* @__PURE__ */ jsxs("div", { className: "relative rounded overflow-hidden bg-black", style: { height: "100%" }, children: [
120907
120932
  !(participant == null ? void 0 : participant.videoOn) && !(participant == null ? void 0 : participant.screenSharing) && /* @__PURE__ */ jsx(VideoOffCard, { className: "border-0" }),
120908
120933
  /* @__PURE__ */ jsx("video", { ref: ref2, autoPlay: true, playsInline: true, className: "w-full h-full object-cover" }),
120909
- /* @__PURE__ */ jsx("span", { className: "absolute bottom-2 left-2 text-white text-xs bg-black/40 px-2 py-1 rounded", children: getParticipantDisplayName(participant) })
120934
+ /* @__PURE__ */ jsx("span", { className: "absolute bottom-2 left-2 text-white text-xs bg-black/40 px-2 py-1 rounded", children: isLocal2 ? "You" : getParticipantDisplayName(participant) })
120910
120935
  ] });
120911
120936
  };
120912
120937
  const IncomingVideoCallModal = memo(
@@ -127178,7 +127203,6 @@ const WidgetFormDisplay = memo(
127178
127203
  companyUser,
127179
127204
  setIsScheduling,
127180
127205
  company,
127181
- callUtilsRef,
127182
127206
  customer
127183
127207
  }
127184
127208
  ) }),
@@ -127195,7 +127219,6 @@ const ChatMode = memo(
127195
127219
  companyUser,
127196
127220
  setIsScheduling,
127197
127221
  company,
127198
- callUtilsRef,
127199
127222
  customer
127200
127223
  }) => {
127201
127224
  var _a, _b;
@@ -127240,10 +127263,10 @@ const ChatMode = memo(
127240
127263
  options: (company == null ? void 0 : company.options) || {},
127241
127264
  customer
127242
127265
  }
127243
- ) : /* @__PURE__ */ jsx(ChatScreen, { callUtilsRef, company, isOngoingChat });
127266
+ ) : /* @__PURE__ */ jsx(ChatScreen, { company, isOngoingChat });
127244
127267
  }
127245
127268
  );
127246
- const ChatScreen = memo(({ company, callUtilsRef, isOngoingChat }) => {
127269
+ const ChatScreen = memo(({ company, isOngoingChat }) => {
127247
127270
  var _a, _b, _c;
127248
127271
  const { dataRef, setHasVerifiedFace } = useChatStore();
127249
127272
  const hasVerifiedFace = (_b = (_a = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _a.conversation) == null ? void 0 : _b.hasVerifiedFace;
@@ -127265,7 +127288,6 @@ const ChatScreen = memo(({ company, callUtilsRef, isOngoingChat }) => {
127265
127288
  ChatWidgetScreen$1,
127266
127289
  {
127267
127290
  welcome_message: company == null ? void 0 : company.welcome_message,
127268
- callUtilsRef,
127269
127291
  company,
127270
127292
  isOngoingChat
127271
127293
  }