@ukhomeoffice/cop-react-form-renderer 4.82.1 → 4.84.0
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.
|
@@ -41,10 +41,10 @@ var DEFAULT_HOOKS = {
|
|
|
41
41
|
onSubmit: function onSubmit(type, payload, onSuccess, onError) {
|
|
42
42
|
if (typeof onSuccess === 'function') onSuccess();
|
|
43
43
|
},
|
|
44
|
-
onValidate: function onValidate(page) {
|
|
45
|
-
return
|
|
44
|
+
onValidate: function onValidate(page, errors) {
|
|
45
|
+
return errors;
|
|
46
46
|
},
|
|
47
|
-
//
|
|
47
|
+
// Returns the list of errors already found in FR by default.
|
|
48
48
|
onCancel: function onCancel() {} // Consuming application must provide function to action, else this does nothing.
|
|
49
49
|
};
|
|
50
50
|
|
|
@@ -70,8 +70,7 @@ var ValidationContextProvider = function ValidationContextProvider(_ref) {
|
|
|
70
70
|
var validate = {
|
|
71
71
|
page: function page(_page) {
|
|
72
72
|
var pageErrors = _utils.default.Validate.page(_page);
|
|
73
|
-
var
|
|
74
|
-
var allErrors = Array.isArray(hookPageErrors) ? pageErrors.concat(hookPageErrors) : pageErrors;
|
|
73
|
+
var allErrors = hooks.onValidate(_page, pageErrors);
|
|
75
74
|
setErrors(allErrors);
|
|
76
75
|
return allErrors;
|
|
77
76
|
},
|
|
@@ -79,10 +78,9 @@ var ValidationContextProvider = function ValidationContextProvider(_ref) {
|
|
|
79
78
|
var pagesErrors = _pages.flatMap(function (page) {
|
|
80
79
|
return _utils.default.Validate.page(page);
|
|
81
80
|
});
|
|
82
|
-
var
|
|
83
|
-
return hooks.onValidate(page);
|
|
81
|
+
var allErrors = _pages.flatMap(function (page) {
|
|
82
|
+
return hooks.onValidate(page, pagesErrors);
|
|
84
83
|
});
|
|
85
|
-
var allErrors = Array.isArray(hookPagesErrors) ? pagesErrors.concat(hookPagesErrors) : pagesErrors;
|
|
86
84
|
setErrors(allErrors);
|
|
87
85
|
return allErrors;
|
|
88
86
|
}
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,12 @@ Object.defineProperty(exports, "FormTypes", {
|
|
|
28
28
|
return _models.FormTypes;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
+
Object.defineProperty(exports, "HooksContextProvider", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function get() {
|
|
34
|
+
return _context.HooksContextProvider;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
31
37
|
Object.defineProperty(exports, "HubFormats", {
|
|
32
38
|
enumerable: true,
|
|
33
39
|
get: function get() {
|
|
@@ -10,7 +10,7 @@ var _models = require("../../models");
|
|
|
10
10
|
var EDITABLE_TYPES = [_models.ComponentTypes.AUTOCOMPLETE, _models.ComponentTypes.CALCULATION, _models.ComponentTypes.CHECKBOXES, _models.ComponentTypes.DATE, _models.ComponentTypes.EMAIL, _models.ComponentTypes.FILE, _models.ComponentTypes.MULTI_FILE, _models.ComponentTypes.PHONE_NUMBER, _models.ComponentTypes.RADIOS, _models.ComponentTypes.SELECT, _models.ComponentTypes.TEXT, _models.ComponentTypes.TEXT_AREA, _models.ComponentTypes.TIME];
|
|
11
11
|
exports.EDITABLE_TYPES = EDITABLE_TYPES;
|
|
12
12
|
var isEditable = function isEditable(options) {
|
|
13
|
-
return EDITABLE_TYPES.includes(options === null || options === void 0 ? void 0 : options.type);
|
|
13
|
+
return EDITABLE_TYPES.includes(options === null || options === void 0 ? void 0 : options.type) || (options === null || options === void 0 ? void 0 : options.isEditable) || false;
|
|
14
14
|
};
|
|
15
15
|
var _default = isEditable;
|
|
16
16
|
exports.default = _default;
|
|
@@ -33,6 +33,11 @@ describe('utils', function () {
|
|
|
33
33
|
type: 'hidden'
|
|
34
34
|
})).toEqual(false);
|
|
35
35
|
});
|
|
36
|
+
it("should return true if options has 'isEditable' set to true", function () {
|
|
37
|
+
expect((0, _isEditable.default)({
|
|
38
|
+
isEditable: true
|
|
39
|
+
})).toEqual(true);
|
|
40
|
+
});
|
|
36
41
|
});
|
|
37
42
|
});
|
|
38
43
|
});
|