@ukhomeoffice/cop-react-form-renderer 5.45.2-alpha → 5.48.1-bravo

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 (353) hide show
  1. package/dist/components/CheckYourAnswers/Answer.js +12 -12
  2. package/dist/components/CheckYourAnswers/Answer.test.js +127 -92
  3. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +131 -101
  4. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +769 -464
  5. package/dist/components/CollectionPage/CollectionPage.js +58 -66
  6. package/dist/components/CollectionPage/CollectionPage.test.js +342 -300
  7. package/dist/components/CollectionSummary/BannerStrip.js +12 -12
  8. package/dist/components/CollectionSummary/BannerStrip.test.js +59 -63
  9. package/dist/components/CollectionSummary/CollectionSummary.js +88 -61
  10. package/dist/components/CollectionSummary/CollectionSummary.test.js +96 -102
  11. package/dist/components/CollectionSummary/Confirmation.js +12 -14
  12. package/dist/components/CollectionSummary/Confirmation.test.js +63 -68
  13. package/dist/components/CollectionSummary/SummaryCard.js +148 -109
  14. package/dist/components/CollectionSummary/SummaryCard.scss +1 -1
  15. package/dist/components/CollectionSummary/SummaryCard.test.js +927 -905
  16. package/dist/components/CollectionSummary/SummaryCardValidationContext.js +29 -23
  17. package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +73 -61
  18. package/dist/components/FormComponent/Collection.js +107 -73
  19. package/dist/components/FormComponent/Collection.test.js +945 -809
  20. package/dist/components/FormComponent/Container.js +38 -40
  21. package/dist/components/FormComponent/Container.test.js +345 -314
  22. package/dist/components/FormComponent/FormComponent.js +70 -67
  23. package/dist/components/FormComponent/FormComponent.test.js +342 -284
  24. package/dist/components/FormComponent/helpers/addLabel.js +7 -4
  25. package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
  26. package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +7 -7
  27. package/dist/components/FormComponent/helpers/getComponentError.js +5 -3
  28. package/dist/components/FormComponent/helpers/getComponentError.test.js +14 -14
  29. package/dist/components/FormComponent/helpers/getComponentFieldSet.js +4 -3
  30. package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +6 -6
  31. package/dist/components/FormComponent/helpers/index.js +4 -4
  32. package/dist/components/FormPage/FormPage.js +80 -65
  33. package/dist/components/FormPage/FormPage.test.js +163 -127
  34. package/dist/components/FormRenderer/FormRenderer.js +181 -144
  35. package/dist/components/FormRenderer/FormRenderer.test.js +1115 -730
  36. package/dist/components/FormRenderer/handlers/cyaAction.js +2 -2
  37. package/dist/components/FormRenderer/handlers/getPageId.js +3 -1
  38. package/dist/components/FormRenderer/handlers/getPageId.test.js +14 -14
  39. package/dist/components/FormRenderer/handlers/handlers.test.js +32 -32
  40. package/dist/components/FormRenderer/handlers/index.js +1 -1
  41. package/dist/components/FormRenderer/handlers/navigate.js +3 -3
  42. package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
  43. package/dist/components/FormRenderer/helpers/canActionProceed.js +5 -1
  44. package/dist/components/FormRenderer/helpers/canActionProceed.test.js +47 -11
  45. package/dist/components/FormRenderer/helpers/canCYASubmit.js +3 -1
  46. package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +20 -16
  47. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -17
  48. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +16 -16
  49. package/dist/components/FormRenderer/helpers/getCYA.js +5 -3
  50. package/dist/components/FormRenderer/helpers/getCYA.test.js +11 -11
  51. package/dist/components/FormRenderer/helpers/getFormState.js +7 -5
  52. package/dist/components/FormRenderer/helpers/getFormState.test.js +10 -10
  53. package/dist/components/FormRenderer/helpers/getNextPageId.js +24 -13
  54. package/dist/components/FormRenderer/helpers/getNextPageId.test.js +67 -67
  55. package/dist/components/FormRenderer/helpers/getPage.js +4 -2
  56. package/dist/components/FormRenderer/helpers/getPage.test.js +11 -11
  57. package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -7
  58. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +14 -14
  59. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +5 -5
  60. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +91 -97
  61. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +60 -62
  62. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +73 -71
  63. package/dist/components/FormRenderer/helpers/index.js +1 -1
  64. package/dist/components/FormRenderer/onCYAAction.js +51 -59
  65. package/dist/components/FormRenderer/onCYAAction.test.js +152 -164
  66. package/dist/components/FormRenderer/onPageAction.js +40 -44
  67. package/dist/components/FormRenderer/onPageAction.test.js +206 -223
  68. package/dist/components/FormRenderer/onTaskAction.js +13 -9
  69. package/dist/components/FormRenderer/onTaskAction.test.js +88 -93
  70. package/dist/components/PageActions/ActionButton.js +15 -12
  71. package/dist/components/PageActions/ActionButton.test.js +78 -56
  72. package/dist/components/PageActions/PageActions.js +10 -10
  73. package/dist/components/PageActions/PageActions.test.js +115 -86
  74. package/dist/components/SummaryList/GroupAction.js +17 -9
  75. package/dist/components/SummaryList/GroupAction.test.js +33 -37
  76. package/dist/components/SummaryList/RowAction.js +16 -11
  77. package/dist/components/SummaryList/RowAction.test.js +33 -37
  78. package/dist/components/SummaryList/SummaryList.js +26 -21
  79. package/dist/components/SummaryList/SummaryList.test.js +166 -143
  80. package/dist/components/SummaryList/SummaryListHeadingRow.js +4 -6
  81. package/dist/components/SummaryList/SummaryListRow.js +4 -6
  82. package/dist/components/SummaryList/SummaryListTitleRow.js +3 -5
  83. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -3
  84. package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +22 -22
  85. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -3
  86. package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +22 -22
  87. package/dist/components/SummaryList/helpers/index.js +1 -1
  88. package/dist/components/TaskList/Task.js +29 -19
  89. package/dist/components/TaskList/Task.test.js +76 -83
  90. package/dist/components/TaskList/TaskList.js +71 -45
  91. package/dist/components/TaskList/TaskList.test.js +111 -113
  92. package/dist/components/TaskList/TaskState.js +5 -7
  93. package/dist/components/TaskList/TaskState.test.js +45 -52
  94. package/dist/components/index.js +7 -7
  95. package/dist/context/HooksContext/HooksContext.js +79 -58
  96. package/dist/context/HooksContext/HooksContext.test.js +35 -26
  97. package/dist/context/HooksContext/index.js +4 -3
  98. package/dist/context/ValidationContext/ValidationContext.js +72 -32
  99. package/dist/context/ValidationContext/ValidationContext.test.js +59 -47
  100. package/dist/context/ValidationContext/index.js +4 -3
  101. package/dist/context/index.js +2 -2
  102. package/dist/hooks/index.js +10 -9
  103. package/dist/hooks/useAxios.js +40 -14
  104. package/dist/hooks/useGetRequest.js +97 -61
  105. package/dist/hooks/useHooks.js +3 -1
  106. package/dist/hooks/useRefData.js +39 -26
  107. package/dist/hooks/useValidation.js +3 -1
  108. package/dist/index.js +14 -13
  109. package/dist/models/CollectionLabels.js +1 -1
  110. package/dist/models/ComponentTypes.js +25 -25
  111. package/dist/models/EventTypes.js +4 -4
  112. package/dist/models/FormPages.js +4 -4
  113. package/dist/models/FormTypes.js +8 -8
  114. package/dist/models/HubFormats.js +3 -3
  115. package/dist/models/PageAction.js +38 -44
  116. package/dist/models/TaskStates.js +28 -30
  117. package/dist/models/index.js +9 -9
  118. package/dist/setupTests.js +31 -30
  119. package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
  120. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +54 -52
  121. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +25 -15
  122. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +35 -33
  123. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +31 -17
  124. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +44 -42
  125. package/dist/utils/CheckYourAnswers/getCYARow.js +6 -6
  126. package/dist/utils/CheckYourAnswers/getCYARow.test.js +86 -86
  127. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +24 -18
  128. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -15
  129. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +36 -33
  130. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +60 -58
  131. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +88 -79
  132. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +124 -146
  133. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +20 -25
  134. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +97 -103
  135. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +18 -13
  136. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +76 -70
  137. package/dist/utils/CheckYourAnswers/index.js +1 -1
  138. package/dist/utils/CheckYourAnswers/showComponentCYA.js +4 -4
  139. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +24 -24
  140. package/dist/utils/CollectionPage/addCollectionPageEntry.js +1 -1
  141. package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +5 -5
  142. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +2 -2
  143. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +17 -17
  144. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +18 -9
  145. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +22 -27
  146. package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
  147. package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +10 -10
  148. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +11 -7
  149. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +22 -22
  150. package/dist/utils/CollectionPage/getCollectionPageData.js +12 -8
  151. package/dist/utils/CollectionPage/getCollectionPageData.test.js +19 -19
  152. package/dist/utils/CollectionPage/getQuickEditPage.js +19 -19
  153. package/dist/utils/CollectionPage/getQuickEditPage.test.js +16 -12
  154. package/dist/utils/CollectionPage/index.js +1 -1
  155. package/dist/utils/CollectionPage/mergeCollectionPages.js +30 -29
  156. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +17 -17
  157. package/dist/utils/CollectionPage/removeCollectionPageEntry.js +6 -4
  158. package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +10 -10
  159. package/dist/utils/CollectionPage/setCollectionPageData.js +12 -8
  160. package/dist/utils/CollectionPage/setCollectionPageData.test.js +17 -17
  161. package/dist/utils/Component/addShowWhen.js +8 -4
  162. package/dist/utils/Component/addShowWhen.test.js +37 -37
  163. package/dist/utils/Component/applyToComponentTree.js +18 -18
  164. package/dist/utils/Component/applyToComponentTree.test.js +32 -27
  165. package/dist/utils/Component/cleanAttributes.js +13 -10
  166. package/dist/utils/Component/cleanAttributes.test.js +18 -17
  167. package/dist/utils/Component/elevateNestedComponents.js +5 -5
  168. package/dist/utils/Component/elevateNestedComponents.test.js +30 -30
  169. package/dist/utils/Component/getComponent.js +95 -88
  170. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +17 -18
  171. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +59 -46
  172. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +48 -39
  173. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -23
  174. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +18 -20
  175. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +22 -17
  176. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +25 -20
  177. package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +9 -10
  178. package/dist/utils/Component/getComponentTests/getComponent.html.test.js +15 -17
  179. package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +8 -9
  180. package/dist/utils/Component/getComponentTests/getComponent.list.test.js +15 -17
  181. package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +26 -22
  182. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +175 -155
  183. package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +15 -17
  184. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +22 -17
  185. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +70 -57
  186. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +22 -17
  187. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +22 -17
  188. package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +38 -31
  189. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +29 -20
  190. package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +2 -2
  191. package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +8 -9
  192. package/dist/utils/Component/getDefaultValue.js +8 -6
  193. package/dist/utils/Component/getDefaultValue.test.js +12 -12
  194. package/dist/utils/Component/getDefaultValueFromConfig.js +22 -23
  195. package/dist/utils/Component/getDefaultValueFromConfig.test.js +31 -31
  196. package/dist/utils/Component/index.js +1 -1
  197. package/dist/utils/Component/isEditable.js +4 -2
  198. package/dist/utils/Component/isEditable.test.js +15 -14
  199. package/dist/utils/Component/optionIsSelected.js +1 -1
  200. package/dist/utils/Component/optionIsSelected.test.js +9 -9
  201. package/dist/utils/Component/setupContainerComponentsPath.js +29 -27
  202. package/dist/utils/Component/setupContainerComponentsPath.test.js +11 -11
  203. package/dist/utils/Component/showComponent.js +1 -1
  204. package/dist/utils/Component/showComponent.test.js +28 -28
  205. package/dist/utils/Component/wrapInFormGroup.js +2 -2
  206. package/dist/utils/Condition/index.js +1 -1
  207. package/dist/utils/Condition/meetsAllConditions.js +7 -7
  208. package/dist/utils/Condition/meetsAllConditions.test.js +17 -17
  209. package/dist/utils/Condition/meetsCondition.js +17 -14
  210. package/dist/utils/Condition/meetsCondition.test.js +376 -376
  211. package/dist/utils/Condition/meetsOneCondition.js +5 -5
  212. package/dist/utils/Condition/meetsOneCondition.test.js +16 -16
  213. package/dist/utils/Condition/setupConditions.js +18 -13
  214. package/dist/utils/Condition/setupConditions.test.js +7 -7
  215. package/dist/utils/Container/getEditableComponents.js +5 -3
  216. package/dist/utils/Container/getEditableComponents.test.js +45 -43
  217. package/dist/utils/Container/index.js +1 -1
  218. package/dist/utils/Container/setupNesting.js +20 -16
  219. package/dist/utils/Container/setupNesting.test.js +30 -27
  220. package/dist/utils/Container/showContainer.js +7 -3
  221. package/dist/utils/Container/showContainer.test.js +30 -30
  222. package/dist/utils/Data/applyFormula.js +48 -38
  223. package/dist/utils/Data/applyFormula.test.js +20 -20
  224. package/dist/utils/Data/getAutocompleteSource.js +26 -18
  225. package/dist/utils/Data/getAutocompleteSource.test.js +86 -80
  226. package/dist/utils/Data/getDataPath.js +28 -18
  227. package/dist/utils/Data/getDataPath.test.js +12 -12
  228. package/dist/utils/Data/getOptions.js +25 -19
  229. package/dist/utils/Data/getOptions.test.js +20 -20
  230. package/dist/utils/Data/getSourceData.js +19 -6
  231. package/dist/utils/Data/getSourceData.test.js +80 -84
  232. package/dist/utils/Data/index.js +1 -1
  233. package/dist/utils/Data/refDataToOptions.js +13 -10
  234. package/dist/utils/Data/refDataToOptions.test.js +19 -19
  235. package/dist/utils/Data/setDataItem.js +8 -7
  236. package/dist/utils/Data/setDataItem.test.js +37 -37
  237. package/dist/utils/Data/setupFormData.js +21 -13
  238. package/dist/utils/Data/setupFormData.test.js +50 -51
  239. package/dist/utils/Data/setupRefDataUrlForComponent.js +26 -20
  240. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +24 -24
  241. package/dist/utils/FormPage/applyConditionalProperties.js +9 -5
  242. package/dist/utils/FormPage/applyConditionalProperties.test.js +18 -15
  243. package/dist/utils/FormPage/getFormPage.js +16 -15
  244. package/dist/utils/FormPage/getFormPage.test.js +46 -47
  245. package/dist/utils/FormPage/getFormPages.js +12 -7
  246. package/dist/utils/FormPage/getFormPages.test.js +23 -20
  247. package/dist/utils/FormPage/getPageActions.js +15 -9
  248. package/dist/utils/FormPage/getPageActions.test.js +32 -32
  249. package/dist/utils/FormPage/getPageTitle.js +2 -2
  250. package/dist/utils/FormPage/getPageTitle.test.js +22 -22
  251. package/dist/utils/FormPage/getParagraphFromText.js +7 -5
  252. package/dist/utils/FormPage/getParagraphFromText.test.js +6 -6
  253. package/dist/utils/FormPage/index.js +1 -1
  254. package/dist/utils/FormPage/showFormPage.js +7 -3
  255. package/dist/utils/FormPage/showFormPage.test.js +32 -32
  256. package/dist/utils/FormPage/showFormPageCYA.js +1 -1
  257. package/dist/utils/FormPage/showFormPageCYA.test.js +8 -8
  258. package/dist/utils/FormPage/useComponent.js +28 -21
  259. package/dist/utils/FormPage/useComponent.test.js +79 -78
  260. package/dist/utils/Format/formatData.js +1 -1
  261. package/dist/utils/Format/formatData.test.js +18 -18
  262. package/dist/utils/Format/formatDataForComponent.js +6 -5
  263. package/dist/utils/Format/formatDataForComponent.test.js +77 -50
  264. package/dist/utils/Format/formatDataForForm.js +8 -6
  265. package/dist/utils/Format/formatDataForForm.test.js +15 -13
  266. package/dist/utils/Format/formatDataForPage.js +5 -4
  267. package/dist/utils/Format/formatDataForPage.test.js +23 -20
  268. package/dist/utils/Format/index.js +1 -1
  269. package/dist/utils/Hub/getFormHub.js +1 -1
  270. package/dist/utils/Hub/getFormHub.test.js +31 -28
  271. package/dist/utils/Hub/index.js +1 -1
  272. package/dist/utils/Meta/constants.js +2 -2
  273. package/dist/utils/Meta/documents/getDocuments.js +1 -1
  274. package/dist/utils/Meta/documents/getDocuments.test.js +16 -24
  275. package/dist/utils/Meta/documents/index.js +1 -1
  276. package/dist/utils/Meta/documents/setDocumentsForField.js +16 -14
  277. package/dist/utils/Meta/documents/setDocumentsForField.test.js +34 -68
  278. package/dist/utils/Meta/index.js +1 -1
  279. package/dist/utils/Operate/checkValueIsTruthy.js +2 -2
  280. package/dist/utils/Operate/checkValueIsTruthy.test.js +16 -16
  281. package/dist/utils/Operate/getFirstOf.js +5 -5
  282. package/dist/utils/Operate/getFirstOf.test.js +31 -31
  283. package/dist/utils/Operate/getIndexOfMatchingValueIn.js +10 -10
  284. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +46 -46
  285. package/dist/utils/Operate/index.js +1 -1
  286. package/dist/utils/Operate/persistValueInFormData.js +3 -3
  287. package/dist/utils/Operate/persistValueInFormData.test.js +20 -22
  288. package/dist/utils/Operate/runPageOperations.js +7 -7
  289. package/dist/utils/Operate/runPageOperations.test.js +36 -35
  290. package/dist/utils/Operate/setValueInFormData.js +2 -2
  291. package/dist/utils/Operate/setValueInFormData.test.js +16 -16
  292. package/dist/utils/Operate/shouldRun.js +6 -6
  293. package/dist/utils/Operate/shouldRun.test.js +26 -21
  294. package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
  295. package/dist/utils/Validate/additional/conditionallyRequired.test.js +18 -18
  296. package/dist/utils/Validate/additional/index.js +10 -8
  297. package/dist/utils/Validate/additional/index.test.js +12 -12
  298. package/dist/utils/Validate/additional/mustBeAfter.js +2 -2
  299. package/dist/utils/Validate/additional/mustBeAfter.test.js +40 -40
  300. package/dist/utils/Validate/additional/mustBeBefore.js +2 -2
  301. package/dist/utils/Validate/additional/mustBeBefore.test.js +28 -28
  302. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +11 -7
  303. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +41 -37
  304. package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
  305. package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +18 -18
  306. package/dist/utils/Validate/additional/mustBeInTheFuture.js +2 -2
  307. package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +12 -12
  308. package/dist/utils/Validate/additional/mustBeInThePast.js +3 -3
  309. package/dist/utils/Validate/additional/mustBeInThePast.test.js +12 -12
  310. package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
  311. package/dist/utils/Validate/additional/mustBeLessThan.test.js +17 -17
  312. package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
  313. package/dist/utils/Validate/additional/mustBeLongerThan.test.js +16 -16
  314. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
  315. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +20 -20
  316. package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
  317. package/dist/utils/Validate/additional/mustBeShorterThan.test.js +16 -16
  318. package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +35 -0
  319. package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +127 -0
  320. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
  321. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +16 -14
  322. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
  323. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +12 -12
  324. package/dist/utils/Validate/additional/mustNotContainSql.js +4 -3
  325. package/dist/utils/Validate/additional/mustNotContainSql.test.js +14 -14
  326. package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
  327. package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +26 -28
  328. package/dist/utils/Validate/additional/utils.js +22 -9
  329. package/dist/utils/Validate/index.js +1 -1
  330. package/dist/utils/Validate/validateCollection.js +25 -19
  331. package/dist/utils/Validate/validateCollection.test.js +66 -74
  332. package/dist/utils/Validate/validateComponent.js +16 -18
  333. package/dist/utils/Validate/validateComponent.test.js +146 -167
  334. package/dist/utils/Validate/validateContainer.js +19 -14
  335. package/dist/utils/Validate/validateContainer.test.js +45 -49
  336. package/dist/utils/Validate/validateDate.js +17 -11
  337. package/dist/utils/Validate/validateDate.test.js +29 -28
  338. package/dist/utils/Validate/validateEmail.js +8 -6
  339. package/dist/utils/Validate/validateEmail.test.js +25 -25
  340. package/dist/utils/Validate/validateMultifile.js +7 -5
  341. package/dist/utils/Validate/validateMultifile.test.js +18 -17
  342. package/dist/utils/Validate/validatePage.js +18 -17
  343. package/dist/utils/Validate/validatePage.test.js +182 -185
  344. package/dist/utils/Validate/validateRegex.js +5 -3
  345. package/dist/utils/Validate/validateRegex.test.js +14 -14
  346. package/dist/utils/Validate/validateRequired.js +6 -4
  347. package/dist/utils/Validate/validateRequired.test.js +18 -18
  348. package/dist/utils/Validate/validateTextArea.js +6 -4
  349. package/dist/utils/Validate/validateTextArea.test.js +20 -20
  350. package/dist/utils/Validate/validateTime.js +14 -7
  351. package/dist/utils/Validate/validateTime.test.js +14 -14
  352. package/dist/utils/index.js +9 -7
  353. package/package.json +1 -1
