strategy-panel 1.0.0
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/.eslintrc.js +9 -0
- package/.fatherrc.ts +26 -0
- package/.prettierrc.js +1 -0
- package/.umirc.ts +29 -0
- package/LICENSE +22 -0
- package/README.md +33 -0
- package/es/assets/AND.svg +11 -0
- package/es/assets/OR.svg +11 -0
- package/es/assets/XOR.svg +11 -0
- package/es/assets/add.svg +13 -0
- package/es/assets/alarm.svg +11 -0
- package/es/assets/application.svg +11 -0
- package/es/assets/cancel.svg +13 -0
- package/es/assets/check.svg +12 -0
- package/es/assets/condition.svg +12 -0
- package/es/assets/control.svg +11 -0
- package/es/assets/decive.svg +11 -0
- package/es/assets/delete.svg +11 -0
- package/es/assets/device.svg +11 -0
- package/es/assets/edit.svg +11 -0
- package/es/assets/hand.svg +11 -0
- package/es/assets/link.svg +11 -0
- package/es/assets/logical.svg +12 -0
- package/es/assets/notice.svg +11 -0
- package/es/assets/order.svg +11 -0
- package/es/assets/relation.svg +11 -0
- package/es/assets/rhombus.svg +3 -0
- package/es/assets/save.svg +13 -0
- package/es/assets/time.svg +11 -0
- package/es/assets/variate.svg +12 -0
- package/es/common/constants/global.d.ts +1 -0
- package/es/common/constants/global.js +1 -0
- package/es/common/constants/graph.d.ts +10 -0
- package/es/common/constants/graph.js +17 -0
- package/es/common/graph-common/category-type.d.ts +16 -0
- package/es/common/graph-common/category-type.js +72 -0
- package/es/common/graph-common/connector/index.d.ts +1 -0
- package/es/common/graph-common/connector/index.js +14 -0
- package/es/common/graph-common/node-element/common-element.less +117 -0
- package/es/common/graph-common/node-element/condition-element.d.ts +8 -0
- package/es/common/graph-common/node-element/condition-element.js +35 -0
- package/es/common/graph-common/node-element/condition-element.less +82 -0
- package/es/common/graph-common/node-element/logical-element.d.ts +8 -0
- package/es/common/graph-common/node-element/logical-element.js +34 -0
- package/es/common/graph-common/node-element/logical-element.less +54 -0
- package/es/common/graph-common/node-element/node-element.d.ts +8 -0
- package/es/common/graph-common/node-element/node-element.js +27 -0
- package/es/common/graph-common/node-element/node-element.less +48 -0
- package/es/common/graph-common/node-element/node-group.d.ts +8 -0
- package/es/common/graph-common/node-element/node-group.js +395 -0
- package/es/common/graph-common/node-element/node-group.less +53 -0
- package/es/common/graph-common/node-popover/index.d.ts +7 -0
- package/es/common/graph-common/node-popover/index.js +11 -0
- package/es/common/graph-common/node-popover/index.less +5 -0
- package/es/common/graph-common/node-types.d.ts +28 -0
- package/es/common/graph-common/node-types.js +60 -0
- package/es/common/graph-common/shape/edge.d.ts +10 -0
- package/es/common/graph-common/shape/edge.js +115 -0
- package/es/common/graph-common/shape/edge.less +8 -0
- package/es/common/graph-common/shape/node.d.ts +6 -0
- package/es/common/graph-common/shape/node.js +6 -0
- package/es/common/graph-common/shape/nodes/BaseNode.d.ts +4 -0
- package/es/common/graph-common/shape/nodes/BaseNode.js +46 -0
- package/es/common/graph-common/shape/nodes/CommonNode.d.ts +5 -0
- package/es/common/graph-common/shape/nodes/CommonNode.js +118 -0
- package/es/common/graph-common/shape/nodes/ConditionJudgment.d.ts +5 -0
- package/es/common/graph-common/shape/nodes/ConditionJudgment.js +130 -0
- package/es/common/graph-common/shape/nodes/GroupNode.d.ts +4 -0
- package/es/common/graph-common/shape/nodes/GroupNode.js +99 -0
- package/es/common/graph-common/shape/nodes/LogicalNode.d.ts +5 -0
- package/es/common/graph-common/shape/nodes/LogicalNode.js +130 -0
- package/es/common/graph-utils/graph.d.ts +83 -0
- package/es/common/graph-utils/graph.js +98 -0
- package/es/component/cut.d.ts +10 -0
- package/es/component/cut.js +34 -0
- package/es/component/cut.less +6 -0
- package/es/component/item-name.d.ts +6 -0
- package/es/component/item-name.js +30 -0
- package/es/component/keyword.d.ts +9 -0
- package/es/component/keyword.js +26 -0
- package/es/component/keyword.less +11 -0
- package/es/component/rx-component/rx-input.d.ts +8 -0
- package/es/component/rx-component/rx-input.js +47 -0
- package/es/hooks/useObservableState.d.ts +3 -0
- package/es/hooks/useObservableState.js +44 -0
- package/es/index.d.ts +8 -0
- package/es/index.js +9 -0
- package/es/pages/component-tree-panel/category-tree/index.d.ts +16 -0
- package/es/pages/component-tree-panel/category-tree/index.js +100 -0
- package/es/pages/component-tree-panel/category-tree/index.less +35 -0
- package/es/pages/component-tree-panel/category-tree/node-title.d.ts +12 -0
- package/es/pages/component-tree-panel/category-tree/node-title.js +57 -0
- package/es/pages/component-tree-panel/category-tree/node-title.less +113 -0
- package/es/pages/component-tree-panel/index.d.ts +17 -0
- package/es/pages/component-tree-panel/index.js +19 -0
- package/es/pages/component-tree-panel/index.less +51 -0
- package/es/pages/config-panel/components/condition-configuration/configure-modal/data-origin.d.ts +49 -0
- package/es/pages/config-panel/components/condition-configuration/configure-modal/data-origin.js +212 -0
- package/es/pages/config-panel/components/condition-configuration/configure-modal/index.d.ts +11 -0
- package/es/pages/config-panel/components/condition-configuration/configure-modal/index.js +178 -0
- package/es/pages/config-panel/components/condition-configuration/configure-modal/style.less +13 -0
- package/es/pages/config-panel/components/condition-configuration/cross-line.d.ts +8 -0
- package/es/pages/config-panel/components/condition-configuration/cross-line.js +47 -0
- package/es/pages/config-panel/components/condition-configuration/index.d.ts +9 -0
- package/es/pages/config-panel/components/condition-configuration/index.js +180 -0
- package/es/pages/config-panel/components/condition-configuration/style.less +70 -0
- package/es/pages/config-panel/components/time-trigger/components/cycle-time.d.ts +8 -0
- package/es/pages/config-panel/components/time-trigger/components/cycle-time.js +87 -0
- package/es/pages/config-panel/components/time-trigger/components/time-horizon.d.ts +9 -0
- package/es/pages/config-panel/components/time-trigger/components/time-horizon.js +73 -0
- package/es/pages/config-panel/components/time-trigger/delay-time.d.ts +8 -0
- package/es/pages/config-panel/components/time-trigger/delay-time.js +18 -0
- package/es/pages/config-panel/components/time-trigger/index.d.ts +8 -0
- package/es/pages/config-panel/components/time-trigger/index.js +84 -0
- package/es/pages/config-panel/components/time-trigger/interval-time.d.ts +8 -0
- package/es/pages/config-panel/components/time-trigger/interval-time.js +50 -0
- package/es/pages/config-panel/components/time-trigger/persistent-time.d.ts +8 -0
- package/es/pages/config-panel/components/time-trigger/persistent-time.js +18 -0
- package/es/pages/config-panel/components/time-trigger/timing-time.d.ts +8 -0
- package/es/pages/config-panel/components/time-trigger/timing-time.js +52 -0
- package/es/pages/config-panel/config-common.d.ts +37 -0
- package/es/pages/config-panel/config-common.js +135 -0
- package/es/pages/config-panel/index.d.ts +12 -0
- package/es/pages/config-panel/index.js +50 -0
- package/es/pages/config-panel/node-form.d.ts +21 -0
- package/es/pages/config-panel/node-form.js +97 -0
- package/es/pages/config-panel/style.less +62 -0
- package/es/pages/dag-canvas/canvas-content.d.ts +9 -0
- package/es/pages/dag-canvas/canvas-content.js +92 -0
- package/es/pages/dag-canvas/canvas-content.less +5 -0
- package/es/pages/dag-canvas/index.d.ts +13 -0
- package/es/pages/dag-canvas/index.js +28 -0
- package/es/pages/dag-canvas/index.less +11 -0
- package/es/pages/dag-canvas/preview.d.ts +9 -0
- package/es/pages/dag-canvas/preview.js +34 -0
- package/es/pages/index.d.ts +37 -0
- package/es/pages/index.js +73 -0
- package/es/pages/index.less +50 -0
- package/es/pages/rx-models/experiment-graph.d.ts +82 -0
- package/es/pages/rx-models/experiment-graph.js +1186 -0
- package/es/pages/rx-models/graph-core.d.ts +96 -0
- package/es/pages/rx-models/graph-core.js +755 -0
- package/es/pages/rx-models/graph-core.less +14 -0
- package/es/pages/rx-models/graph-util.d.ts +186 -0
- package/es/pages/rx-models/graph-util.js +358 -0
- package/es/pages/rx-models/typing.d.ts +126 -0
- package/es/pages/strategy-header/index.d.ts +56 -0
- package/es/pages/strategy-header/index.js +141 -0
- package/es/pages/strategy-header/style.less +22 -0
- package/es/pages/strategy-header/theme-switch/index.d.ts +4 -0
- package/es/pages/strategy-header/theme-switch/index.js +19 -0
- package/es/pages/strategy-header/theme-switch/style.less +11 -0
- package/es/style/basic.less +12 -0
- package/es/style/default.less +2 -0
- package/es/style/position.less +25 -0
- package/es/style/theme-light.less +7 -0
- package/es/style/variable.less +3 -0
- package/es/typings.d.ts +6 -0
- package/es/utils/utils.d.ts +1 -0
- package/es/utils/utils.js +1 -0
- package/package.json +70 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
7
|
+
import random from 'lodash/random';
|
|
8
|
+
import { SIGN_OPERATION } from "../graph-common/node-types";
|
|
9
|
+
export var createNodePorts = function createNodePorts(id, timestamp) {
|
|
10
|
+
// 条件判断
|
|
11
|
+
if (id === SIGN_OPERATION.CONDITION) {
|
|
12
|
+
return {
|
|
13
|
+
inPorts: [{
|
|
14
|
+
id: id ? "".concat(id, "-IN-").concat(timestamp) : "in-".concat(timestamp),
|
|
15
|
+
sequence: 1
|
|
16
|
+
}],
|
|
17
|
+
outPorts: [{
|
|
18
|
+
id: id ? "".concat(id, "-OUT-").concat(timestamp) : "out-".concat(timestamp),
|
|
19
|
+
sequence: 1
|
|
20
|
+
}, {
|
|
21
|
+
id: id ? "".concat(id, "-OUT-LEFT-").concat(timestamp) : "out-".concat(timestamp),
|
|
22
|
+
sequence: 2,
|
|
23
|
+
group: 'outLeft'
|
|
24
|
+
}, {
|
|
25
|
+
id: id ? "".concat(id, "-OUT-RIGHT-").concat(timestamp) : "out-".concat(timestamp),
|
|
26
|
+
sequence: 3,
|
|
27
|
+
group: 'outRight'
|
|
28
|
+
}]
|
|
29
|
+
};
|
|
30
|
+
} // 逻辑判断
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
if (id === SIGN_OPERATION.LOGICAL) {
|
|
34
|
+
return {
|
|
35
|
+
inPorts: [{
|
|
36
|
+
id: id ? "".concat(id, "-IN-").concat(timestamp) : "in-".concat(timestamp),
|
|
37
|
+
sequence: 1
|
|
38
|
+
}],
|
|
39
|
+
outPorts: [{
|
|
40
|
+
id: id ? "".concat(id, "-OUT-").concat(timestamp) : "out-".concat(timestamp),
|
|
41
|
+
sequence: 1
|
|
42
|
+
}, {
|
|
43
|
+
id: id ? "".concat(id, "-OUT-LEFT-").concat(timestamp) : "out-".concat(timestamp),
|
|
44
|
+
sequence: 2,
|
|
45
|
+
group: 'outLeft'
|
|
46
|
+
}, {
|
|
47
|
+
id: id ? "".concat(id, "-OUT-RIGHT-").concat(timestamp) : "out-".concat(timestamp),
|
|
48
|
+
sequence: 3,
|
|
49
|
+
group: 'outRight'
|
|
50
|
+
}]
|
|
51
|
+
};
|
|
52
|
+
} // 普通节点
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
inPorts: [{
|
|
57
|
+
id: id ? "".concat(id, "-IN-").concat(timestamp) : "in-".concat(timestamp),
|
|
58
|
+
sequence: 1
|
|
59
|
+
}],
|
|
60
|
+
outPorts: [{
|
|
61
|
+
id: id ? "".concat(id, "-OUT-").concat(timestamp) : "out-".concat(timestamp),
|
|
62
|
+
sequence: 1
|
|
63
|
+
}]
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export var createNode = function createNode(_ref) {
|
|
67
|
+
var id = _ref.id,
|
|
68
|
+
name = _ref.name,
|
|
69
|
+
imgUrl = _ref.imgUrl,
|
|
70
|
+
x = _ref.x,
|
|
71
|
+
y = _ref.y;
|
|
72
|
+
var timestamp = "".concat(Date.now());
|
|
73
|
+
var portsParams = createNodePorts(id, timestamp);
|
|
74
|
+
return _objectSpread({
|
|
75
|
+
id: id ? "".concat(id, "-").concat(timestamp) : "".concat(timestamp),
|
|
76
|
+
name: name,
|
|
77
|
+
imgUrl: imgUrl,
|
|
78
|
+
positionX: x,
|
|
79
|
+
positionY: y
|
|
80
|
+
}, portsParams);
|
|
81
|
+
};
|
|
82
|
+
export var copyNode = function copyNode(_ref2) {
|
|
83
|
+
var id = _ref2.id,
|
|
84
|
+
name = _ref2.name,
|
|
85
|
+
imgUrl = _ref2.imgUrl,
|
|
86
|
+
x = _ref2.x,
|
|
87
|
+
y = _ref2.y;
|
|
88
|
+
return createNode({
|
|
89
|
+
id: id,
|
|
90
|
+
name: name,
|
|
91
|
+
imgUrl: imgUrl,
|
|
92
|
+
x: x + 200 + random(20, false),
|
|
93
|
+
y: y + 15 + random(20, false)
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
export var addNode = function addNode(params) {
|
|
97
|
+
return createNode(params);
|
|
98
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import "./cut.less";
|
|
3
|
+
export var Cut = function Cut(props) {
|
|
4
|
+
var left = props.left,
|
|
5
|
+
_props$right = props.right,
|
|
6
|
+
right = _props$right === void 0 ? 0 : _props$right,
|
|
7
|
+
max = props.max,
|
|
8
|
+
children = props.children;
|
|
9
|
+
var getText = useCallback(function () {
|
|
10
|
+
var len = children.length;
|
|
11
|
+
var ellipsis = '...';
|
|
12
|
+
var leftStr = '';
|
|
13
|
+
var rightStr = '';
|
|
14
|
+
|
|
15
|
+
if (len > max) {
|
|
16
|
+
if (left && len) {
|
|
17
|
+
leftStr = children.substr(0, left);
|
|
18
|
+
} else {
|
|
19
|
+
leftStr = children.substr(0, max);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (right) {
|
|
23
|
+
rightStr = children.substr(-right, right);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return "".concat(leftStr).concat(ellipsis).concat(rightStr);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return children;
|
|
30
|
+
}, [left, right, max, children]);
|
|
31
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
32
|
+
className: "no-wrap"
|
|
33
|
+
}, getText());
|
|
34
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { unescape } from 'lodash-es';
|
|
3
|
+
import { Cut } from "./cut";
|
|
4
|
+
import { Keyword } from "./keyword";
|
|
5
|
+
export var ItemName = function ItemName(props) {
|
|
6
|
+
var data = props.data;
|
|
7
|
+
var keyword = data.keyword,
|
|
8
|
+
_data$cutParas = data.cutParas,
|
|
9
|
+
cutParas = _data$cutParas === void 0 ? {} : _data$cutParas;
|
|
10
|
+
var name = unescape(data.name);
|
|
11
|
+
var max = cutParas.max,
|
|
12
|
+
side = cutParas.side;
|
|
13
|
+
|
|
14
|
+
if (keyword) {
|
|
15
|
+
return /*#__PURE__*/React.createElement(Keyword, {
|
|
16
|
+
raw: name,
|
|
17
|
+
keyword: keyword
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (max) {
|
|
22
|
+
return /*#__PURE__*/React.createElement(Cut, {
|
|
23
|
+
max: max,
|
|
24
|
+
left: side,
|
|
25
|
+
right: side
|
|
26
|
+
}, name);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return /*#__PURE__*/React.createElement("span", null, name);
|
|
30
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import "./keyword.less";
|
|
6
|
+
export var Keyword = function Keyword(props) {
|
|
7
|
+
var raw = props.raw,
|
|
8
|
+
keyword = props.keyword,
|
|
9
|
+
className = props.className;
|
|
10
|
+
|
|
11
|
+
if (keyword) {
|
|
12
|
+
var regex = new RegExp(keyword, 'ig');
|
|
13
|
+
var arr = raw.split(regex);
|
|
14
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
15
|
+
className: classnames(_defineProperty({
|
|
16
|
+
'keyword-wrapper': true
|
|
17
|
+
}, className, !!className))
|
|
18
|
+
}, arr.map(function (section, index) {
|
|
19
|
+
return index !== arr.length - 1 ? /*#__PURE__*/React.createElement("span", {
|
|
20
|
+
key: section + index
|
|
21
|
+
}, section, /*#__PURE__*/React.createElement("strong", null, keyword)) : section;
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { InputProps } from 'antd/es/input';
|
|
4
|
+
interface RxInputProps extends Omit<InputProps, 'value'> {
|
|
5
|
+
value: Observable<string>;
|
|
6
|
+
}
|
|
7
|
+
export declare const RxInput: React.FC<RxInputProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import "antd/es/input/style";
|
|
2
|
+
import _Input from "antd/es/input";
|
|
3
|
+
import "antd/es/config-provider/style";
|
|
4
|
+
import _ConfigProvider from "antd/es/config-provider";
|
|
5
|
+
var _excluded = ["value"];
|
|
6
|
+
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
+
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
+
|
|
11
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
|
|
13
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
|
+
|
|
15
|
+
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."); }
|
|
16
|
+
|
|
17
|
+
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); }
|
|
18
|
+
|
|
19
|
+
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; }
|
|
20
|
+
|
|
21
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
22
|
+
|
|
23
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
24
|
+
|
|
25
|
+
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; }
|
|
26
|
+
|
|
27
|
+
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; }
|
|
28
|
+
|
|
29
|
+
import React from 'react';
|
|
30
|
+
import { useObservableState } from "../../hooks/useObservableState";
|
|
31
|
+
import { ANT_PREFIX } from "../../common/constants/global";
|
|
32
|
+
export var RxInput = function RxInput(props) {
|
|
33
|
+
var value = props.value,
|
|
34
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
35
|
+
|
|
36
|
+
var _useObservableState = useObservableState(function () {
|
|
37
|
+
return value;
|
|
38
|
+
}),
|
|
39
|
+
_useObservableState2 = _slicedToArray(_useObservableState, 1),
|
|
40
|
+
realValue = _useObservableState2[0];
|
|
41
|
+
|
|
42
|
+
return /*#__PURE__*/React.createElement(_ConfigProvider, {
|
|
43
|
+
prefixCls: ANT_PREFIX
|
|
44
|
+
}, /*#__PURE__*/React.createElement(_Input, _objectSpread({
|
|
45
|
+
value: realValue
|
|
46
|
+
}, otherProps)));
|
|
47
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
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); }
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
+
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
13
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
14
|
+
import { BehaviorSubject } from 'rxjs';
|
|
15
|
+
export var useObservableState = function useObservableState(source$, initialState) {
|
|
16
|
+
var source = useMemo(function () {
|
|
17
|
+
if (typeof source$ === 'function') {
|
|
18
|
+
return source$();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return source$;
|
|
22
|
+
}, [source$]);
|
|
23
|
+
|
|
24
|
+
var _useState = useState(function () {
|
|
25
|
+
if (source instanceof BehaviorSubject) {
|
|
26
|
+
return source.getValue();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return initialState;
|
|
30
|
+
}),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
state = _useState2[0],
|
|
33
|
+
setState = _useState2[1];
|
|
34
|
+
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
var sub = source.subscribe(function (v) {
|
|
37
|
+
setState(v);
|
|
38
|
+
});
|
|
39
|
+
return function () {
|
|
40
|
+
sub.unsubscribe();
|
|
41
|
+
};
|
|
42
|
+
}, [source]);
|
|
43
|
+
return [state, setState];
|
|
44
|
+
};
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="@/typings" />
|
|
2
|
+
export { default as StrategyCanvas } from './pages/index';
|
|
3
|
+
export { default as StrategyHeader } from './pages/strategy-header';
|
|
4
|
+
export { default as ComponentTreePanel } from './pages/component-tree-panel';
|
|
5
|
+
export { default as DAGCanvas } from './pages/dag-canvas';
|
|
6
|
+
export { default as ConfigPanel } from './pages/config-panel';
|
|
7
|
+
export { useExperimentGraph } from './pages/rx-models/experiment-graph';
|
|
8
|
+
export { useObservableState } from './hooks/useObservableState';
|
package/es/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
2
|
+
/// <reference path="./typings.d.ts" />
|
|
3
|
+
export { default as StrategyCanvas } from "./pages/index";
|
|
4
|
+
export { default as StrategyHeader } from "./pages/strategy-header";
|
|
5
|
+
export { default as ComponentTreePanel } from "./pages/component-tree-panel";
|
|
6
|
+
export { default as DAGCanvas } from "./pages/dag-canvas";
|
|
7
|
+
export { default as ConfigPanel } from "./pages/config-panel";
|
|
8
|
+
export { useExperimentGraph } from "./pages/rx-models/experiment-graph";
|
|
9
|
+
export { useObservableState } from "./hooks/useObservableState";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
export interface paneDataItem {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
isDir?: boolean;
|
|
7
|
+
children?: paneDataItem[];
|
|
8
|
+
imgUrl?: string;
|
|
9
|
+
number?: number;
|
|
10
|
+
}
|
|
11
|
+
interface Props {
|
|
12
|
+
sortNum?: number;
|
|
13
|
+
panelData?: paneDataItem[];
|
|
14
|
+
}
|
|
15
|
+
declare const CategoryTree: React.FC<Props>;
|
|
16
|
+
export default CategoryTree;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import "antd/es/col/style";
|
|
2
|
+
import _Col from "antd/es/col";
|
|
3
|
+
import "antd/es/row/style";
|
|
4
|
+
import _Row from "antd/es/row";
|
|
5
|
+
import "antd/es/collapse/style";
|
|
6
|
+
import _Collapse from "antd/es/collapse";
|
|
7
|
+
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
+
|
|
12
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import { componentsData } from "../../../common/graph-common/category-type";
|
|
16
|
+
import { NodeTitle } from "./node-title";
|
|
17
|
+
import "./index.less";
|
|
18
|
+
var Panel = _Collapse.Panel;
|
|
19
|
+
|
|
20
|
+
var getComponentsData = function getComponentsData(data) {
|
|
21
|
+
return data === null || data === void 0 ? void 0 : data.reduce(function (pre, next) {
|
|
22
|
+
var existentIndex = pre.findIndex(function (child) {
|
|
23
|
+
return child.id === next.id;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (existentIndex > -1) {
|
|
27
|
+
var _pre$existentIndex;
|
|
28
|
+
|
|
29
|
+
var existentChildren = pre === null || pre === void 0 ? void 0 : (_pre$existentIndex = pre[existentIndex]) === null || _pre$existentIndex === void 0 ? void 0 : _pre$existentIndex.children;
|
|
30
|
+
|
|
31
|
+
if (existentChildren && next.children) {
|
|
32
|
+
var _next$children;
|
|
33
|
+
|
|
34
|
+
pre[existentIndex] = _objectSpread(_objectSpread({}, pre[existentIndex]), next);
|
|
35
|
+
(_next$children = next.children) === null || _next$children === void 0 ? void 0 : _next$children.forEach(function (item) {
|
|
36
|
+
var childIndex = existentChildren === null || existentChildren === void 0 ? void 0 : existentChildren.findIndex(function (child) {
|
|
37
|
+
return child.id === item.id;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (childIndex > -1) {
|
|
41
|
+
existentChildren[childIndex] = item;
|
|
42
|
+
} else {
|
|
43
|
+
existentChildren.push(item);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
pre[existentIndex].children = existentChildren;
|
|
47
|
+
} else {
|
|
48
|
+
pre[existentIndex] = _objectSpread(_objectSpread({}, pre[existentIndex]), next);
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
pre.push(next);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return pre;
|
|
55
|
+
}, componentsData);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
var CategoryTree = function CategoryTree(props) {
|
|
59
|
+
var _props$sortNum = props.sortNum,
|
|
60
|
+
sortNum = _props$sortNum === void 0 ? 3 : _props$sortNum,
|
|
61
|
+
_props$panelData = props.panelData,
|
|
62
|
+
panelData = _props$panelData === void 0 ? [] : _props$panelData;
|
|
63
|
+
|
|
64
|
+
var isRowFirst = function isRowFirst(index) {
|
|
65
|
+
return (index + 1) % sortNum === 1;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
var sortIndex = function sortIndex(index) {
|
|
69
|
+
return index % sortNum;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
var currentPanelData = getComponentsData(panelData);
|
|
73
|
+
var defaultActiveKey = currentPanelData === null || currentPanelData === void 0 ? void 0 : currentPanelData.map(function (item) {
|
|
74
|
+
return item === null || item === void 0 ? void 0 : item.id;
|
|
75
|
+
});
|
|
76
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
className: "category-tree-list"
|
|
78
|
+
}, /*#__PURE__*/React.createElement(_Collapse, {
|
|
79
|
+
className: "category-tree-collapse",
|
|
80
|
+
defaultActiveKey: defaultActiveKey
|
|
81
|
+
}, currentPanelData === null || currentPanelData === void 0 ? void 0 : currentPanelData.map(function (item) {
|
|
82
|
+
var _item$children, _item$children2;
|
|
83
|
+
|
|
84
|
+
return /*#__PURE__*/React.createElement(Panel, {
|
|
85
|
+
header: item.name,
|
|
86
|
+
key: item.id
|
|
87
|
+
}, /*#__PURE__*/React.createElement(_Row, null, (item === null || item === void 0 ? void 0 : (_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) ? item === null || item === void 0 ? void 0 : (_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.map(function (child, index) {
|
|
88
|
+
return /*#__PURE__*/React.createElement(_Col, {
|
|
89
|
+
key: child.id,
|
|
90
|
+
span: 8
|
|
91
|
+
}, /*#__PURE__*/React.createElement(NodeTitle, {
|
|
92
|
+
node: child,
|
|
93
|
+
isRowFirst: isRowFirst(index),
|
|
94
|
+
sortIndex: sortIndex(index)
|
|
95
|
+
}));
|
|
96
|
+
}) : /*#__PURE__*/React.createElement("div", null)));
|
|
97
|
+
})));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export default CategoryTree;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@import (reference) '../../../style/theme-light';
|
|
2
|
+
|
|
3
|
+
.category-tree-list {
|
|
4
|
+
height: 100%;
|
|
5
|
+
overflow-x: hidden;
|
|
6
|
+
overflow-y: auto;
|
|
7
|
+
background: #fff;
|
|
8
|
+
|
|
9
|
+
.category-tree-collapse {
|
|
10
|
+
border: none;
|
|
11
|
+
|
|
12
|
+
.ant-collapse-header {
|
|
13
|
+
height: 36px;
|
|
14
|
+
font-size: 14px;
|
|
15
|
+
line-height: 1;
|
|
16
|
+
background: @light-gray-bg;
|
|
17
|
+
}
|
|
18
|
+
.ant-collapse-header > div {
|
|
19
|
+
position: absolute;
|
|
20
|
+
right: 0;
|
|
21
|
+
}
|
|
22
|
+
.ant-collapse-header > div > span {
|
|
23
|
+
color: rgba(142, 142, 142, 0.52);
|
|
24
|
+
}
|
|
25
|
+
.ant-collapse-content > .ant-collapse-content-box {
|
|
26
|
+
padding-bottom: 5px;
|
|
27
|
+
}
|
|
28
|
+
.ant-collapse-content {
|
|
29
|
+
border-top: none;
|
|
30
|
+
}
|
|
31
|
+
.ant-collapse-item {
|
|
32
|
+
border-bottom: none;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ConnectDragPreview, ConnectDragSource } from 'react-dnd';
|
|
2
|
+
import './node-title.less';
|
|
3
|
+
interface Props {
|
|
4
|
+
node: any;
|
|
5
|
+
isRowFirst: boolean;
|
|
6
|
+
sortIndex: number;
|
|
7
|
+
isDragging: boolean;
|
|
8
|
+
connectDragSource: ConnectDragSource;
|
|
9
|
+
connectDragPreview: ConnectDragPreview;
|
|
10
|
+
}
|
|
11
|
+
export declare const NodeTitle: import("react-dnd").DndComponentClass<(props: Props) => JSX.Element, import("react-dnd").Omit<Props, "connectDragSource" | "connectDragPreview" | "isDragging">>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DragSource } from 'react-dnd';
|
|
3
|
+
import marked from 'marked';
|
|
4
|
+
import { DRAGGABLE_ALGO_COMPONENT } from "../../../common/constants/graph";
|
|
5
|
+
import "./node-title.less";
|
|
6
|
+
marked.setOptions({
|
|
7
|
+
gfm: true,
|
|
8
|
+
breaks: true
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
var InnerNodeTitle = function InnerNodeTitle(props) {
|
|
12
|
+
var _props$node = props.node,
|
|
13
|
+
node = _props$node === void 0 ? {} : _props$node,
|
|
14
|
+
isRowFirst = props.isRowFirst,
|
|
15
|
+
sortIndex = props.sortIndex,
|
|
16
|
+
connectDragPreview = props.connectDragPreview,
|
|
17
|
+
connectDragSource = props.connectDragSource;
|
|
18
|
+
var _node$name = node.name,
|
|
19
|
+
name = _node$name === void 0 ? '' : _node$name,
|
|
20
|
+
isDir = node.isDir,
|
|
21
|
+
imgUrl = node.imgUrl; // 文件夹
|
|
22
|
+
|
|
23
|
+
if (isDir) {
|
|
24
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: "folder"
|
|
26
|
+
}, name);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
className: "node-title-wrapper"
|
|
31
|
+
}, connectDragPreview(connectDragSource( /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
className: "node",
|
|
33
|
+
style: {
|
|
34
|
+
marginLeft: !isRowFirst ? -sortIndex : 0
|
|
35
|
+
}
|
|
36
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
37
|
+
alt: name,
|
|
38
|
+
className: "node-icon",
|
|
39
|
+
src: imgUrl || require("../../../assets/application.svg")
|
|
40
|
+
})))), /*#__PURE__*/React.createElement("span", {
|
|
41
|
+
className: "label"
|
|
42
|
+
}, name));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export var NodeTitle = DragSource(DRAGGABLE_ALGO_COMPONENT, {
|
|
46
|
+
beginDrag: function beginDrag(props) {
|
|
47
|
+
return {
|
|
48
|
+
component: props.node
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}, function (connect, monitor) {
|
|
52
|
+
return {
|
|
53
|
+
connectDragSource: connect.dragSource(),
|
|
54
|
+
connectDragPreview: connect.dragPreview(),
|
|
55
|
+
isDragging: monitor.isDragging()
|
|
56
|
+
};
|
|
57
|
+
})(InnerNodeTitle);
|