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.
Files changed (121) hide show
  1. package/es/api/index.js +249 -0
  2. package/es/comps/DynamicPorts/comps/ContextMenu.js +44 -0
  3. package/es/comps/DynamicPorts/comps/DragNode.js +55 -0
  4. package/es/comps/DynamicPorts/comps/GraphHandler/index.js +51 -0
  5. package/es/comps/DynamicPorts/comps/NodeElement.js +30 -0
  6. package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +42 -0
  7. package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +40 -0
  8. package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +55 -0
  9. package/es/comps/DynamicPorts/comps/shape/connector.js +19 -0
  10. package/es/comps/DynamicPorts/comps/shape/edge.js +91 -0
  11. package/es/comps/DynamicPorts/comps/shape/node.js +190 -0
  12. package/es/comps/DynamicPorts/constant/index.js +19 -0
  13. package/es/comps/DynamicPorts/graph.js +697 -0
  14. package/es/comps/DynamicPorts/index.js +143 -0
  15. package/es/comps/DynamicPorts/interface.js +6 -0
  16. package/es/comps/DynamicPorts/utils.js +127 -0
  17. package/es/comps/Editable/DataCell/ButtonCell.js +45 -0
  18. package/es/comps/Editable/DataCell/ColorPicker.js +33 -0
  19. package/es/comps/Editable/DataCell/Input.js +54 -0
  20. package/es/comps/Editable/DataCell/Number.js +44 -0
  21. package/es/comps/Editable/DataCell/Select.js +48 -0
  22. package/es/comps/Editable/DataCell/Switch.js +33 -0
  23. package/es/comps/Editable/comps/EditableAction.js +110 -0
  24. package/es/comps/Editable/comps/EditableCell.js +108 -0
  25. package/es/comps/Editable/comps/EditableHeardCell.js +172 -0
  26. package/es/comps/Editable/comps/EditableRow.js +118 -0
  27. package/es/comps/Editable/comps/Texty.js +277 -0
  28. package/es/comps/Editable/index.js +386 -0
  29. package/es/comps/Editable/interface.js +8 -0
  30. package/es/comps/Editable/utils.js +46 -0
  31. package/es/comps/FileView/index.js +198 -0
  32. package/es/comps/FormGenerator/Provider.js +8 -0
  33. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Checkbox.js +69 -0
  34. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Color.js +17 -0
  35. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.js +16 -0
  36. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.js +17 -0
  37. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/List.js +50 -0
  38. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.js +55 -0
  39. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.js +14 -0
  40. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Obj.js +50 -0
  41. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Password.js +17 -0
  42. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Radio.js +69 -0
  43. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.js +55 -0
  44. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.js +13 -0
  45. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Table.js +50 -0
  46. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.js +14 -0
  47. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Upload.js +27 -0
  48. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.js +261 -0
  49. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.js +62 -0
  50. package/es/comps/FormGenerator/comps/Canvas/core/index.js +315 -0
  51. package/es/comps/FormGenerator/comps/Canvas/index.js +120 -0
  52. package/es/comps/FormGenerator/comps/Settings/index.js +150 -0
  53. package/es/comps/FormGenerator/comps/Sidebar/Elements.js +48 -0
  54. package/es/comps/FormGenerator/comps/Sidebar/index.js +37 -0
  55. package/es/comps/FormGenerator/index.js +68 -0
  56. package/es/comps/FormGenerator/settings/index.js +367 -0
  57. package/es/comps/FormGenerator/settings/ruleConfig.js +557 -0
  58. package/es/comps/FormGenerator/transformer.js +300 -0
  59. package/es/comps/Icons/index.js +23 -0
  60. package/es/comps/JsonEdit/constant/index.js +87 -0
  61. package/es/comps/JsonEdit/index.js +221 -0
  62. package/es/comps/JsonView/index.js +109 -0
  63. package/es/comps/MdEdit/index.js +41 -0
  64. package/es/comps/MdNavbar/index.js +180 -0
  65. package/es/comps/MdNavbar/utils.js +34 -0
  66. package/es/comps/MdView/index.js +70 -0
  67. package/es/comps/MetadataEdit/components/MetaFieldsEdit.js +419 -0
  68. package/es/comps/MetadataEdit/components/MetaPropsEdit.js +368 -0
  69. package/es/comps/MetadataEdit/constant/index.js +69 -0
  70. package/es/comps/MetadataEdit/hooks/index.js +43 -0
  71. package/es/comps/MetadataEdit/index.js +255 -0
  72. package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +237 -0
  73. package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +367 -0
  74. package/es/comps/MetadataEditV2/constant/index.js +69 -0
  75. package/es/comps/MetadataEditV2/hooks/index.js +43 -0
  76. package/es/comps/MetadataEditV2/index.js +298 -0
  77. package/es/comps/MetadataForm/DataCell/Array.js +148 -0
  78. package/es/comps/MetadataForm/DataCell/Input.js +198 -0
  79. package/es/comps/MetadataForm/DataCell/Number.js +130 -0
  80. package/es/comps/MetadataForm/DataCell/Ref.js +326 -0
  81. package/es/comps/MetadataForm/DataCell/Select.js +557 -0
  82. package/es/comps/MetadataForm/DataCell/Switch.js +115 -0
  83. package/es/comps/MetadataForm/DataCell/layout/TableArray.js +359 -0
  84. package/es/comps/MetadataForm/HOC/index.js +125 -0
  85. package/es/comps/MetadataForm/constants.js +11 -0
  86. package/es/comps/MetadataForm/hooks/index.js +128 -0
  87. package/es/comps/MetadataForm/index.js +268 -0
  88. package/es/comps/MetadataForm/interface.js +8 -0
  89. package/es/comps/MetadataForm/utils.js +112 -0
  90. package/es/comps/locales/en-US.js +24 -0
  91. package/es/comps/locales/index.js +8 -0
  92. package/es/comps/locales/zh-CN.js +24 -0
  93. package/es/config.js +50 -0
  94. package/es/framework/graph/index.js +515 -0
  95. package/es/framework/hooks/use-async-memo.js +32 -0
  96. package/es/framework/hooks/use-sync-scroll.js +106 -0
  97. package/es/framework/http/cache.js +137 -0
  98. package/es/framework/http/cancel.js +44 -0
  99. package/es/framework/http/index.js +392 -0
  100. package/es/framework/http/msgpack.js +34 -0
  101. package/es/framework/http/msgpack5/index.js +84 -0
  102. package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +71 -0
  103. package/es/framework/http/msgpack5/lib/decoder.js +287 -0
  104. package/es/framework/http/msgpack5/lib/encoder.js +252 -0
  105. package/es/framework/http/msgpack5/lib/helpers.js +23 -0
  106. package/es/framework/http/msgpack5/lib/streams.js +93 -0
  107. package/es/framework/http/types.js +1 -0
  108. package/es/framework/libs/jquery.min.js +4022 -0
  109. package/es/framework/locale/dil8/di18n.js +132 -0
  110. package/es/framework/locale/dil8/index.js +3 -0
  111. package/es/framework/locale/dil8/translate.js +76 -0
  112. package/es/framework/locale/dil8/util.js +17 -0
  113. package/es/framework/locale/index.js +26 -0
  114. package/es/framework/metadata/MetadataService.js +169 -0
  115. package/es/framework/metadata/index.js +384 -0
  116. package/es/framework/rxjs-hooks/useMemoSubject.js +16 -0
  117. package/es/framework/rxjs-hooks/useObservable.js +22 -0
  118. package/es/framework/rxjs-hooks/useObservableState.js +45 -0
  119. package/es/index.js +27 -0
  120. package/es/utils.js +138 -0
  121. package/package.json +1 -1
