ronds-metadata 1.2.16 → 1.2.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,6 +19,8 @@ import "antd/es/input/style";
19
19
  import _Input from "antd/es/input";
20
20
  import "antd/es/divider/style";
21
21
  import _Divider from "antd/es/divider";
22
+ import "antd/es/tree-select/style";
23
+ import _TreeSelect from "antd/es/tree-select";
22
24
  import "antd/es/cascader/style";
23
25
  import _Cascader from "antd/es/cascader";
24
26
  import _typeof from "@babel/runtime/helpers/esm/typeof";
@@ -32,7 +34,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
32
34
  /*
33
35
  * @Author:wangxian
34
36
  * @Date: 2021-09-18 14:15:04
35
- * @LastEditTime: 2023-03-06 14:43:01
37
+ * @LastEditTime: 2023-03-06 16:24:14
36
38
  */
37
39
  import React from 'react';
38
40
  import { MetadataFormContext, MetadataRefContext } from '../interface';
@@ -45,7 +47,7 @@ import useObservable from '../../../framework/rxjs-hooks/useObservable';
45
47
  import { assign } from '../utils';
46
48
 
47
49
  function Index(props) {
48
- var _extraInfo$http6, _extraInfo$http7, _extraInfo$http8, _extraInfo$http9;
50
+ var _extraInfo$http8, _extraInfo$http9, _extraInfo$http10, _extraInfo$http11, _extraInfo$http12, _extraInfo$http13;
49
51
 
50
52
  var id = props.id,
51
53
  name = props.name,
@@ -68,17 +70,22 @@ function Index(props) {
68
70
  cascaderOption = _React$useState2[0],
69
71
  setCascaderOption = _React$useState2[1];
70
72
 
71
- var _React$useState3 = React.useState(),
73
+ var _React$useState3 = React.useState([]),
72
74
  _React$useState4 = _slicedToArray(_React$useState3, 2),
73
- watchValue = _React$useState4[0],
74
- setWatchValue = _React$useState4[1];
75
+ treeData = _React$useState4[0],
76
+ setTreeData = _React$useState4[1];
77
+
78
+ var _React$useState5 = React.useState(),
79
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
80
+ watchValue = _React$useState6[0],
81
+ setWatchValue = _React$useState6[1];
75
82
 
76
83
  var watchValueRef = React.useRef();
77
84
 
78
- var _React$useState5 = React.useState([]),
79
- _React$useState6 = _slicedToArray(_React$useState5, 2),
80
- mutiSelect = _React$useState6[0],
81
- setMutiSelect = _React$useState6[1];
85
+ var _React$useState7 = React.useState([]),
86
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
87
+ mutiSelect = _React$useState8[0],
88
+ setMutiSelect = _React$useState8[1];
82
89
 
83
90
  var pageRef = React.useRef(1);
84
91
  var totalRef = React.useRef();
@@ -101,6 +108,8 @@ function Index(props) {
101
108
  var _watchArr = _watch.split(',');
102
109
 
103
110
  if (_watchArr.length === 1) {
111
+ var _p$payload;
112
+
104
113
  var evalString = '';
105
114
 
106
115
  for (var i = 0; i < name.length; i++) {
@@ -126,7 +135,7 @@ function Index(props) {
126
135
  }
127
136
  }
128
137
 
129
- if (_changeData) {
138
+ if (_changeData && !(p === null || p === void 0 ? void 0 : (_p$payload = p.payload) === null || _p$payload === void 0 ? void 0 : _p$payload.trigger)) {
130
139
  setTimeout(function () {
131
140
  var v = {};
132
141
  assign(name, undefined, v);
@@ -134,6 +143,8 @@ function Index(props) {
134
143
  }, 100);
135
144
  }
136
145
  } else {
146
+ var _p$payload2;
147
+
137
148
  var b = false;
138
149
 
139
150
  for (var _i = 0; _i < _watchArr.length; _i++) {
@@ -157,7 +168,7 @@ function Index(props) {
157
168
  }
158
169
  }
159
170
 
160
- if (b) {
171
+ if (b && !(p === null || p === void 0 ? void 0 : (_p$payload2 = p.payload) === null || _p$payload2 === void 0 ? void 0 : _p$payload2.trigger)) {
161
172
  setWatchValue(_objectSpread({}, watchValueRef.current));
162
173
  setTimeout(function () {
163
174
  var v = {};
@@ -198,7 +209,7 @@ function Index(props) {
198
209
  totalRef.current = res === null || res === void 0 ? void 0 : res.total;
199
210
 
200
211
  if (!(_res && _res.length > 0)) {
201
- _context.next = 17;
212
+ _context.next = 19;
202
213
  break;
203
214
  }
204
215
 
@@ -218,6 +229,14 @@ function Index(props) {
218
229
  return _context.abrupt("return", _res);
219
230
 
220
231
  case 14:
232
+ if (!(http === null || http === void 0 ? void 0 : http.isTreeSelect)) {
233
+ _context.next = 16;
234
+ break;
235
+ }
236
+
237
+ return _context.abrupt("return", _res);
238
+
239
+ case 16:
221
240
  return _context.abrupt("return", _res.map(function (it) {
222
241
  if (http === null || http === void 0 ? void 0 : http.isCascader) {
223
242
  return {
@@ -234,11 +253,11 @@ function Index(props) {
234
253
  }
235
254
  }));
236
255
 
237
- case 17:
256
+ case 19:
238
257
  console.warn("".concat(_url, " is not return success result"));
239
258
  return _context.abrupt("return", []);
240
259
 
241
- case 19:
260
+ case 21:
242
261
  case "end":
243
262
  return _context.stop();
244
263
  }
@@ -284,14 +303,14 @@ function Index(props) {
284
303
  return processSelectOptionsData();
285
304
  }, [initEnumValue, myEnum, id, extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxSelect]);
286
305
  var httpOptions = useAsyncMemo( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
287
- var _extraInfo$http2, _extraInfo$http3, res;
306
+ var _extraInfo$http2, _extraInfo$http3, _extraInfo$http4, res;
288
307
 
289
308
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
290
309
  while (1) {
291
310
  switch (_context2.prev = _context2.next) {
292
311
  case 0:
293
312
  if (!((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http.url))) {
294
- _context2.next = 6;
313
+ _context2.next = 7;
295
314
  break;
296
315
  }
297
316
 
@@ -305,12 +324,16 @@ function Index(props) {
305
324
  setCascaderOption(_toConsumableArray(res));
306
325
  }
307
326
 
327
+ if (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$http4 = extraInfo.http) === null || _extraInfo$http4 === void 0 ? void 0 : _extraInfo$http4.isTreeSelect) {
328
+ setTreeData(_toConsumableArray(res));
329
+ }
330
+
308
331
  return _context2.abrupt("return", res);
309
332
 
310
- case 6:
333
+ case 7:
311
334
  return _context2.abrupt("return", []);
312
335
 
313
- case 7:
336
+ case 8:
314
337
  case "end":
315
338
  return _context2.stop();
316
339
  }
@@ -394,7 +417,7 @@ function Index(props) {
394
417
  }
395
418
  };
396
419
 
397
- var processSelectType = function processSelectType(isCascader, isPagination) {
420
+ var processSelectType = function processSelectType(isCascader, isTreeSelect, isPagination) {
398
421
  if (isCascader) {
399
422
  var _extraInfo$disabled;
400
423
 
@@ -405,13 +428,34 @@ function Index(props) {
405
428
  loadData: loadData,
406
429
  maxTagCount: 10
407
430
  });
408
- } else if (isPagination) {
431
+ } else if (isTreeSelect) {
409
432
  var _extraInfo$disabled2;
410
433
 
434
+ return /*#__PURE__*/React.createElement(_TreeSelect, {
435
+ showSearch: true,
436
+ multiple: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isMutiple,
437
+ style: {
438
+ width: '100%'
439
+ },
440
+ dropdownStyle: {
441
+ maxHeight: 400,
442
+ overflow: 'auto'
443
+ },
444
+ treeData: treeData,
445
+ disabled: (_extraInfo$disabled2 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled2 !== void 0 ? _extraInfo$disabled2 : disabled,
446
+ placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
447
+ treeDefaultExpandAll: true,
448
+ maxTagCount: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagCount,
449
+ maxTagTextLength: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagTextLength,
450
+ maxTagPlaceholder: "..."
451
+ });
452
+ } else if (isPagination) {
453
+ var _extraInfo$disabled3;
454
+
411
455
  return /*#__PURE__*/React.createElement(_Select, {
412
456
  mode: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isMutiple) ? 'multiple' : extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.mode,
413
457
  onSelect: onSelect,
414
- disabled: (_extraInfo$disabled2 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled2 !== void 0 ? _extraInfo$disabled2 : disabled,
458
+ disabled: (_extraInfo$disabled3 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled3 !== void 0 ? _extraInfo$disabled3 : disabled,
415
459
  placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
416
460
  options: httpOptions && httpOptions.length > 0 ? httpOptions : options,
417
461
  dropdownRender: function dropdownRender(menu) {
@@ -470,12 +514,12 @@ function Index(props) {
470
514
  }, it.label));
471
515
  })));
472
516
  } else {
473
- var _extraInfo$disabled3;
517
+ var _extraInfo$disabled4;
474
518
 
475
519
  return /*#__PURE__*/React.createElement(_Select, {
476
520
  mode: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isMutiple) ? 'multiple' : extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.mode,
477
521
  onSelect: onSelect,
478
- disabled: (_extraInfo$disabled3 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled3 !== void 0 ? _extraInfo$disabled3 : disabled,
522
+ disabled: (_extraInfo$disabled4 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled4 !== void 0 ? _extraInfo$disabled4 : disabled,
479
523
  placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
480
524
  options: myOptions,
481
525
  showSearch: true,
@@ -490,14 +534,14 @@ function Index(props) {
490
534
  allowClear: true,
491
535
  onChange: onSelectChange,
492
536
  maxTagCount: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagCount,
493
- maxTagTextLength: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagTextLength) || 9,
537
+ maxTagTextLength: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagTextLength,
494
538
  maxTagPlaceholder: "..."
495
539
  });
496
540
  }
497
541
  };
498
542
 
499
543
  if (isObj && isRefForm && field) {
500
- var _extraInfo$http4, _extraInfo$http5;
544
+ var _extraInfo$http5, _extraInfo$http6, _extraInfo$http7;
501
545
 
502
546
  return /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
503
547
  style: {
@@ -523,7 +567,7 @@ function Index(props) {
523
567
  }],
524
568
  help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
525
569
  tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
526
- }), processSelectType((_extraInfo$http4 = extraInfo.http) === null || _extraInfo$http4 === void 0 ? void 0 : _extraInfo$http4.isCascader, (_extraInfo$http5 = extraInfo.http) === null || _extraInfo$http5 === void 0 ? void 0 : _extraInfo$http5.isPagination));
570
+ }), processSelectType((_extraInfo$http5 = extraInfo.http) === null || _extraInfo$http5 === void 0 ? void 0 : _extraInfo$http5.isCascader, (_extraInfo$http6 = extraInfo.http) === null || _extraInfo$http6 === void 0 ? void 0 : _extraInfo$http6.isTreeSelect, (_extraInfo$http7 = extraInfo.http) === null || _extraInfo$http7 === void 0 ? void 0 : _extraInfo$http7.isPagination));
527
571
  }
528
572
 
529
573
  return !field ? /*#__PURE__*/React.createElement(_Form.Item, {
@@ -551,7 +595,7 @@ function Index(props) {
551
595
  }],
552
596
  help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
553
597
  tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
554
- }, processSelectType((_extraInfo$http6 = extraInfo.http) === null || _extraInfo$http6 === void 0 ? void 0 : _extraInfo$http6.isCascader, (_extraInfo$http7 = extraInfo.http) === null || _extraInfo$http7 === void 0 ? void 0 : _extraInfo$http7.isPagination)) : /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
598
+ }, processSelectType((_extraInfo$http8 = extraInfo.http) === null || _extraInfo$http8 === void 0 ? void 0 : _extraInfo$http8.isCascader, (_extraInfo$http9 = extraInfo.http) === null || _extraInfo$http9 === void 0 ? void 0 : _extraInfo$http9.isTreeSelect, (_extraInfo$http10 = extraInfo.http) === null || _extraInfo$http10 === void 0 ? void 0 : _extraInfo$http10.isPagination)) : /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
555
599
  style: {
556
600
  flex: 1,
557
601
  paddingRight: '10px'
@@ -562,7 +606,7 @@ function Index(props) {
562
606
  }],
563
607
  help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
564
608
  tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
565
- }), processSelectType((_extraInfo$http8 = extraInfo.http) === null || _extraInfo$http8 === void 0 ? void 0 : _extraInfo$http8.isCascader, (_extraInfo$http9 = extraInfo.http) === null || _extraInfo$http9 === void 0 ? void 0 : _extraInfo$http9.isPagination));
609
+ }), processSelectType((_extraInfo$http11 = extraInfo.http) === null || _extraInfo$http11 === void 0 ? void 0 : _extraInfo$http11.isCascader, (_extraInfo$http12 = extraInfo.http) === null || _extraInfo$http12 === void 0 ? void 0 : _extraInfo$http12.isTreeSelect, (_extraInfo$http13 = extraInfo.http) === null || _extraInfo$http13 === void 0 ? void 0 : _extraInfo$http13.isPagination));
566
610
  }
567
611
 
568
612
  export default /*#__PURE__*/React.memo(Index);
@@ -118,8 +118,9 @@ var MetadataForm = function MetadataForm(props) {
118
118
  stream$.next({
119
119
  type: 'onValuesChange',
120
120
  payload: {
121
- val: {},
122
- allVals: vals
121
+ val: vals,
122
+ allVals: vals,
123
+ trigger: 'firstLoad'
123
124
  }
124
125
  });
125
126
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.2.16",
4
+ "version": "1.2.17",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",