@xapp/chat-widget 1.44.0 → 1.45.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.js CHANGED
@@ -30447,15 +30447,16 @@ var TypingIndicator = function (_) {
30447
30447
  * Show the agent is typing (or the bot - for fun)
30448
30448
  */
30449
30449
  var TypingStatus = function (props) {
30450
- var agent_names = Object.values(props.agents)
30451
- .filter(function (agent) { return agent.typing; });
30450
+ var agent_names = Object.values(props.agents).filter(function (agent) { return agent.typing; });
30452
30451
  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) },
30452
+ var _a, _b;
30453
+ 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
30454
  React__default$1["default"].createElement("div", { key: agent.user.nick, className: "chat-msg-container agent chat-typing-progress" },
30455
30455
  React__default$1["default"].createElement(ChatMessagePart, { user: agent.user, showAvatar: true },
30456
30456
  React__default$1["default"].createElement("div", { className: "chat-msg" },
30457
30457
  React__default$1["default"].createElement(ChatMessageBubble, { owner: "others", hasTail: true },
30458
- React__default$1["default"].createElement(TypingIndicator, null)))))));
30458
+ 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",
30459
+ " is typing"))));
30459
30460
  })));
30460
30461
  };
30461
30462
 
@@ -30548,7 +30549,7 @@ var MessageList = function (props) {
30548
30549
  renderAll(),
30549
30550
  React__default$1["default"].createElement("div", { ref: messagesEndRef, style: { float: "left", clear: "both" } }),
30550
30551
  React__default$1["default"].createElement(QueuePosition, { position: queuePosition }),
30551
- React__default$1["default"].createElement(TypingStatus, { agents: agents })),
30552
+ React__default$1["default"].createElement(TypingStatus, { agents: agents, textTypingStatusEnabled: props.textTypingStatusEnabled })),
30552
30553
  React__default$1["default"].createElement(ChatChipsContainer, null)));
30553
30554
  };
30554
30555
 
@@ -30586,12 +30587,13 @@ function getStatusText(status, config) {
30586
30587
  }
30587
30588
  }
30588
30589
  var StatusContainer = function (props) {
30589
- var _a;
30590
+ var _a, _b, _c, _d, _e, _f, _g;
30590
30591
  return (React__default$1["default"].createElement("div", { className: "status-container" },
30591
30592
  React__default$1["default"].createElement("div", { className: "status-container__avatar" },
30592
30593
  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))),
30594
+ 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") },
30595
+ React__default$1["default"].createElement("span", { className: "status-text-title" }, getStatusText(props.accountStatus, (_b = props.config) === null || _b === void 0 ? void 0 : _b.status)),
30596
+ ((_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
30597
  props.canRefresh &&
30596
30598
  React__default$1["default"].createElement(RefreshButton, { onClick: props.refreshOnClick, showInLeft: props.canMinimize && props.canCancel, showInRight: !props.canMinimize && !props.canCancel }),
30597
30599
  props.canMinimize &&
@@ -30601,8 +30603,8 @@ var StatusContainer = function (props) {
30601
30603
  };
30602
30604
 
30603
30605
  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}");
30606
+ var _a, _b, _c, _d, _e;
30607
+ 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
30608
  }
30607
30609
  function WidgetStylesheet(props) {
30608
30610
  var theme = props.theme;
@@ -30843,7 +30845,7 @@ function getHeaderStyle(style) {
30843
30845
  if (!style) {
30844
30846
  return empty();
30845
30847
  }
30846
- return union(getBackgroundStyle(style.background), getTextStyle(style.text), getBorderStyle(style.border));
30848
+ return union(getBackgroundStyle(style.background), getTextStyle(style.text), withPrefix("subtitle-", getTextStyle(style.subtitle)), getBorderStyle(style.border));
30847
30849
  }
30848
30850
  function getFooterStyle(style) {
30849
30851
  var _a;
@@ -30894,7 +30896,7 @@ var ChatWidgetWrapper = function (props) {
30894
30896
  React__default$1["default"].createElement(ChatWidget, __assign({}, props)))));
30895
30897
  };
30896
30898
  var ChatWidget = function (props) {
30897
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
30899
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
30898
30900
  var innerDispatch = useChatDispatch();
30899
30901
  var dispatch = useChatServerDispatch();
30900
30902
  // From Redux
@@ -30914,8 +30916,8 @@ var ChatWidget = function (props) {
30914
30916
  canCancel = !dockedMode && !staticMode;
30915
30917
  }
30916
30918
  // 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
30919
+ var _t = 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 = _t[0], setVisibleState = _t[1];
30920
+ var _u = React$1.useState(false), typing = _u[0], setTypingState = _u[1]; // false initially
30919
30921
  var chatServer = React$1.useContext(ChatServerContext);
30920
30922
  var setVisible = React$1.useCallback(function (newVisible) {
30921
30923
  if (staticMode) {
@@ -31042,12 +31044,12 @@ var ChatWidget = function (props) {
31042
31044
  React__default$1["default"].createElement("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()) },
31043
31045
  React__default$1["default"].createElement(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }),
31044
31046
  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 }),
31047
+ 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
31048
  React__default$1["default"].createElement("div", { className: "spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : "") },
31047
31049
  React__default$1["default"].createElement("div", { className: "spinner" })),
31048
31050
  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 })));
31051
+ 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, visible: visible, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload })),
31052
+ React__default$1["default"].createElement(ChatButton, { addClass: getVisibilityClass(), onClick: chatButtonOnClick, config: (_s = props.config) === null || _s === void 0 ? void 0 : _s.cta, visible: visible })));
31051
31053
  };
31052
31054
 
31053
31055
  function tryParseJson(str) {