@@ -0,0 +1,298 @@
1
+ import "antd/es/drawer/style";
2
+ import _Drawer from "antd/es/drawer";
3
+ import "antd/es/button/style";
4
+ import _Button from "antd/es/button";
5
+ import "antd/es/select/style";
6
+ import _Select from "antd/es/select";
7
+ import "antd/es/input/style";
8
+ import _Input from "antd/es/input";
9
+ import "antd/es/message/style";
10
+ import _message from "antd/es/message";
11
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
12
+ import "antd/es/form/style";
13
+ import _Form from "antd/es/form";
14
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
15
+ import React from 'react';
16
+ import './index.less';
17
+ import MetaFieldsEdit from './components/MetaFieldsEdit';
18
+ import MetaPropsEdit from './components/MetaPropsEdit';
19
+ import { OUTERMOST_TYPES_OPTIONS } from './constant';
20
+
21
+ var MetadataEditV2 = function MetadataEditV2(props) {
22
+ var initialValues = props.initialValues,
23
+ isNameDisabled = props.isNameDisabled,
24
+ metadataTag = props.metadataTag,
25
+ onFinish = props.onFinish,
26
+ onNewRefClick = props.onNewRefClick;
27
+
28
+ var _Form$useForm = _Form.useForm(),
29
+ _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
30
+ form = _Form$useForm2[0];
31
+
32
+ var _React$useState = React.useState('object'),
33
+ _React$useState2 = _slicedToArray(_React$useState, 2),
34
+ outerType = _React$useState2[0],
35
+ setOutType = _React$useState2[1];
36
+
37
+ var _React$useState3 = React.useState({
38
+ id: '',
39
+ type: 'object'
40
+ }),
41
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
42
+ metaSchema = _React$useState4[0],
43
+ setMetaSchema = _React$useState4[1];
44
+
45
+ var metaSchemaRef = React.useRef({
46
+ id: '',
47
+ type: 'object'
48
+ });
49
+ var firstLoadRef = React.useRef(true);
50
+
51
+ var _React$useState5 = React.useState(false),
52
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
53
+ isFields = _React$useState6[0],
54
+ setIsFields = _React$useState6[1];
55
+
56
+ var _React$useState7 = React.useState({}),
57
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
58
+ fields = _React$useState8[0],
59
+ setFields = _React$useState8[1];
60
+
61
+ var _React$useState9 = React.useState({}),
62
+ _React$useState10 = _slicedToArray(_React$useState9, 2),
63
+ curFields = _React$useState10[0],
64
+ setCurFields = _React$useState10[1];
65
+
66
+ React.useEffect(function () {
67
+ form.setFieldsValue({
68
+ id: 'Test'
69
+ });
70
+ form.setFieldsValue({
71
+ type: 'object'
72
+ });
73
+ }, [form]);
74
+ React.useEffect(function () {
75
+ if (initialValues && firstLoadRef.current) {
76
+ form.setFieldsValue(_objectSpread({}, initialValues));
77
+ setMetaSchema(_objectSpread({}, initialValues));
78
+ metaSchemaRef.current = initialValues;
79
+ processFileds(initialValues);
80
+ firstLoadRef.current = false;
81
+ }
82
+ }, [form, initialValues]);
83
+
84
+ var onMyFinish = function onMyFinish(values) {
85
+ // console.log('values:', values, JSON.stringify(values));
86
+ // console.log('values:', values);
87
+ var _metaSchema = metaSchemaRef.current;
88
+ _metaSchema.id = values.id;
89
+ _metaSchema.type = values.type;
90
+
91
+ if (values === null || values === void 0 ? void 0 : values.properties) {
92
+ _metaSchema.properties = values.properties;
93
+
94
+ var _loop = function _loop(i) {
95
+ var ele = _metaSchema.properties[i];
96
+ var curFields = fields[_metaSchema.properties[i].id];
97
+
98
+ if (curFields) {
99
+ _metaSchema.properties[i].fields = curFields;
100
+ }
101
+
102
+ var propKeys = Object.keys(ele);
103
+ var needOptKeys = ['name', 'code', 'desc'];
104
+
105
+ if (ele.fields) {
106
+ propKeys.forEach(function (propKey) {
107
+ if (needOptKeys.indexOf(propKey) > -1) {
108
+ ele.fields.forEach(function (field, index) {
109
+ if (index === 0) {
110
+ if (propKey === 'name') {
111
+ field.value[propKey] = ele[propKey];
112
+ field.value.label = ele[propKey];
113
+ } else {
114
+ field.value[propKey] = ele[propKey];
115
+ }
116
+ }
117
+ });
118
+ delete ele[propKey];
119
+ }
120
+ });
121
+ } else {
122
+ ele.fields = [{
123
+ type: 'ref',
124
+ refId: 'Rule.Form',
125
+ id: 'Rule.Form',
126
+ value: {
127
+ label: '',
128
+ name: '',
129
+ code: '',
130
+ desc: ''
131
+ }
132
+ }];
133
+ propKeys.forEach(function (propKey) {
134
+ if (needOptKeys.indexOf(propKey) > -1) {
135
+ ele.fields.forEach(function (field, index) {
136
+ if (index === 0) {
137
+ if (propKey === 'name') {
138
+ field.value[propKey] = ele[propKey];
139
+ field.value.label = ele[propKey];
140
+ } else {
141
+ field.value[propKey] = ele[propKey];
142
+ }
143
+ }
144
+ });
145
+ delete ele[propKey];
146
+ }
147
+ });
148
+ }
149
+ };
150
+
151
+ for (var i = 0; i < _metaSchema.properties.length; i++) {
152
+ _loop(i);
153
+ }
154
+ }
155
+
156
+ if (fields[values.id]) {
157
+ _metaSchema.fields = fields[values.id];
158
+ }
159
+
160
+ setMetaSchema(_objectSpread({}, _metaSchema));
161
+ metaSchemaRef.current = _metaSchema;
162
+ onFinish && onFinish(JSON.stringify(_metaSchema));
163
+ };
164
+
165
+ var onAddFields = function onAddFields(index) {
166
+ if (index === -1) {
167
+ var _id = form.getFieldValue('id');
168
+
169
+ if (_id) {
170
+ setIsFields(true);
171
+ setCurFields({
172
+ id: _id
173
+ });
174
+ } else {
175
+ _message.warn('请填写元数据名称');
176
+ }
177
+
178
+ return;
179
+ } // console.log('========1========', form.getFieldValue('properties'));
180
+
181
+
182
+ var _properties_from = form.getFieldValue('properties') || [];
183
+
184
+ var _properties_ref = metaSchemaRef.current.properties || [];
185
+
186
+ var _properties = _properties_from.length <= _properties_ref.length ? _properties_ref : _properties_from; // console.log('properties', _properties);
187
+
188
+
189
+ var _curFields = _properties[index];
190
+
191
+ if (_curFields && _curFields.id) {
192
+ setIsFields(true);
193
+ var idx = ((metaSchema === null || metaSchema === void 0 ? void 0 : metaSchema.fields) || []).findIndex(function (v) {
194
+ return v.id === _curFields.id;
195
+ });
196
+
197
+ if ((metaSchema === null || metaSchema === void 0 ? void 0 : metaSchema.fields) && idx >= 0) {
198
+ setCurFields(_objectSpread({}, metaSchema === null || metaSchema === void 0 ? void 0 : metaSchema.fields[idx]));
199
+ } else {
200
+ // console.log('_curFields', _curFields);
201
+ setCurFields(_objectSpread({}, _curFields));
202
+ }
203
+ } else {
204
+ _message.warn('请填写属性名称');
205
+ }
206
+ };
207
+
208
+ var onFieldsChange = function onFieldsChange(values) {
209
+ var _fields = fields;
210
+ _fields[curFields.id] = values;
211
+ setFields(_objectSpread({}, _fields));
212
+ setIsFields(false);
213
+ };
214
+
215
+ var onOuterTypeChange = function onOuterTypeChange(value) {
216
+ setOutType(value);
217
+ };
218
+
219
+ var processFileds = function processFileds(schema) {
220
+ var _properties = schema.properties;
221
+ var _fields = fields;
222
+
223
+ if (_properties) {
224
+ for (var i = 0; i < _properties.length; i++) {
225
+ if (_properties[i].fields) {
226
+ _fields[_properties[i].id] = _properties[i].fields;
227
+ }
228
+ }
229
+ }
230
+
231
+ if (schema.fields) {
232
+ _fields[schema.id] = schema.fields;
233
+ }
234
+
235
+ setFields(_objectSpread({}, _fields));
236
+ };
237
+
238
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Form, {
239
+ className: "metadata-edit",
240
+ initialValues: initialValues,
241
+ form: form,
242
+ name: "control-hooks",
243
+ onFinish: onMyFinish
244
+ }, /*#__PURE__*/React.createElement(_Form.Item, {
245
+ label: "\u540D\u79F0",
246
+ name: "id",
247
+ style: {
248
+ marginBottom: '15px'
249
+ },
250
+ rules: [{
251
+ required: true
252
+ }]
253
+ }, /*#__PURE__*/React.createElement(_Input, {
254
+ disabled: isNameDisabled
255
+ })), /*#__PURE__*/React.createElement(_Form.Item, {
256
+ label: "\u7C7B\u578B",
257
+ name: "type",
258
+ style: {
259
+ marginBottom: '15px'
260
+ },
261
+ rules: [{
262
+ required: true
263
+ }]
264
+ }, /*#__PURE__*/React.createElement(_Select, {
265
+ options: OUTERMOST_TYPES_OPTIONS,
266
+ onChange: onOuterTypeChange
267
+ })), outerType === 'object' && /*#__PURE__*/React.createElement(MetaPropsEdit, {
268
+ form: form,
269
+ metadataTag: metadataTag,
270
+ name: "properties",
271
+ onAddFields: onAddFields,
272
+ onNewRefClick: onNewRefClick
273
+ }), /*#__PURE__*/React.createElement(_Form.Item, null, /*#__PURE__*/React.createElement(_Button, {
274
+ type: "primary",
275
+ block: true,
276
+ htmlType: "submit"
277
+ }, "\u786E\u5B9A"))), /*#__PURE__*/React.createElement(_Drawer, {
278
+ title: (curFields === null || curFields === void 0 ? void 0 : curFields.id) || 'fields',
279
+ width: 450,
280
+ bodyStyle: {
281
+ padding: 0
282
+ },
283
+ placement: "right",
284
+ onClose: function onClose() {
285
+ setIsFields(false);
286
+ },
287
+ mask: false,
288
+ push: false,
289
+ visible: isFields,
290
+ destroyOnClose: true
291
+ }, /*#__PURE__*/React.createElement(MetaFieldsEdit, {
292
+ key: curFields === null || curFields === void 0 ? void 0 : curFields.id,
293
+ defaultValues: fields[curFields.id],
294
+ onChange: onFieldsChange
295
+ })));
296
+ };
297
+
298
+ export default MetadataEditV2;
@@ -0,0 +1,148 @@
1
+ import "antd/es/row/style";
2
+ import _Row from "antd/es/row";
3
+ import "antd/es/form/style";
4
+ import _Form from "antd/es/form";
5
+ import "antd/es/button/style";
6
+ import _Button from "antd/es/button";
7
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
8
+ import "antd/es/col/style";
9
+ import _Col from "antd/es/col";
10
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
11
+
12
+ /*
13
+ * @Author: wangxian
14
+ * @Date: 2021-09-18 14:15:04
15
+ * @LastEditTime: 2023-02-27 10:41:49
16
+ */
17
+ import React from 'react';
18
+ import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
19
+ import { MetadataFormContext, MetadataRefContext } from '../interface';
20
+ import { useGetExtraInfo } from '../hooks';
21
+ import { getDataCell } from '../utils';
22
+ import { tr } from '../../../framework/locale';
23
+ import TableArray from './layout/TableArray';
24
+
25
+ function Index(props) {
26
+ var _fieldRule$, _fieldRule$$value, _fieldRule$2, _fieldRule$2$value, _extraInfo$disabled;
27
+
28
+ var id = props.id,
29
+ items = props.items,
30
+ isRefForm = props.isRefForm,
31
+ fieldRule = props.fields,
32
+ colSpan = props.colSpan,
33
+ labelSpan = props.labelSpan,
34
+ initEnumValue = props.initEnumValue,
35
+ name = props.name,
36
+ disabled = props.disabled;
37
+ var formContext = React.useContext(MetadataFormContext) || {};
38
+ var refContext = React.useContext(MetadataRefContext) || {};
39
+
40
+ var _fileds = React.useMemo(function () {
41
+ var ff = formContext === null || formContext === void 0 ? void 0 : formContext.fields;
42
+
43
+ if (refContext === null || refContext === void 0 ? void 0 : refContext.fields) {
44
+ refContext === null || refContext === void 0 ? void 0 : refContext.fields.forEach(function (v, k) {
45
+ ff.set(k, v);
46
+ });
47
+ }
48
+
49
+ return ff;
50
+ }, [formContext === null || formContext === void 0 ? void 0 : formContext.fields, refContext === null || refContext === void 0 ? void 0 : refContext.fields]);
51
+
52
+ var extraInfo = useGetExtraInfo(formContext === null || formContext === void 0 ? void 0 : formContext.fields, id, formContext.form, props.type);
53
+
54
+ var _React$useState = React.useState(),
55
+ _React$useState2 = _slicedToArray(_React$useState, 2),
56
+ help = _React$useState2[0],
57
+ setHelp = _React$useState2[1];
58
+
59
+ React.useEffect(function () {
60
+ if (items && items.refId) {
61
+ var arr = items.refId.split('.');
62
+ setHelp(arr[arr.length - 1]);
63
+ }
64
+ }, [items]);
65
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Row, null, /*#__PURE__*/React.createElement(_Col, {
66
+ span: (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'vertical' && 24,
67
+ flex: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? "0 0 ".concat(labelSpan * 100 / 24, "%") : ''
68
+ }, !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) && /*#__PURE__*/React.createElement("div", {
69
+ style: {
70
+ position: 'relative',
71
+ width: '100%',
72
+ textAlign: "".concat((formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan) && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? 'right' : 'left')
73
+ }
74
+ }, /*#__PURE__*/React.createElement("div", {
75
+ className: "ant-form-item-label ant-form-item-label-wrap mt-1 "
76
+ }, /*#__PURE__*/React.createElement("label", {
77
+ className: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require) && 'ant-form-item-required')
78
+ }, extraInfo.label || fieldRule && ((_fieldRule$ = fieldRule[0]) === null || _fieldRule$ === void 0 ? void 0 : (_fieldRule$$value = _fieldRule$.value) === null || _fieldRule$$value === void 0 ? void 0 : _fieldRule$$value.label) || fieldRule && ((_fieldRule$2 = fieldRule[0]) === null || _fieldRule$2 === void 0 ? void 0 : (_fieldRule$2$value = _fieldRule$2.value) === null || _fieldRule$2$value === void 0 ? void 0 : _fieldRule$2$value.common.label) || id)), formContext.isShowTypeInfo && /*#__PURE__*/React.createElement("div", {
79
+ style: {
80
+ padding: '0 6px',
81
+ position: 'absolute',
82
+ right: '20px',
83
+ top: '19px',
84
+ background: '#fff'
85
+ }
86
+ }, help || (items === null || items === void 0 ? void 0 : items.type)))), /*#__PURE__*/React.createElement(_Col, {
87
+ flex: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? "0 0 ".concat((24 - labelSpan) * 100 / 24, "%") : 1
88
+ }, extraInfo.layout === 'table' && items.type === 'ref' ? /*#__PURE__*/React.createElement(TableArray, {
89
+ initValue: formContext.initialValues,
90
+ initEnumValue: initEnumValue,
91
+ readonly: (_extraInfo$disabled = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled !== void 0 ? _extraInfo$disabled : disabled,
92
+ addButtonHidden: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.addButtonHidden,
93
+ rowNumber: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.rowNumber) || 10,
94
+ refId: items.refId,
95
+ form: formContext.form,
96
+ name: name
97
+ }) : /*#__PURE__*/React.createElement("div", {
98
+ style: {
99
+ padding: '10px',
100
+ border: '1px solid var(--ronds-metadata-color-border-1)',
101
+ width: '100%',
102
+ borderRadius: '4px',
103
+ margin: '0 0 8px'
104
+ }
105
+ }, /*#__PURE__*/React.createElement(_Form.List, {
106
+ name: name,
107
+ key: id
108
+ }, function (fields, _ref) {
109
+ var add = _ref.add,
110
+ remove = _ref.remove;
111
+ return /*#__PURE__*/React.createElement(React.Fragment, null, fields.map(function (field, idx) {
112
+ var _extraInfo$disabled2;
113
+
114
+ return /*#__PURE__*/React.createElement("div", {
115
+ key: field.key,
116
+ style: {
117
+ display: 'flex',
118
+ width: '100%',
119
+ marginBottom: '10px'
120
+ }
121
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, getDataCell(_objectSpread(_objectSpread({}, items), {}, {
122
+ idx: idx,
123
+ id: id
124
+ }), {
125
+ disabled: (_extraInfo$disabled2 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled2 !== void 0 ? _extraInfo$disabled2 : disabled,
126
+ initEnumValue: initEnumValue,
127
+ isRefForm: isRefForm,
128
+ isShowTypeInfo: formContext.isShowTypeInfo,
129
+ field: field
130
+ }, 23), /*#__PURE__*/React.createElement(MinusCircleOutlined, {
131
+ style: {
132
+ marginLeft: '10px'
133
+ },
134
+ onClick: function onClick() {
135
+ return remove(field.name);
136
+ }
137
+ })));
138
+ }), /*#__PURE__*/React.createElement(_Form.Item, null, /*#__PURE__*/React.createElement(_Button, {
139
+ type: "dashed",
140
+ onClick: function onClick() {
141
+ return add();
142
+ },
143
+ icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
144
+ }, tr('添加'))));
145
+ })))));
146
+ }
147
+
148
+ export default /*#__PURE__*/React.memo(Index);
@@ -0,0 +1,198 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import "antd/es/form/style";
3
+ import _Form from "antd/es/form";
4
+ import "antd/es/select/style";
5
+ import _Select from "antd/es/select";
6
+ import "antd/es/upload/style";
7
+ import _Upload from "antd/es/upload";
8
+ import "antd/es/button/style";
9
+ import _Button from "antd/es/button";
10
+ import "antd/es/date-picker/style";
11
+ import _DatePicker from "antd/es/date-picker";
12
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
13
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
14
+ import "antd/es/input/style";
15
+ import _Input from "antd/es/input";
16
+
17
+ /*
18
+ * @Author: wangxian
19
+ * @Date: 2021-09-18 14:15:04
20
+ * @LastEditTime: 2023-02-25 11:21:22
21
+ */
22
+ import React from 'react';
23
+ import { UploadOutlined } from '@ant-design/icons';
24
+ import { MetadataFormContext, MetadataRefContext } from '../interface';
25
+ import { useGetExtraInfo } from '../hooks';
26
+ var TextArea = _Input.TextArea;
27
+
28
+ function Index(props) {
29
+ var _extraInfo$addonAfter6;
30
+
31
+ var id = props.id,
32
+ isRefForm = props.isRefForm,
33
+ disabled = props.disabled,
34
+ field = props.field,
35
+ labelSpan = props.labelSpan,
36
+ name = props.name,
37
+ isObj = props.isObj;
38
+ var formContext = React.useContext(MetadataFormContext) || {};
39
+ var formRefContext = React.useContext(MetadataRefContext);
40
+ var extraInfo = useGetExtraInfo(formRefContext ? formRefContext.fields : formContext.fields, id, formContext.form, props.type);
41
+
42
+ if (id === 'p' || id === 'user') {}
43
+
44
+ var _React$useState = React.useState([]),
45
+ _React$useState2 = _slicedToArray(_React$useState, 2),
46
+ rules = _React$useState2[0],
47
+ setRules = _React$useState2[1];
48
+
49
+ React.useEffect(function () {
50
+ var _rules = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.rules;
51
+
52
+ if (_rules) {
53
+ var _ = _rules.map(function (it) {
54
+ return {
55
+ pattern: new RegExp(eval(it === null || it === void 0 ? void 0 : it.regExp), 'g'),
56
+ message: it === null || it === void 0 ? void 0 : it.message
57
+ };
58
+ });
59
+
60
+ setRules(_toConsumableArray(_));
61
+ }
62
+ }, [extraInfo]);
63
+
64
+ var onChange = function onChange(e) {};
65
+
66
+ var processInputType = function processInputType(_type) {
67
+ var _extraInfo$disabled, _extraInfo$disabled2, _extraInfo$disabled3, _extraInfo$disabled4, _extraInfo$disabled5, _extraInfo$addonAfter, _extraInfo$addonAfter2, _extraInfo$addonAfter3, _extraInfo$addonAfter4, _extraInfo$disabled6;
68
+
69
+ switch (_type) {
70
+ case 'password':
71
+ return /*#__PURE__*/React.createElement(_Input.Password, {
72
+ disabled: (_extraInfo$disabled = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled !== void 0 ? _extraInfo$disabled : disabled,
73
+ placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder
74
+ });
75
+
76
+ case 'textarea':
77
+ return /*#__PURE__*/React.createElement(TextArea, {
78
+ rows: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.textareaRows) || 4,
79
+ disabled: (_extraInfo$disabled2 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled2 !== void 0 ? _extraInfo$disabled2 : disabled,
80
+ placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder
81
+ });
82
+
83
+ case 'colorPicker':
84
+ return /*#__PURE__*/React.createElement(_Input, {
85
+ type: "color",
86
+ disabled: (_extraInfo$disabled3 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled3 !== void 0 ? _extraInfo$disabled3 : disabled,
87
+ placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder
88
+ });
89
+
90
+ case 'datePicker':
91
+ return /*#__PURE__*/React.createElement(_DatePicker, {
92
+ showTime: true,
93
+ format: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.format) || DEFAULT_DATE_FORMAT,
94
+ disabled: (_extraInfo$disabled4 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled4 !== void 0 ? _extraInfo$disabled4 : disabled,
95
+ placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder
96
+ });
97
+
98
+ case 'upload':
99
+ return /*#__PURE__*/React.createElement(_Upload, null, /*#__PURE__*/React.createElement(_Button, {
100
+ disabled: (_extraInfo$disabled5 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled5 !== void 0 ? _extraInfo$disabled5 : disabled,
101
+ icon: /*#__PURE__*/React.createElement(UploadOutlined, null)
102
+ }, "\u4E0A\u4F20"));
103
+
104
+ default:
105
+ return /*#__PURE__*/React.createElement(_Input, {
106
+ addonAfter: ((_extraInfo$addonAfter = extraInfo.addonAfter) === null || _extraInfo$addonAfter === void 0 ? void 0 : _extraInfo$addonAfter.key) ? /*#__PURE__*/React.createElement(_Form.Item, {
107
+ name: [].concat(_toConsumableArray(name), [(_extraInfo$addonAfter2 = extraInfo.addonAfter) === null || _extraInfo$addonAfter2 === void 0 ? void 0 : _extraInfo$addonAfter2.key]),
108
+ noStyle: true,
109
+ initialValue: (_extraInfo$addonAfter3 = extraInfo.addonAfter) === null || _extraInfo$addonAfter3 === void 0 ? void 0 : _extraInfo$addonAfter3.defaultValue
110
+ }, /*#__PURE__*/React.createElement(_Select, null, (((_extraInfo$addonAfter4 = extraInfo.addonAfter) === null || _extraInfo$addonAfter4 === void 0 ? void 0 : _extraInfo$addonAfter4.value) || []).map(function (v) {
111
+ return /*#__PURE__*/React.createElement(_Select.Option, {
112
+ key: v,
113
+ value: v
114
+ }, v);
115
+ }))) : undefined,
116
+ disabled: (_extraInfo$disabled6 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled6 !== void 0 ? _extraInfo$disabled6 : disabled,
117
+ placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
118
+ allowClear: true,
119
+ onChange: onChange
120
+ });
121
+ }
122
+ }; // ref引用的 应用类型是否展示成表单
123
+
124
+
125
+ if (isObj && isRefForm && field) {
126
+ var _extraInfo$addonAfter5;
127
+
128
+ return /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
129
+ style: {
130
+ flex: 1,
131
+ paddingRight: '10px'
132
+ },
133
+ label: /*#__PURE__*/React.createElement("span", {
134
+ style: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.color) ? {
135
+ color: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.color
136
+ } : {}
137
+ }, (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.label) || id),
138
+ labelCol: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? {
139
+ flex: "0 0 ".concat(labelSpan * 100 / 24, "%"),
140
+ offset: 0
141
+ } : undefined,
142
+ wrapperCol: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? {
143
+ flex: "0 0 ".concat((24 - labelSpan) * 100 / 24, "%"),
144
+ offset: 0
145
+ } : undefined,
146
+ name: (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$addonAfter5 = extraInfo.addonAfter) === null || _extraInfo$addonAfter5 === void 0 ? void 0 : _extraInfo$addonAfter5.key) ? [field === null || field === void 0 ? void 0 : field.name].concat(_toConsumableArray(name), ['value']) : [field === null || field === void 0 ? void 0 : field.name].concat(_toConsumableArray(name)),
147
+ rules: [{
148
+ required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
149
+ }].concat(_toConsumableArray(rules)),
150
+ help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
151
+ tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
152
+ }), processInputType((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.type) || ''));
153
+ }
154
+
155
+ return !field ?
156
+ /*#__PURE__*/
157
+ // 不是引用的
158
+ React.createElement(_Form.Item, {
159
+ key: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.defaultValue,
160
+ initialValue: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.defaultValue,
161
+ style: {
162
+ display: "".concat(extraInfo.hidden ? 'none' : '')
163
+ },
164
+ label: /*#__PURE__*/React.createElement("span", {
165
+ style: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.color) ? {
166
+ color: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.color
167
+ } : {}
168
+ }, (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.label) || id),
169
+ labelCol: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? {
170
+ flex: "0 0 ".concat(labelSpan * 100 / 24, "%"),
171
+ offset: 0
172
+ } : undefined,
173
+ wrapperCol: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? {
174
+ flex: "0 0 ".concat((24 - labelSpan) * 100 / 24, "%"),
175
+ offset: 0
176
+ } : undefined,
177
+ name: (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$addonAfter6 = extraInfo.addonAfter) === null || _extraInfo$addonAfter6 === void 0 ? void 0 : _extraInfo$addonAfter6.key) ? [].concat(_toConsumableArray(name), ['value']) : name,
178
+ rules: [{
179
+ required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
180
+ }].concat(_toConsumableArray(rules)),
181
+ help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
182
+ tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
183
+ }, processInputType((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.type) || '')) : /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
184
+ style: {
185
+ flex: 1,
186
+ paddingRight: '10px'
187
+ },
188
+ name: [field === null || field === void 0 ? void 0 : field.name],
189
+ rules: [{
190
+ required: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require
191
+ }].concat(_toConsumableArray(rules)),
192
+ help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
193
+ tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
194
+ }), processInputType((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.type) || ''));
195
+ }
196
+
197
+ export default /*#__PURE__*/React.memo(Index);
198
+ export var DEFAULT_DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss';