@ukhomeoffice/cop-react-form-renderer 1.0.0-gamma → 2.1.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/LICENSE +21 -0
- package/README.md +12 -0
- package/dist/components/CheckYourAnswers/CheckYourAnswers.js +16 -5
- package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +199 -79
- package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +44 -0
- package/dist/components/FormPage/FormPage.js +8 -2
- package/dist/components/FormPage/FormPage.test.js +3 -3
- package/dist/components/FormRenderer/FormRenderer.js +44 -16
- package/dist/components/FormRenderer/FormRenderer.stories.mdx +115 -49
- package/dist/components/FormRenderer/FormRenderer.test.js +40 -0
- package/dist/components/FormRenderer/handlers/getPageId.js +1 -10
- package/dist/components/FormRenderer/handlers/getPageId.test.js +5 -31
- package/dist/components/FormRenderer/handlers/handlers.test.js +2 -2
- package/dist/components/FormRenderer/helpers/getNextPageId.js +33 -26
- package/dist/components/FormRenderer/helpers/getNextPageId.test.js +89 -7
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +27 -0
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +209 -0
- package/dist/components/FormRenderer/helpers/index.js +4 -1
- package/dist/components/PageActions/ActionButton.test.js +1 -1
- package/dist/components/PageActions/PageActions.stories.mdx +1 -1
- package/dist/components/PageActions/PageActions.test.js +5 -5
- package/dist/components/SummaryList/RowAction.js +1 -1
- package/dist/components/SummaryList/RowAction.test.js +6 -6
- package/dist/components/SummaryList/SummaryList.js +8 -5
- package/dist/components/SummaryList/SummaryList.scss +10 -2
- package/dist/components/SummaryList/SummaryList.stories.mdx +64 -10
- package/dist/components/SummaryList/SummaryList.test.js +54 -0
- package/dist/components/SummaryList/helpers/getRowActionAttributes.js +2 -2
- package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +4 -4
- package/dist/components/index.js +8 -0
- package/dist/index.js +8 -0
- package/dist/json/areYouACivilServant.json +7 -0
- package/dist/json/firstForm.json +94 -0
- package/dist/json/grade.json +108 -0
- package/dist/json/saveAndContinue.json +98 -0
- package/dist/json/team.json +17351 -0
- package/dist/json/userProfile.data.json +14 -0
- package/dist/json/userProfile.json +276 -0
- package/dist/models/ComponentTypes.js +7 -1
- package/dist/models/PageAction.js +9 -7
- package/dist/utils/CheckYourAnswers/getCYAAction.js +24 -3
- package/dist/utils/CheckYourAnswers/getCYAAction.test.js +62 -15
- package/dist/utils/CheckYourAnswers/getCYARow.js +8 -2
- package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +11 -5
- package/dist/utils/Component/getComponent.js +32 -0
- package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +75 -0
- package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +129 -0
- package/dist/utils/Component/getComponentTests/getComponent.date.test.js +129 -0
- package/dist/utils/Component/getComponentTests/getComponent.email.test.js +80 -0
- package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +33 -0
- package/dist/utils/Component/getComponentTests/getComponent.html.test.js +45 -0
- package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +31 -0
- package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +80 -0
- package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +125 -0
- package/dist/utils/Component/getComponentTests/getComponent.text.test.js +80 -0
- package/dist/utils/Component/getComponentTests/getComponent.textarea.test.js +76 -0
- package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +14 -0
- package/dist/utils/Component/isEditable.js +1 -1
- package/dist/utils/Data/refDataToOptions.js +4 -0
- package/dist/utils/Data/refDataToOptions.test.js +30 -0
- package/dist/utils/FormPage/getEditableComponents.js +28 -0
- package/dist/utils/FormPage/getEditableComponents.test.js +75 -0
- package/dist/utils/FormPage/getFormPage.js +5 -1
- package/dist/utils/FormPage/getPageActions.js +66 -0
- package/dist/utils/FormPage/getPageActions.test.js +89 -0
- package/dist/utils/FormPage/index.js +7 -1
- package/dist/utils/FormPage/showFormPage.js +81 -0
- package/dist/utils/FormPage/showFormPage.test.js +131 -0
- package/dist/utils/Validate/validateComponent.js +5 -3
- package/dist/utils/Validate/validateRequired.js +11 -0
- package/dist/utils/Validate/validateRequired.test.js +12 -0
- package/package.json +15 -10
- package/dist/index.test.js +0 -18
- package/dist/utils/Component/getComponent.test.js +0 -329
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "firstForm",
|
|
3
|
+
"version": "1",
|
|
4
|
+
"name": "firstForm",
|
|
5
|
+
"title": "First form",
|
|
6
|
+
"type": "cya",
|
|
7
|
+
"components": [
|
|
8
|
+
{
|
|
9
|
+
"id": "firstName",
|
|
10
|
+
"fieldId": "firstName",
|
|
11
|
+
"label": "First name",
|
|
12
|
+
"type": "text",
|
|
13
|
+
"required": true
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": "surname",
|
|
17
|
+
"fieldId": "surname",
|
|
18
|
+
"label": "Last name",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"required": true
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": "age",
|
|
24
|
+
"fieldId": "age",
|
|
25
|
+
"label": "Your age",
|
|
26
|
+
"type": "text",
|
|
27
|
+
"required": true
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"pages": [
|
|
31
|
+
{
|
|
32
|
+
"id": "before",
|
|
33
|
+
"name": "before",
|
|
34
|
+
"title": "Before you start",
|
|
35
|
+
"components": [
|
|
36
|
+
"This is a sample form to prove out the mechanism for save and continue.",
|
|
37
|
+
"When you click on the Start button, a new business key should be generated for this form.",
|
|
38
|
+
{
|
|
39
|
+
"type": "inset-text",
|
|
40
|
+
"content": "Generating a business key is non-reversible and cancelling the form creation will leave a gap."
|
|
41
|
+
},
|
|
42
|
+
"If you are happy to proceed, click start now."
|
|
43
|
+
],
|
|
44
|
+
"actions": [
|
|
45
|
+
{ "type": "navigate", "page": "firstName", "start": true, "label": "Start now" }
|
|
46
|
+
],
|
|
47
|
+
"show_on_cya": false
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "firstName",
|
|
51
|
+
"name": "firstName",
|
|
52
|
+
"title": "Enter first name",
|
|
53
|
+
"components": [
|
|
54
|
+
{ "use": "firstName", "label": "" }
|
|
55
|
+
],
|
|
56
|
+
"actions": [ "saveAndContinue", "saveAndReturn" ],
|
|
57
|
+
"cya_link": {
|
|
58
|
+
"page": "firstName",
|
|
59
|
+
"aria_suffix": "your first name"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"id": "surname",
|
|
64
|
+
"name": "surname",
|
|
65
|
+
"title": "Enter surname",
|
|
66
|
+
"components": [
|
|
67
|
+
{ "use": "surname", "label": "" }
|
|
68
|
+
],
|
|
69
|
+
"actions": [ "saveAndContinue", "saveAndReturn" ],
|
|
70
|
+
"cya_link": {
|
|
71
|
+
"page": "surname",
|
|
72
|
+
"aria_suffix": "your surname"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "age",
|
|
77
|
+
"name": "age",
|
|
78
|
+
"title": "Enter age",
|
|
79
|
+
"components": [
|
|
80
|
+
{ "use": "age", "label": "" }
|
|
81
|
+
],
|
|
82
|
+
"actions": [ "saveAndContinue", "saveAndReturn" ],
|
|
83
|
+
"cya_link": {
|
|
84
|
+
"page": "age",
|
|
85
|
+
"aria_suffix": "your first name"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
"cya": {
|
|
90
|
+
"actions": [
|
|
91
|
+
{ "type": "submit", "label": "Submit", "validate": true }
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": [
|
|
3
|
+
{
|
|
4
|
+
"id": "373979c1-2360-46be-b712-0409ac068059",
|
|
5
|
+
"name": "SCS4",
|
|
6
|
+
"parentgradetypeid": null,
|
|
7
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
8
|
+
"validto": null,
|
|
9
|
+
"updatedby": null
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"id": "36c80dfe-0aae-455b-9445-2e1c09dcafdc",
|
|
13
|
+
"name": "SCS3",
|
|
14
|
+
"parentgradetypeid": "373979c1-2360-46be-b712-0409ac068059",
|
|
15
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
16
|
+
"validto": null,
|
|
17
|
+
"updatedby": null
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "1b041cda-b151-4769-b76a-d42d67b0b960",
|
|
21
|
+
"name": "Senior Director / SCS2",
|
|
22
|
+
"parentgradetypeid": "36c80dfe-0aae-455b-9445-2e1c09dcafdc",
|
|
23
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
24
|
+
"validto": null,
|
|
25
|
+
"updatedby": null
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": "172de41d-f7b0-4be9-b7e8-0cf4f1a1342f",
|
|
29
|
+
"name": "Director / SCS1",
|
|
30
|
+
"parentgradetypeid": "1b041cda-b151-4769-b76a-d42d67b0b960",
|
|
31
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
32
|
+
"validto": null,
|
|
33
|
+
"updatedby": null
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "39e18b45-0358-4a45-83ec-5a70b74641e8",
|
|
37
|
+
"name": "Deputy Director / Grade 6",
|
|
38
|
+
"parentgradetypeid": "172de41d-f7b0-4be9-b7e8-0cf4f1a1342f",
|
|
39
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
40
|
+
"validto": null,
|
|
41
|
+
"updatedby": null
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "44855085-a36b-42e5-b805-f4ebe209ecf2",
|
|
45
|
+
"name": "Assistant Director / Grade 7",
|
|
46
|
+
"parentgradetypeid": "39e18b45-0358-4a45-83ec-5a70b74641e8",
|
|
47
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
48
|
+
"validto": null,
|
|
49
|
+
"updatedby": null
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "4fad1115-7d12-4b6f-8d8a-97dbe469a346",
|
|
53
|
+
"name": "Senior Officer / Senior Executive Officer",
|
|
54
|
+
"parentgradetypeid": "44855085-a36b-42e5-b805-f4ebe209ecf2",
|
|
55
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
56
|
+
"validto": null,
|
|
57
|
+
"updatedby": null
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "b512288d-95e3-4f60-ad4c-4cdfab68d841",
|
|
61
|
+
"name": "Higher Officer / Higher Executive Officer",
|
|
62
|
+
"parentgradetypeid": "4fad1115-7d12-4b6f-8d8a-97dbe469a346",
|
|
63
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
64
|
+
"validto": null,
|
|
65
|
+
"updatedby": null
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"id": "1c140011-46ad-4a5d-af25-e80a6fcdcdba",
|
|
69
|
+
"name": "Officer / Executive Officer",
|
|
70
|
+
"parentgradetypeid": "b512288d-95e3-4f60-ad4c-4cdfab68d841",
|
|
71
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
72
|
+
"validto": null,
|
|
73
|
+
"updatedby": null
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "02de92d8-aad1-4663-a37f-a87012f60f1b",
|
|
77
|
+
"name": "Assistant Officer / Administrative Officer",
|
|
78
|
+
"parentgradetypeid": "1c140011-46ad-4a5d-af25-e80a6fcdcdba",
|
|
79
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
80
|
+
"validto": null,
|
|
81
|
+
"updatedby": null
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"id": "9910a29d-7fbb-451d-8729-f39f4373bbcc",
|
|
85
|
+
"name": "Assistant Office / Messenger",
|
|
86
|
+
"parentgradetypeid": "02de92d8-aad1-4663-a37f-a87012f60f1b",
|
|
87
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
88
|
+
"validto": null,
|
|
89
|
+
"updatedby": null
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"id": "073b92f8-7208-4026-a090-906c276079f1",
|
|
93
|
+
"name": "Contractor",
|
|
94
|
+
"parentgradetypeid": null,
|
|
95
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
96
|
+
"validto": null,
|
|
97
|
+
"updatedby": null
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"id": "c27cf914-0b97-4c4e-bb2d-2ae4b886baa5",
|
|
101
|
+
"name": "Agency Staff",
|
|
102
|
+
"parentgradetypeid": null,
|
|
103
|
+
"validfrom": "2019-01-01T00:01:00.000Z",
|
|
104
|
+
"validto": null,
|
|
105
|
+
"updatedby": null
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "saveAndContinue",
|
|
3
|
+
"version": "1",
|
|
4
|
+
"name": "saveAndContinue",
|
|
5
|
+
"title": "Save and continue example",
|
|
6
|
+
"type": "hub-and-spoke",
|
|
7
|
+
"components": [
|
|
8
|
+
{
|
|
9
|
+
"id": "firstName",
|
|
10
|
+
"fieldId": "firstName",
|
|
11
|
+
"label": "First name",
|
|
12
|
+
"type": "text",
|
|
13
|
+
"required": true
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"id": "surname",
|
|
17
|
+
"fieldId": "surname",
|
|
18
|
+
"label": "Last name",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"required": true
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": "email",
|
|
24
|
+
"fieldId": "email",
|
|
25
|
+
"label": "Your email address",
|
|
26
|
+
"type": "email",
|
|
27
|
+
"required": true
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "location",
|
|
31
|
+
"fieldId": "location",
|
|
32
|
+
"label": "Incident location",
|
|
33
|
+
"type": "text",
|
|
34
|
+
"required": true
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "when",
|
|
38
|
+
"fieldId": "when",
|
|
39
|
+
"label": "Incident date and start time",
|
|
40
|
+
"type": "text",
|
|
41
|
+
"required": true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"id": "seizedItems",
|
|
45
|
+
"fieldId": "seizedItems",
|
|
46
|
+
"type": "collection",
|
|
47
|
+
"required": true,
|
|
48
|
+
"components": [
|
|
49
|
+
{ "use": "type" },
|
|
50
|
+
{ "use": "description" },
|
|
51
|
+
{
|
|
52
|
+
"id": "status",
|
|
53
|
+
"fieldId": "status",
|
|
54
|
+
"label": "What is the seized status of this item?",
|
|
55
|
+
"type": "radios",
|
|
56
|
+
"required": true
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"_description": "Required means at least 1 item"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"pages": [
|
|
63
|
+
{
|
|
64
|
+
"id": "details",
|
|
65
|
+
"name": "details",
|
|
66
|
+
"title": "Your details",
|
|
67
|
+
"components": [
|
|
68
|
+
{ "use": "firstName" },
|
|
69
|
+
{ "use": "surname" },
|
|
70
|
+
{ "use": "email" }
|
|
71
|
+
],
|
|
72
|
+
"actions": [
|
|
73
|
+
{ "type": "saveDraft", "validate": true, "label": "Save and continue" },
|
|
74
|
+
{ "type": "saveAndReturn", "validate": true, "label": "Save and return later", "classModifiers": "secondary" }
|
|
75
|
+
],
|
|
76
|
+
"cya_link": {
|
|
77
|
+
"page": "details",
|
|
78
|
+
"aria_suffix": "your details"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"id": "where-and-when",
|
|
83
|
+
"name": "where-and-when",
|
|
84
|
+
"title": "Where and when",
|
|
85
|
+
"components": [
|
|
86
|
+
{ "use": "location" },
|
|
87
|
+
{ "use": "when" }
|
|
88
|
+
],
|
|
89
|
+
"actions": ["submit"],
|
|
90
|
+
"cya_link": {
|
|
91
|
+
"page": "where-and-when",
|
|
92
|
+
"aria_suffix": "where and when"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"hub": { "format": "CYA" },
|
|
97
|
+
"cya": {}
|
|
98
|
+
}
|