@xapp/chat-widget 1.57.4 → 1.58.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/ChatWidget/ChatWidget.stories.d.ts +2 -0
- package/dist/index.css +2 -2
- package/dist/index.d.ts +0 -0
- package/dist/index.es.js +151 -122
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +151 -121
- package/dist/index.js.map +1 -1
- package/dist/xapp-chat-widget.css +1 -1
- package/dist/xapp-chat-widget.js +1 -1
- package/dist/xapp-chat-widget.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -6693,6 +6693,10 @@ var ChatChipsContainer = function (_) {
|
|
|
6693
6693
|
React__default$1["default"].createElement(ChatChips, { options: chips, onOptionClick: optionOnChange })));
|
|
6694
6694
|
};
|
|
6695
6695
|
|
|
6696
|
+
var CancelButton = function (props) {
|
|
6697
|
+
return (React__default$1["default"].createElement("button", { id: "xapp-widget-close", "aria-label": "close widget", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "cancel-button", onClick: props.onClick }));
|
|
6698
|
+
};
|
|
6699
|
+
|
|
6696
6700
|
var lib = {};
|
|
6697
6701
|
|
|
6698
6702
|
var ChannelData = {};
|
|
@@ -6813,6 +6817,103 @@ var ChatMenu = function (props) {
|
|
|
6813
6817
|
})));
|
|
6814
6818
|
};
|
|
6815
6819
|
|
|
6820
|
+
var DrawerBars = function (props) {
|
|
6821
|
+
var bars = props.bars;
|
|
6822
|
+
// 0 is not a valid number of bars so a simple truthy check works here
|
|
6823
|
+
if (!bars) {
|
|
6824
|
+
bars = 2;
|
|
6825
|
+
}
|
|
6826
|
+
function getBars() {
|
|
6827
|
+
var barElements = [];
|
|
6828
|
+
for (var bar = 0; bar < bars; bar++) {
|
|
6829
|
+
barElements.push(React__default$1["default"].createElement("div", { className: "drawer-bar bar".concat(bar) }));
|
|
6830
|
+
}
|
|
6831
|
+
return barElements;
|
|
6832
|
+
}
|
|
6833
|
+
return (React__default$1["default"].createElement("button", { className: "drawer-bars", tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, "aria-label": "open menu", "aria-hidden": false, onClick: props.onToggle }, getBars()));
|
|
6834
|
+
};
|
|
6835
|
+
|
|
6836
|
+
var MinimizeButton = function (props) {
|
|
6837
|
+
return (React__default$1["default"].createElement("button", { id: "xapp-widget-minimize", "aria-label": "minimize widget", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "minimize-button ".concat(props.showInRight ? "positionRight" : ""), onClick: props.onClick }));
|
|
6838
|
+
};
|
|
6839
|
+
|
|
6840
|
+
var RefreshButton = function (props) {
|
|
6841
|
+
return (React__default$1["default"].createElement("button", { id: "xapp-widget-refresh", "aria-label": "refresh chat", "aria-hidden": false, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "refresh-button ".concat(props.showInRight ? "positionRight" : props.showInLeft ? "positionLeft" : ""), onClick: props.onClick }));
|
|
6842
|
+
};
|
|
6843
|
+
|
|
6844
|
+
var DEFAULT_STATUS_CONFIG = {
|
|
6845
|
+
online: "Virtual Assistant",
|
|
6846
|
+
offline: "Leave us a message",
|
|
6847
|
+
away: "We're away!",
|
|
6848
|
+
connecting: "Connecting...",
|
|
6849
|
+
};
|
|
6850
|
+
function getStatusText(status, config) {
|
|
6851
|
+
var _a, _b, _c, _d;
|
|
6852
|
+
switch (status) {
|
|
6853
|
+
case "online":
|
|
6854
|
+
return (_a = config === null || config === void 0 ? void 0 : config.online) !== null && _a !== void 0 ? _a : DEFAULT_STATUS_CONFIG.online;
|
|
6855
|
+
case "offline":
|
|
6856
|
+
return (_b = config === null || config === void 0 ? void 0 : config.offline) !== null && _b !== void 0 ? _b : DEFAULT_STATUS_CONFIG.offline;
|
|
6857
|
+
case "away":
|
|
6858
|
+
return (_c = config === null || config === void 0 ? void 0 : config.away) !== null && _c !== void 0 ? _c : DEFAULT_STATUS_CONFIG.away;
|
|
6859
|
+
default:
|
|
6860
|
+
return (_d = config === null || config === void 0 ? void 0 : config.connecting) !== null && _d !== void 0 ? _d : DEFAULT_STATUS_CONFIG.connecting;
|
|
6861
|
+
}
|
|
6862
|
+
}
|
|
6863
|
+
var refreshButtonAriaLabel = "To refresh chat click on clockwise gapped circle arrow icon in top right side of widget. ";
|
|
6864
|
+
var minimizeButtonAriaLabel = "To minimize widget click on minus icon in top right side of widget. ";
|
|
6865
|
+
var closeButtonAriaLabel = "To close widget click on close icon in top right side of widget.";
|
|
6866
|
+
var ChatHeader = function (props) {
|
|
6867
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
6868
|
+
var innerDispatch = useChatDispatch();
|
|
6869
|
+
var menuConfig = props.menuConfig, onSubmit = props.onSubmit;
|
|
6870
|
+
var _s = React$1.useState(false), drawerOpen = _s[0], setDrawerState = _s[1]; // false initially
|
|
6871
|
+
var menuPosition = (menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.menuButtonLocation) || "FOOTER";
|
|
6872
|
+
var showMenu = menuPosition === "HEADER_LEFT";
|
|
6873
|
+
var menuItemsRaw = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.items; // useWidgetEnv()?.menu?.items;
|
|
6874
|
+
var menuItemsTabIndex = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.itemsTabIndex; // useWidgetEnv()?.menu?.itemsTabIndex;
|
|
6875
|
+
var menuButtonTabIndex = (_a = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.button) === null || _a === void 0 ? void 0 : _a.tabIndex; // useWidgetEnv()?.menu?.button?.tabIndex;
|
|
6876
|
+
var menuItems = React$1.useMemo(function () { return menuItemsRaw ? menuItemsRaw : []; }, [menuItemsRaw]);
|
|
6877
|
+
function toggleDrawer() {
|
|
6878
|
+
var newDrawer = !drawerOpen;
|
|
6879
|
+
setDrawerState(newDrawer);
|
|
6880
|
+
innerDispatch(setVisualStatus({
|
|
6881
|
+
drawer: newDrawer
|
|
6882
|
+
}));
|
|
6883
|
+
}
|
|
6884
|
+
function handleMenuItem(label) {
|
|
6885
|
+
setDrawerState(false);
|
|
6886
|
+
onSubmit(label);
|
|
6887
|
+
}
|
|
6888
|
+
var ariaLabel = "";
|
|
6889
|
+
var canRefresh = props.canRefresh, canMinimize = props.canMinimize, canCancel = props.canCancel;
|
|
6890
|
+
if (canRefresh) {
|
|
6891
|
+
ariaLabel = refreshButtonAriaLabel;
|
|
6892
|
+
}
|
|
6893
|
+
if (canMinimize) {
|
|
6894
|
+
ariaLabel = "".concat(ariaLabel).concat(minimizeButtonAriaLabel);
|
|
6895
|
+
}
|
|
6896
|
+
if (canCancel) {
|
|
6897
|
+
ariaLabel = "".concat(ariaLabel).concat(closeButtonAriaLabel);
|
|
6898
|
+
}
|
|
6899
|
+
return (React__default$1["default"].createElement(React__default$1["default"].Fragment, null,
|
|
6900
|
+
React__default$1["default"].createElement("div", { className: "status-container background-header", "aria-label": ariaLabel, "aria-hidden": false },
|
|
6901
|
+
showMenu && menuItems.length ? (React__default$1["default"].createElement(React__default$1["default"].Fragment, null,
|
|
6902
|
+
React__default$1["default"].createElement("div", { className: "chat-footer__menu-icon" },
|
|
6903
|
+
React__default$1["default"].createElement(DrawerBars, { bars: 3, tabIndex: menuButtonTabIndex, onToggle: toggleDrawer })))) : React__default$1["default"].createElement(React__default$1["default"].Fragment, null),
|
|
6904
|
+
((_b = props === null || props === void 0 ? void 0 : props.agent) === null || _b === void 0 ? void 0 : _b.avatarPath) === undefined ? React__default$1["default"].createElement("div", null) :
|
|
6905
|
+
React__default$1["default"].createElement("div", { className: "status-container__avatar" },
|
|
6906
|
+
React__default$1["default"].createElement(Avatar, { entity: props.agent })),
|
|
6907
|
+
React__default$1["default"].createElement("div", { className: "\n ".concat("status-text", "\n ").concat(((_c = props === null || props === void 0 ? void 0 : props.agent) === null || _c === void 0 ? void 0 : _c.avatarPath) === undefined ? "status-text-positionLeftNoAvatar" : "status-text-positionLeft", "\n ").concat(((_d = props.config) === null || _d === void 0 ? void 0 : _d.alignTextCenter) ? "status-text-positionCenter" : "status-text-positionLeft", " \n ") },
|
|
6908
|
+
React__default$1["default"].createElement("span", { className: "status-text-title" }, getStatusText(props.accountStatus, (_e = props.config) === null || _e === void 0 ? void 0 : _e.status)),
|
|
6909
|
+
((_g = (_f = props.config) === null || _f === void 0 ? void 0 : _f.subtitle) === null || _g === void 0 ? void 0 : _g.enabled) && (React__default$1["default"].createElement("span", { className: "status-text-subtitle" }, (_k = (_j = (_h = props.config) === null || _h === void 0 ? void 0 : _h.subtitle) === null || _j === void 0 ? void 0 : _j.text) !== null && _k !== void 0 ? _k : ""))),
|
|
6910
|
+
props.canRefresh && (React__default$1["default"].createElement(RefreshButton, { onClick: props.refreshOnClick, tabIndex: (_m = (_l = props.config) === null || _l === void 0 ? void 0 : _l.actions) === null || _m === void 0 ? void 0 : _m.refreshTabIndex, showInLeft: props.canMinimize && props.canCancel, showInRight: !props.canMinimize && !props.canCancel })),
|
|
6911
|
+
props.canMinimize && (React__default$1["default"].createElement(MinimizeButton, { onClick: props.minimizeOnClick, tabIndex: (_p = (_o = props.config) === null || _o === void 0 ? void 0 : _o.actions) === null || _p === void 0 ? void 0 : _p.minimizeTabIndex, showInRight: !props.canCancel })),
|
|
6912
|
+
props.canCancel && (React__default$1["default"].createElement(CancelButton, { onClick: props.cancelOnClick, tabIndex: (_r = (_q = props.config) === null || _q === void 0 ? void 0 : _q.actions) === null || _r === void 0 ? void 0 : _r.cancelTabIndex }))),
|
|
6913
|
+
drawerOpen ? (React__default$1["default"].createElement("div", { className: "xa-chat-menu-container" },
|
|
6914
|
+
React__default$1["default"].createElement(ChatMenu, { openFrom: "left", opened: drawerOpen, tabIndex: menuItemsTabIndex, onItemClick: handleMenuItem, items: menuItems }))) : React__default$1["default"].createElement(React__default$1["default"].Fragment, null)));
|
|
6915
|
+
};
|
|
6916
|
+
|
|
6816
6917
|
var UnknownMessage = function () { return React__default$1["default"].createElement(React__default$1["default"].Fragment, null); };
|
|
6817
6918
|
|
|
6818
6919
|
function renderAvatar(entity) {
|
|
@@ -7660,22 +7761,6 @@ var ChatBranding = function (props) {
|
|
|
7660
7761
|
return (React__default$1["default"].createElement("div", { className: "chat-footer__branding" }, text !== null && text !== void 0 ? text : "Powered by XAPP AI"));
|
|
7661
7762
|
};
|
|
7662
7763
|
|
|
7663
|
-
var DrawerBars = function (props) {
|
|
7664
|
-
var bars = props.bars;
|
|
7665
|
-
// 0 is not a valid number of bars so a simple truthy check works here
|
|
7666
|
-
if (!bars) {
|
|
7667
|
-
bars = 2;
|
|
7668
|
-
}
|
|
7669
|
-
function getBars() {
|
|
7670
|
-
var barElements = [];
|
|
7671
|
-
for (var bar = 0; bar < bars; bar++) {
|
|
7672
|
-
barElements.push(React__default$1["default"].createElement("div", { className: "drawer-bar bar".concat(bar) }));
|
|
7673
|
-
}
|
|
7674
|
-
return barElements;
|
|
7675
|
-
}
|
|
7676
|
-
return (React__default$1["default"].createElement("button", { className: "drawer-bars", tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, "aria-label": "open menu", "aria-hidden": true, onClick: props.onToggle }, getBars()));
|
|
7677
|
-
};
|
|
7678
|
-
|
|
7679
7764
|
var CloseIcon = function () {
|
|
7680
7765
|
// Sergey, I added this style, you will probably want to change it to be more appropriate
|
|
7681
7766
|
return (React__default$1["default"].createElement("svg", { style: { color: "grey", paddingRight: "5px" }, xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 16 16" },
|
|
@@ -7749,10 +7834,10 @@ var Input = function (props) {
|
|
|
7749
7834
|
}, [suggestion, onChange, onSuggestionCommand]);
|
|
7750
7835
|
return (React__default$1["default"].createElement("div", { className: "xappw-input-container ".concat(props.addClass, " ").concat(dragover ? "drag-drop-zone" : ""), "aria-label": "To start typing click on rounded rectangle at the bottom of widget. To send your message click icon on right side of rounded rectangle at the bottom of widget" +
|
|
7751
7836
|
value.text
|
|
7752
|
-
? "To clear
|
|
7753
|
-
: "", "aria-hidden":
|
|
7837
|
+
? "To clear input field click on clear icon on the left of send button"
|
|
7838
|
+
: "", "aria-hidden": false, onDrop: onDrop, onDragOver: onDragOver, onDragLeave: onDragLeave },
|
|
7754
7839
|
React__default$1["default"].createElement("form", { className: "xappw-input-form", onSubmit: handleOnSubmit },
|
|
7755
|
-
React__default$1["default"].createElement(RichInput_1, { key: "input", id: "chatWidgetInput", className: "xappw-input", placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "
|
|
7840
|
+
React__default$1["default"].createElement(RichInput_1, { key: "input", id: "chatWidgetInput", className: "xappw-input", placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "type your question here", tabIndex: inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.tabIndex, onInput: onChange, onChange: onChange, onKeyDown: handleKeyDown,
|
|
7756
7841
|
// onFocus={onFocus}
|
|
7757
7842
|
value: value, spellCheck: true }),
|
|
7758
7843
|
React__default$1["default"].createElement("div", { className: "xappw-input-form__buttons" },
|
|
@@ -7863,7 +7948,7 @@ var ChatFooter = function (props) {
|
|
|
7863
7948
|
setInput(data);
|
|
7864
7949
|
setSuggestionSearch(data.text);
|
|
7865
7950
|
}, []);
|
|
7866
|
-
return (React__default$1["default"].createElement("div", { className: "chat-footer background-footer", "aria-label": menuItems.length ? "to open menu click a button above the rounded rectangle at the bottom of widget" : "", "aria-hidden":
|
|
7951
|
+
return (React__default$1["default"].createElement("div", { className: "chat-footer background-footer", "aria-label": menuItems.length ? "to open menu click a button above the rounded rectangle at the bottom of widget" : "", "aria-hidden": false },
|
|
7867
7952
|
showMenu && menuItems.length ?
|
|
7868
7953
|
React__default$1["default"].createElement(React__default$1["default"].Fragment, null,
|
|
7869
7954
|
drawerOpen ? React__default$1["default"].createElement(ChatMenu, { opened: drawerOpen, tabIndex: menuItemsTabIndex, onItemClick: handleMenuItem, items: menuItems }) : React__default$1["default"].createElement(React__default$1["default"].Fragment, null),
|
|
@@ -30447,80 +30532,6 @@ var ServerOffline = function () {
|
|
|
30447
30532
|
React__default$1["default"].createElement("h3", null, "Server is offline"));
|
|
30448
30533
|
};
|
|
30449
30534
|
|
|
30450
|
-
var CancelButton = function (props) {
|
|
30451
|
-
return (React__default$1["default"].createElement("button", { id: "xapp-widget-close", "aria-label": "close widget", "aria-hidden": true, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "cancel-button", onClick: props.onClick }));
|
|
30452
|
-
};
|
|
30453
|
-
|
|
30454
|
-
var MinimizeButton = function (props) {
|
|
30455
|
-
return (React__default$1["default"].createElement("button", { id: "xapp-widget-minimize", "aria-label": "minimize widget", "aria-hidden": true, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "minimize-button ".concat(props.showInRight ? "positionRight" : ""), onClick: props.onClick }));
|
|
30456
|
-
};
|
|
30457
|
-
|
|
30458
|
-
var RefreshButton = function (props) {
|
|
30459
|
-
return (React__default$1["default"].createElement("button", { id: "xapp-widget-refresh", "aria-label": "refresh chat", "aria-hidden": true, tabIndex: props.tabIndex ? Number(props.tabIndex) : 0, className: "refresh-button ".concat(props.showInRight ? "positionRight" : props.showInLeft ? "positionLeft" : ""), onClick: props.onClick }));
|
|
30460
|
-
};
|
|
30461
|
-
|
|
30462
|
-
var DEFAULT_STATUS_CONFIG = {
|
|
30463
|
-
online: "Virtual Assistant",
|
|
30464
|
-
offline: "Leave us a message",
|
|
30465
|
-
away: "We're away!",
|
|
30466
|
-
connecting: "Connecting...",
|
|
30467
|
-
};
|
|
30468
|
-
function getStatusText(status, config) {
|
|
30469
|
-
var _a, _b, _c, _d;
|
|
30470
|
-
switch (status) {
|
|
30471
|
-
case "online":
|
|
30472
|
-
return (_a = config === null || config === void 0 ? void 0 : config.online) !== null && _a !== void 0 ? _a : DEFAULT_STATUS_CONFIG.online;
|
|
30473
|
-
case "offline":
|
|
30474
|
-
return (_b = config === null || config === void 0 ? void 0 : config.offline) !== null && _b !== void 0 ? _b : DEFAULT_STATUS_CONFIG.offline;
|
|
30475
|
-
case "away":
|
|
30476
|
-
return (_c = config === null || config === void 0 ? void 0 : config.away) !== null && _c !== void 0 ? _c : DEFAULT_STATUS_CONFIG.away;
|
|
30477
|
-
default:
|
|
30478
|
-
return (_d = config === null || config === void 0 ? void 0 : config.connecting) !== null && _d !== void 0 ? _d : DEFAULT_STATUS_CONFIG.connecting;
|
|
30479
|
-
}
|
|
30480
|
-
}
|
|
30481
|
-
var refreshButtonAriaLabel = "To refresh chat click on clockwise gapped circle arrow icon in top right side of widget. ";
|
|
30482
|
-
var minimizeButtonAriaLabel = "To minimize widget click on minus icon in top right side of widget. ";
|
|
30483
|
-
var closeButtonAriaLabel = "To close widget click on close icon in top right side of widget.";
|
|
30484
|
-
var ChatHeader = function (props) {
|
|
30485
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
30486
|
-
var innerDispatch = useChatDispatch();
|
|
30487
|
-
var menuConfig = props.menuConfig, onSubmit = props.onSubmit;
|
|
30488
|
-
var _s = React$1.useState(false), drawerOpen = _s[0], setDrawerState = _s[1]; // false initially
|
|
30489
|
-
var menuPosition = (menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.menuButtonLocation) || "FOOTER";
|
|
30490
|
-
var showMenu = menuPosition === "HEADER_LEFT";
|
|
30491
|
-
var menuItemsRaw = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.items; // useWidgetEnv()?.menu?.items;
|
|
30492
|
-
var menuItemsTabIndex = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.itemsTabIndex; // useWidgetEnv()?.menu?.itemsTabIndex;
|
|
30493
|
-
var menuButtonTabIndex = (_a = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.button) === null || _a === void 0 ? void 0 : _a.tabIndex; // useWidgetEnv()?.menu?.button?.tabIndex;
|
|
30494
|
-
var menuItems = React$1.useMemo(function () { return menuItemsRaw ? menuItemsRaw : []; }, [menuItemsRaw]);
|
|
30495
|
-
function toggleDrawer() {
|
|
30496
|
-
var newDrawer = !drawerOpen;
|
|
30497
|
-
setDrawerState(newDrawer);
|
|
30498
|
-
innerDispatch(setVisualStatus({
|
|
30499
|
-
drawer: newDrawer
|
|
30500
|
-
}));
|
|
30501
|
-
}
|
|
30502
|
-
function handleMenuItem(label) {
|
|
30503
|
-
setDrawerState(false);
|
|
30504
|
-
onSubmit(label);
|
|
30505
|
-
}
|
|
30506
|
-
return (React__default$1["default"].createElement(React__default$1["default"].Fragment, null,
|
|
30507
|
-
React__default$1["default"].createElement("div", { className: "status-container background-header", "aria-label": props.canRefresh ? refreshButtonAriaLabel : "" + props.canMinimize ? minimizeButtonAriaLabel : "" + props.canCancel ? closeButtonAriaLabel : "", "aria-hidden": true },
|
|
30508
|
-
showMenu && menuItems.length ? (React__default$1["default"].createElement(React__default$1["default"].Fragment, null,
|
|
30509
|
-
React__default$1["default"].createElement("div", { className: "chat-footer__menu-icon" },
|
|
30510
|
-
React__default$1["default"].createElement(DrawerBars, { bars: 3, tabIndex: menuButtonTabIndex, onToggle: toggleDrawer })))) : React__default$1["default"].createElement(React__default$1["default"].Fragment, null),
|
|
30511
|
-
((_b = props === null || props === void 0 ? void 0 : props.agent) === null || _b === void 0 ? void 0 : _b.avatarPath) === undefined ? React__default$1["default"].createElement("div", null) :
|
|
30512
|
-
React__default$1["default"].createElement("div", { className: "status-container__avatar" },
|
|
30513
|
-
React__default$1["default"].createElement(Avatar, { entity: props.agent })),
|
|
30514
|
-
React__default$1["default"].createElement("div", { className: "\n ".concat("status-text", "\n ").concat(((_c = props === null || props === void 0 ? void 0 : props.agent) === null || _c === void 0 ? void 0 : _c.avatarPath) === undefined ? "status-text-positionLeftNoAvatar" : "status-text-positionLeft", "\n ").concat(((_d = props.config) === null || _d === void 0 ? void 0 : _d.alignTextCenter) ? "status-text-positionCenter" : "status-text-positionLeft", " \n ") },
|
|
30515
|
-
React__default$1["default"].createElement("span", { className: "status-text-title" }, getStatusText(props.accountStatus, (_e = props.config) === null || _e === void 0 ? void 0 : _e.status)),
|
|
30516
|
-
((_g = (_f = props.config) === null || _f === void 0 ? void 0 : _f.subtitle) === null || _g === void 0 ? void 0 : _g.enabled) && (React__default$1["default"].createElement("span", { className: "status-text-subtitle" }, (_k = (_j = (_h = props.config) === null || _h === void 0 ? void 0 : _h.subtitle) === null || _j === void 0 ? void 0 : _j.text) !== null && _k !== void 0 ? _k : ""))),
|
|
30517
|
-
props.canRefresh && (React__default$1["default"].createElement(RefreshButton, { onClick: props.refreshOnClick, tabIndex: (_m = (_l = props.config) === null || _l === void 0 ? void 0 : _l.actions) === null || _m === void 0 ? void 0 : _m.refreshTabIndex, showInLeft: props.canMinimize && props.canCancel, showInRight: !props.canMinimize && !props.canCancel })),
|
|
30518
|
-
props.canMinimize && (React__default$1["default"].createElement(MinimizeButton, { onClick: props.minimizeOnClick, tabIndex: (_p = (_o = props.config) === null || _o === void 0 ? void 0 : _o.actions) === null || _p === void 0 ? void 0 : _p.minimizeTabIndex, showInRight: !props.canCancel })),
|
|
30519
|
-
props.canCancel && (React__default$1["default"].createElement(CancelButton, { onClick: props.cancelOnClick, tabIndex: (_r = (_q = props.config) === null || _q === void 0 ? void 0 : _q.actions) === null || _r === void 0 ? void 0 : _r.cancelTabIndex }))),
|
|
30520
|
-
drawerOpen ? (React__default$1["default"].createElement("div", { className: "xa-chat-menu-container" },
|
|
30521
|
-
React__default$1["default"].createElement(ChatMenu, { openFrom: "left", opened: drawerOpen, tabIndex: menuItemsTabIndex, onItemClick: handleMenuItem, items: menuItems }))) : React__default$1["default"].createElement(React__default$1["default"].Fragment, null)));
|
|
30522
|
-
};
|
|
30523
|
-
|
|
30524
30535
|
function buildStyleContent(theme) {
|
|
30525
30536
|
var _a, _b, _c, _d, _e;
|
|
30526
30537
|
return "\n:root {\n".concat(buildVariables(withPrefix("\t--xapp-", union(single("primary-color", theme === null || theme === void 0 ? void 0 : theme.primaryColor), withPrefix("widget-", union(getSize(theme === null || theme === void 0 ? void 0 : theme.size), getMargins(theme === null || theme === void 0 ? void 0 : theme.margin), getBorderStyle(theme === null || theme === void 0 ? void 0 : theme.border), getZIndex(theme === null || theme === void 0 ? void 0 : theme.zIndex))), getChatButtonStyle(theme === null || theme === void 0 ? void 0 : theme.chatButton), withPrefix("header-", getHeaderStyle(theme === null || theme === void 0 ? void 0 : theme.header)), withPrefix("footer-", getFooterStyle(theme === null || theme === void 0 ? void 0 : theme.footer)), withPrefix("content-", union(getBackgroundStyle((_a = theme === null || theme === void 0 ? void 0 : theme.content) === null || _a === void 0 ? void 0 : _a.background))), withPrefix("messages-", getMessagesStyle(theme === null || theme === void 0 ? void 0 : theme.messages)), withPrefix("text-typing-status-", getTextStyle((_b = theme === null || theme === void 0 ? void 0 : theme.textTypingStatus) === null || _b === void 0 ? void 0 : _b.text)), withPrefix("send-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.sendButton)), withPrefix("menu-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.menuButton)), withPrefix("menu-", getMenuStyle(theme === null || theme === void 0 ? void 0 : theme.menu)), withPrefix("refresh-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.refreshButton)), withPrefix("minimize-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.minimizeButton)), withPrefix("cancel-", getButtonStyle(theme === null || theme === void 0 ? void 0 : theme.cancelButton)), withPrefix("carousel-", union(withPrefix("title-", getTextStyle((_c = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _c === void 0 ? void 0 : _c.title)), withPrefix("subtitle-", getTextStyle((_d = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _d === void 0 ? void 0 : _d.subtitle)), withPrefix("action-", getButtonStyle((_e = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _e === void 0 ? void 0 : _e.button)))), withPrefix("input-", getInputStyle(theme === null || theme === void 0 ? void 0 : theme.input)), withPrefix("cta-", getCtaStyle(theme === null || theme === void 0 ? void 0 : theme.cta))))), "\n}");
|
|
@@ -30832,28 +30843,25 @@ var ChatWidgetWrapper = function (props) {
|
|
|
30832
30843
|
React__default$1["default"].createElement(ChatWidget, __assign({}, props)))));
|
|
30833
30844
|
};
|
|
30834
30845
|
var ChatWidget = function (props) {
|
|
30835
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
30846
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
30836
30847
|
var innerDispatch = useChatDispatch();
|
|
30837
30848
|
var dispatch = useChatServerDispatch();
|
|
30838
30849
|
// From Redux
|
|
30839
30850
|
var chatState = reactRedux.useSelector(function (state) { return state; });
|
|
30851
|
+
// Refresh modalReference
|
|
30840
30852
|
var modalRef = React$1.useRef({});
|
|
30841
|
-
function openModal() {
|
|
30842
|
-
modalRef.current.style.display = "block";
|
|
30843
|
-
}
|
|
30844
|
-
function closeModal() {
|
|
30845
|
-
modalRef.current.style.display = "none";
|
|
30846
|
-
}
|
|
30847
30853
|
var mode = (_a = props.mode) !== null && _a !== void 0 ? _a : "normal";
|
|
30848
30854
|
var dockedMode = mode === "docked";
|
|
30849
30855
|
var staticMode = mode === "static";
|
|
30850
30856
|
var modeClass = "widget-container--".concat(mode);
|
|
30851
30857
|
var canRefresh = (_c = (_b = props.config.header) === null || _b === void 0 ? void 0 : _b.actions) === null || _c === void 0 ? void 0 : _c.refresh;
|
|
30858
|
+
// can't minimize in docked mode or static mode.
|
|
30852
30859
|
var canMinimize = !dockedMode && !staticMode && ((_e = (_d = props.config.header) === null || _d === void 0 ? void 0 : _d.actions) === null || _e === void 0 ? void 0 : _e.minimize);
|
|
30860
|
+
console.log("".concat(dockedMode, " ").concat(staticMode, " ").concat((_g = (_f = props.config.header) === null || _f === void 0 ? void 0 : _f.actions) === null || _g === void 0 ? void 0 : _g.minimize));
|
|
30853
30861
|
var canCancel;
|
|
30854
30862
|
// To preserve legacy behavior, cancel needs a little more checks
|
|
30855
|
-
if (typeof ((
|
|
30856
|
-
canCancel = !dockedMode && !staticMode && ((
|
|
30863
|
+
if (typeof ((_j = (_h = props.config.header) === null || _h === void 0 ? void 0 : _h.actions) === null || _j === void 0 ? void 0 : _j.cancel) === "boolean") {
|
|
30864
|
+
canCancel = !dockedMode && !staticMode && ((_l = (_k = props.config.header) === null || _k === void 0 ? void 0 : _k.actions) === null || _l === void 0 ? void 0 : _l.cancel);
|
|
30857
30865
|
}
|
|
30858
30866
|
else {
|
|
30859
30867
|
canCancel = !dockedMode && !staticMode;
|
|
@@ -30863,18 +30871,18 @@ var ChatWidget = function (props) {
|
|
|
30863
30871
|
chatState.visuals = {};
|
|
30864
30872
|
}
|
|
30865
30873
|
// Our state - pull from storage
|
|
30866
|
-
var
|
|
30874
|
+
var _3 = React$1.useState((!canMinimize && !canCancel) ||
|
|
30867
30875
|
// !!get("visible") ||
|
|
30868
30876
|
chatState.visuals.visible ||
|
|
30869
|
-
(((
|
|
30870
|
-
window.matchMedia("(min-width: ".concat((
|
|
30871
|
-
var
|
|
30877
|
+
(((_m = props.config) === null || _m === void 0 ? void 0 : _m.autoOpenOnWidth) &&
|
|
30878
|
+
window.matchMedia("(min-width: ".concat((_o = props.config) === null || _o === void 0 ? void 0 : _o.autoOpenOnWidth, ")")).matches)), visible = _3[0], setVisibleState = _3[1];
|
|
30879
|
+
var _4 = React$1.useState(false), typing = _4[0], setTypingState = _4[1]; // false initially
|
|
30872
30880
|
var chatServer = React$1.useContext(ChatServerContext);
|
|
30873
|
-
var patternsConfig = (
|
|
30881
|
+
var patternsConfig = (_q = (_p = props.config) === null || _p === void 0 ? void 0 : _p.autoOpenOnPattern) === null || _q === void 0 ? void 0 : _q.patterns;
|
|
30874
30882
|
var currentUrl = window.location.href;
|
|
30875
30883
|
var patternExist = patternsConfig && patternsConfig.length > 0;
|
|
30876
30884
|
var patternMatches = patternsConfig === null || patternsConfig === void 0 ? void 0 : patternsConfig.some(function (pattern) { return currentUrl.includes(pattern); });
|
|
30877
|
-
var configWidth = (
|
|
30885
|
+
var configWidth = (_s = (_r = props.config) === null || _r === void 0 ? void 0 : _r.autoOpenOnPattern) === null || _s === void 0 ? void 0 : _s.minimumWidth;
|
|
30878
30886
|
// eslint-disable-next-line no-restricted-globals
|
|
30879
30887
|
var currentWidth = screen.width;
|
|
30880
30888
|
var setVisible = React$1.useCallback(function (newVisible) {
|
|
@@ -30961,17 +30969,38 @@ var ChatWidget = function (props) {
|
|
|
30961
30969
|
function getVisibilityClass() {
|
|
30962
30970
|
return visible ? "visible" : "";
|
|
30963
30971
|
}
|
|
30964
|
-
function
|
|
30965
|
-
|
|
30972
|
+
function openRestartConfirmationModal() {
|
|
30973
|
+
// Interesting, this call the modalRef of the restart modal
|
|
30974
|
+
modalRef.current.style.display = "block";
|
|
30975
|
+
}
|
|
30976
|
+
function closeRestartConfirmationModal() {
|
|
30977
|
+
modalRef.current.style.display = "none";
|
|
30978
|
+
}
|
|
30979
|
+
function handleReset() {
|
|
30966
30980
|
innerDispatch(reset());
|
|
30967
30981
|
}
|
|
30968
|
-
function
|
|
30982
|
+
function handleRestartClick() {
|
|
30983
|
+
if (config.header.actions.refreshShowConfirmation) {
|
|
30984
|
+
// show the modal
|
|
30985
|
+
openRestartConfirmationModal();
|
|
30986
|
+
// we will close when
|
|
30987
|
+
}
|
|
30988
|
+
else {
|
|
30989
|
+
handleReset();
|
|
30990
|
+
}
|
|
30991
|
+
}
|
|
30992
|
+
function handleRestartModalCloseClick() {
|
|
30993
|
+
closeRestartConfirmationModal();
|
|
30994
|
+
}
|
|
30995
|
+
/** Called when minimize button is clicked */
|
|
30996
|
+
function handleMinimizeClick() {
|
|
30969
30997
|
innerDispatch(setVisualStatus({
|
|
30970
30998
|
opened: false
|
|
30971
30999
|
}));
|
|
30972
31000
|
setVisible(false);
|
|
30973
31001
|
}
|
|
30974
|
-
|
|
31002
|
+
/** Called when cancel is clicked */
|
|
31003
|
+
function handleCancelClick() {
|
|
30975
31004
|
//set("opened", false);
|
|
30976
31005
|
innerDispatch(setVisualStatus({
|
|
30977
31006
|
opened: false
|
|
@@ -31030,22 +31059,22 @@ var ChatWidget = function (props) {
|
|
|
31030
31059
|
onConnectionStatusChange(connectionStatus);
|
|
31031
31060
|
}
|
|
31032
31061
|
}, [connectionStatus, onConnectionStatusChange]);
|
|
31033
|
-
useExternalScript((
|
|
31062
|
+
useExternalScript((_t = props.config) === null || _t === void 0 ? void 0 : _t.middlewareUrl);
|
|
31034
31063
|
// This is a pseudo agent. It represent's the widget (shown in the header avatar for instance)
|
|
31035
|
-
var widgetAgent = ((
|
|
31064
|
+
var widgetAgent = ((_u = chatState.agents["agent:robot"]) === null || _u === void 0 ? void 0 : _u.user) || (config === null || config === void 0 ? void 0 : config.agent)
|
|
31036
31065
|
|| { nick: "agent:robot", avatarPath: config.avatarUrl, display_name: "Agent" };
|
|
31037
31066
|
return (React__default$1["default"].createElement(React__default$1["default"].Fragment, null,
|
|
31038
31067
|
React__default$1["default"].createElement("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()) },
|
|
31039
31068
|
React__default$1["default"].createElement(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }),
|
|
31040
|
-
React__default$1["default"].createElement(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick:
|
|
31041
|
-
React__default$1["default"].createElement(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, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (
|
|
31069
|
+
React__default$1["default"].createElement(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, onSubmit: handleOnSubmit }),
|
|
31070
|
+
React__default$1["default"].createElement(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, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (_w = (_v = props.config) === null || _v === void 0 ? void 0 : _v.typingStatus) === null || _w === void 0 ? void 0 : _w.textTypingStatusEnabled, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl }),
|
|
31042
31071
|
React__default$1["default"].createElement("div", { className: "xa-spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : "") },
|
|
31043
31072
|
React__default$1["default"].createElement("div", { className: "xa-spinner" })),
|
|
31044
31073
|
connectionStatus === "offline" && React__default$1["default"].createElement(ServerOffline, null),
|
|
31045
|
-
React__default$1["default"].createElement(ChatFooter, { isAdmin: config === null || config === void 0 ? void 0 : config.isAdmin, isChatting: chatState.isChatting, placeholder: (
|
|
31046
|
-
React__default$1["default"].createElement("div", { className: "restartModal", ref: modalRef, onClick:
|
|
31047
|
-
React__default$1["default"].createElement(ModalContent, { onClose:
|
|
31048
|
-
React__default$1["default"].createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: (
|
|
31074
|
+
React__default$1["default"].createElement(ChatFooter, { isAdmin: config === null || config === void 0 ? void 0 : config.isAdmin, isChatting: chatState.isChatting, placeholder: (_x = config === null || config === void 0 ? void 0 : config.input) === null || _x === void 0 ? void 0 : _x.placeholder, sendButtonIcon: (_z = (_y = config === null || config === void 0 ? void 0 : config.footer) === null || _y === void 0 ? void 0 : _y.sendButton) === null || _z === void 0 ? void 0 : _z.icon, visible: visible, menuConfig: props.config.menu, footerConfig: (_0 = props.config) === null || _0 === void 0 ? void 0 : _0.footer, inputConfig: (_1 = props.config) === null || _1 === void 0 ? void 0 : _1.input, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload }),
|
|
31075
|
+
React__default$1["default"].createElement("div", { className: "restartModal", ref: modalRef, onClick: handleRestartModalCloseClick },
|
|
31076
|
+
React__default$1["default"].createElement(ModalContent, { onClose: handleRestartModalCloseClick, onReset: handleReset }))),
|
|
31077
|
+
React__default$1["default"].createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: (_2 = props.config) === null || _2 === void 0 ? void 0 : _2.cta, visible: visible })));
|
|
31049
31078
|
};
|
|
31050
31079
|
|
|
31051
31080
|
function tryParseJson(str) {
|
|
@@ -31540,6 +31569,7 @@ exports.ChatButton = ChatButton;
|
|
|
31540
31569
|
exports.ChatCard = ChatCard;
|
|
31541
31570
|
exports.ChatChip = ChatChip;
|
|
31542
31571
|
exports.ChatChips = ChatChips;
|
|
31572
|
+
exports.ChatHeader = ChatHeader;
|
|
31543
31573
|
exports.ChatMenu = ChatMenu;
|
|
31544
31574
|
exports.ChatMessage = ChatMessage;
|
|
31545
31575
|
exports.ChatMessageBubble = ChatMessageBubble;
|