@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.
- package/README.zh-CN.md +67 -0
- package/dist/components/base-node/index.d.ts +27 -0
- package/dist/components/base-node/index.js +320 -0
- package/dist/components/base-node/index.less +258 -0
- package/dist/components/branch-title-header/index.d.ts +12 -0
- package/dist/components/branch-title-header/index.js +176 -0
- package/dist/components/branch-title-header/index.less +28 -0
- package/dist/components/check-list-btn/index.d.ts +4 -0
- package/dist/components/check-list-btn/index.js +144 -0
- package/dist/components/check-list-btn/index.less +113 -0
- package/dist/components/code-input/index.d.ts +24 -0
- package/dist/components/code-input/index.js +356 -0
- package/dist/components/code-input/index.less +87 -0
- package/dist/components/condition-item/index.d.ts +13 -0
- package/dist/components/condition-item/index.js +185 -0
- package/dist/components/condition-item/index.less +23 -0
- package/dist/components/custom-connection-line/index.d.ts +4 -0
- package/dist/components/custom-connection-line/index.js +28 -0
- package/dist/components/custom-handle/source-handle.d.ts +10 -0
- package/dist/components/custom-handle/source-handle.js +45 -0
- package/dist/components/custom-handle/target-handle.d.ts +6 -0
- package/dist/components/custom-handle/target-handle.js +21 -0
- package/dist/components/custom-inputs-control/index.d.ts +56 -0
- package/dist/components/custom-inputs-control/index.js +366 -0
- package/dist/components/custom-inputs-control/index.less +28 -0
- package/dist/components/custom-outputs-form/index.d.ts +24 -0
- package/dist/components/custom-outputs-form/index.js +346 -0
- package/dist/components/custom-outputs-form/index.less +51 -0
- package/dist/components/drag-panel/index.d.ts +10 -0
- package/dist/components/drag-panel/index.js +79 -0
- package/dist/components/drag-panel/index.less +23 -0
- package/dist/components/draggable-with-handle/index.d.ts +13 -0
- package/dist/components/draggable-with-handle/index.js +81 -0
- package/dist/components/draggable-with-handle/index.less +23 -0
- package/dist/components/flow-aside/index.d.ts +4 -0
- package/dist/components/flow-aside/index.js +62 -0
- package/dist/components/flow-aside/index.less +84 -0
- package/dist/components/flow-base-edge/index.d.ts +5 -0
- package/dist/components/flow-base-edge/index.js +226 -0
- package/dist/components/flow-base-edge/index.less +28 -0
- package/dist/components/flow-base-edge/linear-gradient-svg.d.ts +21 -0
- package/dist/components/flow-base-edge/linear-gradient-svg.js +32 -0
- package/dist/components/flow-icon/index.d.ts +9 -0
- package/dist/components/flow-icon/index.js +30 -0
- package/dist/components/flow-icon/index.less +20 -0
- package/dist/components/flow-mini-map/index.d.ts +4 -0
- package/dist/components/flow-mini-map/index.js +26 -0
- package/dist/components/flow-mini-map/index.less +22 -0
- package/dist/components/flow-panel/config-panel.d.ts +15 -0
- package/dist/components/flow-panel/config-panel.js +303 -0
- package/dist/components/flow-panel/index.d.ts +7 -0
- package/dist/components/flow-panel/index.js +7 -0
- package/dist/components/flow-panel/index.less +85 -0
- package/dist/components/flow-panel/panel-container.d.ts +12 -0
- package/dist/components/flow-panel/panel-container.js +25 -0
- package/dist/components/flow-tools/add-node-btn.d.ts +3 -0
- package/dist/components/flow-tools/add-node-btn.js +26 -0
- package/dist/components/flow-tools/history-btn.d.ts +3 -0
- package/dist/components/flow-tools/history-btn.js +59 -0
- package/dist/components/flow-tools/index.d.ts +4 -0
- package/dist/components/flow-tools/index.js +29 -0
- package/dist/components/flow-tools/index.less +82 -0
- package/dist/components/flow-tools/layout-btn.d.ts +3 -0
- package/dist/components/flow-tools/layout-btn.js +27 -0
- package/dist/components/flow-tools/mini-map-btn.d.ts +3 -0
- package/dist/components/flow-tools/mini-map-btn.js +32 -0
- package/dist/components/flow-tools/scale-btn.d.ts +3 -0
- package/dist/components/flow-tools/scale-btn.js +101 -0
- package/dist/components/flow-tools/short-key-btn.d.ts +3 -0
- package/dist/components/flow-tools/short-key-btn.js +38 -0
- package/dist/components/flow-tools/short-key-content.d.ts +4 -0
- package/dist/components/flow-tools/short-key-content.js +153 -0
- package/dist/components/flow-tools/short-key-content.less +38 -0
- package/dist/components/flow-tools/touch-mode-btn.d.ts +3 -0
- package/dist/components/flow-tools/touch-mode-btn.js +89 -0
- package/dist/components/input-text-area/index.d.ts +16 -0
- package/dist/components/input-text-area/index.js +74 -0
- package/dist/components/input-text-area/index.less +30 -0
- package/dist/components/judge-form/index.d.ts +13 -0
- package/dist/components/judge-form/index.js +182 -0
- package/dist/components/judge-form/index.less +11 -0
- package/dist/components/node-menu/index.d.ts +35 -0
- package/dist/components/node-menu/index.js +266 -0
- package/dist/components/node-menu/index.less +79 -0
- package/dist/components/node-resizer/index.d.ts +11 -0
- package/dist/components/node-resizer/index.js +46 -0
- package/dist/components/node-resizer/index.less +12 -0
- package/dist/components/node-result-panel/index.d.ts +9 -0
- package/dist/components/node-result-panel/index.js +155 -0
- package/dist/components/node-result-panel/index.less +132 -0
- package/dist/components/node-tree/index.d.ts +4 -0
- package/dist/components/node-tree/index.js +213 -0
- package/dist/components/node-tree/index.less +51 -0
- package/dist/components/output-params-tree/index.d.ts +10 -0
- package/dist/components/output-params-tree/index.js +34 -0
- package/dist/components/output-params-tree/index.less +27 -0
- package/dist/components/script-code-mirror/index.d.ts +14 -0
- package/dist/components/script-code-mirror/index.js +162 -0
- package/dist/components/script-code-mirror/index.less +11 -0
- package/dist/components/script-edit-modal/index.d.ts +30 -0
- package/dist/components/script-edit-modal/index.js +84 -0
- package/dist/components/script-edit-modal/index.less +24 -0
- package/dist/components/select-with-desc/index.d.ts +5 -0
- package/dist/components/select-with-desc/index.js +20 -0
- package/dist/components/select-with-desc/index.less +11 -0
- package/dist/components/task-status/index.d.ts +4 -0
- package/dist/components/task-status/index.js +209 -0
- package/dist/components/task-status/index.less +65 -0
- package/dist/components/var-input-text-area/index.d.ts +17 -0
- package/dist/components/var-input-text-area/index.js +211 -0
- package/dist/components/var-input-text-area/index.less +64 -0
- package/dist/components/var-type-prefix/index.d.ts +17 -0
- package/dist/components/var-type-prefix/index.js +21 -0
- package/dist/components/variable-input/index.d.ts +24 -0
- package/dist/components/variable-input/index.js +163 -0
- package/dist/components/variable-input/index.less +13 -0
- package/dist/components/variable-tree-select/index.d.ts +33 -0
- package/dist/components/variable-tree-select/index.js +160 -0
- package/dist/components/variable-tree-select/index.less +61 -0
- package/dist/constant/index.d.ts +61 -0
- package/dist/constant/index.js +515 -0
- package/dist/flow/animate.css +5 -0
- package/dist/flow/context.d.ts +12 -0
- package/dist/flow/context.js +44 -0
- package/dist/flow/index.d.ts +13 -0
- package/dist/flow/index.js +162 -0
- package/dist/flow/index.less +72 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.js +10 -0
- package/dist/hooks/use-edges-interaction.d.ts +11 -0
- package/dist/hooks/use-edges-interaction.js +125 -0
- package/dist/hooks/use-flow-debug-interaction.d.ts +5 -0
- package/dist/hooks/use-flow-debug-interaction.js +23 -0
- package/dist/hooks/use-flow-interaction.d.ts +12 -0
- package/dist/hooks/use-flow-interaction.js +173 -0
- package/dist/hooks/use-flow-key-press.d.ts +1 -0
- package/dist/hooks/use-flow-key-press.js +32 -0
- package/dist/hooks/use-flow-save.d.ts +5 -0
- package/dist/hooks/use-flow-save.js +47 -0
- package/dist/hooks/use-flow-view-port.d.ts +7 -0
- package/dist/hooks/use-flow-view-port.js +46 -0
- package/dist/hooks/use-history.d.ts +21 -0
- package/dist/hooks/use-history.js +80 -0
- package/dist/hooks/use-nodes-interaction.d.ts +34 -0
- package/dist/hooks/use-nodes-interaction.js +777 -0
- package/dist/hooks/use-nodes-output-params.d.ts +31 -0
- package/dist/hooks/use-nodes-output-params.js +300 -0
- package/dist/hooks/use-nodes-update.d.ts +9 -0
- package/dist/hooks/use-nodes-update.js +38 -0
- package/dist/hooks/use-work-flow.d.ts +4 -0
- package/dist/hooks/use-work-flow.js +21 -0
- package/dist/i18n/i18n.d.ts +62 -0
- package/dist/i18n/i18n.js +111 -0
- package/dist/i18n/index.d.ts +3 -0
- package/dist/i18n/index.js +12 -0
- package/dist/i18n/locales/en-us.json +327 -0
- package/dist/i18n/locales/ja-jp.json +300 -0
- package/dist/i18n/locales/zh-cn.json +327 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +47 -0
- package/dist/index.less +1 -0
- package/dist/store/index.d.ts +70 -0
- package/dist/store/index.js +146 -0
- package/dist/tailwind.css +28 -0
- package/dist/types/work-flow.d.ts +188 -0
- package/dist/types/work-flow.js +1 -0
- package/dist/utils/default-values.d.ts +2 -0
- package/dist/utils/default-values.js +16 -0
- package/dist/utils/index.d.ts +39 -0
- package/dist/utils/index.js +273 -0
- package/dist/utils/unique-id.d.ts +2 -0
- package/dist/utils/unique-id.js +39 -0
- package/dist/utils/work-flow.d.ts +17 -0
- package/dist/utils/work-flow.js +44 -0
- package/package.json +78 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
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; }
|
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
4
|
+
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); }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
9
|
+
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; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import { useStore } from "../../flow/context";
|
|
12
|
+
import $i18n from "../../i18n";
|
|
13
|
+
import { matchVariableFromVarItem } from "../../utils";
|
|
14
|
+
import { SlateEditor } from '@agentscope-ai/design';
|
|
15
|
+
import { useSetState } from 'ahooks';
|
|
16
|
+
import { message, Typography } from 'antd';
|
|
17
|
+
import classNames from 'classnames';
|
|
18
|
+
import React, { forwardRef, memo, useCallback, useImperativeHandle, useRef } from 'react';
|
|
19
|
+
import VariableTreeSelect from "../variable-tree-select";
|
|
20
|
+
import "./index.less";
|
|
21
|
+
var defaultPosition = {
|
|
22
|
+
x: 0,
|
|
23
|
+
y: 0
|
|
24
|
+
};
|
|
25
|
+
var getSelectionPosition = function getSelectionPosition(ele) {
|
|
26
|
+
var selection = window.getSelection();
|
|
27
|
+
if (ele && selection && selection.rangeCount > 0) {
|
|
28
|
+
try {
|
|
29
|
+
var range = selection.getRangeAt(0);
|
|
30
|
+
var rect = range.getClientRects()[0];
|
|
31
|
+
var inputRect = ele.getBoundingClientRect();
|
|
32
|
+
var x = rect.left + rect.width - inputRect.left;
|
|
33
|
+
var y = rect.top + rect.height - inputRect.top;
|
|
34
|
+
return {
|
|
35
|
+
x: x,
|
|
36
|
+
y: y
|
|
37
|
+
};
|
|
38
|
+
} catch (err) {
|
|
39
|
+
return defaultPosition;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
return defaultPosition;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
46
|
+
var variableList = _ref.variableList,
|
|
47
|
+
value = _ref.value,
|
|
48
|
+
onChange = _ref.onChange,
|
|
49
|
+
_ref$maxLength = _ref.maxLength,
|
|
50
|
+
maxLength = _ref$maxLength === void 0 ? 100000 : _ref$maxLength,
|
|
51
|
+
disabled = _ref.disabled,
|
|
52
|
+
placeholder = _ref.placeholder,
|
|
53
|
+
className = _ref.className,
|
|
54
|
+
style = _ref.style;
|
|
55
|
+
var nodeSchemaMap = useStore(function (state) {
|
|
56
|
+
return state.nodeSchemaMap;
|
|
57
|
+
});
|
|
58
|
+
var editorCon = useRef(null);
|
|
59
|
+
var editorRef = useRef(null);
|
|
60
|
+
var _useSetState = useSetState({
|
|
61
|
+
showParams: false,
|
|
62
|
+
position: defaultPosition
|
|
63
|
+
}),
|
|
64
|
+
_useSetState2 = _slicedToArray(_useSetState, 2),
|
|
65
|
+
state = _useSetState2[0],
|
|
66
|
+
setState = _useSetState2[1];
|
|
67
|
+
var checkSlash = useCallback(function (e) {
|
|
68
|
+
switch (e.keyCode) {
|
|
69
|
+
case 8:
|
|
70
|
+
case 27:
|
|
71
|
+
setState({
|
|
72
|
+
showParams: false
|
|
73
|
+
});
|
|
74
|
+
break;
|
|
75
|
+
case 191:
|
|
76
|
+
case 111:
|
|
77
|
+
if (!e.shiftKey) {
|
|
78
|
+
setState({
|
|
79
|
+
showParams: true,
|
|
80
|
+
position: getSelectionPosition(editorCon.current)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}, []);
|
|
86
|
+
var addVarTag = function addVarTag(name) {
|
|
87
|
+
var _editorRef$current;
|
|
88
|
+
if (!editorRef.current) return;
|
|
89
|
+
var text = editorRef.current.getEditorValue() || '';
|
|
90
|
+
if ("".concat(text).concat(name).length > maxLength) {
|
|
91
|
+
message.warning($i18n.get({
|
|
92
|
+
id: 'spark-flow.components.VarInputTextArea.index.maxInputChars',
|
|
93
|
+
dm: '最多可输入{var1}字'
|
|
94
|
+
}, {
|
|
95
|
+
var1: maxLength
|
|
96
|
+
}));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
var nameMatch = name.match(/\${([^}]+)}/);
|
|
100
|
+
var code = nameMatch ? nameMatch[1] : name;
|
|
101
|
+
(_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 || _editorRef$current._insertNodes({
|
|
102
|
+
type: 'var',
|
|
103
|
+
label: name,
|
|
104
|
+
code: code,
|
|
105
|
+
children: [{
|
|
106
|
+
text: ''
|
|
107
|
+
}]
|
|
108
|
+
}, {
|
|
109
|
+
deletePrefix: true
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
var renderVarLabel = useCallback(function (code) {
|
|
113
|
+
var _nodeSchemaMap$nodeTy;
|
|
114
|
+
var finalValue = code.replace(/[\[\]]/g, '');
|
|
115
|
+
var list = finalValue.split('.');
|
|
116
|
+
if (!list.length) return /*#__PURE__*/React.createElement(React.Fragment, null, $i18n.get({
|
|
117
|
+
id: 'spark-flow.components.VarInputTextArea.index.invalidVariable',
|
|
118
|
+
dm: '无效变量'
|
|
119
|
+
}));
|
|
120
|
+
var nodeId = list[0];
|
|
121
|
+
var nodeLabel = '';
|
|
122
|
+
var nodeType = '';
|
|
123
|
+
var variableKey = list[list.length - 1];
|
|
124
|
+
if (['sys', 'conversation'].includes(nodeId)) {
|
|
125
|
+
nodeLabel = nodeId === 'sys' ? $i18n.get({
|
|
126
|
+
id: 'spark-flow.components.VarInputTextArea.index.builtinVariable',
|
|
127
|
+
dm: '内置变量'
|
|
128
|
+
}) : $i18n.get({
|
|
129
|
+
id: 'spark-flow.components.VarInputTextArea.index.conversationVariable',
|
|
130
|
+
dm: '会话变量'
|
|
131
|
+
});
|
|
132
|
+
nodeType = nodeId;
|
|
133
|
+
} else {
|
|
134
|
+
var targetNode = variableList === null || variableList === void 0 ? void 0 : variableList.find(function (node) {
|
|
135
|
+
return node.nodeId === nodeId;
|
|
136
|
+
});
|
|
137
|
+
if (!targetNode) return /*#__PURE__*/React.createElement(React.Fragment, null, $i18n.get({
|
|
138
|
+
id: 'spark-flow.components.VarInputTextArea.index.invalidVariable',
|
|
139
|
+
dm: '无效变量'
|
|
140
|
+
}));
|
|
141
|
+
var targetVar = matchVariableFromVarItem("${".concat(code, "}"), targetNode.children || []);
|
|
142
|
+
if (!targetVar) return /*#__PURE__*/React.createElement(React.Fragment, null, $i18n.get({
|
|
143
|
+
id: 'spark-flow.components.VarInputTextArea.index.invalidVariable',
|
|
144
|
+
dm: '无效变量'
|
|
145
|
+
}));
|
|
146
|
+
nodeLabel = targetNode.label;
|
|
147
|
+
nodeType = targetNode.nodeType;
|
|
148
|
+
}
|
|
149
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
150
|
+
className: "inline-flex gap-[2px] spark-flow-var-input-var-tag"
|
|
151
|
+
}, (_nodeSchemaMap$nodeTy = nodeSchemaMap[nodeType]) === null || _nodeSchemaMap$nodeTy === void 0 ? void 0 : _nodeSchemaMap$nodeTy.iconType({
|
|
152
|
+
className: 'spark-flow-var-input-var-tag-icon',
|
|
153
|
+
size: 16
|
|
154
|
+
}), /*#__PURE__*/React.createElement(Typography.Text, {
|
|
155
|
+
ellipsis: {
|
|
156
|
+
tooltip: true
|
|
157
|
+
},
|
|
158
|
+
className: "spark-flow-var-input-var-tag-label"
|
|
159
|
+
}, nodeLabel), /*#__PURE__*/React.createElement(Typography.Text, {
|
|
160
|
+
ellipsis: {
|
|
161
|
+
tooltip: variableKey
|
|
162
|
+
},
|
|
163
|
+
className: "spark-flow-var-input-var-tag-key"
|
|
164
|
+
}, "/".concat(variableKey)));
|
|
165
|
+
}, [variableList, nodeSchemaMap]);
|
|
166
|
+
useImperativeHandle(ref, function () {
|
|
167
|
+
return {
|
|
168
|
+
setEditorValue: function setEditorValue(value) {
|
|
169
|
+
var _editorRef$current2;
|
|
170
|
+
(_editorRef$current2 = editorRef.current) === null || _editorRef$current2 === void 0 || _editorRef$current2._setEditorContentByStr(value);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
175
|
+
ref: editorCon,
|
|
176
|
+
className: classNames('spark-flow-var-input-text-area relative', _defineProperty({}, 'spark-flow-var-input-text-area-disabled', disabled), className),
|
|
177
|
+
style: style
|
|
178
|
+
}, /*#__PURE__*/React.createElement(SlateEditor, {
|
|
179
|
+
ref: editorRef,
|
|
180
|
+
renderVarLabel: renderVarLabel,
|
|
181
|
+
value: value,
|
|
182
|
+
onChange: onChange,
|
|
183
|
+
disabled: disabled,
|
|
184
|
+
onKeyDown: disabled ? undefined : checkSlash,
|
|
185
|
+
wordLimit: maxLength,
|
|
186
|
+
placeholder: placeholder
|
|
187
|
+
}), state.showParams && /*#__PURE__*/React.createElement(VariableTreeSelect, {
|
|
188
|
+
onChange: function onChange(val) {
|
|
189
|
+
return addVarTag(val.value);
|
|
190
|
+
},
|
|
191
|
+
defaultOpen: true,
|
|
192
|
+
onClose: function onClose() {
|
|
193
|
+
return setState({
|
|
194
|
+
showParams: false
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
options: variableList
|
|
198
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
199
|
+
className: "absolute",
|
|
200
|
+
style: {
|
|
201
|
+
left: state.position.x,
|
|
202
|
+
top: state.position.y,
|
|
203
|
+
width: 200
|
|
204
|
+
}
|
|
205
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
206
|
+
className: "spark-flow-var-input-text-area-footer flex-justify-between"
|
|
207
|
+
}, /*#__PURE__*/React.createElement("span", null, $i18n.get({
|
|
208
|
+
id: 'spark-flow.components.VarInputTextArea.index.insertVariableWithSlash',
|
|
209
|
+
dm: '输入"/"插入变量'
|
|
210
|
+
})), /*#__PURE__*/React.createElement("span", null)));
|
|
211
|
+
}));
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
@import '../../index.less';
|
|
2
|
+
|
|
3
|
+
.spark-flow-var-input-text-area {
|
|
4
|
+
padding: 8px 12px 3px;
|
|
5
|
+
border: 1px solid e('var(--@{ant-prefix}-color-border-secondary)');
|
|
6
|
+
border-radius: 6px;
|
|
7
|
+
min-height: 100px;
|
|
8
|
+
max-height: 240px;
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
gap: 8px;
|
|
12
|
+
background: e('var(--@{ant-prefix}-color-bg-container)');
|
|
13
|
+
|
|
14
|
+
span[data-slate-placeholder="true"] {
|
|
15
|
+
padding-left: 1px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.text-editor {
|
|
19
|
+
flex: 1;
|
|
20
|
+
overflow-y: auto;
|
|
21
|
+
|
|
22
|
+
.text-editor-content {
|
|
23
|
+
gap: 0;
|
|
24
|
+
|
|
25
|
+
div[data-slate-node="element"] {
|
|
26
|
+
line-height: 28px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.spark-editor-var-tag {
|
|
30
|
+
height: 20px;
|
|
31
|
+
line-height: 20px;
|
|
32
|
+
margin: 0 4px;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&-footer {
|
|
38
|
+
font-size: 10px;
|
|
39
|
+
color: e('var(--@{ant-prefix}-color-text-tertiary)');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&.spark-flow-var-input-text-area-disabled {
|
|
43
|
+
cursor: not-allowed;
|
|
44
|
+
background: e('var(--@{ant-prefix}-color-bg-container-disabled)');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.spark-flow-var-input-var-tag {
|
|
49
|
+
height: 100%;
|
|
50
|
+
align-items: center;
|
|
51
|
+
|
|
52
|
+
.spark-flow-var-input-var-tag-icon {
|
|
53
|
+
font-size: 12px !important;
|
|
54
|
+
}
|
|
55
|
+
.spark-flow-var-input-var-tag-key {
|
|
56
|
+
color: e('var(--@{ant-prefix}-color-primary)');
|
|
57
|
+
font-weight: 500;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.spark-flow-var-input-var-tag-label, .spark-flow-var-input-var-tag-key {
|
|
61
|
+
max-width: 148px;
|
|
62
|
+
font-size: 12px;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const typeAbbr: {
|
|
3
|
+
'Array<Object>': string;
|
|
4
|
+
'Array<File>': string;
|
|
5
|
+
'Array<String>': string;
|
|
6
|
+
'Array<Number>': string;
|
|
7
|
+
'Array<Boolean>': string;
|
|
8
|
+
Object: string;
|
|
9
|
+
File: string;
|
|
10
|
+
String: string;
|
|
11
|
+
Number: string;
|
|
12
|
+
Boolean: string;
|
|
13
|
+
};
|
|
14
|
+
declare const _default: React.NamedExoticComponent<{
|
|
15
|
+
prefix?: string | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
export var typeAbbr = {
|
|
3
|
+
'Array<Object>': 'Arr',
|
|
4
|
+
'Array<File>': 'Arr',
|
|
5
|
+
'Array<String>': 'Arr',
|
|
6
|
+
'Array<Number>': 'Arr',
|
|
7
|
+
'Array<Boolean>': 'Arr',
|
|
8
|
+
Object: 'Obj',
|
|
9
|
+
File: 'File',
|
|
10
|
+
String: 'Str',
|
|
11
|
+
Number: 'Num',
|
|
12
|
+
Boolean: 'Bool'
|
|
13
|
+
};
|
|
14
|
+
export default /*#__PURE__*/memo(function VarTypePrefix(props) {
|
|
15
|
+
if (!props.prefix) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
19
|
+
className: "spark-flow-var-type"
|
|
20
|
+
}, typeAbbr[props.prefix]);
|
|
21
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IValueType } from "../../types/work-flow";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import './index.less';
|
|
4
|
+
interface IVariableInputProps {
|
|
5
|
+
value?: string;
|
|
6
|
+
type?: IValueType;
|
|
7
|
+
onChange: (value: {
|
|
8
|
+
value?: string;
|
|
9
|
+
type?: IValueType;
|
|
10
|
+
}) => void;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
isCompact?: boolean;
|
|
14
|
+
prefix?: string;
|
|
15
|
+
variant?: 'borderless';
|
|
16
|
+
enabledTypes?: IValueType[];
|
|
17
|
+
disabledTypes?: IValueType[];
|
|
18
|
+
onErrorChange?: (hasErrors: boolean, errors?: string[]) => void;
|
|
19
|
+
className?: string;
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
}
|
|
22
|
+
export declare const VariableBaseInput: React.MemoExoticComponent<({ value, onChange, type, placeholder, disabled, prefix, variant, isCompact, className, style, onErrorChange, }: IVariableInputProps) => React.JSX.Element | null>;
|
|
23
|
+
declare const _default: React.MemoExoticComponent<({ value, type, onChange, disabled, enabledTypes, disabledTypes, }: IVariableInputProps) => React.JSX.Element>;
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
import $i18n from "../../i18n";
|
|
8
|
+
import { defaultValueMap } from "../../utils/default-values";
|
|
9
|
+
import { Input, InputNumber, Select, Space } from 'antd';
|
|
10
|
+
import React, { memo, useMemo } from 'react';
|
|
11
|
+
import CodeInput from "../code-input";
|
|
12
|
+
import { VariableTypeSelect } from "../custom-outputs-form";
|
|
13
|
+
import VarTypePrefix from "../var-type-prefix";
|
|
14
|
+
import "./index.less";
|
|
15
|
+
export var VariableBaseInput = /*#__PURE__*/memo(function (_ref) {
|
|
16
|
+
var value = _ref.value,
|
|
17
|
+
_onChange = _ref.onChange,
|
|
18
|
+
_ref$type = _ref.type,
|
|
19
|
+
type = _ref$type === void 0 ? 'String' : _ref$type,
|
|
20
|
+
placeholder = _ref.placeholder,
|
|
21
|
+
disabled = _ref.disabled,
|
|
22
|
+
prefix = _ref.prefix,
|
|
23
|
+
variant = _ref.variant,
|
|
24
|
+
isCompact = _ref.isCompact,
|
|
25
|
+
className = _ref.className,
|
|
26
|
+
style = _ref.style,
|
|
27
|
+
onErrorChange = _ref.onErrorChange;
|
|
28
|
+
var renderType = useMemo(function () {
|
|
29
|
+
switch (type) {
|
|
30
|
+
case 'Number':
|
|
31
|
+
return /*#__PURE__*/React.createElement(InputNumber, {
|
|
32
|
+
className: "w-full",
|
|
33
|
+
placeholder: placeholder || $i18n.get({
|
|
34
|
+
id: 'main.components.VariableBaseInput.index.inputValue',
|
|
35
|
+
dm: '输入变量值'
|
|
36
|
+
}),
|
|
37
|
+
stringMode: true,
|
|
38
|
+
prefix: prefix ? /*#__PURE__*/React.createElement(VarTypePrefix, {
|
|
39
|
+
prefix: prefix
|
|
40
|
+
}) : undefined,
|
|
41
|
+
variant: variant,
|
|
42
|
+
disabled: disabled,
|
|
43
|
+
value: value,
|
|
44
|
+
onChange: function onChange(val) {
|
|
45
|
+
return _onChange({
|
|
46
|
+
value: val ? val.toString() : undefined
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
case 'String':
|
|
51
|
+
return /*#__PURE__*/React.createElement(Input, {
|
|
52
|
+
disabled: disabled,
|
|
53
|
+
prefix: prefix ? /*#__PURE__*/React.createElement(VarTypePrefix, {
|
|
54
|
+
prefix: prefix
|
|
55
|
+
}) : undefined,
|
|
56
|
+
variant: variant,
|
|
57
|
+
placeholder: placeholder || $i18n.get({
|
|
58
|
+
id: 'spark-flow.components.VariableInput.index.inputVariableValue',
|
|
59
|
+
dm: '输入变量值'
|
|
60
|
+
}),
|
|
61
|
+
value: value,
|
|
62
|
+
onChange: function onChange(e) {
|
|
63
|
+
return _onChange({
|
|
64
|
+
value: e.target.value
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
case 'Boolean':
|
|
69
|
+
return /*#__PURE__*/React.createElement(Select, {
|
|
70
|
+
disabled: disabled,
|
|
71
|
+
className: "w-full",
|
|
72
|
+
value: value,
|
|
73
|
+
placeholder: $i18n.get({
|
|
74
|
+
id: 'spark-flow.components.VariableInput.index.select',
|
|
75
|
+
dm: '请选择'
|
|
76
|
+
}),
|
|
77
|
+
options: [{
|
|
78
|
+
label: $i18n.get({
|
|
79
|
+
id: 'spark-flow.components.VariableInput.index.yes',
|
|
80
|
+
dm: '是'
|
|
81
|
+
}),
|
|
82
|
+
value: 'true'
|
|
83
|
+
}, {
|
|
84
|
+
label: $i18n.get({
|
|
85
|
+
id: 'spark-flow.components.VariableInput.index.no',
|
|
86
|
+
dm: '否'
|
|
87
|
+
}),
|
|
88
|
+
value: 'false'
|
|
89
|
+
}],
|
|
90
|
+
onChange: function onChange(val) {
|
|
91
|
+
return _onChange({
|
|
92
|
+
value: val
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
variant: variant
|
|
96
|
+
});
|
|
97
|
+
case 'Object':
|
|
98
|
+
case 'Array<Object>':
|
|
99
|
+
case 'Array<String>':
|
|
100
|
+
case 'Array<Number>':
|
|
101
|
+
case 'Array<Boolean>':
|
|
102
|
+
case 'File':
|
|
103
|
+
case 'Array<File>':
|
|
104
|
+
return /*#__PURE__*/React.createElement(CodeInput, {
|
|
105
|
+
style: _objectSpread({
|
|
106
|
+
overflow: 'auto'
|
|
107
|
+
}, style),
|
|
108
|
+
className: className,
|
|
109
|
+
isCompact: isCompact,
|
|
110
|
+
disabled: disabled,
|
|
111
|
+
type: type,
|
|
112
|
+
value: value,
|
|
113
|
+
onChange: function onChange(val) {
|
|
114
|
+
return _onChange({
|
|
115
|
+
value: val
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
onErrorChange: onErrorChange
|
|
119
|
+
});
|
|
120
|
+
default:
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
}, [type, value, _onChange]);
|
|
124
|
+
return renderType;
|
|
125
|
+
});
|
|
126
|
+
var VariableInput = function VariableInput(_ref2) {
|
|
127
|
+
var value = _ref2.value,
|
|
128
|
+
type = _ref2.type,
|
|
129
|
+
onChange = _ref2.onChange,
|
|
130
|
+
disabled = _ref2.disabled,
|
|
131
|
+
enabledTypes = _ref2.enabledTypes,
|
|
132
|
+
_ref2$disabledTypes = _ref2.disabledTypes,
|
|
133
|
+
disabledTypes = _ref2$disabledTypes === void 0 ? ['File', 'Array<File>'] : _ref2$disabledTypes;
|
|
134
|
+
return /*#__PURE__*/React.createElement(Space.Compact, {
|
|
135
|
+
block: true,
|
|
136
|
+
className: "variable-input-container flex-1 w-[1px]"
|
|
137
|
+
}, /*#__PURE__*/React.createElement(VariableTypeSelect, {
|
|
138
|
+
type: type,
|
|
139
|
+
className: "variable-type-select",
|
|
140
|
+
style: {
|
|
141
|
+
width: 70
|
|
142
|
+
},
|
|
143
|
+
disabled: disabled,
|
|
144
|
+
isMini: true,
|
|
145
|
+
enabledTypes: enabledTypes,
|
|
146
|
+
disabledTypes: disabledTypes,
|
|
147
|
+
handleChange: function handleChange(val) {
|
|
148
|
+
return onChange({
|
|
149
|
+
type: val,
|
|
150
|
+
value: defaultValueMap[val]
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
154
|
+
className: "variable-input-content flex-1 w-[1px]"
|
|
155
|
+
}, /*#__PURE__*/React.createElement(VariableBaseInput, {
|
|
156
|
+
disabled: disabled,
|
|
157
|
+
isCompact: true,
|
|
158
|
+
value: value,
|
|
159
|
+
type: type,
|
|
160
|
+
onChange: onChange
|
|
161
|
+
})));
|
|
162
|
+
};
|
|
163
|
+
export default /*#__PURE__*/memo(VariableInput);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
@import '../../index.less';
|
|
2
|
+
.variable-input-container {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: stretch;
|
|
5
|
+
|
|
6
|
+
.@{ant-prefix}-cascader {
|
|
7
|
+
height: auto;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.variable-type-select .@{ant-prefix}-select-selector {
|
|
11
|
+
background-color: e('var(--@{ant-prefix}-color-bg-layout)');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IValueType } from "../../types/work-flow";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import './index.less';
|
|
4
|
+
export interface IVarItem {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
type: IValueType;
|
|
8
|
+
children?: Array<IVarItem>;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface IVarTreeItem {
|
|
12
|
+
label: string;
|
|
13
|
+
nodeId: string;
|
|
14
|
+
nodeType: string;
|
|
15
|
+
children: Array<IVarItem>;
|
|
16
|
+
}
|
|
17
|
+
export interface IVariableTreeSelectProps {
|
|
18
|
+
options?: Array<IVarTreeItem>;
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
defaultOpen?: boolean;
|
|
21
|
+
onChange?: (value: Pick<IVarItem, 'type' | 'value'>) => void;
|
|
22
|
+
onClose?: () => void;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface IVarTreeProps {
|
|
26
|
+
list: IVarItem[];
|
|
27
|
+
}
|
|
28
|
+
export declare const VariableTreeNodeItem: React.MemoExoticComponent<(props: IVarTreeItem & {
|
|
29
|
+
value?: string | undefined;
|
|
30
|
+
onChange?: ((value: Pick<IVarItem, 'type' | 'value'>) => void) | undefined;
|
|
31
|
+
}) => React.JSX.Element>;
|
|
32
|
+
declare const VariableTreeSelect: React.MemoExoticComponent<(props: IVariableTreeSelectProps) => string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined>;
|
|
33
|
+
export default VariableTreeSelect;
|