@@ -2,22 +2,26 @@
2
2
 
3
3
  var _getCYARowsForCollectionPage = _interopRequireDefault(require("./getCYARowsForCollectionPage"));
4
4
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5
- // Local imports
6
-
7
- describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
8
- const TEXT_COMP = {
5
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
10
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Local imports
11
+ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', function () {
12
+ var TEXT_COMP = {
9
13
  id: 'testText',
10
14
  fieldId: 'testText',
11
15
  label: 'Test text',
12
16
  type: 'text'
13
17
  };
14
- const DATE_COMP = {
18
+ var DATE_COMP = {
15
19
  id: 'testDate',
16
20
  fieldId: 'testDate',
17
21
  label: 'Test date',
18
22
  type: 'date'
19
23
  };
20
- const PAGES = [{
24
+ var PAGES = [{
21
25
  id: 'page1',
22
26
  collection: {
23
27
  name: 'collection'
@@ -30,7 +34,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
30
34
  },
31
35
  components: [DATE_COMP]
32
36
  }];
33
- const MASTER_PAGE = {
37
+ var MASTER_PAGE = {
34
38
  id: 'page1',
35
39
  collection: {
36
40
  name: 'collection',
@@ -51,80 +55,73 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
51
55
  },
52
56
  childPages: PAGES
53
57
  };
54
- it('should return no rows for a collection if it does not exist in formData', () => {
55
- const FORM_DATA = {};
56
- const PAGE = {
57
- ...MASTER_PAGE,
58
+ it('should return no rows for a collection if it does not exist in formData', function () {
59
+ var FORM_DATA = {};
60
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
58
61
  formData: FORM_DATA
59
- };
60
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
62
+ });
63
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
61
64
  expect(ROWS.length).toEqual(0);
62
65
  });
63
- it('should return no rows for a collection if it has no entries', () => {
64
- const FORM_DATA = {
66
+ it('should return no rows for a collection if it has no entries', function () {
67
+ var FORM_DATA = {
65
68
  collection: []
66
69
  };
67
- const PAGE = {
68
- ...MASTER_PAGE,
70
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
69
71
  formData: FORM_DATA
70
- };
71
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
72
+ });
73
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
72
74
  expect(ROWS.length).toEqual(0);
73
75
  });
74
- it('should accept the hideNameFromCYA collection flag', () => {
75
- const FORM_DATA = {
76
+ it('should accept the hideNameFromCYA collection flag', function () {
77
+ var FORM_DATA = {
76
78
  collection: [{
77
79
  testText: 'hello'
78
80
  }]
79
81
  };
80
- const PAGE = {
81
- ...MASTER_PAGE,
82
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
82
83
  formData: FORM_DATA,
83
- collection: {
84
- ...MASTER_PAGE.collection,
84
+ collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
85
85
  hideNameFromCYA: true
86
- }
87
- };
88
- const TITLE_FIELD_ID = "".concat(PAGE.collection.name, "Title");
89
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
86
+ })
87
+ });
88
+ var TITLE_FIELD_ID = "".concat(PAGE.collection.name, "Title");
89
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
90
90
  expect(ROWS[0].fieldId).not.toEqual(TITLE_FIELD_ID);
91
91
  });
92
- it('should format titles correctly when collection.labels.item is specified', () => {
93
- const FORM_DATA = {
92
+ it('should format titles correctly when collection.labels.item is specified', function () {
93
+ var FORM_DATA = {
94
94
  collection: [{
95
95
  id: '01',
96
96
  testText: 'value'
97
97
  }]
98
98
  };
99
- const PAGE = {
100
- ...MASTER_PAGE,
99
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
101
100
  formData: FORM_DATA
102
- };
103
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
101
+ });
102
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
104
103
  expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
105
104
  expect(ROWS[1].key).toEqual('Collection entry 1');
106
105
  });
107
- it('should provide default titles if collection.labels.item is not specified', () => {
108
- const FORM_DATA = {
106
+ it('should provide default titles if collection.labels.item is not specified', function () {
107
+ var FORM_DATA = {
109
108
  collection: [{
110
109
  id: '01',
111
110
  testText: 'value'
112
111
  }]
113
112
  };
114
- const PAGE = {
115
- ...MASTER_PAGE,
116
- collection: {
117
- ...MASTER_PAGE.collection,
113
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
114
+ collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
118
115
  labels: {}
119
- },
116
+ }),
120
117
  formData: FORM_DATA
121
- };
122
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
118
+ });
119
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
123
120
  expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
124
121
  expect(ROWS[1].key).toEqual('Item 1');
125
122
  });
126
- it('should return correctly formatted rows for mutliple entries', () => {
127
- const FORM_DATA = {
123
+ it('should return correctly formatted rows for mutliple entries', function () {
124
+ var FORM_DATA = {
128
125
  collection: [{
129
126
  id: '01',
130
127
  testText: 'value'
@@ -133,11 +130,10 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
133
130
  testText: 'value'
134
131
  }]
135
132
  };
136
- const PAGE = {
137
- ...MASTER_PAGE,
133
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
138
134
  formData: FORM_DATA
139
- };
140
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
135
+ });
136
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
141
137
  expect(ROWS.length).toEqual(13); // Title row + component row for each item
142
138
  expect(ROWS[0]).toMatchObject({
143
139
  type: 'heading',
@@ -174,8 +170,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
174
170
  key: 'Test date'
175
171
  });
176
172
  });
177
- it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is defined', () => {
178
- const FORM_DATA = {
173
+ it('should return correctly formatted rows for only the active entry when page.collection.onlyShowActiveEntryOnCYA is defined', function () {
174
+ var FORM_DATA = {
179
175
  collectionActiveId: '02',
180
176
  collection: [{
181
177
  id: '01',
@@ -185,15 +181,13 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
185
181
  testText: 'value'
186
182
  }]
187
183
  };
188
- const PAGE = {
189
- ...MASTER_PAGE,
190
- collection: {
191
- ...MASTER_PAGE.collection,
184
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
185
+ collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
192
186
  onlyShowActiveEntryOnCYA: true
193
- },
187
+ }),
194
188
  formData: FORM_DATA
195
- };
196
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
189
+ });
190
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
197
191
  expect(ROWS.length).toEqual(7); // Title row + component row for only the active item.
198
192
  expect(ROWS[0]).toMatchObject({
199
193
  type: 'heading',
@@ -215,8 +209,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
215
209
  key: 'Test date'
216
210
  });
217
211
  });
218
- it('should exclude components that should not be shown', () => {
219
- const FD = {
212
+ it('should exclude components that should not be shown', function () {
213
+ var FD = {
220
214
  collection: [{
221
215
  id: '01',
222
216
  otherField: 'yes',
@@ -227,14 +221,12 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
227
221
  testText: 'testing'
228
222
  }]
229
223
  };
230
- const PAGE = {
231
- ...MASTER_PAGE,
224
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
232
225
  collection: {
233
226
  name: 'collection'
234
227
  },
235
228
  formData: FD,
236
- childPages: [{
237
- ...PAGES[0],
229
+ childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
238
230
  components: [{
239
231
  id: 'testText',
240
232
  fieldId: 'testText',
@@ -246,9 +238,9 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
246
238
  value: "yes"
247
239
  }
248
240
  }]
249
- }]
250
- };
251
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FD);
241
+ })]
242
+ });
243
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FD);
252
244
  expect(ROWS.length).toEqual(4);
