bstp-agent-widget 0.2.70 → 0.2.72
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/agent-widget.js +79 -90
- package/dist/agent-widget.js.map +1 -1
- package/dist/bstp-agent-widget.css +1 -1
- package/package.json +1 -1
package/dist/agent-widget.js
CHANGED
|
@@ -23917,23 +23917,28 @@ function UO(e = {}) {
|
|
|
23917
23917
|
};
|
|
23918
23918
|
}
|
|
23919
23919
|
var WO = {
|
|
23920
|
-
root: "
|
|
23921
|
-
button: "
|
|
23922
|
-
icon: "
|
|
23923
|
-
label: "
|
|
23920
|
+
root: "_root_1r0du_1",
|
|
23921
|
+
button: "_button_1r0du_5",
|
|
23922
|
+
icon: "_icon_1r0du_22",
|
|
23923
|
+
label: "_label_1r0du_28"
|
|
23924
23924
|
};
|
|
23925
23925
|
//#endregion
|
|
23926
23926
|
//#region src/components/AgentChat/AgentChatFab.tsx
|
|
23927
23927
|
function GO({ onClick: e, zIndex: t, position: n, color: r, label: i }) {
|
|
23928
|
-
let { handlePointerDown: a, style: o } = UO({ skipSelector: "" }), { transform: s, cursor: c, touchAction: l } = o, u =
|
|
23928
|
+
let { handlePointerDown: a, style: o } = UO({ skipSelector: "" }), { transform: s, cursor: c, touchAction: l } = o, u = _(() => ({
|
|
23929
|
+
transform: s,
|
|
23930
|
+
touchAction: l,
|
|
23931
|
+
zIndex: t,
|
|
23932
|
+
...n
|
|
23933
|
+
}), [
|
|
23934
|
+
n,
|
|
23935
|
+
l,
|
|
23936
|
+
s,
|
|
23937
|
+
t
|
|
23938
|
+
]), d = r ? r.includes("linear-gradient") ? r : `linear-gradient(135deg, ${r}, ${r})` : void 0;
|
|
23929
23939
|
return /* @__PURE__ */ T("div", {
|
|
23930
23940
|
className: WO.root,
|
|
23931
|
-
style:
|
|
23932
|
-
transform: s,
|
|
23933
|
-
touchAction: l,
|
|
23934
|
-
zIndex: t,
|
|
23935
|
-
...n
|
|
23936
|
-
},
|
|
23941
|
+
style: u,
|
|
23937
23942
|
children: /* @__PURE__ */ T(_v, {
|
|
23938
23943
|
label: "Open agent widget",
|
|
23939
23944
|
position: "left",
|
|
@@ -23941,8 +23946,8 @@ function GO({ onClick: e, zIndex: t, position: n, color: r, label: i }) {
|
|
|
23941
23946
|
type: "button",
|
|
23942
23947
|
onClick: e,
|
|
23943
23948
|
onPointerDown: a,
|
|
23944
|
-
style:
|
|
23945
|
-
background:
|
|
23949
|
+
style: d ? {
|
|
23950
|
+
background: d,
|
|
23946
23951
|
cursor: c ?? "pointer"
|
|
23947
23952
|
} : { cursor: c ?? "pointer" },
|
|
23948
23953
|
className: WO.button,
|
|
@@ -29047,29 +29052,21 @@ var BF = {
|
|
|
29047
29052
|
];
|
|
29048
29053
|
function UF({ ui: e }) {
|
|
29049
29054
|
RF();
|
|
29050
|
-
let t = e?.panelWidth ?? 420, n = e?.panelHeight ?? "100%", r = e?.panelHeaderHeight ?? 56, i = e?.zIndex ?? VF, a =
|
|
29051
|
-
bottom:
|
|
29052
|
-
right:
|
|
29053
|
-
}, { isOpen:
|
|
29055
|
+
let t = e?.panelWidth ?? 420, n = e?.panelHeight ?? "100%", r = e?.panelHeaderHeight ?? 56, i = e?.zIndex ?? VF, a = {
|
|
29056
|
+
bottom: e?.fabBottomOffset ?? BF.bottom,
|
|
29057
|
+
right: e?.fabRightOffset ?? BF.right
|
|
29058
|
+
}, { isOpen: o, open: s, close: c } = zF({
|
|
29054
29059
|
defaultOpen: !1,
|
|
29055
29060
|
persist: !0
|
|
29056
|
-
}), { messages:
|
|
29061
|
+
}), { messages: l, composerText: d, setComposerText: p, isLoading: m, error: h, sendMessage: g, sendInitialMessage: y, canSend: b } = OF(), { runtimeInfo: x, refreshRuntimeInfo: S } = kF(), C = MF([l.length, m]), { isListening: D, isSupported: O, startListening: k, stopListening: A, reset: j } = NF({
|
|
29057
29062
|
lang: PF(),
|
|
29058
29063
|
continuous: !0,
|
|
29059
29064
|
pauseOnSubmit: !0,
|
|
29060
|
-
onTextChange:
|
|
29061
|
-
}),
|
|
29065
|
+
onTextChange: p
|
|
29066
|
+
}), M = _(() => /* @__PURE__ */ T(Xd, {
|
|
29062
29067
|
fw: 800,
|
|
29063
29068
|
children: e?.panelTitle ?? "Agent Chat"
|
|
29064
|
-
}), [e?.panelTitle]),
|
|
29065
|
-
if (typeof window > "u") return;
|
|
29066
|
-
if (!e) {
|
|
29067
|
-
c(a);
|
|
29068
|
-
return;
|
|
29069
|
-
}
|
|
29070
|
-
let t = e.getBoundingClientRect();
|
|
29071
|
-
c(a + Math.max(0, window.innerHeight - t.bottom));
|
|
29072
|
-
}, [a]), ne = u(() => {
|
|
29069
|
+
}), [e?.panelTitle]), N = v(Math.max(280, t)), P = v(null), F = u(() => {
|
|
29073
29070
|
if (typeof document > "u") return null;
|
|
29074
29071
|
let t = [...typeof e?.hostContainerSelector == "string" ? e.hostContainerSelector.split(",").map((e) => e.trim()).filter(Boolean) : [], ...HF];
|
|
29075
29072
|
for (let e of t) {
|
|
@@ -29077,101 +29074,93 @@ function UF({ ui: e }) {
|
|
|
29077
29074
|
if (t) return t;
|
|
29078
29075
|
}
|
|
29079
29076
|
return document.body;
|
|
29080
|
-
}, [e?.hostContainerSelector]),
|
|
29077
|
+
}, [e?.hostContainerSelector]), ee = u((e) => {
|
|
29081
29078
|
if (typeof document > "u") return;
|
|
29082
29079
|
let t = document.documentElement;
|
|
29083
29080
|
if (e === null ? t.style.removeProperty("--agent-widget-panel-width") : t.style.setProperty("--agent-widget-panel-width", `${e}px`), typeof window > "u") return;
|
|
29084
29081
|
if (e === null) {
|
|
29085
|
-
if (
|
|
29086
|
-
let { element: e, inlinePaddingBefore: t
|
|
29087
|
-
e.style.paddingRight = t,
|
|
29082
|
+
if (P.current) {
|
|
29083
|
+
let { element: e, inlinePaddingBefore: t } = P.current;
|
|
29084
|
+
e.style.paddingRight = t, P.current = null;
|
|
29088
29085
|
}
|
|
29089
|
-
R(null);
|
|
29090
29086
|
return;
|
|
29091
29087
|
}
|
|
29092
|
-
|
|
29093
|
-
|
|
29094
|
-
|
|
29095
|
-
|
|
29088
|
+
if (!P.current || !document.contains(P.current.element)) {
|
|
29089
|
+
let e = F();
|
|
29090
|
+
if (!e) return;
|
|
29091
|
+
P.current = {
|
|
29092
|
+
element: e,
|
|
29093
|
+
inlinePaddingBefore: e.style.paddingRight,
|
|
29094
|
+
widthApplied: 0
|
|
29095
|
+
};
|
|
29096
29096
|
}
|
|
29097
|
-
|
|
29098
|
-
|
|
29099
|
-
|
|
29100
|
-
|
|
29101
|
-
|
|
29102
|
-
|
|
29103
|
-
|
|
29104
|
-
|
|
29105
|
-
|
|
29106
|
-
|
|
29107
|
-
M && F(), m();
|
|
29108
|
-
}, se = async () => {
|
|
29109
|
-
p(), ie.current || (ie.current = !0, await A(), await D());
|
|
29097
|
+
let { element: n, inlinePaddingBefore: r, widthApplied: i } = P.current;
|
|
29098
|
+
e !== i && (n.style.paddingRight = r, n.style.paddingRight = `calc(${r || "0px"} + ${e}px)`, P.current.widthApplied = e);
|
|
29099
|
+
}, [F]), te = v(!1), I = () => {
|
|
29100
|
+
D && A(), j(), g(d);
|
|
29101
|
+
}, L = () => {
|
|
29102
|
+
D ? A() : (p(""), k());
|
|
29103
|
+
}, R = () => {
|
|
29104
|
+
D && A(), c();
|
|
29105
|
+
}, ne = async () => {
|
|
29106
|
+
s(), te.current || (te.current = !0, await S(), await y());
|
|
29110
29107
|
};
|
|
29111
29108
|
f(() => {
|
|
29112
|
-
|
|
29113
|
-
await
|
|
29109
|
+
o && !te.current && (te.current = !0, (async () => {
|
|
29110
|
+
await S(), await y();
|
|
29114
29111
|
})());
|
|
29115
|
-
}, [
|
|
29116
|
-
let
|
|
29112
|
+
}, [o]);
|
|
29113
|
+
let re = AF({
|
|
29117
29114
|
axis: "x",
|
|
29118
29115
|
direction: -1,
|
|
29119
29116
|
onResizeChange: u((e) => {
|
|
29120
29117
|
let n = Math.max(280, t + e);
|
|
29121
|
-
|
|
29122
|
-
}, [t,
|
|
29118
|
+
N.current = n, ee(n);
|
|
29119
|
+
}, [t, ee])
|
|
29123
29120
|
});
|
|
29124
29121
|
return f(() => {
|
|
29125
29122
|
let e = Math.max(280, t);
|
|
29126
|
-
|
|
29123
|
+
N.current = e, o && ee(e);
|
|
29127
29124
|
}, [
|
|
29128
29125
|
t,
|
|
29129
|
-
|
|
29130
|
-
|
|
29126
|
+
o,
|
|
29127
|
+
ee
|
|
29131
29128
|
]), f(() => {
|
|
29132
29129
|
if (!(typeof document > "u")) {
|
|
29133
|
-
if (!
|
|
29134
|
-
|
|
29130
|
+
if (!o) {
|
|
29131
|
+
ee(null), document.documentElement.removeAttribute("data-agent-widget-open");
|
|
29135
29132
|
return;
|
|
29136
29133
|
}
|
|
29137
29134
|
return document.documentElement.setAttribute("data-agent-widget-open", "true"), () => {
|
|
29138
|
-
|
|
29135
|
+
ee(null), document.documentElement.removeAttribute("data-agent-widget-open");
|
|
29139
29136
|
};
|
|
29140
29137
|
}
|
|
29141
|
-
}, [
|
|
29142
|
-
|
|
29143
|
-
let e = () => {
|
|
29144
|
-
R(L.current?.element ?? ne() ?? null);
|
|
29145
|
-
};
|
|
29146
|
-
return window.addEventListener("resize", e), () => {
|
|
29147
|
-
window.removeEventListener("resize", e);
|
|
29148
|
-
};
|
|
29149
|
-
}, [ne, R]), /* @__PURE__ */ E(w, { children: [!d && /* @__PURE__ */ T(GO, {
|
|
29150
|
-
onClick: () => void se(),
|
|
29138
|
+
}, [o, ee]), /* @__PURE__ */ E(w, { children: [!o && /* @__PURE__ */ T(GO, {
|
|
29139
|
+
onClick: () => void ne(),
|
|
29151
29140
|
zIndex: i,
|
|
29152
|
-
position:
|
|
29141
|
+
position: a,
|
|
29153
29142
|
color: e?.accentColor,
|
|
29154
29143
|
label: e?.fabButtonLabel
|
|
29155
|
-
}),
|
|
29144
|
+
}), o && /* @__PURE__ */ T(zO, {
|
|
29156
29145
|
visible: !0,
|
|
29157
|
-
onClose:
|
|
29158
|
-
messages:
|
|
29159
|
-
composerText:
|
|
29160
|
-
onComposerTextChange:
|
|
29161
|
-
isLoading:
|
|
29162
|
-
error:
|
|
29163
|
-
canSend:
|
|
29164
|
-
onSubmit:
|
|
29165
|
-
isListening:
|
|
29166
|
-
isVoiceSupported:
|
|
29167
|
-
onToggleVoice:
|
|
29168
|
-
panelTitle:
|
|
29169
|
-
runtimeInfo:
|
|
29170
|
-
scrollViewportRef:
|
|
29146
|
+
onClose: R,
|
|
29147
|
+
messages: l,
|
|
29148
|
+
composerText: d,
|
|
29149
|
+
onComposerTextChange: p,
|
|
29150
|
+
isLoading: m,
|
|
29151
|
+
error: h,
|
|
29152
|
+
canSend: b,
|
|
29153
|
+
onSubmit: I,
|
|
29154
|
+
isListening: D,
|
|
29155
|
+
isVoiceSupported: O,
|
|
29156
|
+
onToggleVoice: L,
|
|
29157
|
+
panelTitle: M,
|
|
29158
|
+
runtimeInfo: x,
|
|
29159
|
+
scrollViewportRef: C,
|
|
29171
29160
|
panelWidth: t,
|
|
29172
29161
|
panelHeight: n,
|
|
29173
29162
|
panelHeaderHeight: r,
|
|
29174
|
-
panelResizableWidth:
|
|
29163
|
+
panelResizableWidth: re,
|
|
29175
29164
|
zIndex: i
|
|
29176
29165
|
})] });
|
|
29177
29166
|
}
|