@ukhomeoffice/cop-react-form-renderer 5.14.0 → 5.14.4

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 (328) hide show
  1. package/dist/components/CheckYourAnswers/Answer.js +15 -15
  2. package/dist/components/CheckYourAnswers/Answer.test.js +94 -128
  3. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +99 -129
  4. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +291 -501
  5. package/dist/components/CheckYourAnswers/index.js +2 -3
  6. package/dist/components/CollectionPage/CollectionPage.js +64 -58
  7. package/dist/components/CollectionPage/CollectionPage.test.js +212 -238
  8. package/dist/components/CollectionPage/index.js +2 -3
  9. package/dist/components/FormComponent/Collection.js +77 -113
  10. package/dist/components/FormComponent/Collection.test.js +688 -787
  11. package/dist/components/FormComponent/Container.js +44 -43
  12. package/dist/components/FormComponent/Container.test.js +316 -346
  13. package/dist/components/FormComponent/FormComponent.js +58 -64
  14. package/dist/components/FormComponent/FormComponent.test.js +180 -219
  15. package/dist/components/FormComponent/helpers/addLabel.js +5 -9
  16. package/dist/components/FormComponent/helpers/getComponentDisabled.js +2 -3
  17. package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +8 -8
  18. package/dist/components/FormComponent/helpers/getComponentError.js +4 -7
  19. package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
  20. package/dist/components/FormComponent/helpers/getComponentFieldSet.js +2 -2
  21. package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +7 -7
  22. package/dist/components/FormComponent/helpers/index.js +5 -5
  23. package/dist/components/FormComponent/index.js +2 -3
  24. package/dist/components/FormPage/FormPage.js +65 -79
  25. package/dist/components/FormPage/FormPage.test.js +134 -170
  26. package/dist/components/FormPage/index.js +2 -3
  27. package/dist/components/FormRenderer/FormRenderer.js +151 -193
  28. package/dist/components/FormRenderer/FormRenderer.test.js +598 -920
  29. package/dist/components/FormRenderer/handlers/cyaAction.js +4 -5
  30. package/dist/components/FormRenderer/handlers/getPageId.js +2 -5
  31. package/dist/components/FormRenderer/handlers/getPageId.test.js +15 -15
  32. package/dist/components/FormRenderer/handlers/handlers.test.js +33 -33
  33. package/dist/components/FormRenderer/handlers/index.js +3 -4
  34. package/dist/components/FormRenderer/handlers/navigate.js +5 -6
  35. package/dist/components/FormRenderer/handlers/submissionError.js +2 -3
  36. package/dist/components/FormRenderer/helpers/canActionProceed.js +2 -3
  37. package/dist/components/FormRenderer/helpers/canActionProceed.test.js +10 -10
  38. package/dist/components/FormRenderer/helpers/canCYASubmit.js +2 -5
  39. package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
  40. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +19 -27
  41. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +17 -17
  42. package/dist/components/FormRenderer/helpers/getCYA.js +6 -9
  43. package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
  44. package/dist/components/FormRenderer/helpers/getFormState.js +7 -10
  45. package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
  46. package/dist/components/FormRenderer/helpers/getNextPageId.js +19 -34
  47. package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
  48. package/dist/components/FormRenderer/helpers/getPage.js +3 -6
  49. package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
  50. package/dist/components/FormRenderer/helpers/getRelevantPages.js +9 -13
  51. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
  52. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +12 -13
  53. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +98 -92
  54. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +66 -66
  55. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +72 -79
  56. package/dist/components/FormRenderer/helpers/index.js +3 -4
  57. package/dist/components/FormRenderer/index.js +2 -3
  58. package/dist/components/FormRenderer/onCYAAction.js +52 -62
  59. package/dist/components/FormRenderer/onCYAAction.test.js +146 -138
  60. package/dist/components/FormRenderer/onPageAction.js +48 -47
  61. package/dist/components/FormRenderer/onPageAction.test.js +219 -205
  62. package/dist/components/FormRenderer/onTaskAction.js +12 -17
  63. package/dist/components/FormRenderer/onTaskAction.test.js +94 -89
  64. package/dist/components/PageActions/ActionButton.js +15 -19
  65. package/dist/components/PageActions/ActionButton.test.js +58 -79
  66. package/dist/components/PageActions/PageActions.js +12 -13
  67. package/dist/components/PageActions/PageActions.test.js +88 -116
  68. package/dist/components/PageActions/index.js +2 -3
  69. package/dist/components/SummaryList/GroupAction.js +15 -23
  70. package/dist/components/SummaryList/GroupAction.test.js +41 -37
  71. package/dist/components/SummaryList/RowAction.js +14 -19
  72. package/dist/components/SummaryList/RowAction.test.js +41 -37
  73. package/dist/components/SummaryList/SummaryList.js +25 -30
  74. package/dist/components/SummaryList/SummaryList.test.js +160 -182
  75. package/dist/components/SummaryList/SummaryListHeadingRow.js +9 -8
  76. package/dist/components/SummaryList/SummaryListRow.js +9 -8
  77. package/dist/components/SummaryList/SummaryListTitleRow.js +8 -7
  78. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +5 -8
  79. package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +24 -24
  80. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +5 -8
  81. package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +24 -24
  82. package/dist/components/SummaryList/helpers/index.js +2 -2
  83. package/dist/components/SummaryList/index.js +2 -3
  84. package/dist/components/TaskList/Task.js +22 -33
  85. package/dist/components/TaskList/Task.test.js +84 -77
  86. package/dist/components/TaskList/TaskList.js +46 -75
  87. package/dist/components/TaskList/TaskList.test.js +118 -113
  88. package/dist/components/TaskList/TaskState.js +9 -9
  89. package/dist/components/TaskList/TaskState.test.js +56 -49
  90. package/dist/components/TaskList/index.js +2 -3
  91. package/dist/components/index.js +8 -8
  92. package/dist/context/HooksContext/HooksContext.js +59 -85
  93. package/dist/context/HooksContext/HooksContext.test.js +28 -36
  94. package/dist/context/HooksContext/index.js +4 -6
  95. package/dist/context/ValidationContext/ValidationContext.js +35 -76
  96. package/dist/context/ValidationContext/ValidationContext.test.js +50 -61
  97. package/dist/context/ValidationContext/index.js +4 -6
  98. package/dist/context/index.js +3 -3
  99. package/dist/hooks/index.js +10 -11
  100. package/dist/hooks/useAxios.js +17 -43
  101. package/dist/hooks/useGetRequest.js +65 -106
  102. package/dist/hooks/useHooks.js +2 -5
  103. package/dist/hooks/useRefData.js +30 -45
  104. package/dist/hooks/useValidation.js +2 -5
  105. package/dist/index.js +15 -17
  106. package/dist/models/CollectionLabels.js +2 -3
  107. package/dist/models/ComponentTypes.js +25 -26
  108. package/dist/models/EventTypes.js +5 -6
  109. package/dist/models/FormPages.js +5 -6
  110. package/dist/models/FormTypes.js +9 -10
  111. package/dist/models/HubFormats.js +4 -5
  112. package/dist/models/PageAction.js +45 -42
  113. package/dist/models/TaskStates.js +30 -31
  114. package/dist/models/index.js +11 -12
  115. package/dist/setupTests.js +20 -24
  116. package/dist/utils/CheckYourAnswers/getCYAAction.js +6 -7
  117. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
  118. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +18 -20
  119. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +21 -23
  120. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +17 -21
  121. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +18 -20
  122. package/dist/utils/CheckYourAnswers/getCYARow.js +8 -10
  123. package/dist/utils/CheckYourAnswers/getCYARow.test.js +72 -72
  124. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +20 -27
  125. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
  126. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +41 -47
  127. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +72 -75
  128. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +71 -78
  129. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +133 -114
  130. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +27 -23
  131. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
  132. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +16 -23
  133. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +77 -83
  134. package/dist/utils/CheckYourAnswers/index.js +3 -4
  135. package/dist/utils/CheckYourAnswers/showComponentCYA.js +7 -9
  136. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +25 -25
  137. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +9 -16
  138. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +19 -20
  139. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +4 -8
  140. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +15 -15
  141. package/dist/utils/CollectionPage/index.js +3 -4
  142. package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -29
  143. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +15 -15
  144. package/dist/utils/Component/addShowWhen.js +5 -10
  145. package/dist/utils/Component/addShowWhen.test.js +38 -38
  146. package/dist/utils/Component/applyToComponentTree.js +20 -22
  147. package/dist/utils/Component/applyToComponentTree.test.js +28 -33
  148. package/dist/utils/Component/cleanAttributes.js +11 -16
  149. package/dist/utils/Component/cleanAttributes.test.js +17 -18
  150. package/dist/utils/Component/elevateNestedComponents.js +7 -9
  151. package/dist/utils/Component/elevateNestedComponents.test.js +19 -19
  152. package/dist/utils/Component/getComponent.js +91 -99
  153. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
  154. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +51 -63
  155. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +41 -49
  156. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +33 -37
  157. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
  158. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +19 -23
  159. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +23 -27
  160. package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +12 -11
  161. package/dist/utils/Component/getComponentTests/getComponent.html.test.js +18 -16
  162. package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +10 -9
  163. package/dist/utils/Component/getComponentTests/getComponent.list.test.js +18 -16
  164. package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +24 -27
  165. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +156 -175
  166. package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
  167. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +19 -23
  168. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +59 -73
  169. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +19 -23
  170. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +19 -23
  171. package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +35 -41
  172. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +24 -32
  173. package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +3 -3
  174. package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +10 -9
  175. package/dist/utils/Component/getDefaultValue.js +7 -9
  176. package/dist/utils/Component/getDefaultValue.test.js +14 -14
  177. package/dist/utils/Component/index.js +3 -4
  178. package/dist/utils/Component/isEditable.js +3 -7
  179. package/dist/utils/Component/isEditable.test.js +14 -15
  180. package/dist/utils/Component/optionIsSelected.js +2 -3
  181. package/dist/utils/Component/optionIsSelected.test.js +10 -10
  182. package/dist/utils/Component/setupContainerComponentsPath.js +30 -33
  183. package/dist/utils/Component/setupContainerComponentsPath.test.js +16 -16
  184. package/dist/utils/Component/showComponent.js +4 -6
  185. package/dist/utils/Component/showComponent.test.js +29 -29
  186. package/dist/utils/Component/wrapInFormGroup.js +6 -6
  187. package/dist/utils/Condition/index.js +3 -4
  188. package/dist/utils/Condition/meetsAllConditions.js +9 -10
  189. package/dist/utils/Condition/meetsAllConditions.test.js +18 -18
  190. package/dist/utils/Condition/meetsCondition.js +19 -27
  191. package/dist/utils/Condition/meetsCondition.test.js +377 -377
  192. package/dist/utils/Condition/meetsOneCondition.js +7 -8
  193. package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
  194. package/dist/utils/Condition/setupConditions.js +15 -21
  195. package/dist/utils/Condition/setupConditions.test.js +8 -8
  196. package/dist/utils/Container/getEditableComponents.js +5 -8
  197. package/dist/utils/Container/getEditableComponents.test.js +44 -46
  198. package/dist/utils/Container/index.js +3 -4
  199. package/dist/utils/Container/setupNesting.js +17 -24
  200. package/dist/utils/Container/setupNesting.test.js +28 -31
  201. package/dist/utils/Container/showContainer.js +5 -10
  202. package/dist/utils/Container/showContainer.test.js +31 -31
  203. package/dist/utils/Data/applyFormula.js +41 -52
  204. package/dist/utils/Data/applyFormula.test.js +26 -26
  205. package/dist/utils/Data/getAutocompleteSource.js +11 -14
  206. package/dist/utils/Data/getAutocompleteSource.test.js +59 -59
  207. package/dist/utils/Data/getDataPath.js +21 -32
  208. package/dist/utils/Data/getDataPath.test.js +20 -20
  209. package/dist/utils/Data/getOptions.js +22 -28
  210. package/dist/utils/Data/getOptions.test.js +21 -21
  211. package/dist/utils/Data/getSourceData.js +7 -21
  212. package/dist/utils/Data/getSourceData.test.js +85 -81
  213. package/dist/utils/Data/index.js +3 -4
  214. package/dist/utils/Data/refDataToOptions.js +12 -17
  215. package/dist/utils/Data/refDataToOptions.test.js +20 -20
  216. package/dist/utils/Data/setDataItem.js +8 -10
  217. package/dist/utils/Data/setDataItem.test.js +38 -38
  218. package/dist/utils/Data/setupFormData.js +32 -48
  219. package/dist/utils/Data/setupFormData.test.js +99 -98
  220. package/dist/utils/Data/setupRefDataUrlForComponent.js +22 -30
  221. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +28 -28
  222. package/dist/utils/FormPage/applyConditionalProperties.js +7 -12
  223. package/dist/utils/FormPage/applyConditionalProperties.test.js +16 -19
  224. package/dist/utils/FormPage/getFormPage.js +17 -19
  225. package/dist/utils/FormPage/getFormPage.test.js +49 -48
  226. package/dist/utils/FormPage/getFormPages.js +9 -15
  227. package/dist/utils/FormPage/getFormPages.test.js +22 -25
  228. package/dist/utils/FormPage/getPageActions.js +11 -19
  229. package/dist/utils/FormPage/getPageActions.test.js +33 -33
  230. package/dist/utils/FormPage/getParagraphFromText.js +6 -9
  231. package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
  232. package/dist/utils/FormPage/index.js +3 -4
  233. package/dist/utils/FormPage/showFormPage.js +5 -10
  234. package/dist/utils/FormPage/showFormPage.test.js +33 -33
  235. package/dist/utils/FormPage/showFormPageCYA.js +4 -5
  236. package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
  237. package/dist/utils/FormPage/useComponent.js +21 -29
  238. package/dist/utils/FormPage/useComponent.test.js +71 -73
  239. package/dist/utils/Format/formatData.js +2 -3
  240. package/dist/utils/Format/formatData.test.js +19 -19
  241. package/dist/utils/Format/formatDataForComponent.js +6 -9
  242. package/dist/utils/Format/formatDataForComponent.test.js +50 -78
  243. package/dist/utils/Format/formatDataForForm.js +7 -10
  244. package/dist/utils/Format/formatDataForForm.test.js +14 -17
  245. package/dist/utils/Format/formatDataForPage.js +4 -7
  246. package/dist/utils/Format/formatDataForPage.test.js +20 -25
  247. package/dist/utils/Format/index.js +3 -4
  248. package/dist/utils/Hub/getFormHub.js +3 -4
  249. package/dist/utils/Hub/getFormHub.test.js +29 -32
  250. package/dist/utils/Hub/index.js +3 -4
  251. package/dist/utils/Meta/constants.js +2 -4
  252. package/dist/utils/Meta/documents/getDocuments.js +2 -6
  253. package/dist/utils/Meta/documents/getDocuments.test.js +25 -17
  254. package/dist/utils/Meta/documents/index.js +3 -4
  255. package/dist/utils/Meta/documents/setDocumentsForField.js +16 -19
  256. package/dist/utils/Meta/documents/setDocumentsForField.test.js +69 -35
  257. package/dist/utils/Meta/index.js +3 -4
  258. package/dist/utils/Operate/checkValueIsTruthy.js +5 -6
  259. package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
  260. package/dist/utils/Operate/getFirstOf.js +9 -10
  261. package/dist/utils/Operate/getFirstOf.test.js +33 -33
  262. package/dist/utils/Operate/getIndexOfMatchingValueIn.js +13 -14
  263. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
  264. package/dist/utils/Operate/index.js +3 -4
  265. package/dist/utils/Operate/persistValueInFormData.js +7 -8
  266. package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
  267. package/dist/utils/Operate/runPageOperations.js +10 -11
  268. package/dist/utils/Operate/runPageOperations.test.js +36 -37
  269. package/dist/utils/Operate/setValueInFormData.js +6 -7
  270. package/dist/utils/Operate/setValueInFormData.test.js +17 -17
  271. package/dist/utils/Operate/shouldRun.js +9 -10
  272. package/dist/utils/Operate/shouldRun.test.js +22 -28
  273. package/dist/utils/Validate/additional/conditionallyRequired.js +5 -7
  274. package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
  275. package/dist/utils/Validate/additional/index.js +8 -9
  276. package/dist/utils/Validate/additional/index.test.js +13 -13
  277. package/dist/utils/Validate/additional/mustBeAfter.js +4 -5
  278. package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
  279. package/dist/utils/Validate/additional/mustBeBefore.js +4 -5
  280. package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
  281. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -14
  282. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +34 -38
  283. package/dist/utils/Validate/additional/mustBeGreaterThan.js +3 -4
  284. package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
  285. package/dist/utils/Validate/additional/mustBeInTheFuture.js +5 -6
  286. package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
  287. package/dist/utils/Validate/additional/mustBeInThePast.js +6 -7
  288. package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
  289. package/dist/utils/Validate/additional/mustBeLessThan.js +3 -4
  290. package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
  291. package/dist/utils/Validate/additional/mustBeLongerThan.js +2 -3
  292. package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
  293. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +3 -4
  294. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
  295. package/dist/utils/Validate/additional/mustBeShorterThan.js +2 -3
  296. package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
  297. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +4 -7
  298. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
  299. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +2 -3
  300. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
  301. package/dist/utils/Validate/additional/mustSelectOnlyOne.js +4 -7
  302. package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
  303. package/dist/utils/Validate/additional/utils.js +9 -25
  304. package/dist/utils/Validate/index.js +3 -4
  305. package/dist/utils/Validate/validateCollection.js +22 -29
  306. package/dist/utils/Validate/validateCollection.test.js +85 -77
  307. package/dist/utils/Validate/validateComponent.js +19 -19
  308. package/dist/utils/Validate/validateComponent.test.js +169 -147
  309. package/dist/utils/Validate/validateContainer.js +16 -22
  310. package/dist/utils/Validate/validateContainer.test.js +52 -48
  311. package/dist/utils/Validate/validateDate.js +14 -21
  312. package/dist/utils/Validate/validateDate.test.js +28 -29
  313. package/dist/utils/Validate/validateEmail.js +8 -11
  314. package/dist/utils/Validate/validateEmail.test.js +26 -26
  315. package/dist/utils/Validate/validateMultifile.js +6 -10
  316. package/dist/utils/Validate/validateMultifile.test.js +17 -18
  317. package/dist/utils/Validate/validatePage.js +20 -22
  318. package/dist/utils/Validate/validatePage.test.js +146 -143
  319. package/dist/utils/Validate/validateRegex.js +6 -10
  320. package/dist/utils/Validate/validateRegex.test.js +17 -17
  321. package/dist/utils/Validate/validateRequired.js +6 -9
  322. package/dist/utils/Validate/validateRequired.test.js +19 -19
  323. package/dist/utils/Validate/validateTextArea.js +6 -9
  324. package/dist/utils/Validate/validateTextArea.test.js +21 -21
  325. package/dist/utils/Validate/validateTime.js +8 -16
  326. package/dist/utils/Validate/validateTime.test.js +15 -15
  327. package/dist/utils/index.js +10 -12
  328. package/package.json +9 -6
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.PageActionTypes = exports.DefaultPageActions = void 0;
7
- var _DefaultPageActions;
8
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
9
- 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; }
10
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
11
- 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); }
12
- var TYPE_CANCEL = 'cancel';
13
- var TYPE_COLLECTION_ADD = 'collectionAdd';
14
- var TYPE_COLLECTION_DUPLICATE = 'collectionDuplicate';
15
- var TYPE_COLLECTION_REMOVE = 'collectionRemove';
16
- var TYPE_NAVIGATE = 'navigate';
17
- var TYPE_SAVE_AND_CONTINUE = 'saveAndContinue';
18
- var TYPE_SAVE_AND_NAVIGATE = 'saveAndNavigate';
19
- var TYPE_SAVE_AND_RETURN = 'saveAndReturn';
20
- var TYPE_SUBMIT = 'submit';
21
- var PageActionTypes = {
7
+ const TYPE_CANCEL = 'cancel';
8
+ const TYPE_COLLECTION_ADD = 'collectionAdd';
9
+ const TYPE_COLLECTION_DUPLICATE = 'collectionDuplicate';
10
+ const TYPE_COLLECTION_REMOVE = 'collectionRemove';
11
+ const TYPE_NAVIGATE = 'navigate';
12
+ const TYPE_SAVE_AND_CONTINUE = 'saveAndContinue';
13
+ const TYPE_SAVE_AND_NAVIGATE = 'saveAndNavigate';
14
+ const TYPE_SAVE_AND_RETURN = 'saveAndReturn';
15
+ const TYPE_SUBMIT = 'submit';
16
+ const PageActionTypes = exports.PageActionTypes = {
22
17
  CANCEL: TYPE_CANCEL,
23
18
  COLLECTION_ADD: TYPE_COLLECTION_ADD,
24
19
  COLLECTION_DUPLICATE: TYPE_COLLECTION_DUPLICATE,
@@ -29,33 +24,41 @@ var PageActionTypes = {
29
24
  SAVE_AND_RETURN: TYPE_SAVE_AND_RETURN,
30
25
  SUBMIT: TYPE_SUBMIT
31
26
  };
32
- exports.PageActionTypes = PageActionTypes;
33
- var DefaultPageActions = (_DefaultPageActions = {}, _defineProperty(_DefaultPageActions, TYPE_CANCEL, {
34
- type: TYPE_CANCEL,
35
- validate: false,
36
- label: 'Cancel',
37
- classModifiers: 'secondary'
38
- }), _defineProperty(_DefaultPageActions, TYPE_COLLECTION_ADD, undefined), _defineProperty(_DefaultPageActions, TYPE_COLLECTION_DUPLICATE, undefined), _defineProperty(_DefaultPageActions, TYPE_COLLECTION_REMOVE, undefined), _defineProperty(_DefaultPageActions, TYPE_NAVIGATE, undefined), _defineProperty(_DefaultPageActions, TYPE_SAVE_AND_CONTINUE, {
39
- type: TYPE_SAVE_AND_CONTINUE,
40
- validate: true,
41
- label: 'Save and continue'
42
- }), _defineProperty(_DefaultPageActions, TYPE_SAVE_AND_NAVIGATE, {
43
- type: TYPE_SAVE_AND_NAVIGATE,
44
- validate: true,
45
- label: 'Save and continue'
46
- }), _defineProperty(_DefaultPageActions, TYPE_SAVE_AND_RETURN, {
47
- type: TYPE_SAVE_AND_RETURN,
48
- validate: false,
49
- label: 'Save and return later',
50
- classModifiers: 'secondary'
51
- }), _defineProperty(_DefaultPageActions, TYPE_SUBMIT, {
52
- type: TYPE_SUBMIT,
53
- validate: true
54
- }), _DefaultPageActions);
55
- exports.DefaultPageActions = DefaultPageActions;
56
- var PageAction = {
27
+ const DefaultPageActions = exports.DefaultPageActions = {
28
+ [TYPE_CANCEL]: {
29
+ type: TYPE_CANCEL,
30
+ validate: false,
31
+ label: 'Cancel',
32
+ classModifiers: 'secondary'
33
+ },
34
+ [TYPE_COLLECTION_ADD]: undefined,
35
+ [TYPE_COLLECTION_DUPLICATE]: undefined,
36
+ [TYPE_COLLECTION_REMOVE]: undefined,
37
+ [TYPE_NAVIGATE]: undefined,
38
+ // No default for this.
39
+ [TYPE_SAVE_AND_CONTINUE]: {
40
+ type: TYPE_SAVE_AND_CONTINUE,
41
+ validate: true,
42
+ label: 'Save and continue'
43
+ },
44
+ [TYPE_SAVE_AND_NAVIGATE]: {
45
+ type: TYPE_SAVE_AND_NAVIGATE,
46
+ validate: true,
47
+ label: 'Save and continue'
48
+ },
49
+ [TYPE_SAVE_AND_RETURN]: {
50
+ type: TYPE_SAVE_AND_RETURN,
51
+ validate: false,
52
+ label: 'Save and return later',
53
+ classModifiers: 'secondary'
54
+ },
55
+ [TYPE_SUBMIT]: {
56
+ type: TYPE_SUBMIT,
57
+ validate: true
58
+ }
59
+ };
60
+ const PageAction = {
57
61
  TYPES: PageActionTypes,
58
62
  DEFAULTS: DefaultPageActions
59
63
  };
60
- var _default = PageAction;
61
- exports.default = _default;
64
+ var _default = exports.default = PageAction;
@@ -4,43 +4,42 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.StateTypes = void 0;
7
- var _StateDetails;
8
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
9
- 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; }
10
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
11
- 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); }
12
- var TYPE_COMPLETE = 'complete';
13
- var TYPE_IN_PROGRESS = 'inProgress';
14
- var TYPE_NOT_STARTED = 'notStarted';
15
- var TYPE_CANNOT_START_YET = 'cannotStartYet';
16
- var TYPE_SKIPPED = 'skipped';
17
- var StateTypes = {
7
+ const TYPE_COMPLETE = 'complete';
8
+ const TYPE_IN_PROGRESS = 'inProgress';
9
+ const TYPE_NOT_STARTED = 'notStarted';
10
+ const TYPE_CANNOT_START_YET = 'cannotStartYet';
11
+ const TYPE_SKIPPED = 'skipped';
12
+ const StateTypes = exports.StateTypes = {
18
13
  COMPLETE: TYPE_COMPLETE,
19
14
  IN_PROGRESS: TYPE_IN_PROGRESS,
20
15
  NOT_STARTED: TYPE_NOT_STARTED,
21
16
  CANNOT_START_YET: TYPE_CANNOT_START_YET,
22
17
  SKIPPED: TYPE_SKIPPED
23
18
  };
24
- exports.StateTypes = StateTypes;
25
- var StateDetails = (_StateDetails = {}, _defineProperty(_StateDetails, TYPE_COMPLETE, {
26
- label: 'Completed',
27
- colour: 'dark-blue'
28
- }), _defineProperty(_StateDetails, TYPE_IN_PROGRESS, {
29
- label: 'In Progress',
30
- colour: 'white'
31
- }), _defineProperty(_StateDetails, TYPE_NOT_STARTED, {
32
- label: 'Not Started',
33
- colour: 'dark-grey'
34
- }), _defineProperty(_StateDetails, TYPE_CANNOT_START_YET, {
35
- label: 'Cannot Start Yet',
36
- colour: 'dark-grey'
37
- }), _defineProperty(_StateDetails, TYPE_SKIPPED, {
38
- label: 'Skipped',
39
- colour: 'dark-grey'
40
- }), _StateDetails);
41
- var TaskStates = {
19
+ const StateDetails = {
20
+ [TYPE_COMPLETE]: {
21
+ label: 'Completed',
22
+ colour: 'dark-blue'
23
+ },
24
+ [TYPE_IN_PROGRESS]: {
25
+ label: 'In Progress',
26
+ colour: 'white'
27
+ },
28
+ [TYPE_NOT_STARTED]: {
29
+ label: 'Not Started',
30
+ colour: 'dark-grey'
31
+ },
32
+ [TYPE_CANNOT_START_YET]: {
33
+ label: 'Cannot Start Yet',
34
+ colour: 'dark-grey'
35
+ },
36
+ [TYPE_SKIPPED]: {
37
+ label: 'Skipped',
38
+ colour: 'dark-grey'
39
+ } // Shouldn't ever see this, but just in case.
40
+ };
41
+ const TaskStates = {
42
42
  TYPES: StateTypes,
43
43
  DETAILS: StateDetails
44
44
  };
45
- var _default = TaskStates;
46
- exports.default = _default;
45
+ var _default = exports.default = TaskStates;
@@ -5,49 +5,49 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "CollectionLabels", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _CollectionLabels.default;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "ComponentTypes", {
13
13
  enumerable: true,
14
- get: function get() {
14
+ get: function () {
15
15
  return _ComponentTypes.default;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "EventTypes", {
19
19
  enumerable: true,
20
- get: function get() {
20
+ get: function () {
21
21
  return _EventTypes.default;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "FormPages", {
25
25
  enumerable: true,
26
- get: function get() {
26
+ get: function () {
27
27
  return _FormPages.default;
28
28
  }
29
29
  });
30
30
  Object.defineProperty(exports, "FormTypes", {
31
31
  enumerable: true,
32
- get: function get() {
32
+ get: function () {
33
33
  return _FormTypes.default;
34
34
  }
35
35
  });
36
36
  Object.defineProperty(exports, "HubFormats", {
37
37
  enumerable: true,
38
- get: function get() {
38
+ get: function () {
39
39
  return _HubFormats.default;
40
40
  }
41
41
  });
42
42
  Object.defineProperty(exports, "PageAction", {
43
43
  enumerable: true,
44
- get: function get() {
44
+ get: function () {
45
45
  return _PageAction.default;
46
46
  }
47
47
  });
48
48
  Object.defineProperty(exports, "TaskStates", {
49
49
  enumerable: true,
50
- get: function get() {
50
+ get: function () {
51
51
  return _TaskStates.default;
52
52
  }
53
53
  });
@@ -60,10 +60,10 @@ var _FormTypes = _interopRequireDefault(require("./FormTypes"));
60
60
  var _HubFormats = _interopRequireDefault(require("./HubFormats"));
61
61
  var _PageAction = _interopRequireDefault(require("./PageAction"));
62
62
  var _TaskStates = _interopRequireDefault(require("./TaskStates"));
63
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
63
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
64
64
  // Local imports
65
65
 
66
- var Models = {
66
+ const Models = {
67
67
  CollectionLabels: _CollectionLabels.default,
68
68
  ComponentTypes: _ComponentTypes.default,
69
69
  EventTypes: _EventTypes.default,
@@ -73,5 +73,4 @@ var Models = {
73
73
  PageAction: _PageAction.default,
74
74
  TaskStates: _TaskStates.default
75
75
  };
76
- var _default = Models;
77
- exports.default = _default;
76
+ var _default = exports.default = Models;
@@ -8,38 +8,34 @@ var _react = require("@testing-library/react");
8
8
  var _reactHooks = require("@testing-library/react-hooks");
9
9
  var _reactDom = require("react-dom");
10
10
  var _context = require("./context");
11
- var renderWithValidation = function renderWithValidation(ui, options) {
12
- return (0, _react.render)( /*#__PURE__*/React.createElement(_context.HooksContextProvider, {
13
- overrides: options === null || options === void 0 ? void 0 : options.hooks
14
- }, /*#__PURE__*/React.createElement(_context.ValidationContextProvider, {
15
- key: "vcp"
16
- }, ui)), options);
17
- };
11
+ const renderWithValidation = (ui, options) => (0, _react.render)(/*#__PURE__*/React.createElement(_context.HooksContextProvider, {
12
+ overrides: options?.hooks
13
+ }, /*#__PURE__*/React.createElement(_context.ValidationContextProvider, {
14
+ key: "vcp"
15
+ }, ui)), options);
18
16
  exports.renderWithValidation = renderWithValidation;
19
- var renderDomWithValidation = function renderDomWithValidation(ui, container, options) {
20
- return (0, _reactDom.render)( /*#__PURE__*/React.createElement(_context.HooksContextProvider, {
21
- overrides: options === null || options === void 0 ? void 0 : options.hooks
22
- }, /*#__PURE__*/React.createElement(_context.ValidationContextProvider, {
23
- key: "vcp"
24
- }, ui)), container);
25
- };
17
+ const renderDomWithValidation = (ui, container, options) => (0, _reactDom.render)(/*#__PURE__*/React.createElement(_context.HooksContextProvider, {
18
+ overrides: options?.hooks
19
+ }, /*#__PURE__*/React.createElement(_context.ValidationContextProvider, {
20
+ key: "vcp"
21
+ }, ui)), container);
26
22
  exports.renderDomWithValidation = renderDomWithValidation;
27
- var renderHookWithProvider = function renderHookWithProvider(hook, options) {
28
- var wrapper = function wrapper(_ref) {
29
- var children = _ref.children;
23
+ const renderHookWithProvider = (hook, options) => {
24
+ const wrapper = _ref => {
25
+ let {
26
+ children
27
+ } = _ref;
30
28
  return /*#__PURE__*/React.createElement(_context.HooksContextProvider, {
31
- overrides: options === null || options === void 0 ? void 0 : options.hooks
29
+ overrides: options?.hooks
32
30
  }, children);
33
31
  };
34
- return (0, _reactHooks.renderHook)(function () {
35
- return hook();
36
- }, {
37
- wrapper: wrapper
32
+ return (0, _reactHooks.renderHook)(() => hook(), {
33
+ wrapper
38
34
  });
39
35
  };
40
36
  exports.renderHookWithProvider = renderHookWithProvider;
41
- var expectObjectLike = function expectObjectLike(received, expected) {
42
- Object.keys(expected).forEach(function (key) {
37
+ const expectObjectLike = (received, expected) => {
38
+ Object.keys(expected).forEach(key => {
43
39
  expect(received[key]).toEqual(expected[key]);
44
40
  });
45
41
  };
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var getPageFromCYALink = function getPageFromCYALink(link) {
7
+ const getPageFromCYALink = link => {
8
8
  if (link.page) {
9
9
  return link.page;
10
10
  }
11
- var url = link.href || link.url;
11
+ const url = link.href || link.url;
12
12
  if (url) {
13
13
  return url.split('/').pop();
14
14
  }
@@ -28,17 +28,16 @@ var getPageFromCYALink = function getPageFromCYALink(link) {
28
28
  * method will convert both by taking the final part of the relative path:
29
29
  * - `href: '/bravo'` => `page: 'bravo'`
30
30
  */
31
- var getCYAAction = function getCYAAction(readonly, page, onAction) {
32
- var cyaLink = page === null || page === void 0 ? void 0 : page.cya_link;
31
+ const getCYAAction = (readonly, page, onAction) => {
32
+ const cyaLink = page?.cya_link;
33
33
  if (readonly !== true && cyaLink) {
34
34
  return {
35
35
  page: getPageFromCYALink(cyaLink) || page.id || '#',
36
36
  label: cyaLink.label || 'Change',
37
37
  aria_suffix: cyaLink.aria_suffix,
38
- onAction: onAction
38
+ onAction
39
39
  };
40
40
  }
41
41
  return null;
42
42
  };
43
- var _default = getCYAAction;
44
- exports.default = _default;
43
+ var _default = exports.default = getCYAAction;
@@ -1,119 +1,117 @@
1
1
  "use strict";
2
2
 
3
3
  var _getCYAAction = _interopRequireDefault(require("./getCYAAction"));
4
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
5
5
  // Local imports
6
6
 
7
- describe('utils', function () {
8
- describe('CheckYourAnswers', function () {
9
- describe('getCYAAction', function () {
10
- var getPage = function getPage(cyaLink, id) {
11
- return {
12
- cya_link: cyaLink,
13
- id: id
14
- };
15
- };
16
- it('should return null if readonly', function () {
17
- expect((0, _getCYAAction.default)(true, {}, function () {})).toBeNull();
7
+ describe('utils', () => {
8
+ describe('CheckYourAnswers', () => {
9
+ describe('getCYAAction', () => {
10
+ const getPage = (cyaLink, id) => ({
11
+ cya_link: cyaLink,
12
+ id
13
+ });
14
+ it('should return null if readonly', () => {
15
+ expect((0, _getCYAAction.default)(true, {}, () => {})).toBeNull();
18
16
  });
19
- it('should return null if there is no cya_link', function () {
20
- expect((0, _getCYAAction.default)(false, null, function () {})).toBeNull();
17
+ it('should return null if there is no cya_link', () => {
18
+ expect((0, _getCYAAction.default)(false, null, () => {})).toBeNull();
21
19
  });
22
- it('should return a default action if the cya_link is empty and the page has no id', function () {
23
- var cyaLink = {};
24
- var onAction = function onAction() {};
20
+ it('should return a default action if the cya_link is empty and the page has no id', () => {
21
+ const cyaLink = {};
22
+ const onAction = () => {};
25
23
  expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
26
24
  page: '#',
27
25
  label: 'Change',
28
- onAction: onAction
26
+ onAction
29
27
  });
30
28
  });
31
- it('should return a default action if the cya_link is empty but the page has an id', function () {
32
- var PAGE_ID = 'page-id';
33
- var cyaLink = {};
34
- var onAction = function onAction() {};
29
+ it('should return a default action if the cya_link is empty but the page has an id', () => {
30
+ const PAGE_ID = 'page-id';
31
+ const cyaLink = {};
32
+ const onAction = () => {};
35
33
  expect((0, _getCYAAction.default)(false, getPage(cyaLink, PAGE_ID), onAction)).toEqual({
36
34
  page: PAGE_ID,
37
35
  label: 'Change',
38
- onAction: onAction
36
+ onAction
39
37
  });
40
38
  });
41
- it('should use page specified in cya_link', function () {
42
- var PAGE = 'alpha';
43
- var cyaLink = {
39
+ it('should use page specified in cya_link', () => {
40
+ const PAGE = 'alpha';
41
+ const cyaLink = {
44
42
  page: PAGE
45
43
  };
46
- var onAction = function onAction() {};
44
+ const onAction = () => {};
47
45
  expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
48
46
  page: PAGE,
49
47
  label: 'Change',
50
- onAction: onAction
48
+ onAction
51
49
  });
52
50
  });
53
- it('should convert an href specified in cya_link', function () {
54
- var HREF = '/alpha/bravo';
55
- var cyaLink = {
51
+ it('should convert an href specified in cya_link', () => {
52
+ const HREF = '/alpha/bravo';
53
+ const cyaLink = {
56
54
  href: HREF
57
55
  };
58
- var onAction = function onAction() {};
56
+ const onAction = () => {};
59
57
  expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
60
58
  page: 'bravo',
61
59
  label: 'Change',
62
- onAction: onAction
60
+ onAction
63
61
  });
64
62
  });
65
- it('should convert a url specified in cya_link', function () {
66
- var URL = '/alpha/bravo';
67
- var cyaLink = {
63
+ it('should convert a url specified in cya_link', () => {
64
+ const URL = '/alpha/bravo';
65
+ const cyaLink = {
68
66
  url: URL
69
67
  };
70
- var onAction = function onAction() {};
68
+ const onAction = () => {};
71
69
  expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
72
70
  page: 'bravo',
73
71
  label: 'Change',
74
- onAction: onAction
72
+ onAction
75
73
  });
76
74
  });
77
- it('should use label specified in cya_link', function () {
78
- var LABEL = 'Alpha Bravo Charlie';
79
- var cyaLink = {
75
+ it('should use label specified in cya_link', () => {
76
+ const LABEL = 'Alpha Bravo Charlie';
77
+ const cyaLink = {
80
78
  label: LABEL
81
79
  };
82
- var onAction = function onAction() {};
80
+ const onAction = () => {};
83
81
  expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
84
82
  page: '#',
85
83
  label: LABEL,
86
- onAction: onAction
84
+ onAction
87
85
  });
88
86
  });
89
- it('should use aria_suffix specified in cya_link', function () {
90
- var ARIA_SUFFIX = 'This is hidden text';
91
- var cyaLink = {
87
+ it('should use aria_suffix specified in cya_link', () => {
88
+ const ARIA_SUFFIX = 'This is hidden text';
89
+ const cyaLink = {
92
90
  aria_suffix: ARIA_SUFFIX
93
91
  };
94
- var onAction = function onAction() {};
92
+ const onAction = () => {};
95
93
  expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
96
94
  page: '#',
97
95
  label: 'Change',
98
96
  aria_suffix: ARIA_SUFFIX,
99
- onAction: onAction
97
+ onAction
100
98
  });
101
99
  });
102
- it('should use all properties specified in cya_link', function () {
103
- var PAGE = 'alpha';
104
- var LABEL = 'Alpha Bravo Charlie';
105
- var ARIA_SUFFIX = 'This is hidden text';
106
- var cyaLink = {
100
+ it('should use all properties specified in cya_link', () => {
101
+ const PAGE = 'alpha';
102
+ const LABEL = 'Alpha Bravo Charlie';
103
+ const ARIA_SUFFIX = 'This is hidden text';
104
+ const cyaLink = {
107
105
  label: LABEL,
108
106
  page: PAGE,
109
107
  aria_suffix: ARIA_SUFFIX
110
108
  };
111
- var onAction = function onAction() {};
109
+ const onAction = () => {};
112
110
  expect((0, _getCYAAction.default)(false, getPage(cyaLink), onAction)).toEqual({
113
111
  page: PAGE,
114
112
  label: LABEL,
115
113
  aria_suffix: ARIA_SUFFIX,
116
- onAction: onAction
114
+ onAction
117
115
  });
118
116
  });
119
117
  });
@@ -6,39 +6,37 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _copReactComponents = require("@ukhomeoffice/cop-react-components");
8
8
  var _models = require("../../models");
9
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
10
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
- 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; }
13
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
- 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); }
15
- var getCYACollectionChangeAction = function getCYACollectionChangeAction(page, item, _onAction, labelCount, action) {
16
- var label = (action === null || action === void 0 ? void 0 : action.label) || _models.CollectionLabels.change;
9
+ // Global imports
10
+
11
+ // Local imports
12
+
13
+ const getCYACollectionChangeAction = (page, item, onAction, labelCount, action) => {
14
+ const label = action?.label || _models.CollectionLabels.change;
17
15
  return {
18
16
  pageId: page.id,
19
- fieldId: "change".concat(labelCount).concat(action.page),
20
- key: "change".concat(labelCount).concat(action.page),
17
+ fieldId: `change${labelCount}${action.page}`,
18
+ key: `change${labelCount}${action.page}`,
21
19
  type: 'action',
22
20
  action: {
23
- onAction: function onAction(row) {
24
- var changeCallback = function changeCallback(cyaData) {
25
- var data = cyaData;
26
- data["".concat(page.collection.name, "ActiveId")] = item.id;
21
+ onAction: row => {
22
+ const changeCallback = cyaData => {
23
+ const data = cyaData;
24
+ data[`${page.collection.name}ActiveId`] = item.id;
27
25
  return data;
28
26
  };
29
- var nextPage = row;
27
+ let nextPage = row;
30
28
  if (action.page) {
31
29
  nextPage = {
32
30
  pageId: action.page
33
31
  };
34
32
  }
35
- _onAction(nextPage, changeCallback);
33
+ onAction(nextPage, changeCallback);
36
34
  },
37
- label: _copReactComponents.Utils.interpolateString(label, _objectSpread(_objectSpread({}, item), {}, {
35
+ label: _copReactComponents.Utils.interpolateString(label, {
36
+ ...item,
38
37
  index: labelCount
39
- }))
38
+ })
40
39
  }
41
40
  };
42
41
  };
43
- var _default = getCYACollectionChangeAction;
44
- exports.default = _default;
42
+ var _default = exports.default = getCYACollectionChangeAction;