ronds-metadata 1.3.69 → 1.3.70
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.
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import "antd/es/checkbox/style";
|
|
2
2
|
import _Checkbox from "antd/es/checkbox";
|
|
3
|
-
import "antd/es/table/style";
|
|
4
|
-
import _Table from "antd/es/table";
|
|
5
3
|
import "antd/es/button/style";
|
|
6
4
|
import _Button from "antd/es/button";
|
|
7
5
|
import "antd/es/select/style";
|
|
@@ -12,33 +10,45 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
12
10
|
import { CloseCircleFilled, ArrowRightOutlined } from '@ant-design/icons';
|
|
13
11
|
import React from 'react';
|
|
14
12
|
import Editable from '../../../../comps/Editable';
|
|
13
|
+
import { MetadataFormContext } from '../../interface';
|
|
15
14
|
var MapTable = function MapTable(props) {
|
|
16
|
-
var
|
|
17
|
-
dataTarget = props.dataTarget,
|
|
18
|
-
options = props.options,
|
|
19
|
-
value = props.value,
|
|
15
|
+
var value = props.value,
|
|
20
16
|
onChange = props.onChange;
|
|
21
|
-
var _React$useState = React.useState(
|
|
17
|
+
var _React$useState = React.useState([]),
|
|
22
18
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
23
19
|
tableDataSource = _React$useState2[0],
|
|
24
20
|
setTableDataSource = _React$useState2[1];
|
|
25
|
-
var _React$useState3 = React.useState(),
|
|
21
|
+
var _React$useState3 = React.useState([]),
|
|
26
22
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var _React$useState5 = React.useState(),
|
|
23
|
+
tableDataTarget = _React$useState4[0],
|
|
24
|
+
setTableDataTarget = _React$useState4[1];
|
|
25
|
+
var _React$useState5 = React.useState([]),
|
|
30
26
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
options = _React$useState6[0],
|
|
28
|
+
setOptions = _React$useState6[1];
|
|
33
29
|
var _React$useState7 = React.useState(),
|
|
34
30
|
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var
|
|
31
|
+
mapping = _React$useState8[0],
|
|
32
|
+
setMapping = _React$useState8[1];
|
|
33
|
+
var _React$useState9 = React.useState(),
|
|
34
|
+
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
35
|
+
output = _React$useState10[0],
|
|
36
|
+
setOutput = _React$useState10[1];
|
|
37
|
+
var _React$useState11 = React.useState(),
|
|
38
|
+
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
39
|
+
disableArray = _React$useState12[0],
|
|
40
|
+
setDisableArray = _React$useState12[1];
|
|
41
|
+
var sourceEditableStreamRef = React.useRef();
|
|
42
|
+
var targetEditableStreamRef = React.useRef();
|
|
43
|
+
var _React$useContext = React.useContext(MetadataFormContext),
|
|
44
|
+
form = _React$useContext.form;
|
|
38
45
|
var triggerChange = function triggerChange(changedValue) {
|
|
39
46
|
onChange && onChange(_objectSpread({
|
|
40
47
|
mapping: mapping,
|
|
41
|
-
output: output
|
|
48
|
+
output: output,
|
|
49
|
+
options: options,
|
|
50
|
+
dataSource: tableDataSource,
|
|
51
|
+
dataTarget: tableDataTarget
|
|
42
52
|
}, changedValue));
|
|
43
53
|
};
|
|
44
54
|
var onBtnClick = function onBtnClick(index) {
|
|
@@ -52,12 +62,18 @@ var MapTable = function MapTable(props) {
|
|
|
52
62
|
output: value
|
|
53
63
|
});
|
|
54
64
|
};
|
|
55
|
-
var
|
|
65
|
+
var onSourceMove = function onSourceMove(data) {
|
|
56
66
|
var newDataSource = _toConsumableArray(tableDataSource);
|
|
57
67
|
var removedElement = newDataSource.splice(data === null || data === void 0 ? void 0 : data.dragIndex, 1)[0];
|
|
58
68
|
newDataSource.splice(data === null || data === void 0 ? void 0 : data.hoverIndex, 0, removedElement);
|
|
59
69
|
setTableDataSource(newDataSource);
|
|
60
70
|
};
|
|
71
|
+
var onTargetMove = function onTargetMove(data) {
|
|
72
|
+
var newDataTarget = _toConsumableArray(tableDataTarget);
|
|
73
|
+
var removedElement = newDataTarget.splice(data === null || data === void 0 ? void 0 : data.dragIndex, 1)[0];
|
|
74
|
+
newDataTarget.splice(data === null || data === void 0 ? void 0 : data.hoverIndex, 0, removedElement);
|
|
75
|
+
setTableDataTarget(newDataTarget);
|
|
76
|
+
};
|
|
61
77
|
React.useEffect(function () {
|
|
62
78
|
if (value) {
|
|
63
79
|
if (value[mapping]) {
|
|
@@ -66,22 +82,22 @@ var MapTable = function MapTable(props) {
|
|
|
66
82
|
}
|
|
67
83
|
}, [value]);
|
|
68
84
|
React.useEffect(function () {
|
|
69
|
-
setDisableArray(new Array(Math.min(tableDataSource === null || tableDataSource === void 0 ? void 0 : tableDataSource.length,
|
|
85
|
+
setDisableArray(new Array(Math.min(tableDataSource === null || tableDataSource === void 0 ? void 0 : tableDataSource.length, tableDataTarget === null || tableDataTarget === void 0 ? void 0 : tableDataTarget.length)).fill(true));
|
|
70
86
|
}, []);
|
|
71
87
|
React.useEffect(function () {
|
|
72
88
|
if (disableArray) {
|
|
73
89
|
var _mapping = [];
|
|
74
90
|
disableArray.forEach(function (_, idx) {
|
|
75
91
|
if (disableArray[idx]) {
|
|
76
|
-
var _tableDataSource$idx, _tableDataSource$idx2,
|
|
92
|
+
var _tableDataSource$idx, _tableDataSource$idx2, _tableDataTarget$idx, _tableDataTarget$idx2;
|
|
77
93
|
_mapping.push({
|
|
78
94
|
src: {
|
|
79
95
|
name: (_tableDataSource$idx = tableDataSource[idx]) === null || _tableDataSource$idx === void 0 ? void 0 : _tableDataSource$idx.name,
|
|
80
96
|
dataType: (_tableDataSource$idx2 = tableDataSource[idx]) === null || _tableDataSource$idx2 === void 0 ? void 0 : _tableDataSource$idx2.type
|
|
81
97
|
},
|
|
82
98
|
dst: {
|
|
83
|
-
name: (
|
|
84
|
-
dataType: (
|
|
99
|
+
name: (_tableDataTarget$idx = tableDataTarget[idx]) === null || _tableDataTarget$idx === void 0 ? void 0 : _tableDataTarget$idx.name,
|
|
100
|
+
dataType: (_tableDataTarget$idx2 = tableDataTarget[idx]) === null || _tableDataTarget$idx2 === void 0 ? void 0 : _tableDataTarget$idx2.type
|
|
85
101
|
}
|
|
86
102
|
});
|
|
87
103
|
}
|
|
@@ -92,6 +108,12 @@ var MapTable = function MapTable(props) {
|
|
|
92
108
|
});
|
|
93
109
|
}
|
|
94
110
|
}, [disableArray]);
|
|
111
|
+
React.useEffect(function () {
|
|
112
|
+
var values = form.getFieldsValue().mapTable;
|
|
113
|
+
values.dataSource && setTableDataSource(values.dataSource);
|
|
114
|
+
values.dataTarget && setTableDataTarget(values.dataTarget);
|
|
115
|
+
values.options && setOptions(values.options);
|
|
116
|
+
}, [form]);
|
|
95
117
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
96
118
|
style: {
|
|
97
119
|
width: '100%',
|
|
@@ -102,7 +124,6 @@ var MapTable = function MapTable(props) {
|
|
|
102
124
|
marginBottom: '10px'
|
|
103
125
|
}
|
|
104
126
|
}, /*#__PURE__*/React.createElement(_Select, {
|
|
105
|
-
defaultValue: "a1",
|
|
106
127
|
onChange: onOutputChange,
|
|
107
128
|
value: output,
|
|
108
129
|
style: {
|
|
@@ -127,15 +148,15 @@ var MapTable = function MapTable(props) {
|
|
|
127
148
|
onRowConfirm: function onRowConfirm() {},
|
|
128
149
|
onRowDelete: function onRowDelete() {},
|
|
129
150
|
getStreamInstance: function getStreamInstance(stream) {
|
|
130
|
-
return
|
|
151
|
+
return sourceEditableStreamRef.current = stream;
|
|
131
152
|
},
|
|
132
153
|
onRowClick: function onRowClick(record) {},
|
|
133
|
-
onMove:
|
|
154
|
+
onMove: onSourceMove
|
|
134
155
|
})), /*#__PURE__*/React.createElement("div", {
|
|
135
156
|
style: {
|
|
136
157
|
marginTop: '40px'
|
|
137
158
|
}
|
|
138
|
-
}, _toConsumableArray(Array(Math.min(tableDataSource === null || tableDataSource === void 0 ? void 0 : tableDataSource.length,
|
|
159
|
+
}, _toConsumableArray(Array(Math.min(tableDataSource === null || tableDataSource === void 0 ? void 0 : tableDataSource.length, tableDataTarget === null || tableDataTarget === void 0 ? void 0 : tableDataTarget.length))).map(function (_, index) {
|
|
139
160
|
return /*#__PURE__*/React.createElement("div", {
|
|
140
161
|
key: index,
|
|
141
162
|
style: {
|
|
@@ -155,13 +176,18 @@ var MapTable = function MapTable(props) {
|
|
|
155
176
|
style: {
|
|
156
177
|
width: '40%'
|
|
157
178
|
}
|
|
158
|
-
}, /*#__PURE__*/React.createElement(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
columns:
|
|
162
|
-
dataSource:
|
|
163
|
-
|
|
164
|
-
|
|
179
|
+
}, /*#__PURE__*/React.createElement(Editable, {
|
|
180
|
+
readonly: true,
|
|
181
|
+
type: "single",
|
|
182
|
+
columns: columnSource,
|
|
183
|
+
dataSource: tableDataTarget,
|
|
184
|
+
onRowConfirm: function onRowConfirm() {},
|
|
185
|
+
onRowDelete: function onRowDelete() {},
|
|
186
|
+
getStreamInstance: function getStreamInstance(stream) {
|
|
187
|
+
return targetEditableStreamRef.current = stream;
|
|
188
|
+
},
|
|
189
|
+
onRowClick: function onRowClick(record) {},
|
|
190
|
+
onMove: onTargetMove
|
|
165
191
|
})))));
|
|
166
192
|
};
|
|
167
193
|
export default MapTable;
|