@agentscope-ai/flow 0.0.1

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 (176) hide show
  1. package/README.zh-CN.md +67 -0
  2. package/dist/components/base-node/index.d.ts +27 -0
  3. package/dist/components/base-node/index.js +320 -0
  4. package/dist/components/base-node/index.less +258 -0
  5. package/dist/components/branch-title-header/index.d.ts +12 -0
  6. package/dist/components/branch-title-header/index.js +176 -0
  7. package/dist/components/branch-title-header/index.less +28 -0
  8. package/dist/components/check-list-btn/index.d.ts +4 -0
  9. package/dist/components/check-list-btn/index.js +144 -0
  10. package/dist/components/check-list-btn/index.less +113 -0
  11. package/dist/components/code-input/index.d.ts +24 -0
  12. package/dist/components/code-input/index.js +356 -0
  13. package/dist/components/code-input/index.less +87 -0
  14. package/dist/components/condition-item/index.d.ts +13 -0
  15. package/dist/components/condition-item/index.js +185 -0
  16. package/dist/components/condition-item/index.less +23 -0
  17. package/dist/components/custom-connection-line/index.d.ts +4 -0
  18. package/dist/components/custom-connection-line/index.js +28 -0
  19. package/dist/components/custom-handle/source-handle.d.ts +10 -0
  20. package/dist/components/custom-handle/source-handle.js +45 -0
  21. package/dist/components/custom-handle/target-handle.d.ts +6 -0
  22. package/dist/components/custom-handle/target-handle.js +21 -0
  23. package/dist/components/custom-inputs-control/index.d.ts +56 -0
  24. package/dist/components/custom-inputs-control/index.js +366 -0
  25. package/dist/components/custom-inputs-control/index.less +28 -0
  26. package/dist/components/custom-outputs-form/index.d.ts +24 -0
  27. package/dist/components/custom-outputs-form/index.js +346 -0
  28. package/dist/components/custom-outputs-form/index.less +51 -0
  29. package/dist/components/drag-panel/index.d.ts +10 -0
  30. package/dist/components/drag-panel/index.js +79 -0
  31. package/dist/components/drag-panel/index.less +23 -0
  32. package/dist/components/draggable-with-handle/index.d.ts +13 -0
  33. package/dist/components/draggable-with-handle/index.js +81 -0
  34. package/dist/components/draggable-with-handle/index.less +23 -0
  35. package/dist/components/flow-aside/index.d.ts +4 -0
  36. package/dist/components/flow-aside/index.js +62 -0
  37. package/dist/components/flow-aside/index.less +84 -0
  38. package/dist/components/flow-base-edge/index.d.ts +5 -0
  39. package/dist/components/flow-base-edge/index.js +226 -0
  40. package/dist/components/flow-base-edge/index.less +28 -0
  41. package/dist/components/flow-base-edge/linear-gradient-svg.d.ts +21 -0
  42. package/dist/components/flow-base-edge/linear-gradient-svg.js +32 -0
  43. package/dist/components/flow-icon/index.d.ts +9 -0
  44. package/dist/components/flow-icon/index.js +30 -0
  45. package/dist/components/flow-icon/index.less +20 -0
  46. package/dist/components/flow-mini-map/index.d.ts +4 -0
  47. package/dist/components/flow-mini-map/index.js +26 -0
  48. package/dist/components/flow-mini-map/index.less +22 -0
  49. package/dist/components/flow-panel/config-panel.d.ts +15 -0
  50. package/dist/components/flow-panel/config-panel.js +303 -0
  51. package/dist/components/flow-panel/index.d.ts +7 -0
  52. package/dist/components/flow-panel/index.js +7 -0
  53. package/dist/components/flow-panel/index.less +85 -0
  54. package/dist/components/flow-panel/panel-container.d.ts +12 -0
  55. package/dist/components/flow-panel/panel-container.js +25 -0
  56. package/dist/components/flow-tools/add-node-btn.d.ts +3 -0
  57. package/dist/components/flow-tools/add-node-btn.js +26 -0
  58. package/dist/components/flow-tools/history-btn.d.ts +3 -0
  59. package/dist/components/flow-tools/history-btn.js +59 -0
  60. package/dist/components/flow-tools/index.d.ts +4 -0
  61. package/dist/components/flow-tools/index.js +29 -0
  62. package/dist/components/flow-tools/index.less +82 -0
  63. package/dist/components/flow-tools/layout-btn.d.ts +3 -0
  64. package/dist/components/flow-tools/layout-btn.js +27 -0
  65. package/dist/components/flow-tools/mini-map-btn.d.ts +3 -0
  66. package/dist/components/flow-tools/mini-map-btn.js +32 -0
  67. package/dist/components/flow-tools/scale-btn.d.ts +3 -0
  68. package/dist/components/flow-tools/scale-btn.js +101 -0
  69. package/dist/components/flow-tools/short-key-btn.d.ts +3 -0
  70. package/dist/components/flow-tools/short-key-btn.js +38 -0
  71. package/dist/components/flow-tools/short-key-content.d.ts +4 -0
  72. package/dist/components/flow-tools/short-key-content.js +153 -0
  73. package/dist/components/flow-tools/short-key-content.less +38 -0
  74. package/dist/components/flow-tools/touch-mode-btn.d.ts +3 -0
  75. package/dist/components/flow-tools/touch-mode-btn.js +89 -0
  76. package/dist/components/input-text-area/index.d.ts +16 -0
  77. package/dist/components/input-text-area/index.js +74 -0
  78. package/dist/components/input-text-area/index.less +30 -0
  79. package/dist/components/judge-form/index.d.ts +13 -0
  80. package/dist/components/judge-form/index.js +182 -0
  81. package/dist/components/judge-form/index.less +11 -0
  82. package/dist/components/node-menu/index.d.ts +35 -0
  83. package/dist/components/node-menu/index.js +266 -0
  84. package/dist/components/node-menu/index.less +79 -0
  85. package/dist/components/node-resizer/index.d.ts +11 -0
  86. package/dist/components/node-resizer/index.js +46 -0
  87. package/dist/components/node-resizer/index.less +12 -0
  88. package/dist/components/node-result-panel/index.d.ts +9 -0
  89. package/dist/components/node-result-panel/index.js +155 -0
  90. package/dist/components/node-result-panel/index.less +132 -0
  91. package/dist/components/node-tree/index.d.ts +4 -0
  92. package/dist/components/node-tree/index.js +213 -0
  93. package/dist/components/node-tree/index.less +51 -0
  94. package/dist/components/output-params-tree/index.d.ts +10 -0
  95. package/dist/components/output-params-tree/index.js +34 -0
  96. package/dist/components/output-params-tree/index.less +27 -0
  97. package/dist/components/script-code-mirror/index.d.ts +14 -0
  98. package/dist/components/script-code-mirror/index.js +162 -0
  99. package/dist/components/script-code-mirror/index.less +11 -0
  100. package/dist/components/script-edit-modal/index.d.ts +30 -0
  101. package/dist/components/script-edit-modal/index.js +84 -0
  102. package/dist/components/script-edit-modal/index.less +24 -0
  103. package/dist/components/select-with-desc/index.d.ts +5 -0
  104. package/dist/components/select-with-desc/index.js +20 -0
  105. package/dist/components/select-with-desc/index.less +11 -0
  106. package/dist/components/task-status/index.d.ts +4 -0
  107. package/dist/components/task-status/index.js +209 -0
  108. package/dist/components/task-status/index.less +65 -0
  109. package/dist/components/var-input-text-area/index.d.ts +17 -0
  110. package/dist/components/var-input-text-area/index.js +211 -0
  111. package/dist/components/var-input-text-area/index.less +64 -0
  112. package/dist/components/var-type-prefix/index.d.ts +17 -0
  113. package/dist/components/var-type-prefix/index.js +21 -0
  114. package/dist/components/variable-input/index.d.ts +24 -0
  115. package/dist/components/variable-input/index.js +163 -0
  116. package/dist/components/variable-input/index.less +13 -0
  117. package/dist/components/variable-tree-select/index.d.ts +33 -0
  118. package/dist/components/variable-tree-select/index.js +160 -0
  119. package/dist/components/variable-tree-select/index.less +61 -0
  120. package/dist/constant/index.d.ts +61 -0
  121. package/dist/constant/index.js +515 -0
  122. package/dist/flow/animate.css +5 -0
  123. package/dist/flow/context.d.ts +12 -0
  124. package/dist/flow/context.js +44 -0
  125. package/dist/flow/index.d.ts +13 -0
  126. package/dist/flow/index.js +162 -0
  127. package/dist/flow/index.less +72 -0
  128. package/dist/hooks/index.d.ts +10 -0
  129. package/dist/hooks/index.js +10 -0
  130. package/dist/hooks/use-edges-interaction.d.ts +11 -0
  131. package/dist/hooks/use-edges-interaction.js +125 -0
  132. package/dist/hooks/use-flow-debug-interaction.d.ts +5 -0
  133. package/dist/hooks/use-flow-debug-interaction.js +23 -0
  134. package/dist/hooks/use-flow-interaction.d.ts +12 -0
  135. package/dist/hooks/use-flow-interaction.js +173 -0
  136. package/dist/hooks/use-flow-key-press.d.ts +1 -0
  137. package/dist/hooks/use-flow-key-press.js +32 -0
  138. package/dist/hooks/use-flow-save.d.ts +5 -0
  139. package/dist/hooks/use-flow-save.js +47 -0
  140. package/dist/hooks/use-flow-view-port.d.ts +7 -0
  141. package/dist/hooks/use-flow-view-port.js +46 -0
  142. package/dist/hooks/use-history.d.ts +21 -0
  143. package/dist/hooks/use-history.js +80 -0
  144. package/dist/hooks/use-nodes-interaction.d.ts +34 -0
  145. package/dist/hooks/use-nodes-interaction.js +777 -0
  146. package/dist/hooks/use-nodes-output-params.d.ts +31 -0
  147. package/dist/hooks/use-nodes-output-params.js +300 -0
  148. package/dist/hooks/use-nodes-update.d.ts +9 -0
  149. package/dist/hooks/use-nodes-update.js +38 -0
  150. package/dist/hooks/use-work-flow.d.ts +4 -0
  151. package/dist/hooks/use-work-flow.js +21 -0
  152. package/dist/i18n/i18n.d.ts +62 -0
  153. package/dist/i18n/i18n.js +111 -0
  154. package/dist/i18n/index.d.ts +3 -0
  155. package/dist/i18n/index.js +12 -0
  156. package/dist/i18n/locales/en-us.json +327 -0
  157. package/dist/i18n/locales/ja-jp.json +300 -0
  158. package/dist/i18n/locales/zh-cn.json +327 -0
  159. package/dist/index.css +1 -0
  160. package/dist/index.d.ts +47 -0
  161. package/dist/index.js +47 -0
  162. package/dist/index.less +1 -0
  163. package/dist/store/index.d.ts +70 -0
  164. package/dist/store/index.js +146 -0
  165. package/dist/tailwind.css +28 -0
  166. package/dist/types/work-flow.d.ts +188 -0
  167. package/dist/types/work-flow.js +1 -0
  168. package/dist/utils/default-values.d.ts +2 -0
  169. package/dist/utils/default-values.js +16 -0
  170. package/dist/utils/index.d.ts +39 -0
  171. package/dist/utils/index.js +273 -0
  172. package/dist/utils/unique-id.d.ts +2 -0
  173. package/dist/utils/unique-id.js +39 -0
  174. package/dist/utils/work-flow.d.ts +17 -0
  175. package/dist/utils/work-flow.js +44 -0
  176. package/package.json +78 -0