253
245
  expect(ROWS[0]).toMatchObject({
254
246
  type: 'heading',
@@ -267,30 +259,28 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
267
259
  key: 'Test text'
268
260
  });
269
261
  });
270
- it('should exclude pages that should not be shown', () => {
271
- const FD = {
262
+ it('should exclude pages that should not be shown', function () {
263
+ var FD = {
272
264
  collection: [{
273
265
  id: '01',
274
266
  otherField: 'yes',
275
267
  testText: 'testing'
276
268
  }]
277
269
  };
278
- const PAGE = {
279
- ...MASTER_PAGE,
270
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
280
271
  collection: {
281
272
  name: 'collection'
282
273
  },
283
274
  formData: FD,
284
- childPages: [{
285
- ...PAGES[0],
275
+ childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
286
276
  show_when: {
287
277
  field: "otherField",
288
278
  op: "!=",
289
279
  value: "yes"
290
280
  }
291
- }, PAGES[1]]
292
- };
293
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FD);
281
+ }), PAGES[1]]
282
+ });
283
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FD);
294
284
  expect(ROWS.length).toEqual(3); // Missing the page with the text component on.
295
285
  expect(ROWS[0]).toMatchObject({
296
286
  type: 'heading',
@@ -305,28 +295,25 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
305
295
  key: 'Test date'
306
296
  });
