@ant-design/agentic-ui 2.29.40 → 2.29.43

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.
@@ -1,3 +1,5 @@
1
+ /** 表格列宽计算的列数阈值,少于该列数不设置 col 元素,使用浏览器默认布局 */
2
+ export declare const TABLE_COL_WIDTH_MIN_COLUMNS = 3;
1
3
  export declare const MOBILE_PADDING = "clamp(4px, 2vw, 12px)";
2
4
  export declare const MOBILE_BREAKPOINT = "768px";
3
5
  export declare const MOBILE_TABLE_MIN_COLUMN_WIDTH = 96;
@@ -2,6 +2,7 @@ var MOBILE_PADDING_MIN = '4px';
2
2
  var MOBILE_PADDING_MAX = '12px';
3
3
  var MOBILE_PADDING_SCALE = '2vw';
4
4
  var MOBILE_TABLE_MIN_CELL_WIDTH = 96;
5
+ /** 表格列宽计算的列数阈值,少于该列数不设置 col 元素,使用浏览器默认布局 */ export var TABLE_COL_WIDTH_MIN_COLUMNS = 3;
5
6
  export var MOBILE_PADDING = "clamp(".concat(MOBILE_PADDING_MIN, ", ").concat(MOBILE_PADDING_SCALE, ", ").concat(MOBILE_PADDING_MAX, ")");
6
7
  export var MOBILE_BREAKPOINT = '768px';
7
8
  export var MOBILE_TABLE_MIN_COLUMN_WIDTH = MOBILE_TABLE_MIN_CELL_WIDTH;
@@ -64,6 +64,7 @@ import classNames from "clsx";
64
64
  import copy from "copy-to-clipboard";
65
65
  import React, { useCallback, useContext, useMemo, useRef, useState } from "react";
66
66
  import { ActionIconBox } from "../../../../Components/ActionIconBox";
67
+ import { TABLE_COL_WIDTH_MIN_COLUMNS } from "../../../../Constants/mobile";
67
68
  import { I18nContext } from "../../../../I18n";
68
69
  import { useEditorStore } from "../../store";
69
70
  import { parserSlateNodeToMarkdown } from "../../utils";
@@ -84,15 +85,15 @@ import { parserSlateNodeToMarkdown } from "../../utils";
84
85
  var modelTargetRef = useRef(null);
85
86
  var _useState = _sliced_to_array(useState(false), 2), previewOpen = _useState[0], setPreviewOpen = _useState[1];
86
87
  var i18n = useContext(I18nContext);
