@ant-design/agentic-ui 2.24.2 → 2.24.3

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.
@@ -4,7 +4,7 @@
4
4
  */ import React, { useContext } from "react";
5
5
  import { I18nContext } from "../../../I18n";
6
6
  import { EditorStoreContext } from "../../../MarkdownEditor/editor/store";
7
- import { ToolUseBarThink } from "../../../ToolUseBar";
7
+ import { ToolUseBarThink } from "../../../ToolUseBarThink";
8
8
  /**
9
9
  * 将特殊标记恢复为代码块格式
10
10
  * @param content - 包含特殊标记的内容
@@ -59,8 +59,9 @@ function _unsupported_iterable_to_array(o, minLen) {
59
59
  import { ChevronUp, CircleDashed, SuccessFill, X } from "@sofa-design/icons";
60
60
  import { ConfigProvider } from "antd";
61
61
  import classNames from "classnames";
62
+ import { AnimatePresence, motion } from "framer-motion";
62
63
  import { useMergedState } from "rc-util";
63
- import React, { memo, useCallback, useContext } from "react";
64
+ import React, { memo, useCallback, useContext, useMemo } from "react";
64
65
  import { ActionIconBox } from "../Components/ActionIconBox";
65
66
  import { Loading } from "../Components/Loading";
66
67
  import { I18nContext } from "../I18n";
@@ -80,7 +81,8 @@ var hasTaskContent = function(content) {
80
81
  };
81
82
  var getArrowRotation = function(collapsed) {
82
83
  return {
83
- transform: collapsed ? 'rotate(0deg)' : 'rotate(180deg)'
84
+ transform: collapsed ? 'rotate(0deg)' : 'rotate(180deg)',
85
+ transition: 'transform 0.3s ease'
84
86
  };
85
87
  };
86
88
  var StatusIcon = function(param) {
@@ -109,6 +111,35 @@ var TaskListItem = function(param) {
109
111
  return onToggle(item.key);
110
112
  };
111
113
  var arrowTitle = isCollapsed ? (locale === null || locale === void 0 ? void 0 : locale['taskList.expand']) || '展开' : (locale === null || locale === void 0 ? void 0 : locale['taskList.collapse']) || '收起';
114
+ var contentVariants = useMemo(function() {
115
+ return {
116
+ expanded: {
117
+ height: 'auto',
118
+ opacity: 1
119
+ },
120
+ collapsed: {
121
+ height: 0,
122
+ opacity: 0
123
+ }
124
+ };
125
+ }, []);
126
+ var contentTransition = useMemo(function() {
127
+ return {
128
+ height: {
129
+ duration: 0.26,
130
+ ease: [
131
+ 0.4,
132
+ 0,
133
+ 0.2,
134
+ 1
135
+ ]
136
+ },
137
+ opacity: {
138
+ duration: 0.2,
139
+ ease: 'linear'
140
+ }
141
+ };
142
+ }, []);
112
143
  return /*#__PURE__*/ React.createElement("div", {
113
144
  key: item.key,
114
145
  className: buildClassName("".concat(prefixCls, "-thoughtChainItem"), hashId),
@@ -144,11 +175,19 @@ var TaskListItem = function(param) {
144
175
  onClick: handleToggle
145
176
  }, /*#__PURE__*/ React.createElement(ChevronUp, {
146
177
  "data-testid": "task-list-arrow"
147
- })))), !isCollapsed && /*#__PURE__*/ React.createElement("div", {
178
+ })))), /*#__PURE__*/ React.createElement(AnimatePresence, {
179
+ initial: false
180
+ }, !isCollapsed && /*#__PURE__*/ React.createElement(motion.div, {
181
+ key: "task-content",
182
+ variants: contentVariants,
183
+ initial: "collapsed",
184
+ animate: "expanded",
185
+ exit: "collapsed",
186
+ transition: contentTransition,
148
187
  className: buildClassName("".concat(prefixCls, "-body"), hashId)
149
188
  }, /*#__PURE__*/ React.createElement("div", {
150
189
  className: buildClassName("".concat(prefixCls, "-content"), hashId)
151
- }, item.content))));
190
+ }, item.content)))));
152
191
  };
153
192
  var getDefaultExpandedKeys = function(items, isControlled) {
154
193
  return isControlled ? [] : items.map(function(item) {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ToolCall } from './ToolUseBarItem';
2
+ import { ToolCall } from '.';
3
3
  interface ToolImageProps {
4
4
  tool: ToolCall;
5
5
  prefixCls: string;
@@ -314,28 +314,18 @@ var ToolContentComponent = function(param) {
314
314
  ]
315
315
  },
316
316
  opacity: {
317
- duration: 0.26,
318
- ease: [
319
- 0.4,
320
- 0,
321
- 0.2,
322
- 1
323
- ]
317
+ duration: 0.2,
318
+ ease: 'linear'
324
319
  }
325
320
  };
326
321
  }, []);
