ronds-metadata 1.2.10 → 1.2.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) 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 +199 -0
  79. package/es/comps/MetadataForm/DataCell/Number.js +131 -0
  80. package/es/comps/MetadataForm/DataCell/Ref.js +326 -0
  81. package/es/comps/MetadataForm/DataCell/Select.js +558 -0
  82. package/es/comps/MetadataForm/DataCell/Switch.js +116 -0
  83. package/es/comps/MetadataForm/DataCell/layout/TableArray.js +359 -0
  84. package/es/comps/MetadataForm/HOC/index.js +126 -0
  85. package/es/comps/MetadataForm/constants.js +11 -0
  86. package/es/comps/MetadataForm/hooks/index.js +139 -0
  87. package/es/comps/MetadataForm/index.js +268 -0
  88. package/es/comps/MetadataForm/interface.d.ts +2 -1
  89. package/es/comps/MetadataForm/interface.js +8 -0
  90. package/es/comps/MetadataForm/utils.js +112 -0
  91. package/es/comps/locales/en-US.js +24 -0
  92. package/es/comps/locales/index.js +8 -0
  93. package/es/comps/locales/zh-CN.js +24 -0
  94. package/es/config.js +50 -0
  95. package/es/framework/graph/index.js +515 -0
  96. package/es/framework/hooks/use-async-memo.js +32 -0
  97. package/es/framework/hooks/use-sync-scroll.js +106 -0
  98. package/es/framework/http/cache.js +137 -0
  99. package/es/framework/http/cancel.js +44 -0
  100. package/es/framework/http/index.js +392 -0
  101. package/es/framework/http/msgpack.js +34 -0
  102. package/es/framework/http/msgpack5/index.js +84 -0
  103. package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +71 -0
  104. package/es/framework/http/msgpack5/lib/decoder.js +287 -0
  105. package/es/framework/http/msgpack5/lib/encoder.js +252 -0
  106. package/es/framework/http/msgpack5/lib/helpers.js +23 -0
  107. package/es/framework/http/msgpack5/lib/streams.js +93 -0
  108. package/es/framework/http/types.js +1 -0
  109. package/es/framework/libs/jquery.min.js +4022 -0
  110. package/es/framework/locale/dil8/di18n.js +132 -0
  111. package/es/framework/locale/dil8/index.js +3 -0
  112. package/es/framework/locale/dil8/translate.js +76 -0
  113. package/es/framework/locale/dil8/util.js +17 -0
  114. package/es/framework/locale/index.js +26 -0
  115. package/es/framework/metadata/MetadataService.js +169 -0
  116. package/es/framework/metadata/index.js +384 -0
  117. package/es/framework/rxjs-hooks/useMemoSubject.js +16 -0
  118. package/es/framework/rxjs-hooks/useObservable.js +22 -0
  119. package/es/framework/rxjs-hooks/useObservableState.js +45 -0
  120. package/es/index.js +27 -0
  121. package/es/utils.js +138 -0
  122. package/package.json +1 -1
