ronds-metadata 1.1.86 → 1.1.88

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,31 +1,59 @@
1
1
  /*
2
2
  * @Author: wangxian
3
3
  * @Date: 2023-02-06 08:24:17
4
- * @LastEditTime: 2023-02-09 14:09:26
4
+ * @LastEditTime: 2023-02-09 19:32:19
5
5
  */
6
6
  import { RefRule, Rule } from './ruleConfig';
7
7
  export var inputSchema = [{
8
8
  id: 'inputSchema',
9
9
  type: 'object',
10
- properties: [Rule.common.id, Rule.common.label, Rule.common.color, Rule.common.defaultValue, Rule.common.help, Rule.common.tooltip, Rule.common.placeholder, Rule.common.require, Rule.common.disabled, Rule.common.hidden, RefRule.common.depend.props, RefRule.common.rules.props],
11
- types: [RefRule.common.depend.types]
10
+ properties: [Rule.common.id, Rule.common.label, Rule.common.color, Rule.common.colSpan, Rule.common.defaultValue, Rule.common.help, Rule.common.tooltip, Rule.common.placeholder, Rule.common.require, Rule.common.disabled, Rule.common.hidden, RefRule.common.depend.props, RefRule.common.rules.props],
11
+ types: [RefRule.common.depend.types, RefRule.common.rules.types]
12
12
  }];
13
13
  export var textareaSchema = [{
14
14
  id: 'textareaSchema',
15
15
  type: 'object',
16
- properties: [Rule.common.id, Rule.common.label, Rule.common.color, Rule.common.defaultValue, Rule.common.help, Rule.common.tooltip, Rule.common.placeholder, Rule.common.require, Rule.common.disabled, Rule.common.hidden, RefRule.common.depend.props, RefRule.common.rules.props],
17
- types: [RefRule.common.depend.types]
16
+ properties: [Rule.common.id, Rule.common.label, Rule.common.color, Rule.common.colSpan, Rule.common.defaultValue, Rule.common.help, Rule.common.tooltip, Rule.common.placeholder, Rule.common.require, Rule.common.disabled, Rule.common.hidden, RefRule.common.depend.props, RefRule.common.rules.props],
17
+ types: [RefRule.common.depend.types, RefRule.common.rules.types]
18
18
  }];
19
19
  export var dateSchema = [{
20
- id: 'textareaSchema',
20
+ id: 'dateSchema',
21
21
  type: 'object',
22
- properties: [Rule.common.id, Rule.common.label, Rule.common.color, Rule.common.defaultValue, Rule.common.help, Rule.common.tooltip, Rule.common.placeholder, Rule.common.require, Rule.common.disabled, Rule.common.hidden, RefRule.common.depend.props, RefRule.common.rules.props, RefRule.text.props],
23
- types: [RefRule.common.depend.types, RefRule.text.types]
22
+ properties: [Rule.common.id, Rule.common.label, Rule.common.color, Rule.common.colSpan, Rule.common.defaultValue, Rule.common.help, Rule.common.tooltip, Rule.common.placeholder, Rule.common.require, Rule.common.disabled, Rule.common.hidden, RefRule.common.depend.props, RefRule.common.rules.props, RefRule.text.props],
23
+ types: [RefRule.common.depend.types, RefRule.text.types, RefRule.common.rules.types]
24
+ }];
25
+ export var numberSchema = [{
26
+ id: 'numberSchema',
27
+ type: 'object',
28
+ properties: [Rule.common.id, Rule.common.label, Rule.common.color, Rule.common.colSpan, Rule.common.defaultValue, Rule.common.help, Rule.common.tooltip, Rule.common.placeholder, Rule.common.require, Rule.common.disabled, Rule.common.hidden, RefRule.common.depend.props, RefRule.common.rules.props],
29
+ types: [RefRule.common.depend.types, RefRule.common.rules.types]
30
+ }];
31
+ export var switchSchema = [{
32
+ id: 'switchSchema',
33
+ type: 'object',
34
+ properties: [Rule.common.id, Rule.common.label, Rule.common.color, Rule.common.colSpan, Rule.common.defaultValue, Rule.common.help, Rule.common.tooltip, Rule.common.require, Rule.common.disabled, Rule.common.hidden, RefRule.common.depend.props],
35
+ types: [RefRule.common.depend.types]
36
+ }];
37
+ export var selectSchema = [{
38
+ id: 'switchSchema',
39
+ type: 'object',
40
+ properties: [Rule.common.id, Rule.common.label, Rule.common.color, Rule.common.colSpan, Rule.common.defaultValue, Rule.common.help, Rule.common.tooltip, Rule.common.require, Rule.common.disabled, Rule.common.hidden, RefRule.common.depend.props],
41
+ types: [RefRule.common.depend.types]
42
+ }];
43
+ export var mutiSelectSchema = [{
44
+ id: 'switchSchema',
45
+ type: 'object',
46
+ properties: [Rule.common.id, Rule.common.label, Rule.common.color, Rule.common.colSpan, Rule.common.defaultValue, Rule.common.help, Rule.common.tooltip, Rule.common.require, Rule.common.disabled, Rule.common.hidden, RefRule.common.depend.props],
47
+ types: [RefRule.common.depend.types]
24
48
  }];
