@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
@@ -3,23 +3,24 @@
3
3
  var _react = require("@testing-library/react");
4
4
  var _models = require("../../../models");
5
5
  var _getComponent = _interopRequireDefault(require("../getComponent"));
6
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
7
  // Global imports
8
8
 
9
9
  // Local imports
10
10
 
11
- describe('utils.Component.get', function () {
12
- it('should return an appropriately rendered warning-text component', function () {
13
- var ID = 'test-id';
14
- var CONTENT = 'Warning Text';
15
- var COMPONENT = {
11
+ describe('utils.Component.get', () => {
12
+ it('should return an appropriately rendered warning-text component', () => {
13
+ const ID = 'test-id';
14
+ const CONTENT = 'Warning Text';
15
+ const COMPONENT = {
16
16
  type: _models.ComponentTypes.WARNING,
17
17
  content: CONTENT,
18
18
  'data-testid': ID
19
19
  };
20
- var _render = (0, _react.render)((0, _getComponent.default)(COMPONENT)),
21
- container = _render.container;
22
- var warningText = (0, _react.getByTestId)(container, ID);
20
+ const {
21
+ container
22
+ } = (0, _react.render)((0, _getComponent.default)(COMPONENT));
23
+ const warningText = (0, _react.getByTestId)(container, ID);
23
24
  expect(warningText.innerHTML).toContain(CONTENT);
24
25
  expect(warningText.tagName).toEqual('DIV');
25
26
  expect(warningText.classList).toContain('govuk-warning-text');
@@ -5,13 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _models = require("../../models");
8
- var _DEFAULT_VALUES;
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 _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; }
11
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
- 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); }
13
- var DEFAULT_VALUES = (_DEFAULT_VALUES = {}, _defineProperty(_DEFAULT_VALUES, _models.ComponentTypes.COLLECTION, []), _defineProperty(_DEFAULT_VALUES, _models.ComponentTypes.CONTAINER, {}), _defineProperty(_DEFAULT_VALUES, _models.ComponentTypes.FILE, {}), _DEFAULT_VALUES);
14
- var getDefaultValue = function getDefaultValue(component) {
8
+ const DEFAULT_VALUES = {
9
+ [_models.ComponentTypes.COLLECTION]: [],
10
+ [_models.ComponentTypes.CONTAINER]: {},
11
+ [_models.ComponentTypes.FILE]: {}
12
+ };
13
+ const getDefaultValue = component => {
15
14
  if (!component) {
16
15
  return '';
17
16
  }
@@ -23,5 +22,4 @@ var getDefaultValue = function getDefaultValue(component) {
23
22
  }
24
23
  return DEFAULT_VALUES[component.type] || '';
25
24
  };
26
- var _default = getDefaultValue;
27
- exports.default = _default;
25
+ var _default = exports.default = getDefaultValue;
@@ -2,57 +2,57 @@
2
2
 
3
3
  var _models = require("../../models");
4
4
  var _getDefaultValue = _interopRequireDefault(require("./getDefaultValue"));
5
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
- describe('utils.Component.defaultValue', function () {
7
- it('should return an empty string if the component is undefined', function () {
5
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
6
+ describe('utils.Component.defaultValue', () => {
7
+ it('should return an empty string if the component is undefined', () => {
8
8
  expect((0, _getDefaultValue.default)(undefined)).toEqual('');
9
9
  });
10
- it('should return an empty string if the component is null', function () {
10
+ it('should return an empty string if the component is null', () => {
11
11
  expect((0, _getDefaultValue.default)(null)).toEqual('');
12
12
  });
13
- it('should return an empty string if the component has no type', function () {
13
+ it('should return an empty string if the component has no type', () => {
14
14
  expect((0, _getDefaultValue.default)({})).toEqual('');
15
15
  });
16
- it('should return an empty string if the component type is null', function () {
16
+ it('should return an empty string if the component type is null', () => {
17
17
  expect((0, _getDefaultValue.default)({
18
18
  type: null
19
19
  })).toEqual('');
20
20
  });
21
- it('should return an empty string if the component type is undefined', function () {
21
+ it('should return an empty string if the component type is undefined', () => {
22
22
  expect((0, _getDefaultValue.default)({
23
23
  type: undefined
24
24
  })).toEqual('');
25
25
  });
26
- it("should return an empty array if the component type is 'collection'", function () {
26
+ it(`should return an empty array if the component type is 'collection'`, () => {
27
27
  expect((0, _getDefaultValue.default)({
28
28
  type: _models.ComponentTypes.COLLECTION
29
29
  })).toEqual([]);
30
30
  });
31
- it("should return an empty object if the component type is 'container'", function () {
31
+ it(`should return an empty object if the component type is 'container'`, () => {
32
32
  expect((0, _getDefaultValue.default)({
33
33
  type: _models.ComponentTypes.CONTAINER
34
34
  })).toEqual({});
35
35
  });
36
- it("should return an empty object if the component type is 'file'", function () {
36
+ it(`should return an empty object if the component type is 'file'`, () => {
37
37
  expect((0, _getDefaultValue.default)({
38
38
  type: _models.ComponentTypes.FILE
39
39
  })).toEqual({});
40
40
  });
41
- it('should return defaultValue if the component has defaultValue prop', function () {
41
+ it('should return defaultValue if the component has defaultValue prop', () => {
42
42
  expect((0, _getDefaultValue.default)({
43
43
  type: _models.ComponentTypes.AUTOCOMPLETE,
44
44
  defaultValue: 'test'
45
45
  })).toEqual('test');
46
46
  });
47
- it('should return defaultObjectValue if the component has defaultObjectValue prop', function () {
47
+ it('should return defaultObjectValue if the component has defaultObjectValue prop', () => {
48
48
  expect((0, _getDefaultValue.default)({
49
49
  type: _models.ComponentTypes.AUTOCOMPLETE,
50
50
  defaultObjectValue: 'test'
51
51
  })).toEqual('test');
52
52
  });
53
- Object.values(_models.ComponentTypes).forEach(function (value) {
53
+ Object.values(_models.ComponentTypes).forEach(value => {
54
54
  if (![_models.ComponentTypes.COLLECTION, _models.ComponentTypes.CONTAINER, _models.ComponentTypes.FILE].includes(value)) {
55
- it("should return an empty object if the component type is '".concat(value, "'"), function () {
55
+ it(`should return an empty object if the component type is '${value}'`, () => {
56
56
  expect((0, _getDefaultValue.default)({
57
57
  type: _models.ComponentTypes.TEXT
58
58
  })).toEqual('');
@@ -12,8 +12,8 @@ var _isEditable = _interopRequireDefault(require("./isEditable"));
12
12
  var _setupContainerComponentsPath = _interopRequireDefault(require("./setupContainerComponentsPath"));
13
13
  var _showComponent = _interopRequireDefault(require("./showComponent"));
14
14
  var _wrapInFormGroup = _interopRequireDefault(require("./wrapInFormGroup"));
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- var Component = {
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ const Component = {
17
17
  clean: _cleanAttributes.default,
18
18
  defaultValue: _getDefaultValue.default,
19
19
  editable: _isEditable.default,
@@ -23,5 +23,4 @@ var Component = {
23
23
  show: _showComponent.default,
24
24
  wrap: _wrapInFormGroup.default
25
25
  };
26
- var _default = Component;
27
- exports.default = _default;
26
+ var _default = exports.default = Component;
@@ -7,10 +7,6 @@ exports.default = exports.EDITABLE_TYPES = void 0;
7
7
  var _models = require("../../models");
8
8
  // Local imports
9
9
 
10
- var EDITABLE_TYPES = [_models.ComponentTypes.AUTOCOMPLETE, _models.ComponentTypes.CALCULATION, _models.ComponentTypes.CHECKBOXES, _models.ComponentTypes.DATE, _models.ComponentTypes.EMAIL, _models.ComponentTypes.FILE, _models.ComponentTypes.MULTI_FILE, _models.ComponentTypes.PHONE_NUMBER, _models.ComponentTypes.RADIOS, _models.ComponentTypes.SELECT, _models.ComponentTypes.TEXT, _models.ComponentTypes.TEXT_AREA, _models.ComponentTypes.TIME];
11
- exports.EDITABLE_TYPES = EDITABLE_TYPES;
12
- var isEditable = function isEditable(options) {
13
- return EDITABLE_TYPES.includes(options === null || options === void 0 ? void 0 : options.type) || (options === null || options === void 0 ? void 0 : options.isEditable) || false;
14
- };
15
- var _default = isEditable;
16
- exports.default = _default;
10
+ const EDITABLE_TYPES = exports.EDITABLE_TYPES = [_models.ComponentTypes.AUTOCOMPLETE, _models.ComponentTypes.CALCULATION, _models.ComponentTypes.CHECKBOXES, _models.ComponentTypes.DATE, _models.ComponentTypes.EMAIL, _models.ComponentTypes.FILE, _models.ComponentTypes.MULTI_FILE, _models.ComponentTypes.PHONE_NUMBER, _models.ComponentTypes.RADIOS, _models.ComponentTypes.SELECT, _models.ComponentTypes.TEXT, _models.ComponentTypes.TEXT_AREA, _models.ComponentTypes.TIME];
11
+ const isEditable = options => EDITABLE_TYPES.includes(options?.type) || options?.isEditable || false;
12
+ var _default = exports.default = isEditable;
@@ -1,39 +1,38 @@
1
1
  "use strict";
2
2
 
3
- 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); }
4
3
  var _isEditable = _interopRequireWildcard(require("./isEditable"));
5
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
6
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
4
+ 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); }
5
+ 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; }
7
6
  // Local imports
8
7
 
9
- describe('utils', function () {
10
- describe('Component', function () {
11
- describe('isEditable', function () {
12
- _isEditable.EDITABLE_TYPES.forEach(function (type) {
13
- it("should return true for a type of '".concat(type, "'"), function () {
14
- var OPTIONS = {
15
- type: type
8
+ describe('utils', () => {
9
+ describe('Component', () => {
10
+ describe('isEditable', () => {
11
+ _isEditable.EDITABLE_TYPES.forEach(type => {
12
+ it(`should return true for a type of '${type}'`, () => {
13
+ const OPTIONS = {
14
+ type
16
15
  };
17
16
  expect((0, _isEditable.default)(OPTIONS)).toEqual(true);
18
17
  });
19
18
  });
20
- it('should return false if options is undefined', function () {
19
+ it('should return false if options is undefined', () => {
21
20
  expect((0, _isEditable.default)(undefined)).toEqual(false);
22
21
  });
23
- it('should return false if options is null', function () {
22
+ it('should return false if options is null', () => {
24
23
  expect((0, _isEditable.default)(null)).toEqual(false);
25
24
  });
26
- it('should return false if options has no type', function () {
25
+ it('should return false if options has no type', () => {
27
26
  expect((0, _isEditable.default)({
28
27
  bob: 'Bob'
29
28
  })).toEqual(false);
30
29
  });
31
- it("should return false if options has a type of 'hidden'", function () {
30
+ it(`should return false if options has a type of 'hidden'`, () => {
32
31
  expect((0, _isEditable.default)({
33
32
  type: 'hidden'
34
33
  })).toEqual(false);
35
34
  });
36
- it("should return true if options has 'isEditable' set to true", function () {
35
+ it(`should return true if options has 'isEditable' set to true`, () => {
37
36
  expect((0, _isEditable.default)({
38
37
  isEditable: true
39
38
  })).toEqual(true);
@@ -12,11 +12,10 @@ exports.default = void 0;
12
12
  *
13
13
  * @returns A boolean of whether the option is selected.
14
14
  */
15
- var optionIsSelected = function optionIsSelected(componentValue, option) {
15
+ const optionIsSelected = (componentValue, option) => {
16
16
  if (Array.isArray(componentValue)) {
17
17
  return componentValue.includes(option.value);
18
18
  }
19
19
  return componentValue === option.value;
20
20
  };
21
- var _default = optionIsSelected;
22
- exports.default = _default;
21
+ var _default = exports.default = optionIsSelected;
@@ -1,26 +1,26 @@
1
1
  "use strict";
2
2
 
3
3
  var _optionIsSelected = _interopRequireDefault(require("./optionIsSelected"));
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.Component.isSelected', function () {
8
- var SELECTED_VALUE = 'selectedValue';
9
- var NOT_SELECTED_VALUE = 'notSelectedValue';
10
- var OPTIONS = [{
7
+ describe('utils.Component.isSelected', () => {
8
+ const SELECTED_VALUE = 'selectedValue';
9
+ const NOT_SELECTED_VALUE = 'notSelectedValue';
10
+ const OPTIONS = [{
11
11
  value: SELECTED_VALUE
12
12
  }, {
13
13
  value: NOT_SELECTED_VALUE
14
14
  }];
15
- var COMPONENT = {
15
+ const COMPONENT = {
16
16
  id: 'a',
17
17
  fieldId: 'a',
18
18
  data: {
19
19
  options: OPTIONS
20
20
  }
21
21
  };
22
- it('should properly identify which option is selected for checkboxes', function () {
23
- var PAGE = {
22
+ it('should properly identify which option is selected for checkboxes', () => {
23
+ const PAGE = {
24
24
  formData: {
25
25
  a: [SELECTED_VALUE]
26
26
  }
@@ -29,8 +29,8 @@ describe('utils.Component.isSelected', function () {
29
29
  expect((0, _optionIsSelected.default)(PAGE.formData[COMPONENT.id], OPTIONS[0])).toEqual(true);
30
30
  expect((0, _optionIsSelected.default)(PAGE.formData[COMPONENT.id], OPTIONS[1])).toEqual(false);
31
31
  });
32
- it('should properly identify which option is selected for radios', function () {
33
- var PAGE = {
32
+ it('should properly identify which option is selected for radios', () => {
33
+ const PAGE = {
34
34
  formData: {
35
35
  a: SELECTED_VALUE
36
36
  }
@@ -5,36 +5,33 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _showComponentCYA = require("../CheckYourAnswers/showComponentCYA");
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 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; }
10
- 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; }
11
- 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; }
12
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
13
- 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); }
14
- var setupContainerComponentsPath = function setupContainerComponentsPath(container) {
15
- return _objectSpread(_objectSpread({}, container), {}, {
16
- components: container.components.map(function (component) {
17
- if (Array.isArray(component.components)) {
18
- return _objectSpread(_objectSpread({}, component), {}, {
19
- components: component.components.map(function (c) {
20
- if (!_showComponentCYA.EXCLUDE_FROM_CYA.includes(c.type)) {
21
- return _objectSpread(_objectSpread({}, c), !c.full_path && {
22
- full_path: "".concat(component.full_path || "".concat(container.full_path, ".").concat(component.fieldId), ".").concat(c.fieldId)
23
- });
24
- }
25
- ;
26
- return null;
27
- }).filter(function (c) {
28
- return !!c;
29
- })
30
- });
31
- }
32
- ;
33
- return _objectSpread(_objectSpread({}, component), !component.full_path && {
34
- full_path: "".concat(container.full_path || container.fieldId, ".").concat(component.fieldId)
35
- });
36
- })
37
- });
38
- };
39
- var _default = setupContainerComponentsPath;
40
- exports.default = _default;
8
+ const setupContainerComponentsPath = container => ({
9
+ ...container,
10
+ components: container.components.map(component => {
11
+ if (Array.isArray(component.components)) {
12
+ return {
13
+ ...component,
14
+ components: component.components.map(c => {
15
+ if (!_showComponentCYA.EXCLUDE_FROM_CYA.includes(c.type)) {
16
+ return {
17
+ ...c,
18
+ ...(!c.full_path && {
19
+ full_path: `${component.full_path || `${container.full_path}.${component.fieldId}`}.${c.fieldId}`
20
+ })
21
+ };
22
+ }
23
+ ;
24
+ return null;
25
+ }).filter(c => !!c)
26
+ };
27
+ }
28
+ ;
29
+ return {
30
+ ...component,
31
+ ...(!component.full_path && {
32
+ full_path: `${container.full_path || container.fieldId}.${component.fieldId}`
33
+ })
34
+ };
35
+ })
36
+ });
37
+ var _default = exports.default = setupContainerComponentsPath;
@@ -2,75 +2,75 @@
2
2
 
3
3
  var _setupTests = require("../../setupTests");
4
4
  var _setupContainerComponentsPath = _interopRequireDefault(require("./setupContainerComponentsPath"));
5
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
- describe('utils.CheckYourAnswers.setupContainerComponentsPath', function () {
7
- it('should setup the full_path attribute for components within a container', function () {
8
- var COMPONENT_1 = {
5
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
6
+ describe('utils.CheckYourAnswers.setupContainerComponentsPath', () => {
7
+ it('should setup the full_path attribute for components within a container', () => {
8
+ const COMPONENT_1 = {
9
9
  id: 'checkboxes1',
10
10
  fieldId: 'checkboxes1',
11
11
  type: 'checkboxes',
12
12
  label: 'Alpha'
13
13
  };
14
- var COMPONENT_2 = {
14
+ const COMPONENT_2 = {
15
15
  id: 'checkboxes2',
16
16
  fieldId: 'checkboxes2',
17
17
  type: 'checkboxes',
18
18
  label: 'Bravo'
19
19
  };
20
- var CONTAINER = {
20
+ const CONTAINER = {
21
21
  id: 'test-container',
22
22
  fieldId: 'test-container',
23
23
  type: 'container',
24
24
  full_path: 'test-container',
25
25
  components: [COMPONENT_1, COMPONENT_2]
26
26
  };
27
- var container = (0, _setupContainerComponentsPath.default)(CONTAINER);
27
+ const container = (0, _setupContainerComponentsPath.default)(CONTAINER);
28
28
  (0, _setupTests.expectObjectLike)(container.components[0], {
29
29
  id: COMPONENT_1.id,
30
30
  fieldId: COMPONENT_1.fieldId,
31
- full_path: "".concat(CONTAINER.fieldId, ".").concat(COMPONENT_1.fieldId),
31
+ full_path: `${CONTAINER.fieldId}.${COMPONENT_1.fieldId}`,
32
32
  type: COMPONENT_1.type,
33
33
  label: COMPONENT_1.label
34
34
  });
35
35
  (0, _setupTests.expectObjectLike)(container.components[1], {
36
36
  id: COMPONENT_2.id,
37
37
  fieldId: COMPONENT_2.fieldId,
38
- full_path: "".concat(CONTAINER.fieldId, ".").concat(COMPONENT_2.fieldId),
38
+ full_path: `${CONTAINER.fieldId}.${COMPONENT_2.fieldId}`,
39
39
  type: COMPONENT_2.type,
40
40
  label: COMPONENT_2.label
41
41
  });
42
42
  });
43
- it('should setup the full_path attribute for components when the container full_path property is missing', function () {
44
- var COMPONENT_1 = {
43
+ it('should setup the full_path attribute for components when the container full_path property is missing', () => {
44
+ const COMPONENT_1 = {
45
45
  id: 'checkboxes1',
46
46
  fieldId: 'checkboxes1',
47
47
  type: 'checkboxes',
48
48
  label: 'Alpha'
49
49
  };
50
- var COMPONENT_2 = {
50
+ const COMPONENT_2 = {
51
51
  id: 'checkboxes2',
52
52
  fieldId: 'checkboxes2',
53
53
  type: 'checkboxes',
54
54
  label: 'Bravo'
55
55
  };
56
- var CONTAINER = {
56
+ const CONTAINER = {
57
57
  id: 'test-container',
58
58
  fieldId: 'test-container',
59
59
  type: 'container',
60
60
  components: [COMPONENT_1, COMPONENT_2]
61
61
  };
62
- var container = (0, _setupContainerComponentsPath.default)(CONTAINER);
62
+ const container = (0, _setupContainerComponentsPath.default)(CONTAINER);
63
63
  (0, _setupTests.expectObjectLike)(container.components[0], {
64
64
  id: COMPONENT_1.id,
65
65
  fieldId: COMPONENT_1.fieldId,
66
- full_path: "".concat(CONTAINER.fieldId, ".").concat(COMPONENT_1.fieldId),
66
+ full_path: `${CONTAINER.fieldId}.${COMPONENT_1.fieldId}`,
67
67
  type: COMPONENT_1.type,
68
68
  label: COMPONENT_1.label
69
69
  });
70
70
  (0, _setupTests.expectObjectLike)(container.components[1], {
71
71
  id: COMPONENT_2.id,
72
72
  fieldId: COMPONENT_2.fieldId,
73
- full_path: "".concat(CONTAINER.fieldId, ".").concat(COMPONENT_2.fieldId),
73
+ full_path: `${CONTAINER.fieldId}.${COMPONENT_2.fieldId}`,
74
74
  type: COMPONENT_2.type,
75
75
  label: COMPONENT_2.label
76
76
  });
@@ -5,21 +5,19 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _Condition = _interopRequireDefault(require("../Condition"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
9
  // Local imports
10
10
 
11
- var showComponent = function showComponent(component, data) {
12
- var _component$show_when;
11
+ const showComponent = (component, data) => {
13
12
  if (!component) {
14
13
  return false;
15
14
  }
16
15
  if (component.hidden && component.disabled) {
17
16
  return false;
18
17
  }
19
- if (((_component$show_when = component.show_when) === null || _component$show_when === void 0 ? void 0 : _component$show_when.type) === "or") {
18
+ if (component.show_when?.type === "or") {
20
19
  return _Condition.default.meetsOne(component, data);
21
20
  }
22
21
  return _Condition.default.meetsAll(component, data);
23
22
  };
24
- var _default = showComponent;
25
- exports.default = _default;
23
+ var _default = exports.default = showComponent;
@@ -1,59 +1,59 @@
1
1
  "use strict";
2
2
 
3
3
  var _showComponent = _interopRequireDefault(require("./showComponent"));
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('Component', function () {
9
- describe('show', function () {
10
- it('should not show when there are no options', function () {
7
+ describe('utils', () => {
8
+ describe('Component', () => {
9
+ describe('show', () => {
10
+ it('should not show when there are no options', () => {
11
11
  expect((0, _showComponent.default)(null, null)).toBeFalsy();
12
12
  });
13
- it('should not show when hidden and disabled', function () {
13
+ it('should not show when hidden and disabled', () => {
14
14
  expect((0, _showComponent.default)({
15
15
  hidden: true,
16
16
  disabled: true
17
17
  }, null)).toBeFalsy();
18
18
  });
19
- it('should show when hidden but not disabled', function () {
19
+ it('should show when hidden but not disabled', () => {
20
20
  expect((0, _showComponent.default)({
21
21
  hidden: true
22
22
  }, null)).toBeTruthy();
23
23
  });
24
- it('should show when disabled but not hidden', function () {
24
+ it('should show when disabled but not hidden', () => {
25
25
  expect((0, _showComponent.default)({
26
26
  disabled: true
27
27
  }, null)).toBeTruthy();
28
28
  });
29
- it('should show when a single show_when condition is met', function () {
30
- var COMPONENT = {
29
+ it('should show when a single show_when condition is met', () => {
30
+ const COMPONENT = {
31
31
  show_when: {
32
32
  field: 'alpha',
33
33
  op: 'eq',
34
34
  value: 'bravo'
35
35
  }
36
36
  };
37
- var DATA = {
37
+ const DATA = {
38
38
  alpha: 'bravo'
39
39
  };
40
40
  expect((0, _showComponent.default)(COMPONENT, DATA)).toBeTruthy();
41
41
  });
42
- it('should not show when a single show_when condition is not met', function () {
43
- var COMPONENT = {
42
+ it('should not show when a single show_when condition is not met', () => {
43
+ const COMPONENT = {
44
44
  show_when: {
45
45
  field: 'alpha',
46
46
  op: 'eq',
47
47
  value: 'bravo'
48
48
  }
49
49
  };
50
- var DATA = {
50
+ const DATA = {
51
51
  alpha: 'charlie'
52
52
  };
53
53
  expect((0, _showComponent.default)(COMPONENT, DATA)).toBeFalsy();
54
54
  });
55
- it('should show when multiple show_when conditions are met', function () {
56
- var COMPONENT = {
55
+ it('should show when multiple show_when conditions are met', () => {
56
+ const COMPONENT = {
57
57
  show_when: [{
58
58
  field: 'alpha',
59
59
  op: 'eq',
@@ -64,14 +64,14 @@ describe('utils', function () {
64
64
  value: 'delta'
65
65
  }]
66
66
  };
67
- var DATA = {
67
+ const DATA = {
68
68
  alpha: 'bravo',
69
69
  charlie: 'delta'
70
70
  };
71
71
  expect((0, _showComponent.default)(COMPONENT, DATA)).toBeTruthy();
72
72
  });
73
- it('should not show when one of multiple show_when conditions is not met', function () {
74
- var COMPONENT = {
73
+ it('should not show when one of multiple show_when conditions is not met', () => {
74
+ const COMPONENT = {
75
75
  show_when: [{
76
76
  field: 'alpha',
77
77
  op: 'eq',
@@ -82,14 +82,14 @@ describe('utils', function () {
82
82
  value: 'delta'
83
83
  }]
84
84
  };
85
- var DATA = {
85
+ const DATA = {
86
86
  alpha: 'bravo',
87
87
  charlie: 'echo'
88
88
  };
89
89
  expect((0, _showComponent.default)(COMPONENT, DATA)).toBeFalsy();
90
90
  });
91
- it('SHOULD be shown when the component has multiple show_when conditions, with type "or" provided and ALL are matched', function () {
92
- var COMPONENT = {
91
+ it('SHOULD be shown when the component has multiple show_when conditions, with type "or" provided and ALL are matched', () => {
92
+ const COMPONENT = {
93
93
  show_when: {
94
94
  "type": "or",
95
95
  "conditions": [{
@@ -103,14 +103,14 @@ describe('utils', function () {
103
103
  }]
104
104
  }
105
105
  };
106
- var DATA = {
106
+ const DATA = {
107
107
  alpha: 'Alpha',
108
108
  bravo: 'Bravo'
109
109
  };
110
110
  expect((0, _showComponent.default)(COMPONENT, DATA)).toBeTruthy();
111
111
  });
112
- it('SHOULD be shown when the component has multiple show_when conditions, with type "or" provided and at least ONE is matched', function () {
113
- var COMPONENT = {
112
+ it('SHOULD be shown when the component has multiple show_when conditions, with type "or" provided and at least ONE is matched', () => {
113
+ const COMPONENT = {
114
114
  show_when: {
115
115
  "type": "or",
116
116
  "conditions": [{
@@ -124,14 +124,14 @@ describe('utils', function () {
124
124
  }]
125
125
  }
126
126
  };
127
- var DATA = {
127
+ const DATA = {
128
128
  alpha: 'Alpha',
129
129
  bravo: 'Bravo'
130
130
  };
131
131
  expect((0, _showComponent.default)(COMPONENT, DATA)).toBeTruthy();
132
132
  });
133
- it('should NOT be shown when the component has multiple show_when conditions, with type "or" provided and NONE are matched', function () {
134
- var COMPONENT = {
133
+ it('should NOT be shown when the component has multiple show_when conditions, with type "or" provided and NONE are matched', () => {
134
+ const COMPONENT = {
135
135
  show_when: {
136
136
  "type": "or",
137
137
  "conditions": [{
@@ -145,7 +145,7 @@ describe('utils', function () {
145
145
  }]
146
146
  }
147
147
  };
148
- var DATA = {
148
+ const DATA = {
149
149
  alpha: 'Alpha',
150
150
  bravo: 'Bravo'
151
151
  };