@botpress/webchat 1.0.26 → 1.0.27
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/App.d.ts +1 -1
- package/dist/contexts/WebchatContext.d.ts +1 -1
- package/dist/index.js +42 -31
- package/dist/index.umd.cjs +5 -5
- package/dist/providers/WebchatProvider.d.ts +1 -1
- package/package.json +1 -1
package/dist/App.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Container } from './components';
|
|
|
4
4
|
import { Theme } from './schemas';
|
|
5
5
|
type Props = {
|
|
6
6
|
theme: Theme;
|
|
7
|
-
client
|
|
7
|
+
client?: WebChatClient;
|
|
8
8
|
} & ComponentProps<typeof Container>;
|
|
9
9
|
export declare const App: ({ theme, client }: Props) => JSX.Element;
|
|
10
10
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -27158,7 +27158,7 @@ const Jz = ({ text: e, buttonValue: t, type: n, styles: a, variant: l, groupId:
|
|
|
27158
27158
|
});
|
|
27159
27159
|
}, [y, u, d]);
|
|
27160
27160
|
function P() {
|
|
27161
|
-
u && y.emit(`button-group-${u}-click`), S(!0), d || O(!0), l !== "link" && b.sendMessage(t);
|
|
27161
|
+
u && y.emit(`button-group-${u}-click`), S(!0), d || O(!0), l !== "link" && (b == null || b.sendMessage(t));
|
|
27162
27162
|
}
|
|
27163
27163
|
return /* @__PURE__ */ Ae.jsx(
|
|
27164
27164
|
ej,
|
|
@@ -32095,7 +32095,7 @@ const EV = ({ styles: e, type: t, options: n, label: a, reusable: l }) => {
|
|
|
32095
32095
|
xe,
|
|
32096
32096
|
V
|
|
32097
32097
|
]), me = (Ze) => {
|
|
32098
|
-
S(Ze), k.sendMessage(_[A[Ze]]), m(!1);
|
|
32098
|
+
S(Ze), k == null || k.sendMessage(_[A[Ze]]), m(!1);
|
|
32099
32099
|
}, De = w !== null ? A[w] : void 0;
|
|
32100
32100
|
return /* @__PURE__ */ Ae.jsxs(Ae.Fragment, { children: [
|
|
32101
32101
|
/* @__PURE__ */ Ae.jsxs(
|
|
@@ -33009,10 +33009,13 @@ const rW = nW, iW = (e) => {
|
|
|
33009
33009
|
state: n,
|
|
33010
33010
|
theme: { composer: a },
|
|
33011
33011
|
client: l
|
|
33012
|
-
} = ki(), [u, d] = On(""), [m, y] = On(-1)
|
|
33012
|
+
} = ki(), [u, d] = On(""), [m, y] = On(-1);
|
|
33013
|
+
if (n.isReadOnly || !l)
|
|
33014
|
+
return null;
|
|
33015
|
+
const b = () => {
|
|
33013
33016
|
u && (l.sendMessage(u), d(""), y(-1));
|
|
33014
33017
|
};
|
|
33015
|
-
return
|
|
33018
|
+
return /* @__PURE__ */ Ae.jsx(UD.Provider, { value: { value: u, setValue: d, historyIndex: m, setHistoryIndex: y, sendMessage: b }, children: /* @__PURE__ */ Ae.jsx("div", { "data-disabled": n.disableComposer, ...e, ...a == null ? void 0 : a.container, ref: t }) });
|
|
33016
33019
|
})
|
|
33017
33020
|
), lW = Sy(({ ...e }) => {
|
|
33018
33021
|
const {
|
|
@@ -42770,7 +42773,7 @@ const FX = ({
|
|
|
42770
42773
|
setTheme: (q) => {
|
|
42771
42774
|
_(q);
|
|
42772
42775
|
},
|
|
42773
|
-
client: {
|
|
42776
|
+
client: n ? {
|
|
42774
42777
|
...n,
|
|
42775
42778
|
sendMessage: async (q) => {
|
|
42776
42779
|
await n.sendMessage(q), m((U) => [
|
|
@@ -42787,27 +42790,35 @@ const FX = ({
|
|
|
42787
42790
|
restartConversation: async () => {
|
|
42788
42791
|
await n.newConversation(), m([]);
|
|
42789
42792
|
}
|
|
42790
|
-
}
|
|
42793
|
+
} : void 0
|
|
42791
42794
|
}
|
|
42792
42795
|
};
|
|
42793
|
-
return dy(() =>
|
|
42794
|
-
|
|
42795
|
-
|
|
42796
|
-
|
|
42797
|
-
|
|
42798
|
-
|
|
42799
|
-
|
|
42800
|
-
|
|
42801
|
-
|
|
42802
|
-
|
|
42796
|
+
return dy(() => {
|
|
42797
|
+
if (n)
|
|
42798
|
+
return n.on("message", (q) => {
|
|
42799
|
+
try {
|
|
42800
|
+
const U = q.payload;
|
|
42801
|
+
m((V) => [
|
|
42802
|
+
...V,
|
|
42803
|
+
{
|
|
42804
|
+
direction: "incoming",
|
|
42805
|
+
sender: { name: w.botName ?? "Bot", avatar: w.botAvatar },
|
|
42806
|
+
timestamp: q.sentOn,
|
|
42807
|
+
block: U
|
|
42808
|
+
}
|
|
42809
|
+
]);
|
|
42810
|
+
} catch {
|
|
42811
|
+
console.error("Invalid message payload");
|
|
42803
42812
|
}
|
|
42804
|
-
|
|
42805
|
-
|
|
42806
|
-
|
|
42807
|
-
|
|
42808
|
-
|
|
42809
|
-
|
|
42810
|
-
})
|
|
42813
|
+
});
|
|
42814
|
+
}), dy(() => {
|
|
42815
|
+
if (n)
|
|
42816
|
+
return n.on("conversation", (q) => {
|
|
42817
|
+
O(q);
|
|
42818
|
+
});
|
|
42819
|
+
}), HN(async () => {
|
|
42820
|
+
if (!n)
|
|
42821
|
+
return;
|
|
42811
42822
|
z(await n.connect(M)), P && await n.conversationExists(P) && await n.switchConversation(P);
|
|
42812
42823
|
const q = [];
|
|
42813
42824
|
for (const U of await n.listMessages())
|
|
@@ -43070,8 +43081,8 @@ const Aq = _q, Dq = Tq, Nq = Rq, Mq = (e) => /* @__PURE__ */ te.createElement("s
|
|
|
43070
43081
|
var d, m, y, b, w, S;
|
|
43071
43082
|
const {
|
|
43072
43083
|
theme: { header: a },
|
|
43073
|
-
client:
|
|
43074
|
-
} = ki(), u = nM(l ?? "", 15);
|
|
43084
|
+
client: l
|
|
43085
|
+
} = ki(), u = nM((l == null ? void 0 : l.clientId) ?? "", 15);
|
|
43075
43086
|
return /* @__PURE__ */ Ae.jsxs(u5, { ref: n, "data-color": u, ...(m = (d = a == null ? void 0 : a.content) == null ? void 0 : d.avatar) == null ? void 0 : m.container, children: [
|
|
43076
43087
|
/* @__PURE__ */ Ae.jsx(c5, { ...(b = (y = a == null ? void 0 : a.content) == null ? void 0 : y.avatar) == null ? void 0 : b.image, src: e }),
|
|
43077
43088
|
/* @__PURE__ */ Ae.jsx(f5, { ...(S = (w = a == null ? void 0 : a.content) == null ? void 0 : w.avatar) == null ? void 0 : S.fallback, children: t })
|
|
@@ -43147,14 +43158,14 @@ const Aq = _q, Dq = Tq, Nq = Rq, Mq = (e) => /* @__PURE__ */ te.createElement("s
|
|
|
43147
43158
|
const [y, b] = On([]), {
|
|
43148
43159
|
theme: { message: w },
|
|
43149
43160
|
configuration: { botAvatar: S, botName: k },
|
|
43150
|
-
client:
|
|
43161
|
+
client: _
|
|
43151
43162
|
} = ki();
|
|
43152
43163
|
QV(() => {
|
|
43153
43164
|
n();
|
|
43154
43165
|
}), hn(() => {
|
|
43155
43166
|
y.length === 0 && n();
|
|
43156
43167
|
}, [y.length]);
|
|
43157
|
-
const A = nM(_ ?? "", 15);
|
|
43168
|
+
const A = nM((_ == null ? void 0 : _.clientId) ?? "", 15);
|
|
43158
43169
|
return /* @__PURE__ */ Ae.jsx(VD.Provider, { value: { isLoading: y, setIsLoading: b }, children: /* @__PURE__ */ Ae.jsxs(
|
|
43159
43170
|
"div",
|
|
43160
43171
|
{
|
|
@@ -43187,9 +43198,9 @@ const Aq = _q, Dq = Tq, Nq = Rq, Mq = (e) => /* @__PURE__ */ te.createElement("s
|
|
|
43187
43198
|
return hn(() => {
|
|
43188
43199
|
const A = new Date(Date.now() - nA + 2e3);
|
|
43189
43200
|
n.length > 0 && n[n.length - 1].timestamp < A && w(!1);
|
|
43190
|
-
}, [S]), dy(() => l.on("messageSent", () => {
|
|
43201
|
+
}, [S]), dy(() => l == null ? void 0 : l.on("messageSent", () => {
|
|
43191
43202
|
w(!0), k(new Date(Date.now() + nA));
|
|
43192
|
-
})), dy(() => l.on("message", () => {
|
|
43203
|
+
})), dy(() => l == null ? void 0 : l.on("message", () => {
|
|
43193
43204
|
w(!1);
|
|
43194
43205
|
})), hn(() => {
|
|
43195
43206
|
const A = n[n.length - 1];
|
|
@@ -44216,14 +44227,14 @@ const dG = ({ ...e }) => {
|
|
|
44216
44227
|
var d, m;
|
|
44217
44228
|
const {
|
|
44218
44229
|
theme: { header: t, modal: n },
|
|
44219
|
-
client:
|
|
44230
|
+
client: a
|
|
44220
44231
|
} = ki(), { showModal: l } = Xz(), u = (y) => {
|
|
44221
44232
|
var b, w, S, k;
|
|
44222
44233
|
y.stopPropagation(), l({
|
|
44223
44234
|
title: "Restart Conversation",
|
|
44224
44235
|
content: /* @__PURE__ */ Ae.jsxs(Ae.Fragment, { children: [
|
|
44225
44236
|
/* @__PURE__ */ Ae.jsx("p", { ...(w = (b = n == null ? void 0 : n.dialog) == null ? void 0 : b.newConversation) == null ? void 0 : w.text, children: "Are you sure you want to restart a new conversation?" }),
|
|
44226
|
-
/* @__PURE__ */ Ae.jsx(py.Close, { asChild: !0, children: /* @__PURE__ */ Ae.jsx("button", { ...(k = (S = n == null ? void 0 : n.dialog) == null ? void 0 : S.newConversation) == null ? void 0 : k.button, onClick: a, children: "restart" }) })
|
|
44237
|
+
/* @__PURE__ */ Ae.jsx(py.Close, { asChild: !0, children: /* @__PURE__ */ Ae.jsx("button", { ...(k = (S = n == null ? void 0 : n.dialog) == null ? void 0 : S.newConversation) == null ? void 0 : k.button, onClick: a == null ? void 0 : a.restartConversation, children: "restart" }) })
|
|
44227
44238
|
] })
|
|
44228
44239
|
});
|
|
44229
44240
|
};
|