@ant-design/agentic-ui 2.29.45 → 2.29.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Bubble/AIBubble.js +5 -4
- package/dist/Bubble/UserBubble.js +5 -4
- package/dist/Components/LayoutHeader/types.d.ts +2 -2
- package/dist/MarkdownEditor/editor/plugins/useKeyboard.js +16 -8
- package/dist/MarkdownEditor/editor/tools/JinjaTemplatePanel/index.js +6 -0
- package/dist/MarkdownInputField/MarkdownInputField.js +1 -0
- package/dist/TaskList/TaskList.d.ts +3 -0
- package/dist/TaskList/TaskList.js +210 -0
- package/dist/TaskList/components/StatusIcon.d.ts +9 -0
- package/dist/TaskList/components/StatusIcon.js +23 -0
- package/dist/TaskList/components/TaskListItem.d.ts +12 -0
- package/dist/TaskList/components/TaskListItem.js +68 -0
- package/dist/TaskList/constants.d.ts +24 -0
- package/dist/TaskList/constants.js +38 -0
- package/dist/TaskList/index.d.ts +2 -50
- package/dist/TaskList/index.js +1 -260
- package/dist/TaskList/style.js +66 -9
- package/dist/TaskList/types.d.ts +29 -0
- package/dist/TaskList/types.js +3 -0
- package/dist/ToolUseBar/BarItem/Content.js +127 -4
- package/dist/ToolUseBar/style.js +25 -5
- package/dist/ToolUseBarThink/index.js +80 -10
- package/dist/ToolUseBarThink/style.js +19 -0
- package/package.json +1 -2
package/dist/TaskList/index.js
CHANGED
|
@@ -1,260 +1 @@
|
|
|
1
|
-
|
|
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
|
-
}
|
|
9
|
-
function _array_without_holes(arr) {
|
|
10
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
|
-
}
|
|
12
|
-
function _iterable_to_array(iter) {
|
|
13
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
14
|
-
}
|
|
15
|
-
function _iterable_to_array_limit(arr, i) {
|
|
16
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
17
|
-
if (_i == null) return;
|
|
18
|
-
var _arr = [];
|
|
19
|
-
var _n = true;
|
|
20
|
-
var _d = false;
|
|
21
|
-
var _s, _e;
|
|
22
|
-
try {
|
|
23
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
24
|
-
_arr.push(_s.value);
|
|
25
|
-
if (i && _arr.length === i) break;
|
|
26
|
-
}
|
|
27
|
-
} catch (err) {
|
|
28
|
-
_d = true;
|
|
29
|
-
_e = err;
|
|
30
|
-
} finally{
|
|
31
|
-
try {
|
|
32
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
33
|
-
} finally{
|
|
34
|
-
if (_d) throw _e;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return _arr;
|
|
38
|
-
}
|
|
39
|
-
function _non_iterable_rest() {
|
|
40
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
41
|
-
}
|
|
42
|
-
function _non_iterable_spread() {
|
|
43
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
44
|
-
}
|
|
45
|
-
function _sliced_to_array(arr, i) {
|
|
46
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
47
|
-
}
|
|
48
|
-
function _to_consumable_array(arr) {
|
|
49
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
50
|
-
}
|
|
51
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
52
|
-
if (!o) return;
|
|
53
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
54
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
55
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
56
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
57
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
58
|
-
}
|
|
59
|
-
import { ChevronUp, CircleDashed, SuccessFill, X } from "@sofa-design/icons";
|
|
60
|
-
import { ConfigProvider } from "antd";
|
|
61
|
-
import classNames from "clsx";
|
|
62
|
-
import { AnimatePresence, motion } from "framer-motion";
|
|
63
|
-
import { useMergedState } from "rc-util";
|
|
64
|
-
import React, { memo, useCallback, useContext, useMemo } from "react";
|
|
65
|
-
import { ActionIconBox } from "../Components/ActionIconBox";
|
|
66
|
-
import { Loading } from "../Components/Loading";
|
|
67
|
-
import { useRefFunction } from "../Hooks/useRefFunction";
|
|
68
|
-
import { I18nContext } from "../I18n";
|
|
69
|
-
import { useStyle } from "./style";
|
|
70
|
-
var LOADING_SIZE = 16;
|
|
71
|
-
var buildClassName = function buildClassName() {
|
|
72
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
73
|
-
args[_key] = arguments[_key];
|
|
74
|
-
}
|
|
75
|
-
return classNames.apply(void 0, _to_consumable_array(args));
|
|
76
|
-
};
|
|
77
|
-
var hasTaskContent = function hasTaskContent(content) {
|
|
78
|
-
if (Array.isArray(content)) {
|
|
79
|
-
return content.length > 0;
|
|
80
|
-
}
|
|
81
|
-
return !!content;
|
|
82
|
-
};
|
|
83
|
-
var getArrowRotation = function getArrowRotation(collapsed) {
|
|
84
|
-
return {
|
|
85
|
-
transform: collapsed ? 'rotate(0deg)' : 'rotate(180deg)',
|
|
86
|
-
transition: 'transform 0.3s ease'
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
var StatusIcon = /*#__PURE__*/ memo(function(param) {
|
|
90
|
-
var status = param.status, prefixCls = param.prefixCls, hashId = param.hashId;
|
|
91
|
-
var statusMap = {
|
|
92
|
-
success: /*#__PURE__*/ React.createElement(SuccessFill, null),
|
|
93
|
-
loading: /*#__PURE__*/ React.createElement(Loading, {
|
|
94
|
-
size: LOADING_SIZE
|
|
95
|
-
}),
|
|
96
|
-
pending: /*#__PURE__*/ React.createElement("div", {
|
|
97
|
-
className: buildClassName("".concat(prefixCls, "-status-idle"), hashId)
|
|
98
|
-
}, /*#__PURE__*/ React.createElement(CircleDashed, null)),
|
|
99
|
-
error: /*#__PURE__*/ React.createElement(X, null)
|
|
100
|
-
};
|
|
101
|
-
return /*#__PURE__*/ React.createElement("div", {
|
|
102
|
-
className: buildClassName("".concat(prefixCls, "-status"), "".concat(prefixCls, "-status-").concat(status), hashId),
|
|
103
|
-
"data-testid": "task-list-status-".concat(status)
|
|
104
|
-
}, statusMap[status]);
|
|
105
|
-
});
|
|
106
|
-
StatusIcon.displayName = 'StatusIcon';
|
|
107
|
-
var TaskListItem = /*#__PURE__*/ memo(function(param) {
|
|
108
|
-
var item = param.item, isLast = param.isLast, prefixCls = param.prefixCls, hashId = param.hashId, expandedKeys = param.expandedKeys, onToggle = param.onToggle;
|
|
109
|
-
var locale = useContext(I18nContext).locale;
|
|
110
|
-
var isCollapsed = !expandedKeys.includes(item.key);
|
|
111
|
-
var hasContent = hasTaskContent(item.content);
|
|
112
|
-
// 使用 useCallback 优化切换处理函数
|
|
113
|
-
var handleToggle = useCallback(function() {
|
|
114
|
-
onToggle(item.key);
|
|
115
|
-
}, [
|
|
116
|
-
item.key,
|
|
117
|
-
onToggle
|
|
118
|
-
]);
|
|
119
|
-
var arrowTitle = isCollapsed ? (locale === null || locale === void 0 ? void 0 : locale['taskList.expand']) || '展开' : (locale === null || locale === void 0 ? void 0 : locale['taskList.collapse']) || '收起';
|
|
120
|
-
var contentVariants = useMemo(function() {
|
|
121
|
-
return {
|
|
122
|
-
expanded: {
|
|
123
|
-
height: 'auto',
|
|
124
|
-
opacity: 1
|
|
125
|
-
},
|
|
126
|
-
collapsed: {
|
|
127
|
-
height: 0,
|
|
128
|
-
opacity: 0
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
}, []);
|
|
132
|
-
var contentTransition = useMemo(function() {
|
|
133
|
-
return {
|
|
134
|
-
height: {
|
|
135
|
-
duration: 0.26,
|
|
136
|
-
ease: [
|
|
137
|
-
0.4,
|
|
138
|
-
0,
|
|
139
|
-
0.2,
|
|
140
|
-
1
|
|
141
|
-
]
|
|
142
|
-
},
|
|
143
|
-
opacity: {
|
|
144
|
-
duration: 0.2,
|
|
145
|
-
ease: 'linear'
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
}, []);
|
|
149
|
-
return /*#__PURE__*/ React.createElement("div", {
|
|
150
|
-
key: item.key,
|
|
151
|
-
className: buildClassName("".concat(prefixCls, "-thoughtChainItem"), hashId),
|
|
152
|
-
"data-testid": "task-list-thoughtChainItem"
|
|
153
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
154
|
-
className: buildClassName("".concat(prefixCls, "-left"), hashId),
|
|
155
|
-
onClick: handleToggle,
|
|
156
|
-
"data-testid": "task-list-left"
|
|
157
|
-
}, /*#__PURE__*/ React.createElement(StatusIcon, {
|
|
158
|
-
status: item.status,
|
|
159
|
-
prefixCls: prefixCls,
|
|
160
|
-
hashId: hashId
|
|
161
|
-
}), /*#__PURE__*/ React.createElement("div", {
|
|
162
|
-
className: buildClassName("".concat(prefixCls, "-content-left"), hashId)
|
|
163
|
-
}, !isLast && /*#__PURE__*/ React.createElement("div", {
|
|
164
|
-
className: buildClassName("".concat(prefixCls, "-dash-line"), hashId),
|
|
165
|
-
"data-testid": "task-list-dash-line"
|
|
166
|
-
}))), /*#__PURE__*/ React.createElement("div", {
|
|
167
|
-
className: buildClassName("".concat(prefixCls, "-right"), hashId)
|
|
168
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
169
|
-
className: buildClassName("".concat(prefixCls, "-top"), hashId),
|
|
170
|
-
onClick: handleToggle
|
|
171
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
172
|
-
className: buildClassName("".concat(prefixCls, "-title"), hashId)
|
|
173
|
-
}, item.title), hasContent && /*#__PURE__*/ React.createElement("div", {
|
|
174
|
-
className: buildClassName("".concat(prefixCls, "-arrowContainer"), hashId),
|
|
175
|
-
onClick: handleToggle,
|
|
176
|
-
"data-testid": "task-list-arrowContainer"
|
|
177
|
-
}, /*#__PURE__*/ React.createElement(ActionIconBox, {
|
|
178
|
-
title: arrowTitle,
|
|
179
|
-
iconStyle: getArrowRotation(isCollapsed),
|
|
180
|
-
loading: false,
|
|
181
|
-
onClick: handleToggle
|
|
182
|
-
}, /*#__PURE__*/ React.createElement(ChevronUp, {
|
|
183
|
-
"data-testid": "task-list-arrow"
|
|
184
|
-
})))), /*#__PURE__*/ React.createElement(AnimatePresence, {
|
|
185
|
-
initial: false
|
|
186
|
-
}, !isCollapsed && /*#__PURE__*/ React.createElement(motion.div, {
|
|
187
|
-
key: "task-content",
|
|
188
|
-
variants: contentVariants,
|
|
189
|
-
initial: "collapsed",
|
|
190
|
-
animate: "expanded",
|
|
191
|
-
exit: "collapsed",
|
|
192
|
-
transition: contentTransition,
|
|
193
|
-
className: buildClassName("".concat(prefixCls, "-body"), hashId)
|
|
194
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
195
|
-
className: buildClassName("".concat(prefixCls, "-content"), hashId)
|
|
196
|
-
}, item.content)))));
|
|
197
|
-
});
|
|
198
|
-
TaskListItem.displayName = 'TaskListItem';
|
|
199
|
-
var getDefaultExpandedKeys = function getDefaultExpandedKeys(items, isControlled) {
|
|
200
|
-
return isControlled ? [] : items.map(function(item) {
|
|
201
|
-
return item.key;
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
205
|
-
* TaskList 组件
|
|
206
|
-
*
|
|
207
|
-
* 显示任务列表,支持展开/折叠、状态管理等功能
|
|
208
|
-
* 支持受控和非受控两种模式
|
|
209
|
-
*
|
|
210
|
-
* @example
|
|
211
|
-
* ```tsx
|
|
212
|
-
* // 非受控模式
|
|
213
|
-
* <TaskList
|
|
214
|
-
* items={[
|
|
215
|
-
* { key: 'task1', title: '任务1', content: '内容', status: 'success' }
|
|
216
|
-
* ]}
|
|
217
|
-
* />
|
|
218
|
-
*
|
|
219
|
-
* // 受控模式
|
|
220
|
-
* <TaskList
|
|
221
|
-
* items={tasks}
|
|
222
|
-
* expandedKeys={expandedKeys}
|
|
223
|
-
* onExpandedKeysChange={setExpandedKeys}
|
|
224
|
-
* />
|
|
225
|
-
* ```
|
|
226
|
-
*/ export var TaskList = /*#__PURE__*/ memo(function(param) {
|
|
227
|
-
var items = param.items, className = param.className, expandedKeys = param.expandedKeys, onExpandedKeysChange = param.onExpandedKeysChange;
|
|
228
|
-
var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
|
|
229
|
-
var prefixCls = getPrefixCls('task-list');
|
|
230
|
-
var _useStyle = useStyle(prefixCls), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
|
|
231
|
-
var isControlled = expandedKeys !== undefined;
|
|
232
|
-
var defaultKeys = getDefaultExpandedKeys(items, isControlled);
|
|
233
|
-
var _useMergedState = _sliced_to_array(useMergedState(defaultKeys, {
|
|
234
|
-
value: expandedKeys,
|
|
235
|
-
onChange: onExpandedKeysChange
|
|
236
|
-
}), 2), internalExpandedKeys = _useMergedState[0], setInternalExpandedKeys = _useMergedState[1];
|
|
237
|
-
var handleToggle = useRefFunction(function(key) {
|
|
238
|
-
var currentExpanded = isControlled ? expandedKeys : internalExpandedKeys;
|
|
239
|
-
var newExpandedKeys = currentExpanded.includes(key) ? currentExpanded.filter(function(k) {
|
|
240
|
-
return k !== key;
|
|
241
|
-
}) : _to_consumable_array(currentExpanded).concat([
|
|
242
|
-
key
|
|
243
|
-
]);
|
|
244
|
-
setInternalExpandedKeys(newExpandedKeys);
|
|
245
|
-
});
|
|
246
|
-
return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
247
|
-
className: className
|
|
248
|
-
}, items.map(function(item, index) {
|
|
249
|
-
return /*#__PURE__*/ React.createElement(TaskListItem, {
|
|
250
|
-
key: item.key,
|
|
251
|
-
item: item,
|
|
252
|
-
isLast: index === items.length - 1,
|
|
253
|
-
prefixCls: prefixCls,
|
|
254
|
-
hashId: hashId,
|
|
255
|
-
expandedKeys: internalExpandedKeys,
|
|
256
|
-
onToggle: handleToggle
|
|
257
|
-
});
|
|
258
|
-
})));
|
|
259
|
-
});
|
|
260
|
-
TaskList.displayName = 'TaskList';
|
|
1
|
+
export { TaskList } from "./TaskList";
|
package/dist/TaskList/style.js
CHANGED
|
@@ -52,8 +52,9 @@ function _object_spread_props(target, source) {
|
|
|
52
52
|
}
|
|
53
53
|
import { useEditorStyleRegister } from "../Hooks/useStyle";
|
|
54
54
|
var genStyle = function genStyle(token) {
|
|
55
|
-
var
|
|
56
|
-
|
|
55
|
+
var componentCls = token.componentCls;
|
|
56
|
+
var _obj, _obj1;
|
|
57
|
+
return _define_property({}, componentCls, {
|
|
57
58
|
'&-thoughtChainItem': {
|
|
58
59
|
marginBottom: 4,
|
|
59
60
|
display: 'flex',
|
|
@@ -105,27 +106,27 @@ var genStyle = function genStyle(token) {
|
|
|
105
106
|
marginBottom: 4,
|
|
106
107
|
gap: 4,
|
|
107
108
|
cursor: 'pointer'
|
|
108
|
-
}, _define_property(_obj, "".concat(
|
|
109
|
+
}, _define_property(_obj, "".concat(componentCls, "-titleContainer"), {
|
|
109
110
|
paddingTop: 8,
|
|
110
111
|
display: 'flex',
|
|
111
112
|
alignItems: 'center'
|
|
112
|
-
}), _define_property(_obj, "".concat(
|
|
113
|
+
}), _define_property(_obj, "".concat(componentCls, "-title"), {
|
|
113
114
|
font: 'var(--font-text-h6-base)',
|
|
114
115
|
marginLeft: 12,
|
|
115
116
|
textAlign: 'justify',
|
|
116
117
|
color: 'var(--color-gray-text-default)'
|
|
117
|
-
}), _define_property(_obj, "".concat(
|
|
118
|
+
}), _define_property(_obj, "".concat(componentCls, "-loading"), {
|
|
118
119
|
height: 20,
|
|
119
120
|
display: 'flex',
|
|
120
121
|
alignItems: 'center',
|
|
121
122
|
justifyContent: 'center'
|
|
122
|
-
}), _define_property(_obj, "".concat(
|
|
123
|
+
}), _define_property(_obj, "".concat(componentCls, "-arrowContainer"), {
|
|
123
124
|
height: 20,
|
|
124
125
|
lineHeight: '20px',
|
|
125
126
|
display: 'flex',
|
|
126
127
|
alignItems: 'center',
|
|
127
128
|
justifyContent: 'center'
|
|
128
|
-
}), _define_property(_obj, "".concat(
|
|
129
|
+
}), _define_property(_obj, "".concat(componentCls, "-arrow"), {
|
|
129
130
|
flexShrink: 0,
|
|
130
131
|
width: 16,
|
|
131
132
|
height: 16,
|
|
@@ -133,7 +134,7 @@ var genStyle = function genStyle(token) {
|
|
|
133
134
|
}), _obj),
|
|
134
135
|
'&-body': _define_property({
|
|
135
136
|
display: 'flex'
|
|
136
|
-
}, "".concat(
|
|
137
|
+
}, "".concat(componentCls, "-content"), {
|
|
137
138
|
font: 'var(--font-text-paragraph-sm)',
|
|
138
139
|
marginLeft: 12,
|
|
139
140
|
display: 'flex',
|
|
@@ -141,7 +142,63 @@ var genStyle = function genStyle(token) {
|
|
|
141
142
|
gap: 2,
|
|
142
143
|
letterSpacing: 'var(--letter-spacing-paragraph-sm, normal)',
|
|
143
144
|
color: 'var(--color-gray-text-secondary)'
|
|
144
|
-
})
|
|
145
|
+
}),
|
|
146
|
+
// Simple variant - wrapper
|
|
147
|
+
'&-simple-wrapper': {
|
|
148
|
+
borderRadius: 'var(--radius-control-base, 8px)',
|
|
149
|
+
background: 'var(--color-gray-bg-page-dark, #f5f5f5)',
|
|
150
|
+
boxShadow: 'var(--shadow-control-base, none)',
|
|
151
|
+
overflow: 'hidden'
|
|
152
|
+
},
|
|
153
|
+
// Simple variant - bar
|
|
154
|
+
'&-simple': (_obj1 = {
|
|
155
|
+
display: 'flex',
|
|
156
|
+
alignItems: 'center',
|
|
157
|
+
height: 36,
|
|
158
|
+
padding: '0 12px',
|
|
159
|
+
gap: 8,
|
|
160
|
+
cursor: 'pointer',
|
|
161
|
+
userSelect: 'none',
|
|
162
|
+
transition: 'background 0.2s ease',
|
|
163
|
+
'&:hover': {
|
|
164
|
+
background: 'var(--color-gray-control-fill-active, rgba(0,0,0,0.04))'
|
|
165
|
+
}
|
|
166
|
+
}, _define_property(_obj1, "".concat(componentCls, "-simple-status"), _define_property({
|
|
167
|
+
display: 'flex',
|
|
168
|
+
alignItems: 'center',
|
|
169
|
+
flexShrink: 0
|
|
170
|
+
}, "".concat(componentCls, "-status"), {
|
|
171
|
+
height: 'auto',
|
|
172
|
+
svg: {
|
|
173
|
+
width: 14,
|
|
174
|
+
height: 14
|
|
175
|
+
}
|
|
176
|
+
})), _define_property(_obj1, "".concat(componentCls, "-simple-text"), {
|
|
177
|
+
flex: 1,
|
|
178
|
+
minWidth: 0,
|
|
179
|
+
font: 'var(--font-text-paragraph-base, 14px)',
|
|
180
|
+
letterSpacing: 'var(--letter-spacing-paragraph-base, normal)',
|
|
181
|
+
color: 'var(--color-gray-text-default, rgba(0,3,9,0.85))',
|
|
182
|
+
overflow: 'hidden',
|
|
183
|
+
textOverflow: 'ellipsis',
|
|
184
|
+
whiteSpace: 'nowrap'
|
|
185
|
+
}), _define_property(_obj1, "".concat(componentCls, "-simple-progress"), {
|
|
186
|
+
flexShrink: 0,
|
|
187
|
+
font: 'var(--font-text-paragraph-sm, 12px)',
|
|
188
|
+
color: 'var(--color-gray-text-secondary, rgba(0,3,9,0.45))'
|
|
189
|
+
}), _define_property(_obj1, "".concat(componentCls, "-simple-arrow"), {
|
|
190
|
+
flexShrink: 0,
|
|
191
|
+
display: 'flex',
|
|
192
|
+
alignItems: 'center',
|
|
193
|
+
justifyContent: 'center'
|
|
194
|
+
}), _obj1),
|
|
195
|
+
// Simple variant - expanded content
|
|
196
|
+
'&-simple-content': {
|
|
197
|
+
overflow: 'hidden'
|
|
198
|
+
},
|
|
199
|
+
'&-simple-list': {
|
|
200
|
+
padding: '4px 12px 8px'
|
|
201
|
+
}
|
|
145
202
|
});
|
|
146
203
|
};
|
|
147
204
|
export function useStyle(prefixCls) {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type TaskStatus = 'success' | 'pending' | 'loading' | 'error';
|
|
3
|
+
export interface TaskItem {
|
|
4
|
+
key: string;
|
|
5
|
+
title?: React.ReactNode;
|
|
6
|
+
content: React.ReactNode | React.ReactNode[];
|
|
7
|
+
status: TaskStatus;
|
|
8
|
+
}
|
|
9
|
+
export type TaskListVariant = 'default' | 'simple';
|
|
10
|
+
export interface TaskListProps {
|
|
11
|
+
/** 任务列表数据 */
|
|
12
|
+
items: TaskItem[];
|
|
13
|
+
/** 自定义类名 */
|
|
14
|
+
className?: string;
|
|
15
|
+
/** 受控模式:指定当前展开的任务项 key 数组 */
|
|
16
|
+
expandedKeys?: string[];
|
|
17
|
+
/** 受控模式:展开状态变化时的回调函数 */
|
|
18
|
+
onExpandedKeysChange?: (expandedKeys: string[]) => void;
|
|
19
|
+
/** 组件变体,simple 模式将任务列表收起为紧凑的单行摘要 */
|
|
20
|
+
variant?: TaskListVariant;
|
|
21
|
+
/** simple 模式下摘要条是否展开(受控) */
|
|
22
|
+
open?: boolean;
|
|
23
|
+
/** simple 模式下摘要条展开状态变化回调 */
|
|
24
|
+
onOpenChange?: (open: boolean) => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated @since 2.30.0 请使用 TaskListProps 替代
|
|
28
|
+
*/
|
|
29
|
+
export type ThoughtChainProps = TaskListProps;
|
|
@@ -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
|
-
|
|
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
|
-
},
|
|
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
|
-
},
|
|
514
|
+
}, innerContent) : null, !showContent ? /*#__PURE__*/ React.createElement("div", {
|
|
392
515
|
style: {
|
|
393
516
|
overflow: 'hidden',
|
|
394
517
|
height: 1,
|
package/dist/ToolUseBar/style.js
CHANGED
|
@@ -302,7 +302,12 @@ var genStyle = function genStyle(token) {
|
|
|
302
302
|
},
|
|
303
303
|
'&-tool-container': {
|
|
304
304
|
display: 'flex',
|
|
305
|
+
flexDirection: 'column',
|
|
305
306
|
width: '100%',
|
|
307
|
+
maxHeight: 700,
|
|
308
|
+
overflow: 'hidden',
|
|
309
|
+
overflowY: 'auto',
|
|
310
|
+
position: 'relative',
|
|
306
311
|
paddingInline: 4,
|
|
307
312
|
paddingBottom: 4,
|
|
308
313
|
'&-light': {
|
|
@@ -319,11 +324,26 @@ var genStyle = function genStyle(token) {
|
|
|
319
324
|
fontWeight: 'normal',
|
|
320
325
|
lineHeight: '160%',
|
|
321
326
|
letterSpacing: 'normal',
|
|
322
|
-
color: '#767E8B'
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
+
color: '#767E8B'
|
|
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
|
+
}
|
|
327
347
|
},
|
|
328
348
|
'&-tool-content-error': {
|
|
329
349
|
display: 'flex',
|