@ukhomeoffice/cop-react-form-renderer 6.15.14 → 6.15.16
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/FormRenderer/FormRenderer.js +0 -16
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/forms/form-hidden-component-with-nested-questions-visible-elsewhere.json +118 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/forms/form-nested-answers-hidden-by-option-visible-elsewhere.json +113 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/forms/form-page-nested-component.json +26003 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/input/data-hidden-component-with-nested-questions-visible-elsewhere.json +12 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/input/data-nested-answers-hidden-by-option-visible-elsewhere.json +12 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/input/data-page-nested-component.json +63 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/output/data-hidden-component-with-nested-questions-visible-elsewhere-removed.json +11 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/output/data-nested-answers-hidden-by-option-visible-elsewhere-removed.json +12 -0
- package/dist/components/FormRenderer/clear-uncompleted-routes/test-data/output/data-page-nested-component.json +63 -0
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.js +17 -14
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutes.test.js +31 -0
- package/dist/components/FormRenderer/helpers/clearOutUncompletedRoutesUtils.js +44 -35
- package/package.json +1 -1
|
@@ -129,17 +129,6 @@ const InternalFormRenderer = _ref2 => {
|
|
|
129
129
|
validate
|
|
130
130
|
} = (0, _hooks.useValidation)();
|
|
131
131
|
|
|
132
|
-
// Set focus to header for accessibility, Screen reader to anounce the page heading
|
|
133
|
-
const setFocusToHeading = () => {
|
|
134
|
-
if (document) {
|
|
135
|
-
const header = Array.from(document.getElementsByTagName('h1')).pop();
|
|
136
|
-
if (header && document.activeElement !== header) {
|
|
137
|
-
header.setAttribute('tabIndex', '-1');
|
|
138
|
-
header.focus();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
|
|
143
132
|
// Need to set submission data when going back
|
|
144
133
|
window.onpopstate = e => {
|
|
145
134
|
var _formState$page;
|
|
@@ -203,11 +192,6 @@ const InternalFormRenderer = _ref2 => {
|
|
|
203
192
|
setHub(_utils.default.Hub.get(type, _hub, components, _objectSpread({}, data)));
|
|
204
193
|
}, [type, _hub, data, components, setHub]);
|
|
205
194
|
|
|
206
|
-
// Set focus to heading for accessibility
|
|
207
|
-
(0, _react.useEffect)(() => {
|
|
208
|
-
setFocusToHeading();
|
|
209
|
-
}, [formState]);
|
|
210
|
-
|
|
211
195
|
// Form state.
|
|
212
196
|
(0, _react.useEffect)(() => {
|
|
213
197
|
var _formState$page2;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "example-form",
|
|
3
|
+
"cleanseHiddenData": true,
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"name": "example-form",
|
|
6
|
+
"title": "Example form",
|
|
7
|
+
"type": "form",
|
|
8
|
+
"components": [
|
|
9
|
+
{
|
|
10
|
+
"id": "alpha",
|
|
11
|
+
"fieldId": "alpha",
|
|
12
|
+
"label": "Alpha",
|
|
13
|
+
"type": "text"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": "bravo",
|
|
17
|
+
"fieldId": "bravo",
|
|
18
|
+
"label": "Bravo",
|
|
19
|
+
"type": "text"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "person",
|
|
23
|
+
"fieldId": "person",
|
|
24
|
+
"type": "container",
|
|
25
|
+
"components": [
|
|
26
|
+
{
|
|
27
|
+
"id": "telephone_visible",
|
|
28
|
+
"fieldId": "telephone",
|
|
29
|
+
"label": "telephone_visible",
|
|
30
|
+
"type": "text"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "telephoneKnown",
|
|
34
|
+
"fieldId": "telephoneKnown",
|
|
35
|
+
"type": "radios",
|
|
36
|
+
"data": {
|
|
37
|
+
"options": [
|
|
38
|
+
{
|
|
39
|
+
"value": "yes",
|
|
40
|
+
"label": "Yes",
|
|
41
|
+
"nested": [
|
|
42
|
+
{
|
|
43
|
+
"id": "telephone",
|
|
44
|
+
"fieldId": "telephone",
|
|
45
|
+
"type": "text",
|
|
46
|
+
"label": "Telephone",
|
|
47
|
+
"required": true
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"value": "no",
|
|
53
|
+
"label": "No"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
"show_when": {
|
|
58
|
+
"op": "=",
|
|
59
|
+
"field": "bravo",
|
|
60
|
+
"value": "NOT-bravo-value"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"id": "name",
|
|
65
|
+
"fieldId": "name",
|
|
66
|
+
"label": "Name",
|
|
67
|
+
"type": "text"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"id": "gamma",
|
|
73
|
+
"fieldId": "gamma",
|
|
74
|
+
"label": "Gamma",
|
|
75
|
+
"type": "text"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "epsilon",
|
|
79
|
+
"fieldId": "epsilon",
|
|
80
|
+
"label": "Epsilon",
|
|
81
|
+
"type": "text"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"pages": [
|
|
85
|
+
{
|
|
86
|
+
"id": "general",
|
|
87
|
+
"name": "general",
|
|
88
|
+
"title": "General information",
|
|
89
|
+
"components": [
|
|
90
|
+
{
|
|
91
|
+
"use": "alpha"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"use": "bravo"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"use": "person"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"use": "gamma"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"use": "epsilon"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"actions": [
|
|
107
|
+
"submit",
|
|
108
|
+
{
|
|
109
|
+
"type": "cancel",
|
|
110
|
+
"page": "",
|
|
111
|
+
"validate": false,
|
|
112
|
+
"classModifiers": "secondary",
|
|
113
|
+
"label": "Cancel"
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "example-form",
|
|
3
|
+
"cleanseHiddenData": true,
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"name": "example-form",
|
|
6
|
+
"title": "Example form",
|
|
7
|
+
"type": "form",
|
|
8
|
+
"components": [
|
|
9
|
+
{
|
|
10
|
+
"id": "alpha",
|
|
11
|
+
"fieldId": "alpha",
|
|
12
|
+
"label": "Alpha",
|
|
13
|
+
"type": "text"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": "bravo",
|
|
17
|
+
"fieldId": "bravo",
|
|
18
|
+
"label": "Bravo",
|
|
19
|
+
"type": "text"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "person",
|
|
23
|
+
"fieldId": "person",
|
|
24
|
+
"type": "container",
|
|
25
|
+
"components": [
|
|
26
|
+
{
|
|
27
|
+
"id": "telephone_visible",
|
|
28
|
+
"fieldId": "telephone",
|
|
29
|
+
"label": "telephone_visible",
|
|
30
|
+
"type": "text"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "telephoneKnown",
|
|
34
|
+
"fieldId": "telephoneKnown",
|
|
35
|
+
"type": "radios",
|
|
36
|
+
"data": {
|
|
37
|
+
"options": [
|
|
38
|
+
{
|
|
39
|
+
"value": "yes",
|
|
40
|
+
"label": "Yes",
|
|
41
|
+
"nested": [
|
|
42
|
+
{
|
|
43
|
+
"id": "telephone",
|
|
44
|
+
"fieldId": "telephone",
|
|
45
|
+
"type": "text",
|
|
46
|
+
"label": "Telephone",
|
|
47
|
+
"required": true
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"value": "no",
|
|
53
|
+
"label": "No"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "name",
|
|
60
|
+
"fieldId": "name",
|
|
61
|
+
"label": "Name",
|
|
62
|
+
"type": "text"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"id": "gamma",
|
|
68
|
+
"fieldId": "gamma",
|
|
69
|
+
"label": "Gamma",
|
|
70
|
+
"type": "text"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"id": "epsilon",
|
|
74
|
+
"fieldId": "epsilon",
|
|
75
|
+
"label": "Epsilon",
|
|
76
|
+
"type": "text"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"pages": [
|
|
80
|
+
{
|
|
81
|
+
"id": "general",
|
|
82
|
+
"name": "general",
|
|
83
|
+
"title": "General information",
|
|
84
|
+
"components": [
|
|
85
|
+
{
|
|
86
|
+
"use": "alpha"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"use": "bravo"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"use": "person"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"use": "gamma"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"use": "epsilon"
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"actions": [
|
|
102
|
+
"submit",
|
|
103
|
+
{
|
|
104
|
+
"type": "cancel",
|
|
105
|
+
"page": "",
|
|
106
|
+
"validate": false,
|
|
107
|
+
"classModifiers": "secondary",
|
|
108
|
+
"label": "Cancel"
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|