ronds-metadata 1.2.8 → 1.2.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Table.d.ts +2 -0
  2. package/es/comps/FormGenerator/comps/Canvas/core/index.less +23 -23
  3. package/es/comps/FormGenerator/index.d.ts +4 -0
  4. package/es/comps/FormGenerator/settings/index.d.ts +668 -49
  5. package/es/comps/JsonEdit/index.d.ts +5 -1
  6. package/es/comps/MetadataForm/index.less +1 -1
  7. package/es/comps/MetadataForm/utils.d.ts +1 -1
  8. package/package.json +1 -1
  9. package/es/api/index.js +0 -249
  10. package/es/comps/DynamicPorts/comps/ContextMenu.js +0 -44
  11. package/es/comps/DynamicPorts/comps/DragNode.js +0 -55
  12. package/es/comps/DynamicPorts/comps/GraphHandler/index.js +0 -51
  13. package/es/comps/DynamicPorts/comps/NodeElement.js +0 -30
  14. package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +0 -42
  15. package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +0 -40
  16. package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +0 -55
  17. package/es/comps/DynamicPorts/comps/shape/connector.js +0 -19
  18. package/es/comps/DynamicPorts/comps/shape/edge.js +0 -91
  19. package/es/comps/DynamicPorts/comps/shape/node.js +0 -190
  20. package/es/comps/DynamicPorts/constant/index.js +0 -19
  21. package/es/comps/DynamicPorts/graph.js +0 -697
  22. package/es/comps/DynamicPorts/index.js +0 -143
  23. package/es/comps/DynamicPorts/interface.js +0 -6
  24. package/es/comps/DynamicPorts/utils.js +0 -127
  25. package/es/comps/Editable/DataCell/ButtonCell.js +0 -45
  26. package/es/comps/Editable/DataCell/ColorPicker.js +0 -33
  27. package/es/comps/Editable/DataCell/Input.js +0 -54
  28. package/es/comps/Editable/DataCell/Number.js +0 -44
  29. package/es/comps/Editable/DataCell/Select.js +0 -48
  30. package/es/comps/Editable/DataCell/Switch.js +0 -33
  31. package/es/comps/Editable/comps/EditableAction.js +0 -110
  32. package/es/comps/Editable/comps/EditableCell.js +0 -108
  33. package/es/comps/Editable/comps/EditableHeardCell.js +0 -172
  34. package/es/comps/Editable/comps/EditableRow.js +0 -118
  35. package/es/comps/Editable/comps/Texty.js +0 -277
  36. package/es/comps/Editable/index.js +0 -385
  37. package/es/comps/Editable/interface.js +0 -8
  38. package/es/comps/Editable/utils.js +0 -46
  39. package/es/comps/FileView/index.js +0 -198
  40. package/es/comps/FormGenerator/Provider.js +0 -8
  41. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Checkbox.js +0 -17
  42. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Color.js +0 -17
  43. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.js +0 -16
  44. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.js +0 -17
  45. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/List.js +0 -17
  46. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.js +0 -55
  47. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.js +0 -14
  48. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Obj.js +0 -50
  49. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Password.js +0 -17
  50. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Radio.js +0 -17
  51. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.js +0 -55
  52. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.js +0 -13
  53. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.js +0 -14
  54. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Upload.js +0 -17
  55. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.js +0 -250
  56. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.js +0 -60
  57. package/es/comps/FormGenerator/comps/Canvas/core/index.js +0 -313
  58. package/es/comps/FormGenerator/comps/Canvas/index.js +0 -216
  59. package/es/comps/FormGenerator/comps/Settings/index.js +0 -150
  60. package/es/comps/FormGenerator/comps/Sidebar/Elements.js +0 -48
  61. package/es/comps/FormGenerator/comps/Sidebar/index.js +0 -37
  62. package/es/comps/FormGenerator/index.js +0 -56
  63. package/es/comps/FormGenerator/settings/index.js +0 -303
  64. package/es/comps/FormGenerator/settings/ruleConfig.js +0 -557
  65. package/es/comps/FormGenerator/transformer.js +0 -214
  66. package/es/comps/Icons/index.js +0 -23
  67. package/es/comps/JsonEdit/constant/index.js +0 -87
  68. package/es/comps/JsonEdit/index.js +0 -217
  69. package/es/comps/JsonView/index.js +0 -109
  70. package/es/comps/MdEdit/index.js +0 -41
  71. package/es/comps/MdNavbar/index.js +0 -180
  72. package/es/comps/MdNavbar/utils.js +0 -34
  73. package/es/comps/MdView/index.js +0 -70
  74. package/es/comps/MetadataEdit/components/MetaFieldsEdit.js +0 -419
  75. package/es/comps/MetadataEdit/components/MetaPropsEdit.js +0 -368
  76. package/es/comps/MetadataEdit/constant/index.js +0 -69
  77. package/es/comps/MetadataEdit/hooks/index.js +0 -43
  78. package/es/comps/MetadataEdit/index.js +0 -255
  79. package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +0 -237
  80. package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +0 -367
  81. package/es/comps/MetadataEditV2/constant/index.js +0 -69
  82. package/es/comps/MetadataEditV2/hooks/index.js +0 -43
  83. package/es/comps/MetadataEditV2/index.js +0 -298
  84. package/es/comps/MetadataForm/DataCell/Array.js +0 -157
  85. package/es/comps/MetadataForm/DataCell/Input.js +0 -197
  86. package/es/comps/MetadataForm/DataCell/Number.js +0 -130
  87. package/es/comps/MetadataForm/DataCell/Ref.js +0 -323
  88. package/es/comps/MetadataForm/DataCell/Select.js +0 -517
  89. package/es/comps/MetadataForm/DataCell/Switch.js +0 -115
  90. package/es/comps/MetadataForm/DataCell/layout/TableArray.js +0 -359
  91. package/es/comps/MetadataForm/HOC/index.js +0 -111
  92. package/es/comps/MetadataForm/constants.js +0 -11
  93. package/es/comps/MetadataForm/hooks/index.js +0 -128
  94. package/es/comps/MetadataForm/index.js +0 -268
  95. package/es/comps/MetadataForm/interface.js +0 -8
  96. package/es/comps/MetadataForm/utils.js +0 -108
  97. package/es/comps/locales/en-US.js +0 -24
  98. package/es/comps/locales/index.js +0 -8
  99. package/es/comps/locales/zh-CN.js +0 -24
  100. package/es/config.js +0 -50
  101. package/es/framework/graph/index.js +0 -515
  102. package/es/framework/hooks/use-async-memo.js +0 -32
  103. package/es/framework/hooks/use-sync-scroll.js +0 -106
  104. package/es/framework/http/cache.js +0 -137
  105. package/es/framework/http/cancel.js +0 -44
  106. package/es/framework/http/index.js +0 -392
  107. package/es/framework/http/msgpack.js +0 -34
  108. package/es/framework/http/msgpack5/index.js +0 -84
  109. package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +0 -71
  110. package/es/framework/http/msgpack5/lib/decoder.js +0 -287
  111. package/es/framework/http/msgpack5/lib/encoder.js +0 -252
  112. package/es/framework/http/msgpack5/lib/helpers.js +0 -23
  113. package/es/framework/http/msgpack5/lib/streams.js +0 -93
  114. package/es/framework/http/types.js +0 -1
  115. package/es/framework/libs/jquery.min.js +0 -4022
  116. package/es/framework/locale/dil8/di18n.js +0 -132
  117. package/es/framework/locale/dil8/index.js +0 -3
  118. package/es/framework/locale/dil8/translate.js +0 -76
  119. package/es/framework/locale/dil8/util.js +0 -17
  120. package/es/framework/locale/index.js +0 -26
  121. package/es/framework/metadata/MetadataService.js +0 -169
  122. package/es/framework/metadata/index.js +0 -384
  123. package/es/framework/rxjs-hooks/useMemoSubject.js +0 -16
  124. package/es/framework/rxjs-hooks/useObservable.js +0 -22
  125. package/es/framework/rxjs-hooks/useObservableState.js +0 -45
  126. package/es/index.js +0 -27
  127. package/es/utils.js +0 -138
