@xapp/chat-widget 1.44.0 → 1.46.2

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.js CHANGED
@@ -7900,11 +7900,12 @@ var SendIcon = function () {
7900
7900
  };
7901
7901
 
7902
7902
  var SendButton = function (props) {
7903
- return (React__default$1["default"].createElement(IconButton_1, { className: "xappw-send-button ".concat(props.className || ""), onClick: props.onClick, icon: SendIcon }));
7903
+ return (React__default$1["default"].createElement(React__default$1["default"].Fragment, null, !props.sendButtonIcon ? (React__default$1["default"].createElement(IconButton_1, { className: "xappw-send-button ".concat(props.className || ""), onClick: props.onClick, icon: SendIcon })) : (React__default$1["default"].createElement("span", { className: "xappw-custom-send-button", onClick: props.onClick },
7904
+ React__default$1["default"].createElement("img", { src: props.sendButtonIcon, alt: "", draggable: false })))));
7904
7905
  };
7905
7906
 
7906
7907
  var Input = function (props) {
7907
- var value = props.value, placeholder = props.placeholder, suggestion = props.suggestion, onChange = props.onChange, onSubmit = props.onSubmit, onSuggestionCommand = props.onSuggestionCommand;
7908
+ var value = props.value, placeholder = props.placeholder, sendButtonIcon = props.sendButtonIcon, suggestion = props.suggestion, onChange = props.onChange, onSubmit = props.onSubmit, onSuggestionCommand = props.onSuggestionCommand;
7908
7909
  var _a = React$1.useState(false), dragover = _a[0], setDragover = _a[1];
7909
7910
  function onDragOver(event) {
7910
7911
  setDragover(true);
@@ -7957,7 +7958,7 @@ var Input = function (props) {
7957
7958
  value: value, spellCheck: true }),
7958
7959
  React__default$1["default"].createElement("div", { className: "xappw-input-form__buttons" },
7959
7960
  value.text && React__default$1["default"].createElement(IconButton_1, { icon: CloseIcon, className: "xappw-input-form__btn", onClick: handleClear }),
7960
- React__default$1["default"].createElement(SendButton, { className: "xappw-input-form__btn", onClick: handleOnSubmit })))));
7961
+ React__default$1["default"].createElement(SendButton, { className: "xappw-input-form__btn", sendButtonIcon: sendButtonIcon, onClick: handleOnSubmit })))));
7961
7962
  };
7962
7963
 
7963
7964
  function createActions(onItemUse) {
@@ -7999,7 +8000,7 @@ var Suggestions = function (props) {
7999
8000
 
8000
8001
  var ChatFooter = function (props) {
8001
8002
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
8002
- var placeholder = props.placeholder, onSubmit = props.onSubmit;
8003
+ var placeholder = props.placeholder, sendButtonIcon = props.sendButtonIcon, onSubmit = props.onSubmit;
8003
8004
  var _k = React$1.useState(false), drawer = _k[0], setDrawerState = _k[1]; // false initially
8004
8005
  var _l = React$1.useState(), suggestionSearch = _l[0], setSuggestionSearch = _l[1];
8005
8006
  var contexts = reactRedux.useSelector(function (state) { return state.activeContexts; });
@@ -8048,7 +8049,7 @@ var ChatFooter = function (props) {
8048
8049
  React__default$1["default"].createElement("div", { className: "chat-footer__menu-icon" },
8049
8050
  React__default$1["default"].createElement(DrawerBars, { onToggle: toggleDrawer }))) : React__default$1["default"].createElement(React__default$1["default"].Fragment, null),
8050
8051
  ((_j = suggestions.suggestions) === null || _j === void 0 ? void 0 : _j.length) > 0 && React__default$1["default"].createElement(Suggestions, { className: "xappw-chat-footer__suggestions", data: suggestions.suggestions, index: suggestions.index, onItemClick: handleItemClick, onItemUse: handleItemUse }),
8051
- React__default$1["default"].createElement(Input, { addClass: "chat-footer__input " + (props.isChatting && props.visible ? "visible" : ""), suggestion: suggestions.item, value: input, placeholder: placeholder, onSubmit: handleSubmit, onChange: handleChange, onSuggestionCommand: suggestions.execute,
8052
+ React__default$1["default"].createElement(Input, { addClass: "chat-footer__input " + (props.isChatting && props.visible ? "visible" : ""), suggestion: suggestions.item, value: input, placeholder: placeholder, sendButtonIcon: sendButtonIcon, onSubmit: handleSubmit, onChange: handleChange, onSuggestionCommand: suggestions.execute,
8052
8053
  // onFocus={this.inputOnFocus}
8053
8054
  onFileUpload: props.onFileUpload }),
8054
8055
  brandingEnabled && React__default$1["default"].createElement(ChatBranding, { text: branding })));
@@ -30447,15 +30448,16 @@ var TypingIndicator = function (_) {
30447
30448
  * Show the agent is typing (or the bot - for fun)
30448
30449
  */
30449
30450
  var TypingStatus = function (props) {
30450
- var agent_names = Object.values(props.agents)
30451
- .filter(function (agent) { return agent.typing; });
30451
+ var agent_names = Object.values(props.agents).filter(function (agent) { return agent.typing; });
30452
30452
  return (React__default$1["default"].createElement(React__default$1["default"].Fragment, null, agent_names.map(function (agent) {
30453
- return (React__default$1["default"].createElement("div", { className: "chat-msg-container-wrapper", key: "typing-status-".concat(agent.user.nick) },
30453
+ var _a, _b;
30454
+ return (React__default$1["default"].createElement(React__default$1["default"].Fragment, null, !props.textTypingStatusEnabled ? (React__default$1["default"].createElement("div", { className: "chat-msg-container-wrapper", key: "typing-status-".concat(agent.user.nick) },
30454
30455
  React__default$1["default"].createElement("div", { key: agent.user.nick, className: "chat-msg-container agent chat-typing-progress" },
30455
30456
  React__default$1["default"].createElement(ChatMessagePart, { user: agent.user, showAvatar: true },
30456
30457
  React__default$1["default"].createElement("div", { className: "chat-msg" },
30457
30458
  React__default$1["default"].createElement(ChatMessageBubble, { owner: "others", hasTail: true },
30458
- React__default$1["default"].createElement(TypingIndicator, null)))))));
30459
+ React__default$1["default"].createElement(TypingIndicator, null))))))) : (React__default$1["default"].createElement("div", { key: agent.user.nick, className: "chat-msg-agent-typing" }, (_b = (_a = agent.user) === null || _a === void 0 ? void 0 : _a.display_name) !== null && _b !== void 0 ? _b : "Bot",
30460
+ " is typing"))));
30459
30461
  })));
30460
30462
  };
