ronds-metadata 1.2.37 → 1.2.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/es/api/index.js +83 -131
  2. package/es/comps/DynamicPorts/comps/ContextMenu.js +3 -11
  3. package/es/comps/DynamicPorts/comps/DragNode.js +3 -8
  4. package/es/comps/DynamicPorts/comps/GraphHandler/index.js +4 -5
  5. package/es/comps/DynamicPorts/comps/NodeElement.js +1 -4
  6. package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +3 -6
  7. package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +3 -7
  8. package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +18 -21
  9. package/es/comps/DynamicPorts/comps/shape/edge.js +5 -18
  10. package/es/comps/DynamicPorts/comps/shape/node.js +4 -17
  11. package/es/comps/DynamicPorts/constant/index.js +2 -5
  12. package/es/comps/DynamicPorts/graph.d.ts +2 -2
  13. package/es/comps/DynamicPorts/graph.js +228 -312
  14. package/es/comps/DynamicPorts/index.js +39 -58
  15. package/es/comps/DynamicPorts/utils.js +21 -25
  16. package/es/comps/Editable/DataCell/ButtonCell.js +4 -10
  17. package/es/comps/Editable/DataCell/ColorPicker.js +2 -7
  18. package/es/comps/Editable/DataCell/Input.js +5 -14
  19. package/es/comps/Editable/DataCell/Number.js +3 -10
  20. package/es/comps/Editable/DataCell/Select.js +7 -14
  21. package/es/comps/Editable/DataCell/Switch.js +2 -7
  22. package/es/comps/Editable/comps/EditableAction.js +8 -12
  23. package/es/comps/Editable/comps/EditableCell.js +16 -26
  24. package/es/comps/Editable/comps/EditableHeardCell.js +21 -34
  25. package/es/comps/Editable/comps/EditableRow.js +49 -59
  26. package/es/comps/Editable/comps/Texty.js +40 -73
  27. package/es/comps/Editable/index.js +67 -112
  28. package/es/comps/Editable/interface.d.ts +1 -1
  29. package/es/comps/Editable/utils.js +0 -1
  30. package/es/comps/FileView/index.js +65 -101
  31. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Checkbox.js +8 -13
  32. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Color.js +8 -4
  33. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.js +6 -2
  34. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.js +8 -4
  35. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/List.js +6 -11
  36. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.js +6 -10
  37. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.js +6 -2
  38. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Obj.js +6 -11
  39. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Password.js +8 -4
  40. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Radio.js +8 -13
  41. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.js +6 -10
  42. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.js +6 -2
  43. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Table.js +6 -11
  44. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.js +6 -3
  45. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Upload.js +2 -5
  46. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.js +86 -109
  47. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.js +3 -7
  48. package/es/comps/FormGenerator/comps/Canvas/core/index.js +54 -91
  49. package/es/comps/FormGenerator/comps/Canvas/index.js +8 -15
  50. package/es/comps/FormGenerator/comps/Settings/index.js +16 -30
  51. package/es/comps/FormGenerator/comps/Sidebar/Elements.js +23 -22
  52. package/es/comps/FormGenerator/comps/Sidebar/index.js +6 -2
  53. package/es/comps/FormGenerator/index.js +3 -9
  54. package/es/comps/FormGenerator/interface.d.ts +1 -1
  55. package/es/comps/FormGenerator/settings/index.js +12 -11
  56. package/es/comps/FormGenerator/settings/ruleConfig.js +0 -1
  57. package/es/comps/FormGenerator/transformer.js +40 -105
  58. package/es/comps/Icons/index.js +4 -7
  59. package/es/comps/JsonEdit/index.js +25 -50
  60. package/es/comps/JsonView/index.js +7 -21
  61. package/es/comps/MdEdit/index.js +7 -10
  62. package/es/comps/MdEditPro/index.d.ts +10 -0
  63. package/es/comps/MdEditPro/index.js +22 -0
  64. package/es/comps/MdEditPro/index.less +74 -0
  65. package/es/comps/MdNavbar/index.js +17 -40
  66. package/es/comps/MdNavbar/utils.js +0 -4
  67. package/es/comps/MdView/index.js +7 -11
  68. package/es/comps/MetadataEdit/components/MetaFieldsEdit.js +129 -183
  69. package/es/comps/MetadataEdit/components/MetaPropsEdit.js +11 -27
  70. package/es/comps/MetadataEdit/hooks/index.js +3 -11
  71. package/es/comps/MetadataEdit/index.js +25 -58
  72. package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +17 -33
  73. package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +15 -29
  74. package/es/comps/MetadataEditV2/hooks/index.js +5 -12
  75. package/es/comps/MetadataEditV2/index.js +30 -65
  76. package/es/comps/MetadataForm/DataCell/Array.js +12 -23
  77. package/es/comps/MetadataForm/DataCell/Input.js +23 -39
  78. package/es/comps/MetadataForm/DataCell/Number.js +10 -21
  79. package/es/comps/MetadataForm/DataCell/Ref.js +87 -121
  80. package/es/comps/MetadataForm/DataCell/Select.js +131 -226
  81. package/es/comps/MetadataForm/DataCell/Switch.js +7 -14
  82. package/es/comps/MetadataForm/DataCell/layout/TableArray.js +98 -169
  83. package/es/comps/MetadataForm/HOC/index.js +20 -37
  84. package/es/comps/MetadataForm/hooks/index.js +12 -38
  85. package/es/comps/MetadataForm/index.js +37 -72
  86. package/es/comps/MetadataForm/interface.d.ts +3 -3
  87. package/es/comps/MetadataForm/utils.d.ts +1 -0
  88. package/es/comps/MetadataForm/utils.js +12 -14
  89. package/es/comps/Split/index.js +40 -38
  90. package/es/config.js +0 -4
  91. package/es/framework/RxStore/demo/index.js +9 -10
  92. package/es/framework/RxStore/hooks.d.ts +9 -9
  93. package/es/framework/RxStore/hooks.js +10 -35
  94. package/es/framework/RxStore/store.d.ts +4 -4
  95. package/es/framework/RxStore/store.js +0 -10
  96. package/es/framework/fg/index.js +18 -80
  97. package/es/framework/fg/interface.d.ts +2 -2
  98. package/es/framework/fg/utils.js +0 -10
  99. package/es/framework/graph/index.d.ts +2 -2
  100. package/es/framework/graph/index.js +55 -110
  101. package/es/framework/hooks/use-async-memo.js +3 -7
  102. package/es/framework/hooks/use-sync-scroll.js +2 -15
  103. package/es/framework/http/cache.js +25 -32
  104. package/es/framework/http/cancel.js +1 -7
  105. package/es/framework/http/index.js +22 -82
  106. package/es/framework/http/msgpack.js +0 -4
  107. package/es/framework/http/msgpack5/index.js +2 -12
  108. package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +1 -13
  109. package/es/framework/http/msgpack5/lib/decoder.js +10 -68
  110. package/es/framework/http/msgpack5/lib/encoder.js +8 -36
  111. package/es/framework/http/msgpack5/lib/helpers.js +3 -2
  112. package/es/framework/http/msgpack5/lib/streams.js +0 -18
  113. package/es/framework/libs/jquery.min.js +1009 -1696
  114. package/es/framework/locale/dil8/di18n.js +4 -15
  115. package/es/framework/locale/dil8/translate.js +0 -14
  116. package/es/framework/locale/dil8/util.js +0 -3
  117. package/es/framework/locale/index.js +2 -3
  118. package/es/framework/metadata/MetadataService.js +39 -78
  119. package/es/framework/metadata/index.js +4 -70
  120. package/es/framework/rxjs-hooks/useMemoSubject.js +0 -2
  121. package/es/framework/rxjs-hooks/useObservable.js +2 -4
  122. package/es/framework/rxjs-hooks/useObservableState.js +8 -14
  123. package/es/index.d.ts +1 -0
  124. package/es/index.js +2 -1
  125. package/es/utils.js +58 -97
  126. package/package.json +4 -2
  127. package/es/comps/MdEdit/plugin/EditContent.d.ts +0 -5
  128. package/es/comps/MdEdit/plugin/EditContent.js +0 -34
  129. package/es/comps/MdEdit/plugin/Mark.d.ts +0 -7
  130. package/es/comps/MdEdit/plugin/Mark.js +0 -60
  131. package/es/framework/libs/iconfont/iconfont.json +0 -401
