iglooform 2.5.50 → 2.5.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.
@@ -238,13 +238,39 @@ var UploadPhoto = function UploadPhoto(props) {
238
238
  }())).then(function () {
239
239
  return setFiles(_files);
240
240
  });
241
- };
241
+ }; // 有初始值的处理 (不是初始化)
242
+
242
243
 
243
244
  useEffect(function () {
244
245
  if (Array.isArray(value) && value.length && files.length === 0) {
245
246
  mapFilesFromValue(value);
246
247
  }
247
248
  }, [value]);
249
+ useEffect(function () {
250
+ if (!value && !files.length) return;
251
+
252
+ if (files.length) {
253
+ var urls = files.map(function (f) {
254
+ var status = f.status,
255
+ name = f.name,
256
+ errorMsg = f.errorMsg;
257
+
258
+ if (status === 'failed') {
259
+ return {
260
+ name: name,
261
+ errorMsg: errorMsg
262
+ };
263
+ }
264
+
265
+ if (f.url || f.dataUrl) {
266
+ return f.url || f.dataUrl;
267
+ }
268
+ });
269
+ onChange && onChange(urls);
270
+ } else {
271
+ onChange && onChange([]);
272
+ }
273
+ }, [files]);
248
274
  var uploadId = useMemo(function () {
249
275
  return "igloo-upload-photo-input-".concat(Math.random());
250
276
  }, []);
@@ -376,38 +402,21 @@ var UploadPhoto = function UploadPhoto(props) {
376
402
  }]);
377
403
  });