307
297
  });
308
- it('should include rows for custom headings', () => {
309
- const FORM_DATA = {
298
+ it('should include rows for custom headings', function () {
299
+ var FORM_DATA = {
310
300
  collection: [{
311
301
  id: '01',
312
302
  testText: 'value'
313
303
  }]
314
304
  };
315
- const PAGE = {
316
- ...MASTER_PAGE,
305
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
317
306
  formData: FORM_DATA,
318
- childPages: [{
319
- ...PAGES[0],
320
- collection: {
321
- ...PAGES[0].collection,
307
+ childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
308
+ collection: _objectSpread(_objectSpread({}, PAGES[0].collection), {}, {
322
309
  heading: {
323
310
  size: 'm',
324
311
  text: 'Custom page heading'
325
312
  }
326
- }
327
- }]
328
- };
329
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
313
+ })
314
+ })]
315
+ });
316
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
330
317
  expect(ROWS.length).toEqual(7);
331
318
  expect(ROWS[0]).toMatchObject({
332
319
  type: 'heading',
@@ -349,106 +336,99 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
349
336
  key: 'Test text'
350
337
  });
351
338
  });
352
- it('should default to a title size of small if one is not specified', () => {
353
- const FORM_DATA = {
339
+ it('should default to a title size of small if one is not specified', function () {
340
+ var FORM_DATA = {
354
341
  collection: [{
355
342
  id: '01',
356
343
  testText: 'value'
357
344
  }]
358
345
  };
359
- const PAGE = {
360
- ...MASTER_PAGE,
346
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
361
347
  formData: FORM_DATA,
362
- childPages: [{
363
- ...PAGES[0],
364
- collection: {
365
- ...PAGES[0].collection,
348
+ childPages: [_objectSpread(_objectSpread({}, PAGES[0]), {}, {
349
+ collection: _objectSpread(_objectSpread({}, PAGES[0].collection), {}, {
366
350
  heading: {
367
351
  text: 'Custom page heading'
368
352
  }
369
- }
370
- }]
371
- };
372
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
353
+ })
354
+ })]
355
+ });
356
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
373
357
  expect(ROWS[5]).toMatchObject({
374
358
  type: 'heading',
375
359
  key: 'Custom page heading',
376
360
  size: 's'
377
361
  });
378
362
  });
379
- it('should position actions under the title if actionPosition flag is not specified', () => {
380
- const FORM_DATA = {
363
+ it('should position actions under the title if actionPosition flag is not specified', function () {
364
+ var FORM_DATA = {
381
365
  collection: [{
382
366
  id: '01',
383
367
  testText: 'value'
384
368
  }]
385
369
  };
386
- const PAGE = {
387
- ...MASTER_PAGE,
370
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
388
371
  formData: FORM_DATA
389
- };
390
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
372
+ });
373
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
391
374
  expect(ROWS[2].action.label).toEqual('Change');
392
375
  expect(ROWS[3].action.label).toEqual('custom remove label');
393
376
  expect(ROWS[4].action.label).toEqual('custom change label');
394
377
  });
395
- it('should position actions under the title if actionPosition flag is top', () => {
396
- const FORM_DATA = {
378
+ it('should position actions under the title if actionPosition flag is top', function () {
379
+ var FORM_DATA = {
397
380
  collection: [{
398
381
  id: '01',
399
382
  testText: 'value'
400
383
  }]
401
384
  };
402
- const PAGE = {
403
- ...MASTER_PAGE,
404
- collection: {
405
- ...MASTER_PAGE.collection,
385
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
386
+ collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
406
387
  actionPosition: 'top'
407
- },
388
+ }),
408
389
  formData: FORM_DATA
409
- };
410
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
390
+ });
391
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
411
392
  expect(ROWS[2].action.label).toEqual('Change');
412
393
  expect(ROWS[3].action.label).toEqual('custom remove label');
413
394
  expect(ROWS[4].action.label).toEqual('custom change label');
414
395
  });
415
- it('should position actions under all other rows if actionPosition flag is bottom', () => {
416
- const FORM_DATA = {
396
+ it('should position actions under all other rows if actionPosition flag is bottom', function () {
397
+ var FORM_DATA = {
417
398
  collection: [{
418
399
  id: '01',
419
400
  testText: 'value'
420
401
  }]
421
402
  };
422
- const PAGE = {
423
- ...MASTER_PAGE,
424
- collection: {
425
- ...MASTER_PAGE.collection,
403
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
404
+ collection: _objectSpread(_objectSpread({}, MASTER_PAGE.collection), {}, {
426
405
  actionPosition: 'bottom'
427
- },
406
+ }),
428
407
  formData: FORM_DATA
429
- };
430
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
408
+ });
409
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, FORM_DATA);
431
410
  expect(ROWS[ROWS.length - 3].action.label).toEqual('Change');
432
411
  expect(ROWS[ROWS.length - 2].action.label).toEqual('custom remove label');
433
412
  expect(ROWS[ROWS.length - 1].action.label).toEqual('custom change label');
434
413
  });
435
- it('should ignore the result of the override function if it returns nullish', () => {
436
- const FORM_DATA = {
414
+ it('should ignore the result of the override function if it returns nullish', function () {
415
+ var FORM_DATA = {
437
416
  collection: [{
438
417
  id: '01',
439
418
  testText: 'value'
440
419
  }]
441
420
  };
442
- const PAGE = {
443
- ...MASTER_PAGE,
421
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
444
422
  formData: FORM_DATA
445
- };
446
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, () => null, FORM_DATA);
423
+ });
424
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, function () {
425
+ return null;
426
+ }, FORM_DATA);
447
427
  expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
448
428
  expect(ROWS[5].key).toEqual("Test text");
449
429
  });
