ronds-metadata 1.2.37 → 1.2.39
Sign up to get free protection for your applications and to get access to all the features.
- package/es/api/index.js +83 -131
- package/es/comps/DynamicPorts/comps/ContextMenu.js +3 -11
- package/es/comps/DynamicPorts/comps/DragNode.js +3 -8
- package/es/comps/DynamicPorts/comps/GraphHandler/index.js +4 -5
- package/es/comps/DynamicPorts/comps/NodeElement.js +1 -4
- package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +3 -6
- package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +3 -7
- package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +18 -21
- package/es/comps/DynamicPorts/comps/shape/edge.js +5 -18
- package/es/comps/DynamicPorts/comps/shape/node.js +4 -17
- package/es/comps/DynamicPorts/constant/index.js +2 -5
- package/es/comps/DynamicPorts/graph.d.ts +2 -2
- package/es/comps/DynamicPorts/graph.js +228 -312
- package/es/comps/DynamicPorts/index.js +39 -58
- package/es/comps/DynamicPorts/utils.js +21 -25
- package/es/comps/Editable/DataCell/ButtonCell.js +4 -10
- package/es/comps/Editable/DataCell/ColorPicker.js +2 -7
- package/es/comps/Editable/DataCell/Input.js +5 -14
- package/es/comps/Editable/DataCell/Number.js +3 -10
- package/es/comps/Editable/DataCell/Select.js +7 -14
- package/es/comps/Editable/DataCell/Switch.js +2 -7
- package/es/comps/Editable/comps/EditableAction.js +8 -12
- package/es/comps/Editable/comps/EditableCell.js +16 -26
- package/es/comps/Editable/comps/EditableHeardCell.js +21 -34
- package/es/comps/Editable/comps/EditableRow.js +49 -59
- package/es/comps/Editable/comps/Texty.js +40 -73
- package/es/comps/Editable/index.js +67 -112
- package/es/comps/Editable/interface.d.ts +1 -1
- package/es/comps/Editable/utils.js +0 -1
- package/es/comps/FileView/index.js +65 -101
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Checkbox.js +8 -13
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Color.js +8 -4
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.js +6 -2
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.js +8 -4
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/List.js +6 -11
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.js +6 -10
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.js +6 -2
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Obj.js +6 -11
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Password.js +8 -4
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Radio.js +8 -13
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.js +6 -10
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.js +6 -2
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Table.js +6 -11
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.js +6 -3
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Upload.js +2 -5
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.js +86 -109
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.js +3 -7
- package/es/comps/FormGenerator/comps/Canvas/core/index.js +54 -91
- package/es/comps/FormGenerator/comps/Canvas/index.js +8 -15
- package/es/comps/FormGenerator/comps/Settings/index.js +16 -30
- package/es/comps/FormGenerator/comps/Sidebar/Elements.js +23 -22
- package/es/comps/FormGenerator/comps/Sidebar/index.js +6 -2
- package/es/comps/FormGenerator/index.js +3 -9
- package/es/comps/FormGenerator/interface.d.ts +1 -1
- package/es/comps/FormGenerator/settings/index.js +12 -11
- package/es/comps/FormGenerator/settings/ruleConfig.js +0 -1
- package/es/comps/FormGenerator/transformer.js +40 -105
- package/es/comps/Icons/index.js +4 -7
- package/es/comps/JsonEdit/index.js +25 -50
- package/es/comps/JsonView/index.js +7 -21
- package/es/comps/MdEdit/index.js +7 -10
- package/es/comps/MdEditPro/index.d.ts +10 -0
- package/es/comps/MdEditPro/index.js +22 -0
- package/es/comps/MdEditPro/index.less +74 -0
- package/es/comps/MdNavbar/index.js +17 -40
- package/es/comps/MdNavbar/utils.js +0 -4
- package/es/comps/MdView/index.js +7 -11
- package/es/comps/MetadataEdit/components/MetaFieldsEdit.js +129 -183
- package/es/comps/MetadataEdit/components/MetaPropsEdit.js +11 -27
- package/es/comps/MetadataEdit/hooks/index.js +3 -11
- package/es/comps/MetadataEdit/index.js +25 -58
- package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +17 -33
- package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +15 -29
- package/es/comps/MetadataEditV2/hooks/index.js +5 -12
- package/es/comps/MetadataEditV2/index.js +30 -65
- package/es/comps/MetadataForm/DataCell/Array.js +12 -23
- package/es/comps/MetadataForm/DataCell/Input.js +23 -39
- package/es/comps/MetadataForm/DataCell/Number.js +10 -21
- package/es/comps/MetadataForm/DataCell/Ref.js +87 -121
- package/es/comps/MetadataForm/DataCell/Select.js +131 -226
- package/es/comps/MetadataForm/DataCell/Switch.js +7 -14
- package/es/comps/MetadataForm/DataCell/layout/TableArray.js +98 -169
- package/es/comps/MetadataForm/HOC/index.js +20 -37
- package/es/comps/MetadataForm/hooks/index.js +12 -38
- package/es/comps/MetadataForm/index.js +37 -72
- package/es/comps/MetadataForm/interface.d.ts +3 -3
- package/es/comps/MetadataForm/utils.d.ts +1 -0
- package/es/comps/MetadataForm/utils.js +12 -14
- package/es/comps/Split/index.js +40 -38
- package/es/config.js +0 -4
- package/es/framework/RxStore/demo/index.js +9 -10
- package/es/framework/RxStore/hooks.d.ts +9 -9
- package/es/framework/RxStore/hooks.js +10 -35
- package/es/framework/RxStore/store.d.ts +4 -4
- package/es/framework/RxStore/store.js +0 -10
- package/es/framework/fg/index.js +18 -80
- package/es/framework/fg/interface.d.ts +2 -2
- package/es/framework/fg/utils.js +0 -10
- package/es/framework/graph/index.d.ts +2 -2
- package/es/framework/graph/index.js +55 -110
- package/es/framework/hooks/use-async-memo.js +3 -7
- package/es/framework/hooks/use-sync-scroll.js +2 -15
- package/es/framework/http/cache.js +25 -32
- package/es/framework/http/cancel.js +1 -7
- package/es/framework/http/index.js +22 -82
- package/es/framework/http/msgpack.js +0 -4
- package/es/framework/http/msgpack5/index.js +2 -12
- package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +1 -13
- package/es/framework/http/msgpack5/lib/decoder.js +10 -68
- package/es/framework/http/msgpack5/lib/encoder.js +8 -36
- package/es/framework/http/msgpack5/lib/helpers.js +3 -2
- package/es/framework/http/msgpack5/lib/streams.js +0 -18
- package/es/framework/libs/jquery.min.js +1009 -1696
- package/es/framework/locale/dil8/di18n.js +4 -15
- package/es/framework/locale/dil8/translate.js +0 -14
- package/es/framework/locale/dil8/util.js +0 -3
- package/es/framework/locale/index.js +2 -3
- package/es/framework/metadata/MetadataService.js +39 -78
- package/es/framework/metadata/index.js +4 -70
- package/es/framework/rxjs-hooks/useMemoSubject.js +0 -2
- package/es/framework/rxjs-hooks/useObservable.js +2 -4
- package/es/framework/rxjs-hooks/useObservableState.js +8 -14
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/utils.js +58 -97
- package/package.json +4 -2
- package/es/comps/MdEdit/plugin/EditContent.d.ts +0 -5
- package/es/comps/MdEdit/plugin/EditContent.js +0 -34
- package/es/comps/MdEdit/plugin/Mark.d.ts +0 -7
- package/es/comps/MdEdit/plugin/Mark.js +0 -60
- package/es/framework/libs/iconfont/iconfont.json +0 -401
@@ -8,6 +8,11 @@ import _Tooltip from "antd/es/tooltip";
|
|
8
8
|
import _objectDestructuringEmpty from "@babel/runtime/helpers/esm/objectDestructuringEmpty";
|
9
9
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
10
10
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
11
|
+
/*
|
12
|
+
* @Author: wangxian
|
13
|
+
* @Date: 2021-09-18 14:15:04
|
14
|
+
* @LastEditTime: 2023-02-28 13:59:21
|
15
|
+
*/
|
11
16
|
import React from 'react';
|
12
17
|
import { useDrag, useDrop } from 'react-dnd';
|
13
18
|
import { DragOutlined, SnippetsOutlined, DeleteOutlined } from '@ant-design/icons';
|
@@ -17,28 +22,23 @@ import useObservable from '../../../../../../../framework/rxjs-hooks/useObservab
|
|
17
22
|
export function withFieldCellWrapper(WrappedComponent) {
|
18
23
|
return function (props) {
|
19
24
|
var _cellSetting$depend, _cellSetting$depend2, _cellSetting$depend3, _cellSetting$depend4, _cellSetting$depend5, _cellSetting$depend6;
|
20
|
-
|
21
25
|
var data = props.data,
|
22
|
-
|
23
|
-
|
26
|
+
refId = props.refId,
|
27
|
+
isShowAction = props.isShowAction;
|
24
28
|
var fGCtx = React.useContext(FGCtx) || {};
|
25
29
|
var boxRef = React.useRef(null);
|
26
|
-
|
27
30
|
var _React$useState = React.useState(),
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
32
|
+
cellSetting = _React$useState2[0],
|
33
|
+
setCellSetting = _React$useState2[1];
|
32
34
|
var _React$useState3 = React.useState(),
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
36
|
+
types = _React$useState4[0],
|
37
|
+
setTypes = _React$useState4[1];
|
37
38
|
var _React$useState5 = React.useState(),
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
40
|
+
position = _React$useState6[0],
|
41
|
+
setPosition = _React$useState6[1];
|
42
42
|
React.useEffect(function () {
|
43
43
|
if ((fGCtx === null || fGCtx === void 0 ? void 0 : fGCtx.types) && (fGCtx === null || fGCtx === void 0 ? void 0 : fGCtx.types[data.id])) {
|
44
44
|
//
|
@@ -53,106 +53,89 @@ export function withFieldCellWrapper(WrappedComponent) {
|
|
53
53
|
setCellSetting(_objectSpread({}, p === null || p === void 0 ? void 0 : p.payload[data.id]));
|
54
54
|
}
|
55
55
|
}
|
56
|
-
|
57
56
|
break;
|
58
57
|
}
|
59
58
|
}, []);
|
60
59
|
useObservable(function (p) {
|
61
60
|
processFgStreamData(p);
|
62
61
|
}, [fGCtx.fgStream]);
|
63
|
-
|
64
62
|
var _useDrag = useDrag({
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
_useDrag2 = _slicedToArray(_useDrag, 3);
|
81
|
-
|
63
|
+
item: {
|
64
|
+
dragItem: data,
|
65
|
+
type: dragItemType
|
66
|
+
},
|
67
|
+
end: function end(item, monitor) {
|
68
|
+
var dropResult = monitor.getDropResult();
|
69
|
+
if (item && dropResult) {}
|
70
|
+
},
|
71
|
+
collect: function collect(monitor) {
|
72
|
+
return {
|
73
|
+
isDragging: monitor.isDragging()
|
74
|
+
};
|
75
|
+
}
|
76
|
+
}),
|
77
|
+
_useDrag2 = _slicedToArray(_useDrag, 3);
|
82
78
|
_objectDestructuringEmpty(_useDrag2[0]);
|
83
|
-
|
84
79
|
var drag = _useDrag2[1],
|
85
|
-
|
86
|
-
|
80
|
+
dragPreview = _useDrag2[2];
|
81
|
+
// 处理组件拖拽落下事件
|
87
82
|
var _useDrop = useDrop({
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
return;
|
95
|
-
}
|
96
|
-
|
97
|
-
(fGCtx === null || fGCtx === void 0 ? void 0 : fGCtx.fgStream) && fGCtx.fgStream.next({
|
98
|
-
type: streamEventType.onDropOver,
|
99
|
-
payload: {
|
100
|
-
dragItem: item.dragItem,
|
101
|
-
dropId: data.id,
|
102
|
-
position: position,
|
103
|
-
refId: refId
|
83
|
+
accept: [dragItemType],
|
84
|
+
drop: function drop(item, monitor) {
|
85
|
+
// 如果 children 已经作为了 drop target,不处理
|
86
|
+
var didDrop = monitor.didDrop();
|
87
|
+
if (didDrop) {
|
88
|
+
return;
|
104
89
|
}
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
//
|
117
|
-
var
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
90
|
+
(fGCtx === null || fGCtx === void 0 ? void 0 : fGCtx.fgStream) && fGCtx.fgStream.next({
|
91
|
+
type: streamEventType.onDropOver,
|
92
|
+
payload: {
|
93
|
+
dragItem: item.dragItem,
|
94
|
+
dropId: data.id,
|
95
|
+
position: position,
|
96
|
+
refId: refId
|
97
|
+
}
|
98
|
+
});
|
99
|
+
},
|
100
|
+
hover: function hover(item, monitor) {
|
101
|
+
// 只检查被hover的最小元素
|
102
|
+
var didHover = monitor.isOver({
|
103
|
+
shallow: true
|
104
|
+
});
|
105
|
+
if (didHover) {
|
106
|
+
if (item.dragItem.id === data.id) return;
|
107
|
+
// Determine rectangle on screen
|
108
|
+
var hoverBoundingRect = boxRef.current && boxRef.current.getBoundingClientRect();
|
109
|
+
// Get vertical middle
|
110
|
+
var hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
|
111
|
+
// Determine mouse position
|
112
|
+
// const clientOffset = monitor.getClientOffset();
|
113
|
+
var dragOffset = monitor.getSourceClientOffset();
|
114
|
+
// Get pixels to the top
|
115
|
+
var hoverClientY = dragOffset.y - hoverBoundingRect.top;
|
116
|
+
if (hoverClientY <= hoverMiddleY) {
|
117
|
+
setPosition('borderTop');
|
118
|
+
}
|
119
|
+
// Dragging upwards
|
120
|
+
if (hoverClientY > hoverMiddleY) {
|
121
|
+
setPosition('borderBottom');
|
122
|
+
}
|
138
123
|
}
|
124
|
+
},
|
125
|
+
collect: function collect(monitor) {
|
126
|
+
return {
|
127
|
+
isOver: monitor.isOver({
|
128
|
+
shallow: true
|
129
|
+
}),
|
130
|
+
canDrop: monitor.canDrop()
|
131
|
+
};
|
139
132
|
}
|
140
|
-
},
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
canDrop: monitor.canDrop()
|
147
|
-
};
|
148
|
-
}
|
149
|
-
}),
|
150
|
-
_useDrop2 = _slicedToArray(_useDrop, 2),
|
151
|
-
_useDrop2$ = _useDrop2[0],
|
152
|
-
canDrop = _useDrop2$.canDrop,
|
153
|
-
isOver = _useDrop2$.isOver,
|
154
|
-
dropRef = _useDrop2[1];
|
155
|
-
|
133
|
+
}),
|
134
|
+
_useDrop2 = _slicedToArray(_useDrop, 2),
|
135
|
+
_useDrop2$ = _useDrop2[0],
|
136
|
+
canDrop = _useDrop2$.canDrop,
|
137
|
+
isOver = _useDrop2$.isOver,
|
138
|
+
dropRef = _useDrop2[1];
|
156
139
|
var onNodeDelete = function onNodeDelete(e) {
|
157
140
|
e.stopPropagation();
|
158
141
|
fGCtx.fgStream && fGCtx.fgStream.next({
|
@@ -163,7 +146,6 @@ export function withFieldCellWrapper(WrappedComponent) {
|
|
163
146
|
}
|
164
147
|
});
|
165
148
|
};
|
166
|
-
|
167
149
|
var onNodeCopy = function onNodeCopy(e) {
|
168
150
|
e.stopPropagation();
|
169
151
|
fGCtx.fgStream && fGCtx.fgStream.next({
|
@@ -171,24 +153,19 @@ export function withFieldCellWrapper(WrappedComponent) {
|
|
171
153
|
payload: data
|
172
154
|
});
|
173
155
|
};
|
174
|
-
|
175
156
|
var isActive = canDrop && isOver;
|
176
157
|
dragPreview(dropRef(boxRef));
|
177
|
-
|
178
158
|
var getBorder = function getBorder(_position) {
|
179
159
|
var _style = {
|
180
160
|
width: '100%',
|
181
161
|
height: '100%',
|
182
162
|
padding: '4px 10px'
|
183
163
|
};
|
184
|
-
|
185
164
|
if (_position && isActive) {
|
186
165
|
_style[_position] = '2px solid red';
|
187
166
|
}
|
188
|
-
|
189
167
|
return _style;
|
190
168
|
};
|
191
|
-
|
192
169
|
return /*#__PURE__*/React.createElement("div", {
|
193
170
|
ref: boxRef,
|
194
171
|
style: _objectSpread({}, getBorder(position))
|
@@ -19,15 +19,13 @@ import Upload from './Cell/Upload';
|
|
19
19
|
import Obj from './Cell/Obj';
|
20
20
|
import List from './Cell/List';
|
21
21
|
import Table from './Cell/Table';
|
22
|
-
|
23
22
|
var RenderField = function RenderField(props) {
|
24
23
|
var data = props.data,
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
refId = props.refId,
|
25
|
+
_props$isShowAction = props.isShowAction,
|
26
|
+
isShowAction = _props$isShowAction === void 0 ? false : _props$isShowAction;
|
28
27
|
var FieldContent = React.useMemo(function () {
|
29
28
|
var _content = /*#__PURE__*/React.createElement(React.Fragment, null);
|
30
|
-
|
31
29
|
if (data.type && DataCellMap[data.type]) {
|
32
30
|
var Comm = DataCellMap[data.type];
|
33
31
|
return /*#__PURE__*/React.createElement(Comm, {
|
@@ -36,12 +34,10 @@ var RenderField = function RenderField(props) {
|
|
36
34
|
isShowAction: isShowAction
|
37
35
|
});
|
38
36
|
}
|
39
|
-
|
40
37
|
return _content;
|
41
38
|
}, [data, isShowAction]);
|
42
39
|
return /*#__PURE__*/React.createElement(React.Fragment, null, FieldContent);
|
43
40
|
};
|
44
|
-
|
45
41
|
export default RenderField;
|
46
42
|
var DataCellMap = {
|
47
43
|
input: Input,
|
@@ -7,6 +7,11 @@ import _Col from "antd/es/col";
|
|
7
7
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
8
8
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
9
9
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
10
|
+
/*
|
11
|
+
* @Author: wangxian
|
12
|
+
* @Date: 2023-02-06 09:46:17
|
13
|
+
* @LastEditTime: 2023-02-27 11:06:05
|
14
|
+
*/
|
10
15
|
import React from 'react';
|
11
16
|
import { useDrop } from 'react-dnd';
|
12
17
|
import { FGCtx } from '../../../../../comps/FormGenerator/Provider';
|
@@ -15,78 +20,63 @@ import useObservable from '../../../../../framework/rxjs-hooks/useObservable';
|
|
15
20
|
import { arrayInsert, arrayMoveImmutable, guid } from '../../../../../utils';
|
16
21
|
import RenderField from './RenderField';
|
17
22
|
import './index.less';
|
18
|
-
|
19
23
|
var CanvasCore = function CanvasCore(props) {
|
20
24
|
var _formSetting$layout;
|
21
|
-
|
22
25
|
var refId = props.refId,
|
23
|
-
|
24
|
-
|
26
|
+
nodes = props.nodes,
|
27
|
+
onChange = props.onChange;
|
25
28
|
var fGCtx = React.useContext(FGCtx) || {};
|
26
|
-
|
27
29
|
var _React$useState = React.useState([]),
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
31
|
+
list = _React$useState2[0],
|
32
|
+
setList = _React$useState2[1];
|
32
33
|
var listRef = React.useRef([]);
|
33
|
-
|
34
34
|
var _React$useState3 = React.useState(),
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
36
|
+
curNodeId = _React$useState4[0],
|
37
|
+
setCurNodeId = _React$useState4[1];
|
39
38
|
var _React$useState5 = React.useState(_formSetting.param.defaultValue),
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
40
|
+
formSetting = _React$useState6[0],
|
41
|
+
setFormSetting = _React$useState6[1];
|
44
42
|
var _React$useState7 = React.useState(),
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
44
|
+
allSetting = _React$useState8[0],
|
45
|
+
setAllSetting = _React$useState8[1];
|
49
46
|
var allSettingRef = React.useRef();
|
50
47
|
React.useEffect(function () {
|
51
48
|
if (refId && nodes.length > 0) {
|
52
49
|
setList(_toConsumableArray(nodes));
|
53
50
|
listRef.current = nodes;
|
54
51
|
}
|
55
|
-
}, [refId, nodes]);
|
56
|
-
|
52
|
+
}, [refId, nodes]);
|
53
|
+
// 处理默认数据
|
57
54
|
var processDefaultValue = React.useCallback(function (data) {
|
58
55
|
if (!refId) {
|
59
56
|
setList(_toConsumableArray(data.nodes));
|
60
57
|
listRef.current = data.nodes;
|
61
|
-
|
62
58
|
if (data.types) {
|
63
59
|
fGCtx.fgStream && fGCtx.fgStream.next({
|
64
60
|
type: streamEventType.onTypesChange,
|
65
61
|
payload: data.types
|
66
62
|
});
|
67
63
|
}
|
68
|
-
|
69
64
|
onChange && onChange(data.nodes);
|
70
65
|
}
|
71
66
|
}, []);
|
72
67
|
var addNewNode = React.useCallback(function (_node, dropId, position) {
|
73
68
|
var _newNode;
|
74
|
-
|
75
69
|
var _list = listRef.current;
|
76
70
|
var newNode = _node;
|
77
|
-
|
78
71
|
var oldIdx = _list.findIndex(function (it) {
|
79
72
|
return it.id === _node.id;
|
80
73
|
});
|
81
|
-
|
82
74
|
if (dropId && position) {
|
83
75
|
//先判断是新增还是改变顺序
|
84
76
|
var newIdx = _list.findIndex(function (it) {
|
85
77
|
return it.id === dropId;
|
86
78
|
});
|
87
|
-
|
88
79
|
newIdx = position === 'borderTop' ? newIdx : newIdx + 1;
|
89
|
-
|
90
80
|
if (oldIdx === -1) {
|
91
81
|
newNode = _objectSpread(_objectSpread({}, _node), {}, {
|
92
82
|
id: "".concat(_node.id.split('-')[0], "-").concat(guid().substring(0, 4))
|
@@ -101,11 +91,9 @@ var CanvasCore = function CanvasCore(props) {
|
|
101
91
|
newNode = _objectSpread(_objectSpread({}, _node), {}, {
|
102
92
|
id: "".concat(_node.id.split('-')[0], "-").concat(guid().substring(0, 4))
|
103
93
|
});
|
104
|
-
|
105
94
|
_list.push(newNode);
|
106
95
|
}
|
107
96
|
}
|
108
|
-
|
109
97
|
if ((_newNode = newNode) === null || _newNode === void 0 ? void 0 : _newNode.id) {
|
110
98
|
fGCtx.fgStream && fGCtx.fgStream.next({
|
111
99
|
type: streamEventType.onNodeSelect,
|
@@ -115,36 +103,29 @@ var CanvasCore = function CanvasCore(props) {
|
|
115
103
|
}
|
116
104
|
});
|
117
105
|
}
|
118
|
-
|
119
106
|
setList(_toConsumableArray(_list));
|
120
107
|
listRef.current = _list;
|
121
108
|
onChange && onChange(_list);
|
122
109
|
}, []);
|
123
110
|
var processFgStreamData = React.useCallback(function (p) {
|
124
111
|
var _p$payload, _p$payload$node, _p$payload2, _p$payload3, _p$payload4;
|
125
|
-
|
126
112
|
switch (p === null || p === void 0 ? void 0 : p.type) {
|
127
113
|
case streamEventType.onNodeSelect:
|
128
114
|
setCurNodeId(p === null || p === void 0 ? void 0 : (_p$payload = p.payload) === null || _p$payload === void 0 ? void 0 : (_p$payload$node = _p$payload.node) === null || _p$payload$node === void 0 ? void 0 : _p$payload$node.id);
|
129
115
|
break;
|
130
|
-
|
131
116
|
case streamEventType.onClearCanvas:
|
132
117
|
setList([]);
|
133
118
|
listRef.current = [];
|
134
119
|
onChange && onChange([]);
|
135
120
|
break;
|
136
|
-
|
137
121
|
case streamEventType.onDropOver:
|
138
122
|
if (refId === ((_p$payload2 = p.payload) === null || _p$payload2 === void 0 ? void 0 : _p$payload2.refId)) {
|
139
123
|
addNewNode(p.payload.dragItem, p.payload.dropId, p.payload.position);
|
140
124
|
}
|
141
|
-
|
142
125
|
break;
|
143
|
-
|
144
126
|
case streamEventType.onNodeCopy:
|
145
127
|
addNewNode(p.payload);
|
146
128
|
break;
|
147
|
-
|
148
129
|
case streamEventType.onNodeDelete:
|
149
130
|
if (refId === ((_p$payload3 = p.payload) === null || _p$payload3 === void 0 ? void 0 : _p$payload3.refId)) {
|
150
131
|
var _list = listRef.current;
|
@@ -153,8 +134,8 @@ var CanvasCore = function CanvasCore(props) {
|
|
153
134
|
});
|
154
135
|
setList(_toConsumableArray(_list));
|
155
136
|
listRef.current = _list;
|
156
|
-
onChange && onChange(_list);
|
157
|
-
|
137
|
+
onChange && onChange(_list);
|
138
|
+
// 默认焦点放在第一个
|
158
139
|
if (_list.length > 0) {
|
159
140
|
onSelect(_list[0]);
|
160
141
|
} else {
|
@@ -163,32 +144,24 @@ var CanvasCore = function CanvasCore(props) {
|
|
163
144
|
});
|
164
145
|
}
|
165
146
|
}
|
166
|
-
|
167
147
|
break;
|
168
|
-
|
169
148
|
case streamEventType.onSettingValueChange:
|
170
149
|
if (p === null || p === void 0 ? void 0 : (_p$payload4 = p.payload) === null || _p$payload4 === void 0 ? void 0 : _p$payload4.formSetting) {
|
171
150
|
var _p$payload5;
|
172
|
-
|
173
151
|
setFormSetting(_objectSpread({}, p === null || p === void 0 ? void 0 : (_p$payload5 = p.payload) === null || _p$payload5 === void 0 ? void 0 : _p$payload5.formSetting));
|
174
152
|
}
|
175
|
-
|
176
153
|
if ((p === null || p === void 0 ? void 0 : p.payload.refId) === refId) {
|
177
154
|
if (refId) {
|
178
155
|
var _p$payload6, _p$payload7;
|
179
|
-
|
180
156
|
setAllSetting(_objectSpread({}, p === null || p === void 0 ? void 0 : (_p$payload6 = p.payload) === null || _p$payload6 === void 0 ? void 0 : _p$payload6.allSetting[refId]));
|
181
157
|
allSettingRef.current = _objectSpread({}, p === null || p === void 0 ? void 0 : (_p$payload7 = p.payload) === null || _p$payload7 === void 0 ? void 0 : _p$payload7.allSetting[refId]);
|
182
158
|
} else {
|
183
159
|
var _p$payload8, _p$payload9;
|
184
|
-
|
185
160
|
setAllSetting(_objectSpread({}, p === null || p === void 0 ? void 0 : (_p$payload8 = p.payload) === null || _p$payload8 === void 0 ? void 0 : _p$payload8.allSetting));
|
186
161
|
allSettingRef.current = _objectSpread({}, p === null || p === void 0 ? void 0 : (_p$payload9 = p.payload) === null || _p$payload9 === void 0 ? void 0 : _p$payload9.allSetting);
|
187
162
|
}
|
188
163
|
}
|
189
|
-
|
190
164
|
break;
|
191
|
-
|
192
165
|
case streamEventType.onDefaultValue:
|
193
166
|
processDefaultValue(p === null || p === void 0 ? void 0 : p.payload);
|
194
167
|
break;
|
@@ -196,43 +169,39 @@ var CanvasCore = function CanvasCore(props) {
|
|
196
169
|
}, []);
|
197
170
|
useObservable(function (p) {
|
198
171
|
processFgStreamData(p);
|
199
|
-
}, [fGCtx.fgStream]);
|
200
|
-
|
172
|
+
}, [fGCtx.fgStream]);
|
173
|
+
// 处理组件拖拽落下事件
|
201
174
|
var _useDrop = useDrop({
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
// 只检查被hover的最小元素
|
215
|
-
var didHover = monitor.isOver({
|
216
|
-
shallow: true
|
217
|
-
});
|
218
|
-
|
219
|
-
if (didHover) {}
|
220
|
-
},
|
221
|
-
collect: function collect(monitor) {
|
222
|
-
return {
|
223
|
-
isOver: monitor.isOver({
|
175
|
+
accept: [dragItemType],
|
176
|
+
drop: function drop(item, monitor) {
|
177
|
+
// 如果 children 已经作为了 drop target,不处理
|
178
|
+
var didDrop = monitor.didDrop();
|
179
|
+
if (didDrop) {
|
180
|
+
return;
|
181
|
+
}
|
182
|
+
addNewNode(item.dragItem);
|
183
|
+
},
|
184
|
+
hover: function hover(item, monitor) {
|
185
|
+
// 只检查被hover的最小元素
|
186
|
+
var didHover = monitor.isOver({
|
224
187
|
shallow: true
|
225
|
-
})
|
226
|
-
|
227
|
-
}
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
188
|
+
});
|
189
|
+
if (didHover) {}
|
190
|
+
},
|
191
|
+
collect: function collect(monitor) {
|
192
|
+
return {
|
193
|
+
isOver: monitor.isOver({
|
194
|
+
shallow: true
|
195
|
+
}),
|
196
|
+
canDrop: monitor.canDrop()
|
197
|
+
};
|
198
|
+
}
|
199
|
+
}),
|
200
|
+
_useDrop2 = _slicedToArray(_useDrop, 2),
|
201
|
+
_useDrop2$ = _useDrop2[0],
|
202
|
+
isOver = _useDrop2$.isOver,
|
203
|
+
canDrop = _useDrop2$.canDrop,
|
204
|
+
dropRef = _useDrop2[1];
|
236
205
|
var onSelect = function onSelect(it) {
|
237
206
|
fGCtx.fgStream && fGCtx.fgStream.next({
|
238
207
|
type: streamEventType.onNodeSelect,
|
@@ -242,17 +211,13 @@ var CanvasCore = function CanvasCore(props) {
|
|
242
211
|
}
|
243
212
|
});
|
244
213
|
};
|
245
|
-
|
246
214
|
var processColSpan = function processColSpan(compColSpan, formColSpan) {
|
247
215
|
var _formColSpan = formColSpan !== null && formColSpan !== void 0 ? formColSpan : 24;
|
248
|
-
|
249
216
|
if (compColSpan) {
|
250
217
|
return compColSpan * _formColSpan <= 24 ? compColSpan * _formColSpan : 24;
|
251
218
|
}
|
252
|
-
|
253
219
|
return _formColSpan;
|
254
220
|
};
|
255
|
-
|
256
221
|
var isActive = canDrop && isOver;
|
257
222
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
258
223
|
className: "canvas-wrapper",
|
@@ -282,7 +247,6 @@ var CanvasCore = function CanvasCore(props) {
|
|
282
247
|
gutter: 8
|
283
248
|
}, list.length > 0 && list.map(function (it) {
|
284
249
|
var _allSetting$it$id;
|
285
|
-
|
286
250
|
return /*#__PURE__*/React.createElement(_Col, {
|
287
251
|
key: it.id,
|
288
252
|
span: processColSpan(allSetting && ((_allSetting$it$id = allSetting[it.id]) === null || _allSetting$it$id === void 0 ? void 0 : _allSetting$it$id.colSpan), formSetting === null || formSetting === void 0 ? void 0 : formSetting.colSpan),
|
@@ -311,5 +275,4 @@ var CanvasCore = function CanvasCore(props) {
|
|
311
275
|
}
|
312
276
|
}, "\u62D6\u62FD\u5DE6\u4FA7\u680F\u7684\u7EC4\u4EF6\u8FDB\u884C\u6DFB\u52A0")))));
|
313
277
|
};
|
314
|
-
|
315
278
|
export default /*#__PURE__*/React.memo(CanvasCore);
|