@xapp/chat-widget 1.55.0 → 1.55.1

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
@@ -164,6 +164,13 @@ function insertSorted(array, obj, comparer) {
164
164
  return array;
165
165
  }
166
166
 
167
+ /**
168
+ * Agent is determined if the provided nick string starts with `agent:`.
169
+ *
170
+ * This returns false if the nick string is falsey (undefined or "") or does not start with "agent:"
171
+ * @param nick
172
+ * @returns
173
+ */
167
174
  function isAgent(nick) {
168
175
  if (!nick) {
169
176
  return false;
@@ -1561,7 +1568,7 @@ var Avatar = function (props) {
1561
1568
  var avatarPath = entity === null || entity === void 0 ? void 0 : entity.avatarPath;
1562
1569
  if (!avatarPath) {
1563
1570
  var avatarImage = GenerateAvatar({
1564
- initials: entity.displayName ? entity.displayName.slice(0, 2) : "?",
1571
+ initials: (entity === null || entity === void 0 ? void 0 : entity.displayName) ? entity.displayName.slice(0, 2) : "?",
1565
1572
  backgroundColor: (_b = (_a = chatConfig === null || chatConfig === void 0 ? void 0 : chatConfig.env) === null || _a === void 0 ? void 0 : _a.theme) === null || _b === void 0 ? void 0 : _b.primaryColor,
1566
1573
  size: 36,
1567
1574
  });
@@ -8575,7 +8582,6 @@ var ChatMessage = function (props) {
8575
8582
  */
8576
8583
  function convertToSeconds(s) {
8577
8584
  if (!s) {
8578
- err("Empty time string");
8579
8585
  return 0;
8580
8586
  }
8581
8587
  var groups = s.match(/(\d+)([dhms]?)/);
@@ -31428,14 +31434,17 @@ var TypingIndicator = function (_) {
31428
31434
  */
31429
31435
  var TypingStatus = function (props) {
31430
31436
  var agentsTyping = Object.values(props.agents).filter(function (agent) { return agent.typing; });
31431
- return (React__default$1["default"].createElement(React__default$1["default"].Fragment, null, agentsTyping.map(function (agent) {
31437
+ return (React__default$1["default"].createElement(React__default$1["default"].Fragment, null, agentsTyping.map(function (agent, index) {
31432
31438
  var _a, _b;
31433
- 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) },
31434
- React__default$1["default"].createElement("div", { key: agent.user.nick, className: "chat-msg-container agent chat-typing-progress" },
31439
+ var key = ((_a = agent.user) === null || _a === void 0 ? void 0 : _a.nick) || "".concat(index);
31440
+ var displayName = ((_b = agent.user) === null || _b === void 0 ? void 0 : _b.displayName) || "Somebody";
31441
+ 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(key) },
31442
+ React__default$1["default"].createElement("div", { key: key, className: "chat-msg-container agent chat-typing-progress" },
31435
31443
  React__default$1["default"].createElement(ChatMessagePart, { user: agent.user, showAvatar: true },
31436
31444
  React__default$1["default"].createElement("div", { className: "chat-msg" },
31437
31445
  React__default$1["default"].createElement(ChatMessageBubble, { owner: "others", hasTail: true },
31438
- React__default$1["default"].createElement(TypingIndicator, null))))))) : (React__default$1["default"].createElement("div", { key: "typing-status-".concat(agent.user.nick), className: "chat-msg-agent-typing" }, (_b = (_a = agent.user) === null || _a === void 0 ? void 0 : _a.displayName) !== null && _b !== void 0 ? _b : "Somebody",
31446
+ React__default$1["default"].createElement(TypingIndicator, null))))))) : (React__default$1["default"].createElement("div", { key: "typing-status-".concat(key), className: "chat-msg-agent-typing" },
31447
+ displayName,
31439
31448
  " is typing"))));
31440
31449
  })));
31441
31450
  };
@@ -31493,7 +31502,7 @@ var MessageList = function (props) {
31493
31502
  user = ((_a = props.agents[msg.user.nick]) === null || _a === void 0 ? void 0 : _a.user) || props.agent;
31494
31503
  // Still nothing?
31495
31504
  if (!user) {
31496
- console.warn("Could not get a user from agents list with nick: \"".concat(msg.user.nick, "\""));
31505
+ log("Could not get a user from agents list with nick: \"".concat(msg.user.nick, "\""));
31497
31506
  user = msg.user;
31498
31507
  }
31499
31508
  }
@@ -31627,9 +31636,9 @@ var refreshButtonAriaLabel = "To refresh chat click on clockwise gapped circle a
31627
31636
  var minimizeButtonAriaLabel = "To minimize widget click on minus icon in top right side of widget. ";
31628
31637
  var closeButtonAriaLabel = "To close widget click on close icon in top right side of widget.";
31629
31638
  var ChatHeader = function (props) {
31630
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
31639
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
31631
31640
  var menuConfig = props.menuConfig, onSubmit = props.onSubmit;
31632
- var _q = React$1.useState(false), drawerOpen = _q[0], setDrawerState = _q[1]; // false initially
31641
+ var _s = React$1.useState(false), drawerOpen = _s[0], setDrawerState = _s[1]; // false initially
31633
31642
  var menuPosition = (menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.menuButtonLocation) || "FOOTER";
31634
31643
  var showMenu = menuPosition === "HEADER_LEFT";
31635
31644
  var menuItemsRaw = menuConfig === null || menuConfig === void 0 ? void 0 : menuConfig.items; // useWidgetEnv()?.menu?.items;
@@ -31650,16 +31659,15 @@ var ChatHeader = function (props) {
31650
31659
  showMenu && menuItems.length ? (React__default$1["default"].createElement(React__default$1["default"].Fragment, null,
31651
31660
  React__default$1["default"].createElement("div", { className: "chat-footer__menu-icon" },
31652
31661
  React__default$1["default"].createElement(DrawerBars, { bars: 3, tabIndex: menuButtonTabIndex, onToggle: toggleDrawer })))) : React__default$1["default"].createElement(React__default$1["default"].Fragment, null),
31653
- React__default$1["default"].createElement("div", { className: "status-container__avatar" },
31654
- React__default$1["default"].createElement(Avatar, { entity: props.agent })),
31655
- React__default$1["default"].createElement("div", { className: "".concat("status-text", " ").concat(((_b = props.config) === null || _b === void 0 ? void 0 : _b.alignTextCenter)
31656
- ? "status-text-positionCenter"
31657
- : "status-text-positionLeft") },
31658
- React__default$1["default"].createElement("span", { className: "status-text-title" }, getStatusText(props.accountStatus, (_c = props.config) === null || _c === void 0 ? void 0 : _c.status)),
31659
- ((_e = (_d = props.config) === null || _d === void 0 ? void 0 : _d.subtitle) === null || _e === void 0 ? void 0 : _e.enabled) && (React__default$1["default"].createElement("span", { className: "status-text-subtitle" }, (_h = (_g = (_f = props.config) === null || _f === void 0 ? void 0 : _f.subtitle) === null || _g === void 0 ? void 0 : _g.text) !== null && _h !== void 0 ? _h : ""))),
31660
- props.canRefresh && (React__default$1["default"].createElement(RefreshButton, { onClick: props.refreshOnClick, tabIndex: (_k = (_j = props.config) === null || _j === void 0 ? void 0 : _j.actions) === null || _k === void 0 ? void 0 : _k.refreshTabIndex, showInLeft: props.canMinimize && props.canCancel, showInRight: !props.canMinimize && !props.canCancel })),
31661
- props.canMinimize && (React__default$1["default"].createElement(MinimizeButton, { onClick: props.minimizeOnClick, tabIndex: (_m = (_l = props.config) === null || _l === void 0 ? void 0 : _l.actions) === null || _m === void 0 ? void 0 : _m.minimizeTabIndex, showInRight: !props.canCancel })),
31662
- props.canCancel && (React__default$1["default"].createElement(CancelButton, { onClick: props.cancelOnClick, tabIndex: (_p = (_o = props.config) === null || _o === void 0 ? void 0 : _o.actions) === null || _p === void 0 ? void 0 : _p.cancelTabIndex }))),
31662
+ ((_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) :
31663
+ React__default$1["default"].createElement("div", { className: "status-container__avatar" },
31664
+ React__default$1["default"].createElement(Avatar, { entity: props.agent })),
31665
+ 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 ") },
31666
+ React__default$1["default"].createElement("span", { className: "status-text-title" }, getStatusText(props.accountStatus, (_e = props.config) === null || _e === void 0 ? void 0 : _e.status)),
31667
+ ((_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 : ""))),
31668
+ 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 })),
31669
+ 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 })),
31670
+ 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 }))),
31663
31671
  drawerOpen ? (React__default$1["default"].createElement("div", { className: "xa-chat-menu-container" },
31664
31672
  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)));
31665
31673
  };
@@ -32328,7 +32336,7 @@ function resetReducer(state) {
32328
32336
  userId: state.userId,
32329
32337
  attributes: state.attributes,
32330
32338
  sessionExpiration: state.sessionExpiration
32331
- })), { connection: __assign(__assign({}, state.connection), { greetingRequested: false }), visitor: state.visitor, visitorId: state.visitorId });
32339
+ })), { connection: __assign(__assign({}, state.connection), { greetingRequested: false, nonce: uuid_1() }), visitor: state.visitor, visitorId: state.visitorId });
32332
32340
  }
32333
32341
 
32334
32342
  // todo: create reducer (requires redux-thunk dependency)