@@ -1,6 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
-
4
3
  /*
5
4
  * @Author: wangxian
6
5
  * @Date: 2023-02-08 14:45:46
@@ -29,20 +28,16 @@ var EMPTY_PROP = {
29
28
  value: {}
30
29
  }]
31
30
  };
32
-
33
31
  var renderProp = function renderProp(node, setting) {
34
32
  var _prop = deepClone(EMPTY_PROP);
35
-
36
33
  var _setting = setting && deepClone(setting) || {};
37
-
38
34
  _prop.id = (_setting === null || _setting === void 0 ? void 0 : _setting.id) || node.id;
39
- _prop.type = node.param.type; // ref类型加上refId
40
-
35
+ _prop.type = node.param.type;
36
+ // ref类型加上refId
41
37
  if (node.param.type === 'ref') {
42
38
  _prop.refId = "".concat(_prop.id, "_ref");
43
- } // array类型加上 items
44
-
45
-
39
+ }
40
+ // array类型加上 items
46
41
  if (node.param.type === 'array') {
47
42
  var _items = {
48
43
  type: 'ref',
@@ -50,7 +45,6 @@ var renderProp = function renderProp(node, setting) {
50
45
  };
51
46
  _prop.items = _items;
52
47
  }
53
-
54
48
  var typeValue = _setting[node.param.type];
55
49
  delete _setting[node.param.type];
56
50
  _prop.fields[0].value = _defineProperty({
@@ -59,257 +53,199 @@ var renderProp = function renderProp(node, setting) {
59
53
  })
60
54
  }, node.param.type, _objectSpread(_objectSpread({}, node.param.rule || {}), typeValue));
61
55
  return _prop;
62
- }; // FG配置生成 metedata
63
-
64
-
56
+ };
57
+ // FG配置生成 metedata
65
58
  export var transFG2Schema = function transFG2Schema(nodes, settings, _types, schemaId) {
66
59
  try {
67
60
  var schema = deepClone(EMPTY_OBJ);
68
-
69
61
  if (schemaId) {
70
62
  schema[0].id = schemaId;
71
63
  }
72
-
73
64
  var __types__ = _types || {};
74
-
75
65
  var props = [];
76
66
  var types = [];
77
-
78
67
  for (var i = 0; i < nodes.length; i++) {
79
68
  var _nodes$i, _nodes$i$param;
80
-
81
69
  if ((_nodes$i = nodes[i]) === null || _nodes$i === void 0 ? void 0 : (_nodes$i$param = _nodes$i.param) === null || _nodes$i$param === void 0 ? void 0 : _nodes$i$param.types) {
82
70
  __types__[nodes[i].id] = {
83
71
  id: nodes[i].id,
84
72
  nodes: nodes[i].param.types
85
73
  };
86
74
  }
87
-
88
75
  var _prop = renderProp(nodes[i], settings && settings[nodes[i].id] ? settings[nodes[i].id] : nodes[i].param.setting);
89
-
90
76
  props.push(_prop);
91
77
  }
92
-
93
- schema[0].properties = [].concat(props); // 整个表格的扩展规则
94
-
78
+ schema[0].properties = [].concat(props);
79
+ // 整个表格的扩展规则
95
80
  if (settings && (settings === null || settings === void 0 ? void 0 : settings.formSetting)) {
96
81
  schema[0].fields[0].value = deepClone(settings.formSetting);
97
82
  } else {
98
83
  delete schema[0].fields;
99
84
  }
100
-
101
85
  if (__types__) {
102
86
  var typeKeys = Object.keys(__types__);
103
-
104
87
  for (var _i = 0; _i < typeKeys.length; _i++) {
105
- var _type = transFG2Schema(__types__[typeKeys[_i]].nodes, // 没有传入内部类的情况 不需要传
88
+ var _type = transFG2Schema(__types__[typeKeys[_i]].nodes,
89
+ // 没有传入内部类的情况 不需要传
106
90
  _types && settings["".concat(typeKeys[_i], "_ref")], undefined, "".concat(__types__[typeKeys[_i]].id, "_ref"));
107
-
108
91
  if (_type) {
109
92
  types.push(_type[0]);
110
93
  }
111
94
  }
112
95
  }
113
-
114
96
  if (types.length > 0) {
115
97
  schema[0].types = [].concat(types);
116
98
  }
117
-
118
99
  return schema;
119
100
  } catch (error) {
120
101
  console.warn('transFG2Schema.err', error);
121
102
  }
122
103
  };
123
-
124
104
  var renderJson = function renderJson(comps, type, id, field) {
125
105
  var _comps = deepClone(comps);
126
-
127
106
  var node = _comps.find(function (it) {
128
107
  return it.type === type;
129
108
  });
130
-
131
109
  if (node) {
132
110
  var _field$common;
133
-
134
111
  node.id = id;
135
112
  node.name = (field === null || field === void 0 ? void 0 : (_field$common = field.common) === null || _field$common === void 0 ? void 0 : _field$common.label) || node.name;
136
113
  }
137
-
138
114
  var setting = {};
139
-
140
115
  if (field) {
141
116
  var _field = deepClone(field);
142
-
143
117
  _field = _objectSpread(_objectSpread({}, _field), _field.common);
144
118
  _field.id = id;
145
119
  delete _field.common;
146
120
  setting = _defineProperty({}, id, _objectSpread({}, _field));
147
121
  }
148
-
149
122
  return {
150
123
  node: node,
151
124
  setting: setting
152
125
  };
153
126
  };
154
-
155
127
  var getTypeJson = function getTypeJson(id, type, field) {
156
128
  /* */
