@xapp/chat-widget 1.50.2 → 1.52.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/components/Avatar/Avatar.d.ts +1 -1
- package/dist/components/ChatHeader/ChatHeader.d.ts +1 -2
- package/dist/components/ChatMessage/ChatMessage.d.ts +1 -1
- package/dist/components/ChatMessagePart/ChatMessagePart.d.ts +1 -1
- package/dist/components/ChatRating/ChatRating.d.ts +1 -1
- package/dist/components/ChatRating/ChatRatingContainer.d.ts +1 -1
- package/dist/components/ChatWidget/ChatWidget.stories.d.ts +1 -0
- package/dist/components/ChatWidget/ModalContent.d.ts +7 -0
- package/dist/hooks/useOpenUrlCallback.d.ts +2 -1
- package/dist/index.css +7 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.es.js +53 -17
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +53 -17
- package/dist/index.js.map +1 -1
- package/dist/middlewares/message-middleware.d.ts +1 -1
- package/dist/middlewares/middleware-ctx-factory.d.ts +1 -1
- package/dist/store/ChatAction.d.ts +1 -1
- package/dist/store/ChatState.d.ts +1 -1
- package/dist/store/actions/writeMessage.d.ts +1 -1
- package/dist/xapp/ChatServerMessage.d.ts +1 -1
- package/dist/xapp/StentorServerChat.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1584,9 +1584,6 @@ var Avatar = function (props) {
|
|
|
1584
1584
|
return (React__default$1["default"].createElement("div", { className: "avatar ".concat(agentAva ? "avatar--agent" : "avatar--visitor", " ").concat(!hasImage ? "avatar--empty" : ""), style: style, title: entity ? entity.display_name : "Agent" }, child));
|
|
1585
1585
|
};
|
|
1586
1586
|
|
|
1587
|
-
/**
|
|
1588
|
-
* This mirrors the declaration in Chat-Server
|
|
1589
|
-
*/
|
|
1590
1587
|
function isChatServerActionLink(arg) {
|
|
1591
1588
|
return arg.hasOwnProperty("label");
|
|
1592
1589
|
}
|
|
@@ -1997,9 +1994,11 @@ function execute(url, behavior) {
|
|
|
1997
1994
|
}
|
|
1998
1995
|
function useOpenUrlCallback() {
|
|
1999
1996
|
var env = useWidgetEnv();
|
|
2000
|
-
return React$1.useCallback(function (url) {
|
|
2001
|
-
|
|
2002
|
-
|
|
1997
|
+
return React$1.useCallback(function (url, behavior) {
|
|
1998
|
+
if (!behavior) {
|
|
1999
|
+
behavior = (env === null || env === void 0 ? void 0 : env.urls) ? resolveUrlPolicy(url, env.urls) : defaultBehavior;
|
|
2000
|
+
}
|
|
2001
|
+
execute(url, behavior);
|
|
2003
2002
|
}, [env]);
|
|
2004
2003
|
}
|
|
2005
2004
|
|
|
@@ -7155,7 +7154,7 @@ Object.defineProperty(WidgetTheme, "__esModule", { value: true });
|
|
|
7155
7154
|
var guards = {};
|
|
7156
7155
|
|
|
7157
7156
|
Object.defineProperty(guards, "__esModule", { value: true });
|
|
7158
|
-
guards.isStandardMenuItem = guards.isStaticTextMenuItem = guards.isStaticImageMenuItem = void 0;
|
|
7157
|
+
guards.isOpenURLMenuItem = guards.isStandardMenuItem = guards.isStaticTextMenuItem = guards.isStaticImageMenuItem = void 0;
|
|
7159
7158
|
function isStaticImageMenuItem(item) {
|
|
7160
7159
|
return !!item && !!item.imageUrl;
|
|
7161
7160
|
}
|
|
@@ -7168,6 +7167,10 @@ function isStandardMenuItem(item) {
|
|
|
7168
7167
|
return !!item && !!item.label;
|
|
7169
7168
|
}
|
|
7170
7169
|
guards.isStandardMenuItem = isStandardMenuItem;
|
|
7170
|
+
function isOpenURLMenuItem(item) {
|
|
7171
|
+
return !!item && !!item.url;
|
|
7172
|
+
}
|
|
7173
|
+
guards.isOpenURLMenuItem = isOpenURLMenuItem;
|
|
7171
7174
|
|
|
7172
7175
|
(function (exports) {
|
|
7173
7176
|
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
@@ -7208,9 +7211,11 @@ var ChatMenuItem = function (props) {
|
|
|
7208
7211
|
return (React__default$1["default"].createElement("button", { type: "button", className: "chat-menu-item", tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, onClick: handleClick }, content));
|
|
7209
7212
|
};
|
|
7210
7213
|
|
|
7214
|
+
var _this = undefined;
|
|
7211
7215
|
var ChatMenu = function (props) {
|
|
7212
7216
|
var items = props.items, opened = props.opened;
|
|
7213
7217
|
var openFrom = props.openFrom || "bottom";
|
|
7218
|
+
var handleOpenUrl = useOpenUrlCallback();
|
|
7214
7219
|
return (React__default$1["default"].createElement("div", { className: "chat-menu-".concat(openFrom, " ").concat(opened ? "chat-menu-".concat(openFrom, "--opened") : "chat-menu-".concat(openFrom, "--closed")) }, items.map(function (item, i) {
|
|
7215
7220
|
if (lib.isStandardMenuItem(item)) {
|
|
7216
7221
|
return React__default$1["default"].createElement(ChatMenuItem, { key: i, onClick: props.onItemClick, label: item.label, subtitle: item.subtitle });
|
|
@@ -7228,6 +7233,9 @@ var ChatMenu = function (props) {
|
|
|
7228
7233
|
React__default$1["default"].createElement("div", null, item.title),
|
|
7229
7234
|
React__default$1["default"].createElement("div", { className: "chat-menu-item-static-text--body" }, item.body))));
|
|
7230
7235
|
}
|
|
7236
|
+
else if (lib.isOpenURLMenuItem(item)) {
|
|
7237
|
+
return React__default$1["default"].createElement("button", { key: i, className: "chat-menu-item", onClick: handleOpenUrl.bind(_this, item.url, item.behavior) }, item.text);
|
|
7238
|
+
}
|
|
7231
7239
|
return React__default$1["default"].createElement("p", null, "Unknown");
|
|
7232
7240
|
})));
|
|
7233
7241
|
};
|
|
@@ -31061,6 +31069,17 @@ function getCtaStyle(style) {
|
|
|
31061
31069
|
return union(getBackgroundStyle(style.background), getTextStyle(style.text));
|
|
31062
31070
|
}
|
|
31063
31071
|
|
|
31072
|
+
var ModalContent = function (_a) {
|
|
31073
|
+
var onClose = _a.onClose, onReset = _a.onReset;
|
|
31074
|
+
return (React__default$1["default"].createElement("div", { className: "modalContent" },
|
|
31075
|
+
React__default$1["default"].createElement("div", { className: "modalBody" },
|
|
31076
|
+
React__default$1["default"].createElement("h2", null, "Restart Conversation"),
|
|
31077
|
+
React__default$1["default"].createElement("p", null, "Would you like to refresh and return to the starting point of the conversation?")),
|
|
31078
|
+
React__default$1["default"].createElement("div", { className: "modalActions" },
|
|
31079
|
+
React__default$1["default"].createElement("button", { onClick: onClose, className: "cancelBtn" }, "Cancel"),
|
|
31080
|
+
React__default$1["default"].createElement("button", { onClick: onReset, className: "restartBtn" }, "Restart"))));
|
|
31081
|
+
};
|
|
31082
|
+
|
|
31064
31083
|
var ChatWidgetWrapper = function (props) {
|
|
31065
31084
|
var rawConfig = props.config;
|
|
31066
31085
|
var connection = useConnectionInfo(rawConfig);
|
|
@@ -31071,7 +31090,9 @@ var ChatWidgetWrapper = function (props) {
|
|
|
31071
31090
|
var token = reactRedux.useSelector(function (state) { return state.connection.token; });
|
|
31072
31091
|
var options = React$1.useMemo(function () {
|
|
31073
31092
|
var configurableMessages = getConfigurableMessages();
|
|
31074
|
-
if (rawConfig.configurableMessages &&
|
|
31093
|
+
if (rawConfig.configurableMessages &&
|
|
31094
|
+
Array.isArray(rawConfig.configurableMessages.items) &&
|
|
31095
|
+
rawConfig.configurableMessages.items.length > 0) {
|
|
31075
31096
|
configurableMessages = rawConfig.configurableMessages;
|
|
31076
31097
|
}
|
|
31077
31098
|
return {
|
|
@@ -31079,7 +31100,7 @@ var ChatWidgetWrapper = function (props) {
|
|
|
31079
31100
|
bot: {
|
|
31080
31101
|
nick: "Bot",
|
|
31081
31102
|
displayName: rawConfig.botName,
|
|
31082
|
-
avatarPath: rawConfig.avatarUrl
|
|
31103
|
+
avatarPath: rawConfig.avatarUrl
|
|
31083
31104
|
},
|
|
31084
31105
|
configurableMessages: configurableMessages,
|
|
31085
31106
|
hooks: rawConfig.hooks
|
|
@@ -31096,6 +31117,13 @@ var ChatWidget = function (props) {
|
|
|
31096
31117
|
var dispatch = useChatServerDispatch();
|
|
31097
31118
|
// From Redux
|
|
31098
31119
|
var chatState = reactRedux.useSelector(function (state) { return state; });
|
|
31120
|
+
var modalRef = React$1.useRef({});
|
|
31121
|
+
function openModal() {
|
|
31122
|
+
modalRef.current.style.display = "block";
|
|
31123
|
+
}
|
|
31124
|
+
function closeModal() {
|
|
31125
|
+
modalRef.current.style.display = "none";
|
|
31126
|
+
}
|
|
31099
31127
|
var mode = (_a = props.mode) !== null && _a !== void 0 ? _a : "normal";
|
|
31100
31128
|
var dockedMode = mode === "docked";
|
|
31101
31129
|
var staticMode = mode === "static";
|
|
@@ -31111,7 +31139,10 @@ var ChatWidget = function (props) {
|
|
|
31111
31139
|
canCancel = !dockedMode && !staticMode;
|
|
31112
31140
|
}
|
|
31113
31141
|
// Our state - pull from storage
|
|
31114
|
-
var _x = React$1.useState((!canMinimize && !canCancel) ||
|
|
31142
|
+
var _x = React$1.useState((!canMinimize && !canCancel) ||
|
|
31143
|
+
!!get("visible") ||
|
|
31144
|
+
(((_k = props.config) === null || _k === void 0 ? void 0 : _k.autoOpenOnWidth) &&
|
|
31145
|
+
window.matchMedia("(min-width: ".concat((_l = props.config) === null || _l === void 0 ? void 0 : _l.autoOpenOnWidth, ")")).matches)), visible = _x[0], setVisibleState = _x[1];
|
|
31115
31146
|
var _y = React$1.useState(false), typing = _y[0], setTypingState = _y[1]; // false initially
|
|
31116
31147
|
var chatServer = React$1.useContext(ChatServerContext);
|
|
31117
31148
|
var setVisible = React$1.useCallback(function (newVisible) {
|
|
@@ -31123,7 +31154,7 @@ var ChatWidget = function (props) {
|
|
|
31123
31154
|
}, [staticMode]);
|
|
31124
31155
|
React$1.useEffect(function () {
|
|
31125
31156
|
var _a;
|
|
31126
|
-
document.addEventListener(
|
|
31157
|
+
document.addEventListener("keydown", function (event) {
|
|
31127
31158
|
var body = document.getElementsByTagName("body")[0];
|
|
31128
31159
|
body.tabIndex = -1;
|
|
31129
31160
|
if (event.key === "Escape") {
|
|
@@ -31186,6 +31217,7 @@ var ChatWidget = function (props) {
|
|
|
31186
31217
|
return visible ? "visible" : "";
|
|
31187
31218
|
}
|
|
31188
31219
|
function refreshOnClick() {
|
|
31220
|
+
closeModal();
|
|
31189
31221
|
innerDispatch(reset());
|
|
31190
31222
|
}
|
|
31191
31223
|
function minimizeOnClick() {
|
|
@@ -31211,15 +31243,17 @@ var ChatWidget = function (props) {
|
|
|
31211
31243
|
type: "chat.msg",
|
|
31212
31244
|
user: {
|
|
31213
31245
|
displayName: "Chat Agent",
|
|
31214
|
-
nick: "agent:offline"
|
|
31246
|
+
nick: "agent:offline"
|
|
31215
31247
|
},
|
|
31216
31248
|
timestamp: +new Date(),
|
|
31217
|
-
msg: {
|
|
31249
|
+
msg: {
|
|
31250
|
+
text: "Sorry, we are offline at the moment. Please leave us your contact information and we will get back to you soon!"
|
|
31251
|
+
}
|
|
31218
31252
|
});
|
|
31219
31253
|
messages.push({
|
|
31220
31254
|
type: "chat.offline",
|
|
31221
31255
|
user: {
|
|
31222
|
-
nick: "agent:offline"
|
|
31256
|
+
nick: "agent:offline"
|
|
31223
31257
|
},
|
|
31224
31258
|
timestamp: +new Date()
|
|
31225
31259
|
});
|
|
@@ -31230,7 +31264,7 @@ var ChatWidget = function (props) {
|
|
|
31230
31264
|
messages.push({
|
|
31231
31265
|
type: "chat.prechat",
|
|
31232
31266
|
user: {
|
|
31233
|
-
nick: "agent:offline"
|
|
31267
|
+
nick: "agent:offline"
|
|
31234
31268
|
},
|
|
31235
31269
|
timestamp: +new Date()
|
|
31236
31270
|
});
|
|
@@ -31248,12 +31282,14 @@ var ChatWidget = function (props) {
|
|
|
31248
31282
|
return (React__default$1["default"].createElement(React__default$1["default"].Fragment, null,
|
|
31249
31283
|
React__default$1["default"].createElement("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()) },
|
|
31250
31284
|
React__default$1["default"].createElement(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }),
|
|
31251
|
-
React__default$1["default"].createElement(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick:
|
|
31285
|
+
React__default$1["default"].createElement(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick: openModal, minimizeOnClick: minimizeOnClick, cancelOnClick: cancelOnClick, agent: ((_o = chatState.agents["agent:robot"]) === null || _o === void 0 ? void 0 : _o.user) || (config === null || config === void 0 ? void 0 : config.agent), canRefresh: canRefresh, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header, menuConfig: config.menu, onSubmit: handleOnSubmit }),
|
|
31252
31286
|
React__default$1["default"].createElement(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (_q = (_p = props.config) === null || _p === void 0 ? void 0 : _p.typingStatus) === null || _q === void 0 ? void 0 : _q.textTypingStatusEnabled, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl }),
|
|
31253
31287
|
React__default$1["default"].createElement("div", { className: "spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : "") },
|
|
31254
31288
|
React__default$1["default"].createElement("div", { className: "spinner" })),
|
|
31255
31289
|
connectionStatus === "offline" && React__default$1["default"].createElement(ServerOffline, null),
|
|
31256
|
-
React__default$1["default"].createElement(ChatFooter, { isChatting: chatState.isChatting, placeholder: (_r = config === null || config === void 0 ? void 0 : config.input) === null || _r === void 0 ? void 0 : _r.placeholder, sendButtonIcon: (_t = (_s = config === null || config === void 0 ? void 0 : config.footer) === null || _s === void 0 ? void 0 : _s.sendButton) === null || _t === void 0 ? void 0 : _t.icon, visible: visible, menuConfig: props.config.menu, footerConfig: (_u = props.config) === null || _u === void 0 ? void 0 : _u.footer, inputConfig: (_v = props.config) === null || _v === void 0 ? void 0 : _v.input, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload })
|
|
31290
|
+
React__default$1["default"].createElement(ChatFooter, { isChatting: chatState.isChatting, placeholder: (_r = config === null || config === void 0 ? void 0 : config.input) === null || _r === void 0 ? void 0 : _r.placeholder, sendButtonIcon: (_t = (_s = config === null || config === void 0 ? void 0 : config.footer) === null || _s === void 0 ? void 0 : _s.sendButton) === null || _t === void 0 ? void 0 : _t.icon, visible: visible, menuConfig: props.config.menu, footerConfig: (_u = props.config) === null || _u === void 0 ? void 0 : _u.footer, inputConfig: (_v = props.config) === null || _v === void 0 ? void 0 : _v.input, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload }),
|
|
31291
|
+
React__default$1["default"].createElement("div", { className: "restartModal", ref: modalRef, onClick: closeModal },
|
|
31292
|
+
React__default$1["default"].createElement(ModalContent, { onClose: closeModal, onReset: refreshOnClick }))),
|
|
31257
31293
|
React__default$1["default"].createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: (_w = props.config) === null || _w === void 0 ? void 0 : _w.cta, visible: visible })));
|
|
31258
31294
|
};
|
|
31259
31295
|
|