30461
30463
 
@@ -30548,7 +30550,7 @@ var MessageList = function (props) {
30548
30550
  renderAll(),
30549
30551
  React__default$1["default"].createElement("div", { ref: messagesEndRef, style: { float: "left", clear: "both" } }),
30550
30552
  React__default$1["default"].createElement(QueuePosition, { position: queuePosition }),
30551
- React__default$1["default"].createElement(TypingStatus, { agents: agents })),
30553
+ React__default$1["default"].createElement(TypingStatus, { agents: agents, textTypingStatusEnabled: props.textTypingStatusEnabled })),
30552
30554
  React__default$1["default"].createElement(ChatChipsContainer, null)));
30553
30555
  };
30554
30556
 
@@ -30586,12 +30588,13 @@ function getStatusText(status, config) {
30586
30588
  }
30587
30589
  }
30588
30590
  var StatusContainer = function (props) {
30589
- var _a;
30591
+ var _a, _b, _c, _d, _e, _f, _g;
30590
30592
  return (React__default$1["default"].createElement("div", { className: "status-container" },
30591
30593
  React__default$1["default"].createElement("div", { className: "status-container__avatar" },
30592
30594
  React__default$1["default"].createElement(Avatar, { entity: props.agent })),
30593
- React__default$1["default"].createElement("div", { className: "status-text" },
30594
- React__default$1["default"].createElement("span", null, getStatusText(props.accountStatus, (_a = props.config) === null || _a === void 0 ? void 0 : _a.status))),
30595
+ React__default$1["default"].createElement("div", { className: "".concat("status-text", " ").concat(((_a = props.config) === null || _a === void 0 ? void 0 : _a.alignTextCenter) ? "status-text-positionCenter" : "status-text-positionLeft") },
30596
+ React__default$1["default"].createElement("span", { className: "status-text-title" }, getStatusText(props.accountStatus, (_b = props.config) === null || _b === void 0 ? void 0 : _b.status)),
30597
+ ((_d = (_c = props.config) === null || _c === void 0 ? void 0 : _c.subtitle) === null || _d === void 0 ? void 0 : _d.enabled) && React__default$1["default"].createElement("span", { className: "status-text-subtitle" }, (_g = (_f = (_e = props.config) === null || _e === void 0 ? void 0 : _e.subtitle) === null || _f === void 0 ? void 0 : _f.text) !== null && _g !== void 0 ? _g : "")),
30595
30598
  props.canRefresh &&
30596
30599
  React__default$1["default"].createElement(RefreshButton, { onClick: props.refreshOnClick, showInLeft: props.canMinimize && props.canCancel, showInRight: !props.canMinimize && !props.canCancel }),
30597
30600
  props.canMinimize &&
@@ -30601,8 +30604,8 @@ var StatusContainer = function (props) {
30601
30604
  };
30602
30605
 
30603
30606
  function buildStyleContent(theme) {
30604
- var _a, _b, _c, _d;
30605
- 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("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((_b = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _b === void 0 ? void 0 : _b.title)), withPrefix("subtitle-", getTextStyle((_c = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _c === void 0 ? void 0 : _c.subtitle)), withPrefix("action-", getButtonStyle((_d = theme === null || theme === void 0 ? void 0 : theme.carousel) === null || _d === void 0 ? void 0 : _d.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}");
30607
+ var _a, _b, _c, _d, _e;
30608
+ 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}");
30606
30609
  }
30607
30610
  function WidgetStylesheet(props) {
30608
30611
  var theme = props.theme;
@@ -30809,6 +30812,9 @@ function getButtonStyle(style) {
30809
30812
  switch (_a.label) {
30810
30813
  case 0: return [4 /*yield*/, ['button-color', style === null || style === void 0 ? void 0 : style.color]];
30811
30814
  case 1:
30815
+ _a.sent();
30816
+ return [4 /*yield*/, ['button-width', style === null || style === void 0 ? void 0 : style.width]];
30817
+ case 2:
30812
30818
  _a.sent();
30813
30819
  return [2 /*return*/];
30814
30820
  }
@@ -30843,7 +30849,7 @@ function getHeaderStyle(style) {
30843
30849
  if (!style) {
30844
30850
  return empty();
30845
30851
  }
30846
- return union(getBackgroundStyle(style.background), getTextStyle(style.text), getBorderStyle(style.border));
30852
+ return union(getBackgroundStyle(style.background), getTextStyle(style.text), withPrefix("subtitle-", getTextStyle(style.subtitle)), getBorderStyle(style.border));
30847
30853
  }
30848
30854
  function getFooterStyle(style) {
30849
30855
  var _a;
@@ -30894,7 +30900,7 @@ var ChatWidgetWrapper = function (props) {
30894
30900
  React__default$1["default"].createElement(ChatWidget, __assign({}, props)))));
30895
30901
  };
30896
30902
  var ChatWidget = function (props) {
30897
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
30903
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
30898
30904
  var innerDispatch = useChatDispatch();
30899
30905
  var dispatch = useChatServerDispatch();
30900
30906
  // From Redux
@@ -30914,8 +30920,8 @@ var ChatWidget = function (props) {
30914
30920
  canCancel = !dockedMode && !staticMode;
30915
30921
  }
30916
30922
  // Our state - pull from storage
30917
- var _r = React$1.useState((!canMinimize && !canCancel) || !!get("visible") || (((_k = props.config) === null || _k === void 0 ? void 0 : _k.autoOpenOnWidth) && window.matchMedia("(min-width: ".concat((_l = props.config) === null || _l === void 0 ? void 0 : _l.autoOpenOnWidth, ")")).matches)), visible = _r[0], setVisibleState = _r[1];
30918
- var _s = React$1.useState(false), typing = _s[0], setTypingState = _s[1]; // false initially
30923
+ var _v = React$1.useState((!canMinimize && !canCancel) || !!get("visible") || (((_k = props.config) === null || _k === void 0 ? void 0 : _k.autoOpenOnWidth) && window.matchMedia("(min-width: ".concat((_l = props.config) === null || _l === void 0 ? void 0 : _l.autoOpenOnWidth, ")")).matches)), visible = _v[0], setVisibleState = _v[1];
30924
+ var _w = React$1.useState(false), typing = _w[0], setTypingState = _w[1]; // false initially
30919
30925
  var chatServer = React$1.useContext(ChatServerContext);
30920
30926
  var setVisible = React$1.useCallback(function (newVisible) {
30921
30927
  if (staticMode) {
@@ -31042,12 +31048,12 @@ var ChatWidget = function (props) {
31042
31048
  React__default$1["default"].createElement("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()) },
31043
31049
  React__default$1["default"].createElement(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }),
31044
31050
  React__default$1["default"].createElement(StatusContainer, { accountStatus: chatState.accountStatus, refreshOnClick: refreshOnClick, minimizeOnClick: minimizeOnClick, cancelOnClick: cancelOnClick, agent: (_o = chatState.agents["agent:robot"]) === null || _o === void 0 ? void 0 : _o.user, canRefresh: canRefresh, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header }),
31045
- 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, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl }),
31051
+ 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 }),
31046
31052
  React__default$1["default"].createElement("div", { className: "spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : "") },
31047
31053
  React__default$1["default"].createElement("div", { className: "spinner" })),
31048
31054
  connectionStatus === "offline" && React__default$1["default"].createElement(ServerOffline, null),
31049
- React__default$1["default"].createElement(ChatFooter, { isChatting: chatState.isChatting, placeholder: (_p = config === null || config === void 0 ? void 0 : config.input) === null || _p === void 0 ? void 0 : _p.placeholder, visible: visible, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload })),
31050
- React__default$1["default"].createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: (_q = props.config) === null || _q === void 0 ? void 0 : _q.cta, visible: visible })));
31055
+ 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, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload })),
31056
+ React__default$1["default"].createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: (_u = props.config) === null || _u === void 0 ? void 0 : _u.cta, visible: visible })));
31051
31057
  };
31052
31058
 
31053
31059
  function tryParseJson(str) {