@sawport/react-sdk 1.0.7 → 1.0.8-alpha.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.js CHANGED
@@ -110344,12 +110344,25 @@ const Detect = memo(({ onProceed, onCancel }) => /* @__PURE__ */ jsxRuntimeExpor
110344
110344
  /* @__PURE__ */ jsxRuntimeExports.jsx(FacePoseDetector$1, { onProceed, onCancel })
110345
110345
  ] }));
110346
110346
  const updateConversation = (id2, params) => api("conversations/" + id2, params, "put");
110347
+ class WidgetDomEvent {
110348
+ static broadcast(event, data2, target = "*") {
110349
+ const eventData = {
110350
+ type: event,
110351
+ ...data2
110352
+ };
110353
+ window.parent.postMessage(eventData, target);
110354
+ }
110355
+ }
110356
+ __publicField(WidgetDomEvent, "eventsNames", {
110357
+ WIDGET_LAUNCHED: "widget.launched"
110358
+ });
110347
110359
  function UnwrapWidget({
110348
110360
  user: companyUser_,
110349
110361
  projectId,
110350
110362
  launcherEnabled = true
110351
110363
  }) {
110352
110364
  var _a;
110365
+ const widgetCoverRef = useRef$1(null);
110353
110366
  const config = useSawportConfig();
110354
110367
  const companyUser = useMemo$1(() => companyUser_ || config.user, [companyUser_, config.user]);
110355
110368
  const { isWidgetLaunched, setIsWidgetLaunched } = useChatStore();
@@ -110392,6 +110405,14 @@ function UnwrapWidget({
110392
110405
  if ((_a2 = company == null ? void 0 : company.options) == null ? void 0 : _a2.language)
110393
110406
  Language.loadGoogleTranslate({ language: (_b = company == null ? void 0 : company.options) == null ? void 0 : _b.language });
110394
110407
  }, [(_a = company == null ? void 0 : company.options) == null ? void 0 : _a.language]);
110408
+ useEffect(() => {
110409
+ var _a2, _b;
110410
+ WidgetDomEvent.broadcast(WidgetDomEvent.eventsNames.WIDGET_LAUNCHED, {
110411
+ height: isWidgetLaunched ? 708 : (_a2 = widgetCoverRef.current) == null ? void 0 : _a2.clientHeight,
110412
+ width: isWidgetLaunched ? 410 : showTip ? 380 : (_b = widgetCoverRef.current) == null ? void 0 : _b.clientWidth,
110413
+ launched: isWidgetLaunched
110414
+ });
110415
+ }, [isWidgetLaunched, widgetCoverRef, showTip]);
110395
110416
  if (isLoadingCompany || isLoadingCompany === void 0) {
110396
110417
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Spin, {});
110397
110418
  }
@@ -110401,6 +110422,7 @@ function UnwrapWidget({
110401
110422
  "div",
110402
110423
  {
110403
110424
  id: "g-translate-widget",
110425
+ ref: widgetCoverRef,
110404
110426
  className: `widget-cover ${isWidgetLaunched ? "widget-cover-container" : ""}`,
110405
110427
  children: [
110406
110428
  isWidgetLaunched && /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -110558,16 +110580,6 @@ const WidgetFormDisplay = memo(
110558
110580
  (isScheduling2) => useChatStore.setState({ isScheduling: isScheduling2 }),
110559
110581
  []
110560
110582
  );
110561
- useEffect(() => {
110562
- window.parent.postMessage(
110563
- {
110564
- type: "widget.launched",
110565
- height: isWidgetLaunched ? 708 : void 0,
110566
- launched: isWidgetLaunched
110567
- },
110568
- "*"
110569
- );
110570
- }, [isWidgetLaunched]);
110571
110583
  const verificationVisible = !((_e = (_d = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _d.conversation) == null ? void 0 : _e.hasVerifiedFace) && ((_f = company == null ? void 0 : company.options) == null ? void 0 : _f.facialRecognitionEnabled);
110572
110584
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
110573
110585
  "div",