ronds-metadata 1.2.10 → 1.2.11
Sign up to get free protection for your applications and to get access to all the features.
- package/es/api/index.js +249 -0
- package/es/comps/DynamicPorts/comps/ContextMenu.js +44 -0
- package/es/comps/DynamicPorts/comps/DragNode.js +55 -0
- package/es/comps/DynamicPorts/comps/GraphHandler/index.js +51 -0
- package/es/comps/DynamicPorts/comps/NodeElement.js +30 -0
- package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +42 -0
- package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +40 -0
- package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +55 -0
- package/es/comps/DynamicPorts/comps/shape/connector.js +19 -0
- package/es/comps/DynamicPorts/comps/shape/edge.js +91 -0
- package/es/comps/DynamicPorts/comps/shape/node.js +190 -0
- package/es/comps/DynamicPorts/constant/index.js +19 -0
- package/es/comps/DynamicPorts/graph.js +697 -0
- package/es/comps/DynamicPorts/index.js +143 -0
- package/es/comps/DynamicPorts/interface.js +6 -0
- package/es/comps/DynamicPorts/utils.js +127 -0
- package/es/comps/Editable/DataCell/ButtonCell.js +45 -0
- package/es/comps/Editable/DataCell/ColorPicker.js +33 -0
- package/es/comps/Editable/DataCell/Input.js +54 -0
- package/es/comps/Editable/DataCell/Number.js +44 -0
- package/es/comps/Editable/DataCell/Select.js +48 -0
- package/es/comps/Editable/DataCell/Switch.js +33 -0
- package/es/comps/Editable/comps/EditableAction.js +110 -0
- package/es/comps/Editable/comps/EditableCell.js +108 -0
- package/es/comps/Editable/comps/EditableHeardCell.js +172 -0
- package/es/comps/Editable/comps/EditableRow.js +118 -0
- package/es/comps/Editable/comps/Texty.js +277 -0
- package/es/comps/Editable/index.js +386 -0
- package/es/comps/Editable/interface.js +8 -0
- package/es/comps/Editable/utils.js +46 -0
- package/es/comps/FileView/index.js +198 -0
- package/es/comps/FormGenerator/Provider.js +8 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Checkbox.js +69 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Color.js +17 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.js +16 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.js +17 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/List.js +50 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.js +55 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.js +14 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Obj.js +50 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Password.js +17 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Radio.js +69 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.js +55 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.js +13 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Table.js +50 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.js +14 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Upload.js +27 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.js +261 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.js +62 -0
- package/es/comps/FormGenerator/comps/Canvas/core/index.js +315 -0
- package/es/comps/FormGenerator/comps/Canvas/index.js +120 -0
- package/es/comps/FormGenerator/comps/Settings/index.js +150 -0
- package/es/comps/FormGenerator/comps/Sidebar/Elements.js +48 -0
- package/es/comps/FormGenerator/comps/Sidebar/index.js +37 -0
- package/es/comps/FormGenerator/index.js +68 -0
- package/es/comps/FormGenerator/settings/index.js +367 -0
- package/es/comps/FormGenerator/settings/ruleConfig.js +557 -0
- package/es/comps/FormGenerator/transformer.js +300 -0
- package/es/comps/Icons/index.js +23 -0
- package/es/comps/JsonEdit/constant/index.js +87 -0
- package/es/comps/JsonEdit/index.js +221 -0
- package/es/comps/JsonView/index.js +109 -0
- package/es/comps/MdEdit/index.js +41 -0
- package/es/comps/MdNavbar/index.js +180 -0
- package/es/comps/MdNavbar/utils.js +34 -0
- package/es/comps/MdView/index.js +70 -0
- package/es/comps/MetadataEdit/components/MetaFieldsEdit.js +419 -0
- package/es/comps/MetadataEdit/components/MetaPropsEdit.js +368 -0
- package/es/comps/MetadataEdit/constant/index.js +69 -0
- package/es/comps/MetadataEdit/hooks/index.js +43 -0
- package/es/comps/MetadataEdit/index.js +255 -0
- package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +237 -0
- package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +367 -0
- package/es/comps/MetadataEditV2/constant/index.js +69 -0
- package/es/comps/MetadataEditV2/hooks/index.js +43 -0
- package/es/comps/MetadataEditV2/index.js +298 -0
- package/es/comps/MetadataForm/DataCell/Array.js +148 -0
- package/es/comps/MetadataForm/DataCell/Input.js +198 -0
- package/es/comps/MetadataForm/DataCell/Number.js +130 -0
- package/es/comps/MetadataForm/DataCell/Ref.js +326 -0
- package/es/comps/MetadataForm/DataCell/Select.js +557 -0
- package/es/comps/MetadataForm/DataCell/Switch.js +115 -0
- package/es/comps/MetadataForm/DataCell/layout/TableArray.js +359 -0
- package/es/comps/MetadataForm/HOC/index.js +125 -0
- package/es/comps/MetadataForm/constants.js +11 -0
- package/es/comps/MetadataForm/hooks/index.js +128 -0
- package/es/comps/MetadataForm/index.js +268 -0
- package/es/comps/MetadataForm/interface.js +8 -0
- package/es/comps/MetadataForm/utils.js +112 -0
- package/es/comps/locales/en-US.js +24 -0
- package/es/comps/locales/index.js +8 -0
- package/es/comps/locales/zh-CN.js +24 -0
- package/es/config.js +50 -0
- package/es/framework/graph/index.js +515 -0
- package/es/framework/hooks/use-async-memo.js +32 -0
- package/es/framework/hooks/use-sync-scroll.js +106 -0
- package/es/framework/http/cache.js +137 -0
- package/es/framework/http/cancel.js +44 -0
- package/es/framework/http/index.js +392 -0
- package/es/framework/http/msgpack.js +34 -0
- package/es/framework/http/msgpack5/index.js +84 -0
- package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +71 -0
- package/es/framework/http/msgpack5/lib/decoder.js +287 -0
- package/es/framework/http/msgpack5/lib/encoder.js +252 -0
- package/es/framework/http/msgpack5/lib/helpers.js +23 -0
- package/es/framework/http/msgpack5/lib/streams.js +93 -0
- package/es/framework/http/types.js +1 -0
- package/es/framework/libs/jquery.min.js +4022 -0
- package/es/framework/locale/dil8/di18n.js +132 -0
- package/es/framework/locale/dil8/index.js +3 -0
- package/es/framework/locale/dil8/translate.js +76 -0
- package/es/framework/locale/dil8/util.js +17 -0
- package/es/framework/locale/index.js +26 -0
- package/es/framework/metadata/MetadataService.js +169 -0
- package/es/framework/metadata/index.js +384 -0
- package/es/framework/rxjs-hooks/useMemoSubject.js +16 -0
- package/es/framework/rxjs-hooks/useObservable.js +22 -0
- package/es/framework/rxjs-hooks/useObservableState.js +45 -0
- package/es/index.js +27 -0
- package/es/utils.js +138 -0
- package/package.json +1 -1
@@ -0,0 +1,120 @@
|
|
1
|
+
import "antd/es/message/style";
|
2
|
+
import _message from "antd/es/message";
|
3
|
+
import "antd/es/button/style";
|
4
|
+
import _Button from "antd/es/button";
|
5
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
6
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
7
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
8
|
+
import React from 'react';
|
9
|
+
import copy from 'copy-to-clipboard';
|
10
|
+
import { FGCtx } from '../../Provider';
|
11
|
+
import { formSetting, streamEventType } from '../../settings';
|
12
|
+
import { transFG2Schema } from '../../transformer';
|
13
|
+
import CanvasCore from './core';
|
14
|
+
import MetadataForm from '../../../../comps/MetadataForm';
|
15
|
+
import useObservable from '../../../../framework/rxjs-hooks/useObservable';
|
16
|
+
|
17
|
+
var Canvas = function Canvas() {
|
18
|
+
var nodesRef = React.useRef([]);
|
19
|
+
var settingRef = React.useRef({
|
20
|
+
formSetting: formSetting.param.defaultValue
|
21
|
+
});
|
22
|
+
var typesRef = React.useRef({});
|
23
|
+
|
24
|
+
var _React$useState = React.useState([]),
|
25
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
26
|
+
schema = _React$useState2[0],
|
27
|
+
setSchema = _React$useState2[1];
|
28
|
+
|
29
|
+
var fGCtx = React.useContext(FGCtx) || {};
|
30
|
+
var processFgStreamData = React.useCallback(function (p) {
|
31
|
+
switch (p === null || p === void 0 ? void 0 : p.type) {
|
32
|
+
case streamEventType.onSettingValueChange:
|
33
|
+
if (p === null || p === void 0 ? void 0 : p.payload) {
|
34
|
+
settingRef.current = p.payload.allSetting;
|
35
|
+
}
|
36
|
+
|
37
|
+
break;
|
38
|
+
|
39
|
+
case streamEventType.onTypesChange:
|
40
|
+
if (p === null || p === void 0 ? void 0 : p.payload) {
|
41
|
+
typesRef.current = _objectSpread(_objectSpread({}, typesRef.current), p === null || p === void 0 ? void 0 : p.payload);
|
42
|
+
}
|
43
|
+
|
44
|
+
break;
|
45
|
+
}
|
46
|
+
}, []);
|
47
|
+
useObservable(function (p) {
|
48
|
+
processFgStreamData(p);
|
49
|
+
}, [fGCtx.fgStream]);
|
50
|
+
|
51
|
+
var onClearCanvas = function onClearCanvas() {
|
52
|
+
fGCtx.fgStream && fGCtx.fgStream.next({
|
53
|
+
type: streamEventType.onClearCanvas
|
54
|
+
});
|
55
|
+
};
|
56
|
+
|
57
|
+
var onPreview = function onPreview() {
|
58
|
+
if (schema.length === 0) {
|
59
|
+
var _schema = transFG2Schema(nodesRef.current, settingRef.current, typesRef.current);
|
60
|
+
|
61
|
+
setSchema(_toConsumableArray(_schema || []));
|
62
|
+
} else {
|
63
|
+
setSchema([]);
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
return /*#__PURE__*/React.createElement("div", {
|
68
|
+
style: {
|
69
|
+
height: '100%',
|
70
|
+
width: '60%',
|
71
|
+
padding: '4px'
|
72
|
+
}
|
73
|
+
}, /*#__PURE__*/React.createElement("div", {
|
74
|
+
style: {
|
75
|
+
paddingBottom: '8px'
|
76
|
+
}
|
77
|
+
}, /*#__PURE__*/React.createElement(_Button, {
|
78
|
+
style: {
|
79
|
+
marginRight: '8px'
|
80
|
+
},
|
81
|
+
onClick: onPreview
|
82
|
+
}, schema.length > 0 ? '取消预览' : '预览'), /*#__PURE__*/React.createElement(_Button, {
|
83
|
+
style: {
|
84
|
+
marginRight: '8px'
|
85
|
+
},
|
86
|
+
onClick: onClearCanvas
|
87
|
+
}, "\u6E05\u7A7A"), /*#__PURE__*/React.createElement(_Button, {
|
88
|
+
type: "primary",
|
89
|
+
onClick: function onClick() {
|
90
|
+
var _schema = transFG2Schema(nodesRef.current, settingRef.current, typesRef.current);
|
91
|
+
|
92
|
+
if (copy(JSON.stringify(_schema))) {
|
93
|
+
_message.success("\u5DF2\u590D\u5236\u5230\u526A\u5207\u677F");
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}, "\u5BFC\u51FASchema")), schema.length > 0 && /*#__PURE__*/React.createElement("div", {
|
97
|
+
style: {
|
98
|
+
width: '100%',
|
99
|
+
height: 'calc(100% - 40px)',
|
100
|
+
background: 'var(--ronds-metadata-color-bg-4)',
|
101
|
+
padding: '8px',
|
102
|
+
border: '1px solid var(--ronds-metadata-color-border-1)',
|
103
|
+
overflowY: 'auto'
|
104
|
+
}
|
105
|
+
}, /*#__PURE__*/React.createElement(MetadataForm, {
|
106
|
+
schema: schema
|
107
|
+
})), /*#__PURE__*/React.createElement("div", {
|
108
|
+
style: {
|
109
|
+
width: '100%',
|
110
|
+
height: '100%',
|
111
|
+
display: "".concat(schema.length === 0 ? 'block' : 'none')
|
112
|
+
}
|
113
|
+
}, /*#__PURE__*/React.createElement(CanvasCore, {
|
114
|
+
onChange: function onChange(nodes) {
|
115
|
+
nodesRef.current = nodes;
|
116
|
+
}
|
117
|
+
})));
|
118
|
+
};
|
119
|
+
|
120
|
+
export default Canvas;
|
@@ -0,0 +1,150 @@
|
|
1
|
+
import "antd/es/tabs/style";
|
2
|
+
import _Tabs from "antd/es/tabs";
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
4
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
5
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
6
|
+
import React from 'react';
|
7
|
+
import { FGCtx } from '../../Provider';
|
8
|
+
import { formSetting, streamEventType } from '../../settings';
|
9
|
+
import MetadataForm from '../../../../comps/MetadataForm';
|
10
|
+
import useObservable from '../../../../framework/rxjs-hooks/useObservable';
|
11
|
+
|
12
|
+
var Settings = function Settings() {
|
13
|
+
var _curNode$param, _formSetting$param;
|
14
|
+
|
15
|
+
var fGCtx = React.useContext(FGCtx) || {};
|
16
|
+
var compFormRef = React.useRef();
|
17
|
+
var formRef = React.useRef();
|
18
|
+
|
19
|
+
var _React$useState = React.useState(),
|
20
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
21
|
+
curNode = _React$useState2[0],
|
22
|
+
setCurNode = _React$useState2[1];
|
23
|
+
|
24
|
+
var _React$useState3 = React.useState(formSetting.id),
|
25
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
26
|
+
curTab = _React$useState4[0],
|
27
|
+
setCurTab = _React$useState4[1];
|
28
|
+
|
29
|
+
var refIdRef = React.useRef();
|
30
|
+
var settingValueRef = React.useRef({
|
31
|
+
formSetting: formSetting.param.defaultValue
|
32
|
+
}); // 处理默认数据
|
33
|
+
|
34
|
+
var processDefaultValue = React.useCallback(function (data) {
|
35
|
+
settingValueRef.current = data.settings;
|
36
|
+
fGCtx.fgStream && fGCtx.fgStream.next({
|
37
|
+
type: streamEventType.onSettingValueChange,
|
38
|
+
payload: _objectSpread(_objectSpread({}, data.settings), {}, {
|
39
|
+
allSetting: settingValueRef.current,
|
40
|
+
refId: refIdRef.current
|
41
|
+
})
|
42
|
+
});
|
43
|
+
}, []);
|
44
|
+
var processFgStreamData = React.useCallback(function (p) {
|
45
|
+
switch (p === null || p === void 0 ? void 0 : p.type) {
|
46
|
+
case streamEventType.onNodeSelect:
|
47
|
+
refIdRef.current = p === null || p === void 0 ? void 0 : p.payload.refId;
|
48
|
+
|
49
|
+
var _node = p === null || p === void 0 ? void 0 : p.payload.node;
|
50
|
+
|
51
|
+
setCurNode(_objectSpread({}, _node));
|
52
|
+
setCurTab(_node.id); // 赋值
|
53
|
+
|
54
|
+
if (refIdRef.current) {
|
55
|
+
var _key = "".concat(refIdRef.current, "_ref");
|
56
|
+
|
57
|
+
if (settingValueRef.current[_key] && settingValueRef.current[_key][_node.id]) {
|
58
|
+
setTimeout(function () {
|
59
|
+
compFormRef.current && compFormRef.current.setFieldsValue(_objectSpread({}, settingValueRef.current[_key][_node.id]));
|
60
|
+
}, 100);
|
61
|
+
}
|
62
|
+
} else {
|
63
|
+
if (settingValueRef.current[_node.id]) {
|
64
|
+
setTimeout(function () {
|
65
|
+
compFormRef.current && compFormRef.current.setFieldsValue(_objectSpread({}, settingValueRef.current[_node.id]));
|
66
|
+
}, 100);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
break;
|
71
|
+
|
72
|
+
case streamEventType.onClearCanvas:
|
73
|
+
setCurNode(undefined);
|
74
|
+
setCurTab('formSetting');
|
75
|
+
break;
|
76
|
+
|
77
|
+
case streamEventType.onDefaultValue:
|
78
|
+
processDefaultValue(p === null || p === void 0 ? void 0 : p.payload);
|
79
|
+
break;
|
80
|
+
}
|
81
|
+
}, []);
|
82
|
+
useObservable(function (p) {
|
83
|
+
processFgStreamData(p);
|
84
|
+
}, [fGCtx.fgStream]);
|
85
|
+
|
86
|
+
var onTabChange = function onTabChange(key) {
|
87
|
+
setCurTab(key);
|
88
|
+
};
|
89
|
+
|
90
|
+
var _onValuesChange = function onValuesChange(id, val, allVals) {
|
91
|
+
var _payload;
|
92
|
+
|
93
|
+
var _settingValue = settingValueRef.current;
|
94
|
+
|
95
|
+
if (refIdRef.current && id !== formSetting.id) {
|
96
|
+
var _key = "".concat(refIdRef.current, "_ref");
|
97
|
+
|
98
|
+
_settingValue = settingValueRef.current[_key] ? settingValueRef.current : _objectSpread(_objectSpread({}, settingValueRef.current), {}, _defineProperty({}, _key, {}));
|
99
|
+
_settingValue[_key][id] = allVals;
|
100
|
+
} else {
|
101
|
+
_settingValue[id] = allVals;
|
102
|
+
}
|
103
|
+
|
104
|
+
settingValueRef.current = _settingValue;
|
105
|
+
fGCtx.fgStream && fGCtx.fgStream.next({
|
106
|
+
type: streamEventType.onSettingValueChange,
|
107
|
+
payload: (_payload = {}, _defineProperty(_payload, id, allVals), _defineProperty(_payload, "allSetting", settingValueRef.current), _defineProperty(_payload, "refId", refIdRef.current), _payload)
|
108
|
+
});
|
109
|
+
};
|
110
|
+
|
111
|
+
return /*#__PURE__*/React.createElement("div", {
|
112
|
+
style: {
|
113
|
+
height: '100%',
|
114
|
+
width: '23%',
|
115
|
+
padding: '4px'
|
116
|
+
}
|
117
|
+
}, /*#__PURE__*/React.createElement(_Tabs, {
|
118
|
+
activeKey: curTab,
|
119
|
+
onChange: onTabChange
|
120
|
+
}, curNode && /*#__PURE__*/React.createElement(_Tabs.TabPane, {
|
121
|
+
tab: "\u7EC4\u4EF6\u914D\u7F6E",
|
122
|
+
key: curNode.id
|
123
|
+
}, /*#__PURE__*/React.createElement(MetadataForm, {
|
124
|
+
schema: (_curNode$param = curNode.param) === null || _curNode$param === void 0 ? void 0 : _curNode$param.schema,
|
125
|
+
getFormInstance: function getFormInstance(form) {
|
126
|
+
compFormRef.current = form;
|
127
|
+
},
|
128
|
+
colSpan: 24,
|
129
|
+
labelSpan: 8,
|
130
|
+
onValuesChange: function onValuesChange(val, allVals) {
|
131
|
+
_onValuesChange(curNode.id, val, allVals);
|
132
|
+
}
|
133
|
+
})), /*#__PURE__*/React.createElement(_Tabs.TabPane, {
|
134
|
+
tab: formSetting.name,
|
135
|
+
key: formSetting.id
|
136
|
+
}, /*#__PURE__*/React.createElement(MetadataForm, {
|
137
|
+
schema: (_formSetting$param = formSetting.param) === null || _formSetting$param === void 0 ? void 0 : _formSetting$param.schema,
|
138
|
+
initialValues: settingValueRef.current.formSetting,
|
139
|
+
getFormInstance: function getFormInstance(form) {
|
140
|
+
formRef.current = form;
|
141
|
+
},
|
142
|
+
colSpan: 24,
|
143
|
+
layout: "vertical",
|
144
|
+
onValuesChange: function onValuesChange(val, allVals) {
|
145
|
+
_onValuesChange(formSetting.id, val, allVals);
|
146
|
+
}
|
147
|
+
}))));
|
148
|
+
};
|
149
|
+
|
150
|
+
export default Settings;
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import "antd/es/col/style";
|
2
|
+
import _Col from "antd/es/col";
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
4
|
+
import React from "react";
|
5
|
+
import { useDrag } from 'react-dnd';
|
6
|
+
import { dragItemType } from '../../settings';
|
7
|
+
|
8
|
+
var Elements = function Elements(props) {
|
9
|
+
var data = props.data;
|
10
|
+
|
11
|
+
var _useDrag = useDrag({
|
12
|
+
item: {
|
13
|
+
dragItem: data,
|
14
|
+
type: dragItemType
|
15
|
+
},
|
16
|
+
end: function end(item, monitor) {
|
17
|
+
var dropResult = monitor.getDropResult();
|
18
|
+
|
19
|
+
if (item && dropResult) {}
|
20
|
+
},
|
21
|
+
collect: function collect(monitor) {
|
22
|
+
return {
|
23
|
+
isDragging: monitor.isDragging()
|
24
|
+
};
|
25
|
+
}
|
26
|
+
}),
|
27
|
+
_useDrag2 = _slicedToArray(_useDrag, 2),
|
28
|
+
isDragging = _useDrag2[0].isDragging,
|
29
|
+
drag = _useDrag2[1];
|
30
|
+
|
31
|
+
var opacity = isDragging ? 0.7 : 1;
|
32
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Col, {
|
33
|
+
span: 12,
|
34
|
+
key: data.id
|
35
|
+
}, /*#__PURE__*/React.createElement("div", {
|
36
|
+
ref: drag,
|
37
|
+
style: {
|
38
|
+
padding: '4px',
|
39
|
+
textAlign: 'center',
|
40
|
+
border: '1px solid var(--ronds-metadata-color-border-1)',
|
41
|
+
borderRadius: '3px',
|
42
|
+
cursor: 'pointer',
|
43
|
+
opacity: opacity
|
44
|
+
}
|
45
|
+
}, data.name)));
|
46
|
+
};
|
47
|
+
|
48
|
+
export default Elements;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import "antd/es/row/style";
|
2
|
+
import _Row from "antd/es/row";
|
3
|
+
import React from "react";
|
4
|
+
import { sidebarCtx } from '../../settings';
|
5
|
+
import Elements from './Elements';
|
6
|
+
|
7
|
+
var Sidebar = function Sidebar() {
|
8
|
+
return /*#__PURE__*/React.createElement("div", {
|
9
|
+
style: {
|
10
|
+
height: '100%',
|
11
|
+
width: '17%',
|
12
|
+
padding: '4px',
|
13
|
+
overflowY: 'auto'
|
14
|
+
}
|
15
|
+
}, sidebarCtx.map(function (it) {
|
16
|
+
return /*#__PURE__*/React.createElement("div", {
|
17
|
+
key: it.name,
|
18
|
+
style: {
|
19
|
+
paddingBottom: '8px'
|
20
|
+
}
|
21
|
+
}, /*#__PURE__*/React.createElement("div", {
|
22
|
+
style: {
|
23
|
+
fontWeight: 'bold',
|
24
|
+
paddingBottom: '8px'
|
25
|
+
}
|
26
|
+
}, it.name), /*#__PURE__*/React.createElement(_Row, {
|
27
|
+
gutter: [8, 8]
|
28
|
+
}, it.children.map(function (v) {
|
29
|
+
return /*#__PURE__*/React.createElement(Elements, {
|
30
|
+
key: v.id,
|
31
|
+
data: v
|
32
|
+
});
|
33
|
+
})));
|
34
|
+
}));
|
35
|
+
};
|
36
|
+
|
37
|
+
export default Sidebar;
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
3
|
+
|
4
|
+
/*
|
5
|
+
* @Author: wangxian
|
6
|
+
* @Date: 2023-02-04 13:45:31
|
7
|
+
* @LastEditTime: 2023-02-25 10:53:17
|
8
|
+
*/
|
9
|
+
import React from 'react';
|
10
|
+
import { DndProvider } from 'react-dnd';
|
11
|
+
import { HTML5Backend } from 'react-dnd-html5-backend';
|
12
|
+
import Canvas from './comps/Canvas';
|
13
|
+
import Settings from './comps/Settings';
|
14
|
+
import Sidebar from './comps/Sidebar';
|
15
|
+
import './index.less';
|
16
|
+
import { FGCtx } from './Provider';
|
17
|
+
import useMemoSubject from '../../framework/rxjs-hooks/useMemoSubject';
|
18
|
+
import useObservable from '../../framework/rxjs-hooks/useObservable';
|
19
|
+
import { streamEventType } from './settings';
|
20
|
+
import { transSchema2FG } from './transformer';
|
21
|
+
|
22
|
+
var FormGenerator = function FormGenerator(props) {
|
23
|
+
var defaultSchema = props.defaultSchema;
|
24
|
+
var FGStream = useMemoSubject();
|
25
|
+
|
26
|
+
var _React$useState = React.useState({}),
|
27
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
28
|
+
types = _React$useState2[0],
|
29
|
+
setTypes = _React$useState2[1];
|
30
|
+
|
31
|
+
var typesRef = React.useRef({});
|
32
|
+
React.useEffect(function () {
|
33
|
+
if (defaultSchema) {
|
34
|
+
var defaultValue = transSchema2FG(defaultSchema);
|
35
|
+
FGStream.next({
|
36
|
+
type: streamEventType.onDefaultValue,
|
37
|
+
payload: _objectSpread({}, defaultValue)
|
38
|
+
});
|
39
|
+
}
|
40
|
+
}, [defaultSchema]);
|
41
|
+
var processFgStreamData = React.useCallback(function (p) {
|
42
|
+
switch (p === null || p === void 0 ? void 0 : p.type) {
|
43
|
+
case streamEventType.onTypesChange:
|
44
|
+
if (p === null || p === void 0 ? void 0 : p.payload) {
|
45
|
+
typesRef.current = _objectSpread(_objectSpread({}, typesRef.current), p === null || p === void 0 ? void 0 : p.payload);
|
46
|
+
setTypes(_objectSpread({}, typesRef.current));
|
47
|
+
}
|
48
|
+
|
49
|
+
break;
|
50
|
+
}
|
51
|
+
}, []);
|
52
|
+
useObservable(function (p) {
|
53
|
+
processFgStreamData(p);
|
54
|
+
}, [FGStream]);
|
55
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FGCtx.Provider, {
|
56
|
+
value: {
|
57
|
+
fgStream: FGStream,
|
58
|
+
types: types
|
59
|
+
}
|
60
|
+
}, /*#__PURE__*/React.createElement(DndProvider, {
|
61
|
+
backend: HTML5Backend,
|
62
|
+
context: window
|
63
|
+
}, /*#__PURE__*/React.createElement("div", {
|
64
|
+
className: "form-generator-container"
|
65
|
+
}, /*#__PURE__*/React.createElement(Sidebar, null), /*#__PURE__*/React.createElement(Canvas, null), /*#__PURE__*/React.createElement(Settings, null)))));
|
66
|
+
};
|
67
|
+
|
68
|
+
export default FormGenerator;
|