@ukhomeoffice/cop-react-form-renderer 4.18.0 → 5.0.0-alpha

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 (307) hide show
  1. package/dist/components/CheckYourAnswers/Answer.js +1 -14
  2. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +19 -57
  3. package/dist/components/CheckYourAnswers/index.js +0 -3
  4. package/dist/components/CollectionPage/CollectionPage.js +8 -38
  5. package/dist/components/CollectionPage/index.js +0 -3
  6. package/dist/components/FormComponent/Collection.js +13 -54
  7. package/dist/components/FormComponent/Container.js +6 -30
  8. package/dist/components/FormComponent/FormComponent.js +14 -57
  9. package/dist/components/FormComponent/helpers/addLabel.js +4 -7
  10. package/dist/components/FormComponent/helpers/getComponentDisabled.js +0 -4
  11. package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +0 -2
  12. package/dist/components/FormComponent/helpers/getComponentError.js +0 -6
  13. package/dist/components/FormComponent/helpers/getComponentError.test.js +0 -2
  14. package/dist/components/FormComponent/helpers/index.js +0 -4
  15. package/dist/components/FormComponent/index.js +0 -3
  16. package/dist/components/FormPage/FormPage.js +14 -45
  17. package/dist/components/FormPage/index.js +0 -3
  18. package/dist/components/FormRenderer/FormRenderer.js +106 -189
  19. package/dist/components/FormRenderer/handlers/cyaAction.js +0 -5
  20. package/dist/components/FormRenderer/handlers/getPageId.js +0 -2
  21. package/dist/components/FormRenderer/handlers/getPageId.test.js +1 -2
  22. package/dist/components/FormRenderer/handlers/handlers.test.js +1 -18
  23. package/dist/components/FormRenderer/handlers/index.js +0 -5
  24. package/dist/components/FormRenderer/handlers/navigate.js +0 -5
  25. package/dist/components/FormRenderer/handlers/submissionError.js +0 -2
  26. package/dist/components/FormRenderer/helpers/canActionProceed.js +0 -3
  27. package/dist/components/FormRenderer/helpers/canActionProceed.test.js +1 -3
  28. package/dist/components/FormRenderer/helpers/canCYASubmit.js +0 -2
  29. package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +1 -5
  30. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +0 -5
  31. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +1 -2
  32. package/dist/components/FormRenderer/helpers/getCYA.js +0 -6
  33. package/dist/components/FormRenderer/helpers/getCYA.test.js +1 -3
  34. package/dist/components/FormRenderer/helpers/getFormState.js +0 -5
  35. package/dist/components/FormRenderer/helpers/getFormState.test.js +1 -3
  36. package/dist/components/FormRenderer/helpers/getNextPageId.js +0 -25
  37. package/dist/components/FormRenderer/helpers/getNextPageId.test.js +1 -4
  38. package/dist/components/FormRenderer/helpers/getPage.js +0 -5
  39. package/dist/components/FormRenderer/helpers/getPage.test.js +1 -3
  40. package/dist/components/FormRenderer/helpers/getRelevantPages.js +0 -6
  41. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -3
  42. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +0 -10
  43. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +0 -6
  44. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +6 -20
  45. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +3 -8
  46. package/dist/components/FormRenderer/helpers/index.js +1 -11
  47. package/dist/components/FormRenderer/index.js +0 -3
  48. package/dist/components/PageActions/ActionButton.js +2 -17
  49. package/dist/components/PageActions/PageActions.js +3 -10
  50. package/dist/components/PageActions/index.js +0 -3
  51. package/dist/components/SummaryList/GroupAction.js +3 -24
  52. package/dist/components/SummaryList/RowAction.js +3 -23
  53. package/dist/components/SummaryList/SummaryList.js +6 -28
  54. package/dist/components/SummaryList/SummaryListRow.js +4 -8
  55. package/dist/components/SummaryList/SummaryListTitleRow.js +2 -7
  56. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +0 -3
  57. package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +0 -6
  58. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +0 -3
  59. package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +0 -6
  60. package/dist/components/SummaryList/helpers/index.js +0 -2
  61. package/dist/components/SummaryList/index.js +0 -3
  62. package/dist/components/TaskList/Task.js +7 -29
  63. package/dist/components/TaskList/TaskList.js +12 -33
  64. package/dist/components/TaskList/TaskState.js +2 -10
  65. package/dist/components/TaskList/index.js +0 -3
  66. package/dist/components/index.js +0 -6
  67. package/dist/context/HooksContext/HooksContext.js +14 -34
  68. package/dist/context/HooksContext/index.js +0 -5
  69. package/dist/context/ValidationContext/ValidationContext.js +8 -34
  70. package/dist/context/ValidationContext/index.js +0 -5
  71. package/dist/context/index.js +0 -3
  72. package/dist/hooks/index.js +0 -9
  73. package/dist/hooks/useAxios.js +8 -25
  74. package/dist/hooks/useGetRequest.js +13 -47
  75. package/dist/hooks/useHooks.js +2 -4
  76. package/dist/hooks/useRefData.js +8 -37
  77. package/dist/hooks/useValidation.js +2 -4
  78. package/dist/index.js +0 -6
  79. package/dist/models/PageAction.js +0 -3
  80. package/dist/models/TaskStates.js +0 -3
  81. package/dist/models/index.js +0 -9
  82. package/dist/utils/CheckYourAnswers/getCYAAction.js +1 -9
  83. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +0 -10
  84. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +0 -8
  85. package/dist/utils/CheckYourAnswers/getCYARow.js +1 -10
  86. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +2 -20
  87. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +0 -18
  88. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +0 -20
  89. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +0 -13
  90. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +2 -22
  91. package/dist/utils/CheckYourAnswers/index.js +1 -3
  92. package/dist/utils/CheckYourAnswers/showComponentCYA.js +2 -11
  93. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +0 -11
  94. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +0 -6
  95. package/dist/utils/CollectionPage/index.js +1 -5
  96. package/dist/utils/CollectionPage/mergeCollectionPages.js +1 -12
  97. package/dist/utils/Component/cleanAttributes.js +1 -8
  98. package/dist/utils/Component/elevateNestedComponents.js +0 -3
  99. package/dist/utils/Component/getComponent.js +4 -68
  100. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +6 -10
  101. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +10 -28
  102. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +6 -33
  103. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +10 -27
  104. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +4 -10
  105. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +4 -21
  106. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +4 -22
  107. package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +3 -7
  108. package/dist/utils/Component/getComponentTests/getComponent.html.test.js +4 -10
  109. package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +3 -7
  110. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +6 -15
  111. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +4 -21
  112. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +6 -33
  113. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +4 -21
  114. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +4 -21
  115. package/dist/utils/Component/getComponentTests/getComponent.textarea.test.js +4 -21
  116. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +10 -29
  117. package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +1 -2
  118. package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +3 -7
  119. package/dist/utils/Component/getDefaultValue.js +0 -7
  120. package/dist/utils/Component/index.js +0 -9
  121. package/dist/utils/Component/isEditable.js +1 -4
  122. package/dist/utils/Component/showComponent.js +1 -8
  123. package/dist/utils/Component/wrapInFormGroup.js +0 -7
  124. package/dist/utils/Condition/index.js +0 -5
  125. package/dist/utils/Condition/meetsAllConditions.js +0 -9
  126. package/dist/utils/Condition/meetsCondition.js +7 -19
  127. package/dist/utils/Condition/meetsOneCondition.js +1 -9
  128. package/dist/utils/Condition/setupConditions.js +0 -12
  129. package/dist/utils/Container/getEditableComponents.js +0 -7
  130. package/dist/utils/Container/index.js +0 -5
  131. package/dist/utils/Container/setupNesting.js +0 -11
  132. package/dist/utils/Container/showContainer.js +9 -18
  133. package/dist/utils/Data/applyFormula.js +2 -28
  134. package/dist/utils/Data/getAutocompleteSource.js +1 -4
  135. package/dist/utils/Data/getDataPath.js +3 -17
  136. package/dist/utils/Data/getOptions.js +0 -9
  137. package/dist/utils/Data/getSourceData.js +4 -19
  138. package/dist/utils/Data/index.js +1 -11
  139. package/dist/utils/Data/refDataToOptions.js +1 -12
  140. package/dist/utils/Data/setDataItem.js +0 -5
  141. package/dist/utils/Data/setupFormData.js +2 -20
  142. package/dist/utils/Data/setupRefDataUrlForComponent.js +0 -14
  143. package/dist/utils/FormPage/getFormPage.js +0 -15
  144. package/dist/utils/FormPage/getFormPages.js +0 -8
  145. package/dist/utils/FormPage/getPageActions.js +3 -18
  146. package/dist/utils/FormPage/getParagraphFromText.js +0 -3
  147. package/dist/utils/FormPage/index.js +0 -6
  148. package/dist/utils/FormPage/showFormPage.js +9 -18
  149. package/dist/utils/FormPage/showFormPageCYA.js +0 -5
  150. package/dist/utils/FormPage/useComponent.js +3 -18
  151. package/dist/utils/Format/formatData.js +0 -5
  152. package/dist/utils/Format/formatDataForComponent.js +1 -6
  153. package/dist/utils/Format/formatDataForForm.js +0 -8
  154. package/dist/utils/Format/formatDataForPage.js +1 -5
  155. package/dist/utils/Format/index.js +1 -6
  156. package/dist/utils/Hub/getFormHub.js +0 -8
  157. package/dist/utils/Hub/index.js +1 -3
  158. package/dist/utils/Meta/documents/getDocuments.js +1 -4
  159. package/dist/utils/Meta/documents/getDocuments.test.js +0 -9
  160. package/dist/utils/Meta/documents/index.js +1 -5
  161. package/dist/utils/Meta/documents/setDocumentForField.js +0 -11
  162. package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -11
  163. package/dist/utils/Meta/index.js +2 -6
  164. package/dist/utils/Operate/checkValueIsTruthy.js +1 -7
  165. package/dist/utils/Operate/getIndexOfMatchingValueIn.js +7 -21
  166. package/dist/utils/Operate/index.js +0 -3
  167. package/dist/utils/Operate/persistValueInFormData.js +1 -8
  168. package/dist/utils/Operate/runPageOperations.js +3 -18
  169. package/dist/utils/Operate/setValueInFormData.js +2 -7
  170. package/dist/utils/Operate/shouldRun.js +1 -14
  171. package/dist/utils/Validate/additional/index.js +1 -18
  172. package/dist/utils/Validate/additional/index.test.js +0 -6
  173. package/dist/utils/Validate/additional/mustBeAfter.js +3 -8
  174. package/dist/utils/Validate/additional/mustBeAfter.test.js +0 -4
  175. package/dist/utils/Validate/additional/mustBeBefore.js +3 -8
  176. package/dist/utils/Validate/additional/mustBeBefore.test.js +0 -4
  177. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +5 -16
  178. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +0 -7
  179. package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -12
  180. package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +0 -3
  181. package/dist/utils/Validate/additional/mustBeInThePast.js +5 -13
  182. package/dist/utils/Validate/additional/mustBeInThePast.test.js +0 -3
  183. package/dist/utils/Validate/additional/mustBeLessThan.js +0 -3
  184. package/dist/utils/Validate/additional/mustBeLessThan.test.js +0 -2
  185. package/dist/utils/Validate/additional/mustBeLongerThan.js +0 -3
  186. package/dist/utils/Validate/additional/mustBeLongerThan.test.js +0 -2
  187. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +0 -4
  188. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +0 -2
  189. package/dist/utils/Validate/additional/mustBeShorterThan.js +0 -3
  190. package/dist/utils/Validate/additional/mustBeShorterThan.test.js +0 -2
  191. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +0 -5
  192. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +0 -4
  193. package/dist/utils/Validate/additional/utils.js +8 -24
  194. package/dist/utils/Validate/index.js +1 -9
  195. package/dist/utils/Validate/validateCollection.js +0 -9
  196. package/dist/utils/Validate/validateComponent.js +2 -35
  197. package/dist/utils/Validate/validateContainer.js +0 -13
  198. package/dist/utils/Validate/validateDate.js +4 -36
  199. package/dist/utils/Validate/validateEmail.js +1 -7
  200. package/dist/utils/Validate/validatePage.js +0 -15
  201. package/dist/utils/Validate/validateRegex.js +0 -10
  202. package/dist/utils/Validate/validateRequired.js +0 -8
  203. package/dist/utils/Validate/validateTime.js +3 -20
  204. package/dist/utils/index.js +0 -19
  205. package/package.json +50 -34
  206. package/dist/components/CheckYourAnswers/Answer.test.js +0 -95
  207. package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +0 -410
  208. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +0 -680
  209. package/dist/components/CollectionPage/CollectionPage.test.js +0 -428
  210. package/dist/components/FormComponent/Collection.test.js +0 -381
  211. package/dist/components/FormComponent/Container.test.js +0 -423
  212. package/dist/components/FormComponent/FormComponent.stories.mdx +0 -184
  213. package/dist/components/FormComponent/FormComponent.test.js +0 -264
  214. package/dist/components/FormPage/FormPage.stories.mdx +0 -131
  215. package/dist/components/FormPage/FormPage.test.js +0 -368
  216. package/dist/components/FormRenderer/FormRenderer.stories.mdx +0 -183
  217. package/dist/components/FormRenderer/FormRenderer.test.js +0 -1006
  218. package/dist/components/PageActions/ActionButton.test.js +0 -116
  219. package/dist/components/PageActions/PageActions.stories.mdx +0 -74
  220. package/dist/components/PageActions/PageActions.test.js +0 -157
  221. package/dist/components/SummaryList/GroupAction.test.js +0 -94
  222. package/dist/components/SummaryList/RowAction.test.js +0 -94
  223. package/dist/components/SummaryList/SummaryList.stories.mdx +0 -90
  224. package/dist/components/SummaryList/SummaryList.test.js +0 -361
  225. package/dist/components/TaskList/Task.test.js +0 -194
  226. package/dist/components/TaskList/TaskList.stories.mdx +0 -164
  227. package/dist/components/TaskList/TaskList.test.js +0 -334
  228. package/dist/components/TaskList/TaskState.test.js +0 -104
  229. package/dist/context/HooksContext/HooksContext.test.js +0 -60
  230. package/dist/context/ValidationContext/ValidationContext.test.js +0 -98
  231. package/dist/json/areYouACivilServant.json +0 -7
  232. package/dist/json/firstForm.json +0 -94
  233. package/dist/json/grade.json +0 -108
  234. package/dist/json/group.data.json +0 -21
  235. package/dist/json/group.json +0 -402
  236. package/dist/json/groupOfRow.json +0 -137
  237. package/dist/json/groupOfRowData.json +0 -15
  238. package/dist/json/port.json +0 -346
  239. package/dist/json/saveAndContinue.json +0 -98
  240. package/dist/json/sublocation.json +0 -859
  241. package/dist/json/taskList.json +0 -265
  242. package/dist/json/team.json +0 -17351
  243. package/dist/json/terminal.json +0 -81
  244. package/dist/json/userProfile.data.json +0 -21
  245. package/dist/json/userProfile.json +0 -276
  246. package/dist/setupTests.js +0 -59
  247. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +0 -139
  248. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +0 -76
  249. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +0 -59
  250. package/dist/utils/CheckYourAnswers/getCYARow.test.js +0 -256
  251. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +0 -77
  252. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +0 -199
  253. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +0 -170
  254. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +0 -323
  255. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +0 -281
  256. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +0 -64
  257. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +0 -41
  258. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +0 -54
  259. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +0 -131
  260. package/dist/utils/Component/cleanAttributes.test.js +0 -69
  261. package/dist/utils/Component/elevateNestedComponents.test.js +0 -92
  262. package/dist/utils/Component/getDefaultValue.test.js +0 -53
  263. package/dist/utils/Component/isEditable.test.js +0 -42
  264. package/dist/utils/Component/showComponent.test.js +0 -157
  265. package/dist/utils/Condition/meetsAllConditions.test.js +0 -62
  266. package/dist/utils/Condition/meetsCondition.test.js +0 -391
  267. package/dist/utils/Condition/meetsOneCondition.test.js +0 -101
  268. package/dist/utils/Condition/setupConditions.test.js +0 -35
  269. package/dist/utils/Container/getEditableComponents.test.js +0 -146
  270. package/dist/utils/Container/setupNesting.test.js +0 -92
  271. package/dist/utils/Container/showContainer.test.js +0 -179
  272. package/dist/utils/Data/applyFormula.test.js +0 -264
  273. package/dist/utils/Data/getAutocompleteSource.test.js +0 -146
  274. package/dist/utils/Data/getDataPath.test.js +0 -52
  275. package/dist/utils/Data/getOptions.test.js +0 -71
  276. package/dist/utils/Data/getSourceData.test.js +0 -141
  277. package/dist/utils/Data/refDataToOptions.test.js +0 -197
  278. package/dist/utils/Data/setDataItem.test.js +0 -112
  279. package/dist/utils/Data/setupFormData.test.js +0 -276
  280. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +0 -133
  281. package/dist/utils/FormPage/getFormPage.test.js +0 -205
  282. package/dist/utils/FormPage/getFormPages.test.js +0 -98
  283. package/dist/utils/FormPage/getPageActions.test.js +0 -89
  284. package/dist/utils/FormPage/getParagraphFromText.test.js +0 -29
  285. package/dist/utils/FormPage/showFormPage.test.js +0 -182
  286. package/dist/utils/FormPage/showFormPageCYA.test.js +0 -30
  287. package/dist/utils/FormPage/useComponent.test.js +0 -169
  288. package/dist/utils/Format/formatData.test.js +0 -46
  289. package/dist/utils/Format/formatDataForComponent.test.js +0 -161
  290. package/dist/utils/Format/formatDataForForm.test.js +0 -78
  291. package/dist/utils/Format/formatDataForPage.test.js +0 -96
  292. package/dist/utils/Hub/getFormHub.test.js +0 -107
  293. package/dist/utils/Operate/checkValueIsTruthy.test.js +0 -44
  294. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +0 -159
  295. package/dist/utils/Operate/persistValueInFormData.test.js +0 -106
  296. package/dist/utils/Operate/runPageOperations.test.js +0 -107
  297. package/dist/utils/Operate/setValueInFormData.test.js +0 -46
  298. package/dist/utils/Operate/shouldRun.test.js +0 -69
  299. package/dist/utils/Validate/validateCollection.test.js +0 -74
  300. package/dist/utils/Validate/validateComponent.test.js +0 -267
  301. package/dist/utils/Validate/validateContainer.test.js +0 -81
  302. package/dist/utils/Validate/validateDate.test.js +0 -118
  303. package/dist/utils/Validate/validateEmail.test.js +0 -57
  304. package/dist/utils/Validate/validatePage.test.js +0 -383
  305. package/dist/utils/Validate/validateRegex.test.js +0 -41
  306. package/dist/utils/Validate/validateRequired.test.js +0 -62
  307. package/dist/utils/Validate/validateTime.test.js +0 -61
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  var _ = _interopRequireDefault(require("."));
4
-
5
4
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
-
7
5
  // Local imports
