@ant-design/agentic-ui 2.29.46 → 2.29.48

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.
@@ -368,9 +368,10 @@ var getTaskList = function getTaskList(originData) {
368
368
  }, /*#__PURE__*/ React.createElement("div", {
369
369
  style: style,
370
370
  className: clsx("".concat(prefixClass, "-bubble-container"), "".concat(prefixClass, "-bubble-container-").concat(placement), _define_property({}, "".concat(prefixClass, "-bubble-container-pure"), props.pure), hashId)
371
- }, preMessageSameRole ? null : /*#__PURE__*/ React.createElement("div", {
371
+ }, !preMessageSameRole && (avatarDom || titleDom) ? /*#__PURE__*/ React.createElement("div", {
372
+ "data-testid": "bubble-avatar-title",
372
373
  className: clsx("".concat(prefixClass, "-bubble-avatar-title"), "".concat(prefixClass, "-bubble-avatar-title-").concat(placement), "".concat(prefixClass, "-bubble-avatar-title-ai"), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleAvatarTitleClassName, hashId, _define_property({}, "".concat(prefixClass, "-bubble-avatar-title-pure"), props.pure))
373
- }, avatarDom, titleDom), /*#__PURE__*/ React.createElement("div", {
374
+ }, avatarDom, titleDom) : null, /*#__PURE__*/ React.createElement("div", {
374
375
  style: {
375
376
  display: 'flex',
376
377
  gap: 4,
@@ -383,14 +384,14 @@ var getTaskList = function getTaskList(originData) {
383
384
  style: styles === null || styles === void 0 ? void 0 : styles.bubbleListItemExtraStyle,
384
385
  className: clsx("".concat(prefixClass, "-bubble-before"), "".concat(prefixClass, "-bubble-before-").concat(placement), "".concat(prefixClass, "-bubble-before-ai"), hashId),
385
386
  "data-testid": "message-before"
386
- }, contentBeforeDom) : null, /*#__PURE__*/ React.createElement("div", {
387
+ }, contentBeforeDom) : null, childrenDom ? /*#__PURE__*/ React.createElement("div", {
387
388
  style: _object_spread({
388
389
  minWidth: standalone ? 'min(16px,100%)' : '0px'
389
390
  }, styles === null || styles === void 0 ? void 0 : styles.bubbleListItemContentStyle),
390
391
  className: clsx("".concat(prefixClass, "-bubble-content"), "".concat(prefixClass, "-bubble-content-").concat(placement), "".concat(prefixClass, "-bubble-content-ai"), _define_property({}, "".concat(prefixClass, "-bubble-content-pure"), props.pure), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleListItemContentClassName, hashId),
391
392
  onDoubleClick: props.onDoubleClick,
392
393
  "data-testid": "message-content"
393
- }, childrenDom), contentAfterDom)))));
394
+ }, childrenDom) : null, contentAfterDom)))));
394
395
  if ((bubbleRenderConfig === null || bubbleRenderConfig === void 0 ? void 0 : bubbleRenderConfig.render) === false) return null;
