@opencx/widget-react 4.0.43 → 4.0.44

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
@@ -2,7 +2,7 @@ import { jsx as r, jsxs as c, Fragment as re } from "react/jsx-runtime";
2
2
  import * as ce from "@radix-ui/react-popover";
3
3
  import * as G from "react";
4
4
  import U, { memo as $t, forwardRef as dt, useState as T, cloneElement as pt, createContext as Bt, useEffect as oe, useContext as Yt, useMemo as ht, useRef as de, createElement as ot } from "react";
5
- import { useWidget as j, useConfig as b, useSessions as $, useMessages as E, useWidgetRouter as A, useDocumentDir as ve, useWidgetTrigger as K, useModes as mt, useCsat as gt, useUploadFiles as Ut, useIsAwaitingBotReply as wt, useContact as qt, WidgetProvider as Xt, WidgetTriggerProvider as Vt } from "@opencx/widget-react-headless";
5
+ import { useWidget as j, useConfig as b, useSessions as L, useMessages as E, useWidgetRouter as A, useDocumentDir as ve, useWidgetTrigger as K, useModes as mt, useCsat as gt, useUploadFiles as Ut, useIsAwaitingBotReply as wt, useContact as qt, WidgetProvider as Xt, WidgetTriggerProvider as Vt } from "@opencx/widget-react-headless";
6
6
  import { clsx as Gt } from "clsx";
7
7
  import { twMerge as Kt } from "tailwind-merge";
8
8
  import { motion as J, AnimatePresence as _ } from "framer-motion";