@@ -1,180 +0,0 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
-
4
- /*
5
- * @Author: wangxian
6
- * @Date: 2022-10-14 09:05:50
7
- * @LastEditTime: 2022-10-14 14:25:18
8
- */
9
- import React from 'react';
10
- import { getCurrentHashValue, trimArrZero } from './utils';
11
- import './index.less';
12
-
13
- var MdNavbar = function MdNavbar(props) {
14
- var source = props.source,
15
- ordered = props.ordered,
16
- declarative = props.declarative,
17
- className = props.className,
18
- onNavItemClick = props.onNavItemClick,
19
- onHashChange = props.onHashChange;
20
-
21
- var _React$useState = React.useState([]),
22
- _React$useState2 = _slicedToArray(_React$useState, 2),
23
- navStructure = _React$useState2[0],
24
- setNavStructure = _React$useState2[1];
25
-
26
- var navStructureRef = React.useRef([]);
27
-
28
- var _React$useState3 = React.useState(''),
29
- _React$useState4 = _slicedToArray(_React$useState3, 2),
30
- currentListNo = _React$useState4[0],
31
- setCurrentListNo = _React$useState4[1];
32
-
33
- var scrollTimeoutRef = React.useRef();
34
- var addTargetTimeoutRef = React.useRef();
35
- var getNavStructure = React.useCallback(function () {
36
- if (source) {
37
- var contentWithoutCode = source.replace(/^[^#]+\n/g, '').replace(/(?:[^\n#]+)#+\s([^#\n]+)\n*/g, '') // 匹配行内出现 # 号的情况
38
- .replace(/^#\s[^#\n]*\n+/, '').replace(/```[^`\n]*\n+[^```]+```\n+/g, '').replace(/`([^`\n]+)`/g, '$1').replace(/\*\*?([^*\n]+)\*\*?/g, '$1').replace(/__?([^_\n]+)__?/g, '$1').trim();
39
- var pattOfTitle = /#+\s([^#\n]+)\n*/g;
40
- var matchResult = contentWithoutCode.match(pattOfTitle);
41
-
42
- if (!matchResult) {
43
- return;
44
- }
45
-
46
- var navData = matchResult.map(function (r, i) {
47
- return {
48
- index: i,
49
- level: r.match(/^#+/g)[0].length,
50
- text: r.replace(pattOfTitle, '$1')
51
- };
52
- });
53
- var maxLevel = 0;
54
- navData.forEach(function (t) {
55
- if (t.level > maxLevel) {
56
- maxLevel = t.level;
57
- }
58
- });
59
- var matchStack = []; // 此部分重构,原有方法会出现次级标题后再次出现高级标题时,listNo重复的bug
60
-
61
- for (var i = 0; i < navData.length; i++) {
62
- var t = navData[i];
63
- var level = t.level;
64
-
65
- while (matchStack.length && matchStack[matchStack.length - 1].level > level) {
66
- matchStack.pop();
67
- }
68
-
69
- if (matchStack.length === 0) {
70
- var _arr = new Array(maxLevel).fill(0);
71
-
72
- _arr[level - 1] += 1;
73
- matchStack.push({
74
- level: level,
75
- arr: _arr
76
- });
77
- t.listNo = trimArrZero(_arr).join('.');
78
- continue;
79
- }
80
-
81
- var arr = matchStack[matchStack.length - 1].arr;
82
- var newArr = arr.slice();
83
- newArr[level - 1] += 1;
84
- matchStack.push({
85
- level: level,
86
- arr: newArr
87
- });
88
- t.listNo = trimArrZero(newArr).join('.');
89
- }
90
-
91
- setNavStructure(_toConsumableArray(navData));
92
- navStructureRef.current = navData;
93
- }
94
- }, [source]);
95
- var initHeadingsId = React.useCallback(function () {
96
- var headingId = decodeURIComponent(declarative ? window.location.hash.replace(/^#/, '').trim() : (window.location.hash.match(/heading-\d+/g) || [])[0]);
97
- navStructureRef.current.forEach(function (t) {
98
- var headings = document.querySelectorAll("h".concat(t.level));
99
- var curHeading = Array.prototype.slice.apply(headings).find(function (h) {
100
- return h.innerText.trim() === t.text.trim() && (!h.dataset || !h.dataset.id);
101
- });
102
-
103
- if (curHeading) {
104
- curHeading.dataset.id = declarative ? "".concat(t.listNo, "-").concat(t.text) : "heading-".concat(t.index);
105
-
106
- if (headingId && headingId === curHeading.dataset.id) {
107
- scrollToTarget(headingId);
108
- setCurrentListNo(t.listNo);
109
- }
110
- }
111
- });
112
- }, []);
113
- var refreshNav = React.useCallback(function () {
114
- if (addTargetTimeoutRef.current) {
115
- clearTimeout(addTargetTimeoutRef.current);
116
- }
117
-
118
- addTargetTimeoutRef.current = setTimeout(function () {
119
- initHeadingsId();
120
-
121
- if (navStructure.length) {
122
- var listNo = navStructure[0].listNo;
123
- setCurrentListNo(listNo);
124
- }
125
- }, 500);
126
- }, [navStructure]);
127
- React.useEffect(function () {
128
- if (source) {
129
- getNavStructure();
130
- }
131
- }, [source, getNavStructure]);
132
- React.useEffect(function () {
133
- if (source && navStructure && navStructure.length > 0) {
134
- refreshNav();
135
- }
136
- }, [navStructure, source]);
137
-
138
- var scrollToTarget = function scrollToTarget(dataId) {
139
- if (scrollTimeoutRef.current) {
140
- clearTimeout(scrollTimeoutRef.current);
141
- }
142
-
143
- scrollTimeoutRef.current = setTimeout(function () {
144
- var target = document.querySelector("[data-id=\"".concat(dataId, "\"]"));
145
-
146
- if (target) {
147
- target.scrollIntoView({
148
- block: 'start',
149
- behavior: 'smooth'
150
- });
151
- }
152
- }, 0);
153
- };
154
-
155
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
156
- className: "markdown-navigation ".concat(className)
157
- }, navStructure.map(function (t) {
158
- var cls = "title-anchor title-level".concat(t.level, " ").concat(currentListNo === t.listNo ? 'active' : '');
159
- return /*#__PURE__*/React.createElement("div", {
160
- className: cls,
161
- onClick: function onClick(evt) {
162
- var currentHash = declarative ? "".concat(t.listNo, "-").concat(t.text) // 加入listNo确保hash唯一ZZ
163
- : "heading-".concat(t.index); // Avoid execution the callback `onHashChange` when clicking current nav item
164
-
165
- if (t.listNo !== currentListNo) {
166
- // Hash changing callback
167
- onHashChange && onHashChange(currentHash, getCurrentHashValue());
168
- } // Nav item clicking callback
169
-
170
-
171
- onNavItemClick && onNavItemClick(evt, evt.target, currentHash);
172
- scrollToTarget(currentHash);
173
- setCurrentListNo(t.listNo);
174
- },
175
- key: "title_anchor_".concat(Math.random().toString(36).substring(2))
176
- }, ordered ? /*#__PURE__*/React.createElement("small", null, t.listNo) : null, t.text);
177
- })));
178
- };
179
-
180
- export default MdNavbar;
@@ -1,34 +0,0 @@
1
- /*
2
- * @Author: wangxian
3
- * @Date: 2022-10-14 10:03:03
4
- * @LastEditTime: 2022-10-14 10:17:18
5
- */
6
- export var getCurrentHashValue = function getCurrentHashValue() {
7
- return decodeURIComponent(window.location.hash.replace(/^#/, ''));
8
- };
9
- export var trimArrZero = function trimArrZero(arr) {
10
- var start, end;
11
-
12
- for (start = 0; start < arr.length; start++) {
13
- if (arr[start]) {
14
- break;
15
- }
16
- }
17
-
18
- for (end = arr.length - 1; end >= 0; end--) {
19
- if (arr[end]) {
20
- break;
21
- }
22
- }
23
-
24
- return arr.slice(start, end + 1);
25
- };
26
- export var updateHash = function updateHash(updateHashTimeout, value) {
27
- if (updateHashTimeout) {
28
- clearTimeout(updateHashTimeout);
29
- }
30
-
31
- updateHashTimeout = setTimeout(function () {
32
- window.history.replaceState({}, '', "".concat(window.location.pathname).concat(window.location.search, "#").concat(value));
33
- }, 0);
34
- };
@@ -1,70 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["node", "inline", "className", "children"];
4
- import React from "react";
5
-
6
- /*
7
- * @Author: wangxian
8
- * @Date: 2022-09-02 16:17:38
9
- * @LastEditTime: 2022-11-23 09:09:46
10
- */
11
- import ReactMarkdown from 'react-markdown';
12
- import remarkGfm from 'remark-gfm';
13
- import rehypeRaw from 'rehype-raw';
14
- import 'github-markdown-css';
15
- import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
16
- import { oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism';
17
- import './index.less';
18
- import MdNavbar from '../MdNavbar';
19
-
20
- var MdView = function MdView(props) {
21
- var source = props.source,
22
- _props$isMarkNav = props.isMarkNav,
23
- isMarkNav = _props$isMarkNav === void 0 ? false : _props$isMarkNav,
24
- navOptions = props.navOptions;
25
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
26
- className: "react-mark-down",
27
- style: {
28
- height: '100%',
29
- display: 'flex'
30
- }
31
- }, /*#__PURE__*/React.createElement("div", {
32
- className: "markdown-body react-mark-down"
33
- }, /*#__PURE__*/React.createElement(ReactMarkdown, {
34
- remarkPlugins: [remarkGfm],
35
- rehypePlugins: [rehypeRaw],
36
- components: {
37
- code: function code(_ref) {
38
- var node = _ref.node,
39
- inline = _ref.inline,
40
- className = _ref.className,
41
- children = _ref.children,
42
- props = _objectWithoutProperties(_ref, _excluded);
43
-
44
- var match = /language-(\w+)/.exec(className || 'javascript');
45
- return !inline && match ? /*#__PURE__*/React.createElement(SyntaxHighlighter, _extends({
46
- showLineNumbers: true,
47
- style: oneLight,
48
- language: match[1],
49
- PreTag: "div",
50
- className: "self-highlighter"
51
- }, props), String(children).replace(/\n$/, '')) : /*#__PURE__*/React.createElement("code", _extends({
52
- className: className
53
- }, props), children);
54
- }
55
- }
56
- }, source)), isMarkNav && /*#__PURE__*/React.createElement("div", {
57
- style: {
58
- width: '250px',
59
- height: '100%',
60
- padding: '10px',
61
- overflowY: 'auto'
62
- }
63
- }, /*#__PURE__*/React.createElement(MdNavbar, _extends({
64
- className: "h-full w-full",
65
- source: source,
66
- ordered: true
67
- }, navOptions)))));
68
- };
69
-
70
- export default MdView;
@@ -1,419 +0,0 @@
1
- import "antd/es/button/style";
2
- import _Button from "antd/es/button";
3
- import "antd/es/switch/style";
4
- import _Switch from "antd/es/switch";
5
- import "antd/es/input-number/style";
6
- import _InputNumber from "antd/es/input-number";
7
- import "antd/es/select/style";
8
- import _Select from "antd/es/select";
9
- import _extends from "@babel/runtime/helpers/esm/extends";
10
- import "antd/es/input/style";
11
- import _Input from "antd/es/input";
12
- import _regeneratorRuntime from "@babel/runtime/regenerator";
13
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
14
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
15
- import "antd/es/form/style";
16
- import _Form from "antd/es/form";
17
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
18
- import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
19
- import React from 'react';
20
- import { RULE_TYPES_OPTIONS } from '../constant';
21
- import { useMetaType } from '../hooks';
22
- import MetadataForm from '../../MetadataForm';
23
- import { MetadataService } from '../../../framework/metadata/MetadataService';
24
-
25
- var MetaFieldsEdit = function MetaFieldsEdit(props) {
26
- var type = props.type,
27
- defaultValues = props.defaultValues,
28
- onChange = props.onChange;
29
-
30
- var _Form$useForm = _Form.useForm(),
31
- _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
32
- form = _Form$useForm2[0];
33
-
34
- var _React$useState = React.useState({}),
35
- _React$useState2 = _slicedToArray(_React$useState, 2),
36
- ruleTypes = _React$useState2[0],
37
- setRuleTypes = _React$useState2[1];
38
-
39
- var _React$useState3 = React.useState({}),
40
- _React$useState4 = _slicedToArray(_React$useState3, 2),
41
- refIds = _React$useState4[0],
42
- setRefIds = _React$useState4[1];
43
-
44
- var _React$useState5 = React.useState({}),
45
- _React$useState6 = _slicedToArray(_React$useState5, 2),
46
- refSchema = _React$useState6[0],
47
- setRefSchema = _React$useState6[1];
48
-
49
- var _React$useState7 = React.useState({}),
50
- _React$useState8 = _slicedToArray(_React$useState7, 2),
51
- refValues = _React$useState8[0],
52
- setRefValues = _React$useState8[1];
53
-
54
- var metaType = useMetaType('扩展规则');
55
-
56
- var processSpecialRuleData = /*#__PURE__*/function () {
57
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_refId, idx) {
58
- var server, res, _schema, _properties, _refSchema;
59
-
60
- return _regeneratorRuntime.wrap(function _callee$(_context) {
61
- while (1) {
62
- switch (_context.prev = _context.next) {
63
- case 0:
64
- server = new MetadataService();
65
- _context.next = 3;
66
- return server.GetMetadataDetailById(_refId);
67
-
68
- case 3:
69
- res = _context.sent;
70
- _schema = JSON.parse(res.schema);
71
- _properties = _schema[0].properties;
72
-
73
- if (_refId === 'com.ronds.schema.default.Rule.Form') {
74
- _properties = _properties.filter(function (it) {
75
- return it.id === 'common' || it.id === 'common-en-US' || it.id === type;
76
- });
77
- }
78
-
79
- _schema[0].properties = _properties;
80
- _refSchema = refSchema;
81
- _refSchema[idx] = _schema;
82
- setRefSchema(_objectSpread({}, _refSchema));
83
-
84
- case 11:
85
- case "end":
86
- return _context.stop();
87
- }
88
- }
89
- }, _callee);
90
- }));
91
-
92
- return function processSpecialRuleData(_x, _x2) {
93
- return _ref.apply(this, arguments);
94
- };
95
- }();
96
-
97
- var onRefSelectChange = React.useCallback( /*#__PURE__*/function () {
98
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(value, index) {
99
- var _refIds, _refSchema, newData;
100
-
101
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
102
- while (1) {
103
- switch (_context2.prev = _context2.next) {
104
- case 0:
105
- _refIds = refIds;
106
-
107
- if (!(value && value.indexOf('Rule.Form') > -1)) {
108
- _context2.next = 6;
109
- break;
110
- }
111
-
112
- _context2.next = 4;
113
- return processSpecialRuleData(value, index);
114
-
115
- case 4:
116
- _context2.next = 9;
117
- break;
118
-
119
- case 6:
120
- _refSchema = refSchema;
121
- _refSchema[index] = undefined;
122
- setRefSchema(_objectSpread({}, _refSchema));
123
-
124
- case 9:
125
- _refIds[index] = value;
126
- setRefIds(_objectSpread({}, _refIds));
127
- newData = form.getFieldValue('fields');
128
- newData[index].id = value;
129
- form.setFieldsValue({
130
- fields: newData
131
- });
132
-
133
- case 14:
134
- case "end":
135
- return _context2.stop();
136
- }
137
- }
138
- }, _callee2);
139
- }));
140
-
141
- return function (_x3, _x4) {
142
- return _ref2.apply(this, arguments);
143
- };
144
- }(), [form]);
145
- var processInitRule = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
146
- var _defaultValues, _refIds, _ruleTypes;
147
-
148
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
149
- while (1) {
150
- switch (_context3.prev = _context3.next) {
151
- case 0:
152
- _defaultValues = [{
153
- id: 'Rule.Form',
154
- refId: 'com.ronds.schema.default.Rule.Form',
155
- type: 'ref',
156
- value: {}
157
- }];
158
- _refIds = refIds;
159
- _ruleTypes = ruleTypes;
160
-
161
- if (!(_defaultValues[0].refId.indexOf('Rule.Form') > -1)) {
162
- _context3.next = 6;
163
- break;
164
- }
165
-
166
- _context3.next = 6;
167
- return processSpecialRuleData(_defaultValues[0].refId, 0);
168
-
169
- case 6:
170
- _refIds[0] = _defaultValues[0].refId;
171
- setRefIds(_objectSpread({}, _refIds));
172
- _ruleTypes[0] = 'ref';
173
- setRuleTypes(_objectSpread({}, _ruleTypes));
174
- form.setFieldsValue({
175
- fields: _defaultValues
176
- });
177
-
178
- case 11:
179
- case "end":
180
- return _context3.stop();
181
- }
182
- }
183
- }, _callee3);
184
- })), [form]);
185
- var processDefaultValues = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
186
- var _ruleTypes, _refIds, i;
187
-
188
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
189
- while (1) {
190
- switch (_context4.prev = _context4.next) {
191
- case 0:
192
- if (!defaultValues) {
193
- _context4.next = 17;
194
- break;
195
- }
196
-
197
- _ruleTypes = ruleTypes;
198
- _refIds = refIds;
199
- form.setFieldsValue({
200
- fields: defaultValues
201
- });
202
- i = 0;
203
-
204
- case 5:
205
- if (!(i < defaultValues.length)) {
206
- _context4.next = 15;
207
- break;
208
- }
209
-
210
- _ruleTypes[i] = defaultValues[i].type;
211
-
212
- if (!(defaultValues[i].type === 'ref')) {
213
- _context4.next = 12;
214
- break;
215
- }
216
-
217
- if (!(defaultValues[i].refId.indexOf('Rule.Form') > -1)) {
218
- _context4.next = 11;
219
- break;
220
- }
221
-
222
- _context4.next = 11;
223
- return processSpecialRuleData(defaultValues[i].refId, i);
224
-
225
- case 11:
226
- _refIds[i] = defaultValues[i].refId;
227
-
228
- case 12:
229
- i++;
230
- _context4.next = 5;
231
- break;
232
-
233
- case 15:
234
- setRefIds(_objectSpread({}, _refIds));
235
- setRuleTypes(_objectSpread({}, _ruleTypes));
236
-
237
- case 17:
238
- case "end":
239
- return _context4.stop();
240
- }
241
- }
242
- }, _callee4);
243
- })), [form]);
244
- React.useEffect(function () {
245
- if (defaultValues) {
246
- processDefaultValues();
247
- } else {
248
- processInitRule();
249
- }
250
- }, [defaultValues, processInitRule, processDefaultValues]);
251
-
252
- var onFinish = function onFinish(values) {
253
- var _fields = values.fields;
254
-
255
- for (var i = 0; i < _fields.length; i++) {
256
- if (_fields[i].type === 'ref') {
257
- _fields[i].value = refValues[i] || _fields[i].value;
258
- }
259
- }
260
-
261
- onChange && onChange(_fields);
262
- };
263
-
264
- var onRefRulesValuesChange = function onRefRulesValuesChange(values, idx) {
265
- var _refValues = refValues;
266
- _refValues[idx] = _refValues[idx] ? _objectSpread(_objectSpread({}, _refValues[idx]), values) : _objectSpread({}, values);
267
- setRefValues(_objectSpread({}, _refValues));
268
- };
269
-
270
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Form, {
271
- className: "metadata-edit",
272
- style: {
273
- position: 'relative'
274
- },
275
- form: form,
276
- name: "control-hooks",
277
- onFinish: onFinish
278
- }, /*#__PURE__*/React.createElement("div", {
279
- style: {
280
- padding: '10px'
281
- }
282
- }, /*#__PURE__*/React.createElement(_Form.List, {
283
- name: "fields"
284
- }, function (fields, _ref5) {
285
- var add = _ref5.add,
286
- remove = _ref5.remove;
287
- return /*#__PURE__*/React.createElement(React.Fragment, null, fields.map(function (field, index) {
288
- var _defaultValues$index;
289
-
290
- return /*#__PURE__*/React.createElement("div", {
291
- key: "".concat(field.key)
292
- }, /*#__PURE__*/React.createElement("div", {
293
- style: {
294
- display: 'flex',
295
- alignItems: 'flex-start'
296
- }
297
- }, /*#__PURE__*/React.createElement(_Form.Item, _extends({
298
- className: "pr-10"
299
- }, field, {
300
- label: "\u89C4\u5219\u540D\u79F0",
301
- name: [field.name, 'id'],
302
- fieldKey: [field.fieldKey, 'id'],
303
- rules: [{
304
- required: true
305
- }]
306
- }), /*#__PURE__*/React.createElement(_Input, null)), /*#__PURE__*/React.createElement(_Form.Item, _extends({
307
- className: "pr-10"
308
- }, field, {
309
- label: "\u89C4\u5219\u7C7B\u578B",
310
- name: [field.name, 'type'],
311
- fieldKey: [field.fieldKey, 'type'],
312
- rules: [{
313
- required: true
314
- }]
315
- }), /*#__PURE__*/React.createElement(_Select, {
316
- style: {
317
- width: '120px'
318
- },
319
- onChange: function onChange(value) {
320
- var _ruleTypes = ruleTypes;
321
- _ruleTypes[index] = value;
322
- setRuleTypes(_objectSpread({}, _ruleTypes));
323
- },
324
- options: RULE_TYPES_OPTIONS,
325
- getPopupContainer: function getPopupContainer(triggerNode) {
326
- return triggerNode.parentNode;
327
- }
328
- })), ruleTypes[index] === 'text' && /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
329
- label: "\u89C4\u5219\u503C",
330
- name: [field.name, 'value'],
331
- fieldKey: [field.fieldKey, 'value'],
332
- rules: [{
333
- required: true
334
- }]
335
- }), /*#__PURE__*/React.createElement(_Input, {
336
- style: {
337
- width: '120px'
338
- }
339
- })), ruleTypes[index] === 'number' && /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
340
- label: "\u89C4\u5219\u503C",
341
- name: [field.name, 'value'],
342
- fieldKey: [field.fieldKey, 'value'],
343
- rules: [{
344
- required: true
345
- }]
346
- }), /*#__PURE__*/React.createElement(_InputNumber, {
347
- style: {
348
- width: '120px'
349
- }
350
- })), ruleTypes[index] === 'bool' && /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
351
- label: "\u89C4\u5219\u503C",
352
- name: [field.name, 'value'],
353
- fieldKey: [field.fieldKey, 'value'],
354
- rules: [{
355
- required: true
356
- }]
357
- }), /*#__PURE__*/React.createElement(_Switch, null)), ruleTypes[index] === 'ref' && /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
358
- label: "Ref",
359
- name: [field.name, 'refId'],
360
- fieldKey: [field.fieldKey, 'refId'],
361
- rules: [{
362
- required: true
363
- }]
364
- }), /*#__PURE__*/React.createElement(_Select, {
365
- showSearch: true,
366
- style: {
367
- width: '120px'
368
- },
369
- onChange: function onChange(value) {
370
- onRefSelectChange(value, index);
371
- },
372
- options: metaType || [],
373
- filterOption: function filterOption(input, option) {
374
- return (option === null || option === void 0 ? void 0 : option.label.indexOf(input)) >= 0;
375
- },
376
- getPopupContainer: function getPopupContainer(triggerNode) {
377
- return triggerNode.parentNode;
378
- },
379
- allowClear: true
380
- })), /*#__PURE__*/React.createElement("div", {
381
- style: {
382
- lineHeight: '88px',
383
- paddingLeft: '15px'
384
- }
385
- }, /*#__PURE__*/React.createElement(MinusCircleOutlined, {
386
- onClick: function onClick() {
387
- return remove(field.name);
388
- }
389
- }))), (refIds[index] || refSchema[index]) && /*#__PURE__*/React.createElement("div", {
390
- style: {
391
- border: '1px solid var(--ronds-metadata-color-border-1)',
392
- padding: '10px',
393
- marginBottom: '10px'
394
- }
395
- }, /*#__PURE__*/React.createElement(MetadataForm, {
396
- initialValues: defaultValues && defaultValues.length > 0 && ((_defaultValues$index = defaultValues[index]) === null || _defaultValues$index === void 0 ? void 0 : _defaultValues$index.value),
397
- refId: refIds[index],
398
- isFoldForm: true,
399
- schema: refSchema[index],
400
- onValuesChange: function onValuesChange(values, allValues) {
401
- onRefRulesValuesChange(allValues, index);
402
- }
403
- })));
404
- }), /*#__PURE__*/React.createElement(_Form.Item, null, /*#__PURE__*/React.createElement(_Button, {
405
- type: "dashed",
406
- onClick: function onClick() {
407
- return add();
408
- },
409
- block: true,
410
- icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
411
- }, "\u6DFB\u52A0\u6269\u5C55\u89C4\u5219")));
412
- }), /*#__PURE__*/React.createElement(_Form.Item, null, /*#__PURE__*/React.createElement(_Button, {
413
- type: "primary",
414
- block: true,
415
- htmlType: "submit"
416
- }, "\u786E\u5B9A")))));
417
- };
418
-
419
- export default MetaFieldsEdit;