157
129
  var res = {
158
130
  node: {},
159
131
  setting: {}
160
132
  };
161
-
162
133
  if (type === 'text') {
163
134
  var _field$text, _field$text2, _field$text4, _field$text6, _field$text8, _field$text10;
164
-
165
135
  // input
166
136
  if (!(field === null || field === void 0 ? void 0 : (_field$text = field.text) === null || _field$text === void 0 ? void 0 : _field$text.type)) {
167
137
  res = renderJson(basicComps, 'input', id, field);
168
- } // textarea
169
-
170
-
138
+ }
139
+ // textarea
171
140
  if ((field === null || field === void 0 ? void 0 : (_field$text2 = field.text) === null || _field$text2 === void 0 ? void 0 : _field$text2.type) === 'textarea') {
172
141
  var _field$text3;
173
-
174
142
  field === null || field === void 0 ? true : (_field$text3 = field.text) === null || _field$text3 === void 0 ? true : delete _field$text3.type;
175
143
  res = renderJson(basicComps, 'textarea', id, field);
176
- } // date
177
-
178
-
144
+ }
145
+ // date
179
146
  if ((field === null || field === void 0 ? void 0 : (_field$text4 = field.text) === null || _field$text4 === void 0 ? void 0 : _field$text4.type) === 'datePicker') {
180
147
  var _field$text5;
181
-
182
148
  field === null || field === void 0 ? true : (_field$text5 = field.text) === null || _field$text5 === void 0 ? true : delete _field$text5.type;
183
149
  res = renderJson(basicComps, 'date', id, field);
184
- } // color
185
-
186
-
150
+ }
151
+ // color
187
152
  if ((field === null || field === void 0 ? void 0 : (_field$text6 = field.text) === null || _field$text6 === void 0 ? void 0 : _field$text6.type) === 'colorPicker') {
188
153
  var _field$text7;
189
-
190
154
  field === null || field === void 0 ? true : (_field$text7 = field.text) === null || _field$text7 === void 0 ? true : delete _field$text7.type;
191
155
  res = renderJson(complexComps, 'color', id, field);
192
- } // password
193
-
194
-
156
+ }
157
+ // password
195
158
  if ((field === null || field === void 0 ? void 0 : (_field$text8 = field.text) === null || _field$text8 === void 0 ? void 0 : _field$text8.type) === 'password') {
196
159
  var _field$text9;
197
-
198
160
  field === null || field === void 0 ? true : (_field$text9 = field.text) === null || _field$text9 === void 0 ? true : delete _field$text9.type;
199
161
  res = renderJson(complexComps, 'password', id, field);
200
- } // upload
201
-
202
-
162
+ }
163
+ // upload
203
164
  if ((field === null || field === void 0 ? void 0 : (_field$text10 = field.text) === null || _field$text10 === void 0 ? void 0 : _field$text10.type) === 'upload') {
204
165
  var _field$text11;
205
-
206
166
  field === null || field === void 0 ? true : (_field$text11 = field.text) === null || _field$text11 === void 0 ? true : delete _field$text11.type;
207
167
  res = renderJson(complexComps, 'upload', id, field);
208
168
  }
