@ukhomeoffice/cop-react-form-renderer 6.14.0 → 6.14.1

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 (385) hide show
  1. package/README.md +5 -0
  2. package/dist/components/CheckYourAnswers/Answer.js +12 -11
  3. package/dist/components/CheckYourAnswers/Answer.test.js +132 -181
  4. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +98 -133
  5. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +544 -939
  6. package/dist/components/CheckYourAnswers/index.js +1 -1
  7. package/dist/components/CollectionPage/CollectionPage.js +62 -60
  8. package/dist/components/CollectionPage/CollectionPage.test.js +315 -365
  9. package/dist/components/CollectionPage/index.js +1 -1
  10. package/dist/components/CollectionSummary/BannerStrip.js +14 -14
  11. package/dist/components/CollectionSummary/BannerStrip.test.js +79 -74
  12. package/dist/components/CollectionSummary/CollectionSummary.js +75 -97
  13. package/dist/components/CollectionSummary/CollectionSummary.test.js +182 -166
  14. package/dist/components/CollectionSummary/Confirmation.js +15 -13
  15. package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
  16. package/dist/components/CollectionSummary/RenderListView.js +34 -47
  17. package/dist/components/CollectionSummary/RenderListView.test.js +113 -111
  18. package/dist/components/CollectionSummary/SummaryCard.js +101 -133
  19. package/dist/components/CollectionSummary/SummaryCard.test.js +961 -993
  20. package/dist/components/CollectionSummary/SummaryCardButtons.js +25 -30
  21. package/dist/components/CollectionSummary/SummaryCardButtons.test.js +30 -28
  22. package/dist/components/CollectionSummary/SummaryCardDetails.js +59 -76
  23. package/dist/components/CollectionSummary/SummaryCardDetails.test.js +170 -180
  24. package/dist/components/CollectionSummary/SummaryCardValidationContext.js +31 -36
  25. package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +63 -75
  26. package/dist/components/CollectionSummary/index.js +1 -1
  27. package/dist/components/FormComponent/Collection.js +63 -100
  28. package/dist/components/FormComponent/Collection.test.js +907 -1080
  29. package/dist/components/FormComponent/Container.js +35 -29
  30. package/dist/components/FormComponent/Container.test.js +378 -409
  31. package/dist/components/FormComponent/FormComponent.js +59 -63
  32. package/dist/components/FormComponent/FormComponent.test.js +354 -415
  33. package/dist/components/FormComponent/helpers/addLabel.js +4 -7
  34. package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
  35. package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +8 -8
  36. package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
  37. package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
  38. package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
  39. package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +7 -7
  40. package/dist/components/FormComponent/helpers/index.js +5 -5
  41. package/dist/components/FormComponent/index.js +1 -1
  42. package/dist/components/FormPage/FormPage.js +70 -93
  43. package/dist/components/FormPage/FormPage.test.js +150 -202
  44. package/dist/components/FormPage/index.js +1 -1
  45. package/dist/components/FormRenderer/FormRenderer.js +131 -173
  46. package/dist/components/FormRenderer/FormRenderer.test.js +732 -1114
  47. package/dist/components/FormRenderer/handlers/cyaAction.js +3 -3
  48. package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
  49. package/dist/components/FormRenderer/handlers/getPageId.test.js +15 -15
  50. package/dist/components/FormRenderer/handlers/handlers.test.js +33 -33
  51. package/dist/components/FormRenderer/handlers/index.js +2 -2
  52. package/dist/components/FormRenderer/handlers/navigate.js +4 -4
  53. package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
  54. package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
  55. package/dist/components/FormRenderer/helpers/canActionProceed.test.js +16 -16
  56. package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
  57. package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
  58. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -25
  59. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +21 -21
  60. package/dist/components/FormRenderer/helpers/getCYA.js +4 -6
  61. package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
  62. package/dist/components/FormRenderer/helpers/getFormState.js +6 -8
  63. package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
  64. package/dist/components/FormRenderer/helpers/getNextPageId.js +14 -25
  65. package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
  66. package/dist/components/FormRenderer/helpers/getPage.js +2 -4
  67. package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
  68. package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
  69. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
  70. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +6 -6
  71. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +104 -98
  72. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +44 -51
  73. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +68 -74
  74. package/dist/components/FormRenderer/helpers/index.js +2 -2
  75. package/dist/components/FormRenderer/index.js +1 -1
  76. package/dist/components/FormRenderer/onCYAAction.js +43 -44
  77. package/dist/components/FormRenderer/onCYAAction.test.js +126 -133
  78. package/dist/components/FormRenderer/onPageAction.js +26 -35
  79. package/dist/components/FormRenderer/onPageAction.test.js +177 -186
  80. package/dist/components/FormRenderer/onTaskAction.js +11 -12
  81. package/dist/components/FormRenderer/onTaskAction.test.js +63 -68
  82. package/dist/components/PageActions/ActionButton.js +14 -14
  83. package/dist/components/PageActions/ActionButton.test.js +57 -79
  84. package/dist/components/PageActions/PageActions.js +11 -11
  85. package/dist/components/PageActions/PageActions.test.js +87 -116
  86. package/dist/components/PageActions/index.js +1 -1
  87. package/dist/components/SummaryList/GroupAction.js +10 -18
  88. package/dist/components/SummaryList/GroupAction.test.js +38 -34
  89. package/dist/components/SummaryList/RowAction.js +12 -17
  90. package/dist/components/SummaryList/RowAction.test.js +38 -34
  91. package/dist/components/SummaryList/SummaryList.js +23 -25
  92. package/dist/components/SummaryList/SummaryList.test.js +162 -189
  93. package/dist/components/SummaryList/SummaryListHeadingRow.js +7 -5
  94. package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +7 -5
  95. package/dist/components/SummaryList/SummaryListRow.js +7 -5
  96. package/dist/components/SummaryList/SummaryListTitleRow.js +6 -4
  97. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
  98. package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +23 -23
  99. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
  100. package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +23 -23
  101. package/dist/components/SummaryList/helpers/index.js +2 -2
  102. package/dist/components/SummaryList/index.js +1 -1
  103. package/dist/components/TaskList/Task.js +20 -30
  104. package/dist/components/TaskList/Task.test.js +84 -77
  105. package/dist/components/TaskList/TaskList.js +56 -79
  106. package/dist/components/TaskList/TaskList.test.js +149 -149
  107. package/dist/components/TaskList/TaskState.js +8 -6
  108. package/dist/components/TaskList/TaskState.test.js +53 -46
  109. package/dist/components/TaskList/index.js +1 -1
  110. package/dist/components/index.js +8 -8
  111. package/dist/context/HooksContext/HooksContext.js +56 -79
  112. package/dist/context/HooksContext/HooksContext.test.js +27 -36
  113. package/dist/context/HooksContext/index.js +3 -4
  114. package/dist/context/ValidationContext/ValidationContext.js +44 -95
  115. package/dist/context/ValidationContext/ValidationContext.test.js +57 -69
  116. package/dist/context/ValidationContext/index.js +3 -4
  117. package/dist/context/index.js +3 -3
  118. package/dist/hooks/index.js +10 -11
  119. package/dist/hooks/useAxios.js +15 -41
  120. package/dist/hooks/useGetRequest.js +62 -98
  121. package/dist/hooks/useHooks.js +1 -3
  122. package/dist/hooks/useRefData.js +25 -37
  123. package/dist/hooks/useValidation.js +1 -3
  124. package/dist/index.js +14 -15
  125. package/dist/models/CollectionLabels.js +1 -1
  126. package/dist/models/ComponentTypes.js +25 -25
  127. package/dist/models/EventTypes.js +4 -4
  128. package/dist/models/FormPages.js +4 -4
  129. package/dist/models/FormTypes.js +8 -8
  130. package/dist/models/HubFormats.js +3 -3
  131. package/dist/models/PageAction.js +44 -38
  132. package/dist/models/TaskStates.js +29 -28
  133. package/dist/models/index.js +10 -10
  134. package/dist/setupTests.js +30 -31
  135. package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
  136. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
  137. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +12 -21
  138. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +32 -33
  139. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +15 -28
  140. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +41 -42
  141. package/dist/utils/CheckYourAnswers/getCYARow.js +7 -7
  142. package/dist/utils/CheckYourAnswers/getCYARow.test.js +87 -87
  143. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +19 -21
  144. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
  145. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +27 -34
  146. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +48 -52
  147. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +76 -93
  148. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +110 -115
  149. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +11 -16
  150. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
  151. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +14 -19
  152. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +69 -73
  153. package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +7 -8
  154. package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +15 -16
  155. package/dist/utils/CheckYourAnswers/index.js +2 -2
  156. package/dist/utils/CheckYourAnswers/showComponentCYA.js +5 -5
  157. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +26 -26
  158. package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
  159. package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +6 -6
  160. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +3 -3
  161. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +18 -19
  162. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +13 -20
  163. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +48 -39
  164. package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
  165. package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +11 -11
  166. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
  167. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +23 -23
  168. package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
  169. package/dist/utils/CollectionPage/getCollectionPageData.test.js +20 -20
  170. package/dist/utils/CollectionPage/getErrorsForCollection.js +20 -21
  171. package/dist/utils/CollectionPage/getErrorsForCollection.test.js +21 -23
  172. package/dist/utils/CollectionPage/getQuickEditPage.js +22 -23
  173. package/dist/utils/CollectionPage/getQuickEditPage.test.js +17 -18
  174. package/dist/utils/CollectionPage/index.js +2 -2
  175. package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -35
  176. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +18 -18
  177. package/dist/utils/CollectionPage/removeCollectionPageEntry.js +5 -7
  178. package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +11 -11
  179. package/dist/utils/CollectionPage/setCollectionPageData.js +10 -16
  180. package/dist/utils/CollectionPage/setCollectionPageData.test.js +25 -25
  181. package/dist/utils/Component/addShowWhen.js +5 -6
  182. package/dist/utils/Component/addShowWhen.test.js +38 -38
  183. package/dist/utils/Component/applyToComponentTree.js +12 -15
  184. package/dist/utils/Component/applyToComponentTree.test.js +28 -31
  185. package/dist/utils/Component/cleanAttributes.js +12 -11
  186. package/dist/utils/Component/cleanAttributes.test.js +17 -18
  187. package/dist/utils/Component/elevateNestedComponents.js +6 -6
  188. package/dist/utils/Component/elevateNestedComponents.test.js +34 -34
  189. package/dist/utils/Component/getComponent.js +79 -85
  190. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
  191. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +41 -58
  192. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +40 -49
  193. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +24 -34
  194. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
  195. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +18 -23
  196. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +21 -26
  197. package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +11 -10
  198. package/dist/utils/Component/getComponentTests/getComponent.html.test.js +18 -16
  199. package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +10 -9
  200. package/dist/utils/Component/getComponentTests/getComponent.list.test.js +18 -16
  201. package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +23 -27
  202. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +201 -226
  203. package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
  204. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +18 -23
  205. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +58 -73
  206. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +18 -23
  207. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +18 -23
  208. package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +32 -39
  209. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +21 -30
  210. package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +3 -3
  211. package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +10 -9
  212. package/dist/utils/Component/getDefaultValue.js +7 -9
  213. package/dist/utils/Component/getDefaultValue.test.js +13 -13
  214. package/dist/utils/Component/getDefaultValueFromConfig.js +16 -20
  215. package/dist/utils/Component/getDefaultValueFromConfig.test.js +32 -32
  216. package/dist/utils/Component/index.js +2 -2
  217. package/dist/utils/Component/isEditable.js +2 -4
  218. package/dist/utils/Component/isEditable.test.js +14 -15
  219. package/dist/utils/Component/optionIsSelected.js +2 -4
  220. package/dist/utils/Component/optionIsSelected.test.js +12 -12
  221. package/dist/utils/Component/setupContainerComponentsPath.js +23 -28
  222. package/dist/utils/Component/setupContainerComponentsPath.test.js +12 -12
  223. package/dist/utils/Component/showComponent.js +2 -2
  224. package/dist/utils/Component/showComponent.test.js +29 -29
  225. package/dist/utils/Component/wrapInFormGroup.js +4 -4
  226. package/dist/utils/Condition/index.js +2 -2
  227. package/dist/utils/Condition/meetsAllConditions.js +9 -9
  228. package/dist/utils/Condition/meetsAllConditions.test.js +21 -21
  229. package/dist/utils/Condition/meetsCondition.js +17 -26
  230. package/dist/utils/Condition/meetsCondition.test.js +403 -403
  231. package/dist/utils/Condition/meetsOneCondition.js +6 -6
  232. package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
  233. package/dist/utils/Condition/setupConditions.js +12 -15
  234. package/dist/utils/Condition/setupConditions.test.js +8 -8
  235. package/dist/utils/Container/getEditableComponents.js +4 -6
  236. package/dist/utils/Container/getEditableComponents.test.js +44 -46
  237. package/dist/utils/Container/index.js +2 -2
  238. package/dist/utils/Container/setupNesting.js +14 -15
  239. package/dist/utils/Container/setupNesting.test.js +20 -23
  240. package/dist/utils/Container/showContainer.js +4 -8
  241. package/dist/utils/Container/showContainer.test.js +31 -31
  242. package/dist/utils/Data/applyFormula.js +30 -44
  243. package/dist/utils/Data/applyFormula.test.js +21 -21
  244. package/dist/utils/Data/deleteValues.js +4 -8
  245. package/dist/utils/Data/deleteValues.test.js +11 -11
  246. package/dist/utils/Data/getAutocompleteSource.js +19 -27
  247. package/dist/utils/Data/getAutocompleteSource.test.js +76 -81
  248. package/dist/utils/Data/getDataPath.js +18 -28
  249. package/dist/utils/Data/getDataPath.test.js +13 -13
  250. package/dist/utils/Data/getOptions.js +35 -42
  251. package/dist/utils/Data/getOptions.test.js +37 -38
  252. package/dist/utils/Data/getSourceData.js +6 -19
  253. package/dist/utils/Data/getSourceData.test.js +85 -81
  254. package/dist/utils/Data/index.js +2 -2
  255. package/dist/utils/Data/nestInRefdataOptions.js +9 -12
  256. package/dist/utils/Data/nestInRefdataOptions.test.js +17 -17
  257. package/dist/utils/Data/refDataToOptions.js +9 -10
  258. package/dist/utils/Data/refDataToOptions.test.js +20 -20
  259. package/dist/utils/Data/setDataItem.js +7 -8
  260. package/dist/utils/Data/setDataItem.test.js +38 -38
  261. package/dist/utils/Data/setupFormData.js +13 -20
  262. package/dist/utils/Data/setupFormData.test.js +48 -47
  263. package/dist/utils/Data/setupRefDataUrlForComponent.js +11 -20
  264. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +25 -25
  265. package/dist/utils/FormPage/applyConditionalProperties.js +7 -8
  266. package/dist/utils/FormPage/applyConditionalProperties.test.js +14 -15
  267. package/dist/utils/FormPage/getConditionalText.js +4 -4
  268. package/dist/utils/FormPage/getConditionalText.test.js +30 -30
  269. package/dist/utils/FormPage/getFormPage.js +12 -15
  270. package/dist/utils/FormPage/getFormPage.test.js +23 -24
  271. package/dist/utils/FormPage/getFormPages.js +8 -11
  272. package/dist/utils/FormPage/getFormPages.test.js +15 -16
  273. package/dist/utils/FormPage/getPageActions.js +10 -13
  274. package/dist/utils/FormPage/getPageActions.test.js +33 -33
  275. package/dist/utils/FormPage/getParagraphFromText.js +5 -7
  276. package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
  277. package/dist/utils/FormPage/index.js +3 -5
  278. package/dist/utils/FormPage/showFormPage.js +4 -8
  279. package/dist/utils/FormPage/showFormPage.test.js +33 -33
  280. package/dist/utils/FormPage/showFormPageCYA.js +2 -2
  281. package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
  282. package/dist/utils/FormPage/useComponent.js +15 -23
  283. package/dist/utils/FormPage/useComponent.test.js +49 -50
  284. package/dist/utils/Format/formatData.js +1 -1
  285. package/dist/utils/Format/formatData.test.js +19 -19
  286. package/dist/utils/Format/formatDataForComponent.js +6 -7
  287. package/dist/utils/Format/formatDataForComponent.test.js +50 -78
  288. package/dist/utils/Format/formatDataForForm.js +5 -6
  289. package/dist/utils/Format/formatDataForForm.test.js +14 -17
  290. package/dist/utils/Format/formatDataForPage.js +4 -5
  291. package/dist/utils/Format/formatDataForPage.test.js +20 -25
  292. package/dist/utils/Format/index.js +2 -2
  293. package/dist/utils/Hub/getFormHub.js +2 -2
  294. package/dist/utils/Hub/getFormHub.test.js +23 -24
  295. package/dist/utils/Hub/index.js +2 -2
  296. package/dist/utils/Meta/constants.js +2 -2
  297. package/dist/utils/Meta/documents/getDocuments.js +1 -1
  298. package/dist/utils/Meta/documents/getDocuments.test.js +25 -17
  299. package/dist/utils/Meta/documents/index.js +2 -2
  300. package/dist/utils/Meta/documents/setDocumentsForField.js +12 -13
  301. package/dist/utils/Meta/documents/setDocumentsForField.test.js +70 -33
  302. package/dist/utils/Meta/index.js +2 -2
  303. package/dist/utils/Operate/checkValueIsTruthy.js +3 -3
  304. package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
  305. package/dist/utils/Operate/deleteValueInFormData.js +2 -2
  306. package/dist/utils/Operate/deleteValueInFormData.test.js +15 -15
  307. package/dist/utils/Operate/getFirstOf.js +6 -6
  308. package/dist/utils/Operate/getFirstOf.test.js +32 -32
  309. package/dist/utils/Operate/getIndexOfMatchingValueIn.js +11 -11
  310. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
  311. package/dist/utils/Operate/getLength.js +9 -9
  312. package/dist/utils/Operate/getLength.test.js +19 -19
  313. package/dist/utils/Operate/index.js +2 -2
  314. package/dist/utils/Operate/persistValueInFormData.js +4 -4
  315. package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
  316. package/dist/utils/Operate/runPageOperations.js +8 -8
  317. package/dist/utils/Operate/runPageOperations.test.js +24 -25
  318. package/dist/utils/Operate/setValueInFormData.js +3 -3
  319. package/dist/utils/Operate/setValueInFormData.test.js +17 -17
  320. package/dist/utils/Operate/shouldRun.js +7 -7
  321. package/dist/utils/Operate/shouldRun.test.js +22 -24
  322. package/dist/utils/Validate/additional/conditionallyPermittedChange.js +1 -1
  323. package/dist/utils/Validate/additional/conditionallyPermittedChange.test.js +15 -15
  324. package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
  325. package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
  326. package/dist/utils/Validate/additional/index.js +8 -8
  327. package/dist/utils/Validate/additional/index.test.js +22 -22
  328. package/dist/utils/Validate/additional/mustBeAfter.js +3 -3
  329. package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
  330. package/dist/utils/Validate/additional/mustBeBefore.js +3 -3
  331. package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
  332. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -12
  333. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -38
  334. package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
  335. package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
  336. package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -3
  337. package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
  338. package/dist/utils/Validate/additional/mustBeInThePast.js +4 -4
  339. package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
  340. package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
  341. package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
  342. package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
  343. package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
  344. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
  345. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
  346. package/dist/utils/Validate/additional/mustBeOneOf.js +1 -1
  347. package/dist/utils/Validate/additional/mustBeOneOf.test.js +13 -13
  348. package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
  349. package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
  350. package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +5 -5
  351. package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +35 -36
  352. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
  353. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
  354. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
  355. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
  356. package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
  357. package/dist/utils/Validate/additional/mustNotContainSql.test.js +15 -15
  358. package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
  359. package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
  360. package/dist/utils/Validate/additional/utils.js +9 -22
  361. package/dist/utils/Validate/index.js +2 -2
  362. package/dist/utils/Validate/validateCollection.js +18 -23
  363. package/dist/utils/Validate/validateCollection.test.js +75 -67
  364. package/dist/utils/Validate/validateComponent.js +19 -19
  365. package/dist/utils/Validate/validateComponent.test.js +179 -154
  366. package/dist/utils/Validate/validateContainer.js +14 -17
  367. package/dist/utils/Validate/validateContainer.test.js +59 -53
  368. package/dist/utils/Validate/validateDate.js +16 -22
  369. package/dist/utils/Validate/validateDate.test.js +31 -32
  370. package/dist/utils/Validate/validateEmail.js +7 -9
  371. package/dist/utils/Validate/validateEmail.test.js +27 -27
  372. package/dist/utils/Validate/validateMultifile.js +5 -7
  373. package/dist/utils/Validate/validateMultifile.test.js +17 -18
  374. package/dist/utils/Validate/validatePage.js +13 -18
  375. package/dist/utils/Validate/validatePage.test.js +198 -195
  376. package/dist/utils/Validate/validateRegex.js +3 -5
  377. package/dist/utils/Validate/validateRegex.test.js +15 -15
  378. package/dist/utils/Validate/validateRequired.js +4 -6
  379. package/dist/utils/Validate/validateRequired.test.js +19 -19
  380. package/dist/utils/Validate/validateTextArea.js +4 -6
  381. package/dist/utils/Validate/validateTextArea.test.js +21 -21
  382. package/dist/utils/Validate/validateTime.js +12 -19
  383. package/dist/utils/Validate/validateTime.test.js +27 -27
  384. package/dist/utils/index.js +5 -6
  385. package/package.json +2 -4
