ronds-metadata 1.2.8 → 1.2.10
Sign up to get free protection for your applications and to get access to all the features.
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Table.d.ts +2 -0
- package/es/comps/FormGenerator/comps/Canvas/core/index.less +23 -23
- package/es/comps/FormGenerator/index.d.ts +4 -0
- package/es/comps/FormGenerator/settings/index.d.ts +668 -49
- package/es/comps/JsonEdit/index.d.ts +5 -1
- package/es/comps/MetadataForm/index.less +1 -1
- package/es/comps/MetadataForm/utils.d.ts +1 -1
- package/package.json +1 -1
- package/es/api/index.js +0 -249
- package/es/comps/DynamicPorts/comps/ContextMenu.js +0 -44
- package/es/comps/DynamicPorts/comps/DragNode.js +0 -55
- package/es/comps/DynamicPorts/comps/GraphHandler/index.js +0 -51
- package/es/comps/DynamicPorts/comps/NodeElement.js +0 -30
- package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +0 -42
- package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +0 -40
- package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +0 -55
- package/es/comps/DynamicPorts/comps/shape/connector.js +0 -19
- package/es/comps/DynamicPorts/comps/shape/edge.js +0 -91
- package/es/comps/DynamicPorts/comps/shape/node.js +0 -190
- package/es/comps/DynamicPorts/constant/index.js +0 -19
- package/es/comps/DynamicPorts/graph.js +0 -697
- package/es/comps/DynamicPorts/index.js +0 -143
- package/es/comps/DynamicPorts/interface.js +0 -6
- package/es/comps/DynamicPorts/utils.js +0 -127
- package/es/comps/Editable/DataCell/ButtonCell.js +0 -45
- package/es/comps/Editable/DataCell/ColorPicker.js +0 -33
- package/es/comps/Editable/DataCell/Input.js +0 -54
- package/es/comps/Editable/DataCell/Number.js +0 -44
- package/es/comps/Editable/DataCell/Select.js +0 -48
- package/es/comps/Editable/DataCell/Switch.js +0 -33
- package/es/comps/Editable/comps/EditableAction.js +0 -110
- package/es/comps/Editable/comps/EditableCell.js +0 -108
- package/es/comps/Editable/comps/EditableHeardCell.js +0 -172
- package/es/comps/Editable/comps/EditableRow.js +0 -118
- package/es/comps/Editable/comps/Texty.js +0 -277
- package/es/comps/Editable/index.js +0 -385
- package/es/comps/Editable/interface.js +0 -8
- package/es/comps/Editable/utils.js +0 -46
- package/es/comps/FileView/index.js +0 -198
- package/es/comps/FormGenerator/Provider.js +0 -8
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Checkbox.js +0 -17
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Color.js +0 -17
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.js +0 -16
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.js +0 -17
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/List.js +0 -17
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.js +0 -55
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.js +0 -14
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Obj.js +0 -50
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Password.js +0 -17
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Radio.js +0 -17
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.js +0 -55
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.js +0 -13
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.js +0 -14
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Upload.js +0 -17
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.js +0 -250
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.js +0 -60
- package/es/comps/FormGenerator/comps/Canvas/core/index.js +0 -313
- package/es/comps/FormGenerator/comps/Canvas/index.js +0 -216
- package/es/comps/FormGenerator/comps/Settings/index.js +0 -150
- package/es/comps/FormGenerator/comps/Sidebar/Elements.js +0 -48
- package/es/comps/FormGenerator/comps/Sidebar/index.js +0 -37
- package/es/comps/FormGenerator/index.js +0 -56
- package/es/comps/FormGenerator/settings/index.js +0 -303
- package/es/comps/FormGenerator/settings/ruleConfig.js +0 -557
- package/es/comps/FormGenerator/transformer.js +0 -214
- package/es/comps/Icons/index.js +0 -23
- package/es/comps/JsonEdit/constant/index.js +0 -87
- package/es/comps/JsonEdit/index.js +0 -217
- package/es/comps/JsonView/index.js +0 -109
- package/es/comps/MdEdit/index.js +0 -41
- package/es/comps/MdNavbar/index.js +0 -180
- package/es/comps/MdNavbar/utils.js +0 -34
- package/es/comps/MdView/index.js +0 -70
- package/es/comps/MetadataEdit/components/MetaFieldsEdit.js +0 -419
- package/es/comps/MetadataEdit/components/MetaPropsEdit.js +0 -368
- package/es/comps/MetadataEdit/constant/index.js +0 -69
- package/es/comps/MetadataEdit/hooks/index.js +0 -43
- package/es/comps/MetadataEdit/index.js +0 -255
- package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +0 -237
- package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +0 -367
- package/es/comps/MetadataEditV2/constant/index.js +0 -69
- package/es/comps/MetadataEditV2/hooks/index.js +0 -43
- package/es/comps/MetadataEditV2/index.js +0 -298
- package/es/comps/MetadataForm/DataCell/Array.js +0 -157
- package/es/comps/MetadataForm/DataCell/Input.js +0 -197
- package/es/comps/MetadataForm/DataCell/Number.js +0 -130
- package/es/comps/MetadataForm/DataCell/Ref.js +0 -323
- package/es/comps/MetadataForm/DataCell/Select.js +0 -517
- package/es/comps/MetadataForm/DataCell/Switch.js +0 -115
- package/es/comps/MetadataForm/DataCell/layout/TableArray.js +0 -359
- package/es/comps/MetadataForm/HOC/index.js +0 -111
- package/es/comps/MetadataForm/constants.js +0 -11
- package/es/comps/MetadataForm/hooks/index.js +0 -128
- package/es/comps/MetadataForm/index.js +0 -268
- package/es/comps/MetadataForm/interface.js +0 -8
- package/es/comps/MetadataForm/utils.js +0 -108
- package/es/comps/locales/en-US.js +0 -24
- package/es/comps/locales/index.js +0 -8
- package/es/comps/locales/zh-CN.js +0 -24
- package/es/config.js +0 -50
- package/es/framework/graph/index.js +0 -515
- package/es/framework/hooks/use-async-memo.js +0 -32
- package/es/framework/hooks/use-sync-scroll.js +0 -106
- package/es/framework/http/cache.js +0 -137
- package/es/framework/http/cancel.js +0 -44
- package/es/framework/http/index.js +0 -392
- package/es/framework/http/msgpack.js +0 -34
- package/es/framework/http/msgpack5/index.js +0 -84
- package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +0 -71
- package/es/framework/http/msgpack5/lib/decoder.js +0 -287
- package/es/framework/http/msgpack5/lib/encoder.js +0 -252
- package/es/framework/http/msgpack5/lib/helpers.js +0 -23
- package/es/framework/http/msgpack5/lib/streams.js +0 -93
- package/es/framework/http/types.js +0 -1
- package/es/framework/libs/jquery.min.js +0 -4022
- package/es/framework/locale/dil8/di18n.js +0 -132
- package/es/framework/locale/dil8/index.js +0 -3
- package/es/framework/locale/dil8/translate.js +0 -76
- package/es/framework/locale/dil8/util.js +0 -17
- package/es/framework/locale/index.js +0 -26
- package/es/framework/metadata/MetadataService.js +0 -169
- package/es/framework/metadata/index.js +0 -384
- package/es/framework/rxjs-hooks/useMemoSubject.js +0 -16
- package/es/framework/rxjs-hooks/useObservable.js +0 -22
- package/es/framework/rxjs-hooks/useObservableState.js +0 -45
- package/es/index.js +0 -27
- package/es/utils.js +0 -138
@@ -1,359 +0,0 @@
|
|
1
|
-
import "antd/es/form/style";
|
2
|
-
import _Form from "antd/es/form";
|
3
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
4
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
5
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
6
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
7
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
8
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
9
|
-
import React, { useRef } from 'react';
|
10
|
-
import { MetadataService } from '../../../../framework/metadata/MetadataService';
|
11
|
-
import { JsonMetadataProvider } from '../../../../framework/metadata';
|
12
|
-
import Editable from '../../../../comps/Editable';
|
13
|
-
import useObservable from '../../../../framework/rxjs-hooks/useObservable';
|
14
|
-
import { MetadataFormContext } from '../../interface';
|
15
|
-
import { assign, getLabelByProps } from '../../utils';
|
16
|
-
import { deepClone } from '../../../../utils';
|
17
|
-
import { STREAM_EVENT_TYPE } from '../../constants';
|
18
|
-
|
19
|
-
var TableArray = function TableArray(props) {
|
20
|
-
var initValue = props.initValue,
|
21
|
-
readonly = props.readonly,
|
22
|
-
rowNumber = props.rowNumber,
|
23
|
-
initEnumValue = props.initEnumValue,
|
24
|
-
addButtonHidden = props.addButtonHidden,
|
25
|
-
name = props.name,
|
26
|
-
form = props.form,
|
27
|
-
refId = props.refId;
|
28
|
-
var formContext = React.useContext(MetadataFormContext) || {};
|
29
|
-
|
30
|
-
var _React$useState = React.useState([]),
|
31
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
32
|
-
schema = _React$useState2[0],
|
33
|
-
setSchema = _React$useState2[1];
|
34
|
-
|
35
|
-
var _React$useState3 = React.useState({}),
|
36
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
37
|
-
defaultValue = _React$useState4[0],
|
38
|
-
setDefaultValue = _React$useState4[1];
|
39
|
-
|
40
|
-
var _React$useState5 = React.useState({}),
|
41
|
-
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
42
|
-
refFields = _React$useState6[0],
|
43
|
-
setRefFields = _React$useState6[1];
|
44
|
-
|
45
|
-
var refFieldsRef = React.useRef(refFields);
|
46
|
-
var firstLoadRef = useRef(true);
|
47
|
-
|
48
|
-
var _React$useState7 = React.useState(),
|
49
|
-
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
50
|
-
tblStream = _React$useState8[0],
|
51
|
-
setTblStream = _React$useState8[1];
|
52
|
-
|
53
|
-
var _React$useState9 = React.useState([]),
|
54
|
-
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
55
|
-
list = _React$useState10[0],
|
56
|
-
setList = _React$useState10[1];
|
57
|
-
|
58
|
-
var listRef = React.useRef([]);
|
59
|
-
useObservable(function (p) {
|
60
|
-
if ((p === null || p === void 0 ? void 0 : p.type) === 'setFieldsValue') {
|
61
|
-
if (typeof name === 'string' && p.payload[name]) {
|
62
|
-
setList(_toConsumableArray(p.payload[name]));
|
63
|
-
listRef.current = p.payload[name];
|
64
|
-
} else if (p.payload[name[0]]) {
|
65
|
-
var evalString = 'p.payload';
|
66
|
-
|
67
|
-
for (var i = 0; i < name.length; i++) {
|
68
|
-
evalString = "".concat(evalString, "[name[").concat(i, "]]");
|
69
|
-
}
|
70
|
-
|
71
|
-
var _list = eval(evalString) || [];
|
72
|
-
|
73
|
-
setList(_toConsumableArray(_list));
|
74
|
-
listRef.current = _list;
|
75
|
-
}
|
76
|
-
}
|
77
|
-
}, [formContext.stream$, name]);
|
78
|
-
useObservable(function (p) {
|
79
|
-
if ((p === null || p === void 0 ? void 0 : p.type) === 'onValuesChange') {
|
80
|
-
if (typeof name === 'string') {
|
81
|
-
var _p$payload;
|
82
|
-
|
83
|
-
var val = _defineProperty({}, "".concat(name), _objectSpread({
|
84
|
-
rowIdx: p === null || p === void 0 ? void 0 : (_p$payload = p.payload) === null || _p$payload === void 0 ? void 0 : _p$payload.rowIdx
|
85
|
-
}, p.payload.values));
|
86
|
-
|
87
|
-
var allVals = form.getFieldsValue();
|
88
|
-
allVals[name] = listRef.current;
|
89
|
-
formContext.stream$.next({
|
90
|
-
type: STREAM_EVENT_TYPE.ON_VALUES_CHANGE,
|
91
|
-
payload: {
|
92
|
-
val: val,
|
93
|
-
allVals: allVals
|
94
|
-
}
|
95
|
-
});
|
96
|
-
} else {
|
97
|
-
var _p$payload2;
|
98
|
-
|
99
|
-
var _val2 = {};
|
100
|
-
|
101
|
-
var _allVals = form.getFieldsValue();
|
102
|
-
|
103
|
-
assign(name, _objectSpread({
|
104
|
-
rowIdx: p === null || p === void 0 ? void 0 : (_p$payload2 = p.payload) === null || _p$payload2 === void 0 ? void 0 : _p$payload2.rowIdx
|
105
|
-
}, p.payload.values), _val2);
|
106
|
-
assign(name, _toConsumableArray(listRef.current), _allVals);
|
107
|
-
formContext.stream$.next({
|
108
|
-
type: STREAM_EVENT_TYPE.ON_VALUES_CHANGE,
|
109
|
-
payload: {
|
110
|
-
val: _val2,
|
111
|
-
allVals: _allVals
|
112
|
-
}
|
113
|
-
});
|
114
|
-
}
|
115
|
-
}
|
116
|
-
}, [tblStream]);
|
117
|
-
var getSchemaByRefId = React.useCallback( /*#__PURE__*/function () {
|
118
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(server, __TYPE__) {
|
119
|
-
var _schema, res, provider, FormCls, formCls, _fields;
|
120
|
-
|
121
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
122
|
-
while (1) {
|
123
|
-
switch (_context.prev = _context.next) {
|
124
|
-
case 0:
|
125
|
-
_schema = []; // 如果有内部类,优先在内部类里面找
|
126
|
-
|
127
|
-
if (__TYPE__.length > 0) {
|
128
|
-
_schema = __TYPE__.filter(function (it) {
|
129
|
-
return it.id === refId;
|
130
|
-
});
|
131
|
-
} // 内部类找不到 从接口里面拿
|
132
|
-
|
133
|
-
|
134
|
-
if (!(_schema.length === 0)) {
|
135
|
-
_context.next = 7;
|
136
|
-
break;
|
137
|
-
}
|
138
|
-
|
139
|
-
_context.next = 5;
|
140
|
-
return server.GetMetadataDetailById(refId);
|
141
|
-
|
142
|
-
case 5:
|
143
|
-
res = _context.sent;
|
144
|
-
|
145
|
-
if (res === null || res === void 0 ? void 0 : res.schema) {
|
146
|
-
_schema = JSON.parse(res === null || res === void 0 ? void 0 : res.schema);
|
147
|
-
}
|
148
|
-
|
149
|
-
case 7:
|
150
|
-
provider = new JsonMetadataProvider();
|
151
|
-
|
152
|
-
if (_schema.length > 0) {
|
153
|
-
provider.add_types(_schema);
|
154
|
-
FormCls = provider.get_type(_schema[0].id);
|
155
|
-
formCls = new FormCls();
|
156
|
-
_fields = formCls.__type__.__fields__;
|
157
|
-
refFieldsRef.current = _fields;
|
158
|
-
setRefFields(_objectSpread({}, _fields));
|
159
|
-
setSchema(_toConsumableArray(_schema));
|
160
|
-
setDefaultValue(_objectSpread({}, JSON.parse(JSON.stringify(formCls))));
|
161
|
-
}
|
162
|
-
|
163
|
-
case 9:
|
164
|
-
case "end":
|
165
|
-
return _context.stop();
|
166
|
-
}
|
167
|
-
}
|
168
|
-
}, _callee);
|
169
|
-
}));
|
170
|
-
|
171
|
-
return function (_x, _x2) {
|
172
|
-
return _ref.apply(this, arguments);
|
173
|
-
};
|
174
|
-
}(), [refId]);
|
175
|
-
React.useEffect(function () {
|
176
|
-
if (refId) {
|
177
|
-
var server = new MetadataService();
|
178
|
-
getSchemaByRefId(server, formContext.__TYPE__);
|
179
|
-
return function () {
|
180
|
-
server = null;
|
181
|
-
};
|
182
|
-
}
|
183
|
-
|
184
|
-
return function () {};
|
185
|
-
}, [refId]);
|
186
|
-
React.useEffect(function () {
|
187
|
-
if (initValue && firstLoadRef.current) {
|
188
|
-
if (typeof name === 'string' && initValue[name]) {
|
189
|
-
setList(_toConsumableArray(initValue[name]));
|
190
|
-
listRef.current = initValue[name];
|
191
|
-
} else if (initValue[name[0]]) {
|
192
|
-
var evalString = 'initValue';
|
193
|
-
|
194
|
-
for (var i = 0; i < name.length; i++) {
|
195
|
-
evalString = "".concat(evalString, "[name[").concat(i, "]]");
|
196
|
-
}
|
197
|
-
|
198
|
-
var _list = eval(evalString);
|
199
|
-
|
200
|
-
setList(_toConsumableArray(_list));
|
201
|
-
listRef.current = _list;
|
202
|
-
}
|
203
|
-
|
204
|
-
firstLoadRef.current = false;
|
205
|
-
}
|
206
|
-
}, [initValue, form]);
|
207
|
-
var processEnumData = React.useCallback(function (data, _extraInfo) {
|
208
|
-
var _extraInfo$enum;
|
209
|
-
|
210
|
-
var _options = [];
|
211
|
-
|
212
|
-
var _enum = deepClone(data.enum || []); // 扩展规则的value
|
213
|
-
|
214
|
-
|
215
|
-
if (_extraInfo === null || _extraInfo === void 0 ? void 0 : (_extraInfo$enum = _extraInfo.enum) === null || _extraInfo$enum === void 0 ? void 0 : _extraInfo$enum.value) {
|
216
|
-
var _extraInfo$enum2;
|
217
|
-
|
218
|
-
_enum = deepClone(_extraInfo === null || _extraInfo === void 0 ? void 0 : (_extraInfo$enum2 = _extraInfo.enum) === null || _extraInfo$enum2 === void 0 ? void 0 : _extraInfo$enum2.value);
|
219
|
-
} // 目前是更具那么的id判断的,暂未考虑重名问题
|
220
|
-
|
221
|
-
|
222
|
-
if (initEnumValue && initEnumValue[data.id]) {
|
223
|
-
_enum = deepClone(initEnumValue[data.id]);
|
224
|
-
}
|
225
|
-
|
226
|
-
_enum.forEach(function (it) {
|
227
|
-
var obj = {
|
228
|
-
label: it.value,
|
229
|
-
value: (it === null || it === void 0 ? void 0 : it.key) || (it === null || it === void 0 ? void 0 : it.value)
|
230
|
-
};
|
231
|
-
|
232
|
-
_options.push(obj);
|
233
|
-
});
|
234
|
-
|
235
|
-
return _options;
|
236
|
-
}, []);
|
237
|
-
var processColumnType = React.useCallback(function (data, _extraInfo) {
|
238
|
-
var _extraInfo$text;
|
239
|
-
|
240
|
-
if ((data === null || data === void 0 ? void 0 : data.type) === 'text' && (_extraInfo === null || _extraInfo === void 0 ? void 0 : (_extraInfo$text = _extraInfo.text) === null || _extraInfo$text === void 0 ? void 0 : _extraInfo$text.type)) {
|
241
|
-
var _extraInfo$text2;
|
242
|
-
|
243
|
-
return (_extraInfo$text2 = _extraInfo.text) === null || _extraInfo$text2 === void 0 ? void 0 : _extraInfo$text2.type;
|
244
|
-
}
|
245
|
-
|
246
|
-
return data.type;
|
247
|
-
}, []);
|
248
|
-
var processSchemaToColumns = React.useCallback(function (_properties) {
|
249
|
-
var _columns = [];
|
250
|
-
|
251
|
-
for (var i = 0; i < _properties.length; i++) {
|
252
|
-
var _extraInfo$common;
|
253
|
-
|
254
|
-
var it = _properties[i];
|
255
|
-
var extraInfo = refFieldsRef.current.get(it.id);
|
256
|
-
var obj = {
|
257
|
-
title: getLabelByProps(it),
|
258
|
-
key: it.id,
|
259
|
-
dataIndex: it.id,
|
260
|
-
width: processColumnType(it, extraInfo) === 'buttonCell' ? 25 : 50,
|
261
|
-
editable: !(extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$common = extraInfo.common) === null || _extraInfo$common === void 0 ? void 0 : _extraInfo$common.disabled),
|
262
|
-
type: processColumnType(it, extraInfo),
|
263
|
-
enum: it.type === 'enum' ? processEnumData(it, extraInfo) : undefined
|
264
|
-
};
|
265
|
-
|
266
|
-
_columns.push(obj);
|
267
|
-
}
|
268
|
-
|
269
|
-
return _columns;
|
270
|
-
}, []);
|
271
|
-
var columns = React.useMemo(function () {
|
272
|
-
var _columns = [];
|
273
|
-
|
274
|
-
if (schema.length > 0) {
|
275
|
-
_columns = processSchemaToColumns(schema[0].properties);
|
276
|
-
}
|
277
|
-
|
278
|
-
return _columns;
|
279
|
-
}, [schema, processSchemaToColumns]);
|
280
|
-
|
281
|
-
var onTableChange = function onTableChange(values) {
|
282
|
-
if (typeof name === 'string') {
|
283
|
-
var allVals = form.getFieldsValue();
|
284
|
-
allVals[name] = values;
|
285
|
-
formContext.stream$.next({
|
286
|
-
type: STREAM_EVENT_TYPE.ON_VALUES_CHANGE,
|
287
|
-
payload: {
|
288
|
-
val: _defineProperty({}, name, values),
|
289
|
-
allVals: allVals
|
290
|
-
}
|
291
|
-
});
|
292
|
-
form.setFieldsValue(_objectSpread({}, _defineProperty({}, "".concat(name), values)));
|
293
|
-
} else {
|
294
|
-
var val = {};
|
295
|
-
assign(name, _toConsumableArray(values), val);
|
296
|
-
|
297
|
-
var _allVals2 = form.getFieldsValue();
|
298
|
-
|
299
|
-
assign(name, _toConsumableArray(values), _allVals2);
|
300
|
-
formContext.stream$.next({
|
301
|
-
type: STREAM_EVENT_TYPE.ON_VALUES_CHANGE,
|
302
|
-
payload: {
|
303
|
-
val: val,
|
304
|
-
allVals: _allVals2
|
305
|
-
}
|
306
|
-
});
|
307
|
-
form.setFieldsValue(_objectSpread({}, val));
|
308
|
-
}
|
309
|
-
|
310
|
-
listRef.current = values;
|
311
|
-
};
|
312
|
-
|
313
|
-
var onButtonCellClick = function onButtonCellClick(record) {
|
314
|
-
formContext.stream$.next({
|
315
|
-
type: 'onButtonCellClick',
|
316
|
-
payload: record
|
317
|
-
});
|
318
|
-
};
|
319
|
-
|
320
|
-
var getCellHeight = React.useCallback(function (_readonly) {
|
321
|
-
return _readonly ? 30 : 33;
|
322
|
-
}, []);
|
323
|
-
return /*#__PURE__*/React.createElement("div", {
|
324
|
-
style: {
|
325
|
-
width: '100%',
|
326
|
-
padding: '0 0 8px',
|
327
|
-
height: addButtonHidden || readonly ? "".concat(rowNumber * getCellHeight(readonly) + 45, "px") : "".concat(rowNumber * getCellHeight(readonly) + 45 + 40, "px")
|
328
|
-
}
|
329
|
-
}, /*#__PURE__*/React.createElement(_Form.Item, {
|
330
|
-
name: name,
|
331
|
-
noStyle: true,
|
332
|
-
style: {
|
333
|
-
margin: 0,
|
334
|
-
height: '100%'
|
335
|
-
}
|
336
|
-
}, /*#__PURE__*/React.createElement(Editable, {
|
337
|
-
type: "multiple",
|
338
|
-
readonly: readonly,
|
339
|
-
defaultValue: defaultValue,
|
340
|
-
addPosition: "bottom",
|
341
|
-
isAddRow: !addButtonHidden,
|
342
|
-
isAction: !addButtonHidden,
|
343
|
-
columns: columns,
|
344
|
-
dataSource: list,
|
345
|
-
onMulChange: onTableChange,
|
346
|
-
onButtonCellClick: onButtonCellClick,
|
347
|
-
getStreamInstance: function getStreamInstance(_tblStream) {
|
348
|
-
setTblStream(_tblStream);
|
349
|
-
},
|
350
|
-
tableProps: {
|
351
|
-
scroll: {
|
352
|
-
x: '100%',
|
353
|
-
y: addButtonHidden || readonly ? "".concat(rowNumber * getCellHeight(readonly) + 45, "px ") : "".concat(rowNumber * getCellHeight(readonly), "px ")
|
354
|
-
}
|
355
|
-
}
|
356
|
-
})));
|
357
|
-
};
|
358
|
-
|
359
|
-
export default TableArray;
|
@@ -1,111 +0,0 @@
|
|
1
|
-
import "antd/es/col/style";
|
2
|
-
import _Col from "antd/es/col";
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
4
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
5
|
-
import React from 'react';
|
6
|
-
import { deepClone } from '../../../utils';
|
7
|
-
import { useWatchDepend } from '../hooks';
|
8
|
-
import { MetadataFormContext } from '../interface';
|
9
|
-
import './index.less';
|
10
|
-
export function withAddOnAfter(WrappedComponent) {
|
11
|
-
return function (props) {
|
12
|
-
var _fields$, _fields$$value, _fields$$value$common, _fields$4, _fields$4$value, _fields$4$value$commo, _fields$4$value$commo2;
|
13
|
-
|
14
|
-
var type = props.type,
|
15
|
-
refId = props.refId,
|
16
|
-
isShowTypeInfo = props.isShowTypeInfo,
|
17
|
-
fields = props.fields,
|
18
|
-
colSpan = props.colSpan,
|
19
|
-
field = props.field,
|
20
|
-
id = props.id,
|
21
|
-
_props$name = props.name,
|
22
|
-
name = _props$name === void 0 ? [] : _props$name,
|
23
|
-
isObj = props.isObj;
|
24
|
-
var formContext = React.useContext(MetadataFormContext) || {};
|
25
|
-
var depend = useWatchDepend(fields && ((_fields$ = fields[0]) === null || _fields$ === void 0 ? void 0 : (_fields$$value = _fields$.value) === null || _fields$$value === void 0 ? void 0 : (_fields$$value$common = _fields$$value.common) === null || _fields$$value$common === void 0 ? void 0 : _fields$$value$common.depend), formContext === null || formContext === void 0 ? void 0 : formContext.stream$);
|
26
|
-
|
27
|
-
var _React$useState = React.useState(),
|
28
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
29
|
-
help = _React$useState2[0],
|
30
|
-
setHelp = _React$useState2[1];
|
31
|
-
|
32
|
-
var _React$useState3 = React.useState(),
|
33
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
34
|
-
cellColSpan = _React$useState4[0],
|
35
|
-
setCellColSpan = _React$useState4[1];
|
36
|
-
|
37
|
-
var labelSpan = React.useMemo(function () {
|
38
|
-
var _fields$0$value, _fields$0$value$commo;
|
39
|
-
|
40
|
-
var _labelSpan = formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan;
|
41
|
-
|
42
|
-
var _colSpan = fields && ((_fields$0$value = fields[0].value) === null || _fields$0$value === void 0 ? void 0 : (_fields$0$value$commo = _fields$0$value.common) === null || _fields$0$value$commo === void 0 ? void 0 : _fields$0$value$commo.colSpan);
|
43
|
-
|
44
|
-
var _formLabelSpan = formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan;
|
45
|
-
|
46
|
-
if (_colSpan && _formLabelSpan) {
|
47
|
-
_labelSpan = _formLabelSpan / _colSpan;
|
48
|
-
}
|
49
|
-
|
50
|
-
return _labelSpan;
|
51
|
-
}, [fields, formContext === null || formContext === void 0 ? void 0 : formContext.colSpan, formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan]);
|
52
|
-
React.useEffect(function () {
|
53
|
-
if (refId) {
|
54
|
-
var arr = refId.split(':');
|
55
|
-
setHelp(arr[arr.length - 1]);
|
56
|
-
}
|
57
|
-
|
58
|
-
return function () {};
|
59
|
-
}, [refId]);
|
60
|
-
React.useEffect(function () {
|
61
|
-
var _fields$2, _fields$2$value, _fields$2$value$commo, _fields$3, _fields$3$value;
|
62
|
-
|
63
|
-
var _colSpan = colSpan;
|
64
|
-
var compColSpan = fields && (((_fields$2 = fields[0]) === null || _fields$2 === void 0 ? void 0 : (_fields$2$value = _fields$2.value) === null || _fields$2$value === void 0 ? void 0 : (_fields$2$value$commo = _fields$2$value.common) === null || _fields$2$value$commo === void 0 ? void 0 : _fields$2$value$commo.colSpan) || ((_fields$3 = fields[0]) === null || _fields$3 === void 0 ? void 0 : (_fields$3$value = _fields$3.value) === null || _fields$3$value === void 0 ? void 0 : _fields$3$value.colSpan));
|
65
|
-
|
66
|
-
if (compColSpan) {
|
67
|
-
_colSpan = compColSpan * colSpan <= 24 ? compColSpan * colSpan : 24;
|
68
|
-
}
|
69
|
-
|
70
|
-
setCellColSpan(_colSpan);
|
71
|
-
}, [fields, colSpan]);
|
72
|
-
|
73
|
-
var _name = React.useMemo(function () {
|
74
|
-
if (id && name.length > 0 && !field) {
|
75
|
-
var res = deepClone(name);
|
76
|
-
res.push(id);
|
77
|
-
return res;
|
78
|
-
}
|
79
|
-
|
80
|
-
return [id];
|
81
|
-
}, [id, name]);
|
82
|
-
|
83
|
-
if (depend === null || depend === void 0 ? void 0 : depend.hidden) {
|
84
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
85
|
-
}
|
86
|
-
|
87
|
-
if (fields && ((_fields$4 = fields[0]) === null || _fields$4 === void 0 ? void 0 : (_fields$4$value = _fields$4.value) === null || _fields$4$value === void 0 ? void 0 : (_fields$4$value$commo = _fields$4$value.common) === null || _fields$4$value$commo === void 0 ? void 0 : (_fields$4$value$commo2 = _fields$4$value$commo.depend) === null || _fields$4$value$commo2 === void 0 ? void 0 : _fields$4$value$commo2.show) && !(depend === null || depend === void 0 ? void 0 : depend.show)) {
|
88
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
89
|
-
}
|
90
|
-
|
91
|
-
return /*#__PURE__*/React.createElement(_Col, {
|
92
|
-
key: id,
|
93
|
-
span: cellColSpan
|
94
|
-
}, /*#__PURE__*/React.createElement("div", {
|
95
|
-
key: "".concat(_name.toString(), "_div"),
|
96
|
-
className: "with-add-on-after"
|
97
|
-
}, /*#__PURE__*/React.createElement(WrappedComponent, _extends({
|
98
|
-
key: "".concat(_name.toString(), "_Wrapped}")
|
99
|
-
}, props, {
|
100
|
-
style: {
|
101
|
-
padding: '0px',
|
102
|
-
display: 'flex !important'
|
103
|
-
},
|
104
|
-
name: _name,
|
105
|
-
labelSpan: labelSpan,
|
106
|
-
isObj: isObj
|
107
|
-
})), isShowTypeInfo && !field && type !== 'number' && type !== 'bool' && /*#__PURE__*/React.createElement("div", {
|
108
|
-
className: "with-add-on-after-extra"
|
109
|
-
}, help !== null && help !== void 0 ? help : type)));
|
110
|
-
};
|
111
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* @Author: wangxian
|
3
|
-
* @Date: 2023-02-03 09:08:06
|
4
|
-
* @LastEditTime: 2023-02-03 09:10:19
|
5
|
-
*/
|
6
|
-
export var STREAM_EVENT_TYPE = {
|
7
|
-
ON_SELECT_CHANGE: 'onSelectChange',
|
8
|
-
ON_BUTTON_CELL_CLICK: 'onButtonCellClick',
|
9
|
-
ON_VALUES_CHANGE: 'onValuesChange',
|
10
|
-
ON_WATCH_DEPEND: 'onWatchDepend'
|
11
|
-
};
|
@@ -1,128 +0,0 @@
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
4
|
-
|
5
|
-
/*
|
6
|
-
* @Author: your name
|
7
|
-
* @Date: 2021-09-18 14:15:04
|
8
|
-
* @LastEditTime: 2023-02-23 14:53:08
|
9
|
-
*/
|
10
|
-
import { getLocale } from '../../../framework/locale';
|
11
|
-
import moment from 'moment';
|
12
|
-
import React from 'react';
|
13
|
-
import { STREAM_EVENT_TYPE } from '../constants'; // 主题样式名映射
|
14
|
-
|
15
|
-
var languageMap = {
|
16
|
-
'zh-CN': 'common',
|
17
|
-
'en-US': 'common-en-US'
|
18
|
-
};
|
19
|
-
export var useGetExtraInfo = function useGetExtraInfo(fields, id, form, type) {
|
20
|
-
var _React$useState = React.useState({}),
|
21
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
22
|
-
extra = _React$useState2[0],
|
23
|
-
setExtra = _React$useState2[1];
|
24
|
-
|
25
|
-
React.useEffect(function () {
|
26
|
-
if (fields) {
|
27
|
-
var extraInfo = fields.get(id);
|
28
|
-
|
29
|
-
if (extraInfo) {
|
30
|
-
// 将map转化为对象
|
31
|
-
var _extraInfo = {};
|
32
|
-
|
33
|
-
for (var k in extraInfo) {
|
34
|
-
_extraInfo[k] = extraInfo[k];
|
35
|
-
}
|
36
|
-
|
37
|
-
// 兼容 common公共的属性
|
38
|
-
if (_extraInfo['common-en-US']) {
|
39
|
-
_extraInfo = _objectSpread(_objectSpread(_objectSpread({}, _extraInfo), _extraInfo[languageMap[getLocale()]]), _extraInfo[type]);
|
40
|
-
} else {
|
41
|
-
_extraInfo = _objectSpread(_objectSpread(_objectSpread({}, _extraInfo), _extraInfo.common), _extraInfo[type]);
|
42
|
-
}
|
43
|
-
|
44
|
-
delete _extraInfo.common;
|
45
|
-
delete _extraInfo['common-en-US'];
|
46
|
-
delete _extraInfo[type];
|
47
|
-
|
48
|
-
// 时间格式转化
|
49
|
-
if (_extraInfo.type === 'datePicker' && form.getFieldValue(id)) {
|
50
|
-
form.setFieldsValue(_defineProperty({}, id, moment(form.getFieldValue(id), 'YYYY-MM-DD HH:mm:ss')));
|
51
|
-
}
|
52
|
-
|
53
|
-
setExtra(_objectSpread({}, _extraInfo));
|
54
|
-
}
|
55
|
-
}
|
56
|
-
}, [fields, form, id]);
|
57
|
-
return extra;
|
58
|
-
}; // 处理depend联动
|
59
|
-
|
60
|
-
export var useWatchDepend = function useWatchDepend(_depends, stream$) {
|
61
|
-
var _React$useState3 = React.useState({}),
|
62
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
63
|
-
depends = _React$useState4[0],
|
64
|
-
setDepends = _React$useState4[1];
|
65
|
-
|
66
|
-
var dependsRef = React.useRef({});
|
67
|
-
React.useEffect(function () {
|
68
|
-
if (_depends && stream$) {
|
69
|
-
stream$.subscribe(function (p) {
|
70
|
-
if ((p === null || p === void 0 ? void 0 : p.type) === STREAM_EVENT_TYPE.ON_VALUES_CHANGE) {
|
71
|
-
if (_depends === null || _depends === void 0 ? void 0 : _depends.hidden) {
|
72
|
-
var _p$payload;
|
73
|
-
|
74
|
-
var _hidden = processDependHiddenOrShow(_depends === null || _depends === void 0 ? void 0 : _depends.hidden, p === null || p === void 0 ? void 0 : (_p$payload = p.payload) === null || _p$payload === void 0 ? void 0 : _p$payload.allVals, stream$);
|
75
|
-
|
76
|
-
var _dr = dependsRef.current;
|
77
|
-
_dr.hidden = _hidden;
|
78
|
-
setDepends(_objectSpread({}, _dr));
|
79
|
-
dependsRef.current = _dr;
|
80
|
-
}
|
81
|
-
|
82
|
-
if (_depends === null || _depends === void 0 ? void 0 : _depends.show) {
|
83
|
-
var _p$payload2;
|
84
|
-
|
85
|
-
var _show = processDependHiddenOrShow(_depends === null || _depends === void 0 ? void 0 : _depends.show, p === null || p === void 0 ? void 0 : (_p$payload2 = p.payload) === null || _p$payload2 === void 0 ? void 0 : _p$payload2.allVals, stream$);
|
86
|
-
|
87
|
-
var _dr2 = dependsRef.current;
|
88
|
-
_dr2.show = _show;
|
89
|
-
setDepends(_objectSpread({}, _dr2));
|
90
|
-
dependsRef.current = _dr2;
|
91
|
-
}
|
92
|
-
}
|
93
|
-
});
|
94
|
-
}
|
95
|
-
}, [_depends, stream$]);
|
96
|
-
return depends;
|
97
|
-
};
|
98
|
-
|
99
|
-
var processDependHiddenOrShow = function processDependHiddenOrShow(depend, changeData, stream$) {
|
100
|
-
try {
|
101
|
-
// const regex = /\w+(\.\w+)?[=<>!]{1}/g;
|
102
|
-
var regex = /\w+(\.\w+)?[=<>!]{1}|\w+(\.\w+)?(\.indexOf\('\w+'\)[=<>!]{1})/g;
|
103
|
-
var keys = depend.trim().match(regex);
|
104
|
-
|
105
|
-
if (!keys) {
|
106
|
-
return false;
|
107
|
-
}
|
108
|
-
|
109
|
-
var expression = depend;
|
110
|
-
|
111
|
-
for (var i = 0; i < keys.length; i++) {
|
112
|
-
var key = keys[i].substring(0, keys[i].length - 1); // 处理.length 之类的状况
|
113
|
-
|
114
|
-
var _key = key.split('.');
|
115
|
-
|
116
|
-
if (changeData[_key[0]] || changeData[_key[0]] === 0) {
|
117
|
-
var r = key === _key[0] ? "'".concat(changeData[_key[0]], "'") : eval("changeData[_key[0]].".concat(_key[1]));
|
118
|
-
expression = expression.replace(key, r);
|
119
|
-
} else {
|
120
|
-
expression = expression.replace(key, undefined);
|
121
|
-
}
|
122
|
-
}
|
123
|
-
|
124
|
-
return eval(expression);
|
125
|
-
} catch (error) {
|
126
|
-
console.error("useWatchDepend.expression is error", error);
|
127
|
-
}
|
128
|
-
};
|