@ant-design/agentic-ui 2.29.39 → 2.29.41

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.
@@ -660,7 +660,6 @@ import { VoiceButton } from "./VoiceButton";
660
660
  ]);
661
661
  var reSend = useMemo(function() {
662
662
  var _originalData_extra_preMessage, _originalData_extra;
663
- console.log('originalData?.isAborted', originalData, typing);
664
663
  if ((originalData === null || originalData === void 0 ? void 0 : originalData.isAborted) && !originalData.isFinished) {
665
664
  return /*#__PURE__*/ React.createElement("span", null, (locale === null || locale === void 0 ? void 0 : locale['chat.message.aborted']) || '回答已停止生成');
666
665
  }
@@ -451,7 +451,7 @@ var genStyle = function genStyle(token) {
451
451
  borderBottom: '1px solid var(--table-border-color)',
452
452
  textWrap: 'nowrap',
453
453
  verticalAlign: 'top',
454
- padding: '16px 12px',
454
+ padding: 'var(--table-cell-padding, 16px 12px)',
455
455
  textAlign: 'left',
456
456
  lineHeight: '24px',
457
457
  fontSize: '1em',
@@ -466,7 +466,7 @@ var genStyle = function genStyle(token) {
466
466
  background: 'inherit'
467
467
  }), _define_property(_obj1, 'td:not(.config-td)', {
468
468
  verticalAlign: 'top',
469
- padding: '16px 12px',
469
+ padding: 'var(--table-cell-padding, 16px 12px)',
470
470
  textAlign: 'left',
471
471
  position: 'relative',
472
472
  lineHeight: '24px',
@@ -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.39",
3
+ "version": "2.29.41",
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",