327
- if (!showContent || !expanded) {
328
- return /*#__PURE__*/ React.createElement("div", {
329
- style: {
330
- overflow: 'hidden',
331
- height: 1,
332
- opacity: 0,
333
- visibility: 'hidden'
334
- },
335
- role: "presentation",
336
- "aria-hidden": "true"
337
- }, contentDom, errorDom);
338
- }
322
+ // 缓存样式对象
323
+ var containerStyle = useMemo(function() {
324
+ return {
325
+ overflow: 'hidden',
326
+ willChange: 'height, opacity'
327
+ };
328
+ }, []);
339
329
  return /*#__PURE__*/ React.createElement(AnimatePresence, {
340
330
  initial: false,
341
331
  mode: "sync"
@@ -348,9 +338,16 @@ var ToolContentComponent = function(param) {
348
338
  animate: "expanded",
349
339
  exit: "collapsed",
350
340
  transition: contentTransition,
341
+ style: containerStyle
342
+ }, contentDom, errorDom) : null, !showContent || !expanded ? /*#__PURE__*/ React.createElement("div", {
351
343
  style: {
352
- overflow: 'hidden'
353
- }
344
+ overflow: 'hidden',
345
+ height: 1,
346
+ opacity: 0,
347
+ visibility: 'hidden'
348
+ },
349
+ role: "presentation",
350
+ "aria-hidden": "true"
354
351
  }, contentDom, errorDom) : null);
355
352
  };
356
353
  export var ToolContent = /*#__PURE__*/ memo(ToolContentComponent);