@@ -29,7 +29,7 @@ function p(...e) {
29
29
  const V = {
30
30
  x: 2,
31
31
  y: 2
32
- }, L = $t(
32
+ }, Y = $t(
33
33
  dt(
34
34
  ({ children: e, className: o, scale: t = 1.02, off: n = !1 }, s) => {
35
35
  const [i, a] = T(!1), [l, d] = T({ x: 0, y: 0 });
@@ -78,7 +78,7 @@ const V = {
78
78
  }
79
79
  )
80
80
  );
81
- L.displayName = "Wobble";
81
+ Y.displayName = "Wobble";
82
82
  const Er = 10, Rr = (e, o, t) => ({
83
83
  initial: { opacity: 0, x: -e, ...o.initial },
84
84
  animate: { opacity: 1, x: 0, ...o.animate, transition: { delay: t } },
@@ -155,7 +155,7 @@ const Hr = Zt(
155
155
  }
156
156
  }
157
157
  ), C = G.forwardRef(
158
- ({ className: e, variant: o = "default", size: t, asChild: n = !1, ...s }, i) => /* @__PURE__ */ r(L, { ref: i, children: /* @__PURE__ */ r(
158
+ ({ className: e, variant: o = "default", size: t, asChild: n = !1, ...s }, i) => /* @__PURE__ */ r(Y, { ref: i, children: /* @__PURE__ */ r(
159
159
  n ? Qt : "button",
160
160
  {
161
161
  ...g("ui_lib/btn"),
@@ -321,13 +321,13 @@ function It({
321
321
  }
322
322
  function Tt({ attachment: e }) {
323
323
  const { name: o, size: t, type: n, url: s } = e, i = n.startsWith("image/"), a = n.startsWith("video/"), l = n.startsWith("audio/");
324
- return l ? /* @__PURE__ */ r(L, { children: /* @__PURE__ */ r("div", { className: "w-full shrink-0 overflow-hidden", children: /* @__PURE__ */ c("audio", { controls: !0, className: "w-full", children: [
324
+ return l ? /* @__PURE__ */ r(Y, { children: /* @__PURE__ */ r("div", { className: "w-full shrink-0 overflow-hidden", children: /* @__PURE__ */ c("audio", { controls: !0, className: "w-full", children: [
325
325
  /* @__PURE__ */ r("source", { src: s, type: n }),
326
326
  "Your browser does not support the audio tag."
327
- ] }) }) }) : a ? /* @__PURE__ */ r(L, { children: /* @__PURE__ */ r("div", { className: "w-full border shrink-0 rounded-2xl overflow-hidden", children: /* @__PURE__ */ c("video", { controls: !0, children: [
327
+ ] }) }) }) : a ? /* @__PURE__ */ r(Y, { children: /* @__PURE__ */ r("div", { className: "w-full border shrink-0 rounded-2xl overflow-hidden", children: /* @__PURE__ */ c("video", { controls: !0, children: [
328
328
  /* @__PURE__ */ r("source", { src: s, type: n }),
329
329
  "Your browser does not support the video tag."
330
- ] }) }) }) : !i && !a && !l ? /* @__PURE__ */ r(L, { children: /* @__PURE__ */ r("div", { className: "size-fit border shrink-0 rounded-2xl overflow-hidden", children: /* @__PURE__ */ c("div", { className: "flex items-end gap-2 p-2", children: [
330
+ ] }) }) }) : !i && !a && !l ? /* @__PURE__ */ r(Y, { children: /* @__PURE__ */ r("div", { className: "size-fit border shrink-0 rounded-2xl overflow-hidden", children: /* @__PURE__ */ c("div", { className: "flex items-end gap-2 p-2", children: [
331
331
  /* @__PURE__ */ r(
332
332
  "a",
333
333
  {
@@ -349,7 +349,7 @@ function Tt({ attachment: e }) {
349
349
  ] }) }) }) : /* @__PURE__ */ r(
350
350
  It,
351
351
  {
352
- trigger: /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r(L, { children: /* @__PURE__ */ r("div", { className: "size-fit border shrink-0 rounded-2xl overflow-hidden", children: i && /* @__PURE__ */ r("img", { src: s, className: "object-cover size-16", alt: o }) }) }) }),
352
+ trigger: /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r(Y, { children: /* @__PURE__ */ r("div", { className: "size-fit border shrink-0 rounded-2xl overflow-hidden", children: i && /* @__PURE__ */ r("img", { src: s, className: "object-cover size-16", alt: o }) }) }) }),
353
353
  children: /* @__PURE__ */ r(
354
354
  kt,
355
355
  {
@@ -390,7 +390,7 @@ function Z() {
390
390
  widgetCtx: { org: e }
391
391
  } = j(), {
392
392
  sessionState: { session: o }
393
- } = $(), t = b(), {
393
+ } = L(), t = b(), {
394
394
  messagesState: { messages: n }
395
395
  } = E(), {
396
396
  routerState: { screen: s }
@@ -593,8 +593,8 @@ const ae = {
593
593
  transitionDuration: "1000ms"
594
594
  };
595
595
  function q() {
596
- var x, m, z, w, k, I, f, M, O, H, W, R, v, N, S, B, se, _e, Ie, Te, Me, De, je, Ee, Re, Pe, Ae, Fe, Oe, He, We, Le, $e, Be, Ye, Ue, qe, Xe, Ve, Ge, Ke, Qe, Ze, Je, et, tt, rt;
597
- const { dir: e } = ve(), { isSmallScreen: o } = F(), { theme: t, inline: n } = b(), s = (Y) => n ? "100%" : Y, i = (Y, he) => o ? `100dv${Y}` : he, a = (Y, he) => s(i(Y, he)), l = {
596
+ var x, m, z, w, k, I, f, M, O, H, W, R, v, N, S, $, se, _e, Ie, Te, Me, De, je, Ee, Re, Pe, Ae, Fe, Oe, He, We, Le, $e, Be, Ye, Ue, qe, Xe, Ve, Ge, Ke, Qe, Ze, Je, et, tt, rt;
597
+ const { dir: e } = ve(), { isSmallScreen: o } = F(), { theme: t, inline: n } = b(), s = (B) => n ? "100%" : B, i = (B, he) => o ? `100dv${B}` : he, a = (B, he) => s(i(B, he)), l = {
598
598
  zIndex: ((x = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : x.zIndex) ?? 1e7,
599
599
  offset: {
600
600
  bottom: ((z = (m = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : m.offset) == null ? void 0 : z.bottom) ?? 20,
@@ -606,8 +606,8 @@ function q() {
606
606
  icon: ((W = (H = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : H.size) == null ? void 0 : W.icon) ?? 24
607
607
  }
608
608
  }, d = (() => {
609
- const Y = e === "ltr" ? l.offset.right : l.offset.left;
610
- return typeof Y != "number" ? 0 : Y;
609
+ const B = e === "ltr" ? l.offset.right : l.offset.left;
610
+ return typeof B != "number" ? 0 : B;
611
611
  })(), h = {
612
612
  palette: (t == null ? void 0 : t.palette) ?? "neutral",
613
613
  primaryColor: (t == null ? void 0 : t.primaryColor) ?? "hsl(0 0% 9%)",
@@ -618,7 +618,7 @@ function q() {
618
618
  outline: ((N = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : N.outline) ?? "none",
619
619
  // was: '1px solid'
620
620
  outlineColor: ((S = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : S.outlineColor) ?? "hsl(0 0% 50% / .5)",
621
- boxShadow: ((B = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : B.boxShadow) ?? "0 0px 100px 0px rgb(0 0 0 / 0.25)",
621
+ boxShadow: (($ = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : $.boxShadow) ?? "0 0px 100px 0px rgb(0 0 0 / 0.25)",
622
622
  transitionProperty: ((se = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : se.transitionProperty) ?? "all",
623
623
  transitionTimingFunction: ((_e = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : _e.transitionTimingFunction) ?? ae.transitionTimingFunction,
624
624
  transitionDuration: ((Ie = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : Ie.transitionDuration) ?? ae.transitionDuration,
@@ -992,7 +992,7 @@ function Pt({
992
992
  button: e
993
993
  }) {
994
994
  var k, I;
995
- const { close: o } = pe(), { widgetCtx: t } = j(), { setIsOpen: n } = K(), { resolveSession: s, sessionState: i } = $(), { isSmallScreen: a } = F(), l = !i.session, d = ((k = i.session) == null ? void 0 : k.isOpened) === !1, h = e.onResolved || "stay-in-chat", y = e.behaviorBeforeSessionCreation || "disabled", x = e.behaviorIfSessionIsResolved || "disabled", m = !!(i.isResolvingSession || l && y === "disabled" || d && x === "disabled"), z = async () => {
995
+ const { close: o } = pe(), { widgetCtx: t } = j(), { setIsOpen: n } = K(), { resolveSession: s, sessionState: i } = L(), { isSmallScreen: a } = F(), l = !i.session, d = ((k = i.session) == null ? void 0 : k.isOpened) === !1, h = e.onResolved || "stay-in-chat", y = e.behaviorBeforeSessionCreation || "disabled", x = e.behaviorIfSessionIsResolved || "disabled", m = !!(i.isResolvingSession || l && y === "disabled" || d && x === "disabled"), z = async () => {
996
996
  const { success: f, error: M } = await s();
997
997
  if (o(), !f) return console.error(M);
998
998
  switch (h) {
@@ -1165,7 +1165,7 @@ function ro() {
1165
1165
  };
1166
1166
  }
1167
1167
  function oo() {
1168
- const e = Z(), { activeMode: o, Component: t } = mt(), { sendMessage: n } = E(), { createStateCheckpoint: s } = $(), [i, a] = T(!1), l = async (d) => {
1168
+ const e = Z(), { activeMode: o, Component: t } = mt(), { sendMessage: n } = E(), { createStateCheckpoint: s } = L(), [i, a] = T(!1), l = async (d) => {
1169
1169
  try {
1170
1170
  a(!0), await n(d);
1171
1171
  } catch (h) {
@@ -1369,7 +1369,7 @@ function ao() {
1369
1369
  );
1370
1370
  }
1371
1371
  function it() {
1372
- const { sessionState: e } = $(), { chatFooterItems: o } = b(), t = !!e.session && !e.session.isOpened, n = !t;
1372
+ const { sessionState: e } = L(), { chatFooterItems: o } = b(), t = !!e.session && !e.session.isOpened, n = !t;
1373
1373
  return /* @__PURE__ */ r(_, { mode: "wait", children: o == null ? void 0 : o.map((s, i) => s.showWhenSessionIsOpen === !1 && n || s.showWhenSessionIsResolved === !1 && t ? null : /* @__PURE__ */ r(P, { children: /* @__PURE__ */ r("div", { className: "pb-2 text-center text-xs", children: /* @__PURE__ */ r(be, { children: s.message }) }) }, `${s.message}-${i}`)) });
1374
1374
  }
1375
1375
  function io({
@@ -1445,7 +1445,7 @@ function io({
1445
1445
  }
1446
1446
  function lo() {
1447
1447
  var R;
1448
- const { isSmallScreen: e } = F(), o = de(null), { sendMessage: t } = E(), { sessionState: n } = $(), { t: s } = X(), [i, a] = T(""), {
1448
+ const { isSmallScreen: e } = F(), o = de(null), { sendMessage: t } = E(), { sessionState: n } = L(), { t: s } = X(), [i, a] = T(""), {
1449
1449
  allFiles: l,
1450
1450
  emptyTheFiles: d,
1451
1451
  handleCancelUpload: h,
@@ -1607,7 +1607,7 @@ function lo() {
1607
1607
  );
1608
1608
  }
1609
1609
  function lt() {
1610
- const { widgetCtx: e } = j(), { router: o } = b(), { canCreateNewSession: t } = $(), { toSessionsScreen: n } = A(), { t: s } = X();
1610
+ const { widgetCtx: e } = j(), { router: o } = b(), { canCreateNewSession: t } = L(), { toSessionsScreen: n } = A(), { t: s } = X();
1611
1611
  return /* @__PURE__ */ r(re, { children: t || o != null && o.chatScreenOnly ? /* @__PURE__ */ r(C, { onClick: e.resetChat, className: "rounded-2xl w-full", children: s("new_conversation") }) : /* @__PURE__ */ r(C, { onClick: n, className: "rounded-2xl w-full", children: s("back_to_conversations") }) });
1612
1612
  }
1613
1613
  function co() {
@@ -1625,7 +1625,7 @@ function co() {
1625
1625
  }
1626
1626
  function po() {
1627
1627
  var a;
1628
- const { initialQuestions: e, initialQuestionsPosition: o, thisWasHelpfulOrNot: t } = b(), { sessionState: n } = $(), { messagesState: s } = E(), i = s.messages.length === 0;
1628
+ const { initialQuestions: e, initialQuestionsPosition: o, thisWasHelpfulOrNot: t } = b(), { sessionState: n } = L(), { messagesState: s } = E(), i = s.messages.length === 0;
1629
1629
  return /* @__PURE__ */ r("footer", { children: /* @__PURE__ */ r(_, { mode: "wait", children: n.session && !((a = n.session) != null && a.isOpened) ? /* @__PURE__ */ c(P, { children: [
1630
1630
  /* @__PURE__ */ r(co, {}),
1631
1631
  /* @__PURE__ */ r(it, {})
@@ -2021,7 +2021,7 @@ function No() {
2021
2021
  messagesState: { isInitialFetchLoading: e }
2022
2022
  } = E(), {
2023
2023
  sessionState: { session: o }
2024
- } = $(), { isCanvasOpen: t } = ro(), { theme: n } = q();
2024
+ } = L(), { isCanvasOpen: t } = ro(), { theme: n } = q();
2025
2025
  ze({
2026
2026
  width: t ? n.screens.chat.withCanvas.width : n.screens.chat.width,
2027
2027
  height: t ? n.screens.chat.withCanvas.height : n.screens.chat.height
@@ -2139,7 +2139,7 @@ function Ht({ className: e }) {
2139
2139
  "flex items-center justify-center gap-2 p-2 pt-0",
2140
2140
  e
2141
2141
  ),
2142
- children: /* @__PURE__ */ r(L, { children: /* @__PURE__ */ c(
2142
+ children: /* @__PURE__ */ r(Y, { children: /* @__PURE__ */ c(
2143
2143
  "a",
2144
2144
  {
2145
2145
  href: `https://open.cx/?ref=${o}`,
@@ -2211,7 +2211,7 @@ function To() {
2211
2211
  openSessions: s,
2212
2212
  closedSessions: i,
2213
2213
  canCreateNewSession: a
2214
- } = $();
2214
+ } = L();
2215
2215
  return /* @__PURE__ */ r("div", { className: "flex-1 flex flex-col overflow-scroll py-2 px-2", children: /* @__PURE__ */ r(_, { mode: "wait", children: n ? /* @__PURE__ */ r(
2216
2216
  u,
2217
2217
  {
@@ -2317,9 +2317,10 @@ function Mo() {
2317
2317
  const ie = G.forwardRef(
2318
2318
  ({ className: e, type: o, ...t }, n) => {
2319
2319
  const { isSmallScreen: s } = F();
2320
- return /* @__PURE__ */ r(L, { ref: n, children: /* @__PURE__ */ r(
2320
+ return /* @__PURE__ */ r(
2321
2321
  "input",
2322
2322
  {
2323
+ ref: n,
2323
2324
  type: o,
2324
2325
  className: p(
2325
2326
  // 16px on mobiles prevents auto-zoom on the input when focused
@@ -2331,7 +2332,7 @@ const ie = G.forwardRef(
2331
2332
  ),
2332
2333
  ...t
2333
2334
  }
2334
- ) });
2335
+ );
2335
2336
  }
2336
2337
  );
2337
2338
  ie.displayName = "Input";
@@ -2375,11 +2376,11 @@ function Eo() {
2375
2376
  ), [z, w] = T({}), [k, I] = jr(
2376
2377
  async (S) => {
2377
2378
  S.preventDefault();
2378
- const B = jo.safeParse({ name: d, email: y });
2379
- B.success && await t(
2379
+ const $ = jo.safeParse({ name: d, email: y });
2380
+ $.success && await t(
2380
2381
  {
2381
- email: B.data.email,
2382
- non_verified_name: B.data.name
2382
+ email: $.data.email,
2383
+ non_verified_name: $.data.name
2383
2384
  },
2384
2385
  // Only pass extra data if there is any
2385
2386
  Object.values(z).filter(Boolean).length ? z : void 0
@@ -2472,9 +2473,9 @@ function Eo() {
2472
2473
  ie,
2473
2474
  {
2474
2475
  value: z[S],
2475
- onChange: (B) => w((se) => ({
2476
+ onChange: ($) => w((se) => ({
2476
2477
  ...se,
2477
- [S]: B.target.value
2478
+ [S]: $.target.value
2478
2479
  })),
2479
2480
  placeholder: `${S} (${a("optional")})`
2480
2481
  },
@@ -2547,7 +2548,7 @@ function Wt() {
2547
2548
  }
2548
2549
  })() }) });
2549
2550
  }
2550
- const Ro = "4.0.43", Po = `<!DOCTYPE html>
2551
+ const Ro = "4.0.44", Po = `<!DOCTYPE html>
2551
2552
  <html>
2552
2553
  <head>
2553
2554
  <style>
@@ -2768,7 +2769,7 @@ function Ho() {
2768
2769
  height: n.widgetTrigger.size.button,
2769
2770
  width: n.widgetTrigger.size.button
2770
2771
  },
2771
- children: /* @__PURE__ */ r(L, { children: /* @__PURE__ */ r(
2772
+ children: /* @__PURE__ */ r(Y, { children: /* @__PURE__ */ r(
2772
2773
  "div",
2773
2774
  {
2774
2775
  ...g("trigger/btn"),