@ukhomeoffice/cop-react-form-renderer 5.13.0 → 5.13.2
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.
- package/dist/components/CollectionPage/CollectionPage.test.js +1 -1
- package/dist/components/FormComponent/Collection.test.js +10 -10
- package/dist/components/FormComponent/Container.js +3 -3
- package/dist/components/FormComponent/Container.test.js +3 -3
- package/dist/components/FormComponent/FormComponent.test.js +3 -3
- package/dist/components/FormPage/FormPage.test.js +1 -1
- package/dist/components/FormRenderer/FormRenderer.test.js +5 -1
- package/dist/components/FormRenderer/onCYAAction.js +5 -1
- package/dist/components/FormRenderer/onCYAAction.test.js +8 -5
- package/dist/components/FormRenderer/onPageAction.js +8 -5
- package/dist/components/FormRenderer/onPageAction.test.js +6 -5
- package/dist/components/SummaryList/SummaryList.js +1 -2
- package/dist/components/TaskList/TaskList.js +3 -3
- package/dist/context/HooksContext/HooksContext.js +1 -1
- package/dist/models/EventTypes.js +3 -1
- package/dist/utils/CheckYourAnswers/showComponentCYA.js +1 -0
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +6 -6
- package/package.json +2 -2
|
@@ -150,7 +150,7 @@ describe('components.CollectionPage', function () {
|
|
|
150
150
|
expect(input.tagName).toEqual('INPUT');
|
|
151
151
|
expect(input.classList).toContain('govuk-input');
|
|
152
152
|
expect(input.id).toEqual(fieldId);
|
|
153
|
-
expect(input.
|
|
153
|
+
expect(input.value).toEqual(val);
|
|
154
154
|
return input;
|
|
155
155
|
};
|
|
156
156
|
var checkAutoCompleteField = function checkAutoCompleteField(formGroup, fieldId, lbl, hnt, val) {
|
|
@@ -84,7 +84,7 @@ describe('components.FormComponent.Collection', function () {
|
|
|
84
84
|
expect(input.tagName).toEqual('INPUT');
|
|
85
85
|
expect(input.classList).toContain('govuk-input');
|
|
86
86
|
expect(input.id).toEqual("".concat(ID, "[0].").concat(TEXT_ID));
|
|
87
|
-
expect(input.
|
|
87
|
+
expect(input.value).toEqual(TEXT_VALUE);
|
|
88
88
|
case 30:
|
|
89
89
|
case "end":
|
|
90
90
|
return _context.stop();
|
|
@@ -392,7 +392,7 @@ describe('components.FormComponent.Collection', function () {
|
|
|
392
392
|
input = formGroup.childNodes[2];
|
|
393
393
|
expect(input.tagName).toEqual('DIV'); // Now readonly, so a DIV.
|
|
394
394
|
expect(input.classList).toContain('hods-readonly'); // Now readonly, so hods-readonly
|
|
395
|
-
expect(input.
|
|
395
|
+
expect(input.id).toEqual("".concat(ID, "[0].").concat(TEXT_ID));
|
|
396
396
|
expect(input.textContent).toEqual(TEXT_VALUE);
|
|
397
397
|
case 30:
|
|
398
398
|
case "end":
|
|
@@ -518,7 +518,7 @@ describe('components.FormComponent.Collection', function () {
|
|
|
518
518
|
expect(input.tagName).toEqual('INPUT');
|
|
519
519
|
expect(input.classList).toContain('govuk-input');
|
|
520
520
|
expect(input.id).toEqual("".concat(ID, "[0].").concat(TEXT_ID));
|
|
521
|
-
expect(input.
|
|
521
|
+
expect(input.value).toEqual(TEXT_VALUE);
|
|
522
522
|
|
|
523
523
|
// First item component 2
|
|
524
524
|
formGroup = itemContainer.childNodes[1];
|
|
@@ -537,7 +537,7 @@ describe('components.FormComponent.Collection', function () {
|
|
|
537
537
|
expect(input.tagName).toEqual('INPUT');
|
|
538
538
|
expect(input.classList).toContain('govuk-input');
|
|
539
539
|
expect(input.id).toEqual("".concat(ID, "[0].textTwo"));
|
|
540
|
-
expect(input.
|
|
540
|
+
expect(input.value).toEqual('charlie');
|
|
541
541
|
|
|
542
542
|
// Check the second item and confirm there is no hint
|
|
543
543
|
itemTwo = c.childNodes[1];
|
|
@@ -564,7 +564,7 @@ describe('components.FormComponent.Collection', function () {
|
|
|
564
564
|
expect(inputTwo.tagName).toEqual('INPUT');
|
|
565
565
|
expect(inputTwo.classList).toContain('govuk-input');
|
|
566
566
|
expect(inputTwo.id).toEqual("".concat(ID, "[1].").concat(TEXT_ID));
|
|
567
|
-
expect(inputTwo.
|
|
567
|
+
expect(inputTwo.value).toEqual('beta');
|
|
568
568
|
|
|
569
569
|
// Second item second component
|
|
570
570
|
formGroupTwo = itemContainerTwo.childNodes[1];
|
|
@@ -581,7 +581,7 @@ describe('components.FormComponent.Collection', function () {
|
|
|
581
581
|
expect(inputTwo.tagName).toEqual('INPUT');
|
|
582
582
|
expect(inputTwo.classList).toContain('govuk-input');
|
|
583
583
|
expect(inputTwo.id).toEqual("".concat(ID, "[1].textTwo"));
|
|
584
|
-
expect(inputTwo.
|
|
584
|
+
expect(inputTwo.value).toEqual('delta');
|
|
585
585
|
case 87:
|
|
586
586
|
case "end":
|
|
587
587
|
return _context11.stop();
|
|
@@ -658,7 +658,7 @@ describe('components.FormComponent.Collection', function () {
|
|
|
658
658
|
expect(input.tagName).toEqual('INPUT');
|
|
659
659
|
expect(input.classList).toContain('govuk-input');
|
|
660
660
|
expect(input.id).toEqual("".concat(ID, "[0].").concat(TEXT_ID));
|
|
661
|
-
expect(input.
|
|
661
|
+
expect(input.value).toEqual(TEXT_VALUE);
|
|
662
662
|
|
|
663
663
|
// First item component 2
|
|
664
664
|
formGroup = itemContainer.childNodes[1];
|
|
@@ -677,7 +677,7 @@ describe('components.FormComponent.Collection', function () {
|
|
|
677
677
|
expect(input.tagName).toEqual('INPUT');
|
|
678
678
|
expect(input.classList).toContain('govuk-input');
|
|
679
679
|
expect(input.id).toEqual("".concat(ID, "[0].textTwo"));
|
|
680
|
-
expect(input.
|
|
680
|
+
expect(input.value).toEqual('charlie');
|
|
681
681
|
|
|
682
682
|
// Check the second item and confirm there is no hint
|
|
683
683
|
itemTwo = c.childNodes[1];
|
|
@@ -704,7 +704,7 @@ describe('components.FormComponent.Collection', function () {
|
|
|
704
704
|
expect(inputTwo.tagName).toEqual('INPUT');
|
|
705
705
|
expect(inputTwo.classList).toContain('govuk-input');
|
|
706
706
|
expect(inputTwo.id).toEqual("".concat(ID, "[1].").concat(TEXT_ID));
|
|
707
|
-
expect(inputTwo.
|
|
707
|
+
expect(inputTwo.value).toEqual('beta');
|
|
708
708
|
|
|
709
709
|
// Second item second component
|
|
710
710
|
formGroupTwo = itemContainerTwo.childNodes[1];
|
|
@@ -721,7 +721,7 @@ describe('components.FormComponent.Collection', function () {
|
|
|
721
721
|
expect(inputTwo.tagName).toEqual('INPUT');
|
|
722
722
|
expect(inputTwo.classList).toContain('govuk-input');
|
|
723
723
|
expect(inputTwo.id).toEqual("".concat(ID, "[1].textTwo"));
|
|
724
|
-
expect(inputTwo.
|
|
724
|
+
expect(inputTwo.value).toEqual('delta');
|
|
725
725
|
case 89:
|
|
726
726
|
case "end":
|
|
727
727
|
return _context12.stop();
|
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.DEFAULT_CLASS = void 0;
|
|
8
|
-
var _Utils = require("@ukhomeoffice/cop-react-components/dist/utils/Utils");
|
|
9
8
|
var _react = _interopRequireDefault(require("react"));
|
|
10
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
10
|
var _models = require("../../models");
|
|
12
11
|
var _utils = _interopRequireDefault(require("../../utils"));
|
|
12
|
+
var _cleanAttributes = _interopRequireDefault(require("../../utils/Component/cleanAttributes"));
|
|
13
13
|
var _FormComponent = _interopRequireDefault(require("./FormComponent"));
|
|
14
14
|
var _excluded = ["container", "value", "formData", "onChange", "wrap", "onTopLevelChange"];
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -61,8 +61,8 @@ var Container = function Container(_ref) {
|
|
|
61
61
|
}), formData);
|
|
62
62
|
};
|
|
63
63
|
var classes = _utils.default.classBuilder(DEFAULT_CLASS, [], container.className);
|
|
64
|
-
var
|
|
65
|
-
return /*#__PURE__*/_react.default.createElement("div", _extends({},
|
|
64
|
+
var htmlAttrs = (0, _cleanAttributes.default)(attrs);
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement("div", _extends({}, htmlAttrs, {
|
|
66
66
|
className: classes(),
|
|
67
67
|
id: container.id
|
|
68
68
|
}), container.components && container.components.filter(shouldShow).map(function (component, index) {
|
|
@@ -76,7 +76,7 @@ describe('components.FormComponent.Container', function () {
|
|
|
76
76
|
expect(input.tagName).toEqual('INPUT');
|
|
77
77
|
expect(input.classList).toContain('govuk-input');
|
|
78
78
|
expect(input.id).toEqual("".concat(ID, ".").concat(TEXT_ID));
|
|
79
|
-
expect(input.
|
|
79
|
+
expect(input.value).toEqual(TEXT_VALUE);
|
|
80
80
|
case 22:
|
|
81
81
|
case "end":
|
|
82
82
|
return _context.stop();
|
|
@@ -130,7 +130,7 @@ describe('components.FormComponent.Container', function () {
|
|
|
130
130
|
expect(input.tagName).toEqual('INPUT');
|
|
131
131
|
expect(input.classList).toContain('govuk-input');
|
|
132
132
|
expect(input.id).toEqual("".concat(ID, ".").concat(NESTED_ID, ".").concat(TEXT_ID));
|
|
133
|
-
expect(input.
|
|
133
|
+
expect(input.value).toEqual(NESTED_TEXT_VALUE);
|
|
134
134
|
case 25:
|
|
135
135
|
case "end":
|
|
136
136
|
return _context2.stop();
|
|
@@ -359,7 +359,7 @@ describe('components.FormComponent.Container', function () {
|
|
|
359
359
|
input = formGroup.childNodes[2];
|
|
360
360
|
expect(input.tagName).toEqual('DIV'); // Now readonly, so a DIV.
|
|
361
361
|
expect(input.classList).toContain('hods-readonly'); // Now readonly, so hods-readonly
|
|
362
|
-
expect(input.
|
|
362
|
+
expect(input.id).toEqual("".concat(ID, ".").concat(TEXT_ID));
|
|
363
363
|
expect(input.textContent).toEqual(TEXT_VALUE);
|
|
364
364
|
case 22:
|
|
365
365
|
case "end":
|
|
@@ -47,7 +47,7 @@ describe('components', function () {
|
|
|
47
47
|
expect(input.tagName).toEqual('INPUT');
|
|
48
48
|
expect(input.classList).toContain('govuk-input');
|
|
49
49
|
expect(input.id).toEqual(ID);
|
|
50
|
-
expect(input.
|
|
50
|
+
expect(input.value).toEqual(VALUE);
|
|
51
51
|
case 22:
|
|
52
52
|
case "end":
|
|
53
53
|
return _context.stop();
|
|
@@ -80,7 +80,7 @@ describe('components', function () {
|
|
|
80
80
|
expect(input.tagName).toEqual('INPUT');
|
|
81
81
|
expect(input.classList).toContain('govuk-input');
|
|
82
82
|
expect(input.id).toEqual(ID);
|
|
83
|
-
expect(input.
|
|
83
|
+
expect(input.value).toEqual(VALUE);
|
|
84
84
|
case 10:
|
|
85
85
|
case "end":
|
|
86
86
|
return _context2.stop();
|
|
@@ -215,7 +215,7 @@ describe('components', function () {
|
|
|
215
215
|
expect(input.tagName).toEqual('INPUT');
|
|
216
216
|
expect(input.classList).toContain('govuk-input');
|
|
217
217
|
expect(input.id).toEqual(ID);
|
|
218
|
-
expect(input.
|
|
218
|
+
expect(input.value).toEqual(VALUE);
|
|
219
219
|
case 23:
|
|
220
220
|
case "end":
|
|
221
221
|
return _context6.stop();
|
|
@@ -138,7 +138,7 @@ describe('components.FormPage', function () {
|
|
|
138
138
|
expect(input.tagName).toEqual('INPUT');
|
|
139
139
|
expect(input.classList).toContain('govuk-input');
|
|
140
140
|
expect(input.id).toEqual(fieldId);
|
|
141
|
-
expect(input.
|
|
141
|
+
expect(input.value).toEqual(val);
|
|
142
142
|
return input;
|
|
143
143
|
};
|
|
144
144
|
var checkAutoCompleteField = function checkAutoCompleteField(formGroup, fieldId, lbl, hnt, val) {
|
|
@@ -552,9 +552,13 @@ describe('components', function () {
|
|
|
552
552
|
})));
|
|
553
553
|
case 7:
|
|
554
554
|
taskList = container.childNodes[0].childNodes[1];
|
|
555
|
+
taskList.childNodes.forEach(function (child) {
|
|
556
|
+
// eslint-disable-next-line no-console
|
|
557
|
+
console.log("taskList, child = ".concat(JSON.stringify(child.textContent)));
|
|
558
|
+
});
|
|
555
559
|
expect(taskList.childNodes[5].textContent).not.toEqual("test text");
|
|
556
560
|
expect(taskList.childNodes[5].classList).not.toContain('govuk-textarea');
|
|
557
|
-
case
|
|
561
|
+
case 11:
|
|
558
562
|
case "end":
|
|
559
563
|
return _context22.stop();
|
|
560
564
|
}
|
|
@@ -101,7 +101,11 @@ var onCYAAction = function onCYAAction(setPagePoint, action, pages, validate, co
|
|
|
101
101
|
onPageChange(_helpers.default.getNextPageId(type, pages, pageId, action, (_formState$page = formState.page) === null || _formState$page === void 0 ? void 0 : _formState$page.formData));
|
|
102
102
|
}
|
|
103
103
|
if (action.type === _models.PageAction.TYPES.CANCEL) {
|
|
104
|
-
|
|
104
|
+
var formData = _utils.default.Format.form({
|
|
105
|
+
pages: pages,
|
|
106
|
+
components: components
|
|
107
|
+
}, _objectSpread({}, data), _models.EventTypes.CANCEL);
|
|
108
|
+
hooks.onCancel(formData);
|
|
105
109
|
}
|
|
106
110
|
};
|
|
107
111
|
var _default = onCYAAction;
|
|
@@ -102,15 +102,15 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
102
102
|
onFormComplete: function onFormComplete() {
|
|
103
103
|
this.onFormCompleteCalls += 1;
|
|
104
104
|
},
|
|
105
|
-
|
|
106
|
-
onCancel: function onCancel() {
|
|
107
|
-
this.
|
|
105
|
+
onCancelArgs: [],
|
|
106
|
+
onCancel: function onCancel(data) {
|
|
107
|
+
this.onCancelArgs.push(data);
|
|
108
108
|
},
|
|
109
109
|
reset: function reset() {
|
|
110
110
|
this.onSubmitCalls = 0;
|
|
111
111
|
this.onSubmitArgs = [];
|
|
112
112
|
this.onFormCompleteCalls = 0;
|
|
113
|
-
this.
|
|
113
|
+
this.onCancelArgs = [];
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
116
|
var setPagePointCalls = 0;
|
|
@@ -578,6 +578,9 @@ describe('components.FormRenderer.onCYAAction', function () {
|
|
|
578
578
|
}
|
|
579
579
|
});
|
|
580
580
|
_onCYAAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
581
|
-
expect(MOCK_HOOKS.
|
|
581
|
+
expect(MOCK_HOOKS.onCancelArgs.length).toEqual(1);
|
|
582
|
+
expect(MOCK_HOOKS.onCancelArgs[0]).toMatchObject({
|
|
583
|
+
id: 'formId'
|
|
584
|
+
});
|
|
582
585
|
});
|
|
583
586
|
});
|
|
@@ -20,11 +20,6 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
20
20
|
// patchLabel captures non-ID values
|
|
21
21
|
// for display purposes after submission.)
|
|
22
22
|
var onPageAction = function onPageAction(action, patch, patchLabel, hooks, data, formState, validate, onPageChange, type, pages, components, pageId, setPagePoint, currentTask, setData, hubDetails, setSubmitted, addErrors) {
|
|
23
|
-
if (action.type === _models.PageAction.TYPES.CANCEL) {
|
|
24
|
-
hooks.onCancel();
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
;
|
|
28
23
|
// Save a copy of data in case submit errors and we need to revert
|
|
29
24
|
var preSubmitData = _objectSpread({}, data);
|
|
30
25
|
var form = formState;
|
|
@@ -36,6 +31,14 @@ var onPageAction = function onPageAction(action, patch, patchLabel, hooks, data,
|
|
|
36
31
|
// This should normally have no effect but will prevent issues
|
|
37
32
|
// with validation if formData happens to have been wiped.
|
|
38
33
|
form.page.formData = _objectSpread(_objectSpread({}, form.page.formData), _patch);
|
|
34
|
+
|
|
35
|
+
// Exposes form data to consuming application.
|
|
36
|
+
if (action.type === _models.PageAction.TYPES.CANCEL) {
|
|
37
|
+
hooks.onCancel(form.page.formData);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
;
|
|
41
|
+
|
|
39
42
|
// Check to see whether the action is able to proceed, which in
|
|
40
43
|
// in the case of a submission will validate the fields in the page.
|
|
41
44
|
if (_helpers.default.canActionProceed(action, form.page, validate.page)) {
|
|
@@ -121,15 +121,15 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
121
121
|
onFormComplete: function onFormComplete() {
|
|
122
122
|
this.onFormCompleteCalls += 1;
|
|
123
123
|
},
|
|
124
|
-
|
|
125
|
-
onCancel: function onCancel() {
|
|
126
|
-
this.
|
|
124
|
+
onCancelArgs: [],
|
|
125
|
+
onCancel: function onCancel(data) {
|
|
126
|
+
this.onCancelArgs.push(data);
|
|
127
127
|
},
|
|
128
128
|
reset: function reset() {
|
|
129
129
|
this.onSubmitCalls = 0;
|
|
130
130
|
this.onSubmitArgs = [];
|
|
131
131
|
this.onFormCompleteCalls = 0;
|
|
132
|
-
this.
|
|
132
|
+
this.onCancelArgs = [];
|
|
133
133
|
this.onActionCalls = 0;
|
|
134
134
|
},
|
|
135
135
|
onActionCalls: 0,
|
|
@@ -290,7 +290,8 @@ describe('components.FormRenderer.onPageAction', function () {
|
|
|
290
290
|
action: ACTION
|
|
291
291
|
});
|
|
292
292
|
_onPageAction.default.apply(void 0, Object.values(CUSTOM_ARGS));
|
|
293
|
-
expect(MOCK_HOOKS.
|
|
293
|
+
expect(MOCK_HOOKS.onCancelArgs.length).toEqual(1);
|
|
294
|
+
expect(MOCK_HOOKS.onCancelArgs[0]).toMatchObject({});
|
|
294
295
|
// Shouldn't get to the point of validation if
|
|
295
296
|
// action is a cancel action.
|
|
296
297
|
expect(_helpers.default.canActionProceedCalls).toEqual(0);
|
|
@@ -29,7 +29,6 @@ var SummaryList = function SummaryList(_ref) {
|
|
|
29
29
|
className = _ref.className,
|
|
30
30
|
attrs = _objectWithoutProperties(_ref, _excluded);
|
|
31
31
|
var classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
|
|
32
|
-
var cleanedHtmlAttrs = _copReactComponents.Utils.cleanHtmlAttributes(attrs);
|
|
33
32
|
var groupActionRow = null;
|
|
34
33
|
if (isGroup) {
|
|
35
34
|
var rowActions = rows.filter(function (r) {
|
|
@@ -39,7 +38,7 @@ var SummaryList = function SummaryList(_ref) {
|
|
|
39
38
|
}
|
|
40
39
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
41
40
|
className: "group-of-rows"
|
|
42
|
-
}, /*#__PURE__*/_react.default.createElement("dl", _extends({},
|
|
41
|
+
}, /*#__PURE__*/_react.default.createElement("dl", _extends({}, attrs, {
|
|
43
42
|
className: classes()
|
|
44
43
|
}), rows.map(function (row) {
|
|
45
44
|
var key = "".concat(row.pageId, "_").concat(row.full_path || row.fieldId);
|
|
@@ -45,7 +45,7 @@ var TaskList = function TaskList(_ref) {
|
|
|
45
45
|
formData = _ref.formData,
|
|
46
46
|
attrs = _objectWithoutProperties(_ref, _excluded);
|
|
47
47
|
var classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
// TODO state will be retrieved from a document in S3 rather than given in the component definition, covered under COP-9885
|
|
50
50
|
var _sections$filter$redu = sections.filter(function (section) {
|
|
51
51
|
return !section.skipped;
|
|
@@ -71,7 +71,7 @@ var TaskList = function TaskList(_ref) {
|
|
|
71
71
|
};
|
|
72
72
|
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
73
73
|
id: id
|
|
74
|
-
},
|
|
74
|
+
}, attrs, {
|
|
75
75
|
className: classes()
|
|
76
76
|
}), refNumber && refTitle && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
|
|
77
77
|
className: "govuk-body govuk-!-margin-bottom-0"
|
|
@@ -103,7 +103,7 @@ var TaskList = function TaskList(_ref) {
|
|
|
103
103
|
className: classes('section')
|
|
104
104
|
}, sections.length > 1 ? "".concat(index + 1, ". ") : '', section.name), /*#__PURE__*/_react.default.createElement("ol", {
|
|
105
105
|
className: classes('items')
|
|
106
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
106
|
+
}, /*#__PURE__*/_react.default.createElement(_dist.Hint, null, section.label ? section.label : ''), section.tasks.filter(function (task) {
|
|
107
107
|
return task.state !== _models.TaskStates.TYPES.SKIPPED;
|
|
108
108
|
}).map(function (task) {
|
|
109
109
|
return /*#__PURE__*/_react.default.createElement(_Task.default, {
|
|
@@ -56,7 +56,7 @@ var DEFAULT_HOOKS = {
|
|
|
56
56
|
return errors;
|
|
57
57
|
},
|
|
58
58
|
// Returns the list of errors already found in FR by default.
|
|
59
|
-
onCancel: function onCancel() {} // Consuming application must provide function to action, else this does nothing.
|
|
59
|
+
onCancel: function onCancel(data) {} // Consuming application must provide function to action, else this does nothing.
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
var ALLOWED_HOOKS = Object.keys(DEFAULT_HOOKS);
|
|
@@ -6,9 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var TYPE_BLUR = 'blur';
|
|
8
8
|
var TYPE_SUBMIT = 'submit';
|
|
9
|
+
var TYPE_CANCEL = 'cancel';
|
|
9
10
|
var EventTypes = {
|
|
10
11
|
BLUR: TYPE_BLUR,
|
|
11
|
-
SUBMIT: TYPE_SUBMIT
|
|
12
|
+
SUBMIT: TYPE_SUBMIT,
|
|
13
|
+
CANCEL: TYPE_CANCEL
|
|
12
14
|
};
|
|
13
15
|
var _default = EventTypes;
|
|
14
16
|
exports.default = _default;
|
|
@@ -9,6 +9,7 @@ var _Component = _interopRequireDefault(require("../Component"));
|
|
|
9
9
|
var _Container = _interopRequireDefault(require("../Container"));
|
|
10
10
|
var _getSourceData = _interopRequireDefault(require("../Data/getSourceData"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
/* eslint-disable no-console */
|
|
12
13
|
// Local imports
|
|
13
14
|
|
|
14
15
|
var EXCLUDE_FROM_CYA = [_models.ComponentTypes.ALERT, _models.ComponentTypes.HEADING, _models.ComponentTypes.HTML, _models.ComponentTypes.INSET_TEXT];
|
|
@@ -148,7 +148,7 @@ describe('utils.Component.get', function () {
|
|
|
148
148
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
149
149
|
expect(input.tagName).toEqual('DIV');
|
|
150
150
|
expect(input.classList).toContain('hods-readonly');
|
|
151
|
-
expect(input.
|
|
151
|
+
expect(input.id).toEqual(ID);
|
|
152
152
|
expect("".concat(COMPONENT.formData[FIELD_ID])).toEqual(test.result);
|
|
153
153
|
case 13:
|
|
154
154
|
case "end":
|
|
@@ -258,7 +258,7 @@ describe('utils.Component.get', function () {
|
|
|
258
258
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
259
259
|
expect(input.tagName).toEqual('DIV');
|
|
260
260
|
expect(input.classList).toContain('hods-readonly');
|
|
261
|
-
expect(input.
|
|
261
|
+
expect(input.id).toEqual(ID);
|
|
262
262
|
expect(error).toBeCalledTimes(1);
|
|
263
263
|
expect(error).toBeCalledWith(test.error);
|
|
264
264
|
});
|
|
@@ -51,7 +51,7 @@ describe('utils.Component.get', function () {
|
|
|
51
51
|
expect(input.tagName).toEqual('INPUT');
|
|
52
52
|
expect(input.classList).toContain('govuk-input');
|
|
53
53
|
expect(input.id).toEqual(ID);
|
|
54
|
-
expect(input.
|
|
54
|
+
expect(input.value).toEqual(VALUE);
|
|
55
55
|
child2 = container.childNodes[1];
|
|
56
56
|
expect(child2.childNodes[0].childNodes.length).toEqual(3);
|
|
57
57
|
expect(child2.classList).toContain('govuk-form-group');
|
|
@@ -62,9 +62,9 @@ describe('utils.Component.get', function () {
|
|
|
62
62
|
expect(input2.tagName).toEqual('DIV');
|
|
63
63
|
expect(input2.classList).toContain('govuk-date-input');
|
|
64
64
|
expect(input2.id).toEqual(ID2);
|
|
65
|
-
expect(input2.childNodes[0].childNodes[1].
|
|
66
|
-
expect(input2.childNodes[1].childNodes[1].
|
|
67
|
-
expect(input2.childNodes[2].childNodes[1].
|
|
65
|
+
expect(input2.childNodes[0].childNodes[1].value).toEqual('1');
|
|
66
|
+
expect(input2.childNodes[1].childNodes[1].value).toEqual('2');
|
|
67
|
+
expect(input2.childNodes[2].childNodes[1].value).toEqual('2022');
|
|
68
68
|
case 35:
|
|
69
69
|
case "end":
|
|
70
70
|
return _context.stop();
|
|
@@ -133,7 +133,7 @@ describe('utils.Component.get', function () {
|
|
|
133
133
|
expect(input.tagName).toEqual('INPUT');
|
|
134
134
|
expect(input.classList).toContain('govuk-input');
|
|
135
135
|
expect(input.id).toEqual("".concat(CONTAINER_ID, ".").concat(FIELD_ID));
|
|
136
|
-
expect(input.
|
|
136
|
+
expect(input.value).toEqual(VALUE);
|
|
137
137
|
case 19:
|
|
138
138
|
case "end":
|
|
139
139
|
return _context3.stop();
|
|
@@ -172,7 +172,7 @@ describe('utils.Component.get', function () {
|
|
|
172
172
|
expect(input.tagName).toEqual('INPUT');
|
|
173
173
|
expect(input.classList).toContain('govuk-input');
|
|
174
174
|
expect(input.id).toEqual("".concat(COLLECTION_ID, "[0].").concat(FIELD_ID));
|
|
175
|
-
expect(input.
|
|
175
|
+
expect(input.value).toEqual(VALUE);
|
|
176
176
|
case 19:
|
|
177
177
|
case "end":
|
|
178
178
|
return _context4.stop();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ukhomeoffice/cop-react-form-renderer",
|
|
3
|
-
"version": "5.13.
|
|
3
|
+
"version": "5.13.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf dist",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"post-compile": "rimraf dist/*.test.* dist/**/*.test.* dist/**/*.stories.* dist/docs dist/assets"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@ukhomeoffice/cop-react-components": "^3.4.
|
|
19
|
+
"@ukhomeoffice/cop-react-components": "^3.4.2",
|
|
20
20
|
"axios": "^0.23.0",
|
|
21
21
|
"dayjs": "^1.11.0",
|
|
22
22
|
"govuk-frontend": "^4.3.1",
|