@@ -13,38 +13,38 @@ var _SummaryListHeadingRow = _interopRequireDefault(require("./SummaryListHeadin
13
13
  var _SummaryListHeadingRowWithAction = _interopRequireDefault(require("./SummaryListHeadingRowWithAction"));
14
14
  var _SummaryListTitleRow = _interopRequireDefault(require("./SummaryListTitleRow"));
15
15
  require("./SummaryList.scss");
16
- var _excluded = ["rows", "noChangeAction", "noGroupAction", "isGroup", "classBlock", "classModifiers", "className"]; // Global imports
16
+ const _excluded = ["rows", "noChangeAction", "noGroupAction", "isGroup", "classBlock", "classModifiers", "className"]; // Global imports
17
17
  // Local imports
18
18
  // Styles
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
21
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
22
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
23
- var DEFAULT_CLASS = exports.DEFAULT_CLASS = 'govuk-summary-list';
24
- var SummaryList = function SummaryList(_ref) {
25
- var rows = _ref.rows,
26
- noChangeAction = _ref.noChangeAction,
27
- noGroupAction = _ref.noGroupAction,
28
- isGroup = _ref.isGroup,
29
- classBlock = _ref.classBlock,
30
- classModifiers = _ref.classModifiers,
31
- className = _ref.className,
19
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
21
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
22
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
23
+ const DEFAULT_CLASS = exports.DEFAULT_CLASS = 'govuk-summary-list';
24
+ const SummaryList = _ref => {
25
+ let {
26
+ rows,
27
+ noChangeAction,
28
+ noGroupAction,
29
+ isGroup,
30
+ classBlock,
31
+ classModifiers,
32
+ className
33
+ } = _ref,
32
34
  attrs = _objectWithoutProperties(_ref, _excluded);
33
- var classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
34
- var cleanedHtmlAttrs = _copReactComponents.Utils.cleanHtmlAttributes(attrs);
35
- var groupActionRow = null;
35
+ const classes = _copReactComponents.Utils.classBuilder(classBlock, classModifiers, className);
36
+ const cleanedHtmlAttrs = _copReactComponents.Utils.cleanHtmlAttributes(attrs);
37
+ let groupActionRow = null;
36
38
  if (isGroup) {
37
- var rowActions = rows.filter(function (r) {
38
- return !!r.action;
39
- });
39
+ const rowActions = rows.filter(r => !!r.action);
40
40
  groupActionRow = rowActions !== null && rowActions !== void 0 && rowActions.length ? rowActions[0] : null;
41
41
  }
42
42
  return /*#__PURE__*/_react.default.createElement("div", {
43
43
  className: "group-of-rows"
44
44
  }, /*#__PURE__*/_react.default.createElement("dl", _extends({}, cleanedHtmlAttrs, {
45
45
  className: classes()
46
- }), rows.map(function (row) {
47
- var key = "".concat(row.pageId, "_").concat(row.full_path || row.fieldId);
46
+ }), rows.map(row => {
47
+ const key = "".concat(row.pageId, "_").concat(row.full_path || row.fieldId);
48
48
  if (row.type === 'title') {
49
49
  return /*#__PURE__*/_react.default.createElement(_SummaryListTitleRow.default, {
50
50
  key: key,
@@ -80,9 +80,7 @@ var SummaryList = function SummaryList(_ref) {
80
80
  classes: classes,
81
81
  showAction: !noChangeAction
82
82
  });
83
- }).filter(function (r) {
84
- return !!r;
85
- }), isGroup && !noGroupAction && /*#__PURE__*/_react.default.createElement("div", {
83
+ }).filter(r => !!r), isGroup && !noGroupAction && /*#__PURE__*/_react.default.createElement("div", {
86
84
  className: "change-group-button"
87
85
  }, /*#__PURE__*/_react.default.createElement(_GroupAction.default, {
88
86
  group: groupActionRow
@@ -1,53 +1,45 @@
1
1
  "use strict";
2
2
 
3
- 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); }
4
3
  var _react = require("@testing-library/react");
5
4
  var _react2 = _interopRequireDefault(require("react"));
6
5
  var _SummaryList = _interopRequireWildcard(require("./SummaryList"));
7
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
8
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // Global imports
6
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
7
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ // Global imports
10
+
16
11
  // Local imports
17
- describe('components', function () {
18
- describe('SummaryList', function () {
19
- var checkSummaryList = function checkSummaryList(container, id) {
20
- var summaryList = (0, _react.getByTestId)(container, id);
12
+
13
+ describe('components', () => {
14
+ describe('SummaryList', () => {
15
+ const checkSummaryList = (container, id) => {
16
+ const summaryList = (0, _react.getByTestId)(container, id);
21
17
  expect(summaryList.tagName).toEqual('DL');
22
18
  expect(summaryList.classList).toContain(_SummaryList.DEFAULT_CLASS);
23
19
  return summaryList;
24
20
  };
25
- var checkTitleRow = function checkTitleRow(summaryList, index) {
26
- var row = summaryList.childNodes[index];
21
+ const checkTitleRow = (summaryList, index) => {
22
+ const row = summaryList.childNodes[index];
27
23
  expect(row.tagName).toEqual('DIV');
28
24
  expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__row"));
29
25
  expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__title"));
30
- var _row$childNodes = _slicedToArray(row.childNodes, 1),
31
- heading = _row$childNodes[0];
26
+ const [heading] = row.childNodes;
32
27
  expect(heading.tagName).toEqual('H3');
33
28
  expect(heading.classList).toContain('govuk-heading-s');
34
29
  return heading;
35
30
  };
36
- var checkActionRow = function checkActionRow(summaryList, index) {
37
- var row = summaryList.childNodes[index];
31
+ const checkActionRow = (summaryList, index) => {
32
+ const row = summaryList.childNodes[index];
38
33
  expect(row.tagName).toEqual('DIV');
39
34
  expect(row.childNodes.length).toEqual(1);
40
- var link = row.childNodes[0];
35
+ const link = row.childNodes[0];
41
36
  return link;
42
37
  };
43
- var checkRow = function checkRow(summaryList, index) {
44
- var row = summaryList.childNodes[index];
38
+ const checkRow = (summaryList, index) => {
39
+ const row = summaryList.childNodes[index];
45
40
  expect(row.tagName).toEqual('DIV');
46
41
  expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__row"));
47
- var _row$childNodes2 = _slicedToArray(row.childNodes, 3),
48
- key = _row$childNodes2[0],
49
- value = _row$childNodes2[1],
50
- actions = _row$childNodes2[2];
42
+ const [key, value, actions] = row.childNodes;
51
43
  expect(key.tagName).toEqual('DT');
52
44
  expect(key.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__key"));
53
45
  expect(value.tagName).toEqual('DD');
@@ -56,26 +48,22 @@ describe('components', function () {
56
48
  expect(actions.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__actions"));
57
49
  return [key, value, actions];
58
50
  };
59
- var checkHeadingRowWithAction = function checkHeadingRowWithAction(summaryList, index) {
60
- var row = summaryList.childNodes[index];
51
+ const checkHeadingRowWithAction = (summaryList, index) => {
52
+ const row = summaryList.childNodes[index];
61
53
  expect(row.tagName).toEqual('DIV');
62
54
  expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__headingWithAction"));
63
- var _row$childNodes3 = _slicedToArray(row.childNodes, 2),
64
- key = _row$childNodes3[0],
65
- action = _row$childNodes3[1];
55
+ const [key, action] = row.childNodes;
66
56
  expect(key.tagName).toEqual('TD');
67
57
  expect(key.classList).toContain('heading-text');
68
58
  expect(action.tagName).toEqual('TD');
69
59
  expect(action.classList).toContain('heading-action');
70
60
  return [key, action];
71
61
  };
72
- var checkRowNoChangeActions = function checkRowNoChangeActions(summaryList, index) {
73
- var row = summaryList.childNodes[index];
62
+ const checkRowNoChangeActions = (summaryList, index) => {
63
+ const row = summaryList.childNodes[index];
74
64
  expect(row.tagName).toEqual('DIV');
75
65
  expect(row.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__row"));
76
- var _row$childNodes4 = _slicedToArray(row.childNodes, 2),
77
- key = _row$childNodes4[0],
78
- value = _row$childNodes4[1];
66
+ const [key, value] = row.childNodes;
79
67
  expect(key.tagName).toEqual('DT');
80
68
  expect(key.classList).toContain("".concat(_SummaryList.DEFAULT_CLASS, "__key"));
81
69
  expect(value.tagName).toEqual('DD');
@@ -83,20 +71,21 @@ describe('components', function () {
83
71
  expect(row.childNodes.length).toEqual(2);
84
72
  return [key, value];
85
73
  };
86
- it('should handle an empty rows array', function () {
87
- var ID = 'test-id';
88
- var ROWS = [];
89
- var _render = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
90
- "data-testid": ID,
91
- rows: ROWS
92
- })),
93
- container = _render.container;
94
- var summaryList = checkSummaryList(container, ID);
74
+ it('should handle an empty rows array', () => {
75
+ const ID = 'test-id';
76
+ const ROWS = [];
77
+ const {
78
+ container
79
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
80
+ "data-testid": ID,
81
+ rows: ROWS
82
+ }));
83
+ const summaryList = checkSummaryList(container, ID);
95
84
  expect(summaryList.childNodes.length).toEqual(0);
96
85
  });
97
- it('should handle rows with no actions and string values', function () {
98
- var ID = 'test-id';
99
- var ROWS = [{
86
+ it('should handle rows with no actions and string values', () => {
87
+ const ID = 'test-id';
88
+ const ROWS = [{
100
89
  key: 'a',
101
90
  pageId: 'p1',
102
91
  fieldId: 'a',
@@ -107,28 +96,25 @@ describe('components', function () {
107
96
  fieldId: 'b',
108
97
  value: 'Bravo value'
109
98
  }];
110
- var _render2 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
111
- "data-testid": ID,
112
- rows: ROWS,
113
- noGroupAction: true
114
- })),
115
- container = _render2.container;
116
- var summaryList = checkSummaryList(container, ID);
99
+ const {
100
+ container
101
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
102
+ "data-testid": ID,
103
+ rows: ROWS,
104
+ noGroupAction: true
105
+ }));
106
+ const summaryList = checkSummaryList(container, ID);
117
107
  expect(summaryList.childNodes.length).toEqual(ROWS.length);
118
- ROWS.forEach(function (row, index) {
119
- var _checkRow = checkRow(summaryList, index),
120
- _checkRow2 = _slicedToArray(_checkRow, 3),
121
- key = _checkRow2[0],
122
- value = _checkRow2[1],
123
- actions = _checkRow2[2];
108
+ ROWS.forEach((row, index) => {
109
+ const [key, value, actions] = checkRow(summaryList, index);
124
110
  expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
125
111
  expect(value.textContent).toEqual(row.value);
126
112
  expect(actions.childNodes.length).toEqual(0);
127
113
  });
128
114
  });
129
- it('should handle title rows', function () {
130
- var ID = 'test-id';
131
- var ROWS = [{
115
+ it('should handle title rows', () => {
116
+ const ID = 'test-id';
117
+ const ROWS = [{
132
118
  key: 'Title',
133
119
  pageId: 'p1',
134
120
  fieldId: 'a',
@@ -144,28 +130,25 @@ describe('components', function () {
144
130
  fieldId: 'c',
145
131
  value: 'Bravo value'
146
132
  }];
147
- var _render3 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
148
- "data-testid": ID,
149
- rows: ROWS
150
- })),
151
- container = _render3.container;
152
- var summaryList = checkSummaryList(container, ID);
133
+ const {
134
+ container
135
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
136
+ "data-testid": ID,
137
+ rows: ROWS
138
+ }));
139
+ const summaryList = checkSummaryList(container, ID);
153
140
  expect(summaryList.childNodes.length).toEqual(ROWS.length);
154
- var assessTitleRow = function assessTitleRow(row, index) {
155
- var heading = checkTitleRow(summaryList, index);
141
+ const assessTitleRow = (row, index) => {
142
+ const heading = checkTitleRow(summaryList, index);
156
143
  expect(heading.textContent).toEqual(row.key);
157
144
  };
158
- var assessRow = function assessRow(row, index) {
159
- var _checkRow3 = checkRow(summaryList, index),
160
- _checkRow4 = _slicedToArray(_checkRow3, 3),
161
- key = _checkRow4[0],
162
- value = _checkRow4[1],
163
- actions = _checkRow4[2];
145
+ const assessRow = (row, index) => {
146
+ const [key, value, actions] = checkRow(summaryList, index);
164
147
  expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
165
148
  expect(value.textContent).toEqual(row.value);
166
149
  expect(actions.childNodes.length).toEqual(0);
167
150
  };
168
- ROWS.forEach(function (row, index) {
151
+ ROWS.forEach((row, index) => {
169
152
  if (row.type === 'title') {
170
153
  assessTitleRow(row, index);
171
154
  } else {
@@ -173,9 +156,9 @@ describe('components', function () {
173
156
  }
174
157
  });
175
158
  });
176
- it('should handle action rows', function () {
177
- var ID = 'test-id';
178
- var ROWS = [{
159
+ it('should handle action rows', () => {
160
+ const ID = 'test-id';
161
+ const ROWS = [{
179
162
  key: 'a',
180
163
  pageId: 'p1',
181
164
  fieldId: 'a',
@@ -200,24 +183,25 @@ describe('components', function () {
200
183
  label: 'Do action'
201
184
  }
202
185
  }];
203
- var _render4 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
204
- "data-testid": ID,
205
- rows: ROWS
206
- })),
207
- container = _render4.container;
208
- var summaryList = checkSummaryList(container, ID);
186
+ const {
187
+ container
188
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
189
+ "data-testid": ID,
190
+ rows: ROWS
191
+ }));
192
+ const summaryList = checkSummaryList(container, ID);
209
193
  expect(summaryList.childNodes.length).toEqual(ROWS.length);
210
- var assessActionRow = function assessActionRow(row, index) {
211
- var link = checkActionRow(summaryList, index);
194
+ const assessActionRow = (row, index) => {
195
+ const link = checkActionRow(summaryList, index);
212
196
  expect(link.textContent).toEqual(row.action.label);
213
197
  };
214
- ROWS.forEach(function (row, index) {
198
+ ROWS.forEach((row, index) => {
215
199
  assessActionRow(row, index);
216
200
  });
217
201
  });
218
- it('should hide actions rows if flag is given', function () {
219
- var ID = 'test-id';
220
- var ROWS = [{
202
+ it('should hide actions rows if flag is given', () => {
203
+ const ID = 'test-id';
204
+ const ROWS = [{
221
205
  key: 'a',
222
206
  pageId: 'p1',
223
207
  fieldId: 'a',
@@ -242,19 +226,20 @@ describe('components', function () {
242
226
  label: 'Do action'
243
227
  }
244
228
  }];
245
- var _render5 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
246
- "data-testid": ID,
247
- rows: ROWS,
248
- noChangeAction: true
249
- })),
250
- container = _render5.container;
251
- var summaryList = checkSummaryList(container, ID);
229
+ const {
230
+ container
231
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
232
+ "data-testid": ID,
233
+ rows: ROWS,
234
+ noChangeAction: true
235
+ }));
236
+ const summaryList = checkSummaryList(container, ID);
252
237
  expect(summaryList.childNodes.length).toEqual(0);
253
238
  });
254
- it('should handle rows with no actions and component values', function () {
255
- var ID = 'test-id';
256
- var VALUES = ['Alpha component value', 'Bravo component value'];
257
- var ROWS = [{
239
+ it('should handle rows with no actions and component values', () => {
240
+ const ID = 'test-id';
241
+ const VALUES = ['Alpha component value', 'Bravo component value'];
242
+ const ROWS = [{
258
243
  key: 'a',
259
244
  pageId: 'p1',
260
245
  fieldId: 'a',
@@ -265,34 +250,31 @@ describe('components', function () {
265
250
  fieldId: 'b',
266
251
  value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[1])
267
252
  }];
268
- var _render6 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
269
- "data-testid": ID,
270
- rows: ROWS
271
- })),
272
- container = _render6.container;
273
- var summaryList = checkSummaryList(container, ID);
253
+ const {
254
+ container
255
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
256
+ "data-testid": ID,
257
+ rows: ROWS
258
+ }));
259
+ const summaryList = checkSummaryList(container, ID);
274
260
  expect(summaryList.childNodes.length).toEqual(ROWS.length);
275
- ROWS.forEach(function (row, index) {
276
- var _checkRow5 = checkRow(summaryList, index),
277
- _checkRow6 = _slicedToArray(_checkRow5, 3),
278
- key = _checkRow6[0],
279
- value = _checkRow6[1],
280
- actions = _checkRow6[2];
261
+ ROWS.forEach((row, index) => {
262
+ const [key, value, actions] = checkRow(summaryList, index);
281
263
  expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
282
264
  expect(value.childNodes.length).toEqual(1);
283
- var valueDiv = value.childNodes[0];
265
+ const valueDiv = value.childNodes[0];
284
266
  expect(valueDiv.tagName).toEqual('DIV');
285
267
  expect(valueDiv.textContent).toEqual(VALUES[index]);
286
268
  expect(actions.childNodes.length).toEqual(0);
287
269
  });
288
270
  });
289
- it('should handle rows with actions', function () {
290
- var ID = 'test-id';
291
- var ON_ACTION_CALLS = [];
292
- var ON_ACTION = function ON_ACTION(row) {
271
+ it('should handle rows with actions', () => {
272
+ const ID = 'test-id';
273
+ const ON_ACTION_CALLS = [];
274
+ const ON_ACTION = row => {
293
275
  ON_ACTION_CALLS.push(row);
294
276
  };
295
- var ROWS = [{
277
+ const ROWS = [{
296
278
  key: 'a',
297
279
  pageId: 'p1',
298
280
  fieldId: 'a',
@@ -311,35 +293,32 @@ describe('components', function () {
311
293
  onAction: ON_ACTION
312
294
  }
313
295
  }];
314
- var _render7 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
315
- "data-testid": ID,
316
- rows: ROWS
317
- })),
318
- container = _render7.container;
319
- var summaryList = checkSummaryList(container, ID);
296
+ const {
297
+ container
298
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
299
+ "data-testid": ID,
300
+ rows: ROWS
301
+ }));
302
+ const summaryList = checkSummaryList(container, ID);
320
303
  expect(summaryList.childNodes.length).toEqual(ROWS.length);
321
- ROWS.forEach(function (row, index) {
322
- var _checkRow7 = checkRow(summaryList, index),
323
- _checkRow8 = _slicedToArray(_checkRow7, 3),
324
- key = _checkRow8[0],
325
- value = _checkRow8[1],
326
- actions = _checkRow8[2];
304
+ ROWS.forEach((row, index) => {
305
+ const [key, value, actions] = checkRow(summaryList, index);
327
306
  expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
328
307
  expect(value.textContent).toEqual(row.value);
329
- var a = actions.childNodes[0];
308
+ const a = actions.childNodes[0];
330
309
  expect(a.textContent).toEqual(row.action.label);
331
310
  _react.fireEvent.click(a, {});
332
311
  expect(ON_ACTION_CALLS.length).toEqual(index + 1);
333
312
  expect(ON_ACTION_CALLS[index]).toEqual(row);
334
313
  });
335
314
  });
336
- it('should handle heading rows with actions', function () {
337
- var ID = 'test-id';
338
- var ON_ACTION_CALLS = [];
339
- var ON_ACTION = function ON_ACTION(row) {
315
+ it('should handle heading rows with actions', () => {
316
+ const ID = 'test-id';
317
+ const ON_ACTION_CALLS = [];
318
+ const ON_ACTION = row => {
340
319
  ON_ACTION_CALLS.push(row);
341
320
  };
342
- var ROWS = [{
321
+ const ROWS = [{
343
322
  key: 'a',
344
323
  pageId: 'p1',
345
324
  type: 'headingWithAction',
@@ -358,20 +337,18 @@ describe('components', function () {
358
337
  onAction: ON_ACTION
359
338
  }
360
339
  }];
361
- var _render8 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
362
- "data-testid": ID,
363
- rows: ROWS
364
- })),
365
- container = _render8.container;
366
- var summaryList = checkSummaryList(container, ID);
340
+ const {
341
+ container
342
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
343
+ "data-testid": ID,
344
+ rows: ROWS
345
+ }));
346
+ const summaryList = checkSummaryList(container, ID);
367
347
  expect(summaryList.childNodes.length).toEqual(ROWS.length);
368
- ROWS.forEach(function (row, index) {
369
- var _checkHeadingRowWithA = checkHeadingRowWithAction(summaryList, index),
370
- _checkHeadingRowWithA2 = _slicedToArray(_checkHeadingRowWithA, 2),
371
- key = _checkHeadingRowWithA2[0],
372
- actions = _checkHeadingRowWithA2[1];
348
+ ROWS.forEach((row, index) => {
349
+ const [key, actions] = checkHeadingRowWithAction(summaryList, index);
373
350
  expect(key.textContent).toEqual("".concat(row.key));
374
- var a = actions.childNodes[0];
351
+ const a = actions.childNodes[0];
375
352
  expect(a.textContent).toEqual(row.action.label);
376
353
  _react.fireEvent.click(a, {});
377
354
  expect(ON_ACTION_CALLS.length).toEqual(index + 1);
@@ -380,10 +357,10 @@ describe('components', function () {
380
357
  });
381
358
  });
382
359
  });
383
- it('should handle rows with component values and actions set to hidden', function () {
384
- var ID = 'test-id';
385
- var VALUES = ['Alpha component value', 'Bravo component value'];
386
- var ROWS = [{
360
+ it('should handle rows with component values and actions set to hidden', () => {
361
+ const ID = 'test-id';
362
+ const VALUES = ['Alpha component value', 'Bravo component value'];
363
+ const ROWS = [{
387
364
  key: 'a',
388
365
  pageId: 'p1',
389
366
  fieldId: 'a',
@@ -394,31 +371,29 @@ describe('components', function () {
394
371
  fieldId: 'b',
395
372
  value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[1])
396
373
  }];
397
- var _render9 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
398
- "data-testid": ID,
399
- rows: ROWS,
400
- noChangeAction: true
401
- })),
402
- container = _render9.container;
403
- var summaryList = checkSummaryList(container, ID);
374
+ const {
375
+ container
376
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
377
+ "data-testid": ID,
378
+ rows: ROWS,
379
+ noChangeAction: true
380
+ }));
381
+ const summaryList = checkSummaryList(container, ID);
404
382
  expect(summaryList.childNodes.length).toEqual(ROWS.length);
405
- ROWS.forEach(function (row, index) {
406
- var _checkRowNoChangeActi = checkRowNoChangeActions(summaryList, index),
407
- _checkRowNoChangeActi2 = _slicedToArray(_checkRowNoChangeActi, 2),
408
- key = _checkRowNoChangeActi2[0],
409
- value = _checkRowNoChangeActi2[1];
383
+ ROWS.forEach((row, index) => {
384
+ const [key, value] = checkRowNoChangeActions(summaryList, index);
410
385
  expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
411
386
  expect(value.childNodes.length).toEqual(1);
412
- var valueDiv = value.childNodes[0];
387
+ const valueDiv = value.childNodes[0];
413
388
  expect(valueDiv.tagName).toEqual('DIV');
414
389
  expect(valueDiv.textContent).toEqual(VALUES[index]);
415
390
  });
416
391
  });
417
- it('should render groups of rows correctly', function () {
418
- var ID = 'test-id';
419
- var VALUES = ['Alpha component value', 'Bravo component value', 'Charlie component value'];
420
- var ISGROUP = true;
421
- var ROWS = [{
392
+ it('should render groups of rows correctly', () => {
393
+ const ID = 'test-id';
394
+ const VALUES = ['Alpha component value', 'Bravo component value', 'Charlie component value'];
395
+ const ISGROUP = true;
396
+ const ROWS = [{
422
397
  key: 'a',
423
398
  pageId: 'p1',
424
399
  fieldId: 'a',
@@ -437,22 +412,20 @@ describe('components', function () {
437
412
  fieldId: 'c',
438
413
  value: /*#__PURE__*/_react2.default.createElement("div", null, VALUES[2])
439
414
  }];
440
- var _render10 = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
441
- "data-testid": ID,
442
- rows: ROWS,
443
- isGroup: ISGROUP
444
- })),
445
- container = _render10.container;
446
- var summaryList = checkSummaryList(container, ID);
415
+ const {
416
+ container
417
+ } = (0, _react.render)(/*#__PURE__*/_react2.default.createElement(_SummaryList.default, {
418
+ "data-testid": ID,
419
+ rows: ROWS,
420
+ isGroup: ISGROUP
421
+ }));
422
+ const summaryList = checkSummaryList(container, ID);
447
423
  expect(summaryList.childNodes.length).toEqual(ROWS.length + 1);
448
- ROWS.forEach(function (row, index) {
449
- var _checkRow9 = checkRow(summaryList, index),
450
- _checkRow10 = _slicedToArray(_checkRow9, 2),
451
- key = _checkRow10[0],
452
- value = _checkRow10[1];
424
+ ROWS.forEach((row, index) => {
425
+ const [key, value] = checkRow(summaryList, index);
453
426
  expect(key.textContent).toEqual("".concat(row.key, " (optional)"));
454
427
  expect(value.childNodes.length).toEqual(1);
455
- var valueDiv = value.childNodes[0];
428
+ const valueDiv = value.childNodes[0];
456
429
  expect(valueDiv.tagName).toEqual('DIV');
457
430
  expect(valueDiv.textContent).toEqual(VALUES[index]);
458
431
  });
@@ -7,13 +7,15 @@ exports.default = void 0;
7
7
  var _copReactComponents = require("@ukhomeoffice/cop-react-components");
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _react = _interopRequireDefault(require("react"));
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  // Global imports
12
12
 
13
- var SummaryListHeadingRow = function SummaryListHeadingRow(_ref) {
14
- var title = _ref.title,
15
- size = _ref.size,
16
- classes = _ref.classes;
13
+ const SummaryListHeadingRow = _ref => {
14
+ let {
15
+ title,
16
+ size,
17
+ classes
18
+ } = _ref;
17
19
  return /*#__PURE__*/_react.default.createElement("div", {
18
20
  className: "".concat(classes('heading'))
19
21
  }, size === 's' && /*#__PURE__*/_react.default.createElement(_copReactComponents.SmallHeading, null, title), size === 'm' && /*#__PURE__*/_react.default.createElement(_copReactComponents.MediumHeading, null, title));