209
- } // number
210
-
211
-
169
+ }
170
+ // number
212
171
  if (type === 'number') {
213
172
  res = renderJson(basicComps, 'number', id, field);
214
- } // switch
215
-
216
-
173
+ }
174
+ // switch
217
175
  if (type === 'bool') {
218
176
  res = renderJson(basicComps, 'switch', id, field);
219
- } // enum
220
-
221
-
177
+ }
178
+ // enum
222
179
  if (type === 'enum') {
223
180
  var _field$enum, _field$enum2, _field$enum3, _field$enum4, _field$enum5, _field$enum6, _field$enum7, _field$enum8;
224
-
225
181
  // select
226
182
  if ((field === null || field === void 0 ? void 0 : (_field$enum = field.enum) === null || _field$enum === void 0 ? void 0 : _field$enum.type) !== 'checkbox' && !((_field$enum2 = field.enum) === null || _field$enum2 === void 0 ? void 0 : _field$enum2.isMutiple)) {
227
183
  res = renderJson(basicComps, 'select', id, field);
228
- } // mutiSelect
229
-
230
-
184
+ }
185
+ // mutiSelect
231
186
  if ((field === null || field === void 0 ? void 0 : (_field$enum3 = field.enum) === null || _field$enum3 === void 0 ? void 0 : _field$enum3.type) !== 'checkbox' && ((_field$enum4 = field.enum) === null || _field$enum4 === void 0 ? void 0 : _field$enum4.isMutiple)) {
232
187
  res = renderJson(basicComps, 'mutiSelect', id, field);
233
- } // checkbox
234
-
235
-
188
+ }
189
+ // checkbox
236
190
  if ((field === null || field === void 0 ? void 0 : (_field$enum5 = field.enum) === null || _field$enum5 === void 0 ? void 0 : _field$enum5.type) === 'checkbox' && ((_field$enum6 = field.enum) === null || _field$enum6 === void 0 ? void 0 : _field$enum6.isMutiple)) {
237
191
  res = renderJson(complexComps, 'checkbox', id, field);
238
- } // radio
239
-
240
-
192
+ }
193
+ // radio
241
194
  if ((field === null || field === void 0 ? void 0 : (_field$enum7 = field.enum) === null || _field$enum7 === void 0 ? void 0 : _field$enum7.type) === 'checkbox' && !((_field$enum8 = field.enum) === null || _field$enum8 === void 0 ? void 0 : _field$enum8.isMutiple)) {
242
195
  res = renderJson(complexComps, 'radio', id, field);
243
196
  }
