@ukhomeoffice/cop-react-form-renderer 6.14.0 → 6.14.2-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (385) hide show
  1. package/README.md +5 -0
  2. package/dist/components/CheckYourAnswers/Answer.js +12 -11
  3. package/dist/components/CheckYourAnswers/Answer.test.js +132 -181
  4. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +98 -133
  5. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +544 -939
  6. package/dist/components/CheckYourAnswers/index.js +1 -1
  7. package/dist/components/CollectionPage/CollectionPage.js +62 -60
  8. package/dist/components/CollectionPage/CollectionPage.test.js +315 -365
  9. package/dist/components/CollectionPage/index.js +1 -1
  10. package/dist/components/CollectionSummary/BannerStrip.js +14 -14
  11. package/dist/components/CollectionSummary/BannerStrip.test.js +79 -74
  12. package/dist/components/CollectionSummary/CollectionSummary.js +75 -97
  13. package/dist/components/CollectionSummary/CollectionSummary.test.js +182 -166
  14. package/dist/components/CollectionSummary/Confirmation.js +15 -13
  15. package/dist/components/CollectionSummary/Confirmation.test.js +68 -63
  16. package/dist/components/CollectionSummary/RenderListView.js +34 -47
  17. package/dist/components/CollectionSummary/RenderListView.test.js +113 -111
  18. package/dist/components/CollectionSummary/SummaryCard.js +101 -133
  19. package/dist/components/CollectionSummary/SummaryCard.test.js +961 -993
  20. package/dist/components/CollectionSummary/SummaryCardButtons.js +25 -30
  21. package/dist/components/CollectionSummary/SummaryCardButtons.test.js +30 -28
  22. package/dist/components/CollectionSummary/SummaryCardDetails.js +59 -76
  23. package/dist/components/CollectionSummary/SummaryCardDetails.test.js +170 -180
  24. package/dist/components/CollectionSummary/SummaryCardValidationContext.js +31 -36
  25. package/dist/components/CollectionSummary/SummaryCardValidationContext.test.js +63 -75
  26. package/dist/components/CollectionSummary/index.js +1 -1
  27. package/dist/components/FormComponent/Collection.js +63 -100
  28. package/dist/components/FormComponent/Collection.test.js +907 -1080
  29. package/dist/components/FormComponent/Container.js +35 -29
  30. package/dist/components/FormComponent/Container.test.js +378 -409
  31. package/dist/components/FormComponent/FormComponent.js +59 -63
  32. package/dist/components/FormComponent/FormComponent.test.js +354 -415
  33. package/dist/components/FormComponent/helpers/addLabel.js +4 -7
  34. package/dist/components/FormComponent/helpers/getComponentDisabled.js +1 -1
  35. package/dist/components/FormComponent/helpers/getComponentDisabled.test.js +8 -8
  36. package/dist/components/FormComponent/helpers/getComponentError.js +3 -5
  37. package/dist/components/FormComponent/helpers/getComponentError.test.js +15 -15
  38. package/dist/components/FormComponent/helpers/getComponentFieldSet.js +3 -4
  39. package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +7 -7
  40. package/dist/components/FormComponent/helpers/index.js +5 -5
  41. package/dist/components/FormComponent/index.js +1 -1
  42. package/dist/components/FormPage/FormPage.js +70 -93
  43. package/dist/components/FormPage/FormPage.test.js +150 -202
  44. package/dist/components/FormPage/index.js +1 -1
  45. package/dist/components/FormRenderer/FormRenderer.js +131 -173
  46. package/dist/components/FormRenderer/FormRenderer.test.js +732 -1114
  47. package/dist/components/FormRenderer/handlers/cyaAction.js +3 -3
  48. package/dist/components/FormRenderer/handlers/getPageId.js +1 -3
  49. package/dist/components/FormRenderer/handlers/getPageId.test.js +15 -15
  50. package/dist/components/FormRenderer/handlers/handlers.test.js +33 -33
  51. package/dist/components/FormRenderer/handlers/index.js +2 -2
  52. package/dist/components/FormRenderer/handlers/navigate.js +4 -4
  53. package/dist/components/FormRenderer/handlers/submissionError.js +1 -1
  54. package/dist/components/FormRenderer/helpers/canActionProceed.js +1 -1
  55. package/dist/components/FormRenderer/helpers/canActionProceed.test.js +16 -16
  56. package/dist/components/FormRenderer/helpers/canCYASubmit.js +1 -3
  57. package/dist/components/FormRenderer/helpers/canCYASubmit.test.js +17 -21
  58. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +22 -25
  59. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +21 -21
  60. package/dist/components/FormRenderer/helpers/getCYA.js +4 -6
  61. package/dist/components/FormRenderer/helpers/getCYA.test.js +12 -12
  62. package/dist/components/FormRenderer/helpers/getFormState.js +6 -8
  63. package/dist/components/FormRenderer/helpers/getFormState.test.js +11 -11
  64. package/dist/components/FormRenderer/helpers/getNextPageId.js +14 -25
  65. package/dist/components/FormRenderer/helpers/getNextPageId.test.js +68 -68
  66. package/dist/components/FormRenderer/helpers/getPage.js +2 -4
  67. package/dist/components/FormRenderer/helpers/getPage.test.js +12 -12
  68. package/dist/components/FormRenderer/helpers/getRelevantPages.js +7 -9
  69. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +15 -15
  70. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +6 -6
  71. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +104 -98
  72. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +44 -51
  73. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +68 -74
  74. package/dist/components/FormRenderer/helpers/index.js +2 -2
  75. package/dist/components/FormRenderer/index.js +1 -1
  76. package/dist/components/FormRenderer/onCYAAction.js +43 -44
  77. package/dist/components/FormRenderer/onCYAAction.test.js +126 -133
  78. package/dist/components/FormRenderer/onPageAction.js +26 -35
  79. package/dist/components/FormRenderer/onPageAction.test.js +177 -186
  80. package/dist/components/FormRenderer/onTaskAction.js +11 -12
  81. package/dist/components/FormRenderer/onTaskAction.test.js +63 -68
  82. package/dist/components/PageActions/ActionButton.js +14 -14
  83. package/dist/components/PageActions/ActionButton.test.js +57 -79
  84. package/dist/components/PageActions/PageActions.js +11 -11
  85. package/dist/components/PageActions/PageActions.test.js +87 -116
  86. package/dist/components/PageActions/index.js +1 -1
  87. package/dist/components/SummaryList/GroupAction.js +10 -18
  88. package/dist/components/SummaryList/GroupAction.test.js +38 -34
  89. package/dist/components/SummaryList/RowAction.js +12 -17
  90. package/dist/components/SummaryList/RowAction.test.js +38 -34
  91. package/dist/components/SummaryList/SummaryList.js +23 -25
  92. package/dist/components/SummaryList/SummaryList.test.js +162 -189
  93. package/dist/components/SummaryList/SummaryListHeadingRow.js +7 -5
  94. package/dist/components/SummaryList/SummaryListHeadingRowWithAction.js +7 -5
  95. package/dist/components/SummaryList/SummaryListRow.js +7 -5
  96. package/dist/components/SummaryList/SummaryListTitleRow.js +6 -4
  97. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +3 -5
  98. package/dist/components/SummaryList/helpers/getGroupActionAttributes.test.js +23 -23
  99. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +3 -5
  100. package/dist/components/SummaryList/helpers/getRowActionAttributes.test.js +23 -23
  101. package/dist/components/SummaryList/helpers/index.js +2 -2
  102. package/dist/components/SummaryList/index.js +1 -1
  103. package/dist/components/TaskList/Task.js +20 -30
  104. package/dist/components/TaskList/Task.test.js +84 -77
  105. package/dist/components/TaskList/TaskList.js +56 -79
  106. package/dist/components/TaskList/TaskList.test.js +149 -149
  107. package/dist/components/TaskList/TaskState.js +8 -6
  108. package/dist/components/TaskList/TaskState.test.js +53 -46
  109. package/dist/components/TaskList/index.js +1 -1
  110. package/dist/components/index.js +8 -8
  111. package/dist/context/HooksContext/HooksContext.js +56 -79
  112. package/dist/context/HooksContext/HooksContext.test.js +27 -36
  113. package/dist/context/HooksContext/index.js +3 -4
  114. package/dist/context/ValidationContext/ValidationContext.js +44 -95
  115. package/dist/context/ValidationContext/ValidationContext.test.js +57 -69
  116. package/dist/context/ValidationContext/index.js +3 -4
  117. package/dist/context/index.js +3 -3
  118. package/dist/hooks/index.js +10 -11
  119. package/dist/hooks/useAxios.js +15 -41
  120. package/dist/hooks/useGetRequest.js +62 -98
  121. package/dist/hooks/useHooks.js +1 -3
  122. package/dist/hooks/useRefData.js +25 -37
  123. package/dist/hooks/useValidation.js +1 -3
  124. package/dist/index.js +14 -15
  125. package/dist/models/CollectionLabels.js +1 -1
  126. package/dist/models/ComponentTypes.js +25 -25
  127. package/dist/models/EventTypes.js +4 -4
  128. package/dist/models/FormPages.js +4 -4
  129. package/dist/models/FormTypes.js +8 -8
  130. package/dist/models/HubFormats.js +3 -3
  131. package/dist/models/PageAction.js +44 -38
  132. package/dist/models/TaskStates.js +29 -28
  133. package/dist/models/index.js +10 -10
  134. package/dist/setupTests.js +30 -31
  135. package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
  136. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +53 -55
  137. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +12 -21
  138. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +32 -33
  139. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +15 -28
  140. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +41 -42
  141. package/dist/utils/CheckYourAnswers/getCYARow.js +7 -7
  142. package/dist/utils/CheckYourAnswers/getCYARow.test.js +87 -87
  143. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +19 -21
  144. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +16 -17
  145. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +27 -34
  146. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +48 -52
  147. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +76 -93
  148. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +110 -115
  149. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +11 -16
  150. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +112 -106
  151. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +14 -19
  152. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +69 -73
  153. package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.js +7 -8
  154. package/dist/utils/CheckYourAnswers/getSummaryListRowForDetails.test.js +15 -16
  155. package/dist/utils/CheckYourAnswers/index.js +2 -2
  156. package/dist/utils/CheckYourAnswers/showComponentCYA.js +5 -5
  157. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +26 -26
  158. package/dist/utils/CollectionPage/addCollectionPageEntry.js +2 -2
  159. package/dist/utils/CollectionPage/addCollectionPageEntry.test.js +6 -6
  160. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +3 -3
  161. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +18 -19
  162. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.js +13 -20
  163. package/dist/utils/CollectionPage/duplicateCollectionPageEntry.test.js +48 -39
  164. package/dist/utils/CollectionPage/getCollectionPageActiveId.js +2 -2
  165. package/dist/utils/CollectionPage/getCollectionPageActiveId.test.js +11 -11
  166. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.js +7 -11
  167. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +23 -23
  168. package/dist/utils/CollectionPage/getCollectionPageData.js +8 -12
  169. package/dist/utils/CollectionPage/getCollectionPageData.test.js +20 -20
  170. package/dist/utils/CollectionPage/getErrorsForCollection.js +20 -21
  171. package/dist/utils/CollectionPage/getErrorsForCollection.test.js +21 -23
  172. package/dist/utils/CollectionPage/getQuickEditPage.js +22 -23
  173. package/dist/utils/CollectionPage/getQuickEditPage.test.js +17 -18
  174. package/dist/utils/CollectionPage/index.js +2 -2
  175. package/dist/utils/CollectionPage/mergeCollectionPages.js +26 -35
  176. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +18 -18
  177. package/dist/utils/CollectionPage/removeCollectionPageEntry.js +5 -7
  178. package/dist/utils/CollectionPage/removeCollectionPageEntry.test.js +11 -11
  179. package/dist/utils/CollectionPage/setCollectionPageData.js +10 -16
  180. package/dist/utils/CollectionPage/setCollectionPageData.test.js +25 -25
  181. package/dist/utils/Component/addShowWhen.js +5 -6
  182. package/dist/utils/Component/addShowWhen.test.js +38 -38
  183. package/dist/utils/Component/applyToComponentTree.js +12 -15
  184. package/dist/utils/Component/applyToComponentTree.test.js +28 -31
  185. package/dist/utils/Component/cleanAttributes.js +12 -11
  186. package/dist/utils/Component/cleanAttributes.test.js +17 -18
  187. package/dist/utils/Component/elevateNestedComponents.js +6 -6
  188. package/dist/utils/Component/elevateNestedComponents.test.js +34 -34
  189. package/dist/utils/Component/getComponent.js +79 -85
  190. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +19 -18
  191. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +41 -58
  192. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +40 -49
  193. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +24 -34
  194. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +21 -19
  195. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +18 -23
  196. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +21 -26
  197. package/dist/utils/Component/getComponentTests/getComponent.heading.test.js +11 -10
  198. package/dist/utils/Component/getComponentTests/getComponent.html.test.js +18 -16
  199. package/dist/utils/Component/getComponentTests/getComponent.insetText.test.js +10 -9
  200. package/dist/utils/Component/getComponentTests/getComponent.list.test.js +18 -16
  201. package/dist/utils/Component/getComponentTests/getComponent.multifile.test.js +23 -27
  202. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +201 -226
  203. package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +18 -16
  204. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +18 -23
  205. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +58 -73
  206. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +18 -23
  207. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +18 -23
  208. package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +32 -39
  209. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +21 -30
  210. package/dist/utils/Component/getComponentTests/getComponent.unknown.test.js +3 -3
  211. package/dist/utils/Component/getComponentTests/getComponent.warningText.test.js +10 -9
  212. package/dist/utils/Component/getDefaultValue.js +7 -9
  213. package/dist/utils/Component/getDefaultValue.test.js +13 -13
  214. package/dist/utils/Component/getDefaultValueFromConfig.js +16 -20
  215. package/dist/utils/Component/getDefaultValueFromConfig.test.js +32 -32
  216. package/dist/utils/Component/index.js +2 -2
  217. package/dist/utils/Component/isEditable.js +2 -4
  218. package/dist/utils/Component/isEditable.test.js +14 -15
  219. package/dist/utils/Component/optionIsSelected.js +2 -4
  220. package/dist/utils/Component/optionIsSelected.test.js +12 -12
  221. package/dist/utils/Component/setupContainerComponentsPath.js +23 -28
  222. package/dist/utils/Component/setupContainerComponentsPath.test.js +12 -12
  223. package/dist/utils/Component/showComponent.js +2 -2
  224. package/dist/utils/Component/showComponent.test.js +29 -29
  225. package/dist/utils/Component/wrapInFormGroup.js +4 -4
  226. package/dist/utils/Condition/index.js +2 -2
  227. package/dist/utils/Condition/meetsAllConditions.js +9 -9
  228. package/dist/utils/Condition/meetsAllConditions.test.js +21 -21
  229. package/dist/utils/Condition/meetsCondition.js +17 -26
  230. package/dist/utils/Condition/meetsCondition.test.js +403 -403
  231. package/dist/utils/Condition/meetsOneCondition.js +6 -6
  232. package/dist/utils/Condition/meetsOneCondition.test.js +17 -17
  233. package/dist/utils/Condition/setupConditions.js +12 -15
  234. package/dist/utils/Condition/setupConditions.test.js +8 -8
  235. package/dist/utils/Container/getEditableComponents.js +4 -6
  236. package/dist/utils/Container/getEditableComponents.test.js +44 -46
  237. package/dist/utils/Container/index.js +2 -2
  238. package/dist/utils/Container/setupNesting.js +14 -15
  239. package/dist/utils/Container/setupNesting.test.js +20 -23
  240. package/dist/utils/Container/showContainer.js +4 -8
  241. package/dist/utils/Container/showContainer.test.js +31 -31
  242. package/dist/utils/Data/applyFormula.js +30 -44
  243. package/dist/utils/Data/applyFormula.test.js +21 -21
  244. package/dist/utils/Data/deleteValues.js +4 -8
  245. package/dist/utils/Data/deleteValues.test.js +11 -11
  246. package/dist/utils/Data/getAutocompleteSource.js +72 -63
  247. package/dist/utils/Data/getAutocompleteSource.test.js +106 -98
  248. package/dist/utils/Data/getDataPath.js +18 -28
  249. package/dist/utils/Data/getDataPath.test.js +13 -13
  250. package/dist/utils/Data/getOptions.js +35 -42
  251. package/dist/utils/Data/getOptions.test.js +37 -38
  252. package/dist/utils/Data/getSourceData.js +6 -19
  253. package/dist/utils/Data/getSourceData.test.js +85 -81
  254. package/dist/utils/Data/index.js +2 -2
  255. package/dist/utils/Data/nestInRefdataOptions.js +9 -12
  256. package/dist/utils/Data/nestInRefdataOptions.test.js +17 -17
  257. package/dist/utils/Data/refDataToOptions.js +9 -10
  258. package/dist/utils/Data/refDataToOptions.test.js +20 -20
  259. package/dist/utils/Data/setDataItem.js +7 -8
  260. package/dist/utils/Data/setDataItem.test.js +38 -38
  261. package/dist/utils/Data/setupFormData.js +13 -20
  262. package/dist/utils/Data/setupFormData.test.js +48 -47
  263. package/dist/utils/Data/setupRefDataUrlForComponent.js +11 -20
  264. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +25 -25
  265. package/dist/utils/FormPage/applyConditionalProperties.js +7 -8
  266. package/dist/utils/FormPage/applyConditionalProperties.test.js +14 -15
  267. package/dist/utils/FormPage/getConditionalText.js +4 -4
  268. package/dist/utils/FormPage/getConditionalText.test.js +30 -30
  269. package/dist/utils/FormPage/getFormPage.js +12 -15
  270. package/dist/utils/FormPage/getFormPage.test.js +23 -24
  271. package/dist/utils/FormPage/getFormPages.js +8 -11
  272. package/dist/utils/FormPage/getFormPages.test.js +15 -16
  273. package/dist/utils/FormPage/getPageActions.js +10 -13
  274. package/dist/utils/FormPage/getPageActions.test.js +33 -33
  275. package/dist/utils/FormPage/getParagraphFromText.js +5 -7
  276. package/dist/utils/FormPage/getParagraphFromText.test.js +7 -7
  277. package/dist/utils/FormPage/index.js +3 -5
  278. package/dist/utils/FormPage/showFormPage.js +4 -8
  279. package/dist/utils/FormPage/showFormPage.test.js +33 -33
  280. package/dist/utils/FormPage/showFormPageCYA.js +2 -2
  281. package/dist/utils/FormPage/showFormPageCYA.test.js +9 -9
  282. package/dist/utils/FormPage/useComponent.js +15 -23
  283. package/dist/utils/FormPage/useComponent.test.js +49 -50
  284. package/dist/utils/Format/formatData.js +1 -1
  285. package/dist/utils/Format/formatData.test.js +19 -19
  286. package/dist/utils/Format/formatDataForComponent.js +6 -7
  287. package/dist/utils/Format/formatDataForComponent.test.js +50 -78
  288. package/dist/utils/Format/formatDataForForm.js +5 -6
  289. package/dist/utils/Format/formatDataForForm.test.js +14 -17
  290. package/dist/utils/Format/formatDataForPage.js +4 -5
  291. package/dist/utils/Format/formatDataForPage.test.js +20 -25
  292. package/dist/utils/Format/index.js +2 -2
  293. package/dist/utils/Hub/getFormHub.js +2 -2
  294. package/dist/utils/Hub/getFormHub.test.js +23 -24
  295. package/dist/utils/Hub/index.js +2 -2
  296. package/dist/utils/Meta/constants.js +2 -2
  297. package/dist/utils/Meta/documents/getDocuments.js +1 -1
  298. package/dist/utils/Meta/documents/getDocuments.test.js +25 -17
  299. package/dist/utils/Meta/documents/index.js +2 -2
  300. package/dist/utils/Meta/documents/setDocumentsForField.js +12 -13
  301. package/dist/utils/Meta/documents/setDocumentsForField.test.js +70 -33
  302. package/dist/utils/Meta/index.js +2 -2
  303. package/dist/utils/Operate/checkValueIsTruthy.js +3 -3
  304. package/dist/utils/Operate/checkValueIsTruthy.test.js +17 -17
  305. package/dist/utils/Operate/deleteValueInFormData.js +2 -2
  306. package/dist/utils/Operate/deleteValueInFormData.test.js +15 -15
  307. package/dist/utils/Operate/getFirstOf.js +6 -6
  308. package/dist/utils/Operate/getFirstOf.test.js +32 -32
  309. package/dist/utils/Operate/getIndexOfMatchingValueIn.js +11 -11
  310. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +47 -53
  311. package/dist/utils/Operate/getLength.js +9 -9
  312. package/dist/utils/Operate/getLength.test.js +19 -19
  313. package/dist/utils/Operate/index.js +2 -2
  314. package/dist/utils/Operate/persistValueInFormData.js +4 -4
  315. package/dist/utils/Operate/persistValueInFormData.test.js +23 -21
  316. package/dist/utils/Operate/runPageOperations.js +8 -8
  317. package/dist/utils/Operate/runPageOperations.test.js +24 -25
  318. package/dist/utils/Operate/setValueInFormData.js +3 -3
  319. package/dist/utils/Operate/setValueInFormData.test.js +17 -17
  320. package/dist/utils/Operate/shouldRun.js +7 -7
  321. package/dist/utils/Operate/shouldRun.test.js +22 -24
  322. package/dist/utils/Validate/additional/conditionallyPermittedChange.js +1 -1
  323. package/dist/utils/Validate/additional/conditionallyPermittedChange.test.js +15 -15
  324. package/dist/utils/Validate/additional/conditionallyRequired.js +4 -4
  325. package/dist/utils/Validate/additional/conditionallyRequired.test.js +19 -19
  326. package/dist/utils/Validate/additional/index.js +8 -8
  327. package/dist/utils/Validate/additional/index.test.js +22 -22
  328. package/dist/utils/Validate/additional/mustBeAfter.js +3 -3
  329. package/dist/utils/Validate/additional/mustBeAfter.test.js +41 -41
  330. package/dist/utils/Validate/additional/mustBeBefore.js +3 -3
  331. package/dist/utils/Validate/additional/mustBeBefore.test.js +29 -29
  332. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +8 -12
  333. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +37 -38
  334. package/dist/utils/Validate/additional/mustBeGreaterThan.js +2 -2
  335. package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +19 -19
  336. package/dist/utils/Validate/additional/mustBeInTheFuture.js +3 -3
  337. package/dist/utils/Validate/additional/mustBeInTheFuture.test.js +13 -13
  338. package/dist/utils/Validate/additional/mustBeInThePast.js +4 -4
  339. package/dist/utils/Validate/additional/mustBeInThePast.test.js +13 -13
  340. package/dist/utils/Validate/additional/mustBeLessThan.js +2 -2
  341. package/dist/utils/Validate/additional/mustBeLessThan.test.js +18 -18
  342. package/dist/utils/Validate/additional/mustBeLongerThan.js +1 -1
  343. package/dist/utils/Validate/additional/mustBeLongerThan.test.js +17 -17
  344. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +2 -2
  345. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +21 -21
  346. package/dist/utils/Validate/additional/mustBeOneOf.js +1 -1
  347. package/dist/utils/Validate/additional/mustBeOneOf.test.js +13 -13
  348. package/dist/utils/Validate/additional/mustBeShorterThan.js +1 -1
  349. package/dist/utils/Validate/additional/mustBeShorterThan.test.js +17 -17
  350. package/dist/utils/Validate/additional/mustBeUniqueInCollection.js +5 -5
  351. package/dist/utils/Validate/additional/mustBeUniqueInCollection.test.js +35 -36
  352. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +2 -2
  353. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +15 -17
  354. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +1 -1
  355. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +13 -13
  356. package/dist/utils/Validate/additional/mustNotContainSql.js +3 -4
  357. package/dist/utils/Validate/additional/mustNotContainSql.test.js +15 -15
  358. package/dist/utils/Validate/additional/mustSelectOnlyOne.js +2 -2
  359. package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +29 -27
  360. package/dist/utils/Validate/additional/utils.js +9 -22
  361. package/dist/utils/Validate/index.js +2 -2
  362. package/dist/utils/Validate/validateCollection.js +18 -23
  363. package/dist/utils/Validate/validateCollection.test.js +75 -67
  364. package/dist/utils/Validate/validateComponent.js +19 -19
  365. package/dist/utils/Validate/validateComponent.test.js +179 -154
  366. package/dist/utils/Validate/validateContainer.js +14 -17
  367. package/dist/utils/Validate/validateContainer.test.js +59 -53
  368. package/dist/utils/Validate/validateDate.js +16 -22
  369. package/dist/utils/Validate/validateDate.test.js +31 -32
  370. package/dist/utils/Validate/validateEmail.js +7 -9
  371. package/dist/utils/Validate/validateEmail.test.js +27 -27
  372. package/dist/utils/Validate/validateMultifile.js +5 -7
  373. package/dist/utils/Validate/validateMultifile.test.js +17 -18
  374. package/dist/utils/Validate/validatePage.js +13 -18
  375. package/dist/utils/Validate/validatePage.test.js +198 -195
  376. package/dist/utils/Validate/validateRegex.js +3 -5
  377. package/dist/utils/Validate/validateRegex.test.js +15 -15
  378. package/dist/utils/Validate/validateRequired.js +4 -6
  379. package/dist/utils/Validate/validateRequired.test.js +19 -19
  380. package/dist/utils/Validate/validateTextArea.js +4 -6
  381. package/dist/utils/Validate/validateTextArea.test.js +21 -21
  382. package/dist/utils/Validate/validateTime.js +12 -19
  383. package/dist/utils/Validate/validateTime.test.js +27 -27
  384. package/dist/utils/index.js +5 -6
  385. package/package.json +2 -4
