ronds-metadata 1.2.8 → 1.2.9

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.
@@ -1,16 +1,49 @@
1
- import "antd/es/input/style";
2
- import _Input from "antd/es/input";
3
- import React from "react";
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+
5
+ /*
6
+ * @Author: uloveits 719310130@qq.com
7
+ * @Date: 2023-02-06 15:05:42
8
+ * @LastEditors: uloveits 719310130@qq.com
9
+ * @LastEditTime: 2023-02-24 17:00:24
10
+ */
11
+ import React from 'react';
12
+ import CanvasCore from '../../index';
4
13
  import { withFieldCellWrapper } from '../HOC';
14
+ import { streamEventType } from '../../../../../settings/index';
5
15
 
6
16
  var Index = function Index(props) {
7
17
  var data = props.data,
8
18
  fgStream = props.fgStream,
9
- setting = props.setting;
10
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Input, {
11
- disabled: setting === null || setting === void 0 ? void 0 : setting.disabled,
12
- placeholder: setting === null || setting === void 0 ? void 0 : setting.placeholder,
13
- allowClear: true
19
+ setting = props.setting,
20
+ types = props.types;
21
+
22
+ var _React$useState = React.useState([]),
23
+ _React$useState2 = _slicedToArray(_React$useState, 2),
24
+ nodes = _React$useState2[0],
25
+ setNodes = _React$useState2[1];
26
+
27
+ var nodesRef = React.useRef([]);
28
+ React.useEffect(function () {
29
+ if ((types === null || types === void 0 ? void 0 : types.nodes.length) > 0) {
30
+ setNodes(_toConsumableArray(types.nodes));
31
+ nodesRef.current = types.nodes;
32
+ }
33
+ }, [types]);
34
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CanvasCore, {
35
+ key: data.id,
36
+ refId: data.id,
37
+ nodes: nodes,
38
+ onChange: function onChange(nodes) {
39
+ fgStream && fgStream.next({
40
+ type: streamEventType.onTypesChange,
41
+ payload: _defineProperty({}, data.id, {
42
+ id: (setting === null || setting === void 0 ? void 0 : setting.id) || data.id,
43
+ nodes: nodes
44
+ })
45
+ });
46
+ }
14
47
  }));
15
48
  };
16
49
 
@@ -9,7 +9,7 @@ import React from 'react';
9
9
  import copy from 'copy-to-clipboard';
10
10
  import { FGCtx } from '../../Provider';
11
11
  import { streamEventType } from '../../settings';
12
- import { transFG2Schema, transSchema2FG } from '../../transformer';
12
+ import { transFG2Schema } from '../../transformer';
13
13
  import CanvasCore from './core';
14
14
  import MetadataForm from '../../../../comps/MetadataForm';
15
15
  import useObservable from '../../../../framework/rxjs-hooks/useObservable';
@@ -62,99 +62,6 @@ var Canvas = function Canvas() {
62
62
  }
63
63
  };
64
64
 