244
- } // obj
245
-
246
-
197
+ }
198
+ // obj
247
199
  if (type === 'ref') {
248
200
  res = renderJson(layoutComps, 'obj', id, field);
249
- } // list
250
-
251
-
201
+ }
202
+ // list
252
203
  if (type === 'array') {
253
204
  res = renderJson(layoutComps, 'list', id, field);
254
205
  }
255
-
256
206
  return res;
257
207
  };
258
-
259
208
  var processProps = function processProps(prop) {
260
209
  // 获取是什么类型的组件
261
210
  var obj = getTypeJson(prop.id, prop.type, (prop === null || prop === void 0 ? void 0 : prop.fields) && (prop === null || prop === void 0 ? void 0 : prop.fields[0].value));
262
211
  return obj;
263
212
  };
264
-
265
213
  var getTypeParent = function getTypeParent(refId, _props) {
266
214
  var _ = _props.find(function (it) {
267
215
  var _it$items;
268
-
269
216
  return (it === null || it === void 0 ? void 0 : it.refId) === refId || (it === null || it === void 0 ? void 0 : (_it$items = it.items) === null || _it$items === void 0 ? void 0 : _it$items.refId) === refId;
270
217
  });
271
-
272
218
  return _;
273
- }; // metadata 生成FG配置
274
-
275
-
219
+ };
220
+ // metadata 生成FG配置
276
221
  export var transSchema2FG = function transSchema2FG(schema) {
277
222
  var _schema$, _schema$2;
278
-
279
223
  var res = {
280
224
  nodes: [],
281
225
  settings: {},
282
226
  types: {}
283
227
  };
284
- var _props = schema[0].properties; // 表单扩展规则
285
-
228
+ var _props = schema[0].properties;
229
+ // 表单扩展规则
286
230
  var _formFields = (_schema$ = schema[0]) === null || _schema$ === void 0 ? void 0 : _schema$.fields;
287
-
288
231
  if (_formFields) {
289
232
  res.settings = _objectSpread(_objectSpread({}, res.settings), {}, {
290
233
  formSetting: _formFields[0].value
291
234
  });
292
235
  }
293
-
294
236
  for (var i = 0; i < _props.length; i++) {
295
237
  var obj = processProps(_props[i]);
296
238
  res.nodes.push(obj.node);
297
239
  res.settings = _objectSpread(_objectSpread({}, res.settings), obj.setting);
298
240
  }
299
-
300
241
  var _types = (_schema$2 = schema[0]) === null || _schema$2 === void 0 ? void 0 : _schema$2.types;
301
-
302
242
  if (_types && _types.length > 0) {
303
243
  for (var _i2 = 0; _i2 < _types.length; _i2++) {
304
244
  var _parent = getTypeParent(_types[_i2].id, _props);
305
-
306
245
  if (_parent) {
307
246
  var _schema = deepClone(_types[_i2]);
308
-
309
247
  _schema.id = "".concat(_parent.id, "_ref");
310
-
311
248
  var _ = transSchema2FG([_schema]);
312
-
313
249
  res.types[_parent.id] = {
314
250
  id: _parent.id,
315
251
  nodes: _.nodes
@@ -318,6 +254,5 @@ export var transSchema2FG = function transSchema2FG(schema) {
318
254
  }
319
255
  }
320
256
  }
321
-
322
257
  return res;
323
258
  };
@@ -1,23 +1,20 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React from "react";
3
-
4
3
  /*
5
4
  * @Author: wangxian
6
5
  * @Date: 2022-05-28 11:04:20
7
6
  * @LastEditTime: 2023-02-24 09:09:51
8
7
  */
9
8
  import '../../framework/libs/iconfont/iconfont.css';
10
-
11
9
  var Icon = function Icon(props) {
12
10
  var type = props.type,
13
- _props$className = props.className,
14
- className = _props$className === void 0 ? '' : _props$className,
15
- _props$style = props.style,
16
- style = _props$style === void 0 ? {} : _props$style;
11
+ _props$className = props.className,
12
+ className = _props$className === void 0 ? '' : _props$className,
13
+ _props$style = props.style,
14
+ style = _props$style === void 0 ? {} : _props$style;
17
15
  return /*#__PURE__*/React.createElement("span", {
18
16
  className: "mt mt-".concat(type, " ").concat(className),
19
17
  style: _objectSpread({}, style)
20
18
  });
21
19
  };
22
-
23
20
  export default Icon;
@@ -24,26 +24,25 @@ import 'codemirror/addon/edit/closebrackets.js';
24
24
  import 'codemirror/addon/edit/matchbrackets.js';
25
25
  import './index.less';
26
26
  import { SQL_DICO } from './constant';
27
-
28
27
  var SqlEdit = function SqlEdit(props) {
29
28
  var _props$theme = props.theme,
30
- theme = _props$theme === void 0 ? 'idea' : _props$theme,
31
- _props$extraDico = props.extraDico,
32
- extraDico = _props$extraDico === void 0 ? [] : _props$extraDico,
33
- _props$mode = props.mode,
34
- mode = _props$mode === void 0 ? 'text/x-mysql' : _props$mode,
35
- _props$isLineNumbers = props.isLineNumbers,
36
- isLineNumbers = _props$isLineNumbers === void 0 ? true : _props$isLineNumbers,
37
- _props$isGutters = props.isGutters,
38
- isGutters = _props$isGutters === void 0 ? true : _props$isGutters,
39
- _props$readOnly = props.readOnly,
40
- readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
41
- _props$styleActiveLin = props.styleActiveLine,
42
- styleActiveLine = _props$styleActiveLin === void 0 ? false : _props$styleActiveLin,
43
- value = props.value,
44
- onChange = props.onChange,
45
- onSelectChange = props.onSelectChange,
46
- onReWriteEnter = props.onReWriteEnter;
29
+ theme = _props$theme === void 0 ? 'idea' : _props$theme,
30
+ _props$extraDico = props.extraDico,
31
+ extraDico = _props$extraDico === void 0 ? [] : _props$extraDico,
32
+ _props$mode = props.mode,
33
+ mode = _props$mode === void 0 ? 'text/x-mysql' : _props$mode,
34
+ _props$isLineNumbers = props.isLineNumbers,
35
+ isLineNumbers = _props$isLineNumbers === void 0 ? true : _props$isLineNumbers,
36
+ _props$isGutters = props.isGutters,
37
+ isGutters = _props$isGutters === void 0 ? true : _props$isGutters,
38
+ _props$readOnly = props.readOnly,
39
+ readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
40
+ _props$styleActiveLin = props.styleActiveLine,
41
+ styleActiveLine = _props$styleActiveLin === void 0 ? false : _props$styleActiveLin,
42
+ value = props.value,
43
+ onChange = props.onChange,
44
+ onSelectChange = props.onSelectChange,
45
+ onReWriteEnter = props.onReWriteEnter;
47
46
  var textareaRef = React.useRef(null);
48
47
  var firstLoadRef = React.useRef(true);
49
48
  var editorRef = React.useRef();
@@ -57,10 +56,8 @@ var SqlEdit = function SqlEdit(props) {
57
56
  F7: function F7(__editor) {
58
57
  var textJson = JSON.parse(__editor.getValue());
59
58
  var result = JSON.stringify(textJson, undefined, 2);
60
-
61
59
  __editor.setValue(result);
62
60
  } // 代码格式化
63
-
64
61
  };
65
62
 
66
63
  if (onReWriteEnter) {
@@ -68,22 +65,18 @@ var SqlEdit = function SqlEdit(props) {
68
65
  onReWriteEnter();
69
66
  };
70
67
  }
71
-
72
68
  return _extraKeys;
73
69
  }, [mode, onReWriteEnter]);
74
70
  var dico = React.useMemo(function () {
75
71
  var res = SQL_DICO;
76
-
77
72
  if (extraDico.length > 0) {
78
73
  res = [].concat(_toConsumableArray(SQL_DICO), _toConsumableArray(extraDico));
79
74
  }
80
-
81
75
  return res;
82
76
  }, [extraDico]);
83
77
  var initEdit = React.useCallback(function () {
84
78
  if (textareaRef.current === null) return;
85
79
  if (!firstLoadRef.current) return;
86
-
87
80
  var _editor = CodeMirror.fromTextArea(textareaRef.current, {
88
81
  value: value,
89
82
  tabSize: 4,
@@ -105,21 +98,17 @@ var SqlEdit = function SqlEdit(props) {
105
98
  styleActiveLine: styleActiveLine,
106
99
  extraKeys: extraKeys
107
100
  });
108
-
109
101
  _editor.on('keypress', function (__editor) {
110
102
  if (mode === 'text/x-mysql') {
111
103
  __editor.showHint();
112
104
  }
113
105
  });
114
-
115
106
  _editor.on('change', function (__editor) {
116
107
  onChange && onChange(__editor.getValue());
117
108
  });
118
-
119
109
  _editor.on('cursorActivity', function (__editor) {
120
110
  onSelectChange && onSelectChange(__editor.getSelection());
121
111
  });
122
-
123
112
  editorRef.current = _editor;
124
113
  firstLoadRef.current = false;
125
114
  }, [dico, isGutters, readOnly, isLineNumbers]);
@@ -129,7 +118,6 @@ var SqlEdit = function SqlEdit(props) {
129
118
  }, [textareaRef, initEdit]);
130
119
  React.useEffect(function () {
131
120
  if (!editorRef.current) return;
132
-
133
121
  if (value || value === '') {
134
122
  editorRef.current.setValue(value);
135
123
  editorRef.current.focus();
@@ -142,12 +130,9 @@ var SqlEdit = function SqlEdit(props) {
142
130
  editorRef.current.setOption('lineNumbers', isLineNumbers);
143
131
  editorRef.current.setOption('gutters', isGutters ? ['CodeMirror-linenumbers', 'CodeMirror-foldgutter', 'CodeMirror-lint-markers'] : []);
144
132
  }, [readOnly, isLineNumbers, isGutters]);
145
-
146
133
  var hint = function hint(__editor) {
147
134
  var cur = __editor.getCursor();
148
-
149
135
  var token = __editor.getTokenAt(cur);
150
-
151
136
  var searchString = token.string;
152
137
  return {
153
138
  list: suggest(searchString),
@@ -155,33 +140,28 @@ var SqlEdit = function SqlEdit(props) {
155
140
  to: CodeMirror.Pos(cur.line, token.end)
156
141
  };
157
142
  };
158
-
159
143
  var suggest = function suggest(searchString) {
160
144
  /*
161
145
  we will score which suggesion should appears first, the higer the score, the higer is the appearance order
162
146
  */
163
147
  var token = searchString;
164
148
  var isDot = false;
165
-
166
149
  if (searchString.startsWith('.')) {
167
150
  token = searchString.substring(1);
168
151
  isDot = true;
169
152
  }
170
-
171
153
  token = searchString.toLowerCase();
172
154
  var resu = [];
173
- var N = dico.length; // init scoring: only retains and score suggestions which contain the searchString
174
-
155
+ var N = dico.length;
156
+ // init scoring: only retains and score suggestions which contain the searchString
175
157
  for (var i = 0; i < N; i++) {
176
- var suggestion = null; // 支持.之后联想
177
-
158
+ var suggestion = null;
159
+ // 支持.之后联想
178
160
  var _suggestion = {
179
161
  className: dico[i].className,
180
162
  text: "".concat(isDot ? '.' : '').concat(dico[i].text)
181
163
  };
182
-
183
164
  var keyword = _suggestion.text.toLowerCase();
184
-
185
165
  if (keyword.startsWith(token)) {
186
166
  // add N to the score of keywords which begin with the token to make them raise up in the suggestion list
187
167
  suggestion = _objectSpread(_objectSpread({}, {
@@ -192,30 +172,25 @@ var SqlEdit = function SqlEdit(props) {
192
172
  score: N - i
193
173
  }), _suggestion);
194
174
  }
195
-
196
175
  if (suggestion) resu.push(suggestion);
197
- } // case suggestion for "."
198
-
199
-
176
+ }
177
+ // case suggestion for "."
200
178
  if (searchString.startsWith('.')) {
201
179
  // raise score of columns, decrease the score of sql keyword
202
180
  resu.forEach(function (s) {
203
181
  if (s.className === 'column') s.score += N;else if (s.className === 'sql') s.score -= N;
204
182
  return s;
205
183
  });
206
- } // console.log(searchString);
207
-
208
-
184
+ }
185
+ // console.log(searchString);
209
186
  return resu.sort(function (a, b) {
210
187
  return b.score - a.score;
211
188
  });
212
189
  };
213
-
214
190
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("textarea", {
215
191
  ref: textareaRef,
216
192
  defaultValue: value,
217
193
  className: "my-txt"
218
194
  }));
219
195
  };
220
-
221
196
  export default SqlEdit;
@@ -1,15 +1,12 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import React from 'react';
3
3
  import './index.less';
4
-
5
4
  var JsonView = function JsonView(props) {
6
5
  var json = props.json;
7
-
8
6
  var _React$useState = React.useState(''),
9
- _React$useState2 = _slicedToArray(_React$useState, 2),
10
- myJson = _React$useState2[0],
11
- setMyJson = _React$useState2[1];
12
-
7
+ _React$useState2 = _slicedToArray(_React$useState, 2),
8
+ myJson = _React$useState2[0],
9
+ setMyJson = _React$useState2[1];
13
10
  React.useEffect(function () {
14
11
  try {
15
12
  var textJson = JSON.parse(json);
@@ -17,20 +14,18 @@ var JsonView = function JsonView(props) {
17
14
  setMyJson(result);
18
15
  } catch (e) {
19
16
  setMyJson('This is not right JSON');
20
- } // eslint-disable-next-line
21
-
22
- }, [json]); // JSON格式转化
23
-
17
+ }
18
+ // eslint-disable-next-line
19
+ }, [json]);
20
+ // JSON格式转化
24
21
  var syntaxHighlight = function syntaxHighlight(_json) {
25
22
  if (typeof json != 'string') {
26
23
  _json = JSON.stringify(json, undefined, 2);
27
24
  }
28
-
29
25
  var index = 0;
30
26
  _json = _json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
31
27
  return _json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?|{|}|\[|\])/g, function (match) {
32
28
  var cls = 'number';
33
-
34
29
  if (/^"/.test(match)) {
35
30
  if (/:$/.test(match)) {
36
31
  cls = 'key';
@@ -51,36 +46,29 @@ var JsonView = function JsonView(props) {
51
46
  } else if (/\]/.test(match)) {
52
47
  return "".concat(match, "</span>");
53
48
  }
54
-
55
49
  return "<span class='".concat(cls, "'>").concat(match, "</span>");
56
50
  });