395
396
  return /*#__PURE__*/ React.createElement(MessagesContext.Provider, {
396
397
  value: {
@@ -196,18 +196,19 @@ var getContentStyle = function getContentStyle(standalone, customStyle) {
196
196
  style: contentContainerStyle,
197
197
  className: clsx("".concat(prefixClass, "-bubble-container"), "".concat(prefixClass, "-bubble-container-").concat(placement), "".concat(prefixClass, "-bubble-container-user"), _define_property({}, "".concat(prefixClass, "-bubble-container-pure"), props.pure), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleContainerClassName, hashId),
198
198
  "data-testid": "chat-message"
199
- }, /*#__PURE__*/ React.createElement("div", {
199
+ }, titleDom ? /*#__PURE__*/ React.createElement("div", {
200
+ "data-testid": "bubble-avatar-title",
200
201
  className: clsx("".concat(prefixClass, "-bubble-avatar-title"), "".concat(prefixClass, "-bubble-avatar-title-").concat(placement), "".concat(prefixClass, "-bubble-avatar-title-ai"), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleAvatarTitleClassName, hashId, (_obj = {}, _define_property(_obj, "".concat(prefixClass, "-bubble-avatar-title-pure"), props.pure), _define_property(_obj, "".concat(prefixClass, "-bubble-avatar-title-quote"), quote === null || quote === void 0 ? void 0 : quote.quoteDescription), _obj))
201
- }, titleDom), contentBeforeDom && /*#__PURE__*/ React.createElement("div", {
202
+ }, titleDom) : null, contentBeforeDom && /*#__PURE__*/ React.createElement("div", {
202
203
  style: styles === null || styles === void 0 ? void 0 : styles.bubbleListItemExtraStyle,
203
204
  className: clsx("".concat(prefixClass, "-bubble-before"), "".concat(prefixClass, "-bubble-before-").concat(placement), "".concat(prefixClass, "-bubble-before-user"), hashId),
204
205
  "data-testid": "message-before"
205
- }, contentBeforeDom), /*#__PURE__*/ React.createElement("div", {
206
+ }, contentBeforeDom), childrenDom ? /*#__PURE__*/ React.createElement("div", {
206
207
  style: contentStyle,
207
208
  className: clsx("".concat(prefixClass, "-bubble-content"), "".concat(prefixClass, "-bubble-content-").concat(placement), "".concat(prefixClass, "-bubble-content-user"), _define_property({}, "".concat(prefixClass, "-bubble-content-pure"), props.pure), classNames === null || classNames === void 0 ? void 0 : classNames.bubbleListItemContentClassName, hashId),
208
209
  onDoubleClick: props.onDoubleClick,
209
210
  "data-testid": "message-content"
210
- }, childrenDom), hasFileMap && /*#__PURE__*/ React.createElement("div", {
211
+ }, childrenDom) : null, hasFileMap && /*#__PURE__*/ React.createElement("div", {
211
212
  style: fileViewStyle,
212
213
  className: clsx("".concat(prefixClass, "-bubble-after"), "".concat(prefixClass, "-bubble-after-").concat(placement), "".concat(prefixClass, "-bubble-after-ai"), hashId),
213
214
  "data-testid": "message-after"
@@ -3,8 +3,8 @@ import type { ReactNode } from 'react';
3
3
  * 布局头部配置接口
4
4
  */
5
5
  export interface LayoutHeaderConfig {
6
- /** 标题文本 */
7
- title?: string;
6
+ /** 标题,支持文本或自定义 React 节点 */
7
+ title?: ReactNode;
8
8
  /** 是否显示分享按钮 */
9
9
  showShare?: boolean;
10
10
  /** 左侧是否可折叠 */
@@ -251,22 +251,28 @@ import { useEditorStore } from "../store";
251
251
  return Element.isElement(n) && n.type === 'paragraph';
252
252
  },
253
253
  mode: 'lowest'
254
- }), 1), node3 = _Editor_nodes3[0];
255
- if (node3 && node3[0].children.length === 1 && !EditorUtils.isDirtLeaf(node3[0].children[0]) && (e.key === 'Backspace' || /^[^\n]$/.test(e.key))) {
256
- var str = Node.string(node3[0]) || '';
257
- var codeMatch = str.match(/^```([\w+\-#]+)$/i);
258
- if (codeMatch) {} else {
259
- var _e_nativeEvent1;
260
- var strAfterKey = str + (e.key.length === 1 ? e.key : '');
261
- // 在实际输入一个字符且补全 trigger 时打开面板,支持在文本后输入(如 "hello {}")
262
- // IME 组合期间不触发,避免输入法选字时误触发或失效
263
- if (jinjaTemplatePanelEnabled && e.key.length === 1 && !((_e_nativeEvent1 = e.nativeEvent) === null || _e_nativeEvent1 === void 0 ? void 0 : _e_nativeEvent1.isComposing) && strAfterKey.endsWith(jinjaTrigger) && setOpenJinjaTemplate && setJinjaAnchorPath) {
254
+ }), 1), paraNode = _Editor_nodes3[0];
255
+ var node3 = paraNode;
256
+ if (node3) {
257
+ var _e_nativeEvent1;
258
+ var sel = markdownEditorRef.current.selection;
259
+ // Jinja 触发:基于光标位置检测,支持在任意位置输入 {}(含两个模板中间)
260
+ if (jinjaTemplatePanelEnabled && e.key.length === 1 && !((_e_nativeEvent1 = e.nativeEvent) === null || _e_nativeEvent1 === void 0 ? void 0 : _e_nativeEvent1.isComposing) && sel && Range.isCollapsed(sel) && Path.isAncestor(node3[1], sel.anchor.path) && setOpenJinjaTemplate && setJinjaAnchorPath) {
261
+ var strBeforeCursor = Editor.string(markdownEditorRef.current, Editor.range(markdownEditorRef.current, Editor.start(markdownEditorRef.current, node3[1]), sel.anchor));
262
+ var strAfterKeyAtCursor = strBeforeCursor + (e.key.length === 1 ? e.key : '');
263
+ if (strAfterKeyAtCursor.endsWith(jinjaTrigger)) {
264
264
  setJinjaAnchorPath(node3[1]);
265
265
  setTimeout(function() {
266
266
  return setOpenJinjaTemplate(true);
267
267
  });
268
268
  return;
269
269
  }
270
+ }
271
+ }
272
+ if (node3 && node3[0].children.length === 1 && !EditorUtils.isDirtLeaf(node3[0].children[0]) && (e.key === 'Backspace' || /^[^\n]$/.test(e.key))) {
273
+ var str = Node.string(node3[0]) || '';
274
+ var codeMatch = str.match(/^```([\w+\-#]+)$/i);
275
+ if (codeMatch) {} else {
270
276
  var insertMatch = str.match(/^\/([^\n]+)?$/i);
271
277
  if (insertMatch && !(!Path.hasPrevious(node3[1]) && Node.parent(markdownEditorRef.current, node3[1]).type === 'list-item')) {
272
278
  setOpenInsertCompletion === null || setOpenInsertCompletion === void 0 ? void 0 : setOpenInsertCompletion(true);
@@ -343,6 +343,7 @@ import { useVoiceInputManager } from "./VoiceInputManager";
343
343
  }, tagInputProps)
344
344
  }, /*#__PURE__*/ React.createElement("div", {
345
345
  ref: inputRef,
346
+ "data-testid": "markdown-input-field",
346
347
  className: classNames(baseCls, hashId, props.className, (_obj = {}, _define_property(_obj, "".concat(baseCls, "-disabled"), props.disabled), _define_property(_obj, "".concat(baseCls, "-skill-mode"), (_props_skillMode = props.skillMode) === null || _props_skillMode === void 0 ? void 0 : _props_skillMode.open), _define_property(_obj, "".concat(baseCls, "-typing"), false), _define_property(_obj, "".concat(baseCls, "-loading"), isLoading), _define_property(_obj, "".concat(baseCls, "-is-multi-row"), isMultiRowLayout), _define_property(_obj, "".concat(baseCls, "-enlarged"), isEnlarged), _define_property(_obj, "".concat(baseCls, "-focused"), isFocused), _define_property(_obj, "".concat(baseCls, "-has-tools-wrapper"), !!props.toolsRender), _obj)),
347
348
  style: _object_spread_props(_object_spread({}, props.style, enlargedStyle), {
348
349
  height: isEnlarged ? "".concat((_ref = (_props_enlargeable = props.enlargeable) === null || _props_enlargeable === void 0 ? void 0 : _props_enlargeable.height) !== null && _ref !== void 0 ? _ref : 980, "px") : "min(".concat(collapsedHeightPx, "px,100%)"),
@@ -1,3 +1,11 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_with_holes(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
1
9
  function _define_property(obj, key, value) {
2
10
  if (key in obj) {
3
11
  Object.defineProperty(obj, key, {
@@ -11,6 +19,33 @@ function _define_property(obj, key, value) {
11
19
  }
12
20
  return obj;
13
21
  }
22
+ function _iterable_to_array_limit(arr, i) {
23
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
24
+ if (_i == null) return;
25
+ var _arr = [];
26
+ var _n = true;
27
+ var _d = false;
28
+ var _s, _e;
29
+ try {
30
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
31
+ _arr.push(_s.value);
32
+ if (i && _arr.length === i) break;
33
+ }
34
+ } catch (err) {
35
+ _d = true;
36
+ _e = err;
37
+ } finally{
38
+ try {
39
+ if (!_n && _i["return"] != null) _i["return"]();
40
+ } finally{
41
+ if (_d) throw _e;
42
+ }
43
+ }
44
+ return _arr;
45
+ }
46
+ function _non_iterable_rest() {
47
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
48
+ }
14
49
  function _object_spread(target) {
15
50
  for(var i = 1; i < arguments.length; i++){
16
51
  var source = arguments[i] != null ? arguments[i] : {};
@@ -50,11 +85,23 @@ function _object_spread_props(target, source) {
50
85
  }
51
86
  return target;
52
87
  }
53
- import { Api, ChevronUp, X } from "@sofa-design/icons";
88
+ function _sliced_to_array(arr, i) {
89
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
90
+ }
91
+ function _unsupported_iterable_to_array(o, minLen) {
92
+ if (!o) return;
93
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
94
+ var n = Object.prototype.toString.call(o).slice(8, -1);
95
+ if (n === "Object" && o.constructor) n = o.constructor.name;
96
+ if (n === "Map" || n === "Set") return Array.from(n);
97
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
98
+ }
99
+ import { Api, ChevronUp, ChevronsDownUp, ChevronsUpDown, X } from "@sofa-design/icons";
54
100
  import classNames from "clsx";
55
101
  import { AnimatePresence, motion } from "framer-motion";
56
- import React, { memo, useMemo } from "react";
102
+ import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
57
103
  import { useRefFunction } from "../../Hooks/useRefFunction";
104
+ /** 内容超出此高度时自动收起 */ var CONTENT_COLLAPSE_THRESHOLD = 200;
58
105
  var ToolImageComponent = function ToolImageComponent(param) {
59
106
  var tool = param.tool, prefixCls = param.prefixCls, hashId = param.hashId, _param_disableAnimation = param.disableAnimation, disableAnimation = _param_disableAnimation === void 0 ? false : _param_disableAnimation;
60
107
  var toolImageWrapperClassName = useMemo(function() {
@@ -275,6 +322,9 @@ var ToolExpandComponent = function ToolExpandComponent(param) {
275
322
  export var ToolExpand = /*#__PURE__*/ memo(ToolExpandComponent);
276
323
  var ToolContentComponent = function ToolContentComponent(param) {
277
324
  var tool = param.tool, prefixCls = param.prefixCls, hashId = param.hashId, light = param.light, showContent = param.showContent, expanded = param.expanded, _param_disableAnimation = param.disableAnimation, disableAnimation = _param_disableAnimation === void 0 ? false : _param_disableAnimation;
325
+ var contentInnerRef = useRef(null);
326
+ var _useState = _sliced_to_array(useState(false), 2), isContentOverflowing = _useState[0], setIsContentOverflowing = _useState[1];
327
+ var _useState1 = _sliced_to_array(useState(false), 2), contentExpanded = _useState1[0], setContentExpanded = _useState1[1];
278
328
  var toolContainerClassName = useMemo(function() {
279
329
  return classNames("".concat(prefixCls, "-tool-container"), hashId, _define_property({}, "".concat(prefixCls, "-tool-container-light"), light));
280
330
  }, [
@@ -282,6 +332,12 @@ var ToolContentComponent = function ToolContentComponent(param) {
282
332
  hashId,
283
333
  light
284
334
  ]);
335
+ var contentExpandClassName = useMemo(function() {
336
+ return classNames("".concat(prefixCls, "-tool-content-expand"), hashId);
337
+ }, [
338
+ prefixCls,
339
+ hashId
340
+ ]);
285
341
  // 缓存错误样式类名
286
342
  var errorClassName = useMemo(function() {
287
343
  return classNames("".concat(prefixCls, "-tool-content-error"), hashId);
@@ -330,6 +386,69 @@ var ToolContentComponent = function ToolContentComponent(param) {
330
386
  tool.content,
331
387
  contentClassName
332
388
  ]);
389
+ var checkOverflow = useCallback(function() {
390
+ var el = contentInnerRef.current;
391
+ if (!el) return;
392
+ var scrollHeight = el.scrollHeight;
393
+ setIsContentOverflowing(scrollHeight > CONTENT_COLLAPSE_THRESHOLD);
394
+ }, []);
395
+ useEffect(function() {
396
+ if (!showContent || !expanded) return;
397
+ checkOverflow();
398
+ var el = contentInnerRef.current;
399
+ if (!el) return;
400
+ var observer = new ResizeObserver(checkOverflow);
401
+ observer.observe(el);
402
+ return function() {
403
+ return observer.disconnect();
404
+ };
405
+ }, [
406
+ showContent,
407
+ expanded,
408
+ tool.content,
409
+ tool.errorMessage,
410
+ checkOverflow
411
+ ]);
412
+ var handleContentExpandToggle = useRefFunction(function() {
413
+ setContentExpanded(function(prev) {
414
+ return !prev;
415
+ });
416
+ });
417
+ var showContentExpandButton = showContent && expanded && isContentOverflowing;
418
+ var contentInnerStyle = useMemo(function() {
419
+ if (!showContentExpandButton) return undefined;
420
+ if (contentExpanded) return undefined;
421
+ return {
422
+ maxHeight: CONTENT_COLLAPSE_THRESHOLD,
423
+ overflow: 'hidden'
424
+ };
425
+ }, [
426
+ showContentExpandButton,
427
+ contentExpanded
428
+ ]);
429
+ var contentExpandButton = useMemo(function() {
430
+ if (!showContentExpandButton) return null;
431
+ var expandIcon = contentExpanded ? /*#__PURE__*/ React.createElement(ChevronsDownUp, null) : /*#__PURE__*/ React.createElement(ChevronsUpDown, null);
432
+ var expandText = contentExpanded ? '收起' : '展开';
433
+ return /*#__PURE__*/ React.createElement("div", {
434
+ className: contentExpandClassName,
435
+ onClick: handleContentExpandToggle,
436
+ "data-testid": "tool-content-expand",
437
+ role: "button",
438
+ tabIndex: 0,
439
+ onKeyDown: function onKeyDown(e) {
440
+ if (e.key === 'Enter' || e.key === ' ') {
441
+ e.preventDefault();
442
+ handleContentExpandToggle();
443
+ }
444
+ }
445
+ }, expandIcon, expandText);
446
+ }, [
447
+ showContentExpandButton,
448
+ contentExpanded,
449
+ contentExpandClassName,
450
+ handleContentExpandToggle
451
+ ]);
333
452
  var contentVariants = useMemo(function() {
334
453
  return {
335
454
  expanded: {
@@ -365,6 +484,10 @@ var ToolContentComponent = function ToolContentComponent(param) {
365
484
  willChange: 'height, opacity'
366
485
  };
367
486
  }, []);
487
+ var innerContent = /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
488
+ ref: contentInnerRef,
489
+ style: contentInnerStyle
490
+ }, contentDom, errorDom), contentExpandButton);
368
491
  // 禁用动画时使用简单的显示/隐藏
369
492
  if (disableAnimation) {
370
493
  return showContent && expanded ? /*#__PURE__*/ React.createElement("div", {
@@ -373,7 +496,7 @@ var ToolContentComponent = function ToolContentComponent(param) {
373
496
  style: {
374
497
  overflow: 'hidden'
375
498
  }
376
- }, contentDom, errorDom) : null;
499
+ }, innerContent) : null;
377
500
  }
378
501
  return /*#__PURE__*/ React.createElement(AnimatePresence, {
379
502
  initial: false,
@@ -388,7 +511,7 @@ var ToolContentComponent = function ToolContentComponent(param) {
388
511
  exit: "collapsed",
389
512
  transition: contentTransition,
390
513
  style: containerStyle
391
- }, contentDom, errorDom) : null, !showContent ? /*#__PURE__*/ React.createElement("div", {
514
+ }, innerContent) : null, !showContent ? /*#__PURE__*/ React.createElement("div", {
392
515
  style: {
393
516
  overflow: 'hidden',
394
517
  height: 1,
@@ -326,6 +326,25 @@ var genStyle = function genStyle(token) {
326
326
  letterSpacing: 'normal',
327
327
  color: '#767E8B'
328
328
  },
329
+ '&-tool-content-expand': {
330
+ display: 'flex',
331
+ alignItems: 'center',
332
+ justifyContent: 'center',
333
+ gap: 4,
334
+ marginTop: 8,
335
+ padding: '8px 16px',
336
+ fontSize: 'var(--font-size-base)',
337
+ cursor: 'pointer',
338
+ borderRadius: 'var(--radius-control-base)',
339
+ background: 'var(--color-gray-control-fill-active)',
340
+ color: 'var(--color-gray-text-secondary)',
341
+ font: 'var(--font-text-body-emphasized-sm)',
342
+ flexShrink: 0,
343
+ '&:hover': {
344
+ background: 'var(--color-gray-control-fill-hover)',
345
+ color: 'var(--color-gray-text-default)'
346
+ }
347
+ },
329
348
  '&-tool-content-error': {
330
349
  display: 'flex',
331
350
  width: '100%',
@@ -89,7 +89,7 @@ import { ConfigProvider } from "antd";
89
89
  import classNames from "clsx";
90
90
  import { AnimatePresence, motion } from "framer-motion";
91
91
  import { useMergedState } from "rc-util";
92
- import React, { memo, useContext, useEffect, useMemo } from "react";
92
+ import React, { memo, useContext, useCallback, useEffect, useMemo, useRef, useState } from "react";
93
93
  import { useRefFunction } from "../Hooks/useRefFunction";
94
94
  import { useStyle } from "./style";
95
95
  var getChevronStyle = function getChevronStyle(expanded) {
@@ -102,6 +102,7 @@ var FLOATING_ICON_STYLE = {
102
102
  fontSize: 16,
103
103
  color: 'var(--color-gray-text-light)'
104
104
  };
105
+ /** 内容超出此高度时自动收起 */ var CONTENT_COLLAPSE_THRESHOLD = 200;
105
106
  var LOADING_ANIMATION = {
106
107
  animate: {
107
108
  '--rotate': [
@@ -196,10 +197,14 @@ var ExpandButton = function ExpandButton(param) {
196
197
  };
197
198
  var ThinkContainer = function ThinkContainer(param) {
198
199
  var thinkContent = param.thinkContent, expandedState = param.expandedState, floatingExpandedState = param.floatingExpandedState, status = param.status, light = param.light, prefixCls = param.prefixCls, hashId = param.hashId, customClassNames = param.classNames, styles = param.styles, onToggleFloatingExpand = param.onToggleFloatingExpand;
200
+ var contentInnerRef = useRef(null);
201
+ var _useState = _sliced_to_array(useState(false), 2), isContentOverflowing = _useState[0], setIsContentOverflowing = _useState[1];
202
+ var _useState1 = _sliced_to_array(useState(false), 2), contentExpanded = _useState1[0], setContentExpanded = _useState1[1];
199
203
  var _obj;
200
204
  var containerClassName = buildClassName("".concat(prefixCls, "-container"), hashId, customClassNames === null || customClassNames === void 0 ? void 0 : customClassNames.container, (_obj = {}, _define_property(_obj, "".concat(prefixCls, "-container-expanded"), expandedState), _define_property(_obj, "".concat(prefixCls, "-container-loading"), status === 'loading' && !floatingExpandedState), _define_property(_obj, "".concat(prefixCls, "-container-light"), light), _define_property(_obj, "".concat(prefixCls, "-container-floating-expanded"), floatingExpandedState), _obj));
201
205
  var contentClassName = buildClassName("".concat(prefixCls, "-content"), hashId, customClassNames === null || customClassNames === void 0 ? void 0 : customClassNames.content);
202
206
  var floatingExpandClassName = buildClassName("".concat(prefixCls, "-floating-expand"), hashId, customClassNames === null || customClassNames === void 0 ? void 0 : customClassNames.floatingExpand);
207
+ var contentExpandClassName = buildClassName("".concat(prefixCls, "-content-expand"), hashId);
203
208
  var floatingIcon = floatingExpandedState ? /*#__PURE__*/ React.createElement(ChevronsDownUp, {
204
209
  style: FLOATING_ICON_STYLE
205
210
  }) : /*#__PURE__*/ React.createElement(ChevronsUpDown, {
@@ -207,6 +212,67 @@ var ThinkContainer = function ThinkContainer(param) {
207
212
  });
208
213
  var floatingText = floatingExpandedState ? '收起' : '展开';
209
214
  var showFloatingExpand = status === 'loading' && !light;
215
+ var checkOverflow = useCallback(function() {
216
+ var el = contentInnerRef.current;
217
+ if (!el) return;
218
+ var scrollHeight = el.scrollHeight;
219
+ setIsContentOverflowing(scrollHeight > CONTENT_COLLAPSE_THRESHOLD);
220
+ }, []);
221
+ useEffect(function() {
222
+ if (!expandedState || !thinkContent) return;
223
+ checkOverflow();
224
+ var el = contentInnerRef.current;
225
+ if (!el) return;
226
+ var observer = new ResizeObserver(checkOverflow);
227
+ observer.observe(el);
228
+ return function() {
229
+ return observer.disconnect();
230
+ };
231
+ }, [
232
+ expandedState,
233
+ thinkContent,
234
+ checkOverflow
235
+ ]);
236
+ var handleContentExpandToggle = useRefFunction(function() {
237
+ setContentExpanded(function(prev) {
238
+ return !prev;
239
+ });
240
+ });
241
+ var showContentExpand = expandedState && thinkContent && status !== 'loading' && isContentOverflowing;
242
+ var contentInnerStyle = useMemo(function() {
243
+ if (!showContentExpand) return undefined;
244
+ if (contentExpanded) return undefined;
245
+ return {
246
+ maxHeight: CONTENT_COLLAPSE_THRESHOLD,
247
+ overflow: 'hidden'
248
+ };
249
+ }, [
250
+ showContentExpand,
251
+ contentExpanded
252
+ ]);
253
+ var contentExpandButton = useMemo(function() {
254
+ if (!showContentExpand) return null;
255
+ var icon = contentExpanded ? /*#__PURE__*/ React.createElement(ChevronsDownUp, null) : /*#__PURE__*/ React.createElement(ChevronsUpDown, null);
256
+ var text = contentExpanded ? '收起' : '展开';
257
+ return /*#__PURE__*/ React.createElement("div", {
258
+ className: contentExpandClassName,
259
+ onClick: handleContentExpandToggle,
260
+ "data-testid": "tool-use-bar-think-content-expand",
261
+ role: "button",
262
+ tabIndex: 0,
263
+ onKeyDown: function onKeyDown(e) {
264
+ if (e.key === 'Enter' || e.key === ' ') {
265
+ e.preventDefault();
266
+ handleContentExpandToggle();
267
+ }
268
+ }
269
+ }, icon, text);
270
+ }, [
271
+ showContentExpand,
272
+ contentExpanded,
273
+ contentExpandClassName,
274
+ handleContentExpandToggle
275
+ ]);
210
276
  // 缓存容器元素
211
277
  var contentVariants = useMemo(function() {
212
278
  return {
@@ -237,6 +303,18 @@ var ThinkContainer = function ThinkContainer(param) {
237
303
  }
238
304
  };
239
305
  }, []);
306
+ var innerContent = /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
307
+ ref: contentInnerRef,
308
+ style: contentInnerStyle
309
+ }, /*#__PURE__*/ React.createElement("div", {
310
+ className: contentClassName,
311
+ style: styles === null || styles === void 0 ? void 0 : styles.content
312
+ }, thinkContent)), contentExpandButton, showFloatingExpand ? /*#__PURE__*/ React.createElement("div", {
313
+ className: floatingExpandClassName,
314
+ onClick: onToggleFloatingExpand,
315
+ "data-testid": "tool-use-bar-think-floating-expand",
316
+ style: styles === null || styles === void 0 ? void 0 : styles.floatingExpand
317
+ }, floatingIcon, floatingText) : null);
240
318
  return /*#__PURE__*/ React.createElement(AnimatePresence, {
241
319
  initial: false,
242
320
  mode: "sync"
@@ -249,15 +327,7 @@ var ThinkContainer = function ThinkContainer(param) {
249
327
  transition: contentTransition,
250
328
  className: containerClassName,
251
329
  "data-testid": "tool-use-bar-think-container"
252
- }, /*#__PURE__*/ React.createElement("div", {
253
- className: contentClassName,
254
- style: styles === null || styles === void 0 ? void 0 : styles.content
255
- }, thinkContent), showFloatingExpand ? /*#__PURE__*/ React.createElement("div", {
256
- className: floatingExpandClassName,
257
- onClick: onToggleFloatingExpand,
258
- "data-testid": "tool-use-bar-think-floating-expand",
259
- style: styles === null || styles === void 0 ? void 0 : styles.floatingExpand
260
- }, floatingIcon, floatingText) : null) : null, !expandedState ? /*#__PURE__*/ React.createElement("div", {
330
+ }, innerContent) : null, !expandedState ? /*#__PURE__*/ React.createElement("div", {
261
331
  style: {
262
332
  visibility: 'hidden',
263
333
  height: 1,
@@ -319,6 +319,25 @@ var genStyle = function genStyle(token) {
319
319
  color: 'var(--color-gray-text-light)'
320
320
  }
321
321
  },
322
+ '&-content-expand': {
323
+ display: 'flex',
324
+ alignItems: 'center',
325
+ justifyContent: 'center',
326
+ gap: 4,
327
+ marginTop: 8,
328
+ padding: '8px 16px',
329
+ fontSize: 'var(--font-size-base)',
330
+ cursor: 'pointer',
331
+ borderRadius: 'var(--radius-control-base)',
332
+ background: 'var(--color-gray-control-fill-active)',
333
+ color: 'var(--color-gray-text-secondary)',
334
+ font: 'var(--font-text-body-emphasized-sm)',
335
+ flexShrink: 0,
336
+ '&:hover': {
337
+ background: 'var(--color-gray-control-fill-hover)',
338
+ color: 'var(--color-gray-text-default)'
339
+ }
340
+ },
322
341
  '&-floating-expand': {
323
342
  position: 'absolute',
324
343
  bottom: '8px',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.29.46",
3
+ "version": "2.29.48",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",
@@ -24,7 +24,6 @@
24
24
  "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
25
25
  "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
26
26
  "prepare": "husky install && dumi setup",
27
- "prepublishOnly": "father doctor && pnpm run test && pnpm run build",
28
27
  "prettier": "prettier --write \"{src,docs,test}/**/*.{js,jsx,ts,tsx,css,less,json,md}\"",
29
28
  "preview": "pnpm dumi preview",
30
29
  "report:demo": "node scripts/generateDemoReport.js",