@@ -60,7 +60,7 @@ function _unsupported_iterable_to_array(o, minLen) {
60
60
  import classnames from "classnames";
61
61
  import { useMergedState } from "rc-util";
62
62
  import React, { memo, useCallback, useMemo } from "react";
63
- import { ToolContent, ToolExpand, ToolHeaderRight, ToolImage, ToolTime } from "./ToolUseBarItemComponents";
63
+ import { ToolContent, ToolExpand, ToolHeaderRight, ToolImage, ToolTime } from "./Content";
64
64
  var ToolUseBarItemComponent = function(param) {
65
65
  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;
66
66
  // 使用 useMergedState 来管理展开状态
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
- import { ToolCall } from './ToolUseBarItem';
3
- export * from './ToolUseBarItem';
4
- export * from './ToolUseBarThink';
2
+ import { ToolCall } from './BarItem';
3
+ export * from './BarItem';
5
4
  interface ToolUseBarProps {
6
5
  tools?: ToolCall[];
7
6
  onToolClick?: (id: string) => void;
@@ -87,10 +87,9 @@ import { ConfigProvider } from "antd";
87
87
  import classNames from "classnames";
88
88
  import { useMergedState } from "rc-util";
89
89
  import React, { memo, useCallback, useContext, useMemo } from "react";
90
- import { ToolUseBarItem } from "./ToolUseBarItem";
90
+ import { ToolUseBarItem } from "./BarItem";
91
91
  import { useStyle } from "./style";
92
- export * from "./ToolUseBarItem";
93
- export * from "./ToolUseBarThink";
92
+ export * from "./BarItem";
94
93
  /**
95
94
  * ToolUseBar 组件 - 工具使用栏组件
96
95
  *
@@ -87,10 +87,10 @@ function _unsupported_iterable_to_array(o, minLen) {
87
87
  import { Brain, ChevronDown, ChevronsDownUp, ChevronsUpDown } from "@sofa-design/icons";
88
88
  import { ConfigProvider } from "antd";
89
89
  import classNames from "classnames";
90
- import { motion } from "framer-motion";
90
+ import { AnimatePresence, motion } from "framer-motion";
91
91
  import { useMergedState } from "rc-util";
92
- import React, { memo, useCallback, useContext, useEffect } from "react";
93
- import { useStyle } from "./thinkStyle";
92
+ import React, { memo, useCallback, useContext, useEffect, useMemo } from "react";
93
+ import { useStyle } from "./style";
94
94
  var getChevronStyle = function(expanded) {
95
95
  return {
96
96
  transform: expanded ? 'rotate(0deg)' : 'rotate(-90deg)',
@@ -193,22 +193,10 @@ var ExpandButton = function(param) {
193
193
  style: styles === null || styles === void 0 ? void 0 : styles.expand
194
194
  }, expandIcon);
195
195
  };
196
- var getContainerStyle = function(expanded, customStyle) {
197
- return _object_spread({}, expanded ? {} : {
198
- height: 1,
199
- padding: '0 8px',
200
- margin: 0,
201
- overflow: 'hidden',
202
- minHeight: 0,
203
- visibility: 'hidden'
204
- }, customStyle);
205
- };
206
196
  var ThinkContainer = function(param) {
207
197
  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;
208
- if (!thinkContent) return null;
209
198
  var _obj;
210
199
  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));
211
- var containerStyle = getContainerStyle(expandedState, styles === null || styles === void 0 ? void 0 : styles.container);
212
200
  var contentClassName = buildClassName("".concat(prefixCls, "-content"), hashId, customClassNames === null || customClassNames === void 0 ? void 0 : customClassNames.content);
213
201
  var floatingExpandClassName = buildClassName("".concat(prefixCls, "-floating-expand"), hashId, customClassNames === null || customClassNames === void 0 ? void 0 : customClassNames.floatingExpand);
214
202
  var floatingIcon = floatingExpandedState ? /*#__PURE__*/ React.createElement(ChevronsDownUp, {
@@ -218,19 +206,72 @@ var ThinkContainer = function(param) {
218
206
  });
219
207
  var floatingText = floatingExpandedState ? '收起' : '展开';
220
208
  var showFloatingExpand = status === 'loading' && !light;
221
- return /*#__PURE__*/ React.createElement("div", {
209
+ // 缓存容器元素
210
+ var contentVariants = useMemo(function() {
211
+ return {
212
+ expanded: {
213
+ height: 'auto',
214
+ opacity: 1
215
+ },
216
+ collapsed: {
217
+ height: 0,
218
+ opacity: 0
219
+ }
220
+ };
221
+ }, []);
222
+ var contentTransition = useMemo(function() {
223
+ return {
224
+ height: {
225
+ duration: 0.26,
226
+ ease: [
227
+ 0.4,
228
+ 0,
229
+ 0.2,
230
+ 1
231
+ ]
232
+ },
233
+ opacity: {
234
+ duration: 0.2,
235
+ ease: 'linear'
236
+ }
237
+ };
238
+ }, []);
239
+ return /*#__PURE__*/ React.createElement(AnimatePresence, {
240
+ initial: false,
241
+ mode: "sync"
242
+ }, expandedState ? /*#__PURE__*/ React.createElement(motion.div, {
243
+ variants: contentVariants,
244
+ initial: "collapsed",
245
+ key: "think-container",
246
+ animate: "expanded",
247
+ exit: "collapsed",
248
+ transition: contentTransition,
222
249
  className: containerClassName,
223
- "data-testid": "tool-use-bar-think-container",
224
- style: containerStyle
250
+ "data-testid": "tool-use-bar-think-container"
251
+ }, /*#__PURE__*/ React.createElement("div", {
252
+ className: contentClassName,
253
+ style: styles === null || styles === void 0 ? void 0 : styles.content
254
+ }, thinkContent), showFloatingExpand ? /*#__PURE__*/ React.createElement("div", {
255
+ className: floatingExpandClassName,
256
+ onClick: onToggleFloatingExpand,
257
+ "data-testid": "tool-use-bar-think-floating-expand",
258
+ style: styles === null || styles === void 0 ? void 0 : styles.floatingExpand
259
+ }, floatingIcon, floatingText) : null) : null, !expandedState ? /*#__PURE__*/ React.createElement("div", {
260
+ style: {
261
+ visibility: 'hidden',
262
+ height: 1,
263
+ overflow: 'hidden',
264
+ opacity: 0
265
+ }
225
266
  }, /*#__PURE__*/ React.createElement("div", {
226
267
  className: contentClassName,
227
268
  style: styles === null || styles === void 0 ? void 0 : styles.content
228
- }, thinkContent), showFloatingExpand && /*#__PURE__*/ React.createElement("div", {
269
+ }, thinkContent), showFloatingExpand ? /*#__PURE__*/ React.createElement("div", {
229
270
  className: floatingExpandClassName,
230
271
  onClick: onToggleFloatingExpand,
231
272
  "data-testid": "tool-use-bar-think-floating-expand",
232
273
  style: styles === null || styles === void 0 ? void 0 : styles.floatingExpand
233
- }, floatingIcon, floatingText));
274
+ }, floatingIcon, floatingText) : null) : null);
234
275
  };
235
276
  /**
236
277
  * ToolUseBarThink 组件
@@ -348,7 +389,7 @@ var ThinkContainer = function(param) {
348
389
  classNames: customClassNames,
349
390
  styles: styles,
350
391
  onToggleExpand: handleToggleExpand
351
- })), /*#__PURE__*/ React.createElement(ThinkContainer, {
392
+ })), thinkContent ? /*#__PURE__*/ React.createElement(ThinkContainer, {
352
393
  thinkContent: thinkContent,
353
394
  expandedState: expandedState,
354
395
  floatingExpandedState: floatingExpandedState,
@@ -359,6 +400,6 @@ var ThinkContainer = function(param) {
359
400
  classNames: customClassNames,
360
401
  styles: styles,
361
402
  onToggleFloatingExpand: handleToggleFloatingExpand
362
- })));
403
+ }) : null));
363
404
  };