65
- var onImport = function onImport() {
66
- var _schema = [{
67
- id: 'FormGenerator',
68
- type: 'object',
69
- properties: [{
70
- id: 'name',
71
- type: 'text',
72
- fields: [{
73
- id: 'com.ronds.schema.default.Rule.Form',
74
- type: 'ref',
75
- refId: 'com.ronds.schema.default.Rule.Form',
76
- value: {
77
- common: {
78
- id: 'name',
79
- label: '名称',
80
- color: '#d13333',
81
- colSpan: 1,
82
- defaultValue: '1',
83
- help: '2',
84
- tooltip: '3',
85
- placeholder: '4',
86
- require: true,
87
- disabled: true,
88
- rules: []
89
- },
90
- text: {}
91
- }
92
- }]
93
- }, {
94
- id: 'config',
95
- type: 'ref',
96
- fields: [{
97
- id: 'com.ronds.schema.default.Rule.Form',
98
- type: 'ref',
99
- refId: 'com.ronds.schema.default.Rule.Form',
100
- value: {
101
- common: {
102
- id: 'config',
103
- label: '配置中心',
104
- color: '#5671c2',
105
- depend: {}
106
- },
107
- ref: {}
108
- }
109
- }],
110
- refId: 'Setting'
111
- }],
112
- fields: [{
113
- id: 'com.ronds.schema.default.Rule.Form',
114
- type: 'ref',
115
- refId: 'com.ronds.schema.default.Rule.Form',
116
- value: {
117
- colSpan: 24,
118
- layout: 'horizontal'
119
- }
120
- }],
121
- types: [{
122
- id: 'Setting',
123
- type: 'object',
124
- properties: [{
125
- id: 'ege',
126
- type: 'text',
127
- fields: [{
128
- id: 'com.ronds.schema.default.Rule.Form',
129
- type: 'ref',
130
- refId: 'com.ronds.schema.default.Rule.Form',
131
- value: {
132
- common: {
133
- id: 'ege',
134
- label: '年纪',
135
- color: '#df8181',
136
- defaultValue: '1',
137
- help: '4',
138
- tooltip: '333',
139
- placeholder: '5',
140
- rules: [null],
141
- depend: {}
142
- },
143
- text: {
144
- type: 'textarea'
145
- }
146
- }
147
- }]
148
- }]
149
- }]
150
- }];
151
- var defaultValue = transSchema2FG(_schema);
152
- fGCtx.fgStream && fGCtx.fgStream.next({
153
- type: streamEventType.onDefaultValue,
154
- payload: _objectSpread({}, defaultValue)
155
- });
156
- };
157
-
158
65
  return /*#__PURE__*/React.createElement("div", {
159
66
  style: {
160
67
  height: '100%',
@@ -176,11 +83,6 @@ var Canvas = function Canvas() {
176
83
  },
177
84
  onClick: onClearCanvas
178
85
  }, "\u6E05\u7A7A"), /*#__PURE__*/React.createElement(_Button, {
179
- style: {
180
- marginRight: '8px'
181
- },
182
- onClick: onImport
183
- }, "\u5BFC\u5165"), /*#__PURE__*/React.createElement(_Button, {
184
86
  type: "primary",
185
87
  onClick: function onClick() {
186
88
  var _schema = transFG2Schema(nodesRef.current, settingRef.current, typesRef.current);
@@ -1,5 +1,9 @@
1
1
  import './index.less';
2
2
  interface IFormGeneratorProps {
3
+ /**
4
+ * 初始化默认渲染的schema(首次加载渲染)
5
+ */
6
+ defaultSchema?: any;
3
7
  }
4
8
  declare const FormGenerator: (props: IFormGeneratorProps) => JSX.Element;
5
9
  export default FormGenerator;
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  /*
5
5
  * @Author: wangxian
6
6
  * @Date: 2023-02-04 13:45:31
7
- * @LastEditTime: 2023-02-21 15:34:17
7
+ * @LastEditTime: 2023-02-24 16:33:24
8
8
  */
9
9
  import React from 'react';
10
10
  import { DndProvider } from 'react-dnd';
@@ -17,8 +17,10 @@ import { FGCtx } from './Provider';
17
17
  import useMemoSubject from '../../framework/rxjs-hooks/useMemoSubject';
18
18
  import useObservable from '../../framework/rxjs-hooks/useObservable';
19
19
  import { streamEventType } from './settings';
20
+ import { transSchema2FG } from './transformer';
20
21
 
21
22
  var FormGenerator = function FormGenerator(props) {
23
+ var defaultSchema = props.defaultSchema;
22
24
  var FGStream = useMemoSubject();
23
25
 
24
26
  var _React$useState = React.useState({}),
@@ -27,6 +29,15 @@ var FormGenerator = function FormGenerator(props) {
27
29
  setTypes = _React$useState2[1];
28
30
 
29
31
  var typesRef = React.useRef({});
32
+ React.useEffect(function () {
33
+ if (defaultSchema) {
34
+ var defaultValue = transSchema2FG(defaultSchema);
35
+ FGStream.next({
36
+ type: streamEventType.onDefaultValue,
37
+ payload: _objectSpread({}, defaultValue)
38
+ });
39
+ }
40
+ }, [defaultSchema]);
30
41
  var processFgStreamData = React.useCallback(function (p) {
31
42
  switch (p === null || p === void 0 ? void 0 : p.type) {
32
43
  case streamEventType.onTypesChange:
@@ -1221,6 +1221,59 @@ export declare const objParam: {
1221
1221
  }[];
1222
1222
  }[];
1223
1223
  };
1224
+ export declare const listParam: {
1225
+ type: string;
1226
+ schema: {
1227
+ id: string;
1228
+ type: string;
1229
+ properties: ({
1230
+ id: string;
1231
+ type: string;
1232
+ fields: {
1233
+ id: string;
1234
+ type: string;
1235
+ refId: string;
1236
+ value: {
1237
+ label: string;
1238
+ };
1239
+ }[];
1240
+ } | {
1241
+ id: string;
1242
+ type: string;
1243
+ fields: {
1244
+ id: string;
1245
+ type: string;
1246
+ refId: string;
1247
+ value: {
1248
+ common: {
1249
+ label: string;
1250
+ };
1251
+ 'common-en-US': {};
1252
+ };
1253
+ }[];
1254
+ })[];
1255
+ types: {
1256
+ id: string;
1257
+ type: string;
1258
+ properties: {
1259
+ id: string;
1260
+ type: string;
1261
+ fields: {
1262
+ id: string;
1263
+ type: string;
1264
+ refId: string;
1265
+ value: {
1266
+ text: {};
1267
+ common: {
1268
+ label: string;
1269
+ };
1270
+ 'common-en-US': {};
1271
+ };
1272
+ }[];
1273
+ }[];
1274
+ }[];
1275
+ }[];
1276
+ };
1224
1277
  export declare const layoutComps: {
1225
1278
  id: string;
1226
1279
  name: string;
@@ -3,7 +3,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
3
  /*
4
4
  * @Author: wangxian
5
5
  * @Date: 2023-02-06 08:24:17
6
- * @LastEditTime: 2023-02-21 14:19:44
6
+ * @LastEditTime: 2023-02-24 17:01:30
7
7
  */
8
8
  import { RefRule, Rule } from './ruleConfig';
9
9
  export var inputSchema = [{
@@ -168,6 +168,10 @@ export var complexComps = [{
168
168
  export var objParam = {
169
169
  type: 'ref',
170
170
  schema: settingSchema.input
171
+ };
172
+ export var listParam = {
173
+ type: 'array',
174
+ schema: settingSchema.input
171
175
  }; // 布局组件列表渲染
172
176
 
173
177
  export var layoutComps = [{
@@ -179,7 +183,7 @@ export var layoutComps = [{
179
183
  id: 'list',
180
184
  name: '常规列表',
181
185
  type: 'list',
182
- param: inputParam
186
+ param: listParam
183
187
  }]; // Sidebar 内容配置
184
188
 
185
189
  export var sidebarCtx = [{
@@ -4,7 +4,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  /*
5
5
  * @Author: wangxian
6
6
  * @Date: 2023-02-08 14:45:46
7
- * @LastEditTime: 2023-02-21 14:51:10
7
+ * @LastEditTime: 2023-02-24 17:05:48
8
8
  */
9
9
  import { deepClone } from '../../utils';
10
10
  import { basicComps, layoutComps } from './settings';
@@ -40,6 +40,15 @@ var renderProp = function renderProp(node, setting) {
40
40
 
41
41
  if (node.param.type === 'ref') {
42
42
  _prop.refId = "".concat(_prop.id, "_ref");
43
+ } // array类型加上 items
44
+
45
+
46
+ if (node.param.type === 'array') {
47
+ var _items = {
48
+ type: 'ref',
49
+ refId: "".concat(_prop.id, "_ref")
50
+ };
51
+ _prop.items = _items;
43
52
  }
44
53
 
45
54
  var typeValue = _setting[node.param.type];
@@ -47,7 +47,11 @@ interface ISqlEditProps {
47
47
  /**
48
48
  * 是否只读
49
49
  */
50
- readOnly?: boolean;
50
+ readOnly?: boolean | string;
51
+ /**
52
+ * 显示选中行的样式
53
+ */
54
+ styleActiveLine?: boolean;
51
55
  /**
52
56
  * 鼠标光标选中回调
53
57
  */
@@ -38,6 +38,8 @@ var SqlEdit = function SqlEdit(props) {
38
38
  isGutters = _props$isGutters === void 0 ? true : _props$isGutters,
39
39
  _props$readOnly = props.readOnly,
40
40
  readOnly = _props$readOnly === void 0 ? false : _props$readOnly,
41
+ _props$styleActiveLin = props.styleActiveLine,
42
+ styleActiveLine = _props$styleActiveLin === void 0 ? false : _props$styleActiveLin,
41
43
  value = props.value,
42
44
  onChange = props.onChange,
43
45
  onSelectChange = props.onSelectChange,
@@ -87,7 +89,7 @@ var SqlEdit = function SqlEdit(props) {
87
89
  tabSize: 4,
88
90
  mode: mode,
89
91
  theme: theme,
90
- readOnly: readOnly ? 'nocursor' : readOnly,
92
+ readOnly: readOnly,
91
93
  lineNumbers: isLineNumbers,
92
94
  lineWrapping: true,
93
95
  foldGutter: true,
@@ -99,6 +101,8 @@ var SqlEdit = function SqlEdit(props) {
99
101
  },
100
102
  matchBrackets: true,
101
103
  autoCloseBrackets: true,
104
+ smartIndent: true,
105
+ styleActiveLine: styleActiveLine,
102
106
  extraKeys: extraKeys
103
107
  });
104
108
 
@@ -12,7 +12,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
12
12
  /*
13
13
  * @Author: wangxian
14
14
  * @Date: 2021-09-18 14:15:04
15
- * @LastEditTime: 2023-02-23 15:42:40
15
+ * @LastEditTime: 2023-02-24 14:05:06
16
16
  */
17
17
  import React from 'react';
18
18
  import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
@@ -56,16 +56,6 @@ function Index(props) {
56
56
  help = _React$useState2[0],
57
57
  setHelp = _React$useState2[1];
58
58
 
59
- // const myName = React.useMemo(() => {
60
- // let res = [];
61
- // if (name && name.length > 0) {
62
- // res = deepClone(name);
63
- // res.push(id);
64
- // } else {
65
- // return id;
66
- // }
67
- // return res;
68
- // }, [name, id]);
69
59
  React.useEffect(function () {
70
60
  if (items && items.refId) {
71
61
  var arr = items.refId.split('.');
@@ -73,7 +63,7 @@ function Index(props) {
73
63
  }
74
64
  }, [items]);
75
65
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Row, null, /*#__PURE__*/React.createElement(_Col, {
76
- span: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? labelSpan : 24
66
+ flex: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? "0 0 ".concat(labelSpan * 100 / 24, "%") : '0 0 1'
77
67
  }, !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) && /*#__PURE__*/React.createElement("div", {
78
68
  style: {
79
69
  position: 'relative',
@@ -93,7 +83,7 @@ function Index(props) {
93
83
  background: '#fff'
94
84
  }
95
85
  }, help || (items === null || items === void 0 ? void 0 : items.type)))), /*#__PURE__*/React.createElement(_Col, {
96
- span: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? 24 - labelSpan : 24
86
+ flex: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? "0 0 ".concat((24 - labelSpan) * 100 / 24, "%") : '0 0 1'
97
87
  }, extraInfo.layout === 'table' && items.type === 'ref' ? /*#__PURE__*/React.createElement(TableArray, {
98
88
  initValue: formContext.initialValues,
99
89
  initEnumValue: initEnumValue,
@@ -17,7 +17,7 @@ import _Input from "antd/es/input";
17
17
  /*
18
18
  * @Author: wangxian
19
19
  * @Date: 2021-09-18 14:15:04
20
- * @LastEditTime: 2023-02-23 19:32:47
20
+ * @LastEditTime: 2023-02-24 15:35:17
21
21
  */
22
22
  import React from 'react';
23
23
  import { UploadOutlined } from '@ant-design/icons';
@@ -39,6 +39,8 @@ function Index(props) {
39
39
  var formRefContext = React.useContext(MetadataRefContext);
40
40
  var extraInfo = useGetExtraInfo(formRefContext ? formRefContext.fields : formContext.fields, id, formContext.form, props.type);
41
41
 
42
+ if (id === 'p' || id === 'user') {}
43
+
42
44
  var _React$useState = React.useState([]),
43
45
  _React$useState2 = _slicedToArray(_React$useState, 2),
44
46
  rules = _React$useState2[0],
@@ -200,8 +200,10 @@ function Index(props) {
200
200
  if (isRefForm && !field && schema.length > 0) {
201
201
  var _fieldRule$, _fieldRule$$value, _fieldRule$2, _fieldRule$2$value, _fieldRule$2$value$co;
202
202
 
203
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Row, null, !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) && /*#__PURE__*/React.createElement(_Col, {
204
- span: (formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan) && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan : 24
203
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Row, {
204
+ className: "ant-form-item"
205
+ }, !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) && /*#__PURE__*/React.createElement(_Col, {
206
+ flex: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? "0 0 ".concat(labelSpan * 100 / 24, "%") : '0 0 1'
205
207
  }, /*#__PURE__*/React.createElement("div", {
206
208
  style: {
207
209
  display: 'flex',
@@ -228,7 +230,7 @@ function Index(props) {
228
230
  },
229
231
  icon: isFold ? /*#__PURE__*/React.createElement(CaretDownOutlined, null) : /*#__PURE__*/React.createElement(CaretUpOutlined, null)
230
232
  })))), /*#__PURE__*/React.createElement(_Col, {
231
- span: (formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan) && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? 24 - (formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan) : 24
233
+ flex: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? "0 0 ".concat((24 - labelSpan) * 100 / 24, "%") : '0 0 1'
232
234
  }, /*#__PURE__*/React.createElement("div", {
233
235
  style: {
234
236
  padding: '10px',
@@ -31,7 +31,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
31
31
  /*
32
32
  * @Author:wangxian
33
33
  * @Date: 2021-09-18 14:15:04
34
- * @LastEditTime: 2023-02-23 19:34:06
34
+ * @LastEditTime: 2023-02-24 11:32:14
35
35
  */
36
36
  import React from 'react';
37
37
  import { MetadataFormContext, MetadataRefContext } from '../interface';
@@ -212,7 +212,8 @@ function Index(props) {
212
212
  } else {
213
213
  return {
214
214
  value: it[(http === null || http === void 0 ? void 0 : http.key) || 'id'],
215
- label: it[(http === null || http === void 0 ? void 0 : http.value) || 'name']
215
+ label: it[(http === null || http === void 0 ? void 0 : http.value) || 'name'],
216
+ disabled: false
216
217
  };
217
218
  }
218
219
  }));
@@ -34,6 +34,8 @@ export function withAddOnAfter(WrappedComponent) {
34
34
  cellColSpan = _React$useState4[0],
35
35
  setCellColSpan = _React$useState4[1];
36
36
 
37
+ if (id === 'p' || id === 'user') {}
38
+
37
39
  var labelSpan = React.useMemo(function () {
38
40
  var _fields$0$value, _fields$0$value$commo;
39
41
 
@@ -77,6 +79,18 @@ export function withAddOnAfter(WrappedComponent) {
77
79
  return res;
78
80
  }
79
81
 
82
+ if (id && name.length > 0 && field) {
83
+ var _res = deepClone(name);
84
+
85
+ _res.push(id);
86
+
87
+ if (type !== 'ref') {
88
+ _res.shift();
89
+ }
90
+
91
+ return _res;
92
+ }
93
+
80
94
  return [id];
81
95
  }, [id, name]);
82
96
 
@@ -187,7 +187,7 @@ var MetadataForm = function MetadataForm(props) {
187
187
  return _labelSpan;
188
188
  }, [labelSpan, formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.labelSpan]);
189
189
  var myLayout = React.useMemo(function () {
190
- var _layout = undefined;
190
+ var _layout = 'vertical';
191
191
 
192
192
  if (layout || (formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.layout)) {
193
193
  _layout = (formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.layout) ? formFieldValue === null || formFieldValue === void 0 ? void 0 : formFieldValue.layout : layout;
@@ -1,5 +1,5 @@
1
1
  import { IFormOptions } from './interface';
2
- export declare function getDataCell(item: any, options: IFormOptions, colSpan: any): JSX.Element;
2
+ export declare function getDataCell(item: any, options: IFormOptions, colSpan: number): JSX.Element;
3
3
  /**
4
4
  * 渲染表单
5
5
  * @param schemaRef 元数据的schema
@@ -7,7 +7,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
7
7
  /*
8
8
  * @Author: wangxian
9
9
  * @Date: 2021-09-18 14:15:04
10
- * @LastEditTime: 2023-02-21 19:35:40
10
+ * @LastEditTime: 2023-02-24 15:32:47
11
11
  */
12
12
  import React from 'react';
13
13
  import Input from './DataCell/Input';
@@ -29,6 +29,10 @@ export function getDataCell(item, options, colSpan) {
29
29
  if (item.type && DataCellMap[item.type]) {
30
30
  var Comm = DataCellMap[item.type];
31
31
 
32
+ if (colSpan === 23) {}
33
+
34
+ if (item.type === 'ref') {}
35
+
32
36
  var isDisabled = function isDisabled(b) {
33
37
  if (typeof b === 'boolean') {
34
38
  return b;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.2.8",
4
+ "version": "1.2.9",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",