ronds-metadata 1.2.37 → 1.2.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/es/api/index.js +83 -131
  2. package/es/comps/DynamicPorts/comps/ContextMenu.js +3 -11
  3. package/es/comps/DynamicPorts/comps/DragNode.js +3 -8
  4. package/es/comps/DynamicPorts/comps/GraphHandler/index.js +4 -5
  5. package/es/comps/DynamicPorts/comps/NodeElement.js +1 -4
  6. package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +3 -6
  7. package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +3 -7
  8. package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +18 -21
  9. package/es/comps/DynamicPorts/comps/shape/edge.js +5 -18
  10. package/es/comps/DynamicPorts/comps/shape/node.js +4 -17
  11. package/es/comps/DynamicPorts/constant/index.js +2 -5
  12. package/es/comps/DynamicPorts/graph.d.ts +2 -2
  13. package/es/comps/DynamicPorts/graph.js +228 -312
  14. package/es/comps/DynamicPorts/index.js +39 -58
  15. package/es/comps/DynamicPorts/utils.js +21 -25
  16. package/es/comps/Editable/DataCell/ButtonCell.js +4 -10
  17. package/es/comps/Editable/DataCell/ColorPicker.js +2 -7
  18. package/es/comps/Editable/DataCell/Input.js +5 -14
  19. package/es/comps/Editable/DataCell/Number.js +3 -10
  20. package/es/comps/Editable/DataCell/Select.js +7 -14
  21. package/es/comps/Editable/DataCell/Switch.js +2 -7
  22. package/es/comps/Editable/comps/EditableAction.js +8 -12
  23. package/es/comps/Editable/comps/EditableCell.js +16 -26
  24. package/es/comps/Editable/comps/EditableHeardCell.js +21 -34
  25. package/es/comps/Editable/comps/EditableRow.js +49 -59
  26. package/es/comps/Editable/comps/Texty.js +40 -73
  27. package/es/comps/Editable/index.js +67 -112
  28. package/es/comps/Editable/interface.d.ts +1 -1
  29. package/es/comps/Editable/utils.js +0 -1
  30. package/es/comps/FileView/index.js +65 -101
  31. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Checkbox.js +8 -13
  32. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Color.js +8 -4
  33. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.js +6 -2
  34. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.js +8 -4
  35. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/List.js +6 -11
  36. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.js +6 -10
  37. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.js +6 -2
  38. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Obj.js +6 -11
  39. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Password.js +8 -4
  40. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Radio.js +8 -13
  41. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.js +6 -10
  42. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.js +6 -2
  43. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Table.js +6 -11
  44. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.js +6 -3
  45. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Upload.js +2 -5
  46. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.js +86 -109
  47. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.js +3 -7
  48. package/es/comps/FormGenerator/comps/Canvas/core/index.js +54 -91
  49. package/es/comps/FormGenerator/comps/Canvas/index.js +8 -15
  50. package/es/comps/FormGenerator/comps/Settings/index.js +16 -30
  51. package/es/comps/FormGenerator/comps/Sidebar/Elements.js +23 -22
  52. package/es/comps/FormGenerator/comps/Sidebar/index.js +6 -2
  53. package/es/comps/FormGenerator/index.js +3 -9
  54. package/es/comps/FormGenerator/interface.d.ts +1 -1
  55. package/es/comps/FormGenerator/settings/index.js +12 -11
  56. package/es/comps/FormGenerator/settings/ruleConfig.js +0 -1
  57. package/es/comps/FormGenerator/transformer.js +40 -105
  58. package/es/comps/Icons/index.js +4 -7
  59. package/es/comps/JsonEdit/index.js +25 -50
  60. package/es/comps/JsonView/index.js +7 -21
  61. package/es/comps/MdEdit/index.js +7 -10
  62. package/es/comps/MdEditPro/index.d.ts +10 -0
  63. package/es/comps/MdEditPro/index.js +22 -0
  64. package/es/comps/MdEditPro/index.less +74 -0
  65. package/es/comps/MdNavbar/index.js +17 -40
  66. package/es/comps/MdNavbar/utils.js +0 -4
  67. package/es/comps/MdView/index.js +7 -11
  68. package/es/comps/MetadataEdit/components/MetaFieldsEdit.js +129 -183
  69. package/es/comps/MetadataEdit/components/MetaPropsEdit.js +11 -27
  70. package/es/comps/MetadataEdit/hooks/index.js +3 -11
  71. package/es/comps/MetadataEdit/index.js +25 -58
  72. package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +17 -33
  73. package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +15 -29
  74. package/es/comps/MetadataEditV2/hooks/index.js +5 -12
  75. package/es/comps/MetadataEditV2/index.js +30 -65
  76. package/es/comps/MetadataForm/DataCell/Array.js +12 -23
  77. package/es/comps/MetadataForm/DataCell/Input.js +23 -39
  78. package/es/comps/MetadataForm/DataCell/Number.js +10 -21
  79. package/es/comps/MetadataForm/DataCell/Ref.js +87 -121
  80. package/es/comps/MetadataForm/DataCell/Select.js +131 -226
  81. package/es/comps/MetadataForm/DataCell/Switch.js +7 -14
  82. package/es/comps/MetadataForm/DataCell/layout/TableArray.js +98 -169
  83. package/es/comps/MetadataForm/HOC/index.js +20 -37
  84. package/es/comps/MetadataForm/hooks/index.js +12 -38
  85. package/es/comps/MetadataForm/index.js +37 -72
  86. package/es/comps/MetadataForm/interface.d.ts +3 -3
  87. package/es/comps/MetadataForm/utils.d.ts +1 -0
  88. package/es/comps/MetadataForm/utils.js +12 -14
  89. package/es/comps/Split/index.js +40 -38
  90. package/es/config.js +0 -4
  91. package/es/framework/RxStore/demo/index.js +9 -10
  92. package/es/framework/RxStore/hooks.d.ts +9 -9
  93. package/es/framework/RxStore/hooks.js +10 -35
  94. package/es/framework/RxStore/store.d.ts +4 -4
  95. package/es/framework/RxStore/store.js +0 -10
  96. package/es/framework/fg/index.js +18 -80
  97. package/es/framework/fg/interface.d.ts +2 -2
  98. package/es/framework/fg/utils.js +0 -10
  99. package/es/framework/graph/index.d.ts +2 -2
  100. package/es/framework/graph/index.js +55 -110
  101. package/es/framework/hooks/use-async-memo.js +3 -7
  102. package/es/framework/hooks/use-sync-scroll.js +2 -15
  103. package/es/framework/http/cache.js +25 -32
  104. package/es/framework/http/cancel.js +1 -7
  105. package/es/framework/http/index.js +22 -82
  106. package/es/framework/http/msgpack.js +0 -4
  107. package/es/framework/http/msgpack5/index.js +2 -12
  108. package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +1 -13
  109. package/es/framework/http/msgpack5/lib/decoder.js +10 -68
  110. package/es/framework/http/msgpack5/lib/encoder.js +8 -36
  111. package/es/framework/http/msgpack5/lib/helpers.js +3 -2
  112. package/es/framework/http/msgpack5/lib/streams.js +0 -18
  113. package/es/framework/libs/jquery.min.js +1009 -1696
  114. package/es/framework/locale/dil8/di18n.js +4 -15
  115. package/es/framework/locale/dil8/translate.js +0 -14
  116. package/es/framework/locale/dil8/util.js +0 -3
  117. package/es/framework/locale/index.js +2 -3
  118. package/es/framework/metadata/MetadataService.js +39 -78
  119. package/es/framework/metadata/index.js +4 -70
  120. package/es/framework/rxjs-hooks/useMemoSubject.js +0 -2
  121. package/es/framework/rxjs-hooks/useObservable.js +2 -4
  122. package/es/framework/rxjs-hooks/useObservableState.js +8 -14
  123. package/es/index.d.ts +1 -0
  124. package/es/index.js +2 -1
  125. package/es/utils.js +58 -97
  126. package/package.json +4 -2
  127. package/es/comps/MdEdit/plugin/EditContent.d.ts +0 -5
  128. package/es/comps/MdEdit/plugin/EditContent.js +0 -34
  129. package/es/comps/MdEdit/plugin/Mark.d.ts +0 -7
  130. package/es/comps/MdEdit/plugin/Mark.js +0 -60
  131. 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