57
51
  };
58
-
59
52
  var onClickDom = function onClickDom(e) {
60
53
  var target = e.target;
61
-
62
54
  if (target.nodeName === 'I') {
63
55
  if (target.className === 'open') {
64
56
  target.className = 'close';
65
57
  var dom = e.target.nextSibling;
66
58
  dom.style.display = 'none';
67
59
  var childNode = document.createElement('em');
68
-
69
60
  if (dom.className === 'Array') {
70
61
  var childrenList = dom.children;
71
62
  var newList = [];
72
-
73
63
  for (var i = 0; i < childrenList.length; i++) {
74
64
  if (childrenList[i].nodeName === 'SPAN') {
75
65
  newList.push(childrenList[i]);
76
66
  }
77
67
  }
78
-
79
68
  childNode.innerHTML = "".concat(dom.className, "[<em style=\"color:#25aae2;\">").concat(newList.length, "</em>]");
80
69
  } else {
81
70
  childNode.innerHTML = dom.className;
82
71
  }
83
-
84
72
  e.target.parentNode.insertBefore(childNode, e.target.nextSibling);
85
73
  } else if (target.className === 'close') {
86
74
  e.target.parentNode.removeChild(e.target.nextSibling);
@@ -90,7 +78,6 @@ var JsonView = function JsonView(props) {
90
78
  }
91
79
  }
92
80
  };
93
-
94
81
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
95
82
  style: {
96
83
  height: '100%',
@@ -105,5 +92,4 @@ var JsonView = function JsonView(props) {
105
92
  }
106
93
  })));
