@ant-design/agentic-ui 2.30.30 → 2.30.33

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.
Files changed (95) hide show
  1. package/dist/AILabel/index.d.ts +2 -0
  2. package/dist/AILabel/index.js +4 -2
  3. package/dist/AgentRunBar/Robot.js +0 -1
  4. package/dist/AgentRunBar/index.js +1 -0
  5. package/dist/AgenticLayout/index.js +1 -0
  6. package/dist/AnswerAlert/index.js +1 -0
  7. package/dist/BackTo/ScrollVisibleButton.d.ts +2 -0
  8. package/dist/BackTo/ScrollVisibleButton.js +4 -2
  9. package/dist/Bubble/AIBubble.js +6 -3
  10. package/dist/Bubble/List/PureBubbleList.js +24 -1
  11. package/dist/Bubble/List/index.js +7 -5
  12. package/dist/Bubble/MessagesContent/BubbleExtra.js +4 -2
  13. package/dist/Bubble/style.js +0 -1
  14. package/dist/ChatBootPage/ButtonTab.js +1 -0
  15. package/dist/ChatBootPage/ButtonTabGroup.js +1 -0
  16. package/dist/ChatBootPage/CaseReply.js +1 -0
  17. package/dist/ChatBootPage/Title.js +1 -0
  18. package/dist/ChatLayout/index.js +1 -0
  19. package/dist/Components/ActionIconBox/index.js +8 -8
  20. package/dist/Components/ActionItemBox/ActionItemBox.js +1 -0
  21. package/dist/Components/Button/IconButton/index.js +1 -0
  22. package/dist/Components/Button/SwitchButton/index.js +1 -0
  23. package/dist/Components/Button/ToggleButton/index.js +1 -0
  24. package/dist/Components/GradientText/index.js +1 -0
  25. package/dist/Components/LayoutHeader/index.js +2 -1
  26. package/dist/Components/Loading/Loading.js +2 -0
  27. package/dist/Components/Robot/index.js +1 -0
  28. package/dist/Components/SuggestionList/index.js +1 -0
  29. package/dist/Components/TextAnimate/index.js +1 -0
  30. package/dist/Components/TypingAnimation/index.js +2 -1
  31. package/dist/Components/VisualList/index.js +3 -0
  32. package/dist/Components/lotties/ThreeThinkingLottie/index.d.ts +68 -0
  33. package/dist/Components/lotties/ThreeThinkingLottie/index.js +151 -0
  34. package/dist/Components/lotties/ThreeThinkingLottie/three-thinking.json +130 -0
  35. package/dist/Components/lotties/index.d.ts +1 -0
  36. package/dist/Components/lotties/index.js +1 -0
  37. package/dist/History/index.js +1 -0
  38. package/dist/Hooks/useLanguage.d.ts +1 -0
  39. package/dist/I18n/locales.d.ts +1 -0
  40. package/dist/I18n/locales.js +2 -0
  41. package/dist/MarkdownEditor/BaseMarkdownEditor.js +2 -0
  42. package/dist/MarkdownEditor/editor/parser/parse/parseHtml.js +15 -6
  43. package/dist/MarkdownEditor/style.js +0 -4
  44. package/dist/MarkdownInputField/SendButton/index.d.ts +2 -2
  45. package/dist/MarkdownInputField/SendButton/index.js +44 -26
  46. package/dist/MarkdownInputField/SendButton/sendButtonPalette.d.ts +36 -0
  47. package/dist/MarkdownInputField/SendButton/sendButtonPalette.js +247 -0
  48. package/dist/MarkdownInputField/SendButton/style.js +3 -3
  49. package/dist/MarkdownInputField/style.js +3 -1
  50. package/dist/MarkdownRenderer/AnimationText.js +1 -2
  51. package/dist/MarkdownRenderer/CharacterQueue.js +3 -0
  52. package/dist/MarkdownRenderer/MarkdownRenderer.js +6 -18
  53. package/dist/MarkdownRenderer/markdownReactShared.d.ts +2 -1
  54. package/dist/MarkdownRenderer/markdownReactShared.js +57 -19
  55. package/dist/MarkdownRenderer/streaming/MarkdownBlockPiece.js +14 -10
  56. package/dist/MarkdownRenderer/streaming/fenceTracker.d.ts +7 -0
  57. package/dist/MarkdownRenderer/streaming/fenceTracker.js +28 -0
  58. package/dist/MarkdownRenderer/streaming/lastBlockThrottle.js +3 -1
  59. package/dist/MarkdownRenderer/streaming/useShallowMemo.d.ts +1 -0
  60. package/dist/MarkdownRenderer/streaming/useShallowMemo.js +36 -0
  61. package/dist/MarkdownRenderer/streaming/useStreamingMarkdownReact.js +6 -3
  62. package/dist/MarkdownRenderer/useStreaming.js +43 -41
  63. package/dist/Plugins/chart/components/ChartContainer/ChartContainer.d.ts +13 -3
  64. package/dist/Plugins/chart/components/ChartContainer/ChartContainer.js +19 -4
  65. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.d.ts +2 -0
  66. package/dist/Plugins/chart/hooks/index.d.ts +2 -0
  67. package/dist/Plugins/chart/hooks/index.js +1 -0
  68. package/dist/Plugins/chart/hooks/useDetectTheme.d.ts +46 -0
  69. package/dist/Plugins/chart/hooks/useDetectTheme.js +222 -0
  70. package/dist/Schema/SchemaEditor/index.js +1 -0
  71. package/dist/Schema/SchemaForm/index.js +1 -0
  72. package/dist/TaskList/TaskList.js +45 -16
  73. package/dist/TaskList/components/TaskListItem.js +2 -1
  74. package/dist/TaskList/constants.d.ts +1 -1
  75. package/dist/TaskList/constants.js +9 -4
  76. package/dist/TaskList/style.js +30 -12
  77. package/dist/ThoughtChainList/index.js +1 -0
  78. package/dist/ToolUseBar/index.js +7 -6
  79. package/dist/ToolUseBarThink/index.d.ts +0 -23
  80. package/dist/ToolUseBarThink/index.js +178 -315
  81. package/dist/ToolUseBarThink/style.js +61 -52
  82. package/dist/Types/quicklink.d.ts +1 -1
  83. package/dist/WelcomeMessage/index.js +1 -0
  84. package/dist/Workspace/File/FileTree/FileTreeComponent.d.ts +4 -0
  85. package/dist/Workspace/File/FileTree/FileTreeComponent.js +283 -0
  86. package/dist/Workspace/File/FileTree/index.d.ts +2 -0
  87. package/dist/Workspace/File/FileTree/index.js +1 -0
  88. package/dist/Workspace/File/FileTree/style.d.ts +8 -0
  89. package/dist/Workspace/File/FileTree/style.js +80 -0
  90. package/dist/Workspace/File/index.d.ts +2 -1
  91. package/dist/Workspace/File/index.js +1 -0
  92. package/dist/Workspace/index.d.ts +4 -2
  93. package/dist/Workspace/index.js +73 -36
  94. package/dist/Workspace/types.d.ts +70 -2
  95. package/package.json +2 -1
