@xapp/chat-widget 1.99.0 → 1.100.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
@@ -12978,7 +12978,7 @@ var ChatMessage = function (props) {
12978
12978
  return (require$$0.jsxs(require$$0.Fragment, { children: [showToolProgressWithAvatar && (require$$0.jsx(ChatMessagePart, { showAvatar: true, user: user, avatarPosition: (_g = (_f = (_e = chatConfig === null || chatConfig === void 0 ? void 0 : chatConfig.env) === null || _e === void 0 ? void 0 : _e.theme) === null || _f === void 0 ? void 0 : _f.messages) === null || _g === void 0 ? void 0 : _g.avatarPosition, hideUserInfo: hideUserInfo, isStreaming: true, children: require$$0.jsx("div", { className: "chat-msg", children: require$$0.jsx(ToolCallDisplay, { toolCalls: toolCalls, debugMode: debugMode }) }) })), msg.text && (require$$0.jsx(ChatMessagePart, { showAvatar: avaKey === "text", user: user, avatarPosition: (_k = (_j = (_h = chatConfig === null || chatConfig === void 0 ? void 0 : chatConfig.env) === null || _h === void 0 ? void 0 : _h.theme) === null || _j === void 0 ? void 0 : _j.messages) === null || _k === void 0 ? void 0 : _k.avatarPosition, hideUserInfo: hideUserInfo, isStreaming: isStreaming_1 || wasStreamed, children: require$$0.jsx(ChatTextMessage, { message: props.message, sibling: props.sibling, user: user, toolCalls: hasToolCalls ? toolCalls : undefined, debugMode: debugMode }) })), msg.html &&
12979
12979
  require$$0.jsx(ChatMessagePart, { showAvatar: avaKey === "html", user: user, avatarPosition: (_o = (_m = (_l = chatConfig === null || chatConfig === void 0 ? void 0 : chatConfig.env) === null || _l === void 0 ? void 0 : _l.theme) === null || _m === void 0 ? void 0 : _m.messages) === null || _o === void 0 ? void 0 : _o.avatarPosition, hideUserInfo: hideUserInfo, children: require$$0.jsx(ChatMarkdownMessage, { message: props.message, sibling: props.sibling, onOpenUrl: (_p = props.middlewareContext) === null || _p === void 0 ? void 0 : _p.openUrl }) }), msg.displays && middleware && msg.displays.map(function (display, index) {
12980
12980
  if (display.type === "ScheduleButton") {
12981
- return (require$$0.jsx(ChatScheduleWidget, { minimizeOnClick: props.minimizeOnClick, display: display }));
12981
+ return (require$$0.jsx(ChatScheduleWidget, { minimizeOnClick: props.minimizeOnClick, display: display }, index));
12982
12982
  }
12983
12983
  var Middleware = middleware;
12984
12984
  return (require$$0.jsx(Middleware, { msg: display, ctx: props.middlewareContext }, index));
@@ -13476,11 +13476,14 @@ var Suggestions = function (props) {
13476
13476
  var actions = React.useMemo(function () { return createActions(onItemUse); }, [onItemUse]);
13477
13477
  var transformContent = function (content) {
13478
13478
  var lines = content.split('\n');
13479
- return lines.map(function (line) {
13479
+ // Keyed by position: the lines have no id of their own, and a blank line between
13480
+ // paragraphs is not distinguishable by content either. `<></>` cannot carry a key,
13481
+ // hence the explicit Fragment.
13482
+ return lines.map(function (line, index) {
13480
13483
  if (line) {
13481
- return require$$0.jsx(MarkdownBuilder, { text: line });
13484
+ return require$$0.jsx(MarkdownBuilder, { text: line }, "line-".concat(index));
13482
13485
  }
13483
- return require$$0.jsx(require$$0.Fragment, {});
13486
+ return require$$0.jsx(React.Fragment, {}, "line-".concat(index));
13484
13487
  });
13485
13488
  };
13486
13489
  var containerClass = "xappw-suggestions ".concat(props.className || "", " ").concat(props.hasWsButton ? "xappw-suggestions--with-ws-button" : "").trim();
@@ -35471,13 +35474,26 @@ var MessageList = function (_a) {
35471
35474
  * until the user scrolled back by hand. Device, 2026-09-10.
35472
35475
  *
35473
35476
  * A container scroll cannot touch an ancestor, which is the entire point.
35477
+ *
35478
+ * `scrollTo` is feature-detected rather than assumed. It is absent in jsdom, so every
35479
+ * test that mounts this component through a passive effect throws on it -- but the
35480
+ * reason to guard is not the test runner: this widget renders on whatever browser a
35481
+ * customer's visitor brought, and a missing `Element.prototype.scrollTo` would throw
35482
+ * inside a passive effect and take the message list down with it. Assigning
35483
+ * `scrollTop` is the universally supported equivalent; it loses the smooth animation
35484
+ * and nothing else.
35474
35485
  */
35475
35486
  var scrollToBottom = React.useCallback(function (behavior) {
35476
35487
  if (behavior === void 0) { behavior = "smooth"; }
35477
35488
  var container = containerRef.current;
35478
- if (container) {
35489
+ if (!container) {
35490
+ return;
35491
+ }
35492
+ if (typeof container.scrollTo === "function") {
35479
35493
  container.scrollTo({ top: container.scrollHeight, behavior: behavior });
35494
+ return;
35480
35495
  }
35496
+ container.scrollTop = container.scrollHeight;
35481
35497
  }, []);
35482
35498
  // Always scroll to bottom when messages change (unless disabled)
35483
35499
  React.useEffect(function () {
@@ -35568,7 +35584,7 @@ var MessageList = function (_a) {
35568
35584
  case "chat.prechat":
35569
35585
  return require$$0.jsx(PrechatFormContainer, { time: time }, "prechat");
35570
35586
  default:
35571
- return (require$$0.jsxs("span", { children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + time + " system message" }), require$$0.jsxs("div", { children: ["Unhandled message: ", JSON.stringify(msg)] }, "uhm-".concat(+new Date()))] }, "default-".concat(msg.timestamp)));
35587
+ return (require$$0.jsxs("span", { children: [require$$0.jsx("span", { className: "message-sr-only", children: "at " + time + " system message" }), require$$0.jsxs("div", { "data-testid": "unhandled-message", children: ["Unhandled message: ", JSON.stringify(msg)] }, "uhm-".concat(msg.timestamp))] }, "default-".concat(msg.timestamp)));
35572
35588
  }
35573
35589
  }
35574
35590
  /**