@opencx/widget-react 4.0.15 → 4.0.16
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -47
- package/dist/index.js.map +1 -1
- package/dist/src/components/special-components/SessionResolvedComponent.d.ts +3 -0
- package/dist/src/components/special-components/SessionResolvedComponent.d.ts.map +1 -0
- package/dist/src/screens/chat/ChatMain.d.ts.map +1 -1
- package/dist-embed/script.js +8 -8
- package/dist-embed/script.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as o, jsxs as d, Fragment as te } from "react/jsx-runtime";
|
|
|
2
2
|
import * as ie from "@radix-ui/react-popover";
|
|
3
3
|
import * as G from "react";
|
|
4
4
|
import $, { memo as Bt, forwardRef as it, useState as I, cloneElement as lt, createContext as Lt, useEffect as oe, useContext as Yt, useMemo as ct, useRef as le, createElement as tt } from "react";
|
|
5
|
-
import { useWidget as
|
|
5
|
+
import { useWidget as j, useConfig as x, useDocumentDir as we, useWidgetRouter as B, useWidgetTrigger as K, useSessions as q, useMessages as R, useModes as dt, useCsat as pt, useUploadFiles as $t, useIsAwaitingBotReply as ht, useContact as qt, WidgetProvider as Ut, WidgetTriggerProvider as Vt } from "@opencx/widget-react-headless";
|
|
6
6
|
import { clsx as Xt } from "clsx";
|
|
7
7
|
import { twMerge as Gt } from "tailwind-merge";
|
|
8
8
|
import { motion as Q, AnimatePresence as S } from "framer-motion";
|
|
@@ -44,8 +44,8 @@ const X = {
|
|
|
44
44
|
), W = Math.max(
|
|
45
45
|
-1,
|
|
46
46
|
Math.min(1, A / (_.height / 2))
|
|
47
|
-
),
|
|
48
|
-
l({ x:
|
|
47
|
+
), E = P * X.x, v = W * X.y;
|
|
48
|
+
l({ x: E, y: v }), (z = (C = e.props).onMouseMove) == null || z.call(C, f);
|
|
49
49
|
}, w = () => {
|
|
50
50
|
var f, N;
|
|
51
51
|
a(!0), (N = (f = e.props).onMouseEnter) == null || N.call(f);
|
|
@@ -198,7 +198,7 @@ function ce() {
|
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
200
|
function Ho() {
|
|
201
|
-
const { contentIframeRef: e } =
|
|
201
|
+
const { contentIframeRef: e } = j(), { isOpen: r, content: t, close: n } = ce();
|
|
202
202
|
return oe(() => {
|
|
203
203
|
var i, a;
|
|
204
204
|
const s = (c) => {
|
|
@@ -561,7 +561,7 @@ const se = {
|
|
|
561
561
|
transitionDuration: "1000ms"
|
|
562
562
|
};
|
|
563
563
|
function U() {
|
|
564
|
-
var w, m, k, f, N, T, _, M, A, P, W,
|
|
564
|
+
var w, m, k, f, N, T, _, M, A, P, W, E, v, C, z, L, ne, Ne, Se, _e, Ie, Te, Me, De, je, Ee, Re, Oe, Ae, Pe, We, He, Fe, Be, Le, Ye, $e, qe, Ue, Ve, Xe, Ge, Ke, Ze, Qe, Je, et;
|
|
565
565
|
const { dir: e } = we(), { isSmallScreen: r } = O(), { theme: t, inline: n } = x(), s = (Y) => n ? "100%" : Y, i = (Y, de) => r ? `100dv${Y}` : de, a = (Y, de) => s(i(Y, de)), c = {
|
|
566
566
|
zIndex: ((w = t == null ? void 0 : t.widgetTrigger) == null ? void 0 : w.zIndex) ?? 1e7,
|
|
567
567
|
offset: {
|
|
@@ -581,7 +581,7 @@ function U() {
|
|
|
581
581
|
primaryColor: (t == null ? void 0 : t.primaryColor) ?? "hsl(0 0% 9%)",
|
|
582
582
|
widgetTrigger: c,
|
|
583
583
|
widgetContentContainer: {
|
|
584
|
-
borderRadius: r ? "0px" : ((
|
|
584
|
+
borderRadius: r ? "0px" : ((E = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : E.borderRadius) ?? "32px",
|
|
585
585
|
zIndex: ((v = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : v.zIndex) ?? c.zIndex + 1,
|
|
586
586
|
outline: ((C = t == null ? void 0 : t.widgetContentContainer) == null ? void 0 : C.outline) ?? "none",
|
|
587
587
|
// was: '1px solid'
|
|
@@ -759,7 +759,7 @@ function Dt(e) {
|
|
|
759
759
|
}
|
|
760
760
|
}
|
|
761
761
|
function jt() {
|
|
762
|
-
const { contentIframeRef: e } =
|
|
762
|
+
const { contentIframeRef: e } = j(), { inline: r } = x();
|
|
763
763
|
return {
|
|
764
764
|
setWidth: (t) => {
|
|
765
765
|
var n;
|
|
@@ -832,7 +832,7 @@ function ee({
|
|
|
832
832
|
return /* @__PURE__ */ o(t, { className: p("size-4", r) });
|
|
833
833
|
}
|
|
834
834
|
function ke() {
|
|
835
|
-
const { widgetCtx: { org: e } } =
|
|
835
|
+
const { widgetCtx: { org: e } } = j(), {
|
|
836
836
|
routerState: { screen: r }
|
|
837
837
|
} = B(), { textContent: t } = x();
|
|
838
838
|
return (() => {
|
|
@@ -948,7 +948,7 @@ function Et({
|
|
|
948
948
|
button: e
|
|
949
949
|
}) {
|
|
950
950
|
var N, T;
|
|
951
|
-
const { close: r } = ce(), { widgetCtx: t } =
|
|
951
|
+
const { close: r } = ce(), { widgetCtx: t } = j(), { setIsOpen: n } = K(), { resolveSession: s, sessionState: i } = q(), { isSmallScreen: a } = O(), c = !i.session, l = ((N = i.session) == null ? void 0 : N.isOpened) === !1, h = e.onResolved || "stay-in-chat", b = e.behaviorBeforeSessionCreation || "disabled", w = e.behaviorIfSessionIsResolved || "disabled", m = !!(i.isResolvingSession || c && b === "disabled" || l && w === "disabled"), k = async () => {
|
|
952
952
|
const { success: _, error: M } = await s();
|
|
953
953
|
if (r(), !_) return console.error(M);
|
|
954
954
|
switch (h) {
|
|
@@ -1536,7 +1536,7 @@ function mr({
|
|
|
1536
1536
|
);
|
|
1537
1537
|
}
|
|
1538
1538
|
function ur() {
|
|
1539
|
-
var
|
|
1539
|
+
var E;
|
|
1540
1540
|
const { isSmallScreen: e } = O(), r = le(null), { sendMessage: t } = R(), { sessionState: n } = q(), { t: s } = V(), [i, a] = I(""), {
|
|
1541
1541
|
allFiles: c,
|
|
1542
1542
|
emptyTheFiles: l,
|
|
@@ -1544,7 +1544,7 @@ function ur() {
|
|
|
1544
1544
|
appendFiles: b,
|
|
1545
1545
|
isUploading: w,
|
|
1546
1546
|
successFiles: m
|
|
1547
|
-
} = $t(), k = !!((
|
|
1547
|
+
} = $t(), k = !!((E = n.session) != null && E.isHandedOff), { isAwaitingBotReply: f } = ht(), N = (v) => {
|
|
1548
1548
|
b(v);
|
|
1549
1549
|
}, T = !i.trim() && m.length === 0, _ = async () => {
|
|
1550
1550
|
if (f || T) return;
|
|
@@ -1699,7 +1699,7 @@ function ur() {
|
|
|
1699
1699
|
);
|
|
1700
1700
|
}
|
|
1701
1701
|
function st() {
|
|
1702
|
-
const { widgetCtx: e } =
|
|
1702
|
+
const { widgetCtx: e } = j(), { router: r } = x(), { canCreateNewSession: t } = q(), { toSessionsScreen: n } = B(), { t: s } = V();
|
|
1703
1703
|
return /* @__PURE__ */ o(te, { children: t || r != null && r.chatScreenOnly ? /* @__PURE__ */ o(y, { onClick: e.resetChat, className: "rounded-2xl w-full", children: s("new-conversation") }) : /* @__PURE__ */ o(y, { onClick: n, className: "rounded-2xl w-full", children: s("back-to-conversations") }) });
|
|
1704
1704
|
}
|
|
1705
1705
|
function gr() {
|
|
@@ -1736,7 +1736,7 @@ function fr({
|
|
|
1736
1736
|
isAloneInGroup: t,
|
|
1737
1737
|
...n
|
|
1738
1738
|
}) {
|
|
1739
|
-
const { componentStore: s } =
|
|
1739
|
+
const { componentStore: s } = j();
|
|
1740
1740
|
if (n.type !== "AGENT" && n.type !== "AI") return null;
|
|
1741
1741
|
if (n.data.action) {
|
|
1742
1742
|
const a = s.getComponent(n.data.action.name);
|
|
@@ -1871,7 +1871,18 @@ function ze({
|
|
|
1871
1871
|
}
|
|
1872
1872
|
);
|
|
1873
1873
|
}
|
|
1874
|
-
function vr({
|
|
1874
|
+
function vr() {
|
|
1875
|
+
var s;
|
|
1876
|
+
const {
|
|
1877
|
+
widgetCtx: { org: e }
|
|
1878
|
+
} = j(), {
|
|
1879
|
+
sessionState: { session: r }
|
|
1880
|
+
} = q(), t = x();
|
|
1881
|
+
if (r != null && r.isOpened || !r) return null;
|
|
1882
|
+
const n = (s = t.specialComponents) == null ? void 0 : s.onSessionResolved;
|
|
1883
|
+
return n ? /* @__PURE__ */ o(n, { react: $, session: r, config: t, org: e }) : null;
|
|
1884
|
+
}
|
|
1885
|
+
function br({
|
|
1875
1886
|
message: e,
|
|
1876
1887
|
isFirstInGroup: r,
|
|
1877
1888
|
isLastInGroup: t,
|
|
@@ -1911,7 +1922,7 @@ function vr({
|
|
|
1911
1922
|
}
|
|
1912
1923
|
);
|
|
1913
1924
|
}
|
|
1914
|
-
function
|
|
1925
|
+
function xr({
|
|
1915
1926
|
messages: e
|
|
1916
1927
|
}) {
|
|
1917
1928
|
return /* @__PURE__ */ d(
|
|
@@ -1921,7 +1932,7 @@ function br({
|
|
|
1921
1932
|
className: p("group", "flex flex-col gap-1 justify-end items-end"),
|
|
1922
1933
|
children: [
|
|
1923
1934
|
e.map((r, t, n) => /* @__PURE__ */ o(
|
|
1924
|
-
|
|
1935
|
+
br,
|
|
1925
1936
|
{
|
|
1926
1937
|
message: r,
|
|
1927
1938
|
isFirstInGroup: t === 0,
|
|
@@ -1935,7 +1946,7 @@ function br({
|
|
|
1935
1946
|
}
|
|
1936
1947
|
);
|
|
1937
1948
|
}
|
|
1938
|
-
function
|
|
1949
|
+
function yr(e) {
|
|
1939
1950
|
const r = [];
|
|
1940
1951
|
let t = null;
|
|
1941
1952
|
return e.forEach((n) => {
|
|
@@ -1943,19 +1954,19 @@ function xr(e) {
|
|
|
1943
1954
|
(!t || ((s = t[0]) == null ? void 0 : s.type) !== n.type) && (t = [], r.push(t)), ((i = t[0]) == null ? void 0 : i.type) === "AGENT" && n.type === "AGENT" && (((a = n.agent) == null ? void 0 : a.id) !== ((c = t[0].agent) == null ? void 0 : c.id) || ((l = n.agent) == null ? void 0 : l.name) !== ((h = t[0].agent) == null ? void 0 : h.name)) && (t = [], r.push(t)), t.push(n);
|
|
1944
1955
|
}), r;
|
|
1945
1956
|
}
|
|
1946
|
-
function
|
|
1957
|
+
function kr(e) {
|
|
1947
1958
|
var r;
|
|
1948
1959
|
return ((r = e == null ? void 0 : e[0]) == null ? void 0 : r.type) === "USER";
|
|
1949
1960
|
}
|
|
1950
|
-
function
|
|
1961
|
+
function Cr(e) {
|
|
1951
1962
|
var r;
|
|
1952
1963
|
return ((r = e == null ? void 0 : e[0]) == null ? void 0 : r.type) === "AI";
|
|
1953
1964
|
}
|
|
1954
|
-
function
|
|
1965
|
+
function zr(e) {
|
|
1955
1966
|
var r;
|
|
1956
1967
|
return ((r = e == null ? void 0 : e[0]) == null ? void 0 : r.type) === "AGENT";
|
|
1957
1968
|
}
|
|
1958
|
-
function
|
|
1969
|
+
function Nr() {
|
|
1959
1970
|
const {
|
|
1960
1971
|
messagesState: { messages: e }
|
|
1961
1972
|
} = R(), {
|
|
@@ -1981,7 +1992,7 @@ function zr() {
|
|
|
1981
1992
|
}
|
|
1982
1993
|
) });
|
|
1983
1994
|
}
|
|
1984
|
-
function
|
|
1995
|
+
function Sr() {
|
|
1985
1996
|
const {
|
|
1986
1997
|
messagesState: { messages: e }
|
|
1987
1998
|
} = R(), { chatBannerItems: r } = x();
|
|
@@ -1989,7 +2000,7 @@ function Nr() {
|
|
|
1989
2000
|
({ message: t, persistent: n }, s) => e.length > 0 && !n ? null : /* @__PURE__ */ o("div", { children: /* @__PURE__ */ o(It, { children: t }) }, `${t}-${s}`)
|
|
1990
2001
|
) });
|
|
1991
2002
|
}
|
|
1992
|
-
function
|
|
2003
|
+
function _r() {
|
|
1993
2004
|
const {
|
|
1994
2005
|
messagesState: { messages: e }
|
|
1995
2006
|
} = R(), r = x(), {
|
|
@@ -2017,11 +2028,11 @@ function Sr() {
|
|
|
2017
2028
|
}
|
|
2018
2029
|
) });
|
|
2019
2030
|
}
|
|
2020
|
-
function
|
|
2031
|
+
function Ir() {
|
|
2021
2032
|
const {
|
|
2022
2033
|
messagesState: { messages: e }
|
|
2023
|
-
} = R(), { isAwaitingBotReply: r } = ht(), { componentStore: t } =
|
|
2024
|
-
() =>
|
|
2034
|
+
} = R(), { isAwaitingBotReply: r } = ht(), { componentStore: t } = j(), n = x(), s = ct(
|
|
2035
|
+
() => yr(e),
|
|
2025
2036
|
[e]
|
|
2026
2037
|
), i = t.getComponent(
|
|
2027
2038
|
"loading"
|
|
@@ -2041,16 +2052,16 @@ function _r() {
|
|
|
2041
2052
|
ref: a,
|
|
2042
2053
|
className: "max-h-full scroll-smooth relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",
|
|
2043
2054
|
children: [
|
|
2044
|
-
/* @__PURE__ */ o(Nr, {}),
|
|
2045
|
-
/* @__PURE__ */ o(zr, {}),
|
|
2046
2055
|
/* @__PURE__ */ o(Sr, {}),
|
|
2056
|
+
/* @__PURE__ */ o(Nr, {}),
|
|
2057
|
+
/* @__PURE__ */ o(_r, {}),
|
|
2047
2058
|
s.map((l) => {
|
|
2048
2059
|
var w, m, k;
|
|
2049
2060
|
const h = (w = l == null ? void 0 : l[0]) == null ? void 0 : w.type, b = (m = l[0]) == null ? void 0 : m.id;
|
|
2050
2061
|
if (!h || !b) return null;
|
|
2051
|
-
if (
|
|
2052
|
-
return /* @__PURE__ */ o(
|
|
2053
|
-
if (
|
|
2062
|
+
if (kr(l))
|
|
2063
|
+
return /* @__PURE__ */ o(xr, { messages: l }, b);
|
|
2064
|
+
if (Cr(l) || zr(l)) {
|
|
2054
2065
|
const f = (k = l[0]) == null ? void 0 : k.agent;
|
|
2055
2066
|
return /* @__PURE__ */ o(
|
|
2056
2067
|
ze,
|
|
@@ -2064,19 +2075,11 @@ function _r() {
|
|
|
2064
2075
|
return null;
|
|
2065
2076
|
}),
|
|
2066
2077
|
r && i && /* @__PURE__ */ o(i, { agent: n.bot }),
|
|
2067
|
-
/* @__PURE__ */ o(
|
|
2078
|
+
/* @__PURE__ */ o(vr, {})
|
|
2068
2079
|
]
|
|
2069
2080
|
}
|
|
2070
2081
|
);
|
|
2071
2082
|
}
|
|
2072
|
-
function Ir() {
|
|
2073
|
-
const {
|
|
2074
|
-
sessionState: { session: e }
|
|
2075
|
-
} = q(), { specialComponents: r } = x();
|
|
2076
|
-
if (e != null && e.isOpened || !e) return null;
|
|
2077
|
-
const t = r == null ? void 0 : r.onSessionResolved;
|
|
2078
|
-
return t ? /* @__PURE__ */ o(t, { react: $ }) : null;
|
|
2079
|
-
}
|
|
2080
2083
|
function Tr() {
|
|
2081
2084
|
const {
|
|
2082
2085
|
messagesState: { isInitialFetchLoading: e }
|
|
@@ -2131,7 +2134,7 @@ function Tr() {
|
|
|
2131
2134
|
transitionDuration: n.screens.chat.withCanvas.transitionDuration
|
|
2132
2135
|
},
|
|
2133
2136
|
children: [
|
|
2134
|
-
/* @__PURE__ */ o(
|
|
2137
|
+
/* @__PURE__ */ o(Ir, {}),
|
|
2135
2138
|
/* @__PURE__ */ o(wr, {})
|
|
2136
2139
|
]
|
|
2137
2140
|
}
|
|
@@ -2397,7 +2400,7 @@ const ae = G.forwardRef(
|
|
|
2397
2400
|
);
|
|
2398
2401
|
ae.displayName = "Input";
|
|
2399
2402
|
function Or() {
|
|
2400
|
-
const { contentIframeRef: e } =
|
|
2403
|
+
const { contentIframeRef: e } = j(), { inline: r } = x(), t = le(null);
|
|
2401
2404
|
return oe(() => {
|
|
2402
2405
|
const n = e == null ? void 0 : e.current;
|
|
2403
2406
|
if (n && t.current) {
|
|
@@ -2423,8 +2426,8 @@ const Ar = pe.object({
|
|
|
2423
2426
|
email: pe.string().email()
|
|
2424
2427
|
});
|
|
2425
2428
|
function Pr() {
|
|
2426
|
-
var _, M, A, P, W,
|
|
2427
|
-
const { widgetCtx: { org: e } } =
|
|
2429
|
+
var _, M, A, P, W, E, v, C;
|
|
2430
|
+
const { widgetCtx: { org: e } } = j(), { setIsOpen: r } = K(), { createUnverifiedContact: t } = qt(), { isSmallScreen: n } = O(), s = x(), { theme: i } = U(), { t: a } = V(), { observedElementRef: c } = Or();
|
|
2428
2431
|
ye({
|
|
2429
2432
|
height: void 0,
|
|
2430
2433
|
width: i.screens.welcome.width
|
|
@@ -2489,7 +2492,7 @@ function Pr() {
|
|
|
2489
2492
|
}
|
|
2490
2493
|
) : /* @__PURE__ */ o("h2", { className: "font-bold text-sm", children: e.name }) }),
|
|
2491
2494
|
/* @__PURE__ */ d("div", { className: "space-y-2", children: [
|
|
2492
|
-
/* @__PURE__ */ o("h1", { className: "text-[1.75rem] font-semibold tracking-tight leading-none", children: ((
|
|
2495
|
+
/* @__PURE__ */ o("h1", { className: "text-[1.75rem] font-semibold tracking-tight leading-none", children: ((E = (W = s.textContent) == null ? void 0 : W.welcomeScreen) == null ? void 0 : E.title) || a("welcome-title") }),
|
|
2493
2496
|
/* @__PURE__ */ o("p", { className: "text-sm", children: ((C = (v = s.textContent) == null ? void 0 : v.welcomeScreen) == null ? void 0 : C.description) || a("welcome-description") })
|
|
2494
2497
|
] })
|
|
2495
2498
|
]
|
|
@@ -2606,7 +2609,7 @@ function Ht() {
|
|
|
2606
2609
|
}
|
|
2607
2610
|
})() }) });
|
|
2608
2611
|
}
|
|
2609
|
-
const Wr = "4.0.
|
|
2612
|
+
const Wr = "4.0.16", Hr = `<!DOCTYPE html>
|
|
2610
2613
|
<html>
|
|
2611
2614
|
<head>
|
|
2612
2615
|
<style>
|
|
@@ -2625,7 +2628,7 @@ html, body {
|
|
|
2625
2628
|
</body>
|
|
2626
2629
|
</html>`;
|
|
2627
2630
|
function Ft() {
|
|
2628
|
-
const { isOpen: e } = K(), { contentIframeRef: r } =
|
|
2631
|
+
const { isOpen: e } = K(), { contentIframeRef: r } = j(), { cssOverrides: t, inline: n } = x(), { theme: s, cssVars: i, computed: a } = U(), { dir: c } = V();
|
|
2629
2632
|
return /* @__PURE__ */ o(
|
|
2630
2633
|
Q.div,
|
|
2631
2634
|
{
|