107
94
  };
108
-
109
95
  export default JsonView;
@@ -7,21 +7,19 @@ import React from 'react';
7
7
  import MdEditor from 'react-markdown-editor-lite';
8
8
  import 'react-markdown-editor-lite/lib/index.css';
9
9
  import './index.less';
10
- import MdView from '../MdView'; // MdEditor.use(Mark);
11
-
10
+ import MdView from '../MdView';
11
+ // MdEditor.use(Mark);
12
12
  var MdEdit = function MdEdit(props) {
13
13
  var value = props.value,
14
- width = props.width,
15
- height = props.height,
16
- onChange = props.onChange,
17
- onImageUpload = props.onImageUpload,
18
- onCustomImageUpload = props.onCustomImageUpload;
14
+ width = props.width,
15
+ height = props.height,
16
+ onChange = props.onChange,
17
+ onImageUpload = props.onImageUpload,
18
+ onCustomImageUpload = props.onCustomImageUpload;
19
19
  var mdEditor = React.useRef();
20
-
21
20
  var onValueChange = function onValueChange(v) {
22
21
  onChange && onChange(v.text);
23
22
  };
24
-
25
23
  React.useEffect(function () {}, []);
26
24
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MdEditor, {
27
25
  ref: function ref(node) {
@@ -42,5 +40,4 @@ var MdEdit = function MdEdit(props) {
42
40
  onChange: onValueChange
43
41
  }));
44
42
  };
45
-
46
43
  export default MdEdit;