ronds-metadata 1.0.49 → 1.0.52

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.
package/es/api/index.d.ts CHANGED
@@ -14,5 +14,5 @@ export default class Api implements IAPI {
14
14
  GetMetadataDetailById(metadataId: string): Promise<any>;
15
15
  /** 添加元数据 */
16
16
  SaveMetadata(data: any, metadataTag: string): Promise<any>;
17
- GetMetadataObjList(data: any): Promise<any[]>;
17
+ GetMetadataObjList(data: any): Promise<any>;
18
18
  }
package/es/api/index.js CHANGED
@@ -2,6 +2,12 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
5
+
6
+ /*
7
+ * @Author:wangxian
8
+ * @Date: 2021-09-18 14:15:04
9
+ * @LastEditTime: 2022-03-28 15:33:19
10
+ */
5
11
  import { HttpHelper } from '../framework/http';
6
12
  var http = new HttpHelper();
7
13
 
@@ -20,6 +26,8 @@ var Api = /*#__PURE__*/function () {
20
26
  */
21
27
  function () {
22
28
  var _GetMetadataList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(keyWords) {
29
+ var _res$data;
30
+
23
31
  var param, url, res;
24
32
  return _regeneratorRuntime.wrap(function _callee$(_context) {
25
33
  while (1) {
@@ -42,7 +50,7 @@ var Api = /*#__PURE__*/function () {
42
50
 
43
51
  case 4:
44
52
  res = _context.sent;
45
- return _context.abrupt("return", res.data);
53
+ return _context.abrupt("return", (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list);
46
54
 
47
55
  case 6:
48
56
  case "end":
@@ -139,13 +147,20 @@ var Api = /*#__PURE__*/function () {
139
147
  key: "GetMetadataObjList",
140
148
  value: function () {
141
149
  var _GetMetadataObjList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data) {
150
+ var url, res;
142
151
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
143
152
  while (1) {
144
153
  switch (_context4.prev = _context4.next) {
145
154
  case 0:
146
- return _context4.abrupt("return", []);
155
+ url = "/dataset-web/source/{namespace}/entity/page".replace('{namespace}', data.id);
156
+ _context4.next = 3;
157
+ return http.post(encodeURI(url), data);
147
158
 
148
- case 1:
159
+ case 3:
160
+ res = _context4.sent;
161
+ return _context4.abrupt("return", res.successed ? res.data : []);
162
+
163
+ case 5:
149
164
  case "end":
150
165
  return _context4.stop();
151
166
  }
@@ -50,14 +50,6 @@ var EditableCell = function EditableCell(props) {
50
50
  rowIndex: undefined
51
51
  }
52
52
  });
53
- editableStream.next({
54
- type: 'onValuesChange',
55
- payload: {
56
- rowIdx: record === null || record === void 0 ? void 0 : record._rowKey_,
57
- values: {},
58
- allValues: record
59
- }
60
- });
61
53
  }
62
54
 
63
55
  if (isAddColumn) {
@@ -115,7 +115,7 @@ var EditableHeardCell = function EditableHeardCell(props) {
115
115
  };
116
116
 
117
117
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("th", _extends({}, restProps, {
118
- className: "ant-table-cell ".concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right ' : '', " ")
118
+ className: "ant-table-cell font-bold ".concat(isAddColumn && editConfig.editHeardCellKey === dataIndex ? 'border-right ' : '', " ")
119
119
  }), isAddColumn && /*#__PURE__*/React.createElement(_Popover, {
120
120
  placement: "rightTop",
121
121
  content: content,
@@ -17,3 +17,6 @@
17
17
  .border-top {
18
18
  border-top: 1px solid var(--antd-wave-shadow-color) !important;
19
19
  }
20
+ .font-bold {
21
+ font-weight: bold;
22
+ }
@@ -3,13 +3,12 @@ import _Button from "antd/es/button";
3
3
  import "antd/es/table/style";
4
4
  import _Table from "antd/es/table";
5
5
  import _extends from "@babel/runtime/helpers/esm/extends";
6
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
7
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
8
6
  import "antd/es/message/style";
9
7
  import _message from "antd/es/message";
8
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
9
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
10
10
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
11
11
  import React from 'react';
12
- import { BehaviorSubject } from 'rxjs';
13
12
  import { pick, isArray } from 'lodash';
14
13
  import EditableCell from './comps/EditableCell';
15
14
  import EditableRow from './comps/EditableRow';
@@ -17,6 +16,8 @@ import { EditableContext } from './interface';
17
16
  import EditableAction from './comps/EditableAction';
18
17
  import { isFreeEditRow, removeCurKeyFromEditRow } from './utils';
19
18
  import EditableHeardCell from './comps/EditableHeardCell';
19
+ import useMemoSubject from '../../framework/rxjs-hooks/useMemoSubject';
20
+ import useObservable from '../../framework/rxjs-hooks/useObservable';
20
21
 
21
22
  var Editable = function Editable(props) {
22
23
  var _props$type = props.type,
@@ -78,38 +79,7 @@ var Editable = function Editable(props) {
78
79
  var lastDataSourceRef = React.useRef();
79
80
  var firstLoadRef = React.useRef(true); // 定义处理编辑表格的数据流
80
81
 
81
- var editableStream = React.useMemo(function () {
82
- return new BehaviorSubject(undefined);
83
- }, []);
84
-
85
- var processAddColumnsData = function processAddColumnsData(data) {
86
- var _columns = addColumnsRef.current.length > 0 ? addColumnsRef.current : columns; // 判断key是否重复
87
-
88
-
89
- if (_columns.findIndex(function (v) {
90
- return v.key === data.key;
91
- }) > -1) {
92
- _message.warning('表格的key不可以重复');
93
-
94
- return;
95
- }
96
-
97
- var idx = _columns.findIndex(function (v) {
98
- return v.dataIndex === data.dataIndex;
99
- });
100
-
101
- var obj = {
102
- title: data.title,
103
- key: data.key,
104
- dataIndex: data.key
105
- };
106
-
107
- _columns.splice(idx + 1, 0, _objectSpread(_objectSpread({}, _columns[0]), obj));
108
-
109
- setAddColumns(_toConsumableArray(_columns));
110
- addColumnsRef.current = _columns; // editableStream.next({ type: 'editHeardCellKey', payload: undefined });
111
- };
112
-
82
+ var editableStream = useMemoSubject();
113
83
  var processStreamFactory = React.useCallback(function (data) {
114
84
  switch (data === null || data === void 0 ? void 0 : data.type) {
115
85
  case 'onValuesChange':
@@ -216,7 +186,38 @@ var Editable = function Editable(props) {
216
186
 
217
187
  break;
218
188
  }
219
- }, [type]); // 返回stream的实例
189
+ }, [type]); // 集中处理数据流
190
+
191
+ useObservable(processStreamFactory, [editableStream]);
192
+
193
+ var processAddColumnsData = function processAddColumnsData(data) {
194
+ var _columns = addColumnsRef.current.length > 0 ? addColumnsRef.current : columns; // 判断key是否重复
195
+
196
+
197
+ if (_columns.findIndex(function (v) {
198
+ return v.key === data.key;
199
+ }) > -1) {
200
+ _message.warning('表格的key不可以重复');
201
+
202
+ return;
203
+ }
204
+
205
+ var idx = _columns.findIndex(function (v) {
206
+ return v.dataIndex === data.dataIndex;
207
+ });
208
+
209
+ var obj = {
210
+ title: data.title,
211
+ key: data.key,
212
+ dataIndex: data.key
213
+ };
214
+
215
+ _columns.splice(idx + 1, 0, _objectSpread(_objectSpread({}, _columns[0]), obj));
216
+
217
+ setAddColumns(_toConsumableArray(_columns));
218
+ addColumnsRef.current = _columns; // editableStream.next({ type: 'editHeardCellKey', payload: undefined });
219
+ }; // 返回stream的实例
220
+
220
221
 
221
222
  React.useEffect(function () {
222
223
  if (firstLoadRef && editableStream) {
@@ -230,16 +231,7 @@ var Editable = function Editable(props) {
230
231
  setRecords(_toConsumableArray(dataSource));
231
232
  recordsRef.current = dataSource;
232
233
  }
233
- }, [dataSource]); // 集中处理数据流
234
-
235
- React.useEffect(function () {
236
- var subscription = editableStream.subscribe(function (p) {
237
- processStreamFactory(p);
238
- });
239
- return function () {
240
- return subscription.unsubscribe();
241
- };
242
- }, [editableStream, processStreamFactory]);
234
+ }, [dataSource]);
243
235
  var getEditColumn = React.useCallback(function (column) {
244
236
  var _column = _objectSpread(_objectSpread({}, column), {}, {
245
237
  children: isArray(column === null || column === void 0 ? void 0 : column.children) ? column.children.map(getEditColumn) : undefined
@@ -174,6 +174,7 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
174
174
  required: true
175
175
  }]
176
176
  }), /*#__PURE__*/React.createElement(_Select, {
177
+ showSearch: true,
177
178
  style: {
178
179
  width: '120px'
179
180
  },
@@ -187,7 +188,11 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
187
188
  fields: newData
188
189
  });
189
190
  },
190
- options: metaType || []
191
+ options: metaType || [],
192
+ filterOption: function filterOption(input, option) {
193
+ return (option === null || option === void 0 ? void 0 : option.label.indexOf(input)) >= 0;
194
+ },
195
+ allowClear: true
191
196
  })), /*#__PURE__*/React.createElement("div", {
192
197
  style: {
193
198
  lineHeight: '88px',
@@ -165,7 +165,12 @@ var MetaPropsEdit = function MetaPropsEdit(props) {
165
165
  style: {
166
166
  width: '180px'
167
167
  },
168
- options: metaType || []
168
+ options: metaType || [],
169
+ showSearch: true,
170
+ filterOption: function filterOption(input, option) {
171
+ return (option === null || option === void 0 ? void 0 : option.label.indexOf(input)) >= 0;
172
+ },
173
+ allowClear: true
169
174
  })), /*#__PURE__*/React.createElement("div", {
170
175
  style: {
171
176
  padding: '0 10px'
@@ -1,4 +1,10 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+
3
+ /*
4
+ * @Author: wangxian
5
+ * @Date: 2021-09-18 14:15:04
6
+ * @LastEditTime: 2022-03-28 14:30:25
7
+ */
2
8
  import { MetadataService } from './../../../framework/metadata/MetadataService';
3
9
  import React from 'react';
4
10
  export var useMetaType = function useMetaType(tag) {
@@ -1,12 +1,9 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
 
3
3
  /*
4
- * @Author: your name
4
+ * @Author:wangxian
5
5
  * @Date: 2022-03-03 16:12:34
6
- * @LastEditTime: 2022-03-07 10:55:07
7
- * @LastEditors: your name
8
- * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
9
- * @FilePath: \MetaData\src\comps\MetadataEditV2\hooks\index.ts
6
+ * @LastEditTime: 2022-03-28 11:56:36
10
7
  */
11
8
  import { MetadataService } from './../../../framework/metadata/MetadataService';
12
9
  import React from 'react';
@@ -9,7 +9,6 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
9
9
  import "antd/es/select/style";
10
10
  import _Select from "antd/es/select";
11
11
  import React from 'react';
12
- import { useDebounce } from '../../../utils';
13
12
  import { MetadataService } from '../../../framework/metadata/MetadataService';
14
13
  import { MetadataFormContext, MetadataRefContext } from '../interface';
15
14
  import { useGetExtraInfo } from '../hooks';
@@ -52,54 +51,53 @@ function Index(props) {
52
51
  help = _React$useState8[0],
53
52
  setHelp = _React$useState8[1];
54
53
 
55
- var onSearch = useDebounce( /*#__PURE__*/function () {
56
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
57
- var param, server, res, _options, i, obj;
58
-
59
- return _regeneratorRuntime.wrap(function _callee$(_context) {
60
- while (1) {
61
- switch (_context.prev = _context.next) {
62
- case 0:
63
- param = {
64
- id: refId,
65
- filter: {
66
- keywords: value
67
- },
68
- order: []
69
- };
70
- server = new MetadataService();
71
- _context.next = 4;
72
- return server.GetMetadataObjList(param);
73
-
74
- case 4:
75
- res = _context.sent;
76
- _options = [];
77
-
78
- if (res.length > 0) {
79
- for (i = 0; i < res.length; i++) {
80
- obj = {
81
- label: res[i].name,
82
- value: res[i].namespace
83
- };
84
-
85
- _options.push(obj);
86
- }
54
+ var onSearch = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
55
+ var param, server, res, _options, i, obj;
56
+
57
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
58
+ while (1) {
59
+ switch (_context.prev = _context.next) {
60
+ case 0:
61
+ param = {
62
+ id: refId,
63
+ filter: {
64
+ keywords: ''
65
+ },
66
+ order: []
67
+ };
68
+ server = new MetadataService();
69
+ _context.next = 4;
70
+ return server.GetMetadataObjList(param);
71
+
72
+ case 4:
73
+ res = _context.sent;
74
+ _options = [];
75
+
76
+ if (res.length > 0) {
77
+ for (i = 0; i < res.length; i++) {
78
+ obj = {
79
+ label: res[i].name,
80
+ value: res[i].namespace
81
+ };
82
+
83
+ _options.push(obj);
87
84
  }
85
+ }
88
86
 
89
- setOptions(!value ? [] : _options);
87
+ setOptions(_options);
90
88
 
91
- case 8:
92
- case "end":
93
- return _context.stop();
94
- }
89
+ case 8:
90
+ case "end":
91
+ return _context.stop();
95
92
  }
96
- }, _callee);
97
- }));
98
-
99
- return function (_x) {
100
- return _ref.apply(this, arguments);
101
- };
102
- }(), 500, []);
93
+ }
94
+ }, _callee);
95
+ })), []);
96
+ React.useEffect(function () {
97
+ if (refId) {
98
+ onSearch();
99
+ }
100
+ }, [refId, onSearch]);
103
101
  var formOptions = React.useMemo(function () {
104
102
  return {
105
103
  disabled: disabled,
@@ -185,20 +183,15 @@ function Index(props) {
185
183
  tooltip: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip) || help
186
184
  }, /*#__PURE__*/React.createElement(_Select, {
187
185
  showSearch: true,
188
- allowClear: true,
186
+ options: options || [],
189
187
  placeholder: extraInfo.placeholder,
190
- defaultActiveFirstOption: false,
191
- showArrow: false,
192
- filterOption: false,
193
- onSearch: onSearch,
194
188
  disabled: (_extraInfo$disabled = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled !== void 0 ? _extraInfo$disabled : disabled,
195
- notFoundContent: '没有批到到该实体数据'
196
- }, options.map(function (option) {
197
- return /*#__PURE__*/React.createElement(Option, {
198
- key: option.value,
199
- value: option.value
200
- }, option.label);
201
- }))) : /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
189
+ notFoundContent: '没有批到到该实体数据',
190
+ filterOption: function filterOption(input, option) {
191
+ return (option === null || option === void 0 ? void 0 : option.label.indexOf(input)) >= 0;
192
+ },
193
+ allowClear: true
194
+ })) : /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
202
195
  style: {
203
196
  flex: 1,
204
197
  paddingRight: '10px',
@@ -216,20 +209,15 @@ function Index(props) {
216
209
  style: {
217
210
  width: '100%'
218
211
  },
219
- allowClear: true,
212
+ options: options || [],
220
213
  placeholder: extraInfo.placeholder,
221
- defaultActiveFirstOption: false,
222
- showArrow: false,
223
- filterOption: false,
224
- onSearch: onSearch,
225
214
  disabled: (_extraInfo$disabled2 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled2 !== void 0 ? _extraInfo$disabled2 : disabled,
226
- notFoundContent: '没有批到到该实体数据'
227
- }, options.map(function (option) {
228
- return /*#__PURE__*/React.createElement(Option, {
229
- key: option.value,
230
- value: option.value
231
- }, option.label);
232
- })));
215
+ notFoundContent: '没有批到到该实体数据',
216
+ filterOption: function filterOption(input, option) {
217
+ return (option === null || option === void 0 ? void 0 : option.label.indexOf(input)) >= 0;
218
+ },
219
+ allowClear: true
220
+ }));
233
221
  }
234
222
 
235
223
  export default /*#__PURE__*/React.memo(Index);
@@ -102,10 +102,10 @@ httpClient.interceptors.response.use(function (response) {
102
102
  var _response$data2, _response$data3;
103
103
 
104
104
  // 如果自定义转换
105
- if (response.data && response.data.success || response.status === 204) {
105
+ if (response.data && response.data.success || response.status === 200 || response.status === 204) {
106
106
  var _response$data;
107
107
 
108
- response.data = new BaseResData((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.data, true, '', response.status);
108
+ response.data = new BaseResData(((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.data) || response.data, true, '', response.status);
109
109
  } //没有包装的数据
110
110
  else if (((_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.data) === undefined && ((_response$data3 = response.data) === null || _response$data3 === void 0 ? void 0 : _response$data3.success) === undefined) {
111
111
  response.data = new BaseResData(response.data, true, '', response.status, null, response);
@@ -2,6 +2,12 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
5
+
6
+ /*
7
+ * @Author: wangxian
8
+ * @Date: 2021-09-18 14:15:04
9
+ * @LastEditTime: 2022-03-28 11:52:05
10
+ */
5
11
  import Api from '../../api';
6
12
  var globalAPI = new Api();
7
13
  export var registerMetadataAPI = function registerMetadataAPI(api) {
@@ -0,0 +1,3 @@
1
+ import { BehaviorSubject } from 'rxjs';
2
+ declare const useMemoSubject: <T>() => BehaviorSubject<T>;
3
+ export default useMemoSubject;
@@ -0,0 +1,16 @@
1
+ /*
2
+ * @Author: wangxian
3
+ * @Date: 2022-03-30 10:12:11
4
+ * @LastEditTime: 2022-03-30 10:39:05
5
+ */
6
+ import React from 'react';
7
+ import { BehaviorSubject } from 'rxjs';
8
+
9
+ var useMemoSubject = function useMemoSubject() {
10
+ var subject$ = React.useMemo(function () {
11
+ return new BehaviorSubject(undefined);
12
+ }, []);
13
+ return subject$;
14
+ };
15
+
16
+ export default useMemoSubject;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const useObservable: <T>(fn: Function, dep?: React.DependencyList) => void;
3
+ export default useObservable;
@@ -0,0 +1,20 @@
1
+ /*
2
+ * @Author: wangxian
3
+ * @Date: 2022-03-30 10:12:11
4
+ * @LastEditTime: 2022-03-30 10:52:51
5
+ */
6
+ import React from 'react';
7
+
8
+ var useObservable = function useObservable(fn) {
9
+ var dep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
10
+ React.useEffect(function () {
11
+ var subscription = dep[0] && dep[0].subscribe(function (p) {
12
+ fn(p);
13
+ });
14
+ return function () {
15
+ return subscription && subscription.unsubscribe();
16
+ };
17
+ }, dep);
18
+ };
19
+
20
+ export default useObservable;
package/es/index.d.ts CHANGED
@@ -8,4 +8,6 @@ export { default as MdEditor } from './comps/MdEdit';
8
8
  export { default as Editable } from './comps/Editable';
9
9
  export * from './framework/metadata/index';
10
10
  export { default as http, addInterceptor } from './framework/http/index';
11
+ export { default as useMemoSubject } from './framework/rxjs-hooks/useMemoSubject';
12
+ export { default as useObservable } from './framework/rxjs-hooks/useObservable';
11
13
  export { registerMetadataAPI } from './framework/metadata/MetadataService';
package/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author:wangxian
3
3
  * @Date: 2021-09-18 14:15:04
4
- * @LastEditTime: 2022-03-16 16:51:12
4
+ * @LastEditTime: 2022-03-30 10:55:03
5
5
  */
6
6
  export { default as MetadataEdit } from './comps/MetadataEdit';
7
7
  export { default as MetaPropsEdit } from './comps/MetadataEdit/components/MetaPropsEdit';
@@ -13,4 +13,6 @@ export { default as MdEditor } from './comps/MdEdit';
13
13
  export { default as Editable } from './comps/Editable';
14
14
  export * from './framework/metadata/index';
15
15
  export { default as http, addInterceptor } from './framework/http/index';
16
+ export { default as useMemoSubject } from './framework/rxjs-hooks/useMemoSubject';
17
+ export { default as useObservable } from './framework/rxjs-hooks/useObservable';
16
18
  export { registerMetadataAPI } from './framework/metadata/MetadataService';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.0.49",
4
+ "version": "1.0.52",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",