ronds-metadata 1.1.85 → 1.1.87
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/es/comps/FormGenerator/Provider.d.ts +3 -0
- package/es/comps/FormGenerator/Provider.js +8 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.d.ts +2 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.js +15 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.d.ts +2 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.js +17 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.d.ts +2 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.js +13 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.d.ts +2 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.js +11 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.d.ts +2 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.js +11 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.d.ts +2 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.js +11 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.d.ts +2 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.js +11 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.d.ts +1 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.js +114 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.d.ts +7 -0
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.js +44 -0
- package/es/comps/FormGenerator/comps/Canvas/core/index.d.ts +7 -0
- package/es/comps/FormGenerator/comps/Canvas/core/index.js +170 -0
- package/es/comps/FormGenerator/comps/Canvas/core/index.less +24 -0
- package/es/comps/FormGenerator/comps/Canvas/index.d.ts +2 -0
- package/es/comps/FormGenerator/comps/Canvas/index.js +109 -0
- package/es/comps/FormGenerator/comps/Settings/index.d.ts +2 -0
- package/es/comps/FormGenerator/comps/Settings/index.js +116 -0
- package/es/comps/FormGenerator/comps/Sidebar/Elements.d.ts +6 -0
- package/es/comps/FormGenerator/comps/Sidebar/Elements.js +48 -0
- package/es/comps/FormGenerator/comps/Sidebar/index.d.ts +2 -0
- package/es/comps/FormGenerator/comps/Sidebar/index.js +37 -0
- package/es/comps/FormGenerator/index.d.ts +5 -0
- package/es/comps/FormGenerator/index.js +30 -0
- package/es/comps/FormGenerator/index.less +21 -0
- package/es/comps/FormGenerator/settings/index.d.ts +702 -0
- package/es/comps/FormGenerator/settings/index.js +206 -0
- package/es/comps/FormGenerator/settings/ruleConfig.d.ts +364 -0
- package/es/comps/FormGenerator/settings/ruleConfig.js +346 -0
- package/es/comps/FormGenerator/transformer.d.ts +13 -0
- package/es/comps/FormGenerator/transformer.js +66 -0
- package/es/comps/MetadataForm/DataCell/Input.js +11 -3
- package/es/comps/MetadataForm/DataCell/Number.js +11 -4
- package/es/comps/MetadataForm/DataCell/Ref.js +3 -3
- package/es/comps/MetadataForm/DataCell/Select.js +11 -3
- package/es/comps/MetadataForm/DataCell/Switch.js +11 -3
- package/es/comps/MetadataForm/index.js +10 -4
- package/es/config.js +2 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/theme.less +4 -0
- package/package.json +1 -1
@@ -0,0 +1,15 @@
|
|
1
|
+
import "antd/es/date-picker/style";
|
2
|
+
import _DatePicker from "antd/es/date-picker";
|
3
|
+
import React from "react";
|
4
|
+
import { withFieldCellWrapper } from '../HOC';
|
5
|
+
import { DEFAULT_DATE_FORMAT } from '../../../../../../../comps/MetadataForm/DataCell/Input';
|
6
|
+
|
7
|
+
var Index = function Index(props) {
|
8
|
+
var data = props.data;
|
9
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_DatePicker, {
|
10
|
+
showTime: true,
|
11
|
+
format: DEFAULT_DATE_FORMAT
|
12
|
+
}));
|
13
|
+
};
|
14
|
+
|
15
|
+
export default withFieldCellWrapper(Index);
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import "antd/es/input/style";
|
2
|
+
import _Input from "antd/es/input";
|
3
|
+
import React from "react";
|
4
|
+
import { withFieldCellWrapper } from '../HOC';
|
5
|
+
|
6
|
+
var Index = function Index(props) {
|
7
|
+
var data = props.data,
|
8
|
+
fgStream = props.fgStream,
|
9
|
+
setting = props.setting;
|
10
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Input, {
|
11
|
+
disabled: setting === null || setting === void 0 ? void 0 : setting.disabled,
|
12
|
+
placeholder: setting === null || setting === void 0 ? void 0 : setting.placeholder,
|
13
|
+
allowClear: true
|
14
|
+
}));
|
15
|
+
};
|
16
|
+
|
17
|
+
export default withFieldCellWrapper(Index);
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import "antd/es/select/style";
|
2
|
+
import _Select from "antd/es/select";
|
3
|
+
import React from "react";
|
4
|
+
import { withFieldCellWrapper } from '../HOC';
|
5
|
+
|
6
|
+
var Index = function Index(props) {
|
7
|
+
var data = props.data;
|
8
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Select, {
|
9
|
+
mode: "multiple"
|
10
|
+
}));
|
11
|
+
};
|
12
|
+
|
13
|
+
export default withFieldCellWrapper(Index);
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import "antd/es/input-number/style";
|
2
|
+
import _InputNumber from "antd/es/input-number";
|
3
|
+
import React from "react";
|
4
|
+
import { withFieldCellWrapper } from '../HOC';
|
5
|
+
|
6
|
+
var Index = function Index(props) {
|
7
|
+
var data = props.data;
|
8
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_InputNumber, null));
|
9
|
+
};
|
10
|
+
|
11
|
+
export default withFieldCellWrapper(Index);
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import "antd/es/select/style";
|
2
|
+
import _Select from "antd/es/select";
|
3
|
+
import React from "react";
|
4
|
+
import { withFieldCellWrapper } from '../HOC';
|
5
|
+
|
6
|
+
var Index = function Index(props) {
|
7
|
+
var data = props.data;
|
8
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Select, null));
|
9
|
+
};
|
10
|
+
|
11
|
+
export default withFieldCellWrapper(Index);
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import "antd/es/switch/style";
|
2
|
+
import _Switch from "antd/es/switch";
|
3
|
+
import React from "react";
|
4
|
+
import { withFieldCellWrapper } from '../HOC';
|
5
|
+
|
6
|
+
var Index = function Index(props) {
|
7
|
+
var data = props.data;
|
8
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Switch, null));
|
9
|
+
};
|
10
|
+
|
11
|
+
export default withFieldCellWrapper(Index);
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import "antd/es/input/style";
|
2
|
+
import _Input from "antd/es/input";
|
3
|
+
import React from "react";
|
4
|
+
import { withFieldCellWrapper } from '../HOC';
|
5
|
+
|
6
|
+
var Index = function Index(props) {
|
7
|
+
var data = props.data;
|
8
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Input.TextArea, null));
|
9
|
+
};
|
10
|
+
|
11
|
+
export default withFieldCellWrapper(Index);
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function withFieldCellWrapper(WrappedComponent: any): (props: any) => JSX.Element;
|
@@ -0,0 +1,114 @@
|
|
1
|
+
import "antd/es/button/style";
|
2
|
+
import _Button from "antd/es/button";
|
3
|
+
import "antd/es/form/style";
|
4
|
+
import _Form from "antd/es/form";
|
5
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
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 { DragOutlined, SnippetsOutlined, DeleteOutlined } from '@ant-design/icons';
|
10
|
+
import { FGCtx } from '../../../../../Provider';
|
11
|
+
import { streamEventType } from '../../../../../settings';
|
12
|
+
import useObservable from '../../../../../../../framework/rxjs-hooks/useObservable';
|
13
|
+
export function withFieldCellWrapper(WrappedComponent) {
|
14
|
+
return function (props) {
|
15
|
+
var data = props.data,
|
16
|
+
isShowAction = props.isShowAction;
|
17
|
+
var fGCtx = React.useContext(FGCtx) || {};
|
18
|
+
|
19
|
+
var _React$useState = React.useState(),
|
20
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
21
|
+
cellSetting = _React$useState2[0],
|
22
|
+
setCellSetting = _React$useState2[1];
|
23
|
+
|
24
|
+
var processFgStreamData = React.useCallback(function (p) {
|
25
|
+
switch (p === null || p === void 0 ? void 0 : p.type) {
|
26
|
+
case streamEventType.onSettingValueChange:
|
27
|
+
if (p === null || p === void 0 ? void 0 : p.payload[data.id]) {
|
28
|
+
setCellSetting(_objectSpread({}, p === null || p === void 0 ? void 0 : p.payload[data.id]));
|
29
|
+
}
|
30
|
+
|
31
|
+
break;
|
32
|
+
}
|
33
|
+
}, []);
|
34
|
+
useObservable(function (p) {
|
35
|
+
processFgStreamData(p);
|
36
|
+
}, [fGCtx.fgStream]);
|
37
|
+
|
38
|
+
var onNodeDelete = function onNodeDelete(e) {
|
39
|
+
e.stopPropagation();
|
40
|
+
fGCtx.fgStream && fGCtx.fgStream.next({
|
41
|
+
type: streamEventType.onNodeDelete,
|
42
|
+
payload: {
|
43
|
+
id: data.id
|
44
|
+
}
|
45
|
+
});
|
46
|
+
};
|
47
|
+
|
48
|
+
var onNodeCopy = function onNodeCopy(e) {
|
49
|
+
e.stopPropagation();
|
50
|
+
fGCtx.fgStream && fGCtx.fgStream.next({
|
51
|
+
type: streamEventType.onNodeCopy,
|
52
|
+
payload: data
|
53
|
+
});
|
54
|
+
};
|
55
|
+
|
56
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
57
|
+
style: {
|
58
|
+
fontSize: '12px',
|
59
|
+
textAlign: 'right'
|
60
|
+
}
|
61
|
+
}, /*#__PURE__*/React.createElement("span", {
|
62
|
+
style: {
|
63
|
+
color: 'var(--ronds-metadata-color-border-2)'
|
64
|
+
}
|
65
|
+
}, (cellSetting === null || cellSetting === void 0 ? void 0 : cellSetting.id) || data.id), (cellSetting === null || cellSetting === void 0 ? void 0 : cellSetting.hidden) && /*#__PURE__*/React.createElement("span", {
|
66
|
+
style: {
|
67
|
+
color: 'var(--ronds-metadata-color-text-2)'
|
68
|
+
}
|
69
|
+
}, " [ hidden ] ")), /*#__PURE__*/React.createElement(_Form.Item, {
|
70
|
+
key: "".concat(cellSetting === null || cellSetting === void 0 ? void 0 : cellSetting.defaultValue),
|
71
|
+
name: (cellSetting === null || cellSetting === void 0 ? void 0 : cellSetting.id) || data.id,
|
72
|
+
label: /*#__PURE__*/React.createElement("span", {
|
73
|
+
style: (cellSetting === null || cellSetting === void 0 ? void 0 : cellSetting.color) ? {
|
74
|
+
color: cellSetting === null || cellSetting === void 0 ? void 0 : cellSetting.color
|
75
|
+
} : {}
|
76
|
+
}, (cellSetting === null || cellSetting === void 0 ? void 0 : cellSetting.label) || data.name),
|
77
|
+
initialValue: cellSetting === null || cellSetting === void 0 ? void 0 : cellSetting.defaultValue,
|
78
|
+
help: cellSetting === null || cellSetting === void 0 ? void 0 : cellSetting.help,
|
79
|
+
tooltip: cellSetting === null || cellSetting === void 0 ? void 0 : cellSetting.tooltip,
|
80
|
+
rules: [{
|
81
|
+
required: cellSetting === null || cellSetting === void 0 ? void 0 : cellSetting.require
|
82
|
+
}]
|
83
|
+
}, /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, props, {
|
84
|
+
fgStream: fGCtx.fgStream,
|
85
|
+
setting: cellSetting
|
86
|
+
}))), isShowAction && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
87
|
+
style: {
|
88
|
+
position: 'absolute',
|
89
|
+
top: '-3px',
|
90
|
+
left: '-3px'
|
91
|
+
}
|
92
|
+
}, /*#__PURE__*/React.createElement(_Button, {
|
93
|
+
size: "small",
|
94
|
+
type: "primary",
|
95
|
+
icon: /*#__PURE__*/React.createElement(DragOutlined, null)
|
96
|
+
})), /*#__PURE__*/React.createElement("div", {
|
97
|
+
style: {
|
98
|
+
position: 'absolute',
|
99
|
+
bottom: '-3px',
|
100
|
+
right: '-2px'
|
101
|
+
}
|
102
|
+
}, /*#__PURE__*/React.createElement(_Button, {
|
103
|
+
size: "small",
|
104
|
+
type: "primary",
|
105
|
+
onClick: onNodeDelete,
|
106
|
+
icon: /*#__PURE__*/React.createElement(DeleteOutlined, null)
|
107
|
+
}), /*#__PURE__*/React.createElement(_Button, {
|
108
|
+
size: "small",
|
109
|
+
type: "primary",
|
110
|
+
onClick: onNodeCopy,
|
111
|
+
icon: /*#__PURE__*/React.createElement(SnippetsOutlined, null)
|
112
|
+
}))));
|
113
|
+
};
|
114
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/*
|
2
|
+
* @Author: wangxian
|
3
|
+
* @Date: 2023-02-06 11:35:45
|
4
|
+
* @LastEditTime: 2023-02-08 13:41:36
|
5
|
+
*/
|
6
|
+
import React from 'react';
|
7
|
+
import Input from './Cell/Input';
|
8
|
+
import TextArea from './Cell/TextArea';
|
9
|
+
import Date from './Cell/Date';
|
10
|
+
import Number from './Cell/Number';
|
11
|
+
import Switch from './Cell/Switch';
|
12
|
+
import Select from './Cell/Select';
|
13
|
+
import MutiSelect from './Cell/MutiSelect';
|
14
|
+
|
15
|
+
var RenderField = function RenderField(props) {
|
16
|
+
var data = props.data,
|
17
|
+
_props$isShowAction = props.isShowAction,
|
18
|
+
isShowAction = _props$isShowAction === void 0 ? false : _props$isShowAction;
|
19
|
+
var FieldContent = React.useMemo(function () {
|
20
|
+
var _content = /*#__PURE__*/React.createElement(React.Fragment, null);
|
21
|
+
|
22
|
+
if (data.type && DataCellMap[data.type]) {
|
23
|
+
var Comm = DataCellMap[data.type];
|
24
|
+
return /*#__PURE__*/React.createElement(Comm, {
|
25
|
+
data: data,
|
26
|
+
isShowAction: isShowAction
|
27
|
+
});
|
28
|
+
}
|
29
|
+
|
30
|
+
return _content;
|
31
|
+
}, [data, isShowAction]);
|
32
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, FieldContent);
|
33
|
+
};
|
34
|
+
|
35
|
+
export default RenderField;
|
36
|
+
var DataCellMap = {
|
37
|
+
input: Input,
|
38
|
+
textarea: TextArea,
|
39
|
+
date: Date,
|
40
|
+
number: Number,
|
41
|
+
switch: Switch,
|
42
|
+
select: Select,
|
43
|
+
mutiSelect: MutiSelect
|
44
|
+
};
|
@@ -0,0 +1,170 @@
|
|
1
|
+
import "antd/es/form/style";
|
2
|
+
import _Form from "antd/es/form";
|
3
|
+
import "antd/es/row/style";
|
4
|
+
import _Row from "antd/es/row";
|
5
|
+
import "antd/es/col/style";
|
6
|
+
import _Col from "antd/es/col";
|
7
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
8
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
9
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
10
|
+
import React from 'react';
|
11
|
+
import { useDrop } from 'react-dnd';
|
12
|
+
import { FGCtx } from '../../../../../comps/FormGenerator/Provider';
|
13
|
+
import { dragItemType, streamEventType } from '../../../settings';
|
14
|
+
import useObservable from '../../../../../framework/rxjs-hooks/useObservable';
|
15
|
+
import { guid } from '../../../../../utils';
|
16
|
+
import RenderField from './RenderField';
|
17
|
+
import './index.less';
|
18
|
+
|
19
|
+
var CanvasCore = function CanvasCore(props) {
|
20
|
+
var _formSetting$layout;
|
21
|
+
|
22
|
+
var onChange = props.onChange;
|
23
|
+
var fGCtx = React.useContext(FGCtx) || {};
|
24
|
+
|
25
|
+
var _React$useState = React.useState([]),
|
26
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
27
|
+
list = _React$useState2[0],
|
28
|
+
setList = _React$useState2[1];
|
29
|
+
|
30
|
+
var listRef = React.useRef([]);
|
31
|
+
|
32
|
+
var _React$useState3 = React.useState(),
|
33
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
34
|
+
curNodeId = _React$useState4[0],
|
35
|
+
setCurNodeId = _React$useState4[1];
|
36
|
+
|
37
|
+
var _React$useState5 = React.useState(),
|
38
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
39
|
+
formSetting = _React$useState6[0],
|
40
|
+
setFormSetting = _React$useState6[1];
|
41
|
+
|
42
|
+
React.useEffect(function () {
|
43
|
+
onChange && onChange(listRef.current);
|
44
|
+
}, [list]);
|
45
|
+
var addNewNode = React.useCallback(function (_node) {
|
46
|
+
var _list = listRef.current;
|
47
|
+
|
48
|
+
var obj = _objectSpread(_objectSpread({}, _node), {}, {
|
49
|
+
id: "".concat(_node.id.split('-')[0], "-").concat(guid().substring(0, 4))
|
50
|
+
});
|
51
|
+
|
52
|
+
_list.push(obj);
|
53
|
+
|
54
|
+
setCurNodeId(obj.id);
|
55
|
+
fGCtx.fgStream && fGCtx.fgStream.next({
|
56
|
+
type: streamEventType.onNodeSelect,
|
57
|
+
payload: obj
|
58
|
+
});
|
59
|
+
setList(_toConsumableArray(_list));
|
60
|
+
listRef.current = _list;
|
61
|
+
}, []);
|
62
|
+
var processFgStreamData = React.useCallback(function (p) {
|
63
|
+
var _p$payload;
|
64
|
+
|
65
|
+
switch (p === null || p === void 0 ? void 0 : p.type) {
|
66
|
+
case streamEventType.onClearCanvas:
|
67
|
+
setList([]);
|
68
|
+
listRef.current = [];
|
69
|
+
break;
|
70
|
+
|
71
|
+
case streamEventType.onNodeCopy:
|
72
|
+
addNewNode(p.payload);
|
73
|
+
break;
|
74
|
+
|
75
|
+
case streamEventType.onNodeDelete:
|
76
|
+
var _list = listRef.current;
|
77
|
+
_list = _list.filter(function (it) {
|
78
|
+
return it.id !== p.payload.id;
|
79
|
+
});
|
80
|
+
setList(_toConsumableArray(_list));
|
81
|
+
listRef.current = _list; // 默认焦点放在第一个
|
82
|
+
|
83
|
+
if (_list.length > 0) {
|
84
|
+
onSelect(_list[0]);
|
85
|
+
} else {
|
86
|
+
fGCtx.fgStream && fGCtx.fgStream.next({
|
87
|
+
type: streamEventType.onClearCanvas
|
88
|
+
});
|
89
|
+
}
|
90
|
+
|
91
|
+
break;
|
92
|
+
|
93
|
+
case streamEventType.onSettingValueChange:
|
94
|
+
if (p === null || p === void 0 ? void 0 : (_p$payload = p.payload) === null || _p$payload === void 0 ? void 0 : _p$payload.formSetting) {
|
95
|
+
var _p$payload2;
|
96
|
+
|
97
|
+
setFormSetting(_objectSpread({}, p === null || p === void 0 ? void 0 : (_p$payload2 = p.payload) === null || _p$payload2 === void 0 ? void 0 : _p$payload2.formSetting));
|
98
|
+
}
|
99
|
+
|
100
|
+
break;
|
101
|
+
}
|
102
|
+
}, []);
|
103
|
+
useObservable(function (p) {
|
104
|
+
processFgStreamData(p);
|
105
|
+
}, [fGCtx.fgStream]); // 处理组件拖拽落下事件
|
106
|
+
|
107
|
+
var _useDrop = useDrop({
|
108
|
+
accept: [dragItemType],
|
109
|
+
drop: function drop(item, monitor) {
|
110
|
+
addNewNode(item.dragItem);
|
111
|
+
}
|
112
|
+
}),
|
113
|
+
_useDrop2 = _slicedToArray(_useDrop, 2),
|
114
|
+
dropRef = _useDrop2[1];
|
115
|
+
|
116
|
+
var onSelect = function onSelect(it) {
|
117
|
+
setCurNodeId(it.id);
|
118
|
+
fGCtx.fgStream && fGCtx.fgStream.next({
|
119
|
+
type: streamEventType.onNodeSelect,
|
120
|
+
payload: it
|
121
|
+
});
|
122
|
+
};
|
123
|
+
|
124
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
125
|
+
className: "canvas-wrapper",
|
126
|
+
ref: dropRef,
|
127
|
+
style: {
|
128
|
+
width: '100%',
|
129
|
+
height: 'calc(100% - 40px)',
|
130
|
+
background: 'var(--ronds-metadata-color-bg-3)',
|
131
|
+
padding: '8px',
|
132
|
+
border: '1px solid var(--ronds-metadata-color-border-1)',
|
133
|
+
overflowY: 'auto'
|
134
|
+
}
|
135
|
+
}, /*#__PURE__*/React.createElement(_Form, {
|
136
|
+
layout: (_formSetting$layout = formSetting === null || formSetting === void 0 ? void 0 : formSetting.layout) !== null && _formSetting$layout !== void 0 ? _formSetting$layout : 'horizontal',
|
137
|
+
wrapperCol: (formSetting === null || formSetting === void 0 ? void 0 : formSetting.labelSpan) && (formSetting === null || formSetting === void 0 ? void 0 : formSetting.layout) === 'horizontal' ? {
|
138
|
+
span: 24 - (formSetting === null || formSetting === void 0 ? void 0 : formSetting.labelSpan),
|
139
|
+
offset: 0
|
140
|
+
} : undefined,
|
141
|
+
labelCol: (formSetting === null || formSetting === void 0 ? void 0 : formSetting.labelSpan) && (formSetting === null || formSetting === void 0 ? void 0 : formSetting.layout) === 'horizontal' ? {
|
142
|
+
span: formSetting === null || formSetting === void 0 ? void 0 : formSetting.labelSpan,
|
143
|
+
offset: 0
|
144
|
+
} : undefined,
|
145
|
+
labelWrap: true,
|
146
|
+
autoComplete: "off"
|
147
|
+
}, /*#__PURE__*/React.createElement(_Row, {
|
148
|
+
gutter: 8
|
149
|
+
}, list.map(function (it) {
|
150
|
+
var _formSetting$colSpan;
|
151
|
+
|
152
|
+
return /*#__PURE__*/React.createElement(_Col, {
|
153
|
+
span: (_formSetting$colSpan = formSetting === null || formSetting === void 0 ? void 0 : formSetting.colSpan) !== null && _formSetting$colSpan !== void 0 ? _formSetting$colSpan : 24,
|
154
|
+
style: {
|
155
|
+
width: '100%'
|
156
|
+
}
|
157
|
+
}, /*#__PURE__*/React.createElement("div", {
|
158
|
+
key: it.id,
|
159
|
+
className: "drag-item ".concat(curNodeId === it.id ? 'drag-item-selected' : ''),
|
160
|
+
onClick: function onClick() {
|
161
|
+
onSelect(it);
|
162
|
+
}
|
163
|
+
}, /*#__PURE__*/React.createElement(RenderField, {
|
164
|
+
data: it,
|
165
|
+
isShowAction: curNodeId === it.id
|
166
|
+
})));
|
167
|
+
})))));
|
168
|
+
};
|
169
|
+
|
170
|
+
export default CanvasCore;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
.canvas-wrapper {
|
2
|
+
.drag-item {
|
3
|
+
position: relative;
|
4
|
+
border: 1px dashed var(--ronds-metadata-color-border-1);
|
5
|
+
background: var(--ronds-metadata-color-bg-4);
|
6
|
+
padding: 4px 10px;
|
7
|
+
margin-bottom: 8px;
|
8
|
+
}
|
9
|
+
|
10
|
+
.drag-item-selected {
|
11
|
+
border: 3px dashed var(--ronds-metadata-color-border-2);
|
12
|
+
}
|
13
|
+
|
14
|
+
.ant-form-item {
|
15
|
+
margin-bottom: '4px' !important;
|
16
|
+
}
|
17
|
+
.ant-form-item-label {
|
18
|
+
padding: 0%;
|
19
|
+
}
|
20
|
+
.ant-input-number,
|
21
|
+
.ant-picker {
|
22
|
+
width: 100%;
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,109 @@
|
|
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 _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
7
|
+
import React from 'react';
|
8
|
+
import copy from 'copy-to-clipboard';
|
9
|
+
import { FGCtx } from '../../Provider';
|
10
|
+
import { streamEventType } from '../../settings';
|
11
|
+
import { transFG2Schema } from '../../transformer';
|
12
|
+
import CanvasCore from './core';
|
13
|
+
import MetadataForm from '../../../../comps/MetadataForm';
|
14
|
+
import useObservable from '../../../../framework/rxjs-hooks/useObservable';
|
15
|
+
|
16
|
+
var Canvas = function Canvas() {
|
17
|
+
var nodesRef = React.useRef([]);
|
18
|
+
var settingRef = React.useRef({});
|
19
|
+
|
20
|
+
var _React$useState = React.useState([]),
|
21
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
22
|
+
schema = _React$useState2[0],
|
23
|
+
setSchema = _React$useState2[1];
|
24
|
+
|
25
|
+
var fGCtx = React.useContext(FGCtx) || {};
|
26
|
+
var processFgStreamData = React.useCallback(function (p) {
|
27
|
+
switch (p === null || p === void 0 ? void 0 : p.type) {
|
28
|
+
case streamEventType.onSettingValueChange:
|
29
|
+
if (p === null || p === void 0 ? void 0 : p.payload) {
|
30
|
+
settingRef.current = p.payload.allSetting;
|
31
|
+
}
|
32
|
+
|
33
|
+
break;
|
34
|
+
}
|
35
|
+
}, []);
|
36
|
+
useObservable(function (p) {
|
37
|
+
processFgStreamData(p);
|
38
|
+
}, [fGCtx.fgStream]);
|
39
|
+
|
40
|
+
var onClearCanvas = function onClearCanvas() {
|
41
|
+
fGCtx.fgStream && fGCtx.fgStream.next({
|
42
|
+
type: streamEventType.onClearCanvas
|
43
|
+
});
|
44
|
+
};
|
45
|
+
|
46
|
+
var onPreview = function onPreview() {
|
47
|
+
if (schema.length === 0) {
|
48
|
+
var _schema = transFG2Schema(nodesRef.current, settingRef.current);
|
49
|
+
|
50
|
+
setSchema(_toConsumableArray(_schema));
|
51
|
+
} else {
|
52
|
+
setSchema([]);
|
53
|
+
}
|
54
|
+
};
|
55
|
+
|
56
|
+
return /*#__PURE__*/React.createElement("div", {
|
57
|
+
style: {
|
58
|
+
height: '100%',
|
59
|
+
width: '60%',
|
60
|
+
padding: '4px'
|
61
|
+
}
|
62
|
+
}, /*#__PURE__*/React.createElement("div", {
|
63
|
+
style: {
|
64
|
+
paddingBottom: '8px'
|
65
|
+
}
|
66
|
+
}, /*#__PURE__*/React.createElement(_Button, {
|
67
|
+
style: {
|
68
|
+
marginRight: '8px'
|
69
|
+
},
|
70
|
+
onClick: onPreview
|
71
|
+
}, schema.length > 0 ? '取消预览' : '预览'), /*#__PURE__*/React.createElement(_Button, {
|
72
|
+
style: {
|
73
|
+
marginRight: '8px'
|
74
|
+
},
|
75
|
+
onClick: onClearCanvas
|
76
|
+
}, "\u6E05\u7A7A"), /*#__PURE__*/React.createElement(_Button, {
|
77
|
+
type: "primary",
|
78
|
+
onClick: function onClick() {
|
79
|
+
var _schema = transFG2Schema(nodesRef.current, settingRef.current);
|
80
|
+
|
81
|
+
if (copy(JSON.stringify(_schema))) {
|
82
|
+
_message.success("\u5DF2\u590D\u5236\u5230\u526A\u5207\u677F");
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}, "\u5BFC\u51FASchema")), schema.length > 0 && /*#__PURE__*/React.createElement("div", {
|
86
|
+
style: {
|
87
|
+
width: '100%',
|
88
|
+
height: 'calc(100% - 40px)',
|
89
|
+
background: 'var(--ronds-metadata-color-bg-2)',
|
90
|
+
padding: '8px',
|
91
|
+
border: '1px solid var(--ronds-metadata-color-border-1)',
|
92
|
+
overflowY: 'auto'
|
93
|
+
}
|
94
|
+
}, /*#__PURE__*/React.createElement(MetadataForm, {
|
95
|
+
schema: schema
|
96
|
+
})), /*#__PURE__*/React.createElement("div", {
|
97
|
+
style: {
|
98
|
+
width: '100%',
|
99
|
+
height: '100%',
|
100
|
+
display: "".concat(schema.length === 0 ? 'block' : 'none')
|
101
|
+
}
|
102
|
+
}, /*#__PURE__*/React.createElement(CanvasCore, {
|
103
|
+
onChange: function onChange(nodes) {
|
104
|
+
nodesRef.current = nodes;
|
105
|
+
}
|
106
|
+
})));
|
107
|
+
};
|
108
|
+
|
109
|
+
export default Canvas;
|