364
405
  export var ToolUseBarThink = /*#__PURE__*/ memo(ToolUseBarThinkComponent);
@@ -63,13 +63,12 @@ var genStyle = function(token) {
63
63
  boxShadow: 'var(--shadow-border-base)',
64
64
  minHeight: '20px',
65
65
  width: 'auto',
66
- transition: 'padding 0.2s ease',
67
66
  display: 'flex',
68
67
  alignItems: 'center',
69
68
  flexDirection: 'column',
70
69
  gap: '8px',
71
70
  zIndex: 1,
72
- padding: '2px',
71
+ padding: '4px',
73
72
  paddingRight: '4px',
74
73
  marginBottom: '12px',
75
74
  '*': {
@@ -175,8 +174,7 @@ var genStyle = function(token) {
175
174
  color: 'var(--color-gray-text-disabled)',
176
175
  fontSize: 'var(--font-size-base)',
177
176
  cursor: 'pointer',
178
- borderRadius: '12px',
179
- transition: 'all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1)'
177
+ borderRadius: '12px'
180
178
  },
181
179
  '&-name': {
182
180
  fontWeight: 500,
@@ -208,6 +206,7 @@ var genStyle = function(token) {
208
206
  zIndex: 0,
209
207
  '&-loading': {
210
208
  borderRadius: '50%',
209
+ transition: 'border-radius 0.3s ease-in-out',
211
210
  position: 'relative',
212
211
  '&::after': {
213
212
  content: '""',
@@ -330,7 +329,6 @@ var genStyle = function(token) {
330
329
  backdropFilter: 'blur(8px)',
331
330
  border: '1px solid rgba(0, 19, 41, 0.1)',
332
331
  boxShadow: '0px 2px 8px rgba(0, 19, 41, 0.15)',
333
- transition: 'all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1)',
334
332
  font: 'var(--font-text-body-emphasized-base)',
335
333
  color: 'var(--color-gray-text-default)',
336
334
  padding: '16px 5px',
@@ -228,7 +228,8 @@ import { ConfigProvider, Image, Input, Spin, Typography, message } from "antd";
228
228
  import { Check, ChevronDown as DownIcon, Download as DownloadIcon, Eye as EyeIcon, Locate, ChevronRight as RightIcon, Search, SquareArrowOutUpRight as ShareIcon } from "@sofa-design/icons";
229
229
  import { Empty } from "antd";
230
230
  import classNames from "classnames";
231
- import React, { useContext, useEffect, useRef, useState } from "react";
231
+ import { AnimatePresence, motion } from "framer-motion";
232
+ import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
232
233
  import { ActionIconBox } from "../../Components/ActionIconBox";
233
234
  import { I18nContext } from "../../I18n";
234
235
  import { formatFileSize, formatLastModified } from "../utils";
@@ -581,6 +582,35 @@ var FileGroupComponent = function(param) {
581
582
  var group = param.group, onToggle = param.onToggle, onGroupDownload = param.onGroupDownload, onDownload = param.onDownload, onFileClick = param.onFileClick, onPreview = param.onPreview, onShare = param.onShare, onLocate = param.onLocate, prefixCls = param.prefixCls, hashId = param.hashId, bindDomId = param.bindDomId;
582
583
  var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
583
584
  var finalPrefixCls = prefixCls || getPrefixCls('workspace-file');
585
+ var contentVariants = useMemo(function() {
586
+ return {
587
+ expanded: {
588
+ height: 'auto',
589
+ opacity: 1
590
+ },
591
+ collapsed: {
592
+ height: 0,
593
+ opacity: 0
594
+ }
595
+ };
596
+ }, []);
597
+ var contentTransition = useMemo(function() {
598
+ return {
599
+ height: {
600
+ duration: 0.26,
601
+ ease: [
602
+ 0.4,
603
+ 0,
604
+ 0.2,
605
+ 1
606
+ ]
607
+ },
608
+ opacity: {
609
+ duration: 0.2,
610
+ ease: 'linear'
611
+ }
612
+ };
613
+ }, []);
584
614
  return /*#__PURE__*/ React.createElement("div", {
585
615
  className: classNames("".concat(finalPrefixCls, "-container--group"), hashId)
586
616
  }, /*#__PURE__*/ React.createElement(GroupHeader, {
@@ -589,7 +619,18 @@ var FileGroupComponent = function(param) {
589
619
  onGroupDownload: onGroupDownload,
590
620
  prefixCls: finalPrefixCls,
591
621
  hashId: hashId
592
- }), !group.collapsed && /*#__PURE__*/ React.createElement("div", {
622
+ }), /*#__PURE__*/ React.createElement(AnimatePresence, {
623
+ initial: false
624
+ }, !group.collapsed && /*#__PURE__*/ React.createElement(motion.div, {
625
+ key: "group-content",
626
+ variants: contentVariants,
627
+ initial: "collapsed",
628
+ animate: "expanded",
629
+ exit: "collapsed",
630
+ transition: contentTransition,
631
+ style: {
632
+ overflow: 'hidden'
633
+ },
593
634
  className: classNames("".concat(finalPrefixCls, "-group-content"), hashId)
594
635
  }, group.children.map(function(file) {
595
636
  return /*#__PURE__*/ React.createElement(FileItemComponent, {
@@ -604,7 +645,7 @@ var FileGroupComponent = function(param) {
604
645
  hashId: hashId,
605
646
  bindDomId: !!bindDomId
606
647
  });
607
- })));
648
+ }))));
608
649
  };
609
650
  export var FileComponent = function(param) {
610
651
  var nodes = param.nodes, onGroupDownload = param.onGroupDownload, onDownload = param.onDownload, onShare = param.onShare, onFileClick = param.onFileClick, onLocate = param.onLocate, onToggleGroup = param.onToggleGroup, onPreview = param.onPreview, onBack = param.onBack, resetKey = param.resetKey, markdownEditorProps = param.markdownEditorProps, customActions = param.customActions, actionRef = param.actionRef, loading = param.loading, loadingRender = param.loadingRender, emptyRender = param.emptyRender, keyword = param.keyword, onChange = param.onChange, _param_showSearch = param.showSearch, showSearch = _param_showSearch === void 0 ? false : _param_showSearch, searchPlaceholder = param.searchPlaceholder, _param_bindDomId = param.bindDomId, bindDomId = _param_bindDomId === void 0 ? false : _param_bindDomId;
package/dist/index.d.ts CHANGED
@@ -30,6 +30,7 @@ export * from './MarkdownEditor/editor/store';
30
30
  export * from './MarkdownEditor/editor/utils';
31
31
  export * from './MarkdownEditor/editor/utils/docx/index';
32
32
  export * from './MarkdownEditor/editor/utils/markdownToHtml';
33
+ export * from './ToolUseBarThink';
33
34
  export * from './Types';
34
35
  export { default as Workspace } from './Workspace';
35
36
  export * from './AnswerAlert';
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ export * from "./MarkdownEditor/editor/store";
30
30
  export * from "./MarkdownEditor/editor/utils";
31
31
  export * from "./MarkdownEditor/editor/utils/docx/index";
32
32
  export * from "./MarkdownEditor/editor/utils/markdownToHtml";
33
+ export * from "./ToolUseBarThink";
33
34
  export * from "./Types";
34
35
  export { default as Workspace } from "./Workspace";
35
36
  // HTML to Markdown conversion utilities
package/dist/typing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare module '*.svg';
1
+ declare module '*.svg';
2
2
  declare module '*.webp';
3
3
  declare module 'direction' {
4
4
  function direction(text: string): 'neutral' | 'ltr' | 'rtl';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.24.2",
3
+ "version": "2.24.3",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "prettier": "prettier --write \"{src,docs,test}/**/*.{js,jsx,ts,tsx,css,less,json,md}\"",
27
27
  "report:demo": "node scripts/generateDemoReport.js",
28
28
  "start": "npm run dev",
29
- "test": "echo 'test'",
29
+ "test": "vitest --run",
30
30
  "test:coverage": "vitest --run --coverage",
31
31
  "tsc": "tsc --noEmit"
32
32
  },