87
- // 简化的列宽计算 - 只为 readonly 模式设计
88
+ // 简化的列宽计算 - 只为 readonly 模式设计,少于 3 列不设置 col
88
89
  var colWidths = useMemo(function() {
89
90
  var _element_children__children, _element_children_, _element_children;
91
+ var columnCount = (element === null || element === void 0 ? void 0 : (_element_children = element.children) === null || _element_children === void 0 ? void 0 : (_element_children_ = _element_children[0]) === null || _element_children_ === void 0 ? void 0 : (_element_children__children = _element_children_.children) === null || _element_children__children === void 0 ? void 0 : _element_children__children.length) || 0;
92
+ if (columnCount === 0 || columnCount < TABLE_COL_WIDTH_MIN_COLUMNS) return [];
90
93
  var otherProps = element === null || element === void 0 ? void 0 : element.otherProps;
91
94
  if (otherProps === null || otherProps === void 0 ? void 0 : otherProps.colWidths) {
92
95
  return otherProps.colWidths;
93
96
  }
94
- var columnCount = (element === null || element === void 0 ? void 0 : (_element_children = element.children) === null || _element_children === void 0 ? void 0 : (_element_children_ = _element_children[0]) === null || _element_children_ === void 0 ? void 0 : (_element_children__children = _element_children_.children) === null || _element_children__children === void 0 ? void 0 : _element_children__children.length) || 0;
95
- if (columnCount === 0) return [];
96
97
  // 使用固定宽度避免复杂计算
97
98
  var defaultWidth = 80;
98
99
  return Array(columnCount).fill(defaultWidth);
@@ -147,7 +148,7 @@ import { parserSlateNodeToMarkdown } from "../../utils";
147
148
  return /*#__PURE__*/ React.createElement("table", {
148
149
  ref: tableTargetRef,
149
150
  className: classNames("".concat(baseCls, "-editor-table"), 'readonly', "".concat(baseCls, "-readonly-table"), _define_property({}, "".concat(baseCls, "-readonly-pure"), editorProps === null || editorProps === void 0 ? void 0 : (_editorProps_tableConfig = editorProps.tableConfig) === null || _editorProps_tableConfig === void 0 ? void 0 : _editorProps_tableConfig.pure))
150
- }, /*#__PURE__*/ React.createElement("colgroup", null, colWidths.map(function(colWidth, index) {
151
+ }, colWidths.length > 0 && /*#__PURE__*/ React.createElement("colgroup", null, colWidths.map(function(colWidth, index) {
151
152
  var isLastCol = index === colWidths.length - 1;
152
153
  return /*#__PURE__*/ React.createElement("col", {
153
154
  key: index,
@@ -194,6 +195,12 @@ import { parserSlateNodeToMarkdown } from "../../utils";
194
195
  afterClose: handleModalClose,
195
196
  width: "80vw",
196
197
  onCancel: handleModalClose
198
+ }, /*#__PURE__*/ React.createElement("div", {
199
+ className: getPrefixCls('agentic-md-editor'),
200
+ style: {
201
+ flex: 1,
202
+ minWidth: 0
203
+ }
197
204
  }, /*#__PURE__*/ React.createElement("div", {
198
205
  className: classNames(baseCls, getPrefixCls('agentic-md-editor-content')),
199
206
  style: {
@@ -204,15 +211,12 @@ import { parserSlateNodeToMarkdown } from "../../utils";
204
211
  },
205
212
  ref: modelTargetRef,
206
213
  onMouseDown: function onMouseDown(e) {
207
- // 阻止默认的文字选择行为
208
214
  e.preventDefault();
209
215
  },
210
216
  onDragStart: function onDragStart(e) {
211
- // 阻止拖拽开始时的文字选择
212
217
  e.preventDefault();
213
218
  },
214
219
  onDoubleClick: function onDoubleClick(e) {
215
- // 阻止双击选择文字
216
220
  e.preventDefault();
217
221
  }
218
222
  }, /*#__PURE__*/ React.createElement(ConfigProvider, {
@@ -222,6 +226,6 @@ import { parserSlateNodeToMarkdown } from "../../utils";
222
226
  getTargetContainer: function getTargetContainer() {
223
227
  return modelTargetRef.current || document.body;
224
228
  }
225
- }, tableDom))));
229
+ }, tableDom)))));
226
230
  });
227
231
  ReadonlyTableComponent.displayName = 'ReadonlyTableComponent';
@@ -149,7 +149,7 @@ import classNames from "clsx";
149
149
  import React, { useContext, useEffect, useMemo, useRef } from "react";
150
150
  import { Node } from "slate";
151
151
  import stringWidth from "string-width";
152
- import { MOBILE_BREAKPOINT, MOBILE_TABLE_MIN_COLUMN_WIDTH } from "../../../../Constants/mobile";
152
+ import { MOBILE_BREAKPOINT, MOBILE_TABLE_MIN_COLUMN_WIDTH, TABLE_COL_WIDTH_MIN_COLUMNS } from "../../../../Constants/mobile";
153
153
  import { useEditorStore } from "../../store";
154
154
  import { ReadonlyTableComponent } from "./ReadonlyTableComponent";
155
155
  import { TablePropsContext } from "./TableContext";
@@ -197,18 +197,20 @@ import useScrollShadow from "./useScrollShadow";
197
197
  // 只在编辑模式下进行复杂的列宽计算