@@ -0,0 +1,268 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import "antd/es/form/style";
4
+ import _Form from "antd/es/form";
5
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
+ import React from 'react';
7
+ import { renderForm } from './utils';
8
+ import './index.less';
9
+ import { MetadataFormContext } from './interface';
10
+ import { JsonMetadataProvider } from '../../framework/metadata';
11
+ import { MetadataService } from '../../framework/metadata/MetadataService';
12
+ import useMemoSubject from '../../framework/rxjs-hooks/useMemoSubject';
13
+ import useObservable from '../../framework/rxjs-hooks/useObservable';
14
+ import moment from 'moment';
15
+ import { DEFAULT_DATE_FORMAT } from './DataCell/Input';
16
+ import { STREAM_EVENT_TYPE } from './constants';
17
+
18
+ var MetadataForm = function MetadataForm(props) {
19
+ var _Form$useForm = _Form.useForm(),
20
+ _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
21
+ form = _Form$useForm2[0];
22
+
23
+ var schema = props.schema,
24
+ initialValues = props.initialValues,
25
+ refId = props.refId,
26
+ _props$colSpan = props.colSpan,
27
+ colSpan = _props$colSpan === void 0 ? 24 : _props$colSpan,
28
+ labelSpan = props.labelSpan,
29
+ _props$labelWrap = props.labelWrap,
30
+ labelWrap = _props$labelWrap === void 0 ? true : _props$labelWrap,
31
+ _props$layout = props.layout,
32
+ layout = _props$layout === void 0 ? 'vertical' : _props$layout,
33
+ _props$disabled = props.disabled,
34
+ disabled = _props$disabled === void 0 ? false : _props$disabled,
35
+ _props$isRefForm = props.isRefForm,
36
+ isRefForm = _props$isRefForm === void 0 ? true : _props$isRefForm,
37
+ _props$isFoldForm = props.isFoldForm,
38
+ isFoldForm = _props$isFoldForm === void 0 ? false : _props$isFoldForm,
39
+ _props$isShowTypeInfo = props.isShowTypeInfo,
40
+ isShowTypeInfo = _props$isShowTypeInfo === void 0 ? false : _props$isShowTypeInfo,
41
+ initEnumValue = props.initEnumValue,
42
+ onFinish = props.onFinish,
43
+ getFormInstance = props.getFormInstance,
44
+ onValuesChange = props.onValuesChange,
45
+ onSelectChange = props.onSelectChange,
46
+ onCellButtonClick = props.onCellButtonClick;
47
+
48
+ var _React$useState = React.useState([]),
49
+ _React$useState2 = _slicedToArray(_React$useState, 2),
50
+ mySchma = _React$useState2[0],
51
+ setMySchema = _React$useState2[1];
52
+
53
+ var _React$useState3 = React.useState(),
54
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
55
+ innerSchemas = _React$useState4[0],
56
+ setInnerSchemas = _React$useState4[1];
57
+
58
+ var _React$useState5 = React.useState(),
59
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
60
+ fields = _React$useState6[0],
61
+ setFields = _React$useState6[1];
62
+
63
+ var _React$useState7 = React.useState(),
64
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
65
+ formFieldValue = _React$useState8[0],
66
+ setFormFieldValue = _React$useState8[1];
67
+
68
+ var firstLoadRef = React.useRef(true);
69
+ var firstLoadForm = React.useRef(true);
70
+ var stream$ = useMemoSubject();
71
+ var processStreamEvent = React.useCallback(function (p) {
72
+ var _p$payload, _p$payload2;
73
+
74
+ switch (p === null || p === void 0 ? void 0 : p.type) {
75
+ case STREAM_EVENT_TYPE.ON_SELECT_CHANGE:
76
+ onSelectChange && onSelectChange(p.payload);
77
+ break;
78
+
79
+ case STREAM_EVENT_TYPE.ON_BUTTON_CELL_CLICK:
80
+ onCellButtonClick && onCellButtonClick(p.payload);
81
+ break;
82
+
83
+ case STREAM_EVENT_TYPE.ON_VALUES_CHANGE:
84
+ onValuesChange && onValuesChange(p === null || p === void 0 ? void 0 : (_p$payload = p.payload) === null || _p$payload === void 0 ? void 0 : _p$payload.val, p === null || p === void 0 ? void 0 : (_p$payload2 = p.payload) === null || _p$payload2 === void 0 ? void 0 : _p$payload2.allVals);
85
+ break;
86
+ }
87
+ }, []);
88
+ useObservable(function (p) {
89
+ processStreamEvent(p);
90
+ }, [stream$]);
91
+ var options = React.useMemo(function () {
92
+ return {
93
+ disabled: disabled,
94
+ isRefForm: isRefForm,
95
+ isShowTypeInfo: isShowTypeInfo,
96
+ initEnumValue: initEnumValue
97
+ };
98
+ }, [disabled, isRefForm, isShowTypeInfo, initEnumValue]);
99
+ /**
100
+ * 获取form的实例
101
+ */
102
+
103
+ React.useEffect(function () {
104
+ if (form && stream$ && firstLoadForm.current) {
105
+ // 改写setFiedldsValue;
106
+ var e = form.setFieldsValue;
107
+
108
+ var setFieldsValue = function setFieldsValue(vals) {
109
+ e(vals);
110
+ stream$.next({
111
+ type: 'setFieldsValue',
112
+ payload: vals
113
+ });
114
+ };
115
+
116
+ form.setFieldsValue = setFieldsValue;
117
+ getFormInstance && getFormInstance(form);
118
+ firstLoadForm.current = false;
119
+ }
120
+ }, [form, stream$, getFormInstance]);
121
+ React.useEffect(function () {
122
+ if (schema && schema.length > 0) {
123
+ setMySchema(_toConsumableArray(schema));
124
+ setInnerSchemas(undefined);
125
+ }
126
+ }, [schema]);
127
+ React.useEffect(function () {
128
+ if (refId && !schema) {
129
+ var server = new MetadataService();
130
+ server.GetMetadataDetailById(refId).then(function (res) {
131
+ var _schema = JSON.parse(res.schema) || [];
132
+
133
+ setMySchema(_toConsumableArray(_schema));
134
+ });
135
+ }
136
+ }, [refId]);
137
+ React.useEffect(function () {
138
+ if (mySchma && mySchma.length > 0) {
139
+ var _mySchma$, _mySchma$2, _mySchma$3, _mySchma$3$fields$;
140
+
141
+ var provider = new JsonMetadataProvider();
142
+ provider.add_types(mySchma);
143
+ var FormCls = provider.get_type(mySchma[0].id);
144
+ var formCls = new FormCls();
145
+ var _fields = formCls.__type__.__fields__;
146
+ setFields(_fields);
147
+ setInnerSchemas(((_mySchma$ = mySchma[0]) === null || _mySchma$ === void 0 ? void 0 : _mySchma$.types) || []);
148
+ setFormFieldValue(((_mySchma$2 = mySchma[0]) === null || _mySchma$2 === void 0 ? void 0 : _mySchma$2.fields) && ((_mySchma$3 = mySchma[0]) === null || _mySchma$3 === void 0 ? void 0 : (_mySchma$3$fields$ = _mySchma$3.fields[0]) === null || _mySchma$3$fields$ === void 0 ? void 0 : _mySchma$3$fields$.value));
149
+ return function () {
150
+ provider = null;
151
+ };
152
+ }
153
+
154
+ return function () {};
155
+ }, [mySchma]);
156
+ React.useEffect(function () {
157
+ if (initialValues && firstLoadRef.current && fields) {
158
+ try {
159
+ // 处理时间格式
160
+ fields.forEach(function (v, k) {
161
+ var _v$text;
162
+
163
+ if (((v === null || v === void 0 ? void 0 : (_v$text = v.text) === null || _v$text === void 0 ? void 0 : _v$text.type) === 'datePicker' || (v === null || v === void 0 ? void 0 : v.type) === 'datePicker') && initialValues[k]) {
164
+ var _v$text2;
165
+
166
+ initialValues[k] = moment(initialValues[k], (v === null || v === void 0 ? void 0 : (_v$text2 = v.text) === null || _v$text2 === void 0 ? void 0 : _v$text2.format) || DEFAULT_DATE_FORMAT);
167
+ }
168
+ });
169
+ form.setFieldsValue(_objectSpread({}, initialValues));
170
+ firstLoadRef.current = false;
171
+ } catch (ex) {
172
+ console.warn('init not sucess');
173
+ setTimeout(function () {
174
+ form.setFieldsValue(_objectSpread({}, initialValues));
175
+ firstLoadRef.current = false;
176
+ }, 500);
177
+ }
178
+ }
179
+ }, [initialValues, fields]);
180
+ var myLabelSpan = React.useMemo(function () {
181
+ var _labelSpan = undefined;
182
+
183
+ if (labelSpan || (formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.labelSpan)) {
184
+ _labelSpan = (formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.labelSpan) ? formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.labelSpan : labelSpan;
185
+ }
186
+
187
+ return _labelSpan;
188
+ }, [labelSpan, formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.labelSpan]);
189
+ var myLayout = React.useMemo(function () {
190
+ var _layout = 'vertical';
191
+
192
+ if (layout || (formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.layout)) {
193
+ _layout = (formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.layout) ? formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.layout : layout;
194
+ }
195
+
196
+ return _layout;
197
+ }, [layout, formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.layout]);
198
+
199
+ var onMyValuesChange = function onMyValuesChange(value, allValues) {
200
+ var _extra$text;
201
+
202
+ // 处理时间格式
203
+ var key = Object.keys(value);
204
+ var extra = fields.get(key[0]);
205
+
206
+ if ((extra === null || extra === void 0 ? void 0 : (_extra$text = extra.text) === null || _extra$text === void 0 ? void 0 : _extra$text.type) === 'datePicker' || (extra === null || extra === void 0 ? void 0 : extra.type) === 'datePicker') {
207
+ var _extra$text2, _extra$text3;
208
+
209
+ value[key[0]] = moment(value[key[0]]).format((extra === null || extra === void 0 ? void 0 : (_extra$text2 = extra.text) === null || _extra$text2 === void 0 ? void 0 : _extra$text2.format) || DEFAULT_DATE_FORMAT);
210
+ allValues[key[0]] = moment(value[key[0]]).format((extra === null || extra === void 0 ? void 0 : (_extra$text3 = extra.text) === null || _extra$text3 === void 0 ? void 0 : _extra$text3.format) || DEFAULT_DATE_FORMAT);
211
+ }
212
+
213
+ stream$.next({
214
+ type: STREAM_EVENT_TYPE.ON_VALUES_CHANGE,
215
+ payload: {
216
+ val: value,
217
+ allVals: allValues
218
+ }
219
+ });
220
+ };
221
+
222
+ var onMyFinish = function onMyFinish(values) {
223
+ // 处理时间格式
224
+ fields.forEach(function (v, k) {
225
+ var _v$text3;
226
+
227
+ if (((v === null || v === void 0 ? void 0 : (_v$text3 = v.text) === null || _v$text3 === void 0 ? void 0 : _v$text3.type) === 'datePicker' || (v === null || v === void 0 ? void 0 : v.type) === 'datePicker') && values[k]) {
228
+ var _v$text4;
229
+
230
+ values[k] = moment(values[k]).format((v === null || v === void 0 ? void 0 : (_v$text4 = v.text) === null || _v$text4 === void 0 ? void 0 : _v$text4.format) || DEFAULT_DATE_FORMAT);
231
+ }
232
+ });
233
+ onFinish && onFinish(values);
234
+ };
235
+
236
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MetadataFormContext.Provider, {
237
+ value: {
238
+ fields: fields,
239
+ colSpan: (formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.colSpan) || colSpan,
240
+ labelSpan: myLabelSpan,
241
+ layout: myLayout,
242
+ form: form,
243
+ stream$: stream$,
244
+ initialValues: initialValues,
245
+ isShowTypeInfo: isShowTypeInfo,
246
+ isFoldForm: isFoldForm,
247
+ __TYPE__: innerSchemas
248
+ }
249
+ }, /*#__PURE__*/React.createElement(_Form, {
250
+ className: "metadata-form",
251
+ wrapperCol: myLabelSpan && myLayout === 'horizontal' ? {
252
+ span: 24 - myLabelSpan,
253
+ offset: 0
254
+ } : undefined,
255
+ labelCol: myLabelSpan && myLayout === 'horizontal' ? {
256
+ span: myLabelSpan,
257
+ offset: 0
258
+ } : undefined,
259
+ labelWrap: labelWrap,
260
+ layout: myLayout,
261
+ form: form,
262
+ name: "control-hooks",
263
+ onFinish: onMyFinish,
264
+ onValuesChange: onMyValuesChange
265
+ }, renderForm(mySchma, options, (formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.colSpan) || colSpan))));
266
+ };
267
+
268
+ export default MetadataForm;
@@ -31,7 +31,7 @@ export interface IMetaFormProps {
31
31
  id: string;
32
32
  idx?: number;
33
33
  type: string;
34
- require?: boolean;
34
+ notRequire?: boolean;
35
35
  disabled?: boolean;
36
36
  isRefForm?: boolean;
37
37
  initEnumValue?: any;
@@ -53,6 +53,7 @@ export interface IMetaFormProps {
53
53
  export declare type IFiledDepend = {
54
54
  hidden: string;
55
55
  show: string;
56
+ notRequire: string;
56
57
  };
57
58
  export declare type IStreamEventType = 'onSelectChange' | 'onButtonCellClick' | 'onValuesChange' | 'onWatchDepend' | string;
58
59
  export declare type IStreamEvent = {
@@ -0,0 +1,8 @@
1
+ /*
2
+ * @Author:wangxian
3
+ * @Date: 2021-09-18 14:15:04
4
+ * @LastEditTime: 2023-02-28 10:14:07
5
+ */
6
+ import React from 'react';
7
+ export var MetadataFormContext = /*#__PURE__*/React.createContext(null);
8
+ export var MetadataRefContext = /*#__PURE__*/React.createContext(null);
@@ -0,0 +1,112 @@
1
+ import "antd/es/row/style";
2
+ import _Row from "antd/es/row";
3
+ import "antd/es/spin/style";
4
+ import _Spin from "antd/es/spin";
5
+ import _extends from "@babel/runtime/helpers/esm/extends";
6
+
7
+ /*
8
+ * @Author: wangxian
9
+ * @Date: 2021-09-18 14:15:04
10
+ * @LastEditTime: 2023-02-24 15:32:47
11
+ */
12
+ import React from 'react';
13
+ import Input from './DataCell/Input';
14
+ import Number from './DataCell/Number';
15
+ import Select from './DataCell/Select';
16
+ import Switch from './DataCell/Switch';
17
+ import Array from './DataCell/Array';
18
+ import Ref from './DataCell/Ref';
19
+ import { withAddOnAfter } from './HOC';
20
+ var DataCellMap = {
21
+ text: withAddOnAfter(Input),
22
+ number: withAddOnAfter(Number),
23
+ enum: withAddOnAfter(Select),
24
+ bool: withAddOnAfter(Switch),
25
+ array: withAddOnAfter(Array),
26
+ ref: withAddOnAfter(Ref)
27
+ };
28
+ export function getDataCell(item, options, colSpan) {
29
+ if (item.type && DataCellMap[item.type]) {
30
+ var Comm = DataCellMap[item.type];
31
+
32
+ if (colSpan === 23) {}
33
+
34
+ if (item.type === 'ref') {}
35
+
36
+ var isDisabled = function isDisabled(b) {
37
+ if (typeof b === 'boolean') {
38
+ return b;
39
+ } else if (b.findIndex(function (it) {
40
+ return it === item.id;
41
+ }) > -1) {
42
+ return true;
43
+ }
44
+
45
+ return false;
46
+ };
47
+
48
+ return /*#__PURE__*/React.createElement(Comm, _extends({
49
+ key: item.id
50
+ }, item, {
51
+ disabled: isDisabled(options.disabled),
52
+ isRefForm: options.isRefForm,
53
+ isShowTypeInfo: options.isShowTypeInfo,
54
+ field: options.field,
55
+ name: options.pName,
56
+ initEnumValue: options.initEnumValue,
57
+ isObj: options.isObj,
58
+ colSpan: colSpan
59
+ }));
60
+ }
61
+
62
+ return null;
63
+ }
64
+ /**
65
+ * 渲染表单
66
+ * @param schemaRef 元数据的schema
67
+ * @param disabled 是否可用
68
+ * @param isRefForm 引用类型是否显示成表单
69
+ * @param isShowTypeInfo 是否展示类型的提示信息
70
+ * @param pName 上级表单的名称
71
+ * @param field
72
+ * @param isObj 是否是个对象
73
+ * @returns
74
+ */
75
+
76
+ export function renderForm(schemaRef, options) {
77
+ var colSpan = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 24;
78
+ if (schemaRef.length === 0) return /*#__PURE__*/React.createElement(_Spin, null);
79
+ var _schema = schemaRef[0];
80
+ var _properties = _schema.properties;
81
+ var _form = [];
82
+
83
+ for (var i = 0; i < _properties.length; i++) {
84
+ // const depend = useWatchDepend({});
85
+ _form.push( /*#__PURE__*/React.createElement(React.Fragment, null, getDataCell(_properties[i], options, colSpan)));
86
+ }
87
+
88
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Row, {
89
+ gutter: 16
90
+ }, _form));
91
+ }
92
+ export function getLabelByProps(data) {
93
+ if (data.fields && data.fields.length > 0) {
94
+ var _data$fields$0$value, _data$fields$0$value$, _data$fields$, _data$fields$$value;
95
+
96
+ return ((_data$fields$0$value = data.fields[0].value) === null || _data$fields$0$value === void 0 ? void 0 : (_data$fields$0$value$ = _data$fields$0$value.common) === null || _data$fields$0$value$ === void 0 ? void 0 : _data$fields$0$value$.label) || ((_data$fields$ = data.fields[0]) === null || _data$fields$ === void 0 ? void 0 : (_data$fields$$value = _data$fields$.value) === null || _data$fields$$value === void 0 ? void 0 : _data$fields$$value.label) || data.id;
97
+ }
98
+
99
+ return data.id;
100
+ }
101
+ export function assign(pathArr, val, obj) {
102
+ var len = pathArr.length - 1;
103
+ pathArr.reduce(function (cur, key, index) {
104
+ if (index === len) {
105
+ cur[key] = val;
106
+ } else {
107
+ cur[key] = {};
108
+ }
109
+
110
+ return cur[key];
111
+ }, obj);
112
+ }
@@ -0,0 +1,24 @@
1
+ /*
2
+ * @Author: wangxian
3
+ * @Date: 2022-05-09 11:53:44
4
+ * @LastEditTime: 2022-05-28 10:21:09
5
+ */
6
+ export default {
7
+ 操作: 'Operation',
8
+ 添加一行: 'Add New Line',
9
+ 添加: 'Add',
10
+ 编辑: 'Edit',
11
+ 删除: 'Delete',
12
+ 确定: 'Confirm',
13
+ 取消: 'Cancel',
14
+ 确认删除该条数据: 'Confirm to delete this piece of data?',
15
+ 请先保存正在编辑的行: 'Please save the line being edited first',
16
+ 请输入key: 'Please enter key',
17
+ 请输入title: 'Please enter title',
18
+ 确认会删除该列: 'Confirm will delete the column?',
19
+ 当前值无修改: 'No change to current value',
20
+ 放大: 'Enlarge',
21
+ 缩小: 'zoom out',
22
+ 实际尺寸: 'Actual size',
23
+ 适应画布: 'Fit to canvas'
24
+ };
@@ -0,0 +1,8 @@
1
+ import zhCN from './zh-CN';
2
+ import enUS from './en-US';
3
+ import { initLocale } from '../../framework/locale';
4
+ initLocale({
5
+ 'zh-CN': zhCN,
6
+ 'en-US': enUS
7
+ });
8
+ export { setLocale, getLocale } from '../../framework/locale';
@@ -0,0 +1,24 @@
1
+ /*
2
+ * @Author: wangxian
3
+ * @Date: 2022-05-09 11:53:44
4
+ * @LastEditTime: 2022-05-28 10:19:25
5
+ */
6
+ export default {
7
+ 操作: '操作',
8
+ 添加一行: '添加一行',
9
+ 添加: '添加',
10
+ 编辑: '编辑',
11
+ 删除: '删除',
12
+ 确定: '确定',
13
+ 取消: '取消',
14
+ 确定删除该条数据: '确定删除该条数据?',
15
+ 请先保存正在编辑的行: '请先保存正在编辑的行',
16
+ 请输入key: '请输入key',
17
+ 请输入title: '请输入title',
18
+ 确认会删除该列: '确认会删除该列?',
19
+ 当前值无修改: '当前值无修改',
20
+ 放大: '放大',
21
+ 缩小: '缩小',
22
+ 实际尺寸: '实际尺寸',
23
+ 适应画布: '适应画布'
24
+ };
package/es/config.js ADDED
@@ -0,0 +1,50 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+
3
+ /*
4
+ * @Author: wangxian
5
+ * @Date: 2021-09-18 14:15:04
6
+ * @LastEditTime: 2023-02-06 18:45:24
7
+ */
8
+ import { BehaviorSubject, map, distinctUntilChanged } from 'rxjs';
9
+ import { setLocale } from './comps/locales/index';
10
+ import * as jq from './framework/libs/jquery.min.js';
11
+ import { localeKey } from './framework/locale';
12
+ window.jQuery = window.jQuery || jq;
13
+ var defaultConfig = {
14
+ locale: window.localStorage.getItem(localeKey) || 'zh-CN',
15
+ theme: 'normal',
16
+ msgpack: false,
17
+ openLoading: true,
18
+ baseUrl: '/phm'
19
+ };
20
+ export var cssPrefix = 'ronds-metadata';
21
+ export var globalSettingStream = new BehaviorSubject(defaultConfig);
22
+ globalSettingStream.pipe(map(function (p) {
23
+ return p.locale;
24
+ }), distinctUntilChanged()).subscribe(function (p) {
25
+ setLocale(p);
26
+ });
27
+ globalSettingStream.pipe(map(function (p) {
28
+ return p.theme;
29
+ }), distinctUntilChanged()).subscribe(function (p) {
30
+ window.jQuery('body').removeClass("".concat(cssPrefix, "-dark"));
31
+ window.jQuery('body').removeClass("".concat(cssPrefix, "-normal"));
32
+ window.jQuery('body').addClass("".concat(cssPrefix, "-").concat(p));
33
+ window.jQuery('html').removeAttr('data-prefers-color');
34
+ });
35
+ var config = defaultConfig;
36
+ /** 设置配置 */
37
+
38
+ export var setConfig = function setConfig(opts) {
39
+ config = _objectSpread(_objectSpread({}, config), opts);
40
+ };
41
+ /** 获取单个配置 */
42
+
43
+ export function getConfigByKey(key) {
44
+ return config[key];
45
+ }
46
+ /** 获取全部配置 */
47
+
48
+ export var getConfig = function getConfig() {
49
+ return config;
50
+ };