@ukhomeoffice/cop-react-form-renderer 4.29.0-alpha → 4.30.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.
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +5 -23
- package/dist/components/CollectionPage/CollectionPage.test.js +9 -9
- package/dist/components/FormComponent/Collection.test.js +7 -7
- package/dist/components/FormComponent/Container.test.js +14 -14
- package/dist/components/FormComponent/FormComponent.test.js +6 -6
- package/dist/components/FormPage/FormPage.test.js +8 -8
- package/dist/components/FormRenderer/FormRenderer.js +7 -64
- package/dist/components/FormRenderer/FormRenderer.test.js +17 -75
- package/dist/components/FormRenderer/handlers/navigate.js +2 -2
- package/dist/models/PageAction.js +1 -7
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +4 -3
- package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +2 -2
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +4 -3
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +7 -7
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.file.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +11 -11
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.select.test.js +1 -7
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +3 -3
- package/dist/utils/Component/getComponentTests/getComponent.textarea.test.js +1 -1
- package/dist/utils/Component/getComponentTests/getComponent.time.test.js +4 -4
- package/dist/utils/Validate/validateComponent.js +3 -2
- package/dist/utils/Validate/validateEmail.js +9 -1
- package/dist/utils/Validate/validateEmail.test.js +8 -0
- package/package.json +2 -2
- package/dist/json/multiQuestionTaskList.json +0 -275
- package/dist/json/multiQuestionTaskListData.json +0 -39
|
@@ -69,9 +69,7 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
69
69
|
noChangeAction = _ref.noChangeAction,
|
|
70
70
|
groups = _ref.groups,
|
|
71
71
|
sections = _ref.sections,
|
|
72
|
-
type = _ref.type
|
|
73
|
-
cysa = _ref.cysa,
|
|
74
|
-
currentPage = _ref.currentPage;
|
|
72
|
+
type = _ref.type;
|
|
75
73
|
|
|
76
74
|
var _useState = (0, _react.useState)([]),
|
|
77
75
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -88,7 +86,7 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
88
86
|
|
|
89
87
|
(0, _react.useEffect)(function () {
|
|
90
88
|
var getRows = function getRows(page, pageIndex) {
|
|
91
|
-
var rows = _utils.default.CheckYourAnswers.getRows(page, onRowAction
|
|
89
|
+
var rows = _utils.default.CheckYourAnswers.getRows(page, onRowAction);
|
|
92
90
|
|
|
93
91
|
return rows.map(function (row, index) {
|
|
94
92
|
return _objectSpread(_objectSpread({}, row), {}, {
|
|
@@ -111,23 +109,8 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
111
109
|
}).filter(function (p) {
|
|
112
110
|
return !!p;
|
|
113
111
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
var indexOfCurrentPage = pagesWithRows.map(function (object) {
|
|
117
|
-
return object.id;
|
|
118
|
-
}).indexOf(currentPage);
|
|
119
|
-
|
|
120
|
-
if (indexOfCurrentPage === 0) {
|
|
121
|
-
setPages(pagesWithRows.slice(0, 1));
|
|
122
|
-
} else {
|
|
123
|
-
setPages(pagesWithRows.slice(0, indexOfCurrentPage));
|
|
124
|
-
}
|
|
125
|
-
} else {
|
|
126
|
-
setPages(pagesWithRows);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
;
|
|
130
|
-
}, [_pages, onRowAction, setPages, currentPage, cysa]);
|
|
112
|
+
setPages(pagesWithRows);
|
|
113
|
+
}, [_pages, onRowAction, setPages]);
|
|
131
114
|
var listMarginBottom = hide_page_titles ? 0 : DEFAULT_MARGIN_BOTTOM;
|
|
132
115
|
|
|
133
116
|
var isLastPage = function isLastPage(index) {
|
|
@@ -161,12 +144,11 @@ var CheckYourAnswers = function CheckYourAnswers(_ref) {
|
|
|
161
144
|
return groupAnswer;
|
|
162
145
|
};
|
|
163
146
|
|
|
164
|
-
var cysaTitle = 'Check your saved answers';
|
|
165
147
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
166
148
|
className: DEFAULT_CLASS
|
|
167
149
|
}, title && !hide_title && /*#__PURE__*/_react.default.createElement(_copReactComponents.LargeHeading, {
|
|
168
150
|
key: "heading"
|
|
169
|
-
},
|
|
151
|
+
}, title), errors && errors.length > 0 && /*#__PURE__*/_react.default.createElement(_copReactComponents.ErrorSummary, {
|
|
170
152
|
errors: errors
|
|
171
153
|
}), type === 'task-list-cya' && pages.length > 0 && sections && sections.map(function (section) {
|
|
172
154
|
return section.tasks.map(function (task) {
|
|
@@ -147,16 +147,16 @@ describe('components.CollectionPage', function () {
|
|
|
147
147
|
var checkInputField = function checkInputField(formGroup, fieldId, lbl, hnt, val) {
|
|
148
148
|
expect(formGroup.tagName).toEqual('DIV');
|
|
149
149
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
150
|
-
var label = formGroup.childNodes[0];
|
|
150
|
+
var label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
151
151
|
expect(label.tagName).toEqual('LABEL');
|
|
152
152
|
expect(label.classList).toContain('govuk-label');
|
|
153
153
|
expect(label.textContent).toEqual(lbl);
|
|
154
154
|
expect(label.getAttribute('for')).toEqual(fieldId);
|
|
155
|
-
var hint = formGroup.childNodes[1];
|
|
155
|
+
var hint = formGroup.childNodes[0].childNodes[1];
|
|
156
156
|
expect(hint.tagName).toEqual('SPAN');
|
|
157
157
|
expect(hint.classList).toContain('govuk-hint');
|
|
158
158
|
expect(hint.textContent).toEqual(hnt);
|
|
159
|
-
var input = formGroup.childNodes[2];
|
|
159
|
+
var input = formGroup.childNodes[0].childNodes[2];
|
|
160
160
|
expect(input.tagName).toEqual('INPUT');
|
|
161
161
|
expect(input.classList).toContain('govuk-input');
|
|
162
162
|
expect(input.id).toEqual(fieldId);
|
|
@@ -167,16 +167,16 @@ describe('components.CollectionPage', function () {
|
|
|
167
167
|
var checkAutoCompleteField = function checkAutoCompleteField(formGroup, fieldId, lbl, hnt, val) {
|
|
168
168
|
expect(formGroup.tagName).toEqual('DIV');
|
|
169
169
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
170
|
-
var label = formGroup.childNodes[0];
|
|
170
|
+
var label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
171
171
|
expect(label.tagName).toEqual('LABEL');
|
|
172
172
|
expect(label.classList).toContain('govuk-label');
|
|
173
173
|
expect(label.textContent).toEqual(lbl);
|
|
174
174
|
expect(label.getAttribute('for')).toEqual(fieldId);
|
|
175
|
-
var hint = formGroup.childNodes[1];
|
|
175
|
+
var hint = formGroup.childNodes[0].childNodes[1];
|
|
176
176
|
expect(hint.tagName).toEqual('SPAN');
|
|
177
177
|
expect(hint.classList).toContain('govuk-hint');
|
|
178
178
|
expect(hint.textContent).toEqual(hnt);
|
|
179
|
-
var outerWrapper = formGroup.childNodes[2];
|
|
179
|
+
var outerWrapper = formGroup.childNodes[0].childNodes[2];
|
|
180
180
|
expect(outerWrapper.classList).toContain('hods-autocomplete__outer-wrapper');
|
|
181
181
|
var autocomplete = outerWrapper.childNodes[0];
|
|
182
182
|
expect(autocomplete.classList).toContain('hods-autocomplete__wrapper');
|
|
@@ -293,7 +293,7 @@ describe('components.CollectionPage', function () {
|
|
|
293
293
|
page = container.childNodes[0];
|
|
294
294
|
expect(page.tagName).toEqual('DIV'); // Change the input.
|
|
295
295
|
|
|
296
|
-
input = page.childNodes[1].childNodes[2];
|
|
296
|
+
input = page.childNodes[1].childNodes[0].childNodes[2];
|
|
297
297
|
NEW_VALUE = "".concat(VALUE, ".");
|
|
298
298
|
EVENT = {
|
|
299
299
|
target: {
|
|
@@ -327,7 +327,7 @@ describe('components.CollectionPage', function () {
|
|
|
327
327
|
})), container = _renderWithValidation4.container;
|
|
328
328
|
page = container.childNodes[0]; // Change the input.
|
|
329
329
|
|
|
330
|
-
input = page.childNodes[1].childNodes[2];
|
|
330
|
+
input = page.childNodes[1].childNodes[0].childNodes[2];
|
|
331
331
|
NEW_VALUE = "".concat(VALUE, ".");
|
|
332
332
|
CHANGE_EVENT = {
|
|
333
333
|
target: {
|
|
@@ -374,7 +374,7 @@ describe('components.CollectionPage', function () {
|
|
|
374
374
|
})), container = _renderWithValidation5.container;
|
|
375
375
|
page = container.childNodes[0]; // Change the input.
|
|
376
376
|
|
|
377
|
-
input = page.childNodes[1].childNodes[2];
|
|
377
|
+
input = page.childNodes[1].childNodes[0].childNodes[2];
|
|
378
378
|
NEW_VALUE = "".concat(VALUE, ".");
|
|
379
379
|
CHANGE_EVENT = {
|
|
380
380
|
target: {
|
|
@@ -88,16 +88,16 @@ describe('components.FormComponent.Collection', function () {
|
|
|
88
88
|
formGroup = itemContainer.childNodes[0];
|
|
89
89
|
expect(formGroup.tagName).toEqual('DIV');
|
|
90
90
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
91
|
-
label = formGroup.childNodes[0];
|
|
91
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
92
92
|
expect(label.tagName).toEqual('LABEL');
|
|
93
93
|
expect(label.classList).toContain('govuk-label');
|
|
94
94
|
expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
|
|
95
95
|
expect(label.getAttribute('for')).toEqual("".concat(ID, "[0].").concat(TEXT_ID));
|
|
96
|
-
hint = formGroup.childNodes[1];
|
|
96
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
97
97
|
expect(hint.tagName).toEqual('SPAN');
|
|
98
98
|
expect(hint.classList).toContain('govuk-hint');
|
|
99
99
|
expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
|
|
100
|
-
input = formGroup.childNodes[2];
|
|
100
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
101
101
|
expect(input.tagName).toEqual('INPUT');
|
|
102
102
|
expect(input.classList).toContain('govuk-input');
|
|
103
103
|
expect(input.id).toEqual("".concat(ID, "[0].").concat(TEXT_ID));
|
|
@@ -144,7 +144,7 @@ describe('components.FormComponent.Collection', function () {
|
|
|
144
144
|
c = container.childNodes[0];
|
|
145
145
|
item = c.childNodes[0];
|
|
146
146
|
formGroup = item.childNodes[1].childNodes[0];
|
|
147
|
-
input = formGroup.childNodes[2];
|
|
147
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
148
148
|
NEW_TEXT_VALUE = 'bravo';
|
|
149
149
|
EVENT = {
|
|
150
150
|
target: {
|
|
@@ -354,16 +354,16 @@ describe('components.FormComponent.Collection', function () {
|
|
|
354
354
|
formGroup = itemContainer.childNodes[0];
|
|
355
355
|
expect(formGroup.tagName).toEqual('DIV');
|
|
356
356
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
357
|
-
label = formGroup.childNodes[0];
|
|
357
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
358
358
|
expect(label.tagName).toEqual('LABEL');
|
|
359
359
|
expect(label.classList).toContain('govuk-label');
|
|
360
360
|
expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
|
|
361
361
|
expect(label.getAttribute('for')).toEqual("".concat(ID, "[0].").concat(TEXT_ID));
|
|
362
|
-
hint = formGroup.childNodes[1];
|
|
362
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
363
363
|
expect(hint.tagName).toEqual('SPAN');
|
|
364
364
|
expect(hint.classList).toContain('govuk-hint');
|
|
365
365
|
expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
|
|
366
|
-
input = formGroup.childNodes[2];
|
|
366
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
367
367
|
expect(input.tagName).toEqual('DIV'); // Now readonly, so a DIV.
|
|
368
368
|
|
|
369
369
|
expect(input.classList).toContain('hods-readonly'); // Now readonly, so hods-readonly
|
|
@@ -76,16 +76,16 @@ describe('components.FormComponent.Container', function () {
|
|
|
76
76
|
formGroup = c.childNodes[0];
|
|
77
77
|
expect(formGroup.tagName).toEqual('DIV');
|
|
78
78
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
79
|
-
label = formGroup.childNodes[0];
|
|
79
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
80
80
|
expect(label.tagName).toEqual('LABEL');
|
|
81
81
|
expect(label.classList).toContain('govuk-label');
|
|
82
82
|
expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
|
|
83
83
|
expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(TEXT_ID));
|
|
84
|
-
hint = formGroup.childNodes[1];
|
|
84
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
85
85
|
expect(hint.tagName).toEqual('SPAN');
|
|
86
86
|
expect(hint.classList).toContain('govuk-hint');
|
|
87
87
|
expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
|
|
88
|
-
input = formGroup.childNodes[2];
|
|
88
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
89
89
|
expect(input.tagName).toEqual('INPUT');
|
|
90
90
|
expect(input.classList).toContain('govuk-input');
|
|
91
91
|
expect(input.id).toEqual("".concat(ID, ".").concat(TEXT_ID));
|
|
@@ -133,16 +133,16 @@ describe('components.FormComponent.Container', function () {
|
|
|
133
133
|
formGroup = nested.childNodes[0];
|
|
134
134
|
expect(formGroup.tagName).toEqual('DIV');
|
|
135
135
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
136
|
-
label = formGroup.childNodes[0];
|
|
136
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
137
137
|
expect(label.tagName).toEqual('LABEL');
|
|
138
138
|
expect(label.classList).toContain('govuk-label');
|
|
139
139
|
expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
|
|
140
140
|
expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(NESTED_ID, ".").concat(TEXT_ID));
|
|
141
|
-
hint = formGroup.childNodes[1];
|
|
141
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
142
142
|
expect(hint.tagName).toEqual('SPAN');
|
|
143
143
|
expect(hint.classList).toContain('govuk-hint');
|
|
144
144
|
expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
|
|
145
|
-
input = formGroup.childNodes[2];
|
|
145
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
146
146
|
expect(input.tagName).toEqual('INPUT');
|
|
147
147
|
expect(input.classList).toContain('govuk-input');
|
|
148
148
|
expect(input.id).toEqual("".concat(ID, ".").concat(NESTED_ID, ".").concat(TEXT_ID));
|
|
@@ -188,7 +188,7 @@ describe('components.FormComponent.Container', function () {
|
|
|
188
188
|
|
|
189
189
|
c = container.childNodes[0];
|
|
190
190
|
formGroup = c.childNodes[0];
|
|
191
|
-
input = formGroup.childNodes[2];
|
|
191
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
192
192
|
NEW_TEXT_VALUE = 'bravo';
|
|
193
193
|
EVENT = {
|
|
194
194
|
target: {
|
|
@@ -253,7 +253,7 @@ describe('components.FormComponent.Container', function () {
|
|
|
253
253
|
|
|
254
254
|
c = container.childNodes[0];
|
|
255
255
|
formGroup = c.childNodes[0];
|
|
256
|
-
input = formGroup.childNodes[2].childNodes[0];
|
|
256
|
+
input = formGroup.childNodes[0].childNodes[2].childNodes[0];
|
|
257
257
|
FILE_EXTENSION = 'json';
|
|
258
258
|
FILE_NAME = "test.".concat(FILE_EXTENSION);
|
|
259
259
|
FILE_TYPE = 'application/JSON';
|
|
@@ -314,16 +314,16 @@ describe('components.FormComponent.Container', function () {
|
|
|
314
314
|
formGroup = c.childNodes[0];
|
|
315
315
|
expect(formGroup.tagName).toEqual('DIV');
|
|
316
316
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
317
|
-
label = formGroup.childNodes[0];
|
|
317
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
318
318
|
expect(label.tagName).toEqual('LABEL');
|
|
319
319
|
expect(label.classList).toContain('govuk-label');
|
|
320
320
|
expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
|
|
321
321
|
expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(TEXT_ID));
|
|
322
|
-
hint = formGroup.childNodes[1];
|
|
322
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
323
323
|
expect(hint.tagName).toEqual('SPAN');
|
|
324
324
|
expect(hint.classList).toContain('govuk-hint');
|
|
325
325
|
expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
|
|
326
|
-
input = formGroup.childNodes[2];
|
|
326
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
327
327
|
expect(input.tagName).toEqual('INPUT');
|
|
328
328
|
expect(input.classList).toContain('govuk-input');
|
|
329
329
|
expect(input.id).toEqual("".concat(ID, ".").concat(TEXT_ID));
|
|
@@ -396,16 +396,16 @@ describe('components.FormComponent.Container', function () {
|
|
|
396
396
|
formGroup = c.childNodes[0];
|
|
397
397
|
expect(formGroup.tagName).toEqual('DIV');
|
|
398
398
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
399
|
-
label = formGroup.childNodes[0];
|
|
399
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
400
400
|
expect(label.tagName).toEqual('LABEL');
|
|
401
401
|
expect(label.classList).toContain('govuk-label');
|
|
402
402
|
expect(label.textContent).toEqual("".concat(TEXT_COMPONENT.label, " (optional)"));
|
|
403
403
|
expect(label.getAttribute('for')).toEqual("".concat(ID, ".").concat(TEXT_ID));
|
|
404
|
-
hint = formGroup.childNodes[1];
|
|
404
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
405
405
|
expect(hint.tagName).toEqual('SPAN');
|
|
406
406
|
expect(hint.classList).toContain('govuk-hint');
|
|
407
407
|
expect(hint.textContent).toEqual(TEXT_COMPONENT.hint);
|
|
408
|
-
input = formGroup.childNodes[2];
|
|
408
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
409
409
|
expect(input.tagName).toEqual('DIV'); // Now readonly, so a DIV.
|
|
410
410
|
|
|
411
411
|
expect(input.classList).toContain('hods-readonly'); // Now readonly, so hods-readonly
|
|
@@ -43,16 +43,16 @@ describe('components', function () {
|
|
|
43
43
|
formGroup = container.childNodes[0];
|
|
44
44
|
expect(formGroup.tagName).toEqual('DIV');
|
|
45
45
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
46
|
-
label = formGroup.childNodes[0];
|
|
46
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
47
47
|
expect(label.tagName).toEqual('LABEL');
|
|
48
48
|
expect(label.classList).toContain('govuk-label');
|
|
49
49
|
expect(label.textContent).toEqual("".concat(COMPONENT.label, " (optional)"));
|
|
50
50
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
51
|
-
hint = formGroup.childNodes[1];
|
|
51
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
52
52
|
expect(hint.tagName).toEqual('SPAN');
|
|
53
53
|
expect(hint.classList).toContain('govuk-hint');
|
|
54
54
|
expect(hint.textContent).toEqual(COMPONENT.hint);
|
|
55
|
-
input = formGroup.childNodes[2];
|
|
55
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
56
56
|
expect(input.tagName).toEqual('INPUT');
|
|
57
57
|
expect(input.classList).toContain('govuk-input');
|
|
58
58
|
expect(input.id).toEqual(ID);
|
|
@@ -238,16 +238,16 @@ describe('components', function () {
|
|
|
238
238
|
formGroup = container.childNodes[0];
|
|
239
239
|
expect(formGroup.tagName).toEqual('DIV');
|
|
240
240
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
241
|
-
label = formGroup.childNodes[0];
|
|
241
|
+
label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
242
242
|
expect(label.tagName).toEqual('LABEL');
|
|
243
243
|
expect(label.classList).toContain('govuk-label');
|
|
244
244
|
expect(label.textContent).toEqual('Interpolated Text component (optional)');
|
|
245
245
|
expect(label.getAttribute('for')).toEqual(ID);
|
|
246
|
-
hint = formGroup.childNodes[1];
|
|
246
|
+
hint = formGroup.childNodes[0].childNodes[1];
|
|
247
247
|
expect(hint.tagName).toEqual('SPAN');
|
|
248
248
|
expect(hint.classList).toContain('govuk-hint');
|
|
249
249
|
expect(hint.textContent).toEqual(COMPONENT.hint);
|
|
250
|
-
input = formGroup.childNodes[2];
|
|
250
|
+
input = formGroup.childNodes[0].childNodes[2];
|
|
251
251
|
expect(input.tagName).toEqual('INPUT');
|
|
252
252
|
expect(input.classList).toContain('govuk-input');
|
|
253
253
|
expect(input.id).toEqual(ID);
|
|
@@ -135,16 +135,16 @@ describe('components.FormPage', function () {
|
|
|
135
135
|
var checkInputField = function checkInputField(formGroup, fieldId, lbl, hnt, val) {
|
|
136
136
|
expect(formGroup.tagName).toEqual('DIV');
|
|
137
137
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
138
|
-
var label = formGroup.childNodes[0];
|
|
138
|
+
var label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
139
139
|
expect(label.tagName).toEqual('LABEL');
|
|
140
140
|
expect(label.classList).toContain('govuk-label');
|
|
141
141
|
expect(label.textContent).toEqual(lbl);
|
|
142
142
|
expect(label.getAttribute('for')).toEqual(fieldId);
|
|
143
|
-
var hint = formGroup.childNodes[1];
|
|
143
|
+
var hint = formGroup.childNodes[0].childNodes[1];
|
|
144
144
|
expect(hint.tagName).toEqual('SPAN');
|
|
145
145
|
expect(hint.classList).toContain('govuk-hint');
|
|
146
146
|
expect(hint.textContent).toEqual(hnt);
|
|
147
|
-
var input = formGroup.childNodes[2];
|
|
147
|
+
var input = formGroup.childNodes[0].childNodes[2];
|
|
148
148
|
expect(input.tagName).toEqual('INPUT');
|
|
149
149
|
expect(input.classList).toContain('govuk-input');
|
|
150
150
|
expect(input.id).toEqual(fieldId);
|
|
@@ -155,16 +155,16 @@ describe('components.FormPage', function () {
|
|
|
155
155
|
var checkAutoCompleteField = function checkAutoCompleteField(formGroup, fieldId, lbl, hnt, val) {
|
|
156
156
|
expect(formGroup.tagName).toEqual('DIV');
|
|
157
157
|
expect(formGroup.classList).toContain('govuk-form-group');
|
|
158
|
-
var label = formGroup.childNodes[0];
|
|
158
|
+
var label = formGroup.childNodes[0].childNodes[0].childNodes[0];
|
|
159
159
|
expect(label.tagName).toEqual('LABEL');
|
|
160
160
|
expect(label.classList).toContain('govuk-label');
|
|
161
161
|
expect(label.textContent).toEqual(lbl);
|
|
162
162
|
expect(label.getAttribute('for')).toEqual(fieldId);
|
|
163
|
-
var hint = formGroup.childNodes[1];
|
|
163
|
+
var hint = formGroup.childNodes[0].childNodes[1];
|
|
164
164
|
expect(hint.tagName).toEqual('SPAN');
|
|
165
165
|
expect(hint.classList).toContain('govuk-hint');
|
|
166
166
|
expect(hint.textContent).toEqual(hnt);
|
|
167
|
-
var outerWrapper = formGroup.childNodes[2];
|
|
167
|
+
var outerWrapper = formGroup.childNodes[0].childNodes[2];
|
|
168
168
|
expect(outerWrapper.classList).toContain('hods-autocomplete__outer-wrapper');
|
|
169
169
|
var autocomplete = outerWrapper.childNodes[0];
|
|
170
170
|
expect(autocomplete.classList).toContain('hods-autocomplete__wrapper');
|
|
@@ -278,7 +278,7 @@ describe('components.FormPage', function () {
|
|
|
278
278
|
page = container.childNodes[0];
|
|
279
279
|
expect(page.tagName).toEqual('DIV'); // Change the input.
|
|
280
280
|
|
|
281
|
-
input = page.childNodes[1].childNodes[2];
|
|
281
|
+
input = page.childNodes[1].childNodes[0].childNodes[2];
|
|
282
282
|
NEW_VALUE = "".concat(VALUE, ".");
|
|
283
283
|
EVENT = {
|
|
284
284
|
target: {
|
|
@@ -312,7 +312,7 @@ describe('components.FormPage', function () {
|
|
|
312
312
|
})), container = _renderWithValidation4.container;
|
|
313
313
|
page = container.childNodes[0]; // Change the input.
|
|
314
314
|
|
|
315
|
-
input = page.childNodes[1].childNodes[2];
|
|
315
|
+
input = page.childNodes[1].childNodes[0].childNodes[2];
|
|
316
316
|
NEW_VALUE = "".concat(VALUE, ".");
|
|
317
317
|
CHANGE_EVENT = {
|
|
318
318
|
target: {
|
|
@@ -170,17 +170,7 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
170
170
|
var _useState19 = (0, _react.useState)(false),
|
|
171
171
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
172
172
|
goingBack = _useState20[0],
|
|
173
|
-
setGoingBack = _useState20[1];
|
|
174
|
-
|
|
175
|
-
var _useState21 = (0, _react.useState)(false),
|
|
176
|
-
_useState22 = _slicedToArray(_useState21, 2),
|
|
177
|
-
continueOnly = _useState22[0],
|
|
178
|
-
setContinueOnly = _useState22[1];
|
|
179
|
-
|
|
180
|
-
var _useState23 = (0, _react.useState)(),
|
|
181
|
-
_useState24 = _slicedToArray(_useState23, 2),
|
|
182
|
-
currentTaskListPage = _useState24[0],
|
|
183
|
-
setCurrentTaskListPage = _useState24[1]; // Set up hooks.
|
|
173
|
+
setGoingBack = _useState20[1]; // Set up hooks.
|
|
184
174
|
|
|
185
175
|
|
|
186
176
|
var _useHooks = (0, _hooks.useHooks)(),
|
|
@@ -193,29 +183,13 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
193
183
|
validate = _useValidation.validate; // Need to set submission data when going back
|
|
194
184
|
|
|
195
185
|
|
|
196
|
-
window.onpopstate = function (
|
|
186
|
+
window.onpopstate = function () {
|
|
197
187
|
var _formState$page;
|
|
198
188
|
|
|
199
189
|
if (document.location.hash) {
|
|
200
190
|
return;
|
|
201
191
|
}
|
|
202
192
|
|
|
203
|
-
if (e.state && e.state.continueOnly !== undefined) {
|
|
204
|
-
var _e$state;
|
|
205
|
-
|
|
206
|
-
setContinueOnly((_e$state = e.state) === null || _e$state === void 0 ? void 0 : _e$state.continueOnly);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (e.state && e.state.fullPages !== undefined) {
|
|
210
|
-
setCurrentTask(function (prev) {
|
|
211
|
-
var _e$state2;
|
|
212
|
-
|
|
213
|
-
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
214
|
-
fullPages: (_e$state2 = e.state) === null || _e$state2 === void 0 ? void 0 : _e$state2.fullPages
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
|
|
219
193
|
setGoingBack(true);
|
|
220
194
|
hooks.onGoingBack();
|
|
221
195
|
clearErrors();
|
|
@@ -318,10 +292,9 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
318
292
|
}, [currentTask.fullPages, data, hubDetails === null || hubDetails === void 0 ? void 0 : hubDetails.sections, hubDetails === null || hubDetails === void 0 ? void 0 : hubDetails.nonSequential]);
|
|
319
293
|
|
|
320
294
|
var onPageChange = function onPageChange(newPageId) {
|
|
321
|
-
var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
322
295
|
clearErrors();
|
|
323
296
|
setPageId(newPageId);
|
|
324
|
-
hooks.onPageChange(newPageId
|
|
297
|
+
hooks.onPageChange(newPageId);
|
|
325
298
|
};
|
|
326
299
|
|
|
327
300
|
(0, _react.useEffect)(function () {
|
|
@@ -363,13 +336,8 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
363
336
|
break;
|
|
364
337
|
|
|
365
338
|
case _models.PageAction.TYPES.SAVE_AND_NAVIGATE:
|
|
366
|
-
var state = {
|
|
367
|
-
'continueOnly': false,
|
|
368
|
-
'fullPages': currentTask.fullPages
|
|
369
|
-
};
|
|
370
|
-
|
|
371
339
|
pageUpdate = function pageUpdate() {
|
|
372
|
-
return _handlers.default.navigate(action, pageId, onPageChange
|
|
340
|
+
return _handlers.default.navigate(action, pageId, onPageChange);
|
|
373
341
|
};
|
|
374
342
|
|
|
375
343
|
break;
|
|
@@ -482,8 +450,6 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
482
450
|
}
|
|
483
451
|
|
|
484
452
|
if (page) {
|
|
485
|
-
setContinueOnly(false);
|
|
486
|
-
|
|
487
453
|
_handlers.default.cyaAction(page, pageId, onPageChange);
|
|
488
454
|
}
|
|
489
455
|
}; //Kick off a task, gather required pages and move to the correct point
|
|
@@ -506,18 +472,7 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
506
472
|
}
|
|
507
473
|
} else if (currentTask.state === _models.TaskStates.TYPES.IN_PROGRESS) {
|
|
508
474
|
var _currentPage = data.formStatus.tasks[currentTask.name].currentPage;
|
|
509
|
-
|
|
510
|
-
if (currentTask.pages.length > 1 && _currentPage !== _models.FormPages.CYA && _currentPage !== currentTask.pages[0]) {
|
|
511
|
-
setContinueOnly(true);
|
|
512
|
-
setCurrentTaskListPage(_currentPage);
|
|
513
|
-
var state = {
|
|
514
|
-
'continueOnly': true,
|
|
515
|
-
'fullPages': currentTask.fullPages
|
|
516
|
-
};
|
|
517
|
-
onPageChange(_models.FormPages.CYA, state);
|
|
518
|
-
} else {
|
|
519
|
-
onPageChange(_currentPage);
|
|
520
|
-
}
|
|
475
|
+
onPageChange(_currentPage || currentTask.pages[0]);
|
|
521
476
|
} else if (currentTask.firstPage) {
|
|
522
477
|
var _currentPage2 = currentTask.firstPage;
|
|
523
478
|
onPageChange(_currentPage2 || currentTask.pages[0]);
|
|
@@ -620,12 +575,6 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
620
575
|
onPageChange(_helpers.default.getNextPageId(type, pages, pageId, action, (_formState$page4 = formState.page) === null || _formState$page4 === void 0 ? void 0 : _formState$page4.formData));
|
|
621
576
|
}
|
|
622
577
|
|
|
623
|
-
if (action.type === _models.PageAction.TYPES.CONTINUE) {
|
|
624
|
-
var currentPage = data.formStatus.tasks[currentTask.name].currentPage;
|
|
625
|
-
onPageChange(currentPage || currentTask.pages[0]);
|
|
626
|
-
setContinueOnly(false);
|
|
627
|
-
}
|
|
628
|
-
|
|
629
578
|
if (action.type === _models.PageAction.TYPES.CANCEL) {
|
|
630
579
|
hooks.onCancel();
|
|
631
580
|
}
|
|
@@ -634,11 +583,7 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
634
583
|
var classes = _utils.default.classBuilder(classBlock, classModifiers, className);
|
|
635
584
|
|
|
636
585
|
if (hub === _models.HubFormats.TASK) {
|
|
637
|
-
|
|
638
|
-
cya.actions = [_models.PageAction.TYPES.CONTINUE];
|
|
639
|
-
} else {
|
|
640
|
-
cya.actions = [_models.PageAction.TYPES.SAVE_AND_CONTINUE, _models.PageAction.TYPES.SAVE_AND_RETURN];
|
|
641
|
-
}
|
|
586
|
+
cya.actions = [_models.PageAction.TYPES.SAVE_AND_CONTINUE, _models.PageAction.TYPES.SAVE_AND_RETURN];
|
|
642
587
|
}
|
|
643
588
|
|
|
644
589
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -654,9 +599,7 @@ var InternalFormRenderer = function InternalFormRenderer(_ref2) {
|
|
|
654
599
|
hide_title: hide_title,
|
|
655
600
|
noChangeAction: noChangeAction,
|
|
656
601
|
sections: typeof hubDetails !== 'undefined' ? hubDetails.sections : [],
|
|
657
|
-
type: type
|
|
658
|
-
cysa: continueOnly,
|
|
659
|
-
currentPage: currentTaskListPage
|
|
602
|
+
type: type
|
|
660
603
|
})), hub === _models.HubFormats.TASK && formState.pageId === _models.FormPages.HUB && /*#__PURE__*/_react.default.createElement(_TaskList.default, _extends({}, hubDetails, {
|
|
661
604
|
refNumber: data.businessKey,
|
|
662
605
|
onTaskAction: onTaskAction
|