198
198
  var colWidths = useMemo(function() {
199
199
  var _props_element_otherProps, _props_element, _props_element_children, _props_element1, _tableRows__children, _tableRows_, _markdownContainerRef_current_querySelector, _markdownContainerRef_current;
200
- // readonly 模式下使用简化计算
200
+ // readonly 模式下使用简化计算,少于 3 列不设置 col
201
201
  if (readonly) {
202
- var _props_element2, _props_element_children__children, _props_element_children_, _props_element_children1, _props_element3;
203
- var otherProps = (_props_element2 = props.element) === null || _props_element2 === void 0 ? void 0 : _props_element2.otherProps;
202
+ var _props_element_children__children, _props_element_children_, _props_element_children1, _props_element2, _props_element3;
203
+ var colCount = ((_props_element2 = props.element) === null || _props_element2 === void 0 ? void 0 : (_props_element_children1 = _props_element2.children) === null || _props_element_children1 === void 0 ? void 0 : (_props_element_children_ = _props_element_children1[0]) === null || _props_element_children_ === void 0 ? void 0 : (_props_element_children__children = _props_element_children_.children) === null || _props_element_children__children === void 0 ? void 0 : _props_element_children__children.length) || 0;
204
+ if (colCount === 0 || colCount < TABLE_COL_WIDTH_MIN_COLUMNS) return [];
205
+ var otherProps = (_props_element3 = props.element) === null || _props_element3 === void 0 ? void 0 : _props_element3.otherProps;
204
206
  if (otherProps === null || otherProps === void 0 ? void 0 : otherProps.colWidths) {
205
207
  return otherProps.colWidths;
206
208
  }
207
- var columnCount1 = ((_props_element3 = props.element) === null || _props_element3 === void 0 ? void 0 : (_props_element_children1 = _props_element3.children) === null || _props_element_children1 === void 0 ? void 0 : (_props_element_children_ = _props_element_children1[0]) === null || _props_element_children_ === void 0 ? void 0 : (_props_element_children__children = _props_element_children_.children) === null || _props_element_children__children === void 0 ? void 0 : _props_element_children__children.length) || 0;
208
- if (columnCount1 === 0) return [];
209
- return Array(columnCount1).fill(80); // 固定宽度
209
+ return Array(colCount).fill(80); // 固定宽度
210
210
  }
211
- // 如果在props中存在,直接使用以避免计算
211
+ // 少于 3 列不设置 col,使用浏览器默认布局
212
+ if (columnCount < TABLE_COL_WIDTH_MIN_COLUMNS) return [];
213
+ // 如果在 props 中存在,直接使用以避免计算
212
214
  if ((_props_element = props.element) === null || _props_element === void 0 ? void 0 : (_props_element_otherProps = _props_element.otherProps) === null || _props_element_otherProps === void 0 ? void 0 : _props_element_otherProps.colWidths) {
213
215
  var _props_element_otherProps1, _props_element4;
214
216
  return (_props_element4 = props.element) === null || _props_element4 === void 0 ? void 0 : (_props_element_otherProps1 = _props_element4.otherProps) === null || _props_element_otherProps1 === void 0 ? void 0 : _props_element_otherProps1.colWidths;
@@ -333,10 +335,12 @@ import useScrollShadow from "./useScrollShadow";
333
335
  });
334
336
  }) || null), /*#__PURE__*/ React.createElement("tbody", null, readonly ? null : /*#__PURE__*/ React.createElement(TableRowIndex, {
335
337
  colWidths: colWidths,
338
+ columnCount: columnCount,
336
339
  tablePath: tablePath
337
340
  }), children));
338
341
  }, [
339
342
  colWidths,
343
+ columnCount,
340
344
  children,
341
345
  baseCls
342
346
  ]);
@@ -3,8 +3,10 @@ import React from 'react';
3
3
  * TableRowIndex 组件的属性接口
4
4
  */