- refId = props.refId,
23
- isShowAction = props.isShowAction;
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
- _React$useState2 = _slicedToArray(_React$useState, 2),
29
- cellSetting = _React$useState2[0],
30
- setCellSetting = _React$useState2[1];
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
- _React$useState4 = _slicedToArray(_React$useState3, 2),
34
- types = _React$useState4[0],
35
- setTypes = _React$useState4[1];
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
- _React$useState6 = _slicedToArray(_React$useState5, 2),
39
- position = _React$useState6[0],
40
- setPosition = _React$useState6[1];
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
- item: {
66
- dragItem: data,
67
- type: dragItemType
68
- },
69
- end: function end(item, monitor) {
70
- var dropResult = monitor.getDropResult();
71
-
72
- if (item && dropResult) {}
73
- },
74
- collect: function collect(monitor) {
75
- return {
76
- isDragging: monitor.isDragging()
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
- dragPreview = _useDrag2[2]; // 处理组件拖拽落下事件
86
-
80
+ dragPreview = _useDrag2[2];
81
+ // 处理组件拖拽落下事件
87
82
  var _useDrop = useDrop({
88
- accept: [dragItemType],
89
- drop: function drop(item, monitor) {
90
- // 如果 children 已经作为了 drop target,不处理
91
- var didDrop = monitor.didDrop();
92
-
93
- if (didDrop) {
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
- hover: function hover(item, monitor) {
108
- // 只检查被hover的最小元素
109
- var didHover = monitor.isOver({
110
- shallow: true
111
- });
112
-
113
- if (didHover) {
114
- if (item.dragItem.id === data.id) return; // Determine rectangle on screen
115
-
116
- // Determine rectangle on screen
117
- var hoverBoundingRect = boxRef.current && boxRef.current.getBoundingClientRect(); // Get vertical middle
118
-
119
- // Get vertical middle
120
- var hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2; // Determine mouse position
121
- // const clientOffset = monitor.getClientOffset();
122
-
123
- // Determine mouse position
124
- // const clientOffset = monitor.getClientOffset();
125
- var dragOffset = monitor.getSourceClientOffset(); // Get pixels to the top
126
-
127
- // Get pixels to the top
128
- var hoverClientY = dragOffset.y - hoverBoundingRect.top;
129
-
130
- if (hoverClientY <= hoverMiddleY) {
131
- setPosition('borderTop');
132
- } // Dragging upwards
133
-
134
-
135
- // Dragging upwards
136
- if (hoverClientY > hoverMiddleY) {
137
- setPosition('borderBottom');
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
- collect: function collect(monitor) {
142
- return {
143
- isOver: monitor.isOver({
144
- shallow: true
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
- refId = props.refId,
26
- _props$isShowAction = props.isShowAction,
27
- isShowAction = _props$isShowAction === void 0 ? false : _props$isShowAction;
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
- nodes = props.nodes,
24
- onChange = props.onChange;
26
+ nodes = props.nodes,
27
+ onChange = props.onChange;
25
28
  var fGCtx = React.useContext(FGCtx) || {};
26
-
27
29
  var _React$useState = React.useState([]),
28
- _React$useState2 = _slicedToArray(_React$useState, 2),
29
- list = _React$useState2[0],
30
- setList = _React$useState2[1];
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
- _React$useState4 = _slicedToArray(_React$useState3, 2),
36
- curNodeId = _React$useState4[0],
37
- setCurNodeId = _React$useState4[1];
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
- _React$useState6 = _slicedToArray(_React$useState5, 2),
41
- formSetting = _React$useState6[0],
42
- setFormSetting = _React$useState6[1];
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
- _React$useState8 = _slicedToArray(_React$useState7, 2),
46
- allSetting = _React$useState8[0],
47
- setAllSetting = _React$useState8[1];
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
- accept: [dragItemType],
203
- drop: function drop(item, monitor) {
204
- // 如果 children 已经作为了 drop target,不处理
205
- var didDrop = monitor.didDrop();
206
-
207
- if (didDrop) {
208
- return;
209
- }
210
-
211
- addNewNode(item.dragItem);
212
- },
213
- hover: function hover(item, monitor) {
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
- canDrop: monitor.canDrop()
227
- };
228
- }
229
- }),
230
- _useDrop2 = _slicedToArray(_useDrop, 2),
231
- _useDrop2$ = _useDrop2[0],
232
- isOver = _useDrop2$.isOver,
233
- canDrop = _useDrop2$.canDrop,
234
- dropRef = _useDrop2[1];
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);