@@ -3,17 +3,16 @@
3
3
  var _models = require("../../models");
4
4
  var _setupTests = require("../../setupTests");
5
5
  var _getCYARowsForCollection = _interopRequireDefault(require("./getCYARowsForCollection"));
6
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
6
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
7
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
8
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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); } // Local imports
13
- describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
14
- it('should get a single entry point row when there are no items', function () {
15
- var FORM_DATA = undefined;
16
- var PAGE = {
9
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
10
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
11
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Local imports
12
+ describe('utils.CheckYourAnswers.getCYARowsForCollection', () => {
13
+ it('should get a single entry point row when there are no items', () => {
14
+ const FORM_DATA = undefined;
15
+ const PAGE = {
17
16
  id: 'page',
18
17
  components: [{
19
18
  labels: {
@@ -23,42 +22,42 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
23
22
  formData: FORM_DATA,
24
23
  cya_link: {}
25
24
  };
26
- var COMPONENT = {
25
+ const COMPONENT = {
27
26
  type: 'text',
28
27
  readonly: true,
29
28
  id: 'a',
30
29
  fieldId: 'a',
31
30
  label: 'Alpha'
32
31
  };
33
- var COLLECTION = {
32
+ const COLLECTION = {
34
33
  id: 'collection',
35
34
  fieldId: 'collection',
36
35
  type: _models.ComponentTypes.COLLECTION,
37
36
  item: [COMPONENT]
38
37
  };
39
- var ON_ACTION = function ON_ACTION() {};
40
- var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, undefined, ON_ACTION);
38
+ const ON_ACTION = () => {};
39
+ const ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, undefined, ON_ACTION);
41
40
  expect(ROWS.length).toEqual(1);
42
41
  });
43
- it('should get an appropriate row for a collection with a single readonly text component', function () {
44
- var FORM_DATA = {
42
+ it('should get an appropriate row for a collection with a single readonly text component', () => {
43
+ const FORM_DATA = {
45
44
  collection: [{
46
45
  a: 'Bravo'
47
46
  }]
48
47
  };
49
- var PAGE = {
48
+ const PAGE = {
50
49
  id: 'page',
51
50
  formData: FORM_DATA,
52
51
  cya_link: {}
53
52
  };
54
- var COMPONENT = {
53
+ const COMPONENT = {
55
54
  type: 'text',
56
55
  readonly: true,
57
56
  id: 'a',
58
57
  fieldId: 'a',
59
58
  label: 'Alpha'
60
59
  };
61
- var COLLECTION = {
60
+ const COLLECTION = {
62
61
  id: 'collection',
63
62
  fieldId: 'collection',
64
63
  type: _models.ComponentTypes.COLLECTION,
@@ -67,8 +66,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
67
66
  value: FORM_DATA.collection,
68
67
  formData: FORM_DATA
69
68
  };
70
- var ON_ACTION = function ON_ACTION() {};
71
- var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
69
+ const ON_ACTION = () => {};
70
+ const ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
72
71
  expect(ROWS.length).toEqual(2); // Item title row + component row
73
72
  (0, _setupTests.expectObjectLike)(ROWS[0], {
74
73
  pageId: PAGE.id,
@@ -91,25 +90,25 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
91
90
  value: 'Bravo'
92
91
  });
93
92
  });
94
- it('should get an appropriate row for a collection with a single readonly text component where the item label is an empty string', function () {
95
- var FORM_DATA = {
93
+ it('should get an appropriate row for a collection with a single readonly text component where the item label is an empty string', () => {
94
+ const FORM_DATA = {
96
95
  collection: [{
97
96
  a: 'Bravo'
98
97
  }]
99
98
  };
100
- var PAGE = {
99
+ const PAGE = {
101
100
  id: 'page',
102
101
  formData: FORM_DATA,
103
102
  cya_link: {}
104
103
  };
105
- var COMPONENT = {
104
+ const COMPONENT = {
106
105
  type: 'text',
107
106
  readonly: true,
108
107
  id: 'a',
109
108
  fieldId: 'a',
110
109
  label: 'Alpha'
111
110
  };
112
- var COLLECTION = {
111
+ const COLLECTION = {
113
112
  id: 'collection',
114
113
  fieldId: 'collection',
115
114
  type: _models.ComponentTypes.COLLECTION,
@@ -121,8 +120,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
121
120
  value: FORM_DATA.collection,
122
121
  formData: FORM_DATA
123
122
  };
124
- var ON_ACTION = function ON_ACTION() {};
125
- var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
123
+ const ON_ACTION = () => {};
124
+ const ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
126
125
  expect(ROWS.length).toEqual(1); // Just the component row, no title row
127
126
  (0, _setupTests.expectObjectLike)(ROWS[0], {
128
127
  pageId: PAGE.id,
@@ -136,26 +135,26 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
136
135
  value: 'Bravo'
137
136
  });
138
137
  });
139
- it('should interpolate a field label appropriately', function () {
140
- var FORM_DATA = {
138
+ it('should interpolate a field label appropriately', () => {
139
+ const FORM_DATA = {
141
140
  collection: [{
142
141
  a: 'Bravo'
143
142
  }]
144
143
  };
145
- var PAGE = {
144
+ const PAGE = {
146
145
  id: 'page',
147
146
  formData: FORM_DATA,
148
147
  cya_link: {}
149
148
  };
150
149
  // eslint-disable-next-line no-template-curly-in-string
151
- var COMPONENT = {
150
+ const COMPONENT = {
152
151
  type: 'text',
153
152
  readonly: true,
154
153
  id: 'a',
155
154
  fieldId: 'a',
156
155
  label: 'Alpha ${index}'
157
156
  };
158
- var COLLECTION = {
157
+ const COLLECTION = {
159
158
  id: 'collection',
160
159
  fieldId: 'collection',
161
160
  type: _models.ComponentTypes.COLLECTION,
@@ -163,8 +162,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
163
162
  value: FORM_DATA.collection,
164
163
  formData: FORM_DATA
165
164
  };
166
- var ON_ACTION = function ON_ACTION() {};
167
- var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
165
+ const ON_ACTION = () => {};
166
+ const ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
168
167
  expect(ROWS.length).toEqual(2); // Title and item row.
169
168
  (0, _setupTests.expectObjectLike)(ROWS[1], {
170
169
  pageId: PAGE.id,
@@ -177,29 +176,28 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
177
176
  full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId),
178
177
  label: 'Alpha 1' // no countOffset
179
178
  }),
180
-
181
179
  value: 'Bravo'
182
180
  });
183
181
  });
184
- it('should ignore the result of the override function if it returns nullish', function () {
185
- var FORM_DATA = {
182
+ it('should ignore the result of the override function if it returns nullish', () => {
183
+ const FORM_DATA = {
186
184
  collection: [{
187
185
  a: 'Bravo'
188
186
  }]
189
187
  };
190
- var PAGE = {
188
+ const PAGE = {
191
189
  id: 'page',
192
190
  formData: FORM_DATA,
193
191
  cya_link: {}
194
192
  };
195
- var COMPONENT = {
193
+ const COMPONENT = {
196
194
  type: 'text',
197
195
  readonly: true,
198
196
  id: 'a',
199
197
  fieldId: 'a',
200
198
  label: 'Alpha'
201
199
  };
202
- var COLLECTION = {
200
+ const COLLECTION = {
203
201
  id: 'collection',
204
202
  fieldId: 'collection',
205
203
  type: _models.ComponentTypes.COLLECTION,
@@ -208,10 +206,8 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
208
206
  value: FORM_DATA.collection,
209
207
  formData: FORM_DATA
210
208
  };
211
- var ON_ACTION = function ON_ACTION() {};
212
- var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION, function () {
213
- return null;
214
- });
209
+ const ON_ACTION = () => {};
210
+ const ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION, () => null);
215
211
  expect(ROWS.length).toEqual(2); // Item title row + component row
216
212
  (0, _setupTests.expectObjectLike)(ROWS[0], {
217
213
  pageId: PAGE.id,
@@ -234,25 +230,25 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
234
230
  value: 'Bravo'
235
231
  });
236
232
  });
237
- it('should use rows produced by the override function if provided', function () {
238
- var FORM_DATA = {
233
+ it('should use rows produced by the override function if provided', () => {
234
+ const FORM_DATA = {
239
235
  collection: [{
240
236
  a: 'Bravo'
241
237
  }]
242
238
  };
243
- var PAGE = {
239
+ const PAGE = {
244
240
  id: 'page',
245
241
  formData: FORM_DATA,
246
242
  cya_link: {}
247
243
  };
248
- var COMPONENT = {
244
+ const COMPONENT = {
249
245
  type: 'text',
250
246
  readonly: true,
251
247
  id: 'a',
252
248
  fieldId: 'a',
253
249
  label: 'Alpha'
254
250
  };
255
- var COLLECTION = {
251
+ const COLLECTION = {
256
252
  id: 'collection',
257
253
  fieldId: 'collection',
258
254
  type: _models.ComponentTypes.COLLECTION,
@@ -261,16 +257,16 @@ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
261
257
  value: FORM_DATA.collection,
262
258
  formData: FORM_DATA
263
259
  };
264
- var ON_ACTION = function ON_ACTION() {};
260
+ const ON_ACTION = () => {};
265
261
  // eslint-disable-next-line arrow-body-style
266
- var OVERRIDE = function OVERRIDE(page, comp) {
262
+ const OVERRIDE = (page, comp) => {
267
263
  // This will be called for each component in the collection,
268
264
  // returning a custom row object.
269
265
  return {
270
266
  key: "CustomRowFor".concat(comp.label)
271
267
  };
272
268
  };
273
- var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION, OVERRIDE);
269
+ const ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION, OVERRIDE);
274
270
  expect(ROWS.length).toEqual(2); // Item title row + component row
275
271
  (0, _setupTests.expectObjectLike)(ROWS[0], {
276
272
  pageId: PAGE.id,
@@ -12,41 +12,30 @@ var _showFormPageCYA = _interopRequireDefault(require("../FormPage/showFormPageC
12
12
  var _getCYACollectionDeleteAction = _interopRequireDefault(require("./getCYACollectionDeleteAction"));
13
13
  var _getCYACollectionChangeAction = _interopRequireDefault(require("./getCYACollectionChangeAction"));
14
14
  var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
17
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
18
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
20
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
21
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
22
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
23
16
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
24
17
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
25
- 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; }
26
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
27
- 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); } // Global imports
18
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
19
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
20
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Global imports
28
21
  // Local imports
29
- var getContainerForPage = function getContainerForPage(page, item, labelCount, fullPath) {
30
- return {
31
- id: item.id,
32
- fieldId: item.id,
33
- type: _models.ComponentTypes.CONTAINER,
34
- required: true,
35
- full_path: fullPath,
36
- components: page.components.map(function (component) {
37
- return _objectSpread(_objectSpread({}, component), {}, {
38
- label: _copReactComponents.Utils.interpolateString(component.label, _objectSpread(_objectSpread({}, item), {}, {
39
- index: labelCount
40
- })),
41
- full_path: "".concat(fullPath, ".").concat(component.fieldId)
42
- });
43
- })
44
- };
45
- };
46
- var getTitleRowForItem = function getTitleRowForItem(page, item, pageId, labelCount, fullPath) {
47
- var labels = _objectSpread(_objectSpread({}, _models.CollectionLabels), page.collection.labels);
22
+ const getContainerForPage = (page, item, labelCount, fullPath) => ({
23
+ id: item.id,
24
+ fieldId: item.id,
25
+ type: _models.ComponentTypes.CONTAINER,
26
+ required: true,
27
+ full_path: fullPath,
28
+ components: page.components.map(component => _objectSpread(_objectSpread({}, component), {}, {
29
+ label: _copReactComponents.Utils.interpolateString(component.label, _objectSpread(_objectSpread({}, item), {}, {
30
+ index: labelCount
31
+ })),
32
+ full_path: "".concat(fullPath, ".").concat(component.fieldId)
33
+ }))
34
+ });
35
+ const getTitleRowForItem = (page, item, pageId, labelCount, fullPath) => {
36
+ const labels = _objectSpread(_objectSpread({}, _models.CollectionLabels), page.collection.labels);
48
37
  return {
49
- pageId: pageId,
38
+ pageId,
50
39
  fieldId: 'Title',
51
40
  full_path: "".concat(fullPath, ".Title"),
52
41
  key: _copReactComponents.Utils.interpolateString(labels.item, _objectSpread(_objectSpread({}, item), {}, {
@@ -56,12 +45,12 @@ var getTitleRowForItem = function getTitleRowForItem(page, item, pageId, labelCo
56
45
  size: page.collection.titleSize || 's'
57
46
  };
58
47
  };
59
- var getHeadingRow = function getHeadingRow(config, pageId, labelCount, changeAction, item) {
48
+ const getHeadingRow = (config, pageId, labelCount, changeAction, item) => {
60
49
  if (config.text === '') {
61
50
  return null;
62
51
  }
63
52
  return {
64
- pageId: pageId,
53
+ pageId,
65
54
  fieldId: "heading".concat(labelCount),
66
55
  full_path: "heading".concat(labelCount),
67
56
  key: _copReactComponents.Utils.interpolateString(config.text, item),
@@ -73,24 +62,22 @@ var getHeadingRow = function getHeadingRow(config, pageId, labelCount, changeAct
73
62
  }
74
63
  };
75
64
  };
76
- var getCollectionNameHeading = function getCollectionNameHeading(page, titleName, config, changeAction) {
77
- return {
78
- pageId: page.id,
79
- fieldId: "".concat(page.collection.name, "Title"),
80
- full_path: "".concat(page.collection.name, "Title"),
81
- key: (config === null || config === void 0 ? void 0 : config.text) || titleName.charAt(0).toUpperCase() + titleName.slice(1),
82
- type: changeAction == null ? 'heading' : 'headingWithAction',
83
- size: (config === null || config === void 0 ? void 0 : config.size) || 'm',
84
- action: changeAction === null ? null : {
85
- onAction: changeAction,
86
- label: 'Change'
87
- }
88
- };
89
- };
90
- var getActionRows = function getActionRows(page, item, onAction, labelCount) {
65
+ const getCollectionNameHeading = (page, titleName, config, changeAction) => ({
66
+ pageId: page.id,
67
+ fieldId: "".concat(page.collection.name, "Title"),
68
+ full_path: "".concat(page.collection.name, "Title"),
69
+ key: (config === null || config === void 0 ? void 0 : config.text) || titleName.charAt(0).toUpperCase() + titleName.slice(1),
70
+ type: changeAction == null ? 'heading' : 'headingWithAction',
71
+ size: (config === null || config === void 0 ? void 0 : config.size) || 'm',
72
+ action: changeAction === null ? null : {
73
+ onAction: changeAction,
74
+ label: 'Change'
75
+ }
76
+ });
77
+ const getActionRows = function (page, item, onAction, labelCount) {
91
78
  var _page$collection;
92
- var activeIds = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
93
- return (_page$collection = page.collection) === null || _page$collection === void 0 || (_page$collection = _page$collection.actions) === null || _page$collection === void 0 ? void 0 : _page$collection.map(function (action) {
79
+ let activeIds = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
80
+ return (_page$collection = page.collection) === null || _page$collection === void 0 || (_page$collection = _page$collection.actions) === null || _page$collection === void 0 ? void 0 : _page$collection.map(action => {
94
81
  if (action.type === 'remove') {
95
82
  return (0, _getCYACollectionDeleteAction.default)(page, item, onAction, labelCount, action, activeIds);
96
83
  }
@@ -98,24 +85,20 @@ var getActionRows = function getActionRows(page, item, onAction, labelCount) {
98
85
  return (0, _getCYACollectionChangeAction.default)(page, item, onAction, labelCount, action, activeIds);
99
86
  }
100
87
  return null;
101
- }).filter(function (action) {
102
- return !!action;
103
- });
88
+ }).filter(action => !!action);
104
89
  };
105
90
 
106
91
  // eslint-disable-next-line arrow-body-style
107
- var getChangeActionForPage = function getChangeActionForPage(page, onAction) {
108
- var activeIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
109
- return function () {
110
- var changeCallback = function changeCallback(changeData) {
111
- var data = changeData;
92
+ const getChangeActionForPage = function (page, onAction) {
93
+ let activeIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
94
+ return () => {
95
+ const changeCallback = changeData => {
96
+ const data = changeData;
112
97
  // Looping over the keys here as applying the changes
113
98
  // as 'let data = { ...data, ...activeIds }' seemed wasteful,
114
99
  // data could be a huge object.
115
- Object.entries(activeIds).forEach(function (entry) {
116
- var _entry = _slicedToArray(entry, 2),
117
- activeIdKey = _entry[0],
118
- activeId = _entry[1];
100
+ Object.entries(activeIds).forEach(entry => {
101
+ const [activeIdKey, activeId] = entry;
119
102
  data[activeIdKey] = activeId;
120
103
  });
121
104
  return data;
@@ -139,10 +122,10 @@ var getChangeActionForPage = function getChangeActionForPage(page, onAction) {
139
122
  * @param {Object} activeIds The active IDs that must be set for the current item to be active.
140
123
  * @returns An array of CYA rows for all child pages.
141
124
  */
142
- var getCYARowsForChildPages = function getCYARowsForChildPages(childPages, item, onAction, fnOverride, labelCount, fullPath, activeIds) {
143
- var rows = [];
144
- childPages.forEach(function (p) {
145
- var childPage = p;
125
+ const getCYARowsForChildPages = (childPages, item, onAction, fnOverride, labelCount, fullPath, activeIds) => {
126
+ let rows = [];
127
+ childPages.forEach(p => {
128
+ let childPage = p;
146
129
  // If the child page is itself a master page, then we should produce the
147
130
  // rows for it and it's children.
148
131
  if (childPage.collection.masterPage) {
@@ -153,21 +136,21 @@ var getCYARowsForChildPages = function getCYARowsForChildPages(childPages, item,
153
136
  // pages. Regular show_whens can now be used and this code should be removed
154
137
  // at some point.
155
138
  if (childPage.collection.route) {
156
- var pageWithRoute = (0, _addShowWhen.default)(childPage, childPage.collection.route);
139
+ const pageWithRoute = (0, _addShowWhen.default)(childPage, childPage.collection.route);
157
140
  childPage = pageWithRoute || childPage;
158
141
  }
159
142
  // Check that the child page was actually shown to the user. This has
160
143
  // to be done here as the show_when checks could rely upon item-level
161
144
  // data.
162
145
  if ((0, _showFormPageCYA.default)(childPage, _objectSpread(_objectSpread({}, childPage.formData), item))) {
163
- var changeAction = getChangeActionForPage(childPage, onAction, activeIds);
146
+ const changeAction = getChangeActionForPage(childPage, onAction, activeIds);
164
147
  if (childPage.collection.heading) {
165
- var headingAction = childPage.collection.heading.changeLink ? changeAction : null;
166
- var headingRow = getHeadingRow(childPage.collection.heading, childPage.id, labelCount, headingAction, item);
148
+ const headingAction = childPage.collection.heading.changeLink ? changeAction : null;
149
+ const headingRow = getHeadingRow(childPage.collection.heading, childPage.id, labelCount, headingAction, item);
167
150
  rows = rows.concat(headingRow);
168
151
  }
169
- var container = getContainerForPage(childPage, item, labelCount, fullPath);
170
- var containerRows = (0, _getCYARowsForContainer.default)(_objectSpread(_objectSpread({}, childPage), {}, {
152
+ const container = getContainerForPage(childPage, item, labelCount, fullPath);
153
+ const containerRows = (0, _getCYARowsForContainer.default)(_objectSpread(_objectSpread({}, childPage), {}, {
171
154
  formData: _objectSpread(_objectSpread({}, childPage.formData), item)
172
155
  }), container, _objectSpread(_objectSpread({}, childPage.formData), item), changeAction, fnOverride);
173
156
  rows = rows.concat(containerRows);
@@ -187,33 +170,33 @@ var getCYARowsForChildPages = function getCYARowsForChildPages(childPages, item,
187
170
  * @param {Object} activeIds The active IDs that must be set for the current item to be active.
188
171
  * @returns An array of CYA rows.
189
172
  */
190
- var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onAction, fnOverride, data) {
191
- var activeIds = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
192
- var collectionName = page.collection.name.split('.').pop();
193
- var collectionData = data[collectionName] || null;
194
- var activeId = data["".concat(collectionName, "ActiveId")];
173
+ const getCYARowsForCollectionPage = function (page, onAction, fnOverride, data) {
174
+ let activeIds = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
175
+ const collectionName = page.collection.name.split('.').pop();
176
+ let collectionData = data[collectionName] || null;
177
+ const activeId = data["".concat(collectionName, "ActiveId")];
195
178
  if (!collectionData || collectionData.length === 0) {
196
179
  return [];
197
180
  }
198
- var rows = [];
181
+ let rows = [];
199
182
  if (!page.collection.hideNameFromCYA) {
200
183
  var _page$collection$coll;
201
- var headingChangeAction = (_page$collection$coll = page.collection.collectionHeading) !== null && _page$collection$coll !== void 0 && _page$collection$coll.changeLinkPage ? getChangeActionForPage({
184
+ const headingChangeAction = (_page$collection$coll = page.collection.collectionHeading) !== null && _page$collection$coll !== void 0 && _page$collection$coll.changeLinkPage ? getChangeActionForPage({
202
185
  id: page.collection.collectionHeading.changeLinkPage
203
186
  }, onAction, activeIds) : null;
204
187
  rows.push(getCollectionNameHeading(page, collectionName, page.collection.collectionHeading, headingChangeAction));
205
188
  }
206
- var itemIndex = 0;
207
- var hideItemTitles = Array.isArray(page.collection.hideItemTitles) ? (0, _meetsAllConditions.default)(page.collection.hideItemTitles, data) : page.collection.hideItemTitles;
208
- var onlyShowActiveEntry = Array.isArray(page.collection.onlyShowActiveEntryOnCYA) ? (0, _meetsAllConditions.default)(page.collection.onlyShowActiveEntryOnCYA, data) : page.collection.onlyShowActiveEntryOnCYA;
189
+ let itemIndex = 0;
190
+ const hideItemTitles = Array.isArray(page.collection.hideItemTitles) ? (0, _meetsAllConditions.default)(page.collection.hideItemTitles, data) : page.collection.hideItemTitles;
191
+ const onlyShowActiveEntry = Array.isArray(page.collection.onlyShowActiveEntryOnCYA) ? (0, _meetsAllConditions.default)(page.collection.onlyShowActiveEntryOnCYA, data) : page.collection.onlyShowActiveEntryOnCYA;
209
192
  if (onlyShowActiveEntry) {
210
- var activeEntry = collectionData.find(function (entry, index) {
193
+ const activeEntry = collectionData.find((entry, index) => {
211
194
  itemIndex = index;
212
195
  return entry.id === activeId;
213
196
  });
214
197
  collectionData = [activeEntry];
215
198
  }
216
- collectionData.forEach(function (item) {
199
+ collectionData.forEach(item => {
217
200
  var _page$collection2;
218
201
  if (!item) {
219
202
  return; // Skip this iteration if item is undefined
@@ -222,13 +205,15 @@ var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onA
222
205
  // This helps us make sure the right entry is being affected
223
206
  // by change/remove links.
224
207
  // eslint-disable-next-line no-param-reassign
225
- activeIds = _objectSpread(_objectSpread({}, activeIds), {}, _defineProperty({}, "".concat(collectionName, "ActiveId"), item.id));
226
- var labelCount = itemIndex + 1;
227
- var actionPosition = ((_page$collection2 = page.collection) === null || _page$collection2 === void 0 ? void 0 : _page$collection2.actionPosition) || 'top';
228
- var fullPath = "".concat(page.collection.name, "[").concat(itemIndex, "]");
229
- var actionRows = getActionRows(page, item, onAction, labelCount, activeIds);
208
+ activeIds = _objectSpread(_objectSpread({}, activeIds), {}, {
209
+ ["".concat(collectionName, "ActiveId")]: item.id
210
+ });
211
+ const labelCount = itemIndex + 1;
212
+ const actionPosition = ((_page$collection2 = page.collection) === null || _page$collection2 === void 0 ? void 0 : _page$collection2.actionPosition) || 'top';
213
+ const fullPath = "".concat(page.collection.name, "[").concat(itemIndex, "]");
214
+ const actionRows = getActionRows(page, item, onAction, labelCount, activeIds);
230
215
  if (!hideItemTitles) {
231
- var titleRow = getTitleRowForItem(page, item, page.id, labelCount, fullPath);
216
+ const titleRow = getTitleRowForItem(page, item, page.id, labelCount, fullPath);
232
217
  rows = rows.concat(titleRow);
233
218
  }
234
219
  if (actionPosition === 'top') {
@@ -240,8 +225,6 @@ var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onA
240
225
  }
241
226
  itemIndex += 1;
242
227
  });
243
- return rows.filter(function (row) {
244
- return !!row;
245
- });
228
+ return rows.filter(row => !!row);
246
229
  };
247
230
  var _default = exports.default = getCYARowsForCollectionPage;