@inseefr/lunatic 0.4.3-v2 → 0.4.4-v2

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.
Files changed (47) hide show
  1. package/lib/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.js +6 -3
  2. package/lib/components/checkbox/checkbox-group/lunatic-checkbox-group.js +6 -3
  3. package/lib/components/checkbox/checkbox-one/lunatic-checkbox-one.js +15 -2
  4. package/lib/components/commons/components/errors/errors.js +35 -0
  5. package/lib/components/commons/components/errors/errors.scss +5 -0
  6. package/lib/components/commons/components/errors/index.js +15 -0
  7. package/lib/components/commons/index.js +8 -0
  8. package/lib/components/datepicker/lunatic-datepicker.js +16 -1
  9. package/lib/components/dropdown/lunatic-dropdown.js +6 -3
  10. package/lib/components/input/lunatic-input.js +20 -4
  11. package/lib/components/input-number/lunatic-input-number.js +17 -2
  12. package/lib/components/loop/block-for-loop/block-for-loop.js +6 -1
  13. package/lib/components/loop/loop.js +6 -3
  14. package/lib/components/loop/roster-for-loop/roster-for-loop.js +7 -2
  15. package/lib/components/modal-controls/close-or-skip.js +13 -3
  16. package/lib/components/modal-controls/modal-controls.js +1 -2
  17. package/lib/components/modal-controls/modal-controls.scss +1 -1
  18. package/lib/components/pairwise/links/pairwise-links.js +6 -1
  19. package/lib/components/radio/lunatic-radio-group.js +6 -3
  20. package/lib/components/suggester/lunatic-suggester.js +6 -3
  21. package/lib/components/table/lunatic-table.js +5 -2
  22. package/lib/components/textarea/lunatic-textarea.js +22 -6
  23. package/lib/stories/paste-questionnaire/test.stories.js +1 -1
  24. package/lib/stories/questionnaires-test/controls/V2_ControlesNonNum_horsBoucle_PasPageFin.json +489 -451
  25. package/lib/stories/questionnaires-test/controls/V2_ControlesNum_horsBoucle_PasPageFin.json +1956 -1688
  26. package/lib/stories/questionnaires-test/controls/V2_Controles_BouclesLiees_PasPageFin.json +3 -3
  27. package/lib/stories/questionnaires-test/controls/controls.stories.js +4 -4
  28. package/lib/stories/utils/default-arg-types.js +1 -1
  29. package/lib/stories/utils/orchestrator.js +18 -10
  30. package/lib/use-lunatic/actions.js +2 -2
  31. package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.js +1 -0
  32. package/lib/use-lunatic/commons/index.js +14 -2
  33. package/lib/use-lunatic/commons/page-tag.js +83 -0
  34. package/lib/use-lunatic/initial-state.js +3 -1
  35. package/lib/use-lunatic/reducer/reduce-go-next-page.js +53 -37
  36. package/lib/use-lunatic/reducer/reduce-go-previous-page.js +25 -24
  37. package/lib/use-lunatic/reducer/reduce-go-to-page.js +12 -4
  38. package/lib/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.js +4 -1
  39. package/lib/use-lunatic/reducer/reduce-on-init.js +2 -2
  40. package/lib/use-lunatic/reducer/validate-controls/create-controls-reducer.js +59 -0
  41. package/lib/use-lunatic/reducer/validate-controls/create-modal-controls-reducer.js +88 -0
  42. package/lib/use-lunatic/reducer/validate-controls/index.js +11 -3
  43. package/lib/use-lunatic/reducer/validate-controls/validation-utils.js +71 -0
  44. package/lib/use-lunatic/use-lunatic.js +15 -5
  45. package/package.json +1 -1
  46. package/lib/use-lunatic/commons/get-page-tag.js +0 -21
  47. package/lib/use-lunatic/reducer/validate-controls/create-validate-reducer.js +0 -146
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _validationUtils = require("./validation-utils");
9
+
10
+ var _commons = require("../../commons");
11
+
12
+ 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; }
13
+
14
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15
+
16
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
+
18
+ function validateComponents(state, components) {
19
+ var pager = state.pager; // TODO check components in components (Loop, etc...)
20
+
21
+ return components.reduce(function (errors, component) {
22
+ var controls = component.controls;
23
+
24
+ if (Array.isArray(controls)) {
25
+ var componentErrors = (0, _validationUtils.resolveComponentControls)(state, controls);
26
+
27
+ if (componentErrors.length) {
28
+ return _objectSpread(_objectSpread({}, errors), {}, _defineProperty({}, (0, _commons.getPageTag)(pager), componentErrors));
29
+ }
30
+ } // If no error we remove the possible previous errors
31
+
32
+
33
+ return _objectSpread(_objectSpread({}, errors), {}, _defineProperty({}, (0, _commons.getPageTag)(pager), []));
34
+ }, {});
35
+ }
36
+
37
+ function createControlsReducer(reducer) {
38
+ // Nothing to init
39
+ return function (state, action) {
40
+ var activeControls = state.activeControls;
41
+ var updatedState = reducer(state, action);
42
+ if (!activeControls || state.pager.lastReachedPage !== updatedState.pager.lastReachedPage) //if no active controls or is the first time we reach the page
43
+ return _objectSpread(_objectSpread({}, updatedState), {}, {
44
+ currentErrors: undefined
45
+ });
46
+ var components = (0, _commons.getComponentsFromState)(updatedState);
47
+
48
+ var errors = _objectSpread(_objectSpread({}, state.errors), validateComponents(updatedState, components));
49
+
50
+ var pager = updatedState.pager;
51
+ return _objectSpread(_objectSpread({}, updatedState), {}, {
52
+ errors: errors,
53
+ currentErrors: errors[(0, _commons.getPageTag)(pager)]
54
+ });
55
+ };
56
+ }
57
+
58
+ var _default = createControlsReducer;
59
+ exports["default"] = _default;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ exports.isErrors = isErrors;
8
+
9
+ var _validationUtils = require("./validation-utils");
10
+
11
+ var _commons = require("../../commons");
12
+
13
+ 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; }
14
+
15
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
+
17
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+
19
+ function validateComponentsForModal(state, components) {
20
+ var pager = state.pager; // TODO check components in components (Loop, etc...)
21
+
22
+ return components.reduce(function (errors, component) {
23
+ var controls = component.controls;
24
+
25
+ if (Array.isArray(controls)) {
26
+ var componentErrors = (0, _validationUtils.resolveComponentControls)(state, controls);
27
+
28
+ if (componentErrors.length) {
29
+ return _objectSpread(_objectSpread({}, errors), {}, _defineProperty({}, (0, _commons.getPageTag)(pager), componentErrors));
30
+ }
31
+ }
32
+
33
+ return errors;
34
+ }, {});
35
+ }
36
+
37
+ function isErrors(errors) {
38
+ if (errors) {
39
+ return Object.keys(errors).length > 0;
40
+ }
41
+
42
+ return false;
43
+ }
44
+
45
+ function createModalControlsReducer(reducer) {
46
+ // Nothing to init
47
+ return function (state, action) {
48
+ var payload = action.payload;
49
+ var activeControls = state.activeControls,
50
+ errors = state.errors;
51
+ var block = payload.block;
52
+ if (!activeControls) return reducer(_objectSpread(_objectSpread({}, state), {}, {
53
+ modalErrors: undefined
54
+ }), action);
55
+ var components = (0, _commons.getComponentsFromState)(state);
56
+ var prec = state.modalErrors;
57
+
58
+ if (block) {
59
+ // Block the modal and stay in page so we add the error in the current page
60
+ return _objectSpread(_objectSpread({}, state), {}, {
61
+ modalErrors: undefined,
62
+ currentErrors: prec[(0, _commons.getPageTag)(state.pager)]
63
+ });
64
+ }
65
+
66
+ if (prec) {
67
+ return reducer(_objectSpread(_objectSpread({}, state), {}, {
68
+ modalErrors: undefined
69
+ }), action);
70
+ }
71
+
72
+ var modalErrors = validateComponentsForModal(state, components);
73
+
74
+ if (isErrors(modalErrors)) {
75
+ return _objectSpread(_objectSpread({}, state), {}, {
76
+ modalErrors: modalErrors,
77
+ errors: _objectSpread(_objectSpread({}, errors), modalErrors)
78
+ });
79
+ }
80
+
81
+ return reducer(_objectSpread(_objectSpread({}, state), {}, {
82
+ modalErrors: undefined
83
+ }), action);
84
+ };
85
+ }
86
+
87
+ var _default = createModalControlsReducer;
88
+ exports["default"] = _default;
@@ -3,13 +3,21 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "createValidateReducer", {
6
+ Object.defineProperty(exports, "createControlsReducer", {
7
7
  enumerable: true,
8
8
  get: function get() {
9
- return _createValidateReducer["default"];
9
+ return _createControlsReducer["default"];
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "createModalControlsReducer", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _createModalControlsReducer["default"];
16
+ }
17
+ });
18
+
19
+ var _createControlsReducer = _interopRequireDefault(require("./create-controls-reducer"));
12
20
 
13
- var _createValidateReducer = _interopRequireDefault(require("./create-validate-reducer"));
21
+ var _createModalControlsReducer = _interopRequireDefault(require("./create-modal-controls-reducer"));
14
22
 
15
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveComponentControls = resolveComponentControls;
7
+
8
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
+
10
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+
12
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
+
14
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
+
16
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
17
+
18
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
19
+
20
+ function resolveControl(state, control) {
21
+ var executeExpression = state.executeExpression,
22
+ _state$pager = state.pager,
23
+ pager = _state$pager === void 0 ? {} : _state$pager;
24
+ var iteration = pager.iteration;
25
+ var criticality = control.criticality,
26
+ errorMessage = control.errorMessage,
27
+ id = control.id,
28
+ blocking = control.blocking;
29
+ var _control$control = control.control;
30
+ _control$control = _control$control === void 0 ? {} : _control$control;
31
+ var _control$control$valu = _control$control.value,
32
+ value = _control$control$valu === void 0 ? 'true' : _control$control$valu;
33
+
34
+ try {
35
+ var result = executeExpression(value, {
36
+ iteration: iteration
37
+ });
38
+
39
+ if (!result) {
40
+ var labelValue = errorMessage.value;
41
+ var label = executeExpression(labelValue, {
42
+ iteration: iteration
43
+ });
44
+ return {
45
+ criticality: criticality,
46
+ errorMessage: label,
47
+ id: id,
48
+ blocking: blocking,
49
+ formula: value,
50
+ labelFormula: labelValue
51
+ };
52
+ }
53
+
54
+ return undefined;
55
+ } catch (e) {
56
+ console.log("Error on validating control ".concat(value));
57
+ return undefined;
58
+ }
59
+ }
60
+
61
+ function resolveComponentControls(state, controls) {
62
+ return controls.reduce(function (errors, control) {
63
+ var error = resolveControl(state, control);
64
+
65
+ if (error) {
66
+ return [].concat(_toConsumableArray(errors), [error]);
67
+ }
68
+
69
+ return errors;
70
+ }, []);
71
+ }
@@ -79,8 +79,8 @@ function useLunatic(source) {
79
79
  autoSuggesterLoading = _ref$autoSuggesterLoa === void 0 ? false : _ref$autoSuggesterLoa,
80
80
  suggestersConfiguration = _ref.suggesters,
81
81
  suggesterFetcher = _ref.suggesterFetcher,
82
- _ref$modalForControls = _ref.modalForControls,
83
- modalForControls = _ref$modalForControls === void 0 ? false : _ref$modalForControls;
82
+ _ref$activeControls = _ref.activeControls,
83
+ activeControls = _ref$activeControls === void 0 ? false : _ref$activeControls;
84
84
 
85
85
  var _useReducer = (0, _react.useReducer)(_reducer["default"], _initialState["default"]),
86
86
  _useReducer2 = _slicedToArray(_useReducer, 2),
@@ -89,7 +89,9 @@ function useLunatic(source) {
89
89
 
90
90
  var pager = state.pager,
91
91
  waiting = state.waiting,
92
- errors = state.errors;
92
+ modalErrors = state.modalErrors,
93
+ errors = state.errors,
94
+ currentErrors = state.currentErrors;
93
95
  var components = (0, _commons.useComponentsFromState)(state);
94
96
  var suggesters = source.suggesters;
95
97
  (0, _react.useEffect)(function () {
@@ -139,6 +141,12 @@ function useLunatic(source) {
139
141
  var getErrors = (0, _react.useCallback)(function () {
140
142
  return errors;
141
143
  }, [errors]);
144
+ var getModalErrors = (0, _react.useCallback)(function () {
145
+ return modalErrors;
146
+ }, [modalErrors]);
147
+ var getCurrentErrors = (0, _react.useCallback)(function () {
148
+ return currentErrors;
149
+ }, [currentErrors]);
142
150
  var goPreviousPage = (0, _react.useCallback)(function () {
143
151
  dispatch(actions.goPreviousPage());
144
152
  }, [dispatch]);
@@ -183,15 +191,17 @@ function useLunatic(source) {
183
191
  savingType: savingType,
184
192
  management: management,
185
193
  handleChange: handleChange,
186
- modalForControls: modalForControls
194
+ activeControls: activeControls
187
195
  }));
188
- }, [source, data, initialPage, features, preferences, savingType, management, handleChange, modalForControls]);
196
+ }, [source, data, initialPage, features, preferences, savingType, management, handleChange, activeControls]);
189
197
  return {
190
198
  getComponents: getComponents,
191
199
  goPreviousPage: goPreviousPage,
192
200
  goNextPage: goNextPage,
193
201
  goToPage: goToPage,
194
202
  getErrors: getErrors,
203
+ getModalErrors: getModalErrors,
204
+ getCurrentErrors: getCurrentErrors,
195
205
  pageTag: pageTag,
196
206
  isFirstPage: isFirstPage,
197
207
  isLastPage: isLastPage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inseefr/lunatic",
3
- "version": "0.4.3-v2",
3
+ "version": "0.4.4-v2",
4
4
  "workersVersion": "0.2.4-experimental",
5
5
  "description": "Library of questionnaire components",
6
6
  "repository": {
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- function getPageTag(pager) {
9
- var page = pager.page,
10
- subPage = pager.subPage,
11
- iteration = pager.iteration;
12
-
13
- if (subPage !== undefined && iteration !== undefined) {
14
- return "".concat(page, ".").concat(subPage + 1, "#").concat(iteration + 1);
15
- }
16
-
17
- return "".concat(page);
18
- }
19
-
20
- var _default = getPageTag;
21
- exports["default"] = _default;
@@ -1,146 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _commons = require("../../commons");
9
-
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; }
11
-
12
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
13
-
14
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
-
16
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
17
-
18
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
-
20
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
-
22
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
23
-
24
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
25
-
26
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
27
-
28
- // export const CRITICALITY = {
29
- // INFO: 'INFO',
30
- // WARN: 'WARN',
31
- // };
32
- function resolveControl(state, control) {
33
- var executeExpression = state.executeExpression,
34
- _state$pager = state.pager,
35
- pager = _state$pager === void 0 ? {} : _state$pager;
36
- var iteration = pager.iteration;
37
- var criticality = control.criticality,
38
- errorMessage = control.errorMessage,
39
- id = control.id;
40
- var _control$control = control.control;
41
- _control$control = _control$control === void 0 ? {} : _control$control;
42
- var _control$control$valu = _control$control.value,
43
- value = _control$control$valu === void 0 ? 'true' : _control$control$valu;
44
-
45
- try {
46
- var result = executeExpression(value, {
47
- iteration: iteration
48
- });
49
-
50
- if (!result) {
51
- return {
52
- criticality: criticality,
53
- errorMessage: errorMessage,
54
- id: id
55
- };
56
- }
57
-
58
- return undefined;
59
- } catch (e) {
60
- console.log("Error on validating control ".concat(value));
61
- return undefined;
62
- }
63
- }
64
-
65
- function resolveComponentControls(state, controls) {
66
- return controls.reduce(function (errors, control) {
67
- var error = resolveControl(state, control);
68
-
69
- if (error) {
70
- return [].concat(_toConsumableArray(errors), [error]);
71
- }
72
-
73
- return errors;
74
- }, []);
75
- }
76
-
77
- function validateComponents(state, components) {
78
- // TODO check components in components (Loop, etc...)
79
- return components.reduce(function (errors, component) {
80
- var controls = component.controls,
81
- id = component.id;
82
-
83
- if (Array.isArray(controls)) {
84
- var componentErrors = resolveComponentControls(state, controls);
85
-
86
- if (componentErrors.length) {
87
- return _objectSpread(_objectSpread({}, errors), {}, _defineProperty({}, id, componentErrors));
88
- }
89
- }
90
-
91
- return errors;
92
- }, {});
93
- } // function isBlockingErrors(errors) {
94
- // // TODO find criticality WARN
95
- // return false;
96
- // }
97
-
98
-
99
- function isErrors(errors) {
100
- if (errors) {
101
- return Object.keys(errors).length > 0;
102
- }
103
-
104
- return false;
105
- }
106
-
107
- function createValidateReducer(reducer) {
108
- // Nothing to init
109
- return function (state, action) {
110
- var payload = action.payload;
111
- var modalForControls = state.modalForControls;
112
- var block = payload.block;
113
- if (!modalForControls) return reducer(_objectSpread(_objectSpread({}, state), {}, {
114
- errors: undefined
115
- }), action);
116
- var components = (0, _commons.getComponentsFromState)(state);
117
- var prec = state.errors;
118
-
119
- if (block) {
120
- return _objectSpread(_objectSpread({}, state), {}, {
121
- errors: undefined
122
- });
123
- }
124
-
125
- if (prec) {
126
- return reducer(_objectSpread(_objectSpread({}, state), {}, {
127
- errors: undefined
128
- }), action);
129
- }
130
-
131
- var errors = validateComponents(state, components);
132
-
133
- if (isErrors(errors)) {
134
- return _objectSpread(_objectSpread({}, state), {}, {
135
- errors: errors
136
- });
137
- }
138
-
139
- return reducer(_objectSpread(_objectSpread({}, state), {}, {
140
- errors: undefined
141
- }), action);
142
- };
143
- }
144
-
145
- var _default = createValidateReducer;
146
- exports["default"] = _default;