@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.
Files changed (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -0
  3. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +16 -5
  4. package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +199 -79
  5. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +44 -0
  6. package/dist/components/FormPage/FormPage.js +8 -2
  7. package/dist/components/FormPage/FormPage.test.js +3 -3
  8. package/dist/components/FormRenderer/FormRenderer.js +44 -16
  9. package/dist/components/FormRenderer/FormRenderer.stories.mdx +115 -49
  10. package/dist/components/FormRenderer/FormRenderer.test.js +40 -0
  11. package/dist/components/FormRenderer/handlers/getPageId.js +1 -10
  12. package/dist/components/FormRenderer/handlers/getPageId.test.js +5 -31
  13. package/dist/components/FormRenderer/handlers/handlers.test.js +2 -2
  14. package/dist/components/FormRenderer/helpers/getNextPageId.js +33 -26
  15. package/dist/components/FormRenderer/helpers/getNextPageId.test.js +89 -7
  16. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +27 -0
  17. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +209 -0
  18. package/dist/components/FormRenderer/helpers/index.js +4 -1
  19. package/dist/components/PageActions/ActionButton.test.js +1 -1
  20. package/dist/components/PageActions/PageActions.stories.mdx +1 -1
  21. package/dist/components/PageActions/PageActions.test.js +5 -5
  22. package/dist/components/SummaryList/RowAction.js +1 -1
  23. package/dist/components/SummaryList/RowAction.test.js +6 -6
  24. package/dist/components/SummaryList/SummaryList.js +8 -5
  25. package/dist/components/SummaryList/SummaryList.scss +10 -2
  26. package/dist/components/SummaryList/SummaryList.stories.mdx +64 -10
  27. package/dist/components/SummaryList/SummaryList.test.js +54 -0
  28. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +2 -2
  29. package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +4 -4
  30. package/dist/components/index.js +8 -0
  31. package/dist/index.js +8 -0
  32. package/dist/json/areYouACivilServant.json +7 -0
  33. package/dist/json/firstForm.json +94 -0
  34. package/dist/json/grade.json +108 -0
  35. package/dist/json/saveAndContinue.json +98 -0
  36. package/dist/json/team.json +17351 -0
  37. package/dist/json/userProfile.data.json +14 -0
  38. package/dist/json/userProfile.json +276 -0
  39. package/dist/models/ComponentTypes.js +7 -1
  40. package/dist/models/PageAction.js +9 -7
  41. package/dist/utils/CheckYourAnswers/getCYAAction.js +24 -3
  42. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +62 -15
  43. package/dist/utils/CheckYourAnswers/getCYARow.js +8 -2
  44. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +11 -5
  45. package/dist/utils/Component/getComponent.js +32 -0
  46. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +75 -0
  47. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +129 -0
  48. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +129 -0
  49. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +80 -0
  50. package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +33 -0
  51. package/dist/utils/Component/getComponentTests/getComponent.html.test.js +45 -0
  52. package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +31 -0
  53. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +80 -0
  54. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +125 -0
  55. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +80 -0
  56. package/dist/utils/Component/getComponentTests/getComponent.textarea.test.js +76 -0
  57. package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +14 -0
  58. package/dist/utils/Component/isEditable.js +1 -1
  59. package/dist/utils/Data/refDataToOptions.js +4 -0
  60. package/dist/utils/Data/refDataToOptions.test.js +30 -0
  61. package/dist/utils/FormPage/getEditableComponents.js +28 -0
  62. package/dist/utils/FormPage/getEditableComponents.test.js +75 -0
  63. package/dist/utils/FormPage/getFormPage.js +5 -1
  64. package/dist/utils/FormPage/getPageActions.js +66 -0
  65. package/dist/utils/FormPage/getPageActions.test.js +89 -0
  66. package/dist/utils/FormPage/index.js +7 -1
  67. package/dist/utils/FormPage/showFormPage.js +81 -0
  68. package/dist/utils/FormPage/showFormPage.test.js +131 -0
  69. package/dist/utils/Validate/validateComponent.js +5 -3
  70. package/dist/utils/Validate/validateRequired.js +11 -0
  71. package/dist/utils/Validate/validateRequired.test.js +12 -0
  72. package/package.json +15 -10
  73. package/dist/index.test.js +0 -18
  74. package/dist/utils/Component/getComponent.test.js +0 -329
@@ -0,0 +1,14 @@
1
+ {
2
+ "urls": {
3
+ "refData": "/ref-data"
4
+ },
5
+ "currentUser": {
6
+ "givenName": "John",
7
+ "familyName": "Smith"
8
+ },
9
+ "areYouACivilServant": "yes",
10
+ "userDetails": {
11
+ "linemanagerEmail": "line.manager@digital.homeoffice.gov.uk",
12
+ "delegateEmails": "del.egate@digital.homeoffice.gov.uk"
13
+ }
14
+ }
@@ -0,0 +1,276 @@
1
+ {
2
+ "id": "userProfile",
3
+ "version": "1",
4
+ "name": "userProfile",
5
+ "title": "Your profile",
6
+ "type": "hub-and-spoke",
7
+ "components": [
8
+ {
9
+ "id": "firstName",
10
+ "fieldId": "firstName",
11
+ "label": "First name",
12
+ "type": "text",
13
+ "readonly": true,
14
+ "source": {
15
+ "field": "currentUser.givenName"
16
+ }
17
+ },
18
+ {
19
+ "id": "surname",
20
+ "fieldId": "surname",
21
+ "label": "Last name",
22
+ "type": "text",
23
+ "readonly": true,
24
+ "source": {
25
+ "field": "currentUser.familyName"
26
+ }
27
+ },
28
+ {
29
+ "id": "areYouACivilServant",
30
+ "fieldId": "areYouACivilServant",
31
+ "label": "Are you a civil servant?",
32
+ "type": "radios",
33
+ "required": true,
34
+ "data": {
35
+ "url": "${urls.refData}/areYouACivilServant"
36
+ }
37
+ },
38
+ {
39
+ "id": "staffGradeId",
40
+ "fieldId": "staffGradeId",
41
+ "label": "Grade",
42
+ "hint": "We use this to assign you tasks",
43
+ "type": "radios",
44
+ "required": true,
45
+ "data": {
46
+ "url": "${urls.refData}/grade"
47
+ },
48
+ "source": {
49
+ "field": "userDetails.gradeid"
50
+ },
51
+ "show_when": {
52
+ "field": "areYouACivilServant",
53
+ "op": "eq",
54
+ "value": "yes"
55
+ }
56
+ },
57
+ {
58
+ "id": "team",
59
+ "fieldId": "team",
60
+ "label": "Team",
61
+ "hint": "We use this to assign you tasks",
62
+ "type": "autocomplete",
63
+ "required": true,
64
+ "item": { "value": "id", "label": "name" },
65
+ "data": {
66
+ "url": "${urls.refData}/team"
67
+ },
68
+ "displayMenu": "inline",
69
+ "source": {
70
+ "field": "userDetails.defaultteam"
71
+ }
72
+ },
73
+ {
74
+ "id": "linemanagerEmail",
75
+ "fieldId": "linemanagerEmail",
76
+ "label": "Line manager email",
77
+ "hint": "Must be a homeoffice.gov.uk or digital.homeoffice.gov.uk address",
78
+ "type": "email",
79
+ "format": {
80
+ "type": "lowercase",
81
+ "on": "submit"
82
+ },
83
+ "required": true,
84
+ "source": {
85
+ "field": "userDetails.linemanagerEmail"
86
+ }
87
+ },
88
+ {
89
+ "id": "delegateEmails",
90
+ "fieldId": "delegateEmails",
91
+ "label": "Delegate email",
92
+ "hint": "Must be a homeoffice.gov.uk or digital.homeoffice.gov.uk address",
93
+ "type": "email",
94
+ "format": {
95
+ "type": "lowercase",
96
+ "on": "submit"
97
+ },
98
+ "required": true,
99
+ "source": {
100
+ "field": "userDetails.delegateEmails"
101
+ },
102
+ "show_when": [
103
+ {
104
+ "field": "areYouACivilServant",
105
+ "op": "eq",
106
+ "value": "yes"
107
+ },
108
+ {
109
+ "field": "staffGradeId",
110
+ "op": "in",
111
+ "values": [
112
+ "373979c1-2360-46be-b712-0409ac068059",
113
+ "36c80dfe-0aae-455b-9445-2e1c09dcafdc",
114
+ "1b041cda-b151-4769-b76a-d42d67b0b960",
115
+ "172de41d-f7b0-4be9-b7e8-0cf4f1a1342f",
116
+ "39e18b45-0358-4a45-83ec-5a70b74641e8"
117
+ ]
118
+ }
119
+ ]
120
+ }
121
+ ],
122
+ "pages": [
123
+ {
124
+ "id": "names",
125
+ "name": "names",
126
+ "components": [
127
+ { "use": "firstName" },
128
+ { "use": "surname" }
129
+ ]
130
+ },
131
+ {
132
+ "id": "civil-servant-status",
133
+ "name": "civil-servant-status",
134
+ "title": "Are you a civil servant?",
135
+ "components": [
136
+ {
137
+ "use": "areYouACivilServant",
138
+ "label": ""
139
+ }
140
+ ],
141
+ "actions": ["submit"],
142
+ "cya_link": {
143
+ "page": "civil-servant-status",
144
+ "aria_suffix": "civil servant status"
145
+ }
146
+ },
147
+ {
148
+ "id": "grade",
149
+ "name": "grade",
150
+ "title": "What's your grade?",
151
+ "components": [
152
+ {
153
+ "use": "staffGradeId",
154
+ "label": ""
155
+ }
156
+ ],
157
+ "actions": ["submit"],
158
+ "cya_link": {
159
+ "page": "grade",
160
+ "aria_suffix": "grade"
161
+ }
162
+ },
163
+ {
164
+ "id": "team-name",
165
+ "name": "team-name",
166
+ "title": "What's your team name?",
167
+ "components": [
168
+ {
169
+ "use": "team",
170
+ "label": ""
171
+ }
172
+ ],
173
+ "actions": ["submit"],
174
+ "cya_link": {
175
+ "page": "team-name",
176
+ "aria_suffix": "teams"
177
+ }
178
+ },
179
+ {
180
+ "id": "add-or-change-line-manager",
181
+ "name": "add-or-change-line-manager",
182
+ "title": "Add or change a line manager",
183
+ "components": [
184
+ "Your line manager will need to review some of your forms. It’s important to keep their details up-to-date.",
185
+ "An email will be sent to your line manager to ask if they want to approve your request to add them.",
186
+ {
187
+ "type": "inset-text",
188
+ "content": "The changes will show in your profile when they approve your request."
189
+ },
190
+ {
191
+ "type": "heading",
192
+ "size": "m",
193
+ "content": "Mandatory declarations"
194
+ },
195
+ "Mandatory declarations will not go to your line manager until they have approved your request."
196
+ ],
197
+ "actions": [
198
+ {
199
+ "type": "navigate",
200
+ "page": "line-manager-email"
201
+ }
202
+ ],
203
+ "show_on_cya": false
204
+ },
205
+ {
206
+ "id": "line-manager-email",
207
+ "name": "line-manager-email",
208
+ "title": "What’s your line manager’s email address?",
209
+ "components": [
210
+ {
211
+ "use": "linemanagerEmail"
212
+ }
213
+ ],
214
+ "actions": ["submit"],
215
+ "cya_link": {
216
+ "page": "add-or-change-line-manager",
217
+ "aria_suffix": "line manager email address"
218
+ }
219
+ },
220
+ {
221
+ "id": "add-or-change-delegate",
222
+ "name": "add-or-change-delegate",
223
+ "title": "Add or change a delegate",
224
+ "components": [
225
+ "A delegate can review a mandatory declaration on your behalf.",
226
+ "An email will be sent to the delegate to ask if they want to approve your request.",
227
+ {
228
+ "type": "inset-text",
229
+ "content": "The changes will show in your profile when they approve your request."
230
+ }
231
+ ],
232
+ "actions": [
233
+ {
234
+ "type": "navigate",
235
+ "page": "delegate-email"
236
+ }
237
+ ],
238
+ "show_on_cya": false
239
+ },
240
+ {
241
+ "id": "delegate-email",
242
+ "name": "delegate-email",
243
+ "title": "What’s your delegate's email address?",
244
+ "components": [
245
+ {
246
+ "use": "delegateEmails",
247
+ "label": "Delegate email address"
248
+ }
249
+ ],
250
+ "actions": ["submit"],
251
+ "cya_link": {
252
+ "page": "add-or-change-delegate"
253
+ },
254
+ "show_when": [
255
+ {
256
+ "field": "areYouACivilServant",
257
+ "op": "eq",
258
+ "value": "yes"
259
+ },
260
+ {
261
+ "field": "staffGradeId",
262
+ "op": "in",
263
+ "values": [
264
+ "373979c1-2360-46be-b712-0409ac068059",
265
+ "36c80dfe-0aae-455b-9445-2e1c09dcafdc",
266
+ "1b041cda-b151-4769-b76a-d42d67b0b960",
267
+ "172de41d-f7b0-4be9-b7e8-0cf4f1a1342f",
268
+ "39e18b45-0358-4a45-83ec-5a70b74641e8"
269
+ ]
270
+ }
271
+ ]
272
+ }
273
+ ],
274
+ "hub": { "format": "CYA" },
275
+ "cya": { "hide_page_titles": true, "hide_actions": true }
276
+ }
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var TYPE_AUTOCOMPLETE = 'autocomplete';
8
+ var TYPE_CHECKBOXES = 'checkboxes';
9
+ var TYPE_DATE = 'date';
8
10
  var TYPE_EMAIL = 'email';
9
11
  var TYPE_HEADING = 'heading';
10
12
  var TYPE_HTML = 'html';
@@ -12,15 +14,19 @@ var TYPE_INSET_TEXT = 'inset-text';
12
14
  var TYPE_PHONE_NUMBER = 'phone-number';
13
15
  var TYPE_RADIOS = 'radios';
14
16
  var TYPE_TEXT = 'text';
17
+ var TYPE_TEXT_AREA = 'textarea';
15
18
  var ComponentTypes = {
16
19
  AUTOCOMPLETE: TYPE_AUTOCOMPLETE,
20
+ CHECKBOXES: TYPE_CHECKBOXES,
21
+ DATE: TYPE_DATE,
17
22
  EMAIL: TYPE_EMAIL,
18
23
  HEADING: TYPE_HEADING,
19
24
  HTML: TYPE_HTML,
20
25
  INSET_TEXT: TYPE_INSET_TEXT,
21
26
  PHONE_NUMBER: TYPE_PHONE_NUMBER,
22
27
  RADIOS: TYPE_RADIOS,
23
- TEXT: TYPE_TEXT
28
+ TEXT: TYPE_TEXT,
29
+ TEXT_AREA: TYPE_TEXT_AREA
24
30
  };
25
31
  var _default = ComponentTypes;
26
32
  exports.default = _default;
@@ -9,19 +9,18 @@ var _DefaultPageActions;
9
9
 
10
10
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
11
 
12
- var TYPE_SUBMIT = 'submit';
12
+ var TYPE_NAVIGATE = 'navigate';
13
13
  var TYPE_SAVE_AND_CONTINUE = 'saveAndContinue';
14
14
  var TYPE_SAVE_AND_RETURN = 'saveAndReturn';
15
+ var TYPE_SUBMIT = 'submit';
15
16
  var PageActionTypes = {
16
- SUBMIT: TYPE_SUBMIT,
17
+ NAVIGATE: TYPE_NAVIGATE,
17
18
  SAVE_AND_CONTINUE: TYPE_SAVE_AND_CONTINUE,
18
- SAVE_AND_RETURN: TYPE_SAVE_AND_RETURN
19
+ SAVE_AND_RETURN: TYPE_SAVE_AND_RETURN,
20
+ SUBMIT: TYPE_SUBMIT
19
21
  };
20
22
  exports.PageActionTypes = PageActionTypes;
21
- var DefaultPageActions = (_DefaultPageActions = {}, _defineProperty(_DefaultPageActions, TYPE_SUBMIT, {
22
- type: TYPE_SUBMIT,
23
- validate: true
24
- }), _defineProperty(_DefaultPageActions, TYPE_SAVE_AND_CONTINUE, {
23
+ var DefaultPageActions = (_DefaultPageActions = {}, _defineProperty(_DefaultPageActions, TYPE_NAVIGATE, undefined), _defineProperty(_DefaultPageActions, TYPE_SAVE_AND_CONTINUE, {
25
24
  type: TYPE_SAVE_AND_CONTINUE,
26
25
  validate: true,
27
26
  label: 'Save and continue'
@@ -30,6 +29,9 @@ var DefaultPageActions = (_DefaultPageActions = {}, _defineProperty(_DefaultPage
30
29
  validate: false,
31
30
  label: 'Save and return later',
32
31
  classModifiers: 'secondary'
32
+ }), _defineProperty(_DefaultPageActions, TYPE_SUBMIT, {
33
+ type: TYPE_SUBMIT,
34
+ validate: true
33
35
  }), _DefaultPageActions);
34
36
  exports.DefaultPageActions = DefaultPageActions;
35
37
  var PageAction = {
@@ -5,19 +5,40 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ var getPageFromCYALink = function getPageFromCYALink(link) {
9
+ if (link.page) {
10
+ return link.page;
11
+ }
12
+
13
+ var url = link.href || link.url;
14
+
15
+ if (url) {
16
+ return url.split('/').pop();
17
+ }
18
+
19
+ return undefined;
20
+ };
8
21
  /**
9
22
  * Gets an action object, configured appropriately for a Check your answers component.
10
23
  *
11
24
  * @param {boolean} readonly Whether or not the component is readonly.
12
- * @param {object} cya_link A configuration object for any link to show.
25
+ * @param {object} page A configuration object for the page to link to.
13
26
  * @param {Function} onAction A function to invoke if the link is clicked.
14
27
  *
15
28
  * @returns An action object for a Check your answers row.
29
+ * @description
30
+ * `cya_link.href` and `cya_link.url` have been deprecated in favour of `cya_link.page` but this
31
+ * method will convert both by taking the final part of the relative path:
32
+ * - `href: '/bravo'` => `page: 'bravo'`
16
33
  */
17
- var getCYAAction = function getCYAAction(readonly, cya_link, onAction) {
34
+
35
+
36
+ var getCYAAction = function getCYAAction(readonly, page, onAction) {
37
+ var cya_link = page === null || page === void 0 ? void 0 : page.cya_link;
38
+
18
39
  if (readonly !== true && cya_link) {
19
40
  return {
20
- href: cya_link.url || '#',
41
+ page: getPageFromCYALink(cya_link) || page.id || '#',
21
42
  label: cya_link.label || 'Change',
22
43
  aria_suffix: cya_link.aria_suffix,
23
44
  onAction: onAction
@@ -8,33 +8,80 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
8
8
  describe('utils', function () {
9
9
  describe('CheckYourAnswers', function () {
10
10
  describe('getCYAAction', function () {
11
+ var getPage = function getPage(cya_link, id) {
12
+ return {
13
+ cya_link: cya_link,
14
+ id: id
15
+ };
16
+ };
17
+
11
18
  it('should return null if readonly', function () {
12
19
  expect((0, _getCYAAction.default)(true, {}, function () {})).toBeNull();
13
20
  });
14
21
  it('should return null if there is no cya_link', function () {
15
22
  expect((0, _getCYAAction.default)(false, null, function () {})).toBeNull();
16
23
  });
17
- it('should return a default action if the cya_link is empty', function () {
24
+ it('should return a default action if the cya_link is empty and the page has no id', function () {
25
+ var CYA_LINK = {};
26
+
27
+ var ON_ACTION = function ON_ACTION() {};
28
+
29
+ expect((0, _getCYAAction.default)(false, getPage(CYA_LINK), ON_ACTION)).toEqual({
30
+ page: '#',
31
+ label: 'Change',
32
+ onAction: ON_ACTION
33
+ });
34
+ });
35
+ it('should return a default action if the cya_link is empty but the page has an id', function () {
36
+ var PAGE_ID = 'page-id';
18
37
  var CYA_LINK = {};
19
38
 
20
39
  var ON_ACTION = function ON_ACTION() {};
21
40
 
22
- expect((0, _getCYAAction.default)(false, CYA_LINK, ON_ACTION)).toEqual({
23
- href: '#',
41
+ expect((0, _getCYAAction.default)(false, getPage(CYA_LINK, PAGE_ID), ON_ACTION)).toEqual({
42
+ page: PAGE_ID,
43
+ label: 'Change',
44
+ onAction: ON_ACTION
45
+ });
46
+ });
47
+ it('should use page specified in cya_link', function () {
48
+ var PAGE = 'alpha';
49
+ var CYA_LINK = {
50
+ page: PAGE
51
+ };
52
+
53
+ var ON_ACTION = function ON_ACTION() {};
54
+
55
+ expect((0, _getCYAAction.default)(false, getPage(CYA_LINK), ON_ACTION)).toEqual({
56
+ page: PAGE,
57
+ label: 'Change',
58
+ onAction: ON_ACTION
59
+ });
60
+ });
61
+ it('should convert an href specified in cya_link', function () {
62
+ var HREF = '/alpha/bravo';
63
+ var CYA_LINK = {
64
+ href: HREF
65
+ };
66
+
67
+ var ON_ACTION = function ON_ACTION() {};
68
+
69
+ expect((0, _getCYAAction.default)(false, getPage(CYA_LINK), ON_ACTION)).toEqual({
70
+ page: 'bravo',
24
71
  label: 'Change',
25
72
  onAction: ON_ACTION
26
73
  });
27
74
  });
28
- it('should use url specified in cya_link', function () {
29
- var URL = 'https://fake.url.com/something';
75
+ it('should convert a url specified in cya_link', function () {
76
+ var URL = '/alpha/bravo';
30
77
  var CYA_LINK = {
31
78
  url: URL
32
79
  };
33
80
 
34
81
  var ON_ACTION = function ON_ACTION() {};
35
82
 
36
- expect((0, _getCYAAction.default)(false, CYA_LINK, ON_ACTION)).toEqual({
37
- href: URL,
83
+ expect((0, _getCYAAction.default)(false, getPage(CYA_LINK), ON_ACTION)).toEqual({
84
+ page: 'bravo',
38
85
  label: 'Change',
39
86
  onAction: ON_ACTION
40
87
  });
@@ -47,8 +94,8 @@ describe('utils', function () {
47
94
 
48
95
  var ON_ACTION = function ON_ACTION() {};
49
96
 
50
- expect((0, _getCYAAction.default)(false, CYA_LINK, ON_ACTION)).toEqual({
51
- href: '#',
97
+ expect((0, _getCYAAction.default)(false, getPage(CYA_LINK), ON_ACTION)).toEqual({
98
+ page: '#',
52
99
  label: LABEL,
53
100
  onAction: ON_ACTION
54
101
  });
@@ -61,27 +108,27 @@ describe('utils', function () {
61
108
 
62
109
  var ON_ACTION = function ON_ACTION() {};
63
110
 
64
- expect((0, _getCYAAction.default)(false, CYA_LINK, ON_ACTION)).toEqual({
65
- href: '#',
111
+ expect((0, _getCYAAction.default)(false, getPage(CYA_LINK), ON_ACTION)).toEqual({
112
+ page: '#',
66
113
  label: 'Change',
67
114
  aria_suffix: ARIA_SUFFIX,
68
115
  onAction: ON_ACTION
69
116
  });
70
117
  });
71
118
  it('should use all properties specified in cya_link', function () {
72
- var URL = 'https://fake.url.com/something';
119
+ var PAGE = 'alpha';
73
120
  var LABEL = 'Alpha Bravo Charlie';
74
121
  var ARIA_SUFFIX = 'This is hidden text';
75
122
  var CYA_LINK = {
76
123
  label: LABEL,
77
- url: URL,
124
+ page: PAGE,
78
125
  aria_suffix: ARIA_SUFFIX
79
126
  };
80
127
 
81
128
  var ON_ACTION = function ON_ACTION() {};
82
129
 
83
- expect((0, _getCYAAction.default)(false, CYA_LINK, ON_ACTION)).toEqual({
84
- href: URL,
130
+ expect((0, _getCYAAction.default)(false, getPage(CYA_LINK), ON_ACTION)).toEqual({
131
+ page: PAGE,
85
132
  label: LABEL,
86
133
  aria_suffix: ARIA_SUFFIX,
87
134
  onAction: ON_ACTION
@@ -23,13 +23,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
23
23
  * @returns A configuration object for a Check your answers row.
24
24
  */
25
25
  var getCYARow = function getCYARow(page, component, onAction) {
26
+ var value = '';
27
+
28
+ if (page.formData && component.fieldId) {
29
+ value = page.formData[component.fieldId];
30
+ }
31
+
26
32
  return {
27
33
  pageId: page.id,
28
34
  fieldId: component.fieldId,
29
35
  key: component.label || component.cya_label,
30
36
  component: _Component.default.editable(component) ? component : undefined,
31
- value: page.formData[component.fieldId] || '',
32
- action: (0, _getCYAAction.default)(component.readonly, page.cya_link, onAction)
37
+ value: value || '',
38
+ action: (0, _getCYAAction.default)(component.readonly, page, onAction)
33
39
  };
34
40
  };
35
41
 
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ var _FormPage = _interopRequireDefault(require("../FormPage"));
9
+
8
10
  var _getCYARow = _interopRequireDefault(require("./getCYARow"));
9
11
 
10
12
  var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
@@ -22,11 +24,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
22
24
  * @returns An array of configuration objects for Check your answers rows.
23
25
  */
24
26
  var getCYARowsForPage = function getCYARowsForPage(page, onAction) {
25
- return page.components.filter(function (c) {
26
- return (0, _showComponentCYA.default)(c, page.formData);
27
- }).map(function (component) {
28
- return (0, _getCYARow.default)(page, component, onAction);
29
- });
27
+ if (_FormPage.default.show(page, page.formData)) {
28
+ return page.components.filter(function (c) {
29
+ return (0, _showComponentCYA.default)(c, page.formData);
30
+ }).map(function (component) {
31
+ return (0, _getCYARow.default)(page, component, onAction);
32
+ });
33
+ }
34
+
35
+ return [];
30
36
  };
31
37
 
32
38
  var _default = getCYARowsForPage;
@@ -39,6 +39,24 @@ var getAutocomplete = function getAutocomplete(config) {
39
39
  }));
40
40
  };
41
41
 
42
+ var getCheckboxes = function getCheckboxes(config) {
43
+ var options = [];
44
+
45
+ _Data.default.getOptions(config, function (val) {
46
+ options = val;
47
+ });
48
+
49
+ var attrs = (0, _cleanAttributes.default)(config);
50
+ return /*#__PURE__*/_react.default.createElement(_copReactComponents.Checkboxes, _extends({}, attrs, {
51
+ options: options
52
+ }));
53
+ };
54
+
55
+ var getDate = function getDate(config) {
56
+ var attrs = (0, _cleanAttributes.default)(config);
57
+ return /*#__PURE__*/_react.default.createElement(_copReactComponents.DateInput, attrs);
58
+ };
59
+
42
60
  var getHeading = function getHeading(config) {
43
61
  var attrs = (0, _cleanAttributes.default)(config);
44
62
  return /*#__PURE__*/_react.default.createElement(_copReactComponents.Heading, attrs, config.content);
@@ -67,6 +85,11 @@ var getRadios = function getRadios(config) {
67
85
  }));
68
86
  };
69
87
 
88
+ var getTextArea = function getTextArea(config) {
89
+ var attrs = (0, _cleanAttributes.default)(config);
90
+ return /*#__PURE__*/_react.default.createElement(_copReactComponents.TextArea, attrs);
91
+ };
92
+
70
93
  var getTextInput = function getTextInput(config) {
71
94
  var attrs = (0, _cleanAttributes.default)(config);
72
95
  return /*#__PURE__*/_react.default.createElement(_copReactComponents.TextInput, attrs);
@@ -88,12 +111,21 @@ var getComponentByType = function getComponentByType(config) {
88
111
  case _models.ComponentTypes.PHONE_NUMBER:
89
112
  return getTextInput(config);
90
113
 
114
+ case _models.ComponentTypes.TEXT_AREA:
115
+ return getTextArea(config);
116
+
91
117
  case _models.ComponentTypes.AUTOCOMPLETE:
92
118
  return getAutocomplete(config);
93
119
 
94
120
  case _models.ComponentTypes.RADIOS:
95
121
  return getRadios(config);
96
122
 
123
+ case _models.ComponentTypes.DATE:
124
+ return getDate(config);
125
+
126
+ case _models.ComponentTypes.CHECKBOXES:
127
+ return getCheckboxes(config);
128
+
97
129
  default:
98
130
  {
99
131
  return null;