5
5
  export interface TableRowIndexProps {
6
- /** 列宽度数组 */
6
+ /** 列宽度数组,为空时使用 columnCount 渲染占位单元格 */
7
7
  colWidths?: number[];
8
+ /** 数据列数,colWidths 为空时用于渲染占位单元格数量 */
9
+ columnCount?: number;
8
10
  /** 自定义样式 */
9
11
  style?: React.CSSProperties;
10
12
  /** 自定义类名 */
@@ -34,7 +34,8 @@ import { TableCellIndexSpacer } from "../TableCellIndexSpacer";
34
34
  * - 根据列宽度数组生成对应的间隔单元格
35
35
  * - 包含行索引单元格和列间隔单元格
36
36
  */ export var TableRowIndex = function TableRowIndex(param) {
37
- var _param_colWidths = param.colWidths, colWidths = _param_colWidths === void 0 ? [] : _param_colWidths, style = param.style, className = param.className, tablePath = param.tablePath;
37
+ var _param_colWidths = param.colWidths, colWidths = _param_colWidths === void 0 ? [] : _param_colWidths, _param_columnCount = param.columnCount, columnCount = _param_columnCount === void 0 ? 0 : _param_columnCount, style = param.style, className = param.className, tablePath = param.tablePath;
38
+ var spacerCount = colWidths.length > 0 ? colWidths.length : columnCount;
38
39
  var context = useContext(ConfigProvider.ConfigContext);
39
40
  var baseClassName = context === null || context === void 0 ? void 0 : context.getPrefixCls('agentic-md-editor-table-row-index');
40
41
  return /*#__PURE__*/ React.createElement("tr", {
@@ -51,7 +52,9 @@ import { TableCellIndexSpacer } from "../TableCellIndexSpacer";
51
52
  columnIndex: -1,
52
53
  key: -1,
53
54
  tablePath: tablePath
54
- }), colWidths.map(function(_, index) {
55
+ }), Array.from({
56
+ length: spacerCount
57
+ }).map(function(_, index) {
55
58
  return /*#__PURE__*/ React.createElement(TableCellIndexSpacer, {
56
59
  key: index,
57
60
  columnIndex: index,
@@ -415,12 +415,10 @@ var genStyle = function genStyle(token) {
415
415
  width: 'max-content',
416
416
  tableLayout: 'fixed',
417
417
  margin: '16px 0',
418
- maxWidth: '100%',
419
- position: 'relative',
420
- fontVariant: 'tabular-nums',
421
- borderRadius: 'var(--table-border-radius)',
422
- border: '1px solid var(--table-border-color)'
423
- }, _define_property(_obj1, "&".concat(token.componentCls, "-content-table-readonly-pure"), {
418
+ maxWidth: '100%'
419
+ }, _define_property(_obj1, "&".concat(token.componentCls, "-content-table-readonly-table"), {
420
+ width: '100%'
421
+ }), _define_property(_obj1, "position", 'relative'), _define_property(_obj1, "fontVariant", 'tabular-nums'), _define_property(_obj1, "borderRadius", 'var(--table-border-radius)'), _define_property(_obj1, "border", '1px solid var(--table-border-color)'), _define_property(_obj1, "&".concat(token.componentCls, "-content-table-readonly-pure"), {
424
422
  border: 'none',
425
423
  borderRadius: 'none',
426
424
  'tr:not(.config-tr) td:not(.config-td)': {
@@ -4,6 +4,7 @@ interface ToolImageProps {
4
4
  tool: ToolCall;
5
5
  prefixCls: string;
6
6
  hashId: string;
7
+ disableAnimation?: boolean;
7
8
  }
8
9
  export declare const ToolImage: React.NamedExoticComponent<ToolImageProps>;
9
10
  interface ToolHeaderRightProps {
@@ -11,6 +12,7 @@ interface ToolHeaderRightProps {
11
12
  prefixCls: string;
12
13
  hashId: string;
13
14
  light: boolean;
15
+ disableAnimation?: boolean;
14
16
  }
15
17
  export declare const ToolHeaderRight: React.NamedExoticComponent<ToolHeaderRightProps>;
16
18
  interface ToolTimeProps {
@@ -25,6 +27,7 @@ interface ToolExpandProps {
25
27
  prefixCls: string;
26
28
  hashId: string;
27
29
  onExpandClick: (e: React.MouseEvent<HTMLDivElement>) => void;
30
+ disableAnimation?: boolean;
28
31
  }
29
32
  export declare const ToolExpand: React.NamedExoticComponent<ToolExpandProps>;
30
33
  interface ToolContentProps {
@@ -34,6 +37,7 @@ interface ToolContentProps {
34
37
  light: boolean;
35
38
  showContent: boolean;
36
39
  expanded: boolean;
40
+ disableAnimation?: boolean;
37
41
  }
38
42
  export declare const ToolContent: React.NamedExoticComponent<ToolContentProps>;
39
43
  export {};
@@ -26,13 +26,37 @@ function _object_spread(target) {
26
26
  }
27
27
  return target;
28
28
  }
29
+ function ownKeys(object, enumerableOnly) {
30
+ var keys = Object.keys(object);
31
+ if (Object.getOwnPropertySymbols) {
32
+ var symbols = Object.getOwnPropertySymbols(object);
33
+ if (enumerableOnly) {
34
+ symbols = symbols.filter(function(sym) {
35
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
36
+ });
37
+ }
38
+ keys.push.apply(keys, symbols);
39
+ }
40
+ return keys;
41
+ }
42
+ function _object_spread_props(target, source) {
43
+ source = source != null ? source : {};
44
+ if (Object.getOwnPropertyDescriptors) {
45
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
46
+ } else {
47
+ ownKeys(Object(source)).forEach(function(key) {
48
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
49
+ });
50
+ }
51
+ return target;
52
+ }
29
53
  import { Api, ChevronUp, X } from "@sofa-design/icons";
30
54
  import classNames from "clsx";
31
55
  import { AnimatePresence, motion } from "framer-motion";
32
56
  import React, { memo, useMemo } from "react";
33
57
  import { useRefFunction } from "../../Hooks/useRefFunction";
34
58
  var ToolImageComponent = function ToolImageComponent(param) {
35
- var tool = param.tool, prefixCls = param.prefixCls, hashId = param.hashId;
59
+ var tool = param.tool, prefixCls = param.prefixCls, hashId = param.hashId, _param_disableAnimation = param.disableAnimation, disableAnimation = _param_disableAnimation === void 0 ? false : _param_disableAnimation;
36
60
  var toolImageWrapperClassName = useMemo(function() {
37
61
  var _obj;
38
62
  return classNames("".concat(prefixCls, "-tool-image-wrapper"), hashId, (_obj = {}, _define_property(_obj, "".concat(prefixCls, "-tool-image-wrapper-rotating"), tool.status === 'loading'), _define_property(_obj, "".concat(prefixCls, "-tool-image-wrapper-loading"), tool.status === 'loading'), _obj));
@@ -76,11 +100,13 @@ var ToolImageComponent = function ToolImageComponent(param) {
76
100
  };
77
101
  }, []);
78
102
  var animationProps = useMemo(function() {
103
+ if (disableAnimation) return {};
79
104
  return tool.status === 'loading' ? loadingAnimationConfig : idleAnimationConfig;
80
105
  }, [
81
106
  tool.status,
82
107
  loadingAnimationConfig,
83
- idleAnimationConfig
108
+ idleAnimationConfig,
109
+ disableAnimation
84
110
  ]);
85
111
  // 缓存图标渲染
86
112
  var iconElement = useMemo(function() {
@@ -88,6 +114,13 @@ var ToolImageComponent = function ToolImageComponent(param) {
88
114
  }, [
89
115
  tool.icon
90
116
  ]);
117
+ if (disableAnimation) {
118
+ return /*#__PURE__*/ React.createElement("div", {
119
+ className: toolImageWrapperClassName
120
+ }, /*#__PURE__*/ React.createElement("div", {
121
+ className: toolImageClassName
122
+ }, iconElement));
123
+ }
91
124
  return /*#__PURE__*/ React.createElement(motion.div, _object_spread({
92
125
  className: toolImageWrapperClassName
93
126
  }, animationProps), /*#__PURE__*/ React.createElement("div", {
@@ -96,7 +129,7 @@ var ToolImageComponent = function ToolImageComponent(param) {
96
129
  };
97
130
  export var ToolImage = /*#__PURE__*/ memo(ToolImageComponent);
98
131
  var ToolHeaderRightComponent = function ToolHeaderRightComponent(param) {
99
- var tool = param.tool, prefixCls = param.prefixCls, hashId = param.hashId, light = param.light;
132
+ var tool = param.tool, prefixCls = param.prefixCls, hashId = param.hashId, light = param.light, _param_disableAnimation = param.disableAnimation, disableAnimation = _param_disableAnimation === void 0 ? false : _param_disableAnimation;
100
133
  var toolHeaderRightClassName = useMemo(function() {
101
134
  return classNames("".concat(prefixCls, "-tool-header-right"), _define_property({}, "".concat(prefixCls, "-tool-header-right-light"), light), hashId);
102
135
  }, [
@@ -142,10 +175,12 @@ var ToolHeaderRightComponent = function ToolHeaderRightComponent(param) {
142
175
  };
143
176
  }, []);
144
177
  var animationProps = useMemo(function() {
178
+ if (disableAnimation) return {};
145
179
  return tool.status === 'loading' ? loadingAnimationConfig : {};
146
180
  }, [
147
181
  tool.status,
148
- loadingAnimationConfig
182
+ loadingAnimationConfig,
183
+ disableAnimation
149
184
  ]);
150
185
  // 缓存工具名称和目标渲染
151
186
  var toolNameElement = useMemo(function() {
@@ -167,6 +202,11 @@ var ToolHeaderRightComponent = function ToolHeaderRightComponent(param) {
167
202
  tool.toolTarget,
168
203
  toolTargetClassName
169
204
  ]);
205
+ if (disableAnimation) {
206
+ return /*#__PURE__*/ React.createElement("div", {
207
+ className: toolHeaderRightClassName
208
+ }, toolNameElement, toolTargetElement);
209
+ }
170
210
  return /*#__PURE__*/ React.createElement(motion.div, _object_spread({
171
211
  className: toolHeaderRightClassName
172
212
  }, animationProps), toolNameElement, toolTargetElement);
@@ -193,7 +233,7 @@ var ToolTimeComponent = function ToolTimeComponent(param) {
193
233
  };
194
234
  export var ToolTime = /*#__PURE__*/ memo(ToolTimeComponent);
195
235
  var ToolExpandComponent = function ToolExpandComponent(param) {
196
- var showContent = param.showContent, expanded = param.expanded, prefixCls = param.prefixCls, hashId = param.hashId, onExpandClick = param.onExpandClick;
236
+ var showContent = param.showContent, expanded = param.expanded, prefixCls = param.prefixCls, hashId = param.hashId, onExpandClick = param.onExpandClick, _param_disableAnimation = param.disableAnimation, disableAnimation = _param_disableAnimation === void 0 ? false : _param_disableAnimation;
197
237
  var toolExpandClassName = useMemo(function() {
198
238
  return classNames("".concat(prefixCls, "-tool-expand"), hashId);
199
239
  }, [
@@ -202,12 +242,14 @@ var ToolExpandComponent = function ToolExpandComponent(param) {
202
242
  ]);
203
243
  // 缓存样式对象,避免重复创建
204
244
  var chevronStyle = useMemo(function() {
205
- return {
206
- transition: 'transform 0.3s ease-in-out',
245
+ return _object_spread_props(_object_spread({}, disableAnimation ? {} : {
246
+ transition: 'transform 0.3s ease-in-out'
247
+ }), {
207
248
  transform: expanded ? 'rotate(180deg)' : 'rotate(0deg)'
208
- };
249
+ });
209
250
  }, [
210
- expanded
251
+ expanded,
252
+ disableAnimation
211
253
  ]);
212
254
  // 使用 useRefFunction 优化点击处理函数
213
255
  var handleClick = useRefFunction(function(e) {
@@ -232,7 +274,7 @@ var ToolExpandComponent = function ToolExpandComponent(param) {
232
274
  };
233
275
  export var ToolExpand = /*#__PURE__*/ memo(ToolExpandComponent);
234
276
  var ToolContentComponent = function ToolContentComponent(param) {
235
- var tool = param.tool, prefixCls = param.prefixCls, hashId = param.hashId, light = param.light, showContent = param.showContent, expanded = param.expanded;
277
+ 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;
236
278
  var toolContainerClassName = useMemo(function() {
237
279
  return classNames("".concat(prefixCls, "-tool-container"), hashId, _define_property({}, "".concat(prefixCls, "-tool-container-light"), light));
238
280
  }, [
@@ -288,7 +330,6 @@ var ToolContentComponent = function ToolContentComponent(param) {
288
330
  tool.content,
289
331
  contentClassName
290
332
  ]);
291
- // 缓存容器元素
292
333
  var contentVariants = useMemo(function() {
293
334
  return {
294
335
  expanded: {
@@ -318,13 +359,22 @@ var ToolContentComponent = function ToolContentComponent(param) {
318
359
  }
319
360
  };
320
361
  }, []);
321
- // 缓存样式对象
322
362
  var containerStyle = useMemo(function() {
323
363
  return {
324
364
  overflow: 'hidden',
325
365
  willChange: 'height, opacity'
326
366
  };
327
367
  }, []);
368
+ // 禁用动画时使用简单的显示/隐藏
369
+ if (disableAnimation) {
370
+ return showContent && expanded ? /*#__PURE__*/ React.createElement("div", {
371
+ className: toolContainerClassName,
372
+ "data-testid": "tool-user-item-tool-container",
373
+ style: {
374
+ overflow: 'hidden'
375
+ }
376
+ }, contentDom, errorDom) : null;
377
+ }
328
378
  return /*#__PURE__*/ React.createElement(AnimatePresence, {
329
379
  initial: false,
330
380
  mode: "sync"
@@ -22,5 +22,6 @@ export interface ToolUseBarItemProps {
22
22
  onExpandedChange?: (id: string, expanded: boolean) => void;
23
23
  defaultExpanded?: boolean;
24
24
  light?: boolean;
25
+ disableAnimation?: boolean;
25
26
  }
26
27
  export declare const ToolUseBarItem: React.NamedExoticComponent<ToolUseBarItemProps>;
@@ -70,7 +70,7 @@ import React, { memo, useMemo } from "react";
70
70
  import { useRefFunction } from "../../Hooks/useRefFunction";
71
71
  import { ToolContent, ToolExpand, ToolHeaderRight, ToolImage, ToolTime } from "./Content";
72
72
  var ToolUseBarItemComponent = function ToolUseBarItemComponent(param) {
73
- var tool = param.tool, prefixCls = param.prefixCls, hashId = param.hashId, onClick = param.onClick, isActive = param.isActive, onActiveChange = param.onActiveChange, isExpanded = param.isExpanded, onExpandedChange = param.onExpandedChange, defaultExpanded = param.defaultExpanded, _param_light = param.light, light = _param_light === void 0 ? false : _param_light;
73
+ var tool = param.tool, prefixCls = param.prefixCls, hashId = param.hashId, onClick = param.onClick, isActive = param.isActive, onActiveChange = param.onActiveChange, isExpanded = param.isExpanded, onExpandedChange = param.onExpandedChange, defaultExpanded = param.defaultExpanded, _param_light = param.light, light = _param_light === void 0 ? false : _param_light, _param_disableAnimation = param.disableAnimation, disableAnimation = _param_disableAnimation === void 0 ? false : _param_disableAnimation;
74
74
  // 使用 useMergedState 来管理展开状态
75
75
  var _useMergedState = _sliced_to_array(useMergedState(defaultExpanded !== null && defaultExpanded !== void 0 ? defaultExpanded : false, {
76
76
  value: isExpanded,
@@ -146,7 +146,8 @@ var ToolUseBarItemComponent = function ToolUseBarItemComponent(param) {
146
146
  hashId: hashId,
147
147
  light: light,
148
148
  showContent: true,
149
- expanded: true
149
+ expanded: true,
150
+ disableAnimation: disableAnimation
150
151
  });
151
152
  }
152
153
  return /*#__PURE__*/ React.createElement("div", {
@@ -163,12 +164,14 @@ var ToolUseBarItemComponent = function ToolUseBarItemComponent(param) {
163
164
  }, /*#__PURE__*/ React.createElement(ToolImage, {
164
165
  tool: tool,
165
166
  prefixCls: prefixCls,
166
- hashId: hashId
167
+ hashId: hashId,
168
+ disableAnimation: disableAnimation
167
169
  })), /*#__PURE__*/ React.createElement(ToolHeaderRight, {
168
170
  tool: tool,
169
171
  prefixCls: prefixCls,
170
172
  hashId: hashId,
171
- light: light
173
+ light: light,
174
+ disableAnimation: disableAnimation
172
175
  }), tool.time || showContent ? /*#__PURE__*/ React.createElement("div", {
173
176
  className: classNames("".concat(prefixCls, "-tool-time-expand"), hashId)
174
177
  }, /*#__PURE__*/ React.createElement(ToolTime, {
@@ -180,14 +183,16 @@ var ToolUseBarItemComponent = function ToolUseBarItemComponent(param) {
180
183
  expanded: expanded,
181
184
  prefixCls: prefixCls,
182
185
  hashId: hashId,
183
- onExpandClick: handleExpandClick
186
+ onExpandClick: handleExpandClick,
187
+ disableAnimation: disableAnimation
184
188
  })) : null), /*#__PURE__*/ React.createElement(ToolContent, {
185
189
  tool: tool,
186
190
  prefixCls: prefixCls,
187
191
  hashId: hashId,
188
192
  light: light,
189
193
  showContent: showContent,
190
- expanded: expanded
194
+ expanded: expanded,
195
+ disableAnimation: disableAnimation
191
196
  }));
192
197
  };
193
198
  // 使用 memo 优化组件,避免不必要的重新渲染
@@ -14,5 +14,7 @@ interface ToolUseBarProps {
14
14
  onExpandedKeysChange?: (expandedKeys: string[], removedKeys: string[]) => void;
15
15
  testId?: string;
16
16
  light?: boolean;
17
+ /** 关闭动画,在性能较弱设备上可减少卡顿 */
18
+ disableAnimation?: boolean;
17
19
  }
18
20
  export declare const ToolUseBar: React.NamedExoticComponent<ToolUseBarProps>;
@@ -9,6 +9,19 @@ function _array_with_holes(arr) {
9
9
  function _array_without_holes(arr) {
10
10
  if (Array.isArray(arr)) return _array_like_to_array(arr);
11
11
  }
12
+ function _define_property(obj, key, value) {
13
+ if (key in obj) {
14
+ Object.defineProperty(obj, key, {
15
+ value: value,
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true
19
+ });
20
+ } else {
21
+ obj[key] = value;
22
+ }
23
+ return obj;
24
+ }
12
25
  function _iterable_to_array(iter) {
13
26
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
14
27
  }
@@ -142,11 +155,12 @@ export * from "./BarItem";
142
155
  * - 提供加载状态显示
143
156
  * - 支持错误状态处理
144
157
  */ var ToolUseBarComponent = function ToolUseBarComponent(_0) {
145
- var tools = _0.tools, onActiveKeysChange = _0.onActiveKeysChange, onExpandedKeysChange = _0.onExpandedKeysChange, _0_light = _0.light, light = _0_light === void 0 ? false : _0_light, style = _0.style, props = _object_without_properties(_0, [
158
+ var tools = _0.tools, onActiveKeysChange = _0.onActiveKeysChange, onExpandedKeysChange = _0.onExpandedKeysChange, _0_light = _0.light, light = _0_light === void 0 ? false : _0_light, _0_disableAnimation = _0.disableAnimation, disableAnimation = _0_disableAnimation === void 0 ? false : _0_disableAnimation, style = _0.style, props = _object_without_properties(_0, [
146
159
  "tools",
147
160
  "onActiveKeysChange",
148
161
  "onExpandedKeysChange",
149
162
  "light",
163
+ "disableAnimation",
150
164
  "style"
151
165
  ]);
152
166
  var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
@@ -203,7 +217,8 @@ export * from "./BarItem";
203
217
  defaultExpanded: (_props_defaultExpandedKeys = props.defaultExpandedKeys) === null || _props_defaultExpandedKeys === void 0 ? void 0 : _props_defaultExpandedKeys.includes(tool.id),
204
218
  prefixCls: prefixCls,
205
219
  hashId: hashId,
206
- light: light
220
+ light: light,
221
+ disableAnimation: disableAnimation
207
222
  });
208
223
  });
209
224
  }, [
@@ -217,15 +232,17 @@ export * from "./BarItem";
217
232
  props.defaultExpandedKeys,
218
233
  prefixCls,
219
234
  hashId,
220
- light
235
+ light,
236
+ disableAnimation
221
237
  ]);
222
238
  // 使用 useMemo 优化样式类名
223
239
  var containerClassName = useMemo(function() {
224
- return classNames(prefixCls, hashId, props.className);
240
+ return classNames(prefixCls, hashId, props.className, _define_property({}, "".concat(prefixCls, "-no-animation"), disableAnimation));
225
241
  }, [
226
242
  prefixCls,
227
243
  hashId,
228
- props.className
244
+ props.className,
245
+ disableAnimation
229
246
  ]);
230
247
  if (!(tools === null || tools === void 0 ? void 0 : tools.length)) return /*#__PURE__*/ React.createElement("div", {
231
248
  className: containerClassName,
@@ -53,6 +53,11 @@ function _object_spread_props(target, source) {
53
53
  import { useEditorStyleRegister } from "../Hooks/useStyle";
54
54
  var genStyle = function genStyle(token) {
55
55
  return _define_property({}, token.componentCls, {
56
+ '&-no-animation': {
57
+ '& *': {
58
+ transition: 'none !important'
59
+ }
60
+ },
56
61
  display: 'flex',
57
62
  flexDirection: 'column',
58
63
  gap: 4,
@@ -314,7 +319,11 @@ var genStyle = function genStyle(token) {
314
319
  fontWeight: 'normal',
315
320
  lineHeight: '160%',
316
321
  letterSpacing: 'normal',
317
- color: '#767E8B'
322
+ color: '#767E8B',
323
+ overflow: 'hidden',
324
+ display: '-webkit-box',
325
+ WebkitLineClamp: 5,
326
+ WebkitBoxOrient: 'vertical'
318
327
  },
319
328
  '&-tool-content-error': {
320
329
  display: 'flex',
@@ -270,6 +270,12 @@ var genStyle = function genStyle(token) {
270
270
  maxHeight: 158,
271
271
  overflow: 'hidden',
272
272
  position: 'relative',
273
+ '&-content': {
274
+ overflow: 'hidden',
275
+ display: '-webkit-box',
276
+ WebkitLineClamp: 1,
277
+ WebkitBoxOrient: 'vertical'
278
+ },
273
279
  '&:hover': _define_property({}, "&-floating-expand", {
274
280
  opacity: 1,
275
281
  visibility: 'visible'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.29.40",
3
+ "version": "2.29.43",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",