@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,346 @@
|
|
|
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
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."); }
|
|
4
|
+
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); }
|
|
5
|
+
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; }
|
|
6
|
+
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; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
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); }
|
|
13
|
+
import { FILE_PROPERTIES, VALUE_TYPE_OPTIONS } from "../../constant";
|
|
14
|
+
import $i18n from "../../i18n";
|
|
15
|
+
import { Button, Form, getCommonConfig, Input } from '@agentscope-ai/design';
|
|
16
|
+
import { SparkDeleteLine, SparkPlusLine, SparkUpLine } from '@agentscope-ai/icons';
|
|
17
|
+
import { Cascader } from 'antd';
|
|
18
|
+
import classNames from 'classnames';
|
|
19
|
+
import React, { memo, useEffect, useMemo, useState } from 'react';
|
|
20
|
+
import { typeAbbr } from "../var-type-prefix";
|
|
21
|
+
import "./index.less";
|
|
22
|
+
var _displayRender = function displayRender(labels, isMini) {
|
|
23
|
+
var lastLabel = labels[labels.length - 1];
|
|
24
|
+
if (isMini) {
|
|
25
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
26
|
+
className: "text-[12px]"
|
|
27
|
+
}, typeAbbr[lastLabel]);
|
|
28
|
+
}
|
|
29
|
+
return lastLabel;
|
|
30
|
+
};
|
|
31
|
+
var parseType = function parseType(type) {
|
|
32
|
+
if (!type) return [];
|
|
33
|
+
if (type.includes('Array')) return ['Array', type];
|
|
34
|
+
return [type];
|
|
35
|
+
};
|
|
36
|
+
export var VariableTypeSelect = /*#__PURE__*/memo(function (props) {
|
|
37
|
+
var handleChange = props.handleChange,
|
|
38
|
+
type = props.type,
|
|
39
|
+
_props$style = props.style,
|
|
40
|
+
style = _props$style === void 0 ? {} : _props$style,
|
|
41
|
+
enabledTypes = props.enabledTypes,
|
|
42
|
+
_props$disabledTypes = props.disabledTypes,
|
|
43
|
+
disabledTypes = _props$disabledTypes === void 0 ? [] : _props$disabledTypes;
|
|
44
|
+
var typeOptions = useMemo(function () {
|
|
45
|
+
// 如果既没有白名单也没有黑名单,返回所有选项
|
|
46
|
+
if ((!enabledTypes || !enabledTypes.length) && (!disabledTypes || !disabledTypes.length)) {
|
|
47
|
+
return VALUE_TYPE_OPTIONS;
|
|
48
|
+
}
|
|
49
|
+
var list = [];
|
|
50
|
+
|
|
51
|
+
// 白名单优先:如果设置了enabledTypes,只有在白名单中的类型才可用
|
|
52
|
+
if (enabledTypes && enabledTypes.length > 0) {
|
|
53
|
+
VALUE_TYPE_OPTIONS.forEach(function (item) {
|
|
54
|
+
var _item$children;
|
|
55
|
+
if (!enabledTypes.includes(item.value)) return;
|
|
56
|
+
list.push(_objectSpread(_objectSpread({}, item), {}, {
|
|
57
|
+
children: (_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.filter(function (child) {
|
|
58
|
+
return enabledTypes.includes(child.value);
|
|
59
|
+
})
|
|
60
|
+
}));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// 黑名单策略:如果没有设置enabledTypes,使用disabledTypes
|
|
64
|
+
else if (disabledTypes && disabledTypes.length > 0) {
|
|
65
|
+
VALUE_TYPE_OPTIONS.forEach(function (item) {
|
|
66
|
+
var _item$children2;
|
|
67
|
+
if (disabledTypes.includes(item.value)) return;
|
|
68
|
+
list.push(_objectSpread(_objectSpread({}, item), {}, {
|
|
69
|
+
children: (_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.filter(function (child) {
|
|
70
|
+
return !disabledTypes.includes(child.value);
|
|
71
|
+
})
|
|
72
|
+
}));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return list;
|
|
76
|
+
}, [enabledTypes, disabledTypes]);
|
|
77
|
+
return /*#__PURE__*/React.createElement(Cascader, {
|
|
78
|
+
className: "spark-flow-variable-type-select ".concat(props.className),
|
|
79
|
+
allowClear: false,
|
|
80
|
+
style: _objectSpread({
|
|
81
|
+
width: 140,
|
|
82
|
+
flexShrink: 0
|
|
83
|
+
}, style),
|
|
84
|
+
options: typeOptions,
|
|
85
|
+
placeholder: $i18n.get({
|
|
86
|
+
id: 'spark-flow.components.CustomOutputsForm.index.selectVariableType',
|
|
87
|
+
dm: '请选择变量类型'
|
|
88
|
+
})
|
|
89
|
+
// getPopupContainer={(ele) => ele}
|
|
90
|
+
,
|
|
91
|
+
value: parseType(type),
|
|
92
|
+
onChange: function onChange(selectedList) {
|
|
93
|
+
var type = selectedList[selectedList.length - 1];
|
|
94
|
+
handleChange(type);
|
|
95
|
+
},
|
|
96
|
+
displayRender: function displayRender(payload) {
|
|
97
|
+
return _displayRender(payload, props.isMini);
|
|
98
|
+
},
|
|
99
|
+
disabled: props.disabled
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
var getDisableStatus = function getDisableStatus(index, readyOnly, key) {
|
|
103
|
+
if (readyOnly === undefined || readyOnly === null) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
if (typeof readyOnly === 'boolean') {
|
|
107
|
+
return readyOnly;
|
|
108
|
+
}
|
|
109
|
+
var detail = readyOnly[index];
|
|
110
|
+
if (!detail) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
if (typeof detail === 'boolean') {
|
|
114
|
+
return detail;
|
|
115
|
+
}
|
|
116
|
+
return detail.includes(key || '');
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* 创建变量名验证规则
|
|
121
|
+
* @param allValues 所有变量的值数组,用于检查重复
|
|
122
|
+
* @param currentIndex 当前编辑的变量索引
|
|
123
|
+
*/
|
|
124
|
+
var createVariableNameRules = function createVariableNameRules(allValues, currentIndex) {
|
|
125
|
+
return [{
|
|
126
|
+
validator: function validator(_, value) {
|
|
127
|
+
if (!value || value.trim() === '') {
|
|
128
|
+
return Promise.resolve();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// 检查是否以数字开头
|
|
132
|
+
if (/^\d/.test(value)) {
|
|
133
|
+
return Promise.reject(new Error($i18n.get({
|
|
134
|
+
id: 'spark-flow.components.CustomOutputsForm.index.variableNameCannotStartWithNumber',
|
|
135
|
+
dm: '变量名不能以数字开头'
|
|
136
|
+
})));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// 检查是否包含非法字符
|
|
140
|
+
if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(value)) {
|
|
141
|
+
return Promise.reject(new Error($i18n.get({
|
|
142
|
+
id: 'spark-flow.components.CustomOutputsForm.index.variableNameOnlyAllowLettersNumbersUnderscores',
|
|
143
|
+
dm: '变量名只能包含字母、数字和下划线'
|
|
144
|
+
})));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// 检查是否重复
|
|
148
|
+
var isDuplicate = allValues.some(function (item, index) {
|
|
149
|
+
return index !== currentIndex && item.key === value && item.key !== '';
|
|
150
|
+
});
|
|
151
|
+
if (isDuplicate) {
|
|
152
|
+
return Promise.reject(new Error($i18n.get({
|
|
153
|
+
id: 'spark-flow.components.CustomOutputsForm.index.variableNameDuplicate',
|
|
154
|
+
dm: '变量名不能重复'
|
|
155
|
+
})));
|
|
156
|
+
}
|
|
157
|
+
return Promise.resolve();
|
|
158
|
+
}
|
|
159
|
+
}];
|
|
160
|
+
};
|
|
161
|
+
export var CustomOutputsForm = /*#__PURE__*/memo(function (_ref) {
|
|
162
|
+
var _ref$value = _ref.value,
|
|
163
|
+
value = _ref$value === void 0 ? [] : _ref$value,
|
|
164
|
+
onChange = _ref.onChange,
|
|
165
|
+
readyOnly = _ref.readyOnly,
|
|
166
|
+
_ref$isRoot = _ref.isRoot,
|
|
167
|
+
isRoot = _ref$isRoot === void 0 ? false : _ref$isRoot,
|
|
168
|
+
enabledTypes = _ref.enabledTypes,
|
|
169
|
+
disabledTypes = _ref.disabledTypes;
|
|
170
|
+
var _Form$useForm = Form.useForm(),
|
|
171
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
172
|
+
form = _Form$useForm2[0];
|
|
173
|
+
var _useState = useState(true),
|
|
174
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
175
|
+
expand = _useState2[0],
|
|
176
|
+
setExpand = _useState2[1];
|
|
177
|
+
|
|
178
|
+
// 同步 value 到 form
|
|
179
|
+
useEffect(function () {
|
|
180
|
+
var formValues = {};
|
|
181
|
+
value.forEach(function (item, index) {
|
|
182
|
+
formValues["var_".concat(index)] = item.key;
|
|
183
|
+
});
|
|
184
|
+
form.setFieldsValue(formValues);
|
|
185
|
+
}, [value, form]);
|
|
186
|
+
var _handleChange = function handleChange(ind, payload) {
|
|
187
|
+
var newValue = value.map(function (item, index) {
|
|
188
|
+
if (index === ind) return _objectSpread(_objectSpread({}, item), payload);
|
|
189
|
+
return item;
|
|
190
|
+
});
|
|
191
|
+
onChange === null || onChange === void 0 || onChange(newValue);
|
|
192
|
+
};
|
|
193
|
+
var handleAdd = function handleAdd() {
|
|
194
|
+
onChange === null || onChange === void 0 || onChange(value.concat({
|
|
195
|
+
key: '',
|
|
196
|
+
type: 'String',
|
|
197
|
+
desc: ''
|
|
198
|
+
}));
|
|
199
|
+
};
|
|
200
|
+
var handleDelete = function handleDelete(index) {
|
|
201
|
+
onChange === null || onChange === void 0 || onChange(value.filter(function (_, i) {
|
|
202
|
+
return i !== index;
|
|
203
|
+
}));
|
|
204
|
+
};
|
|
205
|
+
var _getCommonConfig = getCommonConfig(),
|
|
206
|
+
antPrefix = _getCommonConfig.antPrefix;
|
|
207
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
208
|
+
form: form,
|
|
209
|
+
component: false
|
|
210
|
+
}, value.map(function (item, index) {
|
|
211
|
+
var hasProperties = item.type === 'Array<Object>' || item.type === 'Object';
|
|
212
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
213
|
+
key: index,
|
|
214
|
+
className: classNames('flex flex-col gap-[8px]', _defineProperty(_defineProperty({}, 'spark-flow-inputs-form-parent-node', hasProperties), 'spark-flow-inputs-form-parent-node-hidden', !expand))
|
|
215
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
216
|
+
className: "spark-flow-inputs-form-item flex gap-[8px] align-center"
|
|
217
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
218
|
+
name: "var_".concat(index),
|
|
219
|
+
style: {
|
|
220
|
+
flex: 1,
|
|
221
|
+
marginBottom: 0
|
|
222
|
+
},
|
|
223
|
+
validateTrigger: ['onChange', 'onBlur'],
|
|
224
|
+
rules: createVariableNameRules(value, index)
|
|
225
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
226
|
+
disabled: getDisableStatus(index, readyOnly, 'key'),
|
|
227
|
+
placeholder: $i18n.get({
|
|
228
|
+
id: 'spark-flow.components.CustomOutputsForm.index.enterVariableName',
|
|
229
|
+
dm: '请输入变量名'
|
|
230
|
+
}),
|
|
231
|
+
onChange: function onChange(e) {
|
|
232
|
+
return _handleChange(index, {
|
|
233
|
+
key: e.target.value
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
})), /*#__PURE__*/React.createElement(VariableTypeSelect, {
|
|
237
|
+
type: item.type,
|
|
238
|
+
disabled: getDisableStatus(index, readyOnly, 'type'),
|
|
239
|
+
handleChange: function handleChange(type) {
|
|
240
|
+
_handleChange(index, {
|
|
241
|
+
type: type,
|
|
242
|
+
properties: type.includes('File') ? FILE_PROPERTIES : []
|
|
243
|
+
});
|
|
244
|
+
},
|
|
245
|
+
enabledTypes: enabledTypes,
|
|
246
|
+
disabledTypes: disabledTypes
|
|
247
|
+
}), /*#__PURE__*/React.createElement(Input, {
|
|
248
|
+
style: {
|
|
249
|
+
width: 100,
|
|
250
|
+
flexShrink: 0,
|
|
251
|
+
height: 32
|
|
252
|
+
},
|
|
253
|
+
disabled: getDisableStatus(index, readyOnly, 'desc'),
|
|
254
|
+
value: item.desc,
|
|
255
|
+
placeholder: $i18n.get({
|
|
256
|
+
id: 'spark-flow.components.CustomOutputsForm.index.enterVariableDescription',
|
|
257
|
+
dm: '请输入变量描述'
|
|
258
|
+
}),
|
|
259
|
+
onChange: function onChange(e) {
|
|
260
|
+
return _handleChange(index, {
|
|
261
|
+
desc: e.target.value
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}), !getDisableStatus(index, readyOnly, 'delete') && /*#__PURE__*/React.createElement(SparkDeleteLine, {
|
|
265
|
+
className: "flex-shrink-0 cursor-pointer",
|
|
266
|
+
style: {
|
|
267
|
+
color: "var(--".concat(antPrefix, "-color-text-tertiary)"),
|
|
268
|
+
height: 32
|
|
269
|
+
},
|
|
270
|
+
onClick: function onClick() {
|
|
271
|
+
return handleDelete(index);
|
|
272
|
+
},
|
|
273
|
+
size: 16
|
|
274
|
+
})), hasProperties && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SparkUpLine, {
|
|
275
|
+
onClick: function onClick() {
|
|
276
|
+
return setExpand(!expand);
|
|
277
|
+
},
|
|
278
|
+
className: "spark-flow-inputs-expand-btn cursor-pointer",
|
|
279
|
+
size: 16
|
|
280
|
+
}), expand && /*#__PURE__*/React.createElement("div", {
|
|
281
|
+
className: "pl-[16px] flex flex-col gap-[8px]"
|
|
282
|
+
}, /*#__PURE__*/React.createElement(CustomOutputsForm, {
|
|
283
|
+
value: item.properties,
|
|
284
|
+
readyOnly: getDisableStatus(index, readyOnly, ''),
|
|
285
|
+
onChange: function onChange(properties) {
|
|
286
|
+
return _handleChange(index, {
|
|
287
|
+
properties: properties
|
|
288
|
+
});
|
|
289
|
+
},
|
|
290
|
+
enabledTypes: enabledTypes,
|
|
291
|
+
disabledTypes: disabledTypes
|
|
292
|
+
}))));
|
|
293
|
+
}), readyOnly !== true && /*#__PURE__*/React.createElement(Button, {
|
|
294
|
+
type: "link",
|
|
295
|
+
onClick: handleAdd,
|
|
296
|
+
size: "small",
|
|
297
|
+
className: "self-start spark-flow-text-btn",
|
|
298
|
+
icon: /*#__PURE__*/React.createElement(SparkPlusLine, null)
|
|
299
|
+
}, isRoot ? $i18n.get({
|
|
300
|
+
id: 'spark-flow.components.CustomOutputsForm.index.addVariable',
|
|
301
|
+
dm: '添加变量'
|
|
302
|
+
}) : $i18n.get({
|
|
303
|
+
id: 'spark-flow.components.CustomOutputsForm.index.addSubVariable',
|
|
304
|
+
dm: '添加子变量'
|
|
305
|
+
})));
|
|
306
|
+
});
|
|
307
|
+
export var CustomOutputsFormWrap = /*#__PURE__*/memo(function (props) {
|
|
308
|
+
var value = props.value,
|
|
309
|
+
onChange = props.onChange,
|
|
310
|
+
readyOnly = props.readyOnly,
|
|
311
|
+
enabledTypes = props.enabledTypes,
|
|
312
|
+
disabledTypes = props.disabledTypes;
|
|
313
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
314
|
+
className: "flex flex-col gap-[8px]"
|
|
315
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
316
|
+
className: "spark-flow-inputs-form-label flex gap-[8px]"
|
|
317
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
318
|
+
style: {
|
|
319
|
+
flex: 1
|
|
320
|
+
}
|
|
321
|
+
}, $i18n.get({
|
|
322
|
+
id: 'spark-flow.components.CustomOutputsForm.index.variableName',
|
|
323
|
+
dm: '变量名'
|
|
324
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
325
|
+
style: {
|
|
326
|
+
width: 140
|
|
327
|
+
}
|
|
328
|
+
}, $i18n.get({
|
|
329
|
+
id: 'spark-flow.components.CustomOutputsForm.index.type',
|
|
330
|
+
dm: '类型'
|
|
331
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
332
|
+
style: {
|
|
333
|
+
width: readyOnly ? 100 : 124
|
|
334
|
+
}
|
|
335
|
+
}, $i18n.get({
|
|
336
|
+
id: 'spark-flow.components.CustomOutputsForm.index.description',
|
|
337
|
+
dm: '描述'
|
|
338
|
+
}))), /*#__PURE__*/React.createElement(CustomOutputsForm, {
|
|
339
|
+
value: value,
|
|
340
|
+
onChange: onChange,
|
|
341
|
+
readyOnly: readyOnly,
|
|
342
|
+
isRoot: true,
|
|
343
|
+
enabledTypes: enabledTypes,
|
|
344
|
+
disabledTypes: disabledTypes
|
|
345
|
+
}));
|
|
346
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
@import '../../index.less';
|
|
2
|
+
|
|
3
|
+
.spark-flow-inputs-form-label {
|
|
4
|
+
font-size: 12px;
|
|
5
|
+
color: e('var(--@{ant-prefix}-color-text-secondary)');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.spark-flow-inputs-form-parent-node {
|
|
9
|
+
position: relative;
|
|
10
|
+
|
|
11
|
+
&:not(&-hidden)::after {
|
|
12
|
+
content: '';
|
|
13
|
+
height: calc(100% - 24px);
|
|
14
|
+
bottom: 0;
|
|
15
|
+
left: -10.5px;
|
|
16
|
+
width: 1px;
|
|
17
|
+
background: e('var(--@{ant-prefix}-color-border-secondary)');
|
|
18
|
+
position: absolute;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.spark-flow-inputs-expand-btn {
|
|
22
|
+
transition: transform 0.3s ease-in-out;
|
|
23
|
+
position: absolute;
|
|
24
|
+
top: 4px;
|
|
25
|
+
left: -18px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&-hidden {
|
|
29
|
+
.spark-flow-inputs-expand-btn {
|
|
30
|
+
transform: rotate(180deg);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.spark-flow-inputs-form-item {
|
|
36
|
+
.ant-select-sm .ant-select-selector,
|
|
37
|
+
.ant-input-sm {
|
|
38
|
+
font-size: 12px;
|
|
39
|
+
line-height: 22px;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.spark-flow-variable-type-select {
|
|
44
|
+
.@{ant-prefix}-cascader-dropdown .@{ant-prefix}-cascader-menu {
|
|
45
|
+
height: auto;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.@{ant-prefix}-select-selection-item {
|
|
49
|
+
height: 30px;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
interface DragPanelProps {
|
|
4
|
+
maxWidth: number;
|
|
5
|
+
minWidth: number;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
defaultWidth?: number;
|
|
8
|
+
}
|
|
9
|
+
declare const DragPanel: React.FC<DragPanelProps>;
|
|
10
|
+
export default DragPanel;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import classNames from 'classnames';
|
|
8
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
9
|
+
import "./index.less";
|
|
10
|
+
var DragPanel = function DragPanel(_ref) {
|
|
11
|
+
var maxWidth = _ref.maxWidth,
|
|
12
|
+
minWidth = _ref.minWidth,
|
|
13
|
+
children = _ref.children,
|
|
14
|
+
_ref$defaultWidth = _ref.defaultWidth,
|
|
15
|
+
defaultWidth = _ref$defaultWidth === void 0 ? 300 : _ref$defaultWidth;
|
|
16
|
+
var _useState = useState(defaultWidth),
|
|
17
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
+
width = _useState2[0],
|
|
19
|
+
setWidth = _useState2[1];
|
|
20
|
+
var _useState3 = useState(false),
|
|
21
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
22
|
+
isDragging = _useState4[0],
|
|
23
|
+
setIsDragging = _useState4[1];
|
|
24
|
+
var _useState5 = useState(false),
|
|
25
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
26
|
+
isHovering = _useState6[0],
|
|
27
|
+
setIsHovering = _useState6[1];
|
|
28
|
+
var panelRef = useRef(null);
|
|
29
|
+
var startXRef = useRef(0);
|
|
30
|
+
var startWidthRef = useRef(0);
|
|
31
|
+
var handleMouseDown = useCallback(function (e) {
|
|
32
|
+
setIsDragging(true);
|
|
33
|
+
startXRef.current = e.clientX;
|
|
34
|
+
startWidthRef.current = width;
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
}, [width]);
|
|
37
|
+
var handleMouseMove = useCallback(function (e) {
|
|
38
|
+
if (!isDragging) return;
|
|
39
|
+
var deltaX = startXRef.current - e.clientX;
|
|
40
|
+
var newWidth = startWidthRef.current + deltaX;
|
|
41
|
+
var clampedWidth = Math.min(Math.max(newWidth, minWidth), maxWidth);
|
|
42
|
+
requestAnimationFrame(function () {
|
|
43
|
+
setWidth(clampedWidth);
|
|
44
|
+
});
|
|
45
|
+
}, [isDragging, maxWidth, minWidth]);
|
|
46
|
+
var handleMouseUp = useCallback(function () {
|
|
47
|
+
setIsDragging(false);
|
|
48
|
+
}, []);
|
|
49
|
+
React.useEffect(function () {
|
|
50
|
+
if (isDragging) {
|
|
51
|
+
window.addEventListener('mousemove', handleMouseMove);
|
|
52
|
+
window.addEventListener('mouseup', handleMouseUp);
|
|
53
|
+
}
|
|
54
|
+
return function () {
|
|
55
|
+
window.removeEventListener('mousemove', handleMouseMove);
|
|
56
|
+
window.removeEventListener('mouseup', handleMouseUp);
|
|
57
|
+
};
|
|
58
|
+
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
59
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
ref: panelRef,
|
|
61
|
+
className: "spark-drag-panel",
|
|
62
|
+
style: {
|
|
63
|
+
width: width
|
|
64
|
+
}
|
|
65
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
className: classNames('spark-drag-panel-handle', {
|
|
67
|
+
'spark-drag-panel-handle--dragging': isDragging,
|
|
68
|
+
'spark-drag-panel-handle--hovering': isHovering
|
|
69
|
+
}),
|
|
70
|
+
onMouseDown: handleMouseDown,
|
|
71
|
+
onMouseEnter: function onMouseEnter() {
|
|
72
|
+
return setIsHovering(true);
|
|
73
|
+
},
|
|
74
|
+
onMouseLeave: function onMouseLeave() {
|
|
75
|
+
return setIsHovering(false);
|
|
76
|
+
}
|
|
77
|
+
}), children);
|
|
78
|
+
};
|
|
79
|
+
export default DragPanel;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.spark-drag-panel {
|
|
2
|
+
position: relative;
|
|
3
|
+
height: 100%;
|
|
4
|
+
|
|
5
|
+
&-handle {
|
|
6
|
+
position: absolute;
|
|
7
|
+
left: 0;
|
|
8
|
+
top: 0;
|
|
9
|
+
bottom: 0;
|
|
10
|
+
width: 2px;
|
|
11
|
+
cursor: ew-resize;
|
|
12
|
+
background-color: transparent;
|
|
13
|
+
transition: background-color 0.2s ease;
|
|
14
|
+
|
|
15
|
+
&--dragging {
|
|
16
|
+
background-color: #1890ff;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&--hovering {
|
|
20
|
+
background-color: #e6f7ff;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
interface DraggableWithHandleProps<T> {
|
|
4
|
+
items: T[];
|
|
5
|
+
onChange: (items: T[]) => void;
|
|
6
|
+
renderItem: (item: T, dragHandleProps: ReactNode) => ReactNode;
|
|
7
|
+
getItemId: (item: T) => string;
|
|
8
|
+
dragIcon?: ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function DraggableWithHandle<T>({ items, onChange, renderItem, getItemId, dragIcon, className, disabled, }: DraggableWithHandleProps<T>): React.JSX.Element;
|
|
13
|
+
export default DraggableWithHandle;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
import { SparkDragDotLine } from '@agentscope-ai/icons';
|
|
3
|
+
import { closestCenter, DndContext, KeyboardSensor, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';
|
|
4
|
+
import { arrayMove, SortableContext, sortableKeyboardCoordinates, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
5
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import "./index.less";
|
|
8
|
+
var SortableItem = function SortableItem(_ref) {
|
|
9
|
+
var id = _ref.id,
|
|
10
|
+
children = _ref.children;
|
|
11
|
+
var _useSortable = useSortable({
|
|
12
|
+
id: id
|
|
13
|
+
}),
|
|
14
|
+
attributes = _useSortable.attributes,
|
|
15
|
+
listeners = _useSortable.listeners,
|
|
16
|
+
setNodeRef = _useSortable.setNodeRef,
|
|
17
|
+
transform = _useSortable.transform,
|
|
18
|
+
transition = _useSortable.transition,
|
|
19
|
+
isDragging = _useSortable.isDragging;
|
|
20
|
+
var style = {
|
|
21
|
+
transform: CSS.Transform.toString(transform),
|
|
22
|
+
transition: transition,
|
|
23
|
+
opacity: isDragging ? 0.5 : 1
|
|
24
|
+
};
|
|
25
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
26
|
+
ref: setNodeRef,
|
|
27
|
+
style: style
|
|
28
|
+
}, attributes, {
|
|
29
|
+
className: "draggable-item"
|
|
30
|
+
}), children(listeners));
|
|
31
|
+
};
|
|
32
|
+
export function DraggableWithHandle(_ref2) {
|
|
33
|
+
var items = _ref2.items,
|
|
34
|
+
onChange = _ref2.onChange,
|
|
35
|
+
renderItem = _ref2.renderItem,
|
|
36
|
+
getItemId = _ref2.getItemId,
|
|
37
|
+
_ref2$dragIcon = _ref2.dragIcon,
|
|
38
|
+
dragIcon = _ref2$dragIcon === void 0 ? /*#__PURE__*/React.createElement(SparkDragDotLine, null) : _ref2$dragIcon,
|
|
39
|
+
className = _ref2.className,
|
|
40
|
+
disabled = _ref2.disabled;
|
|
41
|
+
var sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
|
|
42
|
+
coordinateGetter: sortableKeyboardCoordinates
|
|
43
|
+
}));
|
|
44
|
+
var handleDragEnd = function handleDragEnd(event) {
|
|
45
|
+
var active = event.active,
|
|
46
|
+
over = event.over;
|
|
47
|
+
if (over && active.id !== over.id) {
|
|
48
|
+
var oldIndex = items.findIndex(function (item) {
|
|
49
|
+
return getItemId(item) === active.id;
|
|
50
|
+
});
|
|
51
|
+
var newIndex = items.findIndex(function (item) {
|
|
52
|
+
return getItemId(item) === over.id;
|
|
53
|
+
});
|
|
54
|
+
onChange(arrayMove(items, oldIndex, newIndex));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var renderHandle = function renderHandle(listeners) {
|
|
58
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
59
|
+
className: "drag-handle"
|
|
60
|
+
}, listeners), dragIcon);
|
|
61
|
+
};
|
|
62
|
+
return /*#__PURE__*/React.createElement(DndContext, {
|
|
63
|
+
sensors: sensors,
|
|
64
|
+
collisionDetection: closestCenter,
|
|
65
|
+
onDragEnd: handleDragEnd
|
|
66
|
+
}, /*#__PURE__*/React.createElement(SortableContext, {
|
|
67
|
+
disabled: disabled,
|
|
68
|
+
items: items.map(getItemId),
|
|
69
|
+
strategy: verticalListSortingStrategy
|
|
70
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
className: className
|
|
72
|
+
}, items.map(function (item) {
|
|
73
|
+
return /*#__PURE__*/React.createElement(SortableItem, {
|
|
74
|
+
key: getItemId(item),
|
|
75
|
+
id: getItemId(item)
|
|
76
|
+
}, function (listeners) {
|
|
77
|
+
return renderItem(item, renderHandle(listeners));
|
|
78
|
+
});
|
|
79
|
+
}))));
|
|
80
|
+
}
|
|
81
|
+
export default DraggableWithHandle;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@import '../../index.less';
|
|
2
|
+
|
|
3
|
+
.draggable-item {
|
|
4
|
+
position: relative;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.drag-handle {
|
|
8
|
+
cursor: grab;
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
-webkit-touch-callout: none;
|
|
13
|
+
user-select: none;
|
|
14
|
+
|
|
15
|
+
&:active {
|
|
16
|
+
cursor: grabbing;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
i {
|
|
20
|
+
font-size: 16px;
|
|
21
|
+
color: e('var(--@{ant-prefix}-color-text-secondary)');
|
|
22
|
+
}
|
|
23
|
+
}
|