iglooform 2.5.45 → 2.5.46

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.
@@ -29,11 +29,14 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
29
29
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
30
30
 
31
31
  import { jsx as _jsx } from "react/jsx-runtime";
32
- import { useState, useRef } from 'react';
32
+ import { useState, useRef, useContext } from 'react';
33
33
  import FormContext from '../form-context';
34
34
  import messages from './messages';
35
35
  import './style/index.less';
36
+ import invariant from 'invariant';
36
37
  import classNames from 'classnames';
38
+ import { LocaleContext } from '../locale';
39
+ import { getRuleValidation } from './../utils/form-utils';
37
40
 
38
41
  var FreeForm = function FreeForm(props) {
39
42
  var children = props.children,
@@ -56,7 +59,9 @@ var FreeForm = function FreeForm(props) {
56
59
  _props$onFirstModifie = props.onFirstModified,
57
60
  onFirstModified = _props$onFirstModifie === void 0 ? function () {} : _props$onFirstModifie,
58
61
  uploadApi = props.uploadApi,
59
- selectDatasourceApi = props.selectDatasourceApi;
62
+ selectDatasourceApi = props.selectDatasourceApi,
63
+ validationRule = props.validationRule,
64
+ getRuleValidationApi = props.getRuleValidationApi;
60
65
 
61
66
  var _Form$useForm = _Form.useForm(),
62
67
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
@@ -78,27 +83,67 @@ var FreeForm = function FreeForm(props) {
78
83
  firstModifiedCalled = _useState6[0],
79
84
  callFirstModified = _useState6[1];
80
85
 
86
+ var _useContext = useContext(LocaleContext),
87
+ currentLang = _useContext.currentLang;
88
+
89
+ invariant(!validationRule || getRuleValidationApi, 'Please provide getRuleValidationApi in Form props');
90
+
81
91
  var validateMessages = localesProp.validateMessages,
82
92
  locales = _objectWithoutProperties(localesProp, _excluded);
83
93
 
84
94
  var handleSubmit = /*#__PURE__*/function () {
85
95
  var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(values) {
86
- var errors;
96
+ var allValues, res, errors;
87
97
  return regeneratorRuntime.wrap(function _callee$(_context) {
88
98
  while (1) {
89
99
  switch (_context.prev = _context.next) {
90
100
  case 0:
101
+ allValues = form.getFieldsValue(true);
102
+ setSubmitting(true);
103
+
104
+ if (!(validationRule && getRuleValidationApi)) {
105
+ _context.next = 18;
106
+ break;
107
+ }
108
+
109
+ _context.prev = 3;
110
+ _context.next = 6;
111
+ return getRuleValidation(getRuleValidationApi, validationRule, allValues, currentLang);
112
+
113
+ case 6:
114
+ res = _context.sent;
115
+
116
+ if (!(Array.isArray(res) && res.length)) {
117
+ _context.next = 12;
118
+ break;
119
+ }
120
+
121
+ form.setFields(res);
122
+ form.scrollToField(res[0].name);
123
+ setSubmitting(false);
124
+ return _context.abrupt("return");
125
+
126
+ case 12:
127
+ _context.next = 18;
128
+ break;
129
+
130
+ case 14:
131
+ _context.prev = 14;
132
+ _context.t0 = _context["catch"](3);
133
+ setSubmitting(false);
134
+ return _context.abrupt("return");
135
+
136
+ case 18:
91
137
  if (!(typeof onSubmit === 'function')) {
92
- _context.next = 10;
138
+ _context.next = 27;
93
139
  break;
94
140
  }
95
141
 
96
- setSubmitting(true);
97
- _context.prev = 2;
98
- _context.next = 5;
142
+ _context.prev = 19;
143
+ _context.next = 22;
99
144
  return onSubmit(values);
100
145
 
101
- case 5:
146
+ case 22:
102
147
  errors = _context.sent;
103
148
 
104
149
  if (Array.isArray(errors)) {
@@ -106,17 +151,20 @@ var FreeForm = function FreeForm(props) {
106
151
  form.scrollToField(errors[0].name);
107
152
  }
108
153
 
109
- case 7:
110
- _context.prev = 7;
154
+ case 24:
155
+ _context.prev = 24;
156
+ setSubmitting(false);
157
+ return _context.finish(24);
158
+
159
+ case 27:
111
160
  setSubmitting(false);
112
- return _context.finish(7);
113
161
 
114
- case 10:
162
+ case 28:
115
163
  case "end":
116
164
  return _context.stop();
117
165
  }
118
166
  }
119
- }, _callee, null, [[2,, 7, 10]]);
167
+ }, _callee, null, [[3, 14], [19,, 24, 27]]);
120
168
  }));
121
169
 
122
170
  return function handleSubmit(_x) {
@@ -185,6 +233,7 @@ var FreeForm = function FreeForm(props) {
185
233
  registerDependencies: registerDependencies,
186
234
  uploadApi: uploadApi,
187
235
  selectDatasourceApi: selectDatasourceApi,
236
+ getRuleValidationApi: getRuleValidationApi,
188
237
  handleValuesChange: handleValuesChange
189
238
  }, locales),
190
239
  children: _jsx(_Form, {
@@ -16,6 +16,7 @@ export interface StepProps extends FormItemConfig {
16
16
  editButtonLabel?: string;
17
17
  disableEditButton?: boolean;
18
18
  buttonText?: string;
19
+ validationRule?: string;
19
20
  }
20
21
  declare const Step: FC<StepProps>;
21
22
  export default Step;
@@ -33,8 +33,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
33
33
  import { useContext, useState, useRef, useEffect, useMemo, useReducer, cloneElement, isValidElement } from 'react';
34
34
  import { LocaleContext } from '../../locale';
35
35
  import Button from '../../button';
36
- import { calcNamePath } from '../../utils/form-utils';
36
+ import { calcNamePath, getRuleValidation } from '../../utils/form-utils';
37
37
  import FormContext from '../../form-context';
38
+ import invariant from 'invariant';
38
39
  import './style/index.less';
39
40
  var useBreakpoint = _Grid.useBreakpoint;
40
41
 
@@ -61,10 +62,12 @@ var Step = function Step(_ref) {
61
62
  children = _ref.children,
62
63
  shouldRender = _ref.shouldRender,
63
64
  subscribedFields = _ref.subscribedFields,
64
- buttonText = _ref.buttonText;
65
+ buttonText = _ref.buttonText,
66
+ validationRule = _ref.validationRule;
65
67
 
66
68
  var _useContext = useContext(LocaleContext),
67
- formatMessage = _useContext.formatMessage;
69
+ formatMessage = _useContext.formatMessage,
70
+ currentLang = _useContext.currentLang;
68
71
 
69
72
  var _useContext2 = useContext(FormContext),
70
73
  continueText = _useContext2.continueText,
@@ -72,6 +75,7 @@ var Step = function Step(_ref) {
72
75
  submitting = _useContext2.submitting,
73
76
  form = _useContext2.form,
74
77
  showSubmitButton = _useContext2.showSubmitButton,
78
+ getRuleValidationApi = _useContext2.getRuleValidationApi,
75
79
  getScrollContainer = _useContext2.getScrollContainer,
76
80
  registerDependencies = _useContext2.registerDependencies;
77
81
 
@@ -89,6 +93,7 @@ var Step = function Step(_ref) {
89
93
  _ = _useReducer2[0],
90
94
  dispatch = _useReducer2[1];
91
95
 
96
+ invariant(!validationRule || getRuleValidationApi, 'Please provide getRuleValidationApi in Form props');
92
97
  useEffect(function () {
93
98
  if (shouldRender || getButtonDisabledState) {
94
99
  registerDependencies(Array.isArray(subscribedFields) ? subscribedFields : 'SUBSCRIBE_ALL', dispatch);
@@ -148,12 +153,13 @@ var Step = function Step(_ref) {
148
153
  var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
149
154
  var _allFields$filter;
150
155
 
151
- var allFields, fields, errors;
156
+ var allFields, allValues, fields, res, errors;
152
157
  return regeneratorRuntime.wrap(function _callee$(_context) {
153
158
  while (1) {
154
159
  switch (_context.prev = _context.next) {
155
160
  case 0:
156
161
  allFields = (form === null || form === void 0 ? void 0 : form.getFieldsError()) || [];
162
+ allValues = form === null || form === void 0 ? void 0 : form.getFieldsValue(true);
157
163
  fields = allFields === null || allFields === void 0 ? void 0 : (_allFields$filter = allFields.filter(function (_ref3) {
158
164
  var name = _ref3.name;
159
165
  return name.join().startsWith(pName === null || pName === void 0 ? void 0 : pName.join());
@@ -161,54 +167,85 @@ var Step = function Step(_ref) {
161
167
  var name = _ref4.name;
162
168
  return name;
163
169
  });
164
- _context.prev = 2;
165
- _context.next = 5;
170
+ _context.prev = 3;
171
+ _context.next = 6;
166
172
  return form === null || form === void 0 ? void 0 : form.validateFields(fields);
167
173
 
168
- case 5:
169
- _context.next = 11;
174
+ case 6:
175
+ _context.next = 12;
170
176
  break;
171
177
 
172
- case 7:
173
- _context.prev = 7;
174
- _context.t0 = _context["catch"](2);
178
+ case 8:
179
+ _context.prev = 8;
180
+ _context.t0 = _context["catch"](3);
175
181
  form === null || form === void 0 ? void 0 : form.scrollToField(_context.t0.errorFields[0].name);
176
182
  return _context.abrupt("return");
177
183
 
178
- case 11:
184
+ case 12:
185
+ if (!(validationRule && getRuleValidationApi)) {
186
+ _context.next = 26;
187
+ break;
188
+ }
189
+
190
+ _context.prev = 13;
191
+ _context.next = 16;
192
+ return getRuleValidation(getRuleValidationApi, validationRule, allValues, currentLang);
193
+
194
+ case 16:
195
+ res = _context.sent;
196
+
197
+ if (!(Array.isArray(res) && res.length)) {
198
+ _context.next = 21;
199
+ break;
200
+ }
201
+
202
+ form === null || form === void 0 ? void 0 : form.setFields(res);
203
+ form === null || form === void 0 ? void 0 : form.scrollToField(res[0].name);
204
+ return _context.abrupt("return");
205
+
206
+ case 21:
207
+ _context.next = 26;
208
+ break;
209
+
210
+ case 23:
211
+ _context.prev = 23;
212
+ _context.t1 = _context["catch"](13);
213
+ return _context.abrupt("return");
214
+
215
+ case 26:
179
216
  if (!(typeof handleNextProp === 'function')) {
180
- _context.next = 22;
217
+ _context.next = 37;
181
218
  break;
182
219
  }
183
220
 
184
- _context.prev = 12;
185
- _context.next = 15;
221
+ _context.prev = 27;
222
+ _context.next = 30;
186
223
  return handleNextProp(form === null || form === void 0 ? void 0 : form.getFieldsValue(fields));
187
224
 
188
- case 15:
225
+ case 30:
189
226
  errors = _context.sent;
190
227
 
191
228
  if (Array.isArray(errors)) {
192
229
  form === null || form === void 0 ? void 0 : form.setFields(errors);
193
230
  }
194
231
 
195
- _context.next = 22;
232
+ _context.next = 37;
196
233
  break;
197
234
 
198
- case 19:
199
- _context.prev = 19;
200
- _context.t1 = _context["catch"](12);
235
+ case 34:
236
+ _context.prev = 34;
237
+ _context.t2 = _context["catch"](27);
201
238
  return _context.abrupt("return");
202
239
 
203
- case 22:
240
+ case 37:
204
241
  handleNextStep && handleNextStep(fields);
205
242
 
206
- case 23:
243
+ case 38:
207
244
  case "end":
208
245
  return _context.stop();
209
246
  }
210
247
  }
211
- }, _callee, null, [[2, 7], [12, 19]]);
248
+ }, _callee, null, [[3, 8], [13, 23], [27, 34]]);
212
249
  }));
213
250
 
214
251
  return function handleNext() {
package/es/types.d.ts CHANGED
@@ -28,6 +28,8 @@ export interface FormBasicConfig {
28
28
  onFirstModified?: () => any;
29
29
  uploadApi?: string;
30
30
  selectDatasourceApi?: string;
31
+ validationRule?: string;
32
+ getRuleValidationApi?: string;
31
33
  stepDirection?: 'vertical' | 'horizontal';
32
34
  }
33
35
  export declare type FormItemAssert = {
@@ -120,6 +122,7 @@ export interface FormItemExtraConfig extends FormItemProps {
120
122
  minLength?: number;
121
123
  maxLength?: number;
122
124
  idType?: 'KTP' | 'NIK';
125
+ validationRule?: string;
123
126
  [key: string]: any;
124
127
  }
125
128
  export interface FormItemConfig extends FormItemExtraConfig {
@@ -73,3 +73,4 @@ export declare const calcSelectValue: (selectValue?: FormItemSelectValue[] | und
73
73
  disabled: boolean | undefined;
74
74
  };
75
75
  export declare const calcShouldRender: (dependencies?: NamePath[], asserts?: FormItemAssert[], shouldRender?: ((form?: FormInstance<any> | undefined) => boolean) | undefined, form?: FormInstance<any> | undefined) => boolean;
76
+ export declare const getRuleValidation: (url: string, rule: string | string[], values?: any, lang?: string | undefined) => Promise<any>;
@@ -1,6 +1,10 @@
1
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"],
2
2
  _excluded2 = ["initialValue", "normalize", "rules", "extra", "help", "getValueFromEvent", "span", "valuePropName", "fullRow", "halfRow", "messageVariables", "requiredMessage", "previewFormater", "valueFormater", "required", "requiredMark", "className"];
3
3
 
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); } }
5
+
6
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
7
+
4
8
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
5
9
 
6
10
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -510,4 +514,73 @@ export var calcShouldRender = function calcShouldRender() {
510
514
  }
511
515
 
512
516
  return true;
513
- };
517
+ };
518
+ export var getRuleValidation = /*#__PURE__*/function () {
519
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(url, rule, values, lang) {
520
+ var _lang, _lang$split;
521
+
522
+ var res, json, _ref4, conclusion, details;
523
+
524
+ return regeneratorRuntime.wrap(function _callee$(_context) {
525
+ while (1) {
526
+ switch (_context.prev = _context.next) {
527
+ case 0:
528
+ lang = ((_lang = lang) === null || _lang === void 0 ? void 0 : (_lang$split = _lang.split('-')) === null || _lang$split === void 0 ? void 0 : _lang$split[0]) || 'en';
529
+ _context.next = 3;
530
+ return fetch("".concat(url, "?lang=").concat(lang), {
531
+ method: 'post',
532
+ headers: {
533
+ 'Content-Type': 'application/json; charset=utf-8'
534
+ },
535
+ body: JSON.stringify({
536
+ form: values || {},
537
+ rules: Array.isArray(rule) ? rule : [rule]
538
+ })
539
+ });
540
+
541
+ case 3:
542
+ res = _context.sent;
543
+ _context.next = 6;
544
+ return res.json();
545
+
546
+ case 6:
547
+ json = _context.sent;
548
+ _ref4 = json || {}, conclusion = _ref4.conclusion, details = _ref4.details;
549
+
550
+ if (!conclusion) {
551
+ _context.next = 10;
552
+ break;
553
+ }
554
+
555
+ return _context.abrupt("return");
556
+
557
+ case 10:
558
+ if (!(conclusion === false)) {
559
+ _context.next = 12;
560
+ break;
561
+ }
562
+
563
+ return _context.abrupt("return", details === null || details === void 0 ? void 0 : details.map(function (_ref5) {
564
+ var err_message = _ref5.err_message,
565
+ path = _ref5.path;
566
+ return {
567
+ name: path.split('.'),
568
+ errors: [err_message]
569
+ };
570
+ }));
571
+
572
+ case 12:
573
+ return _context.abrupt("return", Promise.reject(json.message));
574
+
575
+ case 13:
576
+ case "end":
577
+ return _context.stop();
578
+ }
579
+ }
580
+ }, _callee);
581
+ }));
582
+
583
+ return function getRuleValidation(_x, _x2, _x3, _x4) {
584
+ return _ref3.apply(this, arguments);
585
+ };
586
+ }();
@@ -33,6 +33,8 @@ var _section = _interopRequireDefault(require("../section"));
33
33
 
34
34
  var _addableSection = _interopRequireDefault(require("../addable-section"));
35
35
 
36
+ var _typography = _interopRequireDefault(require("../../typography"));
37
+
36
38
  var _elements = _interopRequireDefault(require("../elements"));
37
39
 
38
40
  var _formContext = _interopRequireDefault(require("../../form-context"));
@@ -371,8 +373,21 @@ var Element = function Element(_ref) {
371
373
  sm: 24,
372
374
  xs: 24,
373
375
  className: "igloo-element-preview-value",
374
- children: [error && !!error.length && (0, _jsxRuntime.jsx)(_iglooicon.AlertFilled, {
375
- className: "igloo-element-preview-value-icon"
376
+ children: [error && !!error.length && (0, _jsxRuntime.jsxs)(_row.default, {
377
+ style: {
378
+ alignItems: 'center'
379
+ },
380
+ children: [(0, _jsxRuntime.jsx)(_col.default, {
381
+ children: (0, _jsxRuntime.jsx)(_iglooicon.AlertFilled, {
382
+ className: "igloo-element-preview-value-icon"
383
+ })
384
+ }), (0, _jsxRuntime.jsx)(_col.default, {
385
+ children: (0, _jsxRuntime.jsx)(_typography.default, {
386
+ level: "caption2",
387
+ className: "igloo-element-preview-value-errors",
388
+ children: error.join('\n')
389
+ })
390
+ })]
376
391
  }), (0, _jsxRuntime.jsx)("div", {
377
392
  children: renderPreviewValue()
378
393
  })]
@@ -25,6 +25,10 @@
25
25
  color: @error-color;
26
26
  margin-right: 8px;
27
27
  }
28
+
29
+ .igloo-element-preview-value-errors {
30
+ color: @error-color;
31
+ }
28
32
  }
29
33
  }
30
34
 
@@ -113,6 +117,10 @@
113
117
  color: @error-color;
114
118
  margin-right: 8px;
115
119
  }
120
+
121
+ .igloo-element-preview-value-errors {
122
+ color: @error-color;
123
+ }
116
124
  }
117
125
 
118
126
  .ant-form-item-explain-error {
@@ -124,10 +124,12 @@ var HSteps = function HSteps(_ref) {
124
124
  registerDependencies = _useContext.registerDependencies,
125
125
  submitText = _useContext.submitText,
126
126
  submitting = _useContext.submitting,
127
- showSubmitButton = _useContext.showSubmitButton;
127
+ showSubmitButton = _useContext.showSubmitButton,
128
+ getRuleValidationApi = _useContext.getRuleValidationApi;
128
129
 
129
130
  var _useContext2 = (0, _react.useContext)(_locale.LocaleContext),
130
- formatMessage = _useContext2.formatMessage;
131
+ formatMessage = _useContext2.formatMessage,
132
+ currentLang = _useContext2.currentLang;
131
133
 
132
134
  (0, _react.useEffect)(function () {
133
135
  var subscribe = elements.some(function (_ref2) {
@@ -146,6 +148,7 @@ var HSteps = function HSteps(_ref) {
146
148
  }, [currentStep]);
147
149
  var renderElements = elements.filter(function (step) {
148
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');
149
152
  return typeof step.shouldRender !== 'function' || step.shouldRender(form);
150
153
  });
151
154
 
@@ -153,14 +156,15 @@ var HSteps = function HSteps(_ref) {
153
156
  var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
154
157
  var _allFields$filter;
155
158
 
156
- var allFields, _renderElements$curre, currentName, handleNext, namePath, fields, _iterator, _step, collapseSection, errors;
159
+ var allFields, allValues, _renderElements$curre, currentName, handleNext, validationRule, namePath, fields, _iterator, _step, collapseSection, res, errors;
157
160
 
158
161
  return regeneratorRuntime.wrap(function _callee$(_context) {
159
162
  while (1) {
160
163
  switch (_context.prev = _context.next) {
161
164
  case 0:
162
165
  allFields = (form === null || form === void 0 ? void 0 : form.getFieldsError()) || [];
163
- _renderElements$curre = renderElements[current], currentName = _renderElements$curre.name, handleNext = _renderElements$curre.handleNext;
166
+ allValues = form === null || form === void 0 ? void 0 : form.getFieldsValue(true);
167
+ _renderElements$curre = renderElements[current], currentName = _renderElements$curre.name, handleNext = _renderElements$curre.handleNext, validationRule = _renderElements$curre.validationRule;
164
168
  namePath = (0, _formUtils.calcNamePath)(name, currentName);
165
169
  fields = allFields === null || allFields === void 0 ? void 0 : (_allFields$filter = allFields.filter(function (_ref4) {
166
170
  var name = _ref4.name;
@@ -169,17 +173,17 @@ var HSteps = function HSteps(_ref) {
169
173
  var name = _ref5.name;
170
174
  return name;
171
175
  });
172
- _context.prev = 4;
173
- _context.next = 7;
176
+ _context.prev = 5;
177
+ _context.next = 8;
174
178
  return form === null || form === void 0 ? void 0 : form.validateFields(fields);
175
179
 
176
- case 7:
177
- _context.next = 15;
180
+ case 8:
181
+ _context.next = 16;
178
182
  break;
179
183
 
180
- case 9:
181
- _context.prev = 9;
182
- _context.t0 = _context["catch"](4);
184
+ case 10:
185
+ _context.prev = 10;
186
+ _context.t0 = _context["catch"](5);
183
187
  form === null || form === void 0 ? void 0 : form.scrollToField(_context.t0.errorFields[0].name);
184
188
  _iterator = _createForOfIteratorHelper(sections.current.values());
185
189
 
@@ -196,46 +200,77 @@ var HSteps = function HSteps(_ref) {
196
200
 
197
201
  return _context.abrupt("return");
198
202
 
199
- case 15:
203
+ case 16:
204
+ if (!(validationRule && getRuleValidationApi)) {
205
+ _context.next = 30;
206
+ break;
207
+ }
208
+
209
+ _context.prev = 17;
210
+ _context.next = 20;
211
+ return (0, _formUtils.getRuleValidation)(getRuleValidationApi, validationRule, allValues, currentLang);
212
+
213
+ case 20:
214
+ res = _context.sent;
215
+
216
+ if (!(Array.isArray(res) && res.length)) {
217
+ _context.next = 25;
218
+ break;
219
+ }
220
+
221
+ form === null || form === void 0 ? void 0 : form.setFields(res);
222
+ form === null || form === void 0 ? void 0 : form.scrollToField(res[0].name);
223
+ return _context.abrupt("return");
224
+
225
+ case 25:
226
+ _context.next = 30;
227
+ break;
228
+
229
+ case 27:
230
+ _context.prev = 27;
231
+ _context.t1 = _context["catch"](17);
232
+ return _context.abrupt("return");
233
+
234
+ case 30:
200
235
  if (!(typeof handleNext === 'function')) {
201
- _context.next = 27;
236
+ _context.next = 42;
202
237
  break;
203
238
  }
204
239
 
205
- _context.prev = 16;
206
- _context.next = 19;
240
+ _context.prev = 31;
241
+ _context.next = 34;
207
242
  return handleNext(form === null || form === void 0 ? void 0 : form.getFieldsValue(fields));
208
243
 
209
- case 19:
244
+ case 34:
210
245
  errors = _context.sent;
211
246
 
212
247
  if (!Array.isArray(errors)) {
213
- _context.next = 22;
248
+ _context.next = 37;
214
249
  break;
215
250
  }
216
251
 
217
252
  return _context.abrupt("return", form === null || form === void 0 ? void 0 : form.setFields(errors));
218
253
 
219
- case 22:
220
- _context.next = 27;
254
+ case 37:
255
+ _context.next = 42;
221
256
  break;
222
257
 
223
- case 24:
224
- _context.prev = 24;
225
- _context.t1 = _context["catch"](16);
258
+ case 39:
259
+ _context.prev = 39;
260
+ _context.t2 = _context["catch"](31);
226
261
  return _context.abrupt("return");
227
262
 
228
- case 27:
263
+ case 42:
229
264
  setCurrent(last || current + 1);
230
265
  setLast(0);
231
266
  setShouldScroll(true);
232
267
 
233
- case 30:
268
+ case 45:
234
269
  case "end":
235
270
  return _context.stop();
236
271
  }
237
272
  }
238
- }, _callee, null, [[4, 9], [16, 24]]);
273
+ }, _callee, null, [[5, 10], [17, 27], [31, 39]]);
239
274
  }));
240
275
 
241
276
  return function handleNext() {