378
404
  return _context4.abrupt("return", handleUploadPromise(file, function (url) {
379
- var urls = [];
380
- setFiles(function (files) {
405
+ return setFiles(function (files) {
381
406
  return files.map(function (f) {
382
407
  if (f.uid === uid) {
383
- urls.push(url);
384
408
  return _objectSpread(_objectSpread({}, f), {}, {
385
409
  url: url,
386
410
  status: 'success'
387
411
  });
388
412
  }
389
413
 
390
- var status = f.status,
391
- name = f.name,
392
- errorMsg = f.errorMsg;
393
-
394
- if (status === 'failed') {
395
- urls.push({
396
- name: name,
397
- errorMsg: errorMsg
398
- });
399
- } else {
400
- f.url && urls.push(f.url);
401
- }
402
-
403
414
  return f;
404
415
  });
405
416
  });
406
- onChange && onChange(urls);
407
417
  }, function (errorMsg) {
408
- var fileList = [];
409
- setFiles(function (files) {
410
- var newList = files.map(function (f) {
418
+ return setFiles(function (files) {
419
+ return files.map(function (f) {
411
420
  if (f.uid === uid) {
412
421
  return _objectSpread(_objectSpread({}, f), {}, {
413
422
  status: 'failed',
@@ -417,23 +426,7 @@ var UploadPhoto = function UploadPhoto(props) {
417
426
 
418
427
  return f;
419
428
  });
420
- fileList = newList;
421
- return newList;
422
429
  });
423
- var fileListWithError = fileList.map(function (f) {
424
- if (f.uid === uid) {
425
- return {
426
- name: f.name,
427
- status: 'failed',
428
- errorMsg: errorMsg
429
- };
430
- }
431
-
432
- return f.url;
433
- }); // 需要触发onchange 在form级别报错
434
-
435
- // 需要触发onchange 在form级别报错
436
- typeof onChange === 'function' && onChange(fileListWithError);
437
430
  }));
438
431
 
439
432
  case 18:
@@ -487,59 +480,28 @@ var UploadPhoto = function UploadPhoto(props) {
487
480
 
488
481
  var handleDelete = /*#__PURE__*/function () {
489
482
  var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(index) {
490
- var arr, hasError, rst;
491
483
  return regeneratorRuntime.wrap(function _callee6$(_context6) {
492
484
  while (1) {
493
485
  switch (_context6.prev = _context6.next) {
494
486
  case 0:
495
487
  limitNumError.current = null;
496
- arr = files;
497
- _context6.next = 4;
488
+ _context6.next = 3;
498
489
  return setFiles(function (files) {
499
490
  var newArr = files.filter(function (_, i) {
500
491
  return i !== index;
501
492
  });
502
- arr = newArr;
503
493
  return newArr;
504
494
  });
505
495
 
506
- case 4:
507
- _context6.next = 6;
496
+ case 3:
497
+ _context6.next = 5;
508
498
  return setMasks(function (masks) {
509
499
  return masks.filter(function (_, i) {
510
500
  return i !== index;
511
501
  });
512
502
  });
513
503
 
514
- case 6:
515
- // 删除之后找一下是否存在上传过程中错误的文件
516
- hasError = arr.some(function (f) {
517
- return (f === null || f === void 0 ? void 0 : f.status) === 'failed';
518
- });
519
-
520
- if (!hasError) {
521
- _context6.next = 10;
522
- break;
523
- }
524
-
525
- rst = arr.map(function (f) {
526
- if ((f === null || f === void 0 ? void 0 : f.status) === 'failed') {
527
- return {
528
- errorMsg: f.errorMsg
529
- };
530
- }
531
-
532
- return f.url;
533
- });
534
- return _context6.abrupt("return", typeof onChange === 'function' && onChange(rst));
535
-
536
- case 10:
537
- typeof onChange === 'function' && onChange(arr.map(function (_ref7) {
538
- var url = _ref7.url;
539
- return url;
540
- }));
541
-
542
- case 11:
504
+ case 5:
543
505
  case "end":
544
506
  return _context6.stop();
545
507
  }
@@ -553,8 +515,8 @@ var UploadPhoto = function UploadPhoto(props) {
553
515
  }();
554
516
 
555
517
  var handleReUpload = /*#__PURE__*/function () {
556
- var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(index) {
557
- var _files$index, originFile, reUpUid, rst, latestFiles, fileListWithError, newList, _rst;
518
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(index) {
519
+ var _files$index, originFile, reUpUid, rst;
558
520
 
559
521
  return regeneratorRuntime.wrap(function _callee7$(_context7) {
560
522
  while (1) {
@@ -585,86 +547,46 @@ var UploadPhoto = function UploadPhoto(props) {
585
547
 
586
548
  case 8:
587
549
  rst = _context7.sent;
588
- latestFiles = [];
589
- _context7.next = 12;
550
+ _context7.next = 11;
590
551
  return setFiles(function (files) {
591
552
  var newFiles = _toConsumableArray(files);
592
553
 
593
554
  newFiles[index].url = rst;
594
555
  newFiles[index].status = 'success';
595
- latestFiles = newFiles;
596
556
  return newFiles;
597
557
  });
598
558
 
599
- case 12:
600
- // 查找出现在file 列表中地错误信息
601
- fileListWithError = latestFiles.map(function (f) {
602
- var status = f.status,
603
- errorMsg = f.errorMsg,
604
- url = f.url,
605
- name = f.name;
606
-
607
- if (status === 'failed') {
608
- return {
609
- errorMsg: errorMsg,
610
- name: name
611
- };
612
- }
613
-
614
- return url;
615
- });
616
- onChange && onChange(fileListWithError);
617
- _context7.next = 23;
559
+ case 11:
560
+ _context7.next = 17;
618
561
  break;
619
562
 
620
- case 16:
621
- _context7.prev = 16;
563
+ case 13:
564
+ _context7.prev = 13;
622
565
  _context7.t0 = _context7["catch"](5);
623
- newList = [];
624
- _context7.next = 21;
566
+ _context7.next = 17;
625
567
  return setFiles(function (files) {
626
568
  var newFiles = _toConsumableArray(files);
627
569
 
628
570
  newFiles[index].status = 'failed';
629
571
  newFiles[index].errorMsg = _context7.t0;
630
- newList = newFiles;
631
572
  return newFiles;
632
573
  });
633
574
 
634
- case 21:
635
- // 报错之后要重制报错信息
636
- _rst = newList.map(function (f) {
637
- var name = f.name,
638
- errorMsg = f.errorMsg,
639
- url = f.url,
640
- uid = f.uid;
641
-
642
- if (uid === reUpUid) {
643
- return {
644
- name: name,
645
- errorMsg: errorMsg
646
- };
647
- }
648
-
649
- return url;
650
- });
651
- typeof onChange === 'function' && onChange(_rst);
652
-
653
- case 23:
575
+ case 17:
654
576
  if (isMobile) {
655
577
  closeMask(index);
656
578
  }
657
579
 
658
- case 24:
580
+ case 18:
659
581
  case "end":
660
582
  return _context7.stop();
661
583
  }
662
584
  }
663
- }, _callee7, null, [[5, 16]]);
585
+ }, _callee7, null, [[5, 13]]);
664
586
  }));
665
587
 
666
588
  return function handleReUpload(_x11) {
667
- return _ref8.apply(this, arguments);
589
+ return _ref7.apply(this, arguments);
668
590
  };
669
591
  }();
670
592
 
@@ -761,12 +683,12 @@ var UploadPhoto = function UploadPhoto(props) {
761
683
  children: _jsxs(_Row, {
762
684
  gutter: [isMobile ? 16 : 32, 16],
763
685
  wrap: true,
764
- children: [Boolean(samples === null || samples === void 0 ? void 0 : samples.length) && samples.map(function (_ref9, index) {
686
+ children: [Boolean(samples === null || samples === void 0 ? void 0 : samples.length) && samples.map(function (_ref8, index) {
765
687
  var _classnames, _classnames2;
766
688
 
767
- var src = _ref9.src,
768
- label = _ref9.label,
769
- type = _ref9.type;
689
+ var src = _ref8.src,
690
+ label = _ref8.label,
691
+ type = _ref8.type;
770
692
  return _jsxs(_Col, {
771
693
  span: sampleSpan,
772
694
  children: [_jsx("img", {
@@ -826,13 +748,13 @@ var UploadPhoto = function UploadPhoto(props) {
826
748
  children: buttonText || 'Upload'
827
749
  })
828
750
  })]
829
- }), files.map(function (_ref10, index) {
751
+ }), files.map(function (_ref9, index) {
830
752
  var _classnames5;
831
753
 
832
- var dataUrl = _ref10.dataUrl,
833
- status = _ref10.status,
834
- type = _ref10.type,
835
- uid = _ref10.uid;
754
+ var dataUrl = _ref9.dataUrl,
755
+ status = _ref9.status,
756
+ type = _ref9.type,
757
+ uid = _ref9.uid;
836
758
  return _jsx(_Badge, {
837
759
  count: getBadge(status, index, limit),
838
760
  children: _jsxs("div", {
@@ -900,10 +822,10 @@ function checkFileList(value) {
900
822
  return Promise.resolve();
901
823
  }
902
824
 
903
- UploadPhoto.formItemPropsHandler = function (_ref11) {
904
- var limit = _ref11.limit,
905
- previewFormater = _ref11.previewFormater,
906
- label = _ref11.label;
825
+ UploadPhoto.formItemPropsHandler = function (_ref10) {
826
+ var limit = _ref10.limit,
827
+ previewFormater = _ref10.previewFormater,
828
+ label = _ref10.label;
907
829
  return {
908
830
  previewFormater: previewFormater || function (value) {
909
831
  return _jsx(UploadPreview, {
@@ -50,7 +50,7 @@ export declare const calcFormItemProps: (config: FormItemConfig, extraProps: For
50
50
  elementProps: {
51
51
  [key: string]: any;
52
52
  };
53
- display: boolean;
53
+ display: any;
54
54
  previewFormater: ((value: any, form?: FormInstance<any> | undefined) => any) | undefined;
55
55
  };
56
56
  export declare const calcDisabled: (disabled?: boolean | FormItemAssert | FormItemAssert[] | undefined, form?: FormInstance<any> | undefined) => boolean;
@@ -72,5 +72,5 @@ export declare const calcSelectValue: (selectValue?: FormItemSelectValue[] | und
72
72
  value: any;
73
73
  disabled: boolean | undefined;
74
74
  };
75
- export declare const calcShouldRender: (dependencies?: NamePath[], asserts?: FormItemAssert[], shouldRender?: ((form?: FormInstance<any> | undefined) => boolean) | undefined, form?: FormInstance<any> | undefined) => boolean;
75
+ export declare const calcShouldRender: (name: NamePath, dependencies?: NamePath[], asserts?: FormItemAssert[], shouldRender?: ((form?: FormInstance<any> | undefined) => boolean) | undefined, shouldRenderCode?: string | undefined, form?: FormInstance<any> | undefined) => any;
76
76
  export declare const getRuleValidation: (url: string, rule: string | string[], values?: any, lang?: string) => Promise<any>;
@@ -1,4 +1,4 @@
1
- var _excluded = ["type", "name", "required", "requiredAsserts", "showOptional", "rules", "initialValue", "normalize", "mergeRules", "getValueFromEvent", "getValueProps", "extra", "help", "label", "previewLabel", "extraLabel", "copyValue", "selectValue", "span", "halfRow", "fullRow", "valuePropName", "dependencies", "asserts", "messageVariables", "requiredMessage", "previewFormater", "disabled", "ignore", "shouldRender", "valueFormater", "antdDependencies", "dateLimitationType", "absoluteRangeEnd", "absoluteRangeStart", "relativeRangeStart", "relativeRangeEnd", "validationCode"],
1
+ var _excluded = ["type", "name", "required", "requiredAsserts", "showOptional", "rules", "initialValue", "normalize", "mergeRules", "getValueFromEvent", "getValueProps", "extra", "help", "label", "previewLabel", "extraLabel", "copyValue", "selectValue", "span", "halfRow", "fullRow", "valuePropName", "dependencies", "asserts", "messageVariables", "requiredMessage", "previewFormater", "disabled", "ignore", "shouldRender", "valueFormater", "antdDependencies", "dateLimitationType", "absoluteRangeEnd", "absoluteRangeStart", "relativeRangeStart", "relativeRangeEnd", "validationCode", "shouldRenderCode"],
2
2
  _excluded2 = ["initialValue", "normalize", "rules", "extra", "help", "getValueFromEvent", "span", "valuePropName", "fullRow", "halfRow", "messageVariables", "requiredMessage", "previewFormater", "valueFormater", "required", "requiredMark", "className"];
3
3
 
4
4
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
@@ -207,6 +207,7 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
207
207
  relativeRangeEnd = config.relativeRangeEnd,
208
208
  _config$validationCod = config.validationCode,
209
209
  validationCode = _config$validationCod === void 0 ? [] : _config$validationCod,
210
+ shouldRenderCode = config.shouldRenderCode,
210
211
  rest = _objectWithoutProperties(config, _excluded);
211
212
 
212
213
  invariant(nameProp !== undefined || type === 'Divider' || type === 'Section' || type === 'Typography' || !type, "name property is required for form item config (type: ".concat(type, ")"));
@@ -428,7 +429,7 @@ export var calcFormItemProps = function calcFormItemProps(config, extraProps, fo
428
429
  dependencies: antdDependencies
429
430
  },
430
431
  elementProps: elementProps,
431
- display: !ignore && calcShouldRender(dependencies, asserts, shouldRender, form),
432
+ display: !ignore && calcShouldRender(name, dependencies, asserts, shouldRender, shouldRenderCode, form),
432
433
  previewFormater: previewFormater || extraPreviewFormater
433
434
  };
434
435
  };
@@ -514,11 +515,12 @@ export var calcSelectValue = function calcSelectValue(selectValue, form) {
514
515
  selected: false
515
516
  };
516
517
  };
517
- export var calcShouldRender = function calcShouldRender() {
518
- var dependencies = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
519
- var asserts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
520
- var shouldRender = arguments.length > 2 ? arguments[2] : undefined;
521
- var form = arguments.length > 3 ? arguments[3] : undefined;
518
+ export var calcShouldRender = function calcShouldRender(name) {
519
+ var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
520
+ var asserts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
521
+ var shouldRender = arguments.length > 3 ? arguments[3] : undefined;
522
+ var shouldRenderCode = arguments.length > 4 ? arguments[4] : undefined;
523
+ var form = arguments.length > 5 ? arguments[5] : undefined;
522
524
  if (!form) return true;
523
525
 
524
526
  var _iterator3 = _createForOfIteratorHelper(dependencies),
@@ -538,6 +540,26 @@ export var calcShouldRender = function calcShouldRender() {
538
540
  _iterator3.f();
539
541
  }
540
542
 
543
+ if (typeof shouldRender === 'function') {
544
+ return shouldRender(form);
545
+ }
546
+
547
+ if (shouldRenderCode) {
548
+ var fn = eval(shouldRenderCode);
549
+
550
+ if (typeof fn === 'function') {
551
+ try {
552
+ var value = form.getFieldValue(name);
553
+ var values = form.getFieldsValue(true);
554
+ return fn(value, values, {
555
+ moment: moment
556
+ });
557
+ } catch (_unused2) {
558
+ return false;
559
+ }
560
+ }
561
+ }
562
+
541
563
  var _iterator4 = _createForOfIteratorHelper(asserts),
542
564
  _step4;
543
565
 
@@ -553,10 +575,6 @@ export var calcShouldRender = function calcShouldRender() {
553
575
  _iterator4.f();
554
576
  }
555
577
 
556
- if (typeof shouldRender === 'function' && !shouldRender(form)) {
557
- return false;
558
- }
559
-
560
578
  return true;
561
579
  };
562
580
  export var getRuleValidation = /*#__PURE__*/function () {
@@ -1,8 +1,11 @@
1
1
  import { DatePickerProps, RangePickerProps, MonthPickerProps, WeekPickerProps } from 'antd/es/date-picker';
2
2
  import { FC, IglooComponentProps } from '../types';
3
+ import { Moment } from 'moment';
3
4
  import './style/index.less';
4
5
  export { default as IglooBuddhistDatePicker } from './buddhist';
5
- declare type Props = DatePickerProps & IglooComponentProps;
6
+ declare type Props = Omit<DatePickerProps, 'value'> & IglooComponentProps & {
7
+ value?: Moment | null | 0;
8
+ };
6
9
  declare const IglooDatePicker: FC<Props>;
7
10
  export default IglooDatePicker;
8
11
  export declare const IglooRangePicker: FC<RangePickerProps & IglooComponentProps>;
@@ -89,7 +89,7 @@ var IglooDatePicker = function IglooDatePicker(_ref) {
89
89
  setFocus = _useState2[1];
90
90
 
91
91
  return (0, _jsxRuntime.jsx)(_datePicker.default, _objectSpread(_objectSpread({}, (0, _omit.default)(props, _formMethods.default)), {}, {
92
- value: (0, _moment.default)(value),
92
+ value: value || value === 0 ? (0, _moment.default)(value) : undefined,
93
93
  placeholder: placeholder || dateFormater,
94
94
  format: format || dateFormater,
95
95
  inputReadOnly: true,
@@ -116,7 +116,7 @@ IglooDatePicker.formItemPropsHandler = function (_ref2) {
116
116
  return (0, _moment.default)(value).format(format || dateFormater);
117
117
  },
118
118
  valueFormater: function valueFormater(value) {
119
- return +(0, _moment.default)(value);
119
+ return value ? +(0, _moment.default)(value) : value;
120
120
  },
121
121
  'element-allowClear': false
122
122
  };
@@ -121,7 +121,8 @@ var Element = function Element(_ref) {
121
121
  subscribedFields = config.subscribedFields,
122
122
  disabled = config.disabled,
123
123
  extraLabel = config.extraLabel,
124
- requiredAsserts = config.requiredAsserts;
124
+ requiredAsserts = config.requiredAsserts,
125
+ shouldRenderCode = config.shouldRenderCode;
125
126
  var dependentField = dependencies || [];
126
127
 
127
128
  if (Array.isArray(subscribedFields)) {
@@ -153,7 +154,7 @@ var Element = function Element(_ref) {
153
154
  });
154
155
  }
155
156
 
156
- if ((shouldRender || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
157
+ if ((shouldRender || shouldRenderCode || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
157
158
  dependentField.push('SUBSCRIBE_ALL');
158
159
  }
159
160
 
@@ -134,26 +134,45 @@ var HSteps = function HSteps(_ref) {
134
134
  (0, _react.useEffect)(function () {
135
135
  var subscribe = elements.some(function (_ref2) {
136
136
  var shouldRender = _ref2.shouldRender,
137
- getButtonDisabledState = _ref2.getButtonDisabledState;
138
- return Boolean(shouldRender) || Boolean(getButtonDisabledState);
137
+ getButtonDisabledState = _ref2.getButtonDisabledState,
138
+ shouldRenderCode = _ref2.shouldRenderCode;
139
+ return Boolean(shouldRender) || Boolean(getButtonDisabledState) || Boolean(shouldRenderCode);
139
140
  });
140
141
 
141
142
  if (subscribe) {
142
143
  Array.isArray(subscribedFields) ? registerDependencies(subscribedFields, dispatch) : registerDependencies('SUBSCRIBE_ALL', dispatch);
143
144
  }
145
+
146
+ var dependentField = [];
147
+ elements.forEach(function (_ref3) {
148
+ var asserts = _ref3.asserts;
149
+ if (!(asserts === null || asserts === void 0 ? void 0 : asserts.length)) return;
150
+ asserts.forEach(function (_ref4) {
151
+ var field = _ref4.field;
152
+ return dependentField.push(field);
153
+ });
154
+ });
155
+ dependentField.length && registerDependencies(dependentField, dispatch);
144
156
  }, []);
145
157
  (0, _react.useEffect)(function () {
146
158
  if (currentStep === undefined || currentStep === current) return;
147
159
  setCurrent(currentStep);
148
160
  }, [currentStep]);
149
- var renderElements = elements.filter(function (step) {
150
- (0, _invariant.default)(step.type === 'Step', 'Child of steps should be Step');
151
- (0, _invariant.default)(!step.validationRule || getRuleValidationApi, 'Please provide getRuleValidationApi in Form props');
152
- return typeof step.shouldRender !== 'function' || step.shouldRender(form);
161
+ var renderElements = elements.filter(function (_ref5) {
162
+ var type = _ref5.type,
163
+ curName = _ref5.name,
164
+ validationRule = _ref5.validationRule,
165
+ dependencies = _ref5.dependencies,
166
+ asserts = _ref5.asserts,
167
+ shouldRender = _ref5.shouldRender,
168
+ shouldRenderCode = _ref5.shouldRenderCode;
169
+ (0, _invariant.default)(type === 'Step', 'Child of steps should be Step');
170
+ (0, _invariant.default)(!validationRule || getRuleValidationApi, 'Please provide getRuleValidationApi in Form props');
171
+ return (0, _formUtils.calcShouldRender)((0, _formUtils.calcNamePath)((0, _formUtils.calcNamePath)(parentName, name), curName), dependencies, asserts, shouldRender, shouldRenderCode, form);
153
172
  });
154
173
 
155
174
  var handleNext = /*#__PURE__*/function () {
156
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
175
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
157
176
  var _allFields$filter;
158
177
 
159
178
  var allFields, allValues, _renderElements$curre, currentName, handleNext, validationRule, namePath, fields, _iterator, _step, collapseSection, res, errors;
@@ -166,11 +185,11 @@ var HSteps = function HSteps(_ref) {
166
185
  allValues = form === null || form === void 0 ? void 0 : form.getFieldsValue(true);
167
186
  _renderElements$curre = renderElements[current], currentName = _renderElements$curre.name, handleNext = _renderElements$curre.handleNext, validationRule = _renderElements$curre.validationRule;
168
187
  namePath = (0, _formUtils.calcNamePath)(name, currentName);
169
- fields = allFields === null || allFields === void 0 ? void 0 : (_allFields$filter = allFields.filter(function (_ref4) {
170
- var name = _ref4.name;
188
+ fields = allFields === null || allFields === void 0 ? void 0 : (_allFields$filter = allFields.filter(function (_ref7) {
189
+ var name = _ref7.name;
171
190
  return name.join().startsWith(namePath === null || namePath === void 0 ? void 0 : namePath.join());
172
- })) === null || _allFields$filter === void 0 ? void 0 : _allFields$filter.map(function (_ref5) {
173
- var name = _ref5.name;
191
+ })) === null || _allFields$filter === void 0 ? void 0 : _allFields$filter.map(function (_ref8) {
192
+ var name = _ref8.name;
174
193
  return name;
175
194
  });
176
195
  _context.prev = 5;
@@ -274,7 +293,7 @@ var HSteps = function HSteps(_ref) {
274
293
  }));
275
294
 
276
295
  return function handleNext() {
277
- return _ref3.apply(this, arguments);
296
+ return _ref6.apply(this, arguments);
278
297
  };
279
298
  }();
280
299
 
@@ -421,14 +440,14 @@ var HSteps = function HSteps(_ref) {
421
440
  margin: 0
422
441
  },
423
442
  children: (0, _jsxRuntime.jsx)(_confirmation.default, {})
424
- }), confirmations && Object.entries(confirmations).map(function (_ref6) {
425
- var _ref7 = _slicedToArray(_ref6, 2),
426
- key = _ref7[0],
427
- _ref7$ = _ref7[1],
428
- required = _ref7$.required,
429
- _ref7$$confirmation = _ref7$.confirmation,
430
- confirmation = _ref7$$confirmation === void 0 ? {} : _ref7$$confirmation,
431
- requiredMessage = _ref7$.requiredMessage;
443
+ }), confirmations && Object.entries(confirmations).map(function (_ref9) {
444
+ var _ref10 = _slicedToArray(_ref9, 2),
445
+ key = _ref10[0],
446
+ _ref10$ = _ref10[1],
447
+ required = _ref10$.required,
448
+ _ref10$$confirmation = _ref10$.confirmation,
449
+ confirmation = _ref10$$confirmation === void 0 ? {} : _ref10$$confirmation,
450
+ requiredMessage = _ref10$.requiredMessage;
432
451
 
433
452
  return (0, _jsxRuntime.jsx)(_form.default.Item, {
434
453
  name: (0, _formUtils.calcNamePath)(parentName, key),
@@ -92,24 +92,41 @@ var Steps = function Steps(_ref) {
92
92
  (0, _react.useEffect)(function () {
93
93
  var subscribe = elements.some(function (_ref2) {
94
94
  var shouldRender = _ref2.shouldRender,
95
- getButtonDisabledState = _ref2.getButtonDisabledState;
96
- return Boolean(shouldRender) || Boolean(getButtonDisabledState);
95
+ getButtonDisabledState = _ref2.getButtonDisabledState,
96
+ shouldRenderCode = _ref2.shouldRenderCode;
97
+ return Boolean(shouldRender) || Boolean(getButtonDisabledState) || Boolean(shouldRenderCode);
97
98
  });
98
99
 
99
100
  if (subscribe) {
100
101
  Array.isArray(subscribedFields) ? registerDependencies(subscribedFields, dispatch) : registerDependencies('SUBSCRIBE_ALL', dispatch);
101
102
  }
103
+
104
+ var dependentField = [];
105
+ elements.forEach(function (_ref3) {
106
+ var asserts = _ref3.asserts;
107
+ if (!(asserts === null || asserts === void 0 ? void 0 : asserts.length)) return;
108
+ asserts.forEach(function (_ref4) {
109
+ var field = _ref4.field;
110
+ return dependentField.push(field);
111
+ });
112
+ });
113
+ dependentField.length && registerDependencies(dependentField, dispatch);
102
114
  }, []);
103
115
  (0, _react.useEffect)(function () {
104
116
  if (currentStep === undefined || currentStep === current) return;
105
117
  setCurrent(currentStep);
106
118
  }, [currentStep]);
107
- var renderElements = elements.filter(function (step) {
108
- return typeof step.shouldRender !== 'function' || step.shouldRender(form);
119
+ var renderElements = elements.filter(function (_ref5) {
120
+ var curName = _ref5.name,
121
+ dependencies = _ref5.dependencies,
122
+ asserts = _ref5.asserts,
123
+ shouldRender = _ref5.shouldRender,
124
+ shouldRenderCode = _ref5.shouldRenderCode;
125
+ return (0, _formUtils.calcShouldRender)((0, _formUtils.calcNamePath)((0, _formUtils.calcNamePath)(parentName, name), curName), dependencies, asserts, shouldRender, shouldRenderCode, form);
109
126
  });
110
127
 
111
128
  var handleNext = /*#__PURE__*/function () {
112
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
129
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
113
130
  var _allFields$filter;
114
131
 
115
132
  var allFields, allValues, _renderElements$curre, currentName, handleNext, validationRule, namePath, fields, res, errors;
@@ -122,11 +139,11 @@ var Steps = function Steps(_ref) {
122
139
  allValues = form === null || form === void 0 ? void 0 : form.getFieldsValue(true);
123
140
  _renderElements$curre = renderElements[current], currentName = _renderElements$curre.name, handleNext = _renderElements$curre.handleNext, validationRule = _renderElements$curre.validationRule;
124
141
  namePath = (0, _formUtils.calcNamePath)(name, currentName);
125
- fields = allFields === null || allFields === void 0 ? void 0 : (_allFields$filter = allFields.filter(function (_ref4) {
126
- var name = _ref4.name;
142
+ fields = allFields === null || allFields === void 0 ? void 0 : (_allFields$filter = allFields.filter(function (_ref7) {
143
+ var name = _ref7.name;
127
144
  return name.join().startsWith(namePath === null || namePath === void 0 ? void 0 : namePath.join());
128
- })) === null || _allFields$filter === void 0 ? void 0 : _allFields$filter.map(function (_ref5) {
129
- var name = _ref5.name;
145
+ })) === null || _allFields$filter === void 0 ? void 0 : _allFields$filter.map(function (_ref8) {
146
+ var name = _ref8.name;
130
147
  return name;
131
148
  });
132
149
  _context.prev = 5;
@@ -217,7 +234,7 @@ var Steps = function Steps(_ref) {
217
234
  }));
218
235
 
219
236
  return function handleNext() {
220
- return _ref3.apply(this, arguments);
237
+ return _ref6.apply(this, arguments);
221
238
  };
222
239
  }();
223
240
 
@@ -16,7 +16,6 @@ export interface StepProps extends FormItemConfig {
16
16
  editButtonLabel?: string;
17
17
  disableEditButton?: boolean;
18
18
  buttonText?: string;
19
- validationRule?: string;
20
19
  }
21
20
  declare const Step: FC<StepProps>;
22
21
  export default Step;