25
49
  export var settingSchema = {
26
50
  input: inputSchema,
27
51
  textarea: textareaSchema,
28
- dateSchema: dateSchema
52
+ date: dateSchema,
53
+ numebr: numberSchema,
54
+ switch: switchSchema,
55
+ select: selectSchema,
56
+ mutiSelect: mutiSelectSchema
29
57
  };
30
58
  export var inputParam = {
31
59
  type: 'text',
@@ -40,10 +68,29 @@ export var textareaParam = {
40
68
  };
41
69
  export var dateParam = {
42
70
  type: 'text',
43
- schema: settingSchema.dateSchema,
71
+ schema: settingSchema.date,
44
72
  rule: {
45
73
  type: 'datePicker'
46
74
  }
75
+ };
76
+ export var numberParam = {
77
+ type: 'number',
78
+ schema: settingSchema.numebr
79
+ };
80
+ export var switchParam = {
81
+ type: 'bool',
82
+ schema: settingSchema.switch
83
+ };
84
+ export var selectParam = {
85
+ type: 'enum',
86
+ schema: settingSchema.select
87
+ };
88
+ export var mutiSelectParam = {
89
+ type: 'enum',
90
+ schema: settingSchema.mutiSelect,
91
+ rule: {
92
+ isMutiple: true
93
+ }
47
94
  }; // 基础组件列表渲染
48
95
 
49
96
  export var basicComps = [{
@@ -65,22 +112,22 @@ export var basicComps = [{
65
112
  id: 'number',
66
113
  name: '数字输入框',
67
114
  type: 'number',
68
- param: inputParam
115
+ param: numberParam
69
116
  }, {
70
117
  id: 'switch',
71
118
  name: '开关',
72
119
  type: 'switch',
73
- param: inputParam
120
+ param: switchParam
74
121
  }, {
75
122
  id: 'select',
76
123
  name: '下拉单选',
77
124
  type: 'select',
78
- param: inputParam
125
+ param: selectParam
79
126
  }, {
80
127
  id: 'mutiSelect',
81
128
  name: '下拉多选',
82
129
  type: 'mutiSelect',
83
- param: inputParam
130
+ param: mutiSelectParam
84
131
  }]; // 布局组件列表渲染
85
132
 
86
133
  export var layoutComps = [{
@@ -38,6 +38,25 @@ export declare const Rule: {
38
38
  };
39
39
  }[];
40
40
  };
41
+ colSpan: {
42
+ id: string;
43
+ type: string;
44
+ fields: {
45
+ id: string;
46
+ refId: string;
47
+ type: string;
48
+ value: {
49
+ 'common-en-US': {
50
+ depend: {};
51
+ };
52
+ common: {
53
+ label: string;
54
+ tooltip: string;
55
+ help: string;
56
+ };
57
+ };
58
+ }[];
59
+ };
41
60
  defaultValue: {
42
61
  id: string;
43
62
  type: string;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author: wangxian
3
3
  * @Date: 2023-02-08 10:36:25
4
- * @LastEditTime: 2023-02-09 14:08:23
4
+ * @LastEditTime: 2023-02-09 15:36:22
5
5
  */
6
6
  import { DEFAULT_DATE_FORMAT } from '../../../comps/MetadataForm/DataCell/Input';
7
7
  export var Rule = {
@@ -44,6 +44,25 @@ export var Rule = {
44
44
  }
45
45
  }]
46
46
  },
47
+ colSpan: {
48
+ id: 'colSpan',
49
+ type: 'number',
50
+ fields: [{
51
+ id: 'Rule.Form',
52
+ refId: 'com.ronds.schema.default.Rule.Form',
53
+ type: 'ref',
54
+ value: {
55
+ 'common-en-US': {
56
+ depend: {}
57
+ },
58
+ common: {
59
+ label: '组件布局',
60
+ tooltip: '默认按照整体布局配置排布',
61
+ help: '这里填写表单整体布局的倍数,最大一行'
62
+ }
63
+ }
64
+ }]
65
+ },
47
66
  defaultValue: {
48
67
  id: 'defaultValue',
49
68
  type: 'text',
@@ -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-08 16:05:51
7
+ * @LastEditTime: 2023-02-09 14:50:08
8
8
  */
9
9
  import { deepClone } from '../../utils';
10
10
  var EMPTY_OBJ = [{
@@ -20,13 +20,14 @@ import _Cascader from "antd/es/cascader";
20
20
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
21
21
  import _regeneratorRuntime from "@babel/runtime/regenerator";
22
22
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
23
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
23
24
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
24
25
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
25
26
 
26
27
  /*
27
28
  * @Author:wangxian
28
29
  * @Date: 2021-09-18 14:15:04
29
- * @LastEditTime: 2023-02-09 14:24:16
30
+ * @LastEditTime: 2023-02-10 08:23:34
30
31
  */
31
32
  import React from 'react';
32
33
  import { MetadataFormContext, MetadataRefContext } from '../interface';
@@ -83,12 +84,32 @@ function Index(props) {
83
84
  var _watch = extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$http = extraInfo.http) === null || _extraInfo$http === void 0 ? void 0 : _extraInfo$http.watch;
84
85
 
85
86
  if (_watch && (p === null || p === void 0 ? void 0 : p.type) === 'onSelectChange') {
86
- var _value = p === null || p === void 0 ? void 0 : p.payload[_watch];
87
+ var _watchArr = _watch.split(',');
88
+
89
+ if (_watchArr.length === 1) {
90
+ var _value = p === null || p === void 0 ? void 0 : p.payload[_watchArr[0]];
91
+
92
+ if (_value) {
93
+ setWatchValue(_value);
94
+ watchValueRef.current = _value;
95
+ formContext.form.setFieldsValue(_defineProperty({}, id, undefined));
96
+ }
97
+ } else {
98
+ for (var i = 0; i < _watchArr.length; i++) {
99
+ var w = _watchArr[i];
100
+
101
+ var _value2 = p === null || p === void 0 ? void 0 : p.payload[w];
102
+
103
+ if (_value2) {
104
+ var _wRef = watchValueRef.current || {};
105
+
106
+ _wRef[w] = _value2;
107
+ watchValueRef.current = _wRef;
108
+ }
109
+ }
87
110
 
88
- if (_value) {
89
- setWatchValue(_value);
90
- watchValueRef.current = _value;
91
111
  formContext.form.setFieldsValue(_defineProperty({}, id, undefined));
112
+ setWatchValue(_objectSpread({}, watchValueRef.current));
92
113
  }
93
114
  }
94
115
  }, [formContext.stream$, extraInfo]);
@@ -105,11 +126,13 @@ function Index(props) {
105
126
  _url = page ? http.url.replace('{page}', page) : _url;
106
127
 
107
128
  if (watchValueRef.current) {
108
- _url = _url.replace('{watch}', watchValueRef.current);
129
+ if (typeof watchValueRef.current === 'string') {
130
+ _url = _url.replace('{watch}', watchValueRef.current);
131
+ }
109
132
  }
110
133
 
111
134
  _context.next = 6;
112
- return server.GetEnumDataByUrl(_url);
135
+ return server.GetEnumDataByUrl(_url, http.method, (http === null || http === void 0 ? void 0 : http.body) && JSON.parse(http === null || http === void 0 ? void 0 : http.body) ? _objectSpread(_objectSpread({}, JSON.parse(http === null || http === void 0 ? void 0 : http.body)), watchValueRef.current || {}) : watchValueRef.current);
113
136
 
114
137
  case 6:
115
138
  res = _context.sent;
@@ -9,7 +9,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
9
9
  /*
10
10
  * @Author: wangxian
11
11
  * @Date: 2021-09-18 14:15:04
12
- * @LastEditTime: 2023-02-03 08:40:14
12
+ * @LastEditTime: 2023-02-09 15:53:44
13
13
  */
14
14
  import React from 'react';
15
15
  import Input from './DataCell/Input';
@@ -78,8 +78,17 @@ export function renderForm(schemaRef, options) {
78
78
  var _form = [];
79
79
 
80
80
  for (var i = 0; i < _properties.length; i++) {
81
+ var _properties$i, _properties$i2, _properties$i2$fields, _properties$i2$fields2;
82
+
83
+ var _colSpan = colSpan;
84
+ var compColSpan = ((_properties$i = _properties[i]) === null || _properties$i === void 0 ? void 0 : _properties$i.fields) && ((_properties$i2 = _properties[i]) === null || _properties$i2 === void 0 ? void 0 : (_properties$i2$fields = _properties$i2.fields[0]) === null || _properties$i2$fields === void 0 ? void 0 : (_properties$i2$fields2 = _properties$i2$fields.value) === null || _properties$i2$fields2 === void 0 ? void 0 : _properties$i2$fields2.colSpan);
85
+
86
+ if (compColSpan) {
87
+ _colSpan = compColSpan * colSpan <= 24 ? compColSpan * colSpan : 24;
88
+ }
89
+
81
90
  _form.push( /*#__PURE__*/React.createElement(_Col, {
82
- span: colSpan
91
+ span: _colSpan
83
92
  }, getDataCell(_properties[i], options)));
84
93
  }
85
94
 
@@ -16,5 +16,5 @@ export declare class MetadataService {
16
16
  /** 获取元数据的值 */
17
17
  GetMetadataObjList(data: any): Promise<any[]>;
18
18
  /** 通过扩展规则获取枚举类型的值 */
19
- GetEnumDataByUrl(url: string): Promise<any>;
19
+ GetEnumDataByUrl(url: string, method?: 'get' | 'post', body?: any): Promise<any>;
20
20
  }
@@ -6,7 +6,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
6
6
  /*
7
7
  * @Author: wangxian
8
8
  * @Date: 2021-09-18 14:15:04
9
- * @LastEditTime: 2022-05-21 08:35:21
9
+ * @LastEditTime: 2023-02-09 18:36:47
10
10
  */
11
11
  import Api from '../../api';
12
12
  var globalAPI = new Api();
@@ -138,13 +138,18 @@ export var MetadataService = /*#__PURE__*/function () {
138
138
  key: "GetEnumDataByUrl",
139
139
  value: function () {
140
140
  var _GetEnumDataByUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(url) {
141
+ var method,
142
+ body,
143
+ _args5 = arguments;
141
144
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
142
145
  while (1) {
143
146
  switch (_context5.prev = _context5.next) {
144
147
  case 0:
145
- return _context5.abrupt("return", this.api.GetEnumDataByUrl(url));
148
+ method = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : 'get';
149
+ body = _args5.length > 2 ? _args5[2] : undefined;
150
+ return _context5.abrupt("return", this.api.GetEnumDataByUrl(url, method, body));
146
151
 
147
- case 1:
152
+ case 3:
148
153
  case "end":
149
154
  return _context5.stop();
150
155
  }
@@ -1,98 +1,98 @@
1
- /*
2
- * @Author: wangxian
3
- * @Date: 2021-09-18 14:15:04
4
- * @LastEditTime: 2022-08-11 18:26:11
5
- */
6
- export type IMetaType = 'object' | 'ref' | 'bool' | 'number' | 'text' | 'enum' | 'array' | string;
7
-
8
- export type IMetaData = {
9
- /**
10
- * 类名称/属性名称
11
- */
12
- id: string;
13
- /**
14
- * 类型
15
- */
16
- type: IMetaType;
17
- /**
18
- * 属性
19
- */
20
- properties?: IMetaProperties[];
21
-
22
- /**
23
- * 引用id
24
- */
25
- refId?: string;
26
- /**
27
- * 静态的变量
28
- */
29
- fields?: IMetaFileds[];
30
- /**
31
- * 内部类
32
- */
33
- types?: IMetaData[];
34
- };
35
-
36
- export type IMetaProperties = {
37
- /**
38
- * 类规则名称
39
- */
40
- id: string;
41
-
42
- /**
43
- * 类型
44
- */
45
- type: IMetaType;
46
-
47
- /**
48
- * 引用id
49
- */
50
- refId?: string;
51
- /**
52
- * 静态的变量
53
- */
54
- fields?: IMetaFileds[];
55
- /**
56
- * 枚举值
57
- */
58
- enum?: { value: string }[];
59
- /**
60
- * 数组类型
61
- */
62
- items?: { type: IMetaType; refId?: string };
63
- };
64
-
65
- export type IMetaFileds = {
66
- /**
67
- * 规则名称
68
- */
69
- id: string;
70
-
71
- /**
72
- * 类型
73
- */
74
- type: IMetaType;
75
-
76
- /**
77
- * 引用id
78
- */
79
- refId?: string;
80
-
81
- /**
82
- * 规则值
83
- */
84
- value: any;
85
- };
86
-
87
- export interface IAPI {
88
- // 获取元数据列表
89
- GetMetadataList(keyWords?: string[]): Promise<{ id: string; name: string; schema: string }[]>;
90
- // 通过元数据Id获取元数据详情
91
- GetMetadataDetailById(metadataId: string): Promise<any>;
92
- // 新增元数据
93
- SaveMetadata(data: any, metadataTag: string): Promise<any>;
94
- // 获取元数据的值
95
- GetMetadataObjList(data: any): Promise<any[]>;
96
- /** 通过扩展规则获取枚举类型的值 */
97
- GetEnumDataByUrl(url: string): Promise<any>;
98
- }
1
+ /*
2
+ * @Author: wangxian
3
+ * @Date: 2021-09-18 14:15:04
4
+ * @LastEditTime: 2023-02-09 18:37:15
5
+ */
6
+ export type IMetaType = 'object' | 'ref' | 'bool' | 'number' | 'text' | 'enum' | 'array' | string;
7
+
8
+ export type IMetaData = {
9
+ /**
10
+ * 类名称/属性名称
11
+ */
12
+ id: string;
13
+ /**
14
+ * 类型
15
+ */
16
+ type: IMetaType;
17
+ /**
18
+ * 属性
19
+ */
20
+ properties?: IMetaProperties[];
21
+
22
+ /**
23
+ * 引用id
24
+ */
25
+ refId?: string;
26
+ /**
27
+ * 静态的变量
28
+ */
29
+ fields?: IMetaFileds[];
30
+ /**
31
+ * 内部类
32
+ */
33
+ types?: IMetaData[];
34
+ };
35
+
36
+ export type IMetaProperties = {
37
+ /**
38
+ * 类规则名称
39
+ */
40
+ id: string;
41
+
42
+ /**
43
+ * 类型
44
+ */
45
+ type: IMetaType;
46
+
47
+ /**
48
+ * 引用id
49
+ */
50
+ refId?: string;
51
+ /**
52
+ * 静态的变量
53
+ */
54
+ fields?: IMetaFileds[];
55
+ /**
56
+ * 枚举值
57
+ */
58
+ enum?: { value: string }[];
59
+ /**
60
+ * 数组类型
61
+ */
62
+ items?: { type: IMetaType; refId?: string };
63
+ };
64
+
65
+ export type IMetaFileds = {
66
+ /**
67
+ * 规则名称
68
+ */
69
+ id: string;
70
+
71
+ /**
72
+ * 类型
73
+ */
74
+ type: IMetaType;
75
+
76
+ /**
77
+ * 引用id
78
+ */
79
+ refId?: string;
80
+
81
+ /**
82
+ * 规则值
83
+ */
84
+ value: any;
85
+ };
86
+
87
+ export interface IAPI {
88
+ // 获取元数据列表
89
+ GetMetadataList(keyWords?: string[]): Promise<{ id: string; name: string; schema: string }[]>;
90
+ // 通过元数据Id获取元数据详情
91
+ GetMetadataDetailById(metadataId: string): Promise<any>;
92
+ // 新增元数据
93
+ SaveMetadata(data: any, metadataTag: string): Promise<any>;
94
+ // 获取元数据的值
95
+ GetMetadataObjList(data: any): Promise<any[]>;
96
+ /** 通过扩展规则获取枚举类型的值 */
97
+ GetEnumDataByUrl(url: string, method: 'get' | 'post', body: any): Promise<any>;
98
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.1.86",
4
+ "version": "1.1.88",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",