@xapp/chat-widget 1.102.0 → 1.103.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.css +1 -1
- package/dist/index.es.js +21 -12
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +21 -12
- package/dist/index.js.map +1 -1
- package/dist/xapp-chat-widget.css +1 -1
- package/dist/xapp-chat-widget.js +4 -4
- package/dist/xapp-chat-widget.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -37296,14 +37296,23 @@ var ChatWidgetUI = function (props) {
|
|
|
37296
37296
|
var arrivedViaChatLink = useArrivedViaChatLink(previewMode);
|
|
37297
37297
|
var conversationOnScreen = hasConversation(chatState.chats);
|
|
37298
37298
|
var chatButtonCta = React.useMemo(function () { var _a; return resolveCta((_a = props.config) === null || _a === void 0 ? void 0 : _a.cta, { hasConversation: conversationOnScreen, arrivedViaChatLink: arrivedViaChatLink }); }, [(_b = props.config) === null || _b === void 0 ? void 0 : _b.cta, conversationOnScreen, arrivedViaChatLink]);
|
|
37299
|
-
|
|
37299
|
+
// Only an embedded widget may drop its header. In normal mode the header holds the
|
|
37300
|
+
// minimize and close buttons, so hiding it would leave a floating window with no way out.
|
|
37301
|
+
var headerHidden = ((_c = props.config.header) === null || _c === void 0 ? void 0 : _c.hidden) === true && (dockedMode || staticMode);
|
|
37302
|
+
// The header is the only place a HEADER_LEFT / HEADER_RIGHT menu button renders. Without it
|
|
37303
|
+
// the menu would be unreachable, so hand the button to the footer instead.
|
|
37304
|
+
var menuConfig = React.useMemo(function () {
|
|
37305
|
+
return headerHidden && props.config.menu && props.config.menu.menuButtonLocation !== "FOOTER"
|
|
37306
|
+
? __assign$1(__assign$1({}, props.config.menu), { menuButtonLocation: "FOOTER" }) : props.config.menu;
|
|
37307
|
+
}, [headerHidden, props.config.menu]);
|
|
37308
|
+
var canRefresh = (_e = (_d = props.config.header) === null || _d === void 0 ? void 0 : _d.actions) === null || _e === void 0 ? void 0 : _e.refresh;
|
|
37300
37309
|
// can't minimize in docked mode, static mode, or preview mode.
|
|
37301
|
-
var canMinimize = !dockedMode && !staticMode && !previewMode && ((
|
|
37302
|
-
log("docked: ".concat(dockedMode, " static: ").concat(staticMode, " preview: ").concat(previewMode, " minimized: ").concat((
|
|
37310
|
+
var canMinimize = !dockedMode && !staticMode && !previewMode && ((_g = (_f = props.config.header) === null || _f === void 0 ? void 0 : _f.actions) === null || _g === void 0 ? void 0 : _g.minimize);
|
|
37311
|
+
log("docked: ".concat(dockedMode, " static: ").concat(staticMode, " preview: ").concat(previewMode, " minimized: ").concat((_j = (_h = props.config.header) === null || _h === void 0 ? void 0 : _h.actions) === null || _j === void 0 ? void 0 : _j.minimize));
|
|
37303
37312
|
var canCancel;
|
|
37304
37313
|
// To preserve legacy behavior, cancel needs a little more checks
|
|
37305
|
-
if (typeof ((
|
|
37306
|
-
canCancel = !dockedMode && !staticMode && !previewMode && ((
|
|
37314
|
+
if (typeof ((_l = (_k = props.config.header) === null || _k === void 0 ? void 0 : _k.actions) === null || _l === void 0 ? void 0 : _l.cancel) === "boolean") {
|
|
37315
|
+
canCancel = !dockedMode && !staticMode && !previewMode && ((_o = (_m = props.config.header) === null || _m === void 0 ? void 0 : _m.actions) === null || _o === void 0 ? void 0 : _o.cancel);
|
|
37307
37316
|
}
|
|
37308
37317
|
else {
|
|
37309
37318
|
canCancel = !dockedMode && !staticMode && !previewMode;
|
|
@@ -37314,7 +37323,7 @@ var ChatWidgetUI = function (props) {
|
|
|
37314
37323
|
}
|
|
37315
37324
|
// Our state - pull from storage
|
|
37316
37325
|
// Parse autoOpenOnWidth once for use in both initial state and useEffect
|
|
37317
|
-
var autoOpenOnWidthValue = ((
|
|
37326
|
+
var autoOpenOnWidthValue = ((_p = props.config) === null || _p === void 0 ? void 0 : _p.autoOpenOnWidth)
|
|
37318
37327
|
? parseInt(props.config.autoOpenOnWidth, 10)
|
|
37319
37328
|
: NaN;
|
|
37320
37329
|
var autoOpenOnWidthMatch = !isNaN(autoOpenOnWidthValue) && window.innerWidth >= autoOpenOnWidthValue;
|
|
@@ -37331,11 +37340,11 @@ var ChatWidgetUI = function (props) {
|
|
|
37331
37340
|
// Track whether autoOpenOnWidth has already fired so it doesn't re-open after user closes
|
|
37332
37341
|
var autoOpenFiredRef = React.useRef(autoOpenOnWidthMatch);
|
|
37333
37342
|
var chatServer = React.useContext(ChatServerContext);
|
|
37334
|
-
var patternsConfig = (
|
|
37343
|
+
var patternsConfig = (_r = (_q = props.config) === null || _q === void 0 ? void 0 : _q.autoOpenOnPattern) === null || _r === void 0 ? void 0 : _r.patterns;
|
|
37335
37344
|
var currentUrl = window.location.href;
|
|
37336
37345
|
var patternExist = patternsConfig && patternsConfig.length > 0;
|
|
37337
37346
|
var patternMatches = patternsConfig === null || patternsConfig === void 0 ? void 0 : patternsConfig.some(function (pattern) { return currentUrl.includes(pattern); });
|
|
37338
|
-
var configWidth = (
|
|
37347
|
+
var configWidth = (_t = (_s = props.config) === null || _s === void 0 ? void 0 : _s.autoOpenOnPattern) === null || _t === void 0 ? void 0 : _t.minimumWidth;
|
|
37339
37348
|
var currentWidth = window.innerWidth;
|
|
37340
37349
|
var setVisible = React.useCallback(function (newVisible) {
|
|
37341
37350
|
if (staticMode || previewMode) {
|
|
@@ -37662,7 +37671,7 @@ var ChatWidgetUI = function (props) {
|
|
|
37662
37671
|
var messages = chatState && chatState.chats;
|
|
37663
37672
|
log("Rendering - accountStatus: \"".concat(chatState.accountStatus, "\", connectionStatus: \"").concat(chatState.connection.connectionStatus, "\""));
|
|
37664
37673
|
var config = props.config, onConnectionStatusChange = props.onConnectionStatusChange;
|
|
37665
|
-
var actionBarEnabled = ((
|
|
37674
|
+
var actionBarEnabled = ((_u = config === null || config === void 0 ? void 0 : config.actionBar) === null || _u === void 0 ? void 0 : _u.enabled) === true;
|
|
37666
37675
|
// The host page declares this; the widget cannot work it out. On the standalone
|
|
37667
37676
|
// contact/booking page the form already *is* the page, which makes every button that
|
|
37668
37677
|
// only opens one redundant. XappMedia/chat-widget#1626.
|
|
@@ -37686,7 +37695,7 @@ var ChatWidgetUI = function (props) {
|
|
|
37686
37695
|
onConnectionStatusChange(connectionStatus);
|
|
37687
37696
|
}
|
|
37688
37697
|
}, [connectionStatus, onConnectionStatusChange]);
|
|
37689
|
-
useExternalScript((
|
|
37698
|
+
useExternalScript((_v = props.config) === null || _v === void 0 ? void 0 : _v.middlewareUrl);
|
|
37690
37699
|
// Only reach for form.xapp.ai when something on this page can still open the form.
|
|
37691
37700
|
//
|
|
37692
37701
|
// Loading it is not free: the script mounts a second form-widget instance whose wrapper
|
|
@@ -37726,13 +37735,13 @@ var ChatWidgetUI = function (props) {
|
|
|
37726
37735
|
};
|
|
37727
37736
|
}, [actionBarVisible]);
|
|
37728
37737
|
// This is a pseudo agent. It represent's the widget (shown in the header avatar for instance)
|
|
37729
|
-
var widgetAgent = ((
|
|
37738
|
+
var widgetAgent = ((_w = chatState.agents["agent:robot"]) === null || _w === void 0 ? void 0 : _w.user) ||
|
|
37730
37739
|
(config === null || config === void 0 ? void 0 : config.agent) || {
|
|
37731
37740
|
nick: "agent:robot",
|
|
37732
37741
|
avatarPath: config.avatarUrl,
|
|
37733
37742
|
display_name: "Agent",
|
|
37734
37743
|
};
|
|
37735
|
-
return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsxs("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()).concat(actionBarVisible ? " widget-container--with-action-bar" : ""), children: [require$$0.jsx(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }), require$$0.jsx(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick: handleRestartClick, minimizeOnClick: handleMinimizeClick, cancelOnClick: handleCancelClick, agent: widgetAgent, canRefresh: canRefresh, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header, menuConfig: config.menu, debugMode: (
|
|
37744
|
+
return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsxs("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()).concat(actionBarVisible ? " widget-container--with-action-bar" : ""), children: [require$$0.jsx(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }), !headerHidden && (require$$0.jsx(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick: handleRestartClick, minimizeOnClick: handleMinimizeClick, cancelOnClick: handleCancelClick, agent: widgetAgent, canRefresh: canRefresh, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header, menuConfig: config.menu, debugMode: (_z = (_y = (_x = props.config) === null || _x === void 0 ? void 0 : _x.connection) === null || _y === void 0 ? void 0 : _y.mcp) === null || _z === void 0 ? void 0 : _z.debugMode, onSubmit: handleOnSubmit })), require$$0.jsx(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, agent: config === null || config === void 0 ? void 0 : config.agent, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, hasWsButton: !!chatState.wsButton, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (_1 = (_0 = props.config) === null || _0 === void 0 ? void 0 : _0.typingStatus) === null || _1 === void 0 ? void 0 : _1.textTypingStatusEnabled, disableAutoScroll: props.disableAutoScroll, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl, minimizeOnClick: handleMinimizeClick }), require$$0.jsx("div", { className: "xa-spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : ""), children: require$$0.jsx("div", { className: "xa-spinner" }) }), connectionStatus === "offline" && require$$0.jsx(ServerOffline, {}), chatState.wsButton && visible && (require$$0.jsx(WsButton, { button: chatState.wsButton, onPress: handleWsButtonPress })), require$$0.jsx(ChatFooter, { isAdmin: config === null || config === void 0 ? void 0 : config.isAdmin, isChatting: chatState.isChatting, placeholder: (_2 = config === null || config === void 0 ? void 0 : config.input) === null || _2 === void 0 ? void 0 : _2.placeholder, sendButtonIcon: (_4 = (_3 = config === null || config === void 0 ? void 0 : config.footer) === null || _3 === void 0 ? void 0 : _3.sendButton) === null || _4 === void 0 ? void 0 : _4.icon, sendButtonIconHover: (_6 = (_5 = config === null || config === void 0 ? void 0 : config.footer) === null || _5 === void 0 ? void 0 : _5.sendButton) === null || _6 === void 0 ? void 0 : _6.iconHover, sendButtonIconDisabled: (_8 = (_7 = config === null || config === void 0 ? void 0 : config.footer) === null || _7 === void 0 ? void 0 : _7.sendButton) === null || _8 === void 0 ? void 0 : _8.iconDisabled, visible: visible, hasWsButton: !!chatState.wsButton, menuConfig: menuConfig, footerConfig: (_9 = props.config) === null || _9 === void 0 ? void 0 : _9.footer, inputConfig: (_10 = props.config) === null || _10 === void 0 ? void 0 : _10.input, disabled: previewMode, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload }), require$$0.jsx("div", { className: "restartModal", ref: modalRef, onClick: handleRestartModalCloseClick, children: require$$0.jsx(ModalContent, { onClose: handleRestartModalCloseClick, onReset: handleReset }) })] }), actionBarVisible && config.actionBar ? (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsx(ActionBar, { config: __assign$1(__assign$1({}, config.actionBar), {
|
|
37736
37745
|
// Use actionBar.cta if set, otherwise fall back to widget-level cta
|
|
37737
37746
|
cta: resolveCta((_11 = config.actionBar.cta) !== null && _11 !== void 0 ? _11 : config.cta, {
|
|
37738
37747
|
hasConversation: conversationOnScreen,
|