6
+
8
7
  describe('components', function () {
9
8
  describe('FormRenderer', function () {
10
9
  describe('handlers', function () {
@@ -15,13 +14,10 @@ describe('components', function () {
15
14
  pageId: CURRENT_PAGE_ID
16
15
  };
17
16
  var ON_CHANGE_CALLS = [];
18
-
19
17
  var ON_CHANGE = function ON_CHANGE(pageId) {
20
18
  ON_CHANGE_CALLS.push(pageId);
21
19
  };
22
-
23
20
  _.default.cyaAction(PAGE, CURRENT_PAGE_ID, ON_CHANGE);
24
-
25
21
  expect(ON_CHANGE_CALLS.length).toEqual(0);
26
22
  });
27
23
  it('should call the onChange method when the page has changed', function () {
@@ -31,13 +27,10 @@ describe('components', function () {
31
27
  pageId: NEW_PAGE_ID
32
28
  };
33
29
  var ON_CHANGE_CALLS = [];
34
-
35
30
  var ON_CHANGE = function ON_CHANGE(pageId) {
36
31
  ON_CHANGE_CALLS.push(pageId);
37
32
  };
38
-
39
33
  _.default.cyaAction(PAGE, CURRENT_PAGE_ID, ON_CHANGE);
40
-
41
34
  expect(ON_CHANGE_CALLS.length).toEqual(1);
42
35
  expect(ON_CHANGE_CALLS[0]).toEqual(NEW_PAGE_ID);
43
36
  });
@@ -49,13 +42,10 @@ describe('components', function () {
49
42
  page: CURRENT_PAGE_ID
50
43
  };
51
44
  var ON_NAVIGATE_CALLS = [];
52
-
53
45
  var ON_NAVIGATE = function ON_NAVIGATE(pageId) {
54
46
  ON_NAVIGATE_CALLS.push(pageId);
55
47
  };
56
-
57
48
  _.default.navigate(ACTION, CURRENT_PAGE_ID, ON_NAVIGATE);
58
-
59
49
  expect(ON_NAVIGATE_CALLS.length).toEqual(0);
60
50
  });
61
51
  it('should call the onNavigate method when the page has changed', function () {
@@ -65,13 +55,10 @@ describe('components', function () {
65
55
  page: NEW_PAGE_ID
66
56
  };
67
57
  var ON_NAVIGATE_CALLS = [];
68
-
69
58
  var ON_NAVIGATE = function ON_NAVIGATE(pageId) {
70
59
  ON_NAVIGATE_CALLS.push(pageId);
71
60
  };
72
-
73
61
  _.default.navigate(ACTION, CURRENT_PAGE_ID, ON_NAVIGATE);
74
-
75
62
  expect(ON_NAVIGATE_CALLS.length).toEqual(1);
76
63
  expect(ON_NAVIGATE_CALLS[0]).toEqual(NEW_PAGE_ID);
77
64
  });
@@ -79,15 +66,11 @@ describe('components', function () {
79
66
  describe('submissionError', function () {
80
67
  it('should call the onError method with the same errors', function () {
81
68
  var ON_ERROR_CALLS = [];
82
-
83
69
  var ON_ERROR = function ON_ERROR(errors) {
84
70
  ON_ERROR_CALLS.push(errors);
85
71
  };
86
-
87
72
  var ERRORS = ['alpha', 'bravo', 'charlie'];
88
-
89
73
  _.default.submissionError(ERRORS, ON_ERROR);
90
-
91
74
  expect(ON_ERROR_CALLS.length).toEqual(1);
92
75
  expect(ON_ERROR_CALLS[0]).toEqual(ERRORS);
93
76
  });
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.handlers = exports.default = void 0;
7
-
8
7
  var _cyaAction = _interopRequireDefault(require("./cyaAction"));
9
-
10
8
  var _navigate = _interopRequireDefault(require("./navigate"));
11
-
12
9
  var _submissionError = _interopRequireDefault(require("./submissionError"));
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  var handlers = {
17
12
  cyaAction: _cyaAction.default,
18
13
  navigate: _navigate.default,
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _getPageId = _interopRequireDefault(require("./getPageId"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
9
  /**
13
10
  * Gets the pageId from the invoked page action and calls onNavigate if it is
14
11
  * different to the currentPageId.
@@ -18,11 +15,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
18
15
  */
19
16
  var navigate = function navigate(action, currentPageId, onNavigate) {
20
17
  var pageId = (0, _getPageId.default)(action, currentPageId);
21
-
22
18
  if (pageId !== currentPageId) {
23
19
  onNavigate(pageId);
24
20
  }
25
21
  };
26
-
27
22
  var _default = navigate;
28
23
  exports.default = _default;
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  /**
9
8
  * Formats back-end errors and invokes an onError handler.
10
9
  * @param {Array} errors The errors returned by the backend when submitting.
@@ -15,6 +14,5 @@ var submissionError = function submissionError(errors, onError) {
15
14
  // what the errors will look like.
16
15
  onError(errors);
17
16
  };
18
-
19
17
  var _default = submissionError;
20
18
  exports.default = _default;
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  /**
9
8
  * Assesses whether the action can proceed when navigating, submitting, etc.
10
9
  * Presently, this will validate a page when submitting and, only if the page is
@@ -18,9 +17,7 @@ var canActionProceed = function canActionProceed(action, page, pageValidator) {
18
17
  if (action.validate) {
19
18
  return pageValidator(page).length === 0;
20
19
  }
21
-
22
20
  return true;
23
21
  };
24
-
25
22
  var _default = canActionProceed;
26
23
  exports.default = _default;
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
 
3
3
  var _Validate = _interopRequireDefault(require("../../../utils/Validate"));
4
-
5
4
  var _canActionProceed = _interopRequireDefault(require("./canActionProceed"));
6
-
7
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
-
9
6
  // Local imports
7
+
10
8
  describe('components.FormRenderer.helpers.canActionProceed', function () {
11
9
  it('should return true when the action does not require validation', function () {
12
10
  var ACTION = {
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  /**
9
8
  * Assesses whether the CYA screen can submit.
10
9
  * Presently, this will validate all of the form pages and, only if all pages are
@@ -16,6 +15,5 @@ exports.default = void 0;
16
15
  var canCYASubmit = function canCYASubmit(pages, pagesValidator) {
17
16
  return pagesValidator(pages).length === 0;
18
17
  };
19
-
20
18
  var _default = canCYASubmit;
21
19
  exports.default = _default;
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
 
3
3
  var _Validate = _interopRequireDefault(require("../../../utils/Validate"));
4
-
5
4
  var _canCYASubmit = _interopRequireDefault(require("./canCYASubmit"));
6
-
7
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
-
9
6
  // Local imports
7
+
10
8
  describe('components.FormRenderer.helpers.canCYASubmit', function () {
11
9
  var ALPHA = {
12
10
  id: 'a',
@@ -20,13 +18,11 @@ describe('components.FormRenderer.helpers.canCYASubmit', function () {
20
18
  label: 'Charlie',
21
19
  required: true
22
20
  };
23
-
24
21
  var validatePages = function validatePages(pages) {
25
22
  return pages.flatMap(function (page) {
26
23
  return _Validate.default.page(page);
27
24
  });
28
25
  };
29
-
30
26
  it('should return true when all pages are valid', function () {
31
27
  var PAGE_1 = {
32
28
  components: [ALPHA],
@@ -5,13 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var parentComponents = ['radios'];
8
-
9
8
  var cleanHiddenNestedData = function cleanHiddenNestedData(patch, page) {
10
9
  page.components.forEach(function (component) {
11
10
  if (!parentComponents.includes(component.type)) {
12
11
  return;
13
12
  }
14
-
15
13
  var idsToDelete = getIdsToDelete(component, patch[component.id]);
16
14
  idsToDelete.forEach(function (id) {
17
15
  delete patch[id];
@@ -19,10 +17,8 @@ var cleanHiddenNestedData = function cleanHiddenNestedData(patch, page) {
19
17
  });
20
18
  return patch;
21
19
  };
22
-
23
20
  function getIdsToDelete(component, selectedValue) {
24
21
  var _component$data, _component$data$optio;
25
-
26
22
  var idsToDelete = [];
27
23
  component === null || component === void 0 ? void 0 : (_component$data = component.data) === null || _component$data === void 0 ? void 0 : (_component$data$optio = _component$data.options) === null || _component$data$optio === void 0 ? void 0 : _component$data$optio.forEach(function (option) {
28
24
  if (option.value !== selectedValue && option.nested) {
@@ -33,6 +29,5 @@ function getIdsToDelete(component, selectedValue) {
33
29
  });
34
30
  return idsToDelete;
35
31
  }
36
-
37
32
  var _default = cleanHiddenNestedData;
38
33
  exports.default = _default;
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  var _cleanHiddenNestedData = _interopRequireDefault(require("./cleanHiddenNestedData"));
4
-
5
4
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
-
7
5
  // Local imports
6
+
8
7
  describe('components', function () {
9
8
  describe('FormRenderer', function () {
10
9
  describe('helpers', function () {
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _models = require("../../../models");
9
-
10
8
  // Local imports
11
9
 
12
10
  /**
@@ -23,19 +21,15 @@ var getCYA = function getCYA(pageId, pages, hub) {
23
21
  } else if (pageId === _models.FormPages.CYA) {
24
22
  return {};
25
23
  }
26
-
27
24
  var currentPage = pages === null || pages === void 0 ? void 0 : pages.find(function (p) {
28
25
  return p.id === pageId;
29
26
  });
30
-
31
27
  if ((currentPage === null || currentPage === void 0 ? void 0 : currentPage.type) === _models.FormPages.PARTIAL_CYA) {
32
28
  return {
33
29
  title: currentPage.title
34
30
  };
35
31
  }
36
-
37
32
  return undefined;
38
33
  };
39
-
40
34
  var _default = getCYA;
41
35
  exports.default = _default;
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
 
3
3
  var _models = require("../../../models");
4
-
5
4
  var _getCYA = _interopRequireDefault(require("./getCYA"));
6
-
7
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
-
9
6
  // Local imports
7
+
10
8
  describe('components', function () {
11
9
  describe('FormRenderer', function () {
12
10
  describe('helpers', function () {
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _getCYA = _interopRequireDefault(require("./getCYA"));
9
-
10
8
  var _getPage = _interopRequireDefault(require("./getPage"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  // Local imports
15
11
 
16
12
  /**
@@ -27,6 +23,5 @@ var getFormState = function getFormState(pageId, pages, hub) {
27
23
  page: (0, _getPage.default)(pageId, pages, hub)
28
24
  };
29
25
  };
30
-
31
26
  var _default = getFormState;
32
27
  exports.default = _default;
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
 
3
3
  var _models = require("../../../models");
4
-
5
4
  var _getFormState = _interopRequireDefault(require("./getFormState"));
6
-
7
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
-
9
6
  // Local imports
7
+
10
8
  describe('components', function () {
11
9
  describe('FormRenderer', function () {
12
10
  describe('helpers', function () {
@@ -4,34 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _models = require("../../../models");
9
-
10
8
  var _FormPage = _interopRequireDefault(require("../../../utils/FormPage"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  var getNextHubPageId = function getNextHubPageId(action, currentPageId, pages, formData, formType) {
15
11
  var _action$pages;
16
-
17
12
  if (!currentPageId && formType === _models.FormTypes.FORM_WITH_TASK) {
18
13
  var _formData$formStatus;
19
-
20
14
  if (formData !== null && formData !== void 0 && (_formData$formStatus = formData.formStatus) !== null && _formData$formStatus !== void 0 && _formData$formStatus.taskPage) {
21
15
  var currentPage = pages.find(function (page) {
22
16
  return page.id === formData.formStatus.taskPage;
23
17
  });
24
-
25
18
  if ((currentPage === null || currentPage === void 0 ? void 0 : currentPage.type) === 'pre-task-list') {
26
19
  return currentPage.id;
27
20
  }
28
-
29
21
  return _models.FormPages.HUB;
30
22
  }
31
-
32
23
  return pages.length > 0 ? pages[0].id : undefined;
33
24
  }
34
-
35
25
  var nextPage = undefined;
36
26
  action === null || action === void 0 ? void 0 : (_action$pages = action.pages) === null || _action$pages === void 0 ? void 0 : _action$pages.forEach(function (page) {
37
27
  if (_FormPage.default.show({
@@ -39,37 +29,29 @@ var getNextHubPageId = function getNextHubPageId(action, currentPageId, pages, f
39
29
  }, formData)) {
40
30
  nextPage = page.pageId;
41
31
  }
42
-
43
32
  ;
44
33
  });
45
34
  return nextPage || (action === null || action === void 0 ? void 0 : action.page) || _models.FormPages.HUB;
46
35
  };
47
-
48
36
  var getNextCYAPageId = function getNextCYAPageId(pages, currentPageId, formData) {
49
37
  return getNextWizardPageId(pages, currentPageId, formData) || _models.FormPages.CYA;
50
38
  };
51
-
52
39
  var getNextWizardPageId = function getNextWizardPageId(pages, currentPageId, formData) {
53
40
  var _page;
54
-
55
41
  var nextIndex = pages.findIndex(function (p) {
56
42
  return p.id === currentPageId;
57
43
  }) + 1;
58
44
  var page = pages[nextIndex];
59
-
60
45
  while (page && !_FormPage.default.show(page, formData)) {
61
46
  nextIndex++;
62
47
  page = pages[nextIndex];
63
48
  }
64
-
65
49
  return ((_page = page) === null || _page === void 0 ? void 0 : _page.id) || undefined;
66
50
  };
67
-
68
51
  var getNextFormPageId = function getNextFormPageId(pages) {
69
52
  // A form has a single page... so always return that id.
70
53
  return pages.length > 0 ? pages[0].id : undefined;
71
54
  };
72
-
73
55
  var getNextPageId = function getNextPageId(formType, pages, currentPageId, action, formData) {
74
56
  if (action) {
75
57
  if (action.type === _models.PageAction.TYPES.NAVIGATE) {
@@ -77,30 +59,23 @@ var getNextPageId = function getNextPageId(formType, pages, currentPageId, actio
77
59
  return p.id === action.page;
78
60
  }) ? action.page : undefined;
79
61
  }
80
-
81
62
  if (action.type === _models.PageAction.TYPES.SAVE_AND_RETURN) {
82
63
  return formType === _models.FormTypes.HUB ? _models.FormPages.HUB : undefined;
83
64
  }
84
65
  }
85
-
86
66
  switch (formType) {
87
67
  case _models.FormTypes.HUB:
88
68
  return getNextHubPageId(action);
89
-
90
69
  case _models.FormTypes.CYA:
91
70
  return getNextCYAPageId(pages, currentPageId, formData);
92
-
93
71
  case _models.FormTypes.FORM_WITH_TASK:
94
72
  case _models.FormTypes.TASK:
95
73
  return getNextHubPageId(action, currentPageId, pages, formData, formType);
96
-
97
74
  case _models.FormTypes.WIZARD:
98
75
  return getNextWizardPageId(pages, currentPageId, formData);
99
-
100
76
  default:
101
77
  return getNextFormPageId(pages);
102
78
  }
103
79
  };
104
-
105
80
  var _default = getNextPageId;
106
81
  exports.default = _default;
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
 
3
3
  var _models = require("../../../models");
4
-
5
4
  var _getNextPageId = _interopRequireDefault(require("./getNextPageId"));
6
-
7
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
-
9
6
  // Local imports
7
+
10
8
  describe('components', function () {
11
9
  describe('FormRenderer', function () {
12
10
  describe('helpers', function () {
@@ -48,7 +46,6 @@ describe('components', function () {
48
46
  var FORM_DATA = {
49
47
  radios: OPTIONS[0].value
50
48
  }; // 'romeo'
51
-
52
49
  var PAGES = [{
53
50
  id: 'alpha'
54
51
  }, {
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _models = require("../../../models");
9
-
10
8
  // Local imports
11
9
 
12
10
  /**
@@ -21,14 +19,11 @@ var getPage = function getPage(pageId, pages, hub) {
21
19
  if (pageId === _models.FormPages.HUB) {
22
20
  return hub === _models.HubFormats.CYA || hub === _models.HubFormats.TASK ? undefined : hub;
23
21
  }
24
-
25
22
  return pages.find(function (p) {
26
23
  return p.id === pageId;
27
24
  });
28
25
  }
29
-
30
26
  return undefined;
31
27
  };
32
-
33
28
  var _default = getPage;
34
29
  exports.default = _default;
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
 
3
3
  var _models = require("../../../models");
4
-
5
4
  var _getPage = _interopRequireDefault(require("./getPage"));
6
-
7
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
-
9
6
  // Local imports
7
+
10
8
  describe('components', function () {
11
9
  describe('FormRenderer', function () {
12
10
  describe('helpers', function () {
@@ -4,24 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _models = require("../../../models");
9
-
10
8
  var slicePages = function slicePages(pages, currentPageId) {
11
9
  return pages.slice(0, pages.findIndex(function (p) {
12
10
  return p.id === currentPageId;
13
11
  }));
14
12
  };
15
-
16
13
  var getRelevantPages = function getRelevantPages(formState, pages, currentTaskPages) {
17
14
  var _formState$page;
18
-
19
15
  if (((_formState$page = formState.page) === null || _formState$page === void 0 ? void 0 : _formState$page.type) === _models.FormPages.PARTIAL_CYA) {
20
16
  return currentTaskPages ? slicePages(currentTaskPages, formState.pageId) : slicePages(pages, formState.pageId);
21
17
  }
22
-
23
18
  return currentTaskPages ? currentTaskPages : pages;
24
19
  };
25
-
26
20
  var _default = getRelevantPages;
27
21
  exports.default = _default;
@@ -1,12 +1,10 @@
1
1
  "use strict";
2
2
 
3
3
  var _models = require("../../../models");
4
-
5
4
  var _getRelevantPages = _interopRequireDefault(require("../helpers/getRelevantPages"));
6
-
7
5
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
-
9
6
  // Local imports
7
+
10
8
  describe('components', function () {
11
9
  describe('FormRenderer', function () {
12
10
  describe('helpers', function () {
@@ -4,19 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _models = require("../../../models");
9
-
10
8
  var _getNextPageId = _interopRequireDefault(require("./getNextPageId"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentPageId, action, formData, currentTask, isCompleted, sections) {
15
11
  if (formType === _models.FormTypes.TASK || formType === _models.FormTypes.FORM_WITH_TASK) {
16
12
  var formStatus = formData.formStatus || {};
17
13
  formStatus.tasks = formStatus.tasks || {};
18
14
  formStatus.tasks[currentTask.name] = formStatus.tasks[currentTask.name] || {};
19
-
20
15
  if (currentPageId === (_models.FormPages.CYA || 'submitForm') && isCompleted) {
21
16
  formStatus.tasks[currentTask.name].complete = true;
22
17
  } else if (!currentTask.name) {
@@ -28,7 +23,6 @@ var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentP
28
23
  sections.forEach(function (section) {
29
24
  section.tasks.forEach(function (task) {
30
25
  var lastPage = task.pages[task.pages.length - 1];
31
-
32
26
  if ((lastPage === currentPageId || lastPage.id === currentPageId) && isCompleted) {
33
27
  formStatus.tasks[task.name] = {
34
28
  complete: isCompleted,
@@ -54,21 +48,17 @@ var getSubmissionStatus = function getSubmissionStatus(formType, pages, currentP
54
48
  currentPage: currentPageId
55
49
  };
56
50
  }
57
-
58
51
  formStatus.taskPage = formStatus.tasks[currentTask.name].currentPage;
59
52
  return formStatus;
60
53
  }
61
-
62
54
  if ((action === null || action === void 0 ? void 0 : action.type) === _models.PageAction.TYPES.SAVE_AND_RETURN) {
63
55
  return {
64
56
  page: currentPageId
65
57
  };
66
58
  }
67
-
68
59
  return {
69
60
  page: (0, _getNextPageId.default)(formType, pages, currentPageId, action, formData)
70
61
  };
71
62
  };
72
-
73
63
  var _default = getSubmissionStatus;
74
64
  exports.default = _default;
@@ -1,15 +1,10 @@
1
1
  "use strict";
2
2
 
3
3
  var _models = require("../../../models");
4
-
5
4
  var _PageAction = require("../../../models/PageAction");
6
-
7
5
  var _getSubmissionStatus = _interopRequireDefault(require("./getSubmissionStatus"));
8
-
9
6
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
7
  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; }
12
-
13
8
  describe('components', function () {
14
9
  describe('FormRenderer', function () {
15
10
  describe('helpers', function () {
@@ -51,7 +46,6 @@ describe('components', function () {
51
46
  var FORM_DATA = {
52
47
  radios: OPTIONS[0].value
53
48
  }; // 'romeo'
54
-
55
49
  var PAGES = [{
56
50
  id: 'alpha'
57
51
  }, {