@@ -51,10 +51,27 @@ function _object_spread_props(target, source) {
51
51
  return target;
52
52
  }
53
53
  import { useEditorStyleRegister } from "../Hooks/useStyle";
54
- var LIGHT_MODE_BACKGROUND = 'rgba(255, 255, 255, 0.65)';
55
54
  var LIGHT_MODE_BACKDROP_FILTER = 'blur(12px)';
56
55
  var genStyle = function genStyle(token) {
57
56
  return _define_property({}, token.componentCls, {
57
+ '@keyframes thinkSpin': {
58
+ from: {
59
+ '--think-rotate': '0deg'
60
+ },
61
+ to: {
62
+ '--think-rotate': '360deg'
63
+ }
64
+ },
65
+ '@keyframes thinkMaskSweep': {
66
+ '0%': {
67
+ maskPosition: '200% 0',
68
+ WebkitMaskPosition: '200% 0'
69
+ },
70
+ '100%': {
71
+ maskPosition: '-100% 0',
72
+ WebkitMaskPosition: '-100% 0'
73
+ }
74
+ },
58
75
  position: 'relative',
59
76
  cursor: 'pointer',
60
77
  borderRadius: 'var(--radius-card-base)',
@@ -92,36 +109,32 @@ var genStyle = function genStyle(token) {
92
109
  boxShadow: 'var(--shadow-border-base)'
93
110
  }
94
111
  },
112
+ '&-loading': {
113
+ boxSizing: 'border-box',
114
+ boxShadow: '0px 0px 1px 0px rgba(0, 19, 41, 0.05),0px 2px 7px 0px rgba(0, 19, 41, 0.05),0px 2px 5px -2px rgba(0, 19, 41, 0.06)',
115
+ '&:hover': {
116
+ boxSizing: 'border-box',
117
+ boxShadow: '0px 0px 1px 0px rgba(0, 19, 41, 0.05),0px 2px 7px 0px rgba(0, 19, 41, 0.05),0px 2px 5px -2px rgba(0, 19, 41, 0.06)'
118
+ }
119
+ },
120
+ '&-success': {
121
+ borderRadius: 'var(--radius-card-base)',
122
+ boxShadow: 'inset 0px 0px 1px 0px rgba(0, 19, 41, 0.15)'
123
+ },
124
+ // Placed after &-success so light mode wins when both classes apply (success + light).
95
125
  '&-light': {
96
126
  boxShadow: 'none',
97
127
  border: 'none',
98
128
  borderRadius: '14px',
99
129
  padding: 4,
100
- background: LIGHT_MODE_BACKGROUND,
101
130
  backdropFilter: LIGHT_MODE_BACKDROP_FILTER,
102
131
  WebkitBackdropFilter: LIGHT_MODE_BACKDROP_FILTER,
103
132
  '&:hover': _define_property({
104
- background: 'none',
105
133
  boxShadow: 'none'
106
134
  }, "".concat(token.componentCls, "-header-left-icon-light"), {
107
135
  color: 'var(--color-gray-text-secondary)'
108
136
  })
109
137
  },
110
- '&-loading': {
111
- background: 'var(--color-gray-bg-card-white)',
112
- boxSizing: 'border-box',
113
- boxShadow: '0px 0px 1px 0px rgba(0, 19, 41, 0.05),0px 2px 7px 0px rgba(0, 19, 41, 0.05),0px 2px 5px -2px rgba(0, 19, 41, 0.06)',
114
- '&:hover': {
115
- background: 'var(--color-gray-bg-card-white)',
116
- boxSizing: 'border-box',
117
- boxShadow: '0px 0px 1px 0px rgba(0, 19, 41, 0.05),0px 2px 7px 0px rgba(0, 19, 41, 0.05),0px 2px 5px -2px rgba(0, 19, 41, 0.06)'
118
- }
119
- },
120
- '&-success': {
121
- borderRadius: 'var(--radius-card-base)',
122
- background: 'var(--color-gray-bg-card-light)',
123
- boxShadow: 'inset 0px 0px 1px 0px rgba(0, 19, 41, 0.15)'
124
- },
125
138
  '&-bar': {
126
139
  borderRadius: 'var(--radius-card-base)',
127
140
  minHeight: '24px',
@@ -143,26 +156,21 @@ var genStyle = function genStyle(token) {
143
156
  gap: 4
144
157
  }
145
158
  },
146
- '&-header-left': {
159
+ '&-header-left-icon': {
160
+ font: 'var(--font-text-body-emphasized-base)',
161
+ color: 'var(--color-gray-text-default)',
162
+ height: 20,
147
163
  display: 'flex',
148
164
  alignItems: 'center',
149
- gap: 4,
150
- '&-icon': {
151
- font: 'var(--font-text-body-emphasized-base)',
152
- color: 'var(--color-gray-text-default)',
153
- height: 20,
154
- display: 'flex',
155
- alignItems: 'center',
156
- justifyContent: 'center',
157
- borderRadius: 'var(--radius-control-sm)',
165
+ justifyContent: 'center',
166
+ borderRadius: 'var(--radius-control-sm)',
167
+ '&:hover': {
168
+ backgroundColor: 'var(--color-gray-control-fill-hover)'
169
+ },
170
+ '&-light': {
171
+ color: 'var(--color-gray-text-light)',
158
172
  '&:hover': {
159
- backgroundColor: 'var(--color-gray-control-fill-hover)'
160
- },
161
- '&-light': {
162
- color: 'var(--color-gray-text-light)',
163
- '&:hover': {
164
- color: 'var(--color-gray-text-secondary)'
165
- }
173
+ color: 'var(--color-gray-text-secondary)'
166
174
  }
167
175
  }
168
176
  },
@@ -197,39 +205,33 @@ var genStyle = function genStyle(token) {
197
205
  justifyContent: 'center',
198
206
  alignItems: 'center',
199
207
  padding: '4px',
200
- gap: '0px 8px',
201
- flexWrap: 'wrap',
202
- alignContent: 'center',
203
208
  borderRadius: '200px',
204
209
  boxSizing: 'border-box',
205
210
  boxShadow: 'var(--shadow-border-base)',
206
211
  background: 'var(--color-gray-bg-card-white)',
207
212
  zIndex: 0,
213
+ position: 'relative',
214
+ color: '#767E8B',
215
+ fontSize: 'var(--font-size-lg)',
216
+ '& > svg, & > *:first-child': {
217
+ position: 'relative',
218
+ zIndex: 1
219
+ },
208
220
  '&-loading': {
209
221
  borderRadius: '50%',
210
222
  transition: 'border-radius 0.3s ease-in-out',
211
- position: 'relative',
223
+ animation: 'thinkSpin 1s linear infinite',
212
224
  '&::after': {
213
225
  content: '""',
214
226
  position: 'absolute',
215
227
  inset: '0',
216
228
  borderRadius: '50%',
217
- background: 'conic-gradient(from var(--rotate, 0deg),transparent 0deg 0deg, #5EF050 35deg 55deg, #37ABFF 105deg 115deg, #D7B9FF 135deg 135deg, transparent 165deg 360deg)',
229
+ background: 'conic-gradient(from var(--think-rotate, 0deg),transparent 0deg 0deg, #5EF050 35deg 55deg, #37ABFF 105deg 115deg, #D7B9FF 135deg 135deg, transparent 165deg 360deg)',
218
230
  WebkitMask: 'radial-gradient(50% 50% at 50% 50%, rgba(255, 0, 0, 0) 65%, #FF0000 100%)',
219
231
  mask: 'radial-gradient(50% 50% at 50% 50%, rgba(255, 0, 0, 0) 80%, #FF0000 80%, #FF0000 100%)'
220
232
  }
221
233
  }
222
234
  },
223
- '&-image': {
224
- color: '#767E8B',
225
- fontSize: 'var(--font-size-lg)',
226
- position: 'absolute',
227
- zIndex: 999,
228
- borderRadius: '50%',
229
- display: 'flex',
230
- justifyContent: 'center',
231
- alignItems: 'center'
232
- },
233
235
  '&-target': {
234
236
  lineHeight: '20px',
235
237
  flex: 1,
@@ -259,7 +261,6 @@ var genStyle = function genStyle(token) {
259
261
  paddingLeft: 12,
260
262
  marginLeft: 16,
261
263
  marginTop: -10,
262
- background: LIGHT_MODE_BACKGROUND,
263
264
  backdropFilter: LIGHT_MODE_BACKDROP_FILTER,
264
265
  WebkitBackdropFilter: LIGHT_MODE_BACKDROP_FILTER
265
266
  }
@@ -310,7 +311,14 @@ var genStyle = function genStyle(token) {
310
311
  display: 'flex',
311
312
  alignItems: 'center',
312
313
  gap: 8,
313
- flex: 1
314
+ flex: 1,
315
+ '&-loading': {
316
+ maskImage: 'linear-gradient(to right, rgba(0,0,0,1) 0%, rgba(0,0,0,0.15) 50%, rgba(0,0,0,1) 100%)',
317
+ WebkitMaskImage: 'linear-gradient(to right, rgba(0,0,0,1) 0%, rgba(0,0,0,0.15) 50%, rgba(0,0,0,1) 100%)',
318
+ maskSize: '200% 100%',
319
+ WebkitMaskSize: '200% 100%',
320
+ animation: 'thinkMaskSweep 1.5s linear infinite'
321
+ }
314
322
  },
315
323
  '&-content': {
316
324
  font: 'var(--font-text-paragraph-sm)',
@@ -362,6 +370,7 @@ var genStyle = function genStyle(token) {
362
370
  zIndex: 10,
363
371
  transform: 'translateY(100%)',
364
372
  opacity: 0,
373
+ transition: 'transform 0.2s ease, opacity 0.2s ease',
365
374
  '&:hover': {
366
375
  boxShadow: 'var(--shadow-popover-base)'
367
376
  },
@@ -1 +1 @@
1
- declare module 'quicklink';
1
+ declare module 'quicklink';
@@ -121,6 +121,7 @@ import { useStyle } from "./style";
121
121
  var _ref = customStyle || {}, ref = _object_destructuring_empty(_ref), restStyle = _extends({}, _ref);
122
122
  return wrapSSR(/*#__PURE__*/ React.createElement("div", {
123
123
  className: clsx(prefixCls, hashId, rootClassName),
124
+ "data-testid": prefixCls,
124
125
  style: restStyle
125
126
  }, title && /*#__PURE__*/ React.createElement(TypingAnimation, _object_spread_props(_object_spread({
126
127
  as: "div"
@@ -0,0 +1,4 @@
1
+ import { type FC } from 'react';
2
+ import type { FileTreeProps } from '../../types';
3
+ declare const FileTreeComponent: FC<FileTreeProps>;
4
+ export { FileTreeComponent as FileTree };
@@ -0,0 +1,283 @@
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
+ }
9
+ function _define_property(obj, key, value) {
10
+ if (key in obj) {
11
+ Object.defineProperty(obj, key, {
12
+ value: value,
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true
16
+ });
17
+ } else {
18
+ obj[key] = value;
19
+ }
20
+ return obj;
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
+ }
49
+ function _object_spread(target) {
50
+ for(var i = 1; i < arguments.length; i++){
51
+ var source = arguments[i] != null ? arguments[i] : {};
52
+ var ownKeys = Object.keys(source);
53
+ if (typeof Object.getOwnPropertySymbols === "function") {
54
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
55
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
56
+ }));
57
+ }
58
+ ownKeys.forEach(function(key) {
59
+ _define_property(target, key, source[key]);
60
+ });
61
+ }
62
+ return target;
63
+ }
64
+ function ownKeys(object, enumerableOnly) {
65
+ var keys = Object.keys(object);
66
+ if (Object.getOwnPropertySymbols) {
67
+ var symbols = Object.getOwnPropertySymbols(object);
68
+ if (enumerableOnly) {
69
+ symbols = symbols.filter(function(sym) {
70
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
71
+ });
72
+ }
73
+ keys.push.apply(keys, symbols);
74
+ }
75
+ return keys;
76
+ }
77
+ function _object_spread_props(target, source) {
78
+ source = source != null ? source : {};
79
+ if (Object.getOwnPropertyDescriptors) {
80
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
81
+ } else {
82
+ ownKeys(Object(source)).forEach(function(key) {
83
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
84
+ });
85
+ }
86
+ return target;
87
+ }
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 { FileFolders } from "@sofa-design/icons";
100
+ import { ConfigProvider, Empty, Tree } from "antd";
101
+ import classNames from "clsx";
102
+ import React, { useCallback, useContext, useEffect, useMemo, useState } from "react";
103
+ import { useRefFunction } from "../../../Hooks/useRefFunction";
104
+ import { I18nContext } from "../../../I18n";
105
+ import { getFileType } from "../../types";
106
+ import { getFileTypeIcon } from "../utils";
107
+ import { useFileTreeStyle } from "./style";
108
+ var walkAndIndex = function walkAndIndex1(nodes, map) {
109
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
110
+ try {
111
+ for(var _iterator = nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
112
+ var n = _step.value;
113
+ var _n_children;
114
+ map.set(n.key, n);
115
+ if ((_n_children = n.children) === null || _n_children === void 0 ? void 0 : _n_children.length) {
116
+ walkAndIndex(n.children, map);
117
+ }
118
+ }
119
+ } catch (err) {
120
+ _didIteratorError = true;
121
+ _iteratorError = err;
122
+ } finally{
123
+ try {
124
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
125
+ _iterator.return();
126
+ }
127
+ } finally{
128
+ if (_didIteratorError) {
129
+ throw _iteratorError;
130
+ }
131
+ }
132
+ }
133
+ };
134
+ var toDataNode = function toDataNode1(node) {
135
+ var key = node.key, name = node.name, isLeaf = node.isLeaf, disabled = node.disabled, children = node.children;
136
+ var hasChildren = Boolean(children && children.length > 0);
137
+ // `isLeaf: false` = 目录;未传时:有子节点 = 目录,无子节点 = 视为文件(与懒加载目录需显式 `isLeaf: false` 一致)
138
+ var resolvedIsLeaf = isLeaf !== null && isLeaf !== void 0 ? isLeaf : !hasChildren;
139
+ if (resolvedIsLeaf) {
140
+ return {
141
+ key: key,
142
+ title: name,
143
+ isLeaf: true,
144
+ disabled: disabled
145
+ };
146
+ }
147
+ return {
148
+ key: key,
149
+ title: name,
150
+ isLeaf: false,
151
+ disabled: disabled,
152
+ children: hasChildren ? children.map(toDataNode) : []
153
+ };
154
+ };
155
+ var replaceNodeChildren = function replaceNodeChildren1(nodes, key, newChildren) {
156
+ return nodes.map(function(n) {
157
+ var _n_children;
158
+ if (n.key === key) {
159
+ return _object_spread_props(_object_spread({}, n), {
160
+ children: newChildren
161
+ });
162
+ }
163
+ if ((_n_children = n.children) === null || _n_children === void 0 ? void 0 : _n_children.length) {
164
+ return _object_spread_props(_object_spread({}, n), {
165
+ children: replaceNodeChildren(n.children, key, newChildren)
166
+ });
167
+ }
168
+ return n;
169
+ });
170
+ };
171
+ var buildMap = function buildMap(nodes) {
172
+ var m = new Map();
173
+ walkAndIndex(nodes, m);
174
+ return m;
175
+ };
176
+ var FileTreeComponent = function FileTreeComponent(param) {
177
+ var _tab = param.tab, className = param.className, style = param.style, treeData = param.treeData, onLoadChildren = param.onLoadChildren, onSelect = param.onSelect, _param_showLine = param.showLine, showLine = _param_showLine === void 0 ? true : _param_showLine, _resetKey = param.resetKey, emptyRender = param.emptyRender, _param_blockNode = param.blockNode, blockNode = _param_blockNode === void 0 ? true : _param_blockNode;
178
+ var _ref;
179
+ var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
180
+ var locale = useContext(I18nContext).locale;
181
+ var prefixCls = getPrefixCls('workspace-file-tree');
182
+ var _useFileTreeStyle = useFileTreeStyle(prefixCls), wrapSSR = _useFileTreeStyle.wrapSSR, hashId = _useFileTreeStyle.hashId;
183
+ var _useState = _sliced_to_array(useState(treeData), 2), innerTree = _useState[0], setInnerTree = _useState[1];
184
+ var nodeMap = useMemo(function() {
185
+ return buildMap(innerTree);
186
+ }, [
187
+ innerTree
188
+ ]);
189
+ var onLoadChildrenRef = useRefFunction(onLoadChildren);
190
+ useEffect(function() {
191
+ setInnerTree(treeData);
192
+ }, [
193
+ treeData
194
+ ]);
195
+ var dataNodes = useMemo(function() {
196
+ return innerTree.map(toDataNode);
197
+ }, [
198
+ innerTree
199
+ ]);
200
+ var handleLoadData = useCallback(function(treeNode) {
201
+ var k = String(treeNode.key);
202
+ var source = nodeMap.get(k);
203
+ if (!source) {
204
+ return Promise.resolve();
205
+ }
206
+ if (source.isLeaf === true) {
207
+ return Promise.resolve();
208
+ }
209
+ if (source.isLeaf === undefined && (!source.children || source.children.length === 0)) {
210
+ return Promise.resolve();
211
+ }
212
+ if (source.children && source.children.length > 0) {
213
+ return Promise.resolve();
214
+ }
215
+ // 须让 `Promise` 在失败时 reject,以便 rc-tree 不将 key 记为已加载,从而可再次展开重试
216
+ return Promise.resolve(onLoadChildrenRef(source)).then(function(loaded) {
217
+ setInnerTree(function(prev) {
218
+ return replaceNodeChildren(prev, k, loaded);
219
+ });
220
+ });
221
+ }, [
222
+ onLoadChildrenRef,
223
+ nodeMap
224
+ ]);
225
+ var handleSelect = useCallback(function(_keys, info) {
226
+ if (!onSelect) return;
227
+ if (!info.selected) return;
228
+ var k = String(info.node.key);
229
+ var n = nodeMap.get(k);
230
+ if (n) onSelect(n);
231
+ }, [
232
+ nodeMap,
233
+ onSelect
234
+ ]);
235
+ var handleTreeIcon = useCallback(function(iconProps) {
236
+ var k = String(iconProps.eventKey);
237
+ var n = nodeMap.get(k);
238
+ if (n === null || n === void 0 ? void 0 : n.icon) {
239
+ return /*#__PURE__*/ React.createElement("span", {
240
+ className: classNames("".concat(prefixCls, "-icon"), hashId)
241
+ }, n.icon);
242
+ }
243
+ if (iconProps.isLeaf) {
244
+ var _ref;
245
+ var fileName = (_ref = n === null || n === void 0 ? void 0 : n.name) !== null && _ref !== void 0 ? _ref : '';
246
+ var fileType = getFileType(fileName);
247
+ return /*#__PURE__*/ React.createElement("span", {
248
+ className: classNames("".concat(prefixCls, "-icon"), hashId),
249
+ "aria-hidden": true
250
+ }, getFileTypeIcon(fileType, undefined, fileName));
251
+ }
252
+ return /*#__PURE__*/ React.createElement("span", {
253
+ className: classNames("".concat(prefixCls, "-icon"), "".concat(prefixCls, "-icon--folder"), hashId),
254
+ "aria-hidden": true
255
+ }, /*#__PURE__*/ React.createElement(FileFolders, null));
256
+ }, [
257
+ hashId,
258
+ nodeMap,
259
+ prefixCls
260
+ ]);
261
+ var showEmpty = innerTree.length === 0;
262
+ var emptyNode = typeof emptyRender === 'function' ? emptyRender() : emptyRender;
263
+ var defaultEmpty = /*#__PURE__*/ React.createElement(Empty, {
264
+ image: Empty.PRESENTED_IMAGE_SIMPLE,
265
+ description: (_ref = locale === null || locale === void 0 ? void 0 : locale['workspace.empty']) !== null && _ref !== void 0 ? _ref : '暂无数据'
266
+ });
267
+ return wrapSSR(/*#__PURE__*/ React.createElement("div", {
268
+ className: classNames(prefixCls, hashId, className),
269
+ style: style,
270
+ "data-testid": "workspace-file-tree"
271
+ }, showEmpty ? emptyNode !== null && emptyNode !== void 0 ? emptyNode : defaultEmpty : /*#__PURE__*/ React.createElement(Tree, {
272
+ className: classNames("".concat(prefixCls, "-tree"), hashId),
273
+ showLine: showLine,
274
+ showIcon: true,
275
+ blockNode: blockNode,
276
+ loadData: handleLoadData,
277
+ onSelect: handleSelect,
278
+ treeData: dataNodes,
279
+ icon: handleTreeIcon
280
+ })));
281
+ };
282
+ FileTreeComponent.displayName = 'FileTree';
283
+ export { FileTreeComponent as FileTree };
@@ -0,0 +1,2 @@
1
+ export type { FileTreeNode, FileTreeProps } from '../../types';
2
+ export { FileTree } from './FileTreeComponent';
@@ -0,0 +1 @@
1
+ export { FileTree } from "./FileTreeComponent";
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export declare function useFileTreeStyle(prefixCls?: string): {
3
+ hashId: string;
4
+ wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
5
+ } | {
6
+ wrapSSR: (node: any) => any;
7
+ hashId: string;
8
+ };
@@ -0,0 +1,80 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _object_spread(target) {
15
+ for(var i = 1; i < arguments.length; i++){
16
+ var source = arguments[i] != null ? arguments[i] : {};
17
+ var ownKeys = Object.keys(source);
18
+ if (typeof Object.getOwnPropertySymbols === "function") {
19
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
+ }));
22
+ }
23
+ ownKeys.forEach(function(key) {
24
+ _define_property(target, key, source[key]);
25
+ });
26
+ }
27
+ return target;
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
+ }
53
+ import { useEditorStyleRegister } from "../../../Hooks/useStyle";
54
+ var genStyle = function genStyle(token) {
55
+ var componentCls = token.componentCls;
56
+ return _define_property({}, componentCls, _define_property({
57
+ height: '100%',
58
+ minHeight: 0,
59
+ display: 'flex',
60
+ flexDirection: 'column',
61
+ overflow: 'hidden',
62
+ boxSizing: 'border-box',
63
+ padding: 'var(--margin-2x) var(--margin-3x)'
64
+ }, "".concat(componentCls, "-tree"), {
65
+ flex: 1,
66
+ minHeight: 0,
67
+ overflow: 'auto',
68
+ background: 'transparent'
69
+ }));
70
+ };
71
+ export function useFileTreeStyle(prefixCls) {
72
+ return useEditorStyleRegister('WorkspaceFileTree', function(token) {
73
+ var fileTreeToken = _object_spread_props(_object_spread({}, token), {
74
+ componentCls: ".".concat(prefixCls)
75
+ });
76
+ return [
77
+ genStyle(fileTreeToken)
78
+ ];
79
+ });
80
+ }
@@ -1,6 +1,7 @@
1
1
  export { FileComponent as File } from './FileComponent';
2
+ export { FileTree } from './FileTree';
2
3
  export { PreviewComponent } from './PreviewComponent';
3
4
  export type { PreviewComponentProps } from './PreviewComponent';
4
5
  export { getFileTypeName } from '../types';
5
- export type { FileActionRef, FileBuiltinActions, FileNode, FileProps, FileRenderContext, FileType, GroupNode, } from '../types';
6
+ export type { FileActionRef, FileBuiltinActions, FileNode, FileProps, FileRenderContext, FileTreeNode, FileTreeProps, FileType, GroupNode, } from '../types';
6
7
  export { getFileTypeIcon, getGroupIcon } from './utils';
@@ -1,4 +1,5 @@
1
1
  export { FileComponent as File } from "./FileComponent";
2
+ export { FileTree } from "./FileTree";
2
3
  export { PreviewComponent } from "./PreviewComponent";
3
4
  // 导出类型和工具函数
4
5
  export { getFileTypeName } from "../types";
@@ -1,10 +1,11 @@
1
1
  import { FC } from 'react';
2
- import type { BrowserProps, CustomProps, FileProps, RealtimeProps, TaskProps, WorkspaceProps } from './types';
2
+ import type { BrowserProps, CustomProps, FileProps, FileTreeProps, RealtimeProps, TaskProps, WorkspaceProps } from './types';
3
3
  export type { FileActionRef } from './types';
4
4
  declare const RealtimeComponent: FC<RealtimeProps>;
5
5
  declare const BrowserComponent: FC<BrowserProps>;
6
6
  declare const TaskComponent: FC<TaskProps>;
7
7
  declare const FileComponent: FC<FileProps>;
8
+ declare const FileTreeComponent: FC<FileTreeProps>;
8
9
  declare const CustomComponent: FC<CustomProps>;
9
10
  /**
10
11
  * 工作空间组件
@@ -15,9 +16,10 @@ declare const Workspace: FC<WorkspaceProps> & {
15
16
  Browser: typeof BrowserComponent;
16
17
  Task: typeof TaskComponent;
17
18
  File: typeof FileComponent;
19
+ FileTree: typeof FileTreeComponent;
18
20
  Custom: typeof CustomComponent;
19
21
  };
20
22
  export * from './File';
21
23
  export type { HtmlPreviewProps } from './HtmlPreview';
22
- export type { BrowserProps, CustomProps, FileProps, RealtimeProps, TabConfiguration, TabItem, TaskProps, WorkspaceProps, } from './types';
24
+ export type { BrowserProps, CustomProps, FileProps, FileTreeNode, FileTreeProps, RealtimeProps, TabConfiguration, TabItem, TaskProps, WorkspacePanelType, WorkspaceProps, } from './types';
23
25
  export default Workspace;