450
- it('should use the rows produced by the override function if provided', () => {
451
- const FORM_DATA = {
430
+ it('should use the rows produced by the override function if provided', function () {
431
+ var FORM_DATA = {
452
432
  collection: [{
453
433
  id: '01',
454
434
  testText: 'value'
@@ -456,23 +436,22 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
456
436
  };
457
437
 
458
438
  // eslint-disable-next-line arrow-body-style
459
- const OVERRIDE = (page, comp) => {
439
+ var OVERRIDE = function OVERRIDE(page, comp) {
460
440
  // This will be called for each component on the page,
461
441
  // returning a custom row object.
462
442
  return {
463
443
  key: "CustomRowFor".concat(comp.label)
464
444
  };
465
445
  };
466
- const PAGE = {
467
- ...MASTER_PAGE,
446
+ var PAGE = _objectSpread(_objectSpread({}, MASTER_PAGE), {}, {
468
447
  formData: FORM_DATA
469
- };
470
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, OVERRIDE, FORM_DATA);
448
+ });
449
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, OVERRIDE, FORM_DATA);
471
450
  expect(ROWS.length).toEqual(7); // Collection title, item title, action rows & component rows
472
451
  expect(ROWS[5].key).toEqual("CustomRowFor".concat(TEXT_COMP.label));
473
452
  });
474
- it('should create rows for nested collections correctly', () => {
475
- const CUSTOM_FORM_DATA = {
453
+ it('should create rows for nested collections correctly', function () {
454
+ var CUSTOM_FORM_DATA = {
476
455
  parentActiveId: '001',
477
456
  childActiveId: '001',
478
457
  parent: [{
@@ -484,7 +463,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
484
463
  }]
485
464
  }]
486
465
  };
487
- const CHILD_MASTER_PAGE = {
466
+ var CHILD_MASTER_PAGE = {
488
467
  id: 'childPage',
489
468
  collection: {
490
469
  name: 'parent.child',
@@ -508,7 +487,7 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
508
487
  components: [TEXT_COMP]
509
488
  }]
510
489
  };
511
- const PARENT_MASTER_PAGE = {
490
+ var PARENT_MASTER_PAGE = {
512
491
  id: 'parentPage',
513
492
  collection: {
514
493
  name: 'parent',
@@ -522,11 +501,10 @@ describe('utils.CheckYourAnswers.getCYARowsForCollectionPage', () => {
522
501
  components: [TEXT_COMP]
523
502
  }, CHILD_MASTER_PAGE]
524
503
  };
525
- const PAGE = {
526
- ...PARENT_MASTER_PAGE,
504
+ var PAGE = _objectSpread(_objectSpread({}, PARENT_MASTER_PAGE), {}, {
527
505
  formData: CUSTOM_FORM_DATA
528
- };
529
- const ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, CUSTOM_FORM_DATA);
506
+ });
507
+ var ROWS = (0, _getCYARowsForCollectionPage.default)(PAGE, null, null, CUSTOM_FORM_DATA);
530
508
  expect(ROWS.length).toEqual(8);
531
509
  expect(ROWS[0]).toMatchObject({
532
510
  type: 'heading',
@@ -10,41 +10,36 @@ var _getCYARow = _interopRequireDefault(require("./getCYARow"));
10
10
  var _getCYARowsForCollection = _interopRequireDefault(require("./getCYARowsForCollection"));
11
11
  var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
- // Local imports
14
-
15
- const getCYARowsForContainer = (page, container, formData, onAction, fnOverride) => {
16
- if ((0, _showComponentCYA.default)(container, {
17
- ...page.formData,
18
- ...formData
19
- })) {
20
- const allComponents = (0, _elevateNestedComponents.default)(container.components, formData);
21
- return allComponents.filter(c => (0, _showComponentCYA.default)(c, {
22
- ...page.formData,
23
- ...formData
24
- })).flatMap(component => {
25
- const fd = formData ? formData[component.fieldId] : undefined;
13
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
14
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
18
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Local imports
19
+ var getCYARowsForContainer = function getCYARowsForContainer(page, container, formData, onAction, fnOverride) {
20
+ if ((0, _showComponentCYA.default)(container, _objectSpread(_objectSpread({}, page.formData), formData))) {
21
+ var allComponents = (0, _elevateNestedComponents.default)(container.components, formData);
22
+ return allComponents.filter(function (c) {
23
+ return (0, _showComponentCYA.default)(c, _objectSpread(_objectSpread({}, page.formData), formData));
24
+ }).flatMap(function (component) {
25
+ var fd = formData ? formData[component.fieldId] : undefined;
26
26
  if (typeof fnOverride === 'function') {
27
- const overrideRows = fnOverride({
28
- ...page,
29
- formData
30
- }, component, onAction);
27
+ var overrideRows = fnOverride(_objectSpread(_objectSpread({}, page), {}, {
28
+ formData: formData
29
+ }), component, onAction);
31
30
  if (overrideRows) {
32
31
  return overrideRows;
33
32
  }
34
33
  }
35
34
  if (component.type === _models.ComponentTypes.CONTAINER) {
36
- return getCYARowsForContainer(page, component, {
37
- ...fd,
38
- ...formData
39
- }, onAction, fnOverride);
35
+ return getCYARowsForContainer(page, component, _objectSpread(_objectSpread({}, fd), formData), onAction, fnOverride);
40
36
  }
41
37
  if (component.type === _models.ComponentTypes.COLLECTION) {
42
38
  return (0, _getCYARowsForCollection.default)(page, component, fd, onAction, fnOverride);
43
39
  }
44
- return (0, _getCYARow.default)({
45
- ...page,
46
- formData
47
- }, component, onAction);
40
+ return (0, _getCYARow.default)(_objectSpread(_objectSpread({}, page), {}, {
41
+ formData: formData
42
+ }), component, onAction);
48
43
  });
49
44
  }
50
45
  return null;