@@ -0,0 +1,67 @@
1
+ # Spark Flow
2
+ ## 项目介绍
3
+ Spark Flow是供给主包`packages/main`的画布编辑基础业务组件,主要技术栈包含React、React Flow、Antd、zustand等。
4
+
5
+ ### 主要功能
6
+ + 节点检查清单列表;
7
+ + 节点管理器;
8
+ + 画布执行状态管理;
9
+ + 支持回退、撤销;
10
+ + 支持全生命周期快速定制业务节点;
11
+ + 支持复杂节点交互;
12
+
13
+ ### 项目主要结构
14
+ ```plain
15
+ spark-flow/
16
+ ├── docs/
17
+ ├── public/ # 静态资源文件
18
+ ├── src/
19
+ │ ├── components/ # 基础组件
20
+ │ ├── constant/ # 可视化工作流编辑器
21
+ │ ├── demos/ # 国际化支持
22
+ │ ├── flow/ # 画布组件主入口
23
+ │ ├── hooks/ # 画布类操作工具库
24
+ │ ├── i18n/ # 国际化
25
+ │ ├── store/ # 全局状态管理
26
+ │ ├── types/ # 类型定义
27
+ | ├── utils/ # 函数工具库
28
+ | ├── index.less/ # less变量定义
29
+ | └── index.ts/ # 项目主入口文件
30
+ └── package.json # 项目配置
31
+ ```
32
+
33
+ #### 节点结构
34
+ ```plain
35
+ [业务节点名]
36
+ ├── node # 画布节点渲染
37
+ ├── panel # 节点配置面板
38
+ └── schema # 节点Schema协议配置
39
+ ```
40
+
41
+ #### 自定义
42
+ + 通过覆盖 `packages/spark-flow/src/index.less` 中的 `@ant-prefix` 可以修改样式文件中的自定义类名和 CSS 变量名前缀;
43
+ + 同时需要在项目中通过 `ConfigProvider` 设置自定义类名和 CSS 变量名前缀:
44
+ ```
45
+ import { ConfigProvider } from '@agentscope-ai/design';
46
+
47
+ <ConfigProvider prefix="efm" prefixCls="efm_ant>
48
+ ...
49
+ </ConfigProvider>
50
+ ```
51
+
52
+ ## 如何开发
53
+ ### 快速启动
54
+ ```shell
55
+ npm run re-install && cd packages/spark-flow && npm start
56
+ ```
57
+
58
+ + **安装依赖** 在根目录执行`npm run re-install`
59
+ + **运行** cd`packages/spark-flow`且执行`npm start`
60
+
61
+ ### 开发
62
+ > [!NOTE]
63
+ > **注意:** 前提是你完成了快速启动的 **安装依赖** 操作
64
+
65
+ + 开发完之后根目录下执行`npm run fresh:flow`能够快速清除主包`packages/main`的依赖;
66
+ + 进入主包`packages/main`执行`npm start`
67
+ + 进行测试 & 验证;
@@ -0,0 +1,27 @@
1
+ import { IWorkFlowNode, IWorkFlowStatus } from "../../types/work-flow";
2
+ import { NodeProps } from '@xyflow/react';
3
+ import React from 'react';
4
+ import './index.less';
5
+ interface IProps extends NodeProps<IWorkFlowNode> {
6
+ children?: React.ReactNode;
7
+ disableShowSourceHandle?: boolean;
8
+ disableShowTargetHandle?: boolean;
9
+ disableShowDebug?: boolean;
10
+ disableAction?: boolean;
11
+ className?: string;
12
+ hasFailBranch?: boolean;
13
+ }
14
+ export declare const NodeStatusIcon: React.MemoExoticComponent<({ status }: {
15
+ status: IWorkFlowStatus;
16
+ }) => React.ReactNode>;
17
+ declare function BaseNode(props: IProps): React.JSX.Element;
18
+ export interface IGroupNodeProps extends NodeProps<IWorkFlowNode> {
19
+ children?: React.ReactNode;
20
+ disableShowSourceHandle?: boolean;
21
+ disableShowTargetHandle?: boolean;
22
+ disableShowDebug?: boolean;
23
+ disableAction?: boolean;
24
+ }
25
+ export declare const GroupNode: React.MemoExoticComponent<(props: IGroupNodeProps) => React.JSX.Element>;
26
+ declare const _default: React.MemoExoticComponent<typeof BaseNode>;
27
+ export default _default;
@@ -0,0 +1,320 @@
1
+ var _excluded = ["children"];
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
5
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
14
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
+ import { useStore } from "../../flow/context";
16
+ import { useNodesInteraction, useNodesReadOnly } from "../../hooks";
17
+ import $i18n from "../../i18n";
18
+ import { copy, Dropdown, Tag, Tooltip } from '@agentscope-ai/design';
19
+ import { SparkCheckCircleFill, SparkCirclePlayLine, SparkCopyLine, SparkDeleteLine, SparkIdLine, SparkLoadingLine, SparkMoreLine, SparkPauseCircleFill, SparkStopCircleLine, SparkWarningCircleFill } from '@agentscope-ai/icons';
20
+ import { Background } from '@xyflow/react';
21
+ import { ConfigProvider, message, Typography } from 'antd';
22
+ import classNames from 'classnames';
23
+ import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
24
+ import SourceHandle from "../custom-handle/source-handle";
25
+ import TargetHandle from "../custom-handle/target-handle";
26
+ import FlowIcon from "../flow-icon";
27
+ import NodeResizer from "../node-resizer";
28
+ import NodeResultPanel from "../node-result-panel";
29
+ import "./index.less";
30
+ export var NodeStatusIcon = /*#__PURE__*/memo(function (_ref) {
31
+ var status = _ref.status;
32
+ var IconType = function IconType() {
33
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
34
+ };
35
+ switch (status) {
36
+ case 'success':
37
+ IconType = function IconType(props) {
38
+ return /*#__PURE__*/React.createElement(SparkCheckCircleFill, props);
39
+ };
40
+ break;
41
+ case 'fail':
42
+ IconType = function IconType(props) {
43
+ return /*#__PURE__*/React.createElement(SparkWarningCircleFill, props);
44
+ };
45
+ break;
46
+ case 'executing':
47
+ IconType = function IconType(props) {
48
+ return /*#__PURE__*/React.createElement(SparkLoadingLine, props);
49
+ };
50
+ break;
51
+ case 'stop':
52
+ IconType = function IconType(props) {
53
+ return /*#__PURE__*/React.createElement(SparkStopCircleLine, props);
54
+ };
55
+ break;
56
+ case 'wait':
57
+ IconType = function IconType(props) {
58
+ return /*#__PURE__*/React.createElement(SparkPauseCircleFill, props);
59
+ };
60
+ break;
61
+ }
62
+ return IconType({
63
+ className: classNames('spark-flow-status-icon', "spark-flow-status-icon-".concat(status))
64
+ });
65
+ });
66
+ function BaseNode(props) {
67
+ var containerRef = useRef(null);
68
+ var taskStore = useStore(function (store) {
69
+ return store.taskStore;
70
+ });
71
+ var showResults = useStore(function (store) {
72
+ return store.showResults;
73
+ });
74
+ var setShowSingleTest = useStore(function (store) {
75
+ return store.setShowSingleTest;
76
+ });
77
+ var setSelectedNode = useStore(function (store) {
78
+ return store.setSelectedNode;
79
+ });
80
+ var nodeSchemaMap = useStore(function (store) {
81
+ return store.nodeSchemaMap;
82
+ });
83
+ var _useNodesInteraction = useNodesInteraction(),
84
+ onNodeDelete = _useNodesInteraction.onNodeDelete,
85
+ onNodeCopy = _useNodesInteraction.onNodeCopy,
86
+ updateParentNodeSize = _useNodesInteraction.updateParentNodeSize,
87
+ handleNodeClickByNodeId = _useNodesInteraction.handleNodeClickByNodeId;
88
+ var _useNodesReadOnly = useNodesReadOnly(),
89
+ nodesReadOnly = _useNodesReadOnly.nodesReadOnly;
90
+ var handleClickOperation = useCallback(function (_ref2) {
91
+ var key = _ref2.key;
92
+ switch (key) {
93
+ case 'copy':
94
+ onNodeCopy(props.id);
95
+ break;
96
+ case 'delete':
97
+ onNodeDelete(props.id);
98
+ break;
99
+ case 'id':
100
+ copy(props.id);
101
+ message.success($i18n.get({
102
+ id: 'spark-flow.components.BaseNode.index.copySuccess',
103
+ dm: '复制成功'
104
+ }));
105
+ break;
106
+ }
107
+ }, [props.id]);
108
+ var nodeResult = useMemo(function () {
109
+ var _taskStore$node_resul;
110
+ if (!taskStore) return null;
111
+ return ((_taskStore$node_resul = taskStore.node_results) === null || _taskStore$node_resul === void 0 ? void 0 : _taskStore$node_resul.find(function (item) {
112
+ return item.node_id === props.id;
113
+ })) || null;
114
+ }, [props.id, taskStore]);
115
+ var actionMenus = useMemo(function () {
116
+ return [{
117
+ label: /*#__PURE__*/React.createElement("div", {
118
+ className: "flex items-center gap-[8px]"
119
+ }, /*#__PURE__*/React.createElement(SparkCopyLine, null), /*#__PURE__*/React.createElement("span", null, $i18n.get({
120
+ id: 'spark-flow.components.BaseNode.index.copy',
121
+ dm: '复制'
122
+ }))),
123
+ key: 'copy'
124
+ }, {
125
+ label: /*#__PURE__*/React.createElement("div", {
126
+ className: "flex items-center gap-[8px]"
127
+ }, /*#__PURE__*/React.createElement(SparkDeleteLine, null), /*#__PURE__*/React.createElement("span", null, $i18n.get({
128
+ id: 'spark-flow.components.BaseNode.index.delete',
129
+ dm: '删除'
130
+ }))),
131
+ key: 'delete',
132
+ danger: true
133
+ }, {
134
+ type: 'divider'
135
+ }, {
136
+ label: /*#__PURE__*/React.createElement("div", {
137
+ className: "flex items-center spark-flow-node-copy-btn gap-[4px]"
138
+ }, /*#__PURE__*/React.createElement(Tag, {
139
+ className: "spark-flow-node-copy-btn-tag",
140
+ icon: /*#__PURE__*/React.createElement(SparkIdLine, null)
141
+ }, props.id), /*#__PURE__*/React.createElement(SparkCopyLine, {
142
+ className: "spark-flow-node-copy-btn-icon"
143
+ })),
144
+ key: 'id'
145
+ }].filter(function (item) {
146
+ if (nodeSchemaMap[props.type].isSystem || nodesReadOnly) return !['copy', 'delete'].includes(item.key) && item.type !== 'divider';
147
+ return true;
148
+ });
149
+ }, [nodeSchemaMap, props.type, nodesReadOnly]);
150
+ var nodeSchemaInfo = useMemo(function () {
151
+ return nodeSchemaMap[props.type];
152
+ }, [nodeSchemaMap, props.type]);
153
+ useEffect(function () {
154
+ if (containerRef.current && !!props.parentId) {
155
+ var resizeObserver = new ResizeObserver(function () {
156
+ updateParentNodeSize(props.parentId);
157
+ });
158
+ resizeObserver.observe(containerRef.current);
159
+ return function () {
160
+ resizeObserver.disconnect();
161
+ };
162
+ }
163
+ }, [props.parentId, updateParentNodeSize]);
164
+ return /*#__PURE__*/React.createElement(ConfigProvider, {
165
+ getPopupContainer: function getPopupContainer() {
166
+ return containerRef.current || document.body;
167
+ }
168
+ }, /*#__PURE__*/React.createElement("div", {
169
+ ref: containerRef,
170
+ className: classNames('spark-flow-node-container', props.className, _defineProperty({}, "spark-flow-node-container-".concat(nodeResult === null || nodeResult === void 0 ? void 0 : nodeResult.node_status), !!nodeResult && showResults))
171
+ }, /*#__PURE__*/React.createElement("div", {
172
+ className: "flex-justify-between"
173
+ }, /*#__PURE__*/React.createElement("div", {
174
+ className: "flex gap-[8px] items-center flex-1"
175
+ }, /*#__PURE__*/React.createElement(FlowIcon, {
176
+ nodeType: props.type
177
+ }), /*#__PURE__*/React.createElement(Typography.Text, {
178
+ ellipsis: {
179
+ tooltip: true
180
+ },
181
+ className: "spark-flow-node-label flex-1 w-1"
182
+ }, props.data.label)), !!nodeResult && showResults ? /*#__PURE__*/React.createElement(NodeStatusIcon, {
183
+ status: nodeResult.node_status
184
+ }) : props.disableAction ? null : /*#__PURE__*/React.createElement("div", {
185
+ onClick: function onClick(e) {
186
+ e.stopPropagation();
187
+ e.preventDefault();
188
+ },
189
+ className: "flex gap-[4px] items-center nodrag"
190
+ }, nodeSchemaInfo.allowSingleTest && !nodesReadOnly && /*#__PURE__*/React.createElement(Tooltip, {
191
+ title: $i18n.get({
192
+ id: 'spark-flow.components.BaseNode.index.debug',
193
+ dm: '调试'
194
+ })
195
+ }, /*#__PURE__*/React.createElement("div", {
196
+ onClick: function onClick() {
197
+ setSelectedNode({
198
+ id: props.id,
199
+ data: props.data,
200
+ type: props.type,
201
+ position: {
202
+ x: 0,
203
+ y: 0
204
+ }
205
+ });
206
+ setShowSingleTest(true);
207
+ },
208
+ className: "spark-flow-operator-icon-with-bg rounded-[6px] size-[24px] cursor-pointer flex-center"
209
+ }, /*#__PURE__*/React.createElement(SparkCirclePlayLine, {
210
+ className: "spark-flow-node-action-btn text-[20px]"
211
+ }))), !!actionMenus.length && /*#__PURE__*/React.createElement(ConfigProvider, {
212
+ theme: {
213
+ components: {
214
+ Dropdown: {
215
+ zIndexPopup: 2005
216
+ }
217
+ }
218
+ }
219
+ }, /*#__PURE__*/React.createElement(Dropdown, {
220
+ placement: "bottomRight",
221
+ trigger: ['click'],
222
+ overlayClassName: "spark-flow-node-dropdown",
223
+ menu: {
224
+ onClick: handleClickOperation,
225
+ items: actionMenus
226
+ }
227
+ }, /*#__PURE__*/React.createElement("div", {
228
+ className: "spark-flow-operator-icon-with-bg rounded-[6px] size-[24px] flex-center cursor-pointer"
229
+ }, /*#__PURE__*/React.createElement(SparkMoreLine, {
230
+ className: "spark-flow-node-action-btn text-[20px]"
231
+ })))))), !!props.data.desc && /*#__PURE__*/React.createElement(Typography.Paragraph, {
232
+ ellipsis: {
233
+ tooltip: props.data.desc,
234
+ rows: 2
235
+ },
236
+ className: "spark-flow-node-desc"
237
+ }, props.data.desc), !props.disableShowSourceHandle && /*#__PURE__*/React.createElement(SourceHandle, {
238
+ nodeType: props.type,
239
+ nodeId: props.id,
240
+ handleId: props.id,
241
+ parentId: props.parentId
242
+ }), !props.disableShowTargetHandle && /*#__PURE__*/React.createElement(TargetHandle, {
243
+ handleId: props.id
244
+ }), props.children, props.hasFailBranch && /*#__PURE__*/React.createElement("div", {
245
+ className: 'spark-flow-judge-branch flex-justify-between items-center'
246
+ }, /*#__PURE__*/React.createElement("span", {
247
+ className: "spark-flow-fail-branch-label"
248
+ }, $i18n.get({
249
+ id: 'spark-flow.components.BaseNode.index.whenError',
250
+ dm: '当异常时'
251
+ })), /*#__PURE__*/React.createElement("span", {
252
+ className: "spark-flow-fail-branch-label-right"
253
+ }, $i18n.get({
254
+ id: 'spark-flow.components.BaseNode.index.errorBranch',
255
+ dm: '异常分支'
256
+ })), /*#__PURE__*/React.createElement(SourceHandle, {
257
+ className: "spark-flow-fail-branch-handle spark-flow-judge-branch-handle",
258
+ nodeType: props.type,
259
+ nodeId: props.id,
260
+ parentId: props.parentId,
261
+ handleId: "".concat(props.id, "_fail")
262
+ })), nodeResult && showResults && /*#__PURE__*/React.createElement(NodeResultPanel, {
263
+ data: nodeResult,
264
+ onNodeClick: handleNodeClickByNodeId
265
+ })));
266
+ }
267
+ export var GroupNode = /*#__PURE__*/memo(function (props) {
268
+ var isDragging = useStore(function (state) {
269
+ return state.isDragging;
270
+ });
271
+ var _useState = useState(false),
272
+ _useState2 = _slicedToArray(_useState, 2),
273
+ hovered = _useState2[0],
274
+ setHovered = _useState2[1];
275
+ var setIsDragging = useStore(function (store) {
276
+ return store.setIsDragging;
277
+ });
278
+ var _useNodesInteraction2 = useNodesInteraction(),
279
+ onAddNewNode = _useNodesInteraction2.onAddNewNode;
280
+ var onDrop = function onDrop(event) {
281
+ setHovered(false);
282
+ setIsDragging(false);
283
+ event.preventDefault();
284
+ event.stopPropagation();
285
+ var type = event.dataTransfer.getData('application/reactflow');
286
+ if (typeof type === 'undefined' || !type) {
287
+ return;
288
+ }
289
+ onAddNewNode({
290
+ type: type,
291
+ parentId: props.id,
292
+ parentNodeType: props.type
293
+ }, {
294
+ x: event.clientX,
295
+ y: event.clientY
296
+ });
297
+ };
298
+ var children = props.children,
299
+ extraProps = _objectWithoutProperties(props, _excluded);
300
+ return /*#__PURE__*/React.createElement(BaseNode, _extends({
301
+ className: classNames('spark-flow-node-container-group', {
302
+ 'spark-flow-node-container-dragging': isDragging,
303
+ 'spark-flow-node-container-hovered': hovered
304
+ })
305
+ }, extraProps), props.children, /*#__PURE__*/React.createElement("div", {
306
+ onDrop: onDrop,
307
+ onDragLeave: function onDragLeave(event) {
308
+ event.preventDefault();
309
+ setHovered(false);
310
+ },
311
+ onDragEnter: function onDragEnter(event) {
312
+ event.preventDefault();
313
+ setHovered(true);
314
+ },
315
+ className: 'spark-flow-group-node-sub-flow relative'
316
+ }, /*#__PURE__*/React.createElement(Background, null)), /*#__PURE__*/React.createElement(NodeResizer, {
317
+ nodeId: props.id
318
+ }));
319
+ });
320
+ export default /*#__PURE__*/memo(BaseNode);
@@ -0,0 +1,258 @@
1
+ @import '../../index.less';
2
+
3
+ .spark-flow-node-container {
4
+ --angle: 0deg;
5
+ border: 1px solid e('var(--@{ant-prefix}-color-border-secondary)');
6
+ background: e('var(--@{ant-prefix}-color-bg-base)');
7
+ display: flex;
8
+ flex-direction: column;
9
+ padding: 16px;
10
+ gap: 12px;
11
+ border-radius: 12px;
12
+ position: relative;
13
+ transition: 0.4s ease-in-out;
14
+ width: auto;
15
+ height: auto;
16
+ min-height: 58px;
17
+
18
+ &.spark-flow-node-container-group {
19
+ min-width: 320px;
20
+ width: 100%;
21
+ height: 100%;
22
+ padding: 16px;
23
+
24
+ .spark-flow-group-node-sub-flow {
25
+ flex: 1;
26
+
27
+ .react-flow__background {
28
+ border-radius: 6px;
29
+ z-index: 1;
30
+ border: 1px solid e('var(--@{ant-prefix}-color-border-secondary)');
31
+ }
32
+ }
33
+
34
+ &.spark-flow-node-container-hovered {
35
+ box-shadow: 0px 2px 8px 0px rgba(38, 36, 76, 0.3);
36
+ border-color: e('var(--@{ant-prefix}-color-primary)');
37
+ }
38
+ }
39
+
40
+ &-success {
41
+ border-color: e('var(--@{ant-prefix}-color-success)');
42
+ }
43
+
44
+ &-fail {
45
+ border-color: e('var(--@{ant-prefix}-color-error)');
46
+ }
47
+
48
+ @keyframes rotate {
49
+ to {
50
+ --angle: 360deg;
51
+ }
52
+ }
53
+
54
+ &.spark-flow-node-container-executing {
55
+ border: 2px solid transparent;
56
+ background:
57
+ linear-gradient(
58
+ e('var(--@{ant-prefix}-color-bg-base)'),
59
+ e('var(--@{ant-prefix}-color-bg-base)')
60
+ )
61
+ padding-box,
62
+ conic-gradient(
63
+ from var(--angle),
64
+ e('var(--@{ant-prefix}-color-primary)') 0deg,
65
+ transparent 90deg,
66
+ transparent 270deg,
67
+ e('var(--@{ant-prefix}-color-primary)') 360deg
68
+ )
69
+ border-box;
70
+ animation: rotate 2s linear infinite;
71
+ }
72
+
73
+ .spark-flow-node-label {
74
+ font-size: 16px;
75
+ font-weight: 600;
76
+ line-height: 24px;
77
+ }
78
+
79
+ .spark-flow-source-handle,
80
+ .spark-flow-target-handle {
81
+ width: 10px;
82
+ height: 10px;
83
+ background: e('var(--@{ant-prefix}-color-bg-base)');
84
+ border: 1px solid e('var(--@{ant-prefix}-color-primary)');
85
+ border-radius: 50%;
86
+ transition-duration: 0.2s;
87
+
88
+ &-add-btn {
89
+ color: e('var(--@{ant-prefix}-color-bg-base)');
90
+ font-size: 16px;
91
+ height: 16px;
92
+ display: none;
93
+ pointer-events: none;
94
+ }
95
+ }
96
+
97
+ .spark-flow-fail-branch-handle {
98
+ border-color: e('var(--@{ant-prefix}-color-orange)');
99
+ }
100
+
101
+ &:hover {
102
+ box-shadow: 0px 4px 36px 0px rgba(60, 52, 197, 0.08);
103
+ .spark-flow-target-handle {
104
+ box-shadow: 0 0 0 2px rgb(105 83 245 / 15%);
105
+ width: 16px;
106
+ height: 16px;
107
+ }
108
+ }
109
+
110
+ .spark-flow-target-handle-full {
111
+ width: 100%;
112
+ height: 100%;
113
+ left: 0;
114
+ top: 0;
115
+ transform: none;
116
+ background: transparent;
117
+ border-radius: 0;
118
+ z-index: 100;
119
+ border: none;
120
+ }
121
+
122
+ .spark-flow-source-handle.spark-flow-source-handle-open,
123
+ &:hover .spark-flow-source-handle {
124
+ background: e('var(--@{ant-prefix}-color-primary)');
125
+ width: 16px;
126
+ height: 16px;
127
+ border-width: 0;
128
+
129
+ .spark-flow-source-handle-add-btn {
130
+ display: block;
131
+ }
132
+ }
133
+
134
+ &:hover .spark-flow-fail-branch-handle,
135
+ .spark-flow-fail-branch-handle.spark-flow-source-handle-open {
136
+ background: e('var(--@{ant-prefix}-color-orange-hover)');
137
+ width: 16px;
138
+ height: 16px;
139
+ border-width: 0;
140
+
141
+ .spark-flow-source-handle-add-btn {
142
+ display: block;
143
+ }
144
+ }
145
+ }
146
+
147
+ .react-flow__node.selected
148
+ .spark-flow-node-container:not(
149
+ .spark-flow-node-container-success,
150
+ .spark-flow-node-container-fail,
151
+ .spark-flow-node-container-executing,
152
+ .spark-flow-node-container-stop,
153
+ .spark-flow-node-container-wait
154
+ ) {
155
+ border-color: e('var(--@{ant-prefix}-color-primary)');
156
+ box-shadow:
157
+ 0 0 0 2px rgb(105 83 245 / 15%),
158
+ 0 4px 36px 0 rgb(60 52 197 / 8%);
159
+ }
160
+
161
+ .react-flow__node:has(div.isDraggingAdd) {
162
+ pointer-events: none !important;
163
+ }
164
+
165
+ .spark-flow-judge-branch {
166
+ color: e('var(--@{ant-prefix}-color-text-secondary)');
167
+ background: e('var(--@{ant-prefix}-color-fill-tertiary)');
168
+ border-radius: 6px;
169
+ padding: 0 8px;
170
+ font-size: 12px;
171
+ line-height: 24px;
172
+ height: 24px;
173
+ position: relative;
174
+
175
+ .spark-flow-judge-branch-handle {
176
+ right: -16px;
177
+ }
178
+
179
+ .spark-flow-fail-branch-label,
180
+ .spark-flow-fail-branch-label-right {
181
+ font-size: 12px;
182
+ line-height: 20px;
183
+ }
184
+
185
+ .spark-flow-fail-branch-label {
186
+ color: e('var(--@{ant-prefix}-color-text-tertiary)');
187
+ }
188
+
189
+ .spark-flow-fail-branch-label-right {
190
+ font-weight: 500;
191
+ color: e('var(--@{ant-prefix}-color-text-secondary)');
192
+ }
193
+ }
194
+
195
+ .spark-flow-node-copy-btn {
196
+ &-icon {
197
+ color: e('var(--@{ant-prefix}-color-text-tertiary)');
198
+ opacity: 0;
199
+ transition: 0.4s ease-in-out;
200
+ }
201
+
202
+ &-tag {
203
+ line-height: 20px;
204
+ font-size: 12px;
205
+ font-weight: 500;
206
+ background: e('var(--@{ant-prefix}-color-mauve-bg)');
207
+ color: e('var(--@{ant-prefix}-color-mauve)');
208
+ padding: 0 4px;
209
+ border-radius: 4px;
210
+ margin: 0;
211
+ align-items: center;
212
+ display: flex;
213
+
214
+ > .anticon + span {
215
+ margin-inline-start: 4px;
216
+ }
217
+ }
218
+ }
219
+
220
+ .spark-flow-node-dropdown {
221
+ .@{ant-prefix}-dropdown-menu-item:hover {
222
+ .spark-flow-node-copy-btn-icon {
223
+ opacity: 1;
224
+ }
225
+ }
226
+ }
227
+
228
+ .spark-flow-status-icon {
229
+ font-size: 20px;
230
+ &-success {
231
+ color: e('var(--@{ant-prefix}-color-success)');
232
+ }
233
+
234
+ &-fail {
235
+ color: e('var(--@{ant-prefix}-color-error)');
236
+ }
237
+
238
+ &-executing {
239
+ color: e('var(--@{ant-prefix}-color-primary)');
240
+ animation: executing-animation 3s linear infinite;
241
+ }
242
+ }
243
+
244
+ @keyframes executing-animation {
245
+ from {
246
+ transform: rotate(0deg);
247
+ }
248
+ to {
249
+ transform: rotate(360deg);
250
+ }
251
+ }
252
+
253
+ .spark-flow-node-desc {
254
+ font-size: 14px;
255
+ line-height: 24px;
256
+ color: e('var(--@{ant-prefix}-color-text-secondary)');
257
+ margin: 0 !important;
258
+ }
@@ -0,0 +1,12 @@
1
+ import { IBranchItem } from "../../types/work-flow";
2
+ import React from 'react';
3
+ import './index.less';
4
+ export interface IBranchTitleHeaderProps {
5
+ data: IBranchItem;
6
+ onChange: (data: Partial<IBranchItem>) => void;
7
+ deleteBranchItem: () => void;
8
+ branches: IBranchItem[];
9
+ disabled?: boolean;
10
+ }
11
+ declare const _default: React.NamedExoticComponent<IBranchTitleHeaderProps>;
12
+ export default _default;