@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
@@ -5,13 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _getCollectionPageActiveIndex = _interopRequireDefault(require("./getCollectionPageActiveIndex"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
10
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
9
  /**
16
10
  * Duplicates the currently active entry in a named collection's data.
17
11
  * Once duplicated, the new entry is set as the active entry.
@@ -19,20 +13,19 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
19
13
  * @param {object} formData A page's form data containing the collection's data.
20
14
  * @return true if the entry ws successfully duplicated, false if not.
21
15
  */
22
- var duplicateCollectionPageActiveEntry = function duplicateCollectionPageActiveEntry(collectionName, formData) {
23
- var _formData$collectionN;
24
- var currentIndex = (0, _getCollectionPageActiveIndex.default)(collectionName, formData);
25
- var currentEntry = (_formData$collectionN = formData[collectionName]) === null || _formData$collectionN === void 0 ? void 0 : _formData$collectionN[currentIndex];
16
+ const duplicateCollectionPageActiveEntry = (collectionName, formData) => {
17
+ const currentIndex = (0, _getCollectionPageActiveIndex.default)(collectionName, formData);
18
+ const currentEntry = formData[collectionName]?.[currentIndex];
26
19
  if (!currentEntry) {
27
20
  return false;
28
21
  }
29
- var newEntry = _objectSpread(_objectSpread({}, currentEntry), {}, {
22
+ const newEntry = {
23
+ ...currentEntry,
30
24
  id: Date.now().toString()
31
- });
25
+ };
32
26
  formData[collectionName].push(newEntry);
33
27
  // eslint-disable-next-line no-param-reassign
34
- formData["".concat(collectionName, "ActiveId")] = newEntry.id;
28
+ formData[`${collectionName}ActiveId`] = newEntry.id;
35
29
  return true;
36
30
  };
37
- var _default = duplicateCollectionPageActiveEntry;
38
- exports.default = _default;
31
+ var _default = exports.default = duplicateCollectionPageActiveEntry;
@@ -1,39 +1,38 @@
1
1
  "use strict";
2
2
 
3
3
  var _duplicateCollectionPageActiveEntry = _interopRequireDefault(require("./duplicateCollectionPageActiveEntry"));
4
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5
- 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); }
6
- 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; }
7
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
- 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); }
9
- describe('utils.CollectionPage.duplicateCollectionPageActiveEntry', function () {
10
- var COLLECTION_NAME = 'testCollection';
11
- var OBJ = {
4
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
5
+ describe('utils.CollectionPage.duplicateCollectionPageActiveEntry', () => {
6
+ const COLLECTION_NAME = 'testCollection';
7
+ const OBJ = {
12
8
  id: '1',
13
9
  value: 'value'
14
10
  };
15
- it('should duplicate the active entry if one exists', function () {
16
- var _FORM_DATA;
17
- var FORM_DATA = (_FORM_DATA = {}, _defineProperty(_FORM_DATA, "".concat(COLLECTION_NAME, "ActiveId"), '1'), _defineProperty(_FORM_DATA, COLLECTION_NAME, [OBJ]), _FORM_DATA);
11
+ it('should duplicate the active entry if one exists', () => {
12
+ const FORM_DATA = {
13
+ [`${COLLECTION_NAME}ActiveId`]: '1',
14
+ [COLLECTION_NAME]: [OBJ]
15
+ };
18
16
  (0, _duplicateCollectionPageActiveEntry.default)(COLLECTION_NAME, FORM_DATA);
19
17
  expect(FORM_DATA[COLLECTION_NAME].length).toEqual(2);
20
18
  expect(FORM_DATA[COLLECTION_NAME][1].value).toEqual(FORM_DATA[COLLECTION_NAME][0].value);
21
19
  expect(FORM_DATA[COLLECTION_NAME][1].id).toBeTruthy();
22
20
  expect(FORM_DATA[COLLECTION_NAME][1].id === '1').toBeFalsy();
23
- expect(FORM_DATA["".concat(COLLECTION_NAME, "ActiveId")]).toBeTruthy();
24
- expect(FORM_DATA["".concat(COLLECTION_NAME, "ActiveId")] === '1').toBeFalsy();
21
+ expect(FORM_DATA[`${COLLECTION_NAME}ActiveId`]).toBeTruthy();
22
+ expect(FORM_DATA[`${COLLECTION_NAME}ActiveId`] === '1').toBeFalsy();
25
23
  });
26
- it('should do nothing if there is no active entry', function () {
27
- var _FORM_DATA2;
28
- var FORM_DATA = (_FORM_DATA2 = {}, _defineProperty(_FORM_DATA2, "".concat(COLLECTION_NAME, "ActiveId"), '2'), _defineProperty(_FORM_DATA2, COLLECTION_NAME, [OBJ]), _FORM_DATA2);
24
+ it('should do nothing if there is no active entry', () => {
25
+ const FORM_DATA = {
26
+ [`${COLLECTION_NAME}ActiveId`]: '2',
27
+ [COLLECTION_NAME]: [OBJ]
28
+ };
29
29
  (0, _duplicateCollectionPageActiveEntry.default)(COLLECTION_NAME, FORM_DATA);
30
30
  expect(FORM_DATA[COLLECTION_NAME].length).toEqual(1);
31
31
  expect(FORM_DATA[COLLECTION_NAME][0]).toEqual(OBJ);
32
- expect(FORM_DATA["".concat(COLLECTION_NAME, "ActiveId")]).toEqual('2'); // Shouldn't have changed.
32
+ expect(FORM_DATA[`${COLLECTION_NAME}ActiveId`]).toEqual('2'); // Shouldn't have changed.
33
33
  });
34
-
35
- it('should do nothing if the collection does not exist', function () {
36
- var FORM_DATA = {};
34
+ it('should do nothing if the collection does not exist', () => {
35
+ const FORM_DATA = {};
37
36
  (0, _duplicateCollectionPageActiveEntry.default)(COLLECTION_NAME, FORM_DATA);
38
37
  expect(FORM_DATA).toEqual({});
39
38
  });
@@ -10,19 +10,15 @@ exports.default = void 0;
10
10
  * @param {object} formData A page's form data containing the collection's data.
11
11
  * @returns The index of the active entry, or null if there isn't one.
12
12
  */
13
- var getCollectionPageActiveIndex = function getCollectionPageActiveIndex(collectionName, formData) {
14
- var _formData$collectionN;
13
+ const getCollectionPageActiveIndex = (collectionName, formData) => {
15
14
  if (!collectionName) {
16
15
  return null;
17
16
  }
18
- var id = formData === null || formData === void 0 ? void 0 : formData["".concat(collectionName, "ActiveId")];
17
+ const id = formData?.[`${collectionName}ActiveId`];
19
18
  if (!id) {
20
19
  return null;
21
20
  }
22
- var activeIndex = (_formData$collectionN = formData[collectionName]) === null || _formData$collectionN === void 0 ? void 0 : _formData$collectionN.findIndex(function (item) {
23
- return item.id === id;
24
- });
21
+ const activeIndex = formData[collectionName]?.findIndex(item => item.id === id);
25
22
  return activeIndex > -1 ? activeIndex : null;
26
23
  };
27
- var _default = getCollectionPageActiveIndex;
28
- exports.default = _default;
24
+ var _default = exports.default = getCollectionPageActiveIndex;
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _getCollectionPageActiveIndex = _interopRequireDefault(require("./getCollectionPageActiveIndex"));
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.CollectionPage.getCollectionPageActiveIndex', function () {
8
- it('should return the index of the active item in the collection, if one exists', function () {
9
- var COLLECTION_NAME = 'test';
10
- var ACTIVE_ID = '002';
11
- var FORM_DATA = {
7
+ describe('utils.CollectionPage.getCollectionPageActiveIndex', () => {
8
+ it('should return the index of the active item in the collection, if one exists', () => {
9
+ const COLLECTION_NAME = 'test';
10
+ const ACTIVE_ID = '002';
11
+ const FORM_DATA = {
12
12
  testActiveId: ACTIVE_ID,
13
13
  test: [{
14
14
  id: '001'
@@ -16,7 +16,7 @@ describe('utils.CollectionPage.getCollectionPageActiveIndex', function () {
16
16
  id: '002'
17
17
  }]
18
18
  };
19
- var PAGE = {
19
+ const PAGE = {
20
20
  collection: {
21
21
  name: COLLECTION_NAME
22
22
  },
@@ -24,16 +24,16 @@ describe('utils.CollectionPage.getCollectionPageActiveIndex', function () {
24
24
  };
25
25
  expect((0, _getCollectionPageActiveIndex.default)(PAGE.collection.name, PAGE.formData)).toEqual(1);
26
26
  });
27
- it('should return null if no active item can be found in the collection', function () {
28
- var COLLECTION_NAME = 'test';
29
- var ACTIVE_ID = '002';
30
- var FORM_DATA = {
27
+ it('should return null if no active item can be found in the collection', () => {
28
+ const COLLECTION_NAME = 'test';
29
+ const ACTIVE_ID = '002';
30
+ const FORM_DATA = {
31
31
  testActiveId: ACTIVE_ID,
32
32
  test: [{
33
33
  id: '001'
34
34
  }]
35
35
  };
36
- var PAGE = {
36
+ const PAGE = {
37
37
  collection: {
38
38
  name: COLLECTION_NAME
39
39
  },
@@ -41,9 +41,9 @@ describe('utils.CollectionPage.getCollectionPageActiveIndex', function () {
41
41
  };
42
42
  expect((0, _getCollectionPageActiveIndex.default)(PAGE.collection.name, PAGE.formData)).toEqual(null);
43
43
  });
44
- it('should return null if formData is null', function () {
45
- var COLLECTION_NAME = 'test';
46
- var PAGE = {
44
+ it('should return null if formData is null', () => {
45
+ const COLLECTION_NAME = 'test';
46
+ const PAGE = {
47
47
  collection: {
48
48
  name: COLLECTION_NAME
49
49
  }
@@ -7,13 +7,12 @@ exports.default = void 0;
7
7
  var _duplicateCollectionPageActiveEntry = _interopRequireDefault(require("./duplicateCollectionPageActiveEntry"));
8
8
  var _getCollectionPageActiveIndex = _interopRequireDefault(require("./getCollectionPageActiveIndex"));
9
9
  var _mergeCollectionPages = _interopRequireDefault(require("./mergeCollectionPages"));
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  // Local imports
12
12
 
13
- var CollectionPage = {
13
+ const CollectionPage = {
14
14
  duplicateActiveEntry: _duplicateCollectionPageActiveEntry.default,
15
15
  getActiveIndex: _getCollectionPageActiveIndex.default,
16
16
  mergePages: _mergeCollectionPages.default
17
17
  };
18
- var _default = CollectionPage;
19
- exports.default = _default;
18
+ var _default = exports.default = CollectionPage;
@@ -4,28 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- 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); }
8
- 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; }
9
- 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; }
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
7
  /* eslint-disable no-param-reassign */
14
8
 
15
- var createMasterPage = function createMasterPage(page) {
16
- return {
17
- id: page.id,
18
- name: page.name,
19
- collection: _objectSpread({
20
- masterPage: true
21
- }, page.collection),
22
- formData: _objectSpread({}, page.formData),
23
- collectionPages: [page]
9
+ const createMasterPage = page => ({
10
+ id: page.id,
11
+ name: page.name,
12
+ collection: {
13
+ masterPage: true,
14
+ ...page.collection
15
+ },
16
+ formData: {
17
+ ...page.formData
18
+ },
19
+ collectionPages: [page]
20
+ });
21
+ const mergeIntoMasterPage = (page, masterPage) => {
22
+ masterPage.collection = {
23
+ ...masterPage.collection,
24
+ ...page.collection
25
+ };
26
+ masterPage.formData = {
27
+ ...masterPage.formData,
28
+ ...page.formData
24
29
  };
25
- };
26
- var mergeIntoMasterPage = function mergeIntoMasterPage(page, masterPage) {
27
- masterPage.collection = _objectSpread(_objectSpread({}, masterPage.collection), page.collection);
28
- masterPage.formData = _objectSpread(_objectSpread({}, masterPage.formData), page.formData);
29
30
  masterPage.collectionPages = [].concat(masterPage.collectionPages, [page]);
30
31
  };
31
32
 
@@ -40,11 +41,10 @@ var mergeIntoMasterPage = function mergeIntoMasterPage(page, masterPage) {
40
41
  * @param { array } pages Array of pages in the form.
41
42
  * @returns An array of the same pages, with a master page for each collection.
42
43
  */
43
- var mergeCollectionPages = function mergeCollectionPages(pages) {
44
- var masterPages = {};
45
- return pages.map(function (page) {
46
- var _page$collection;
47
- if (page !== null && page !== void 0 && (_page$collection = page.collection) !== null && _page$collection !== void 0 && _page$collection.name) {
44
+ const mergeCollectionPages = pages => {
45
+ const masterPages = {};
46
+ return pages.map(page => {
47
+ if (page?.collection?.name) {
48
48
  if (!masterPages[page.collection.name]) {
49
49
  // If no master page exists for this collection.name, then
50
50
  // we kick one off using this page as a template.
@@ -58,9 +58,6 @@ var mergeCollectionPages = function mergeCollectionPages(pages) {
58
58
  return null;
59
59
  }
60
60
  return page;
61
- }).filter(function (page) {
62
- return !!page;
63
- });
61
+ }).filter(page => !!page);
64
62
  };
65
- var _default = mergeCollectionPages;
66
- exports.default = _default;
63
+ var _default = exports.default = mergeCollectionPages;
@@ -1,30 +1,30 @@
1
1
  "use strict";
2
2
 
3
3
  var _mergeCollectionPages = _interopRequireDefault(require("./mergeCollectionPages"));
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.CollectionPage.mergeCollectionPages', function () {
8
- var TEXT_COMP = {
7
+ describe('utils.CollectionPage.mergeCollectionPages', () => {
8
+ const TEXT_COMP = {
9
9
  id: 'testText',
10
10
  fieldId: 'testText',
11
11
  type: 'text'
12
12
  };
13
- var DATE_COMP = {
13
+ const DATE_COMP = {
14
14
  id: 'testDate',
15
15
  fieldId: 'testDate',
16
16
  type: 'date'
17
17
  };
18
- it('should return the same array if no pages belong to collections', function () {
19
- var PAGES = [{
18
+ it('should return the same array if no pages belong to collections', () => {
19
+ const PAGES = [{
20
20
  id: 'page1'
21
21
  }, {
22
22
  id: 'page2'
23
23
  }];
24
24
  expect((0, _mergeCollectionPages.default)(PAGES)).toEqual(PAGES);
25
25
  });
26
- it('should merge pages from the same collection into a single page', function () {
27
- var PAGES = [{
26
+ it('should merge pages from the same collection into a single page', () => {
27
+ const PAGES = [{
28
28
  id: 'page1',
29
29
  collection: {
30
30
  name: 'collection'
@@ -37,7 +37,7 @@ describe('utils.CollectionPage.mergeCollectionPages', function () {
37
37
  },
38
38
  components: [DATE_COMP]
39
39
  }];
40
- var RESULT = (0, _mergeCollectionPages.default)(PAGES);
40
+ const RESULT = (0, _mergeCollectionPages.default)(PAGES);
41
41
  expect(RESULT.length).toEqual(1);
42
42
  expect(RESULT[0]).toMatchObject({
43
43
  id: 'page1',
@@ -49,8 +49,8 @@ describe('utils.CollectionPage.mergeCollectionPages', function () {
49
49
  collectionPages: PAGES
50
50
  });
51
51
  });
52
- it('should leave non-collection pages unaffected', function () {
53
- var PAGES = [{
52
+ it('should leave non-collection pages unaffected', () => {
53
+ const PAGES = [{
54
54
  id: 'page1',
55
55
  collection: {
56
56
  name: 'collection'
@@ -65,7 +65,7 @@ describe('utils.CollectionPage.mergeCollectionPages', function () {
65
65
  }, {
66
66
  id: 'page3'
67
67
  }];
68
- var RESULT = (0, _mergeCollectionPages.default)(PAGES);
68
+ const RESULT = (0, _mergeCollectionPages.default)(PAGES);
69
69
  expect(RESULT.length).toEqual(2);
70
70
  expect(RESULT[0]).toEqual({
71
71
  id: 'page1',
@@ -80,8 +80,8 @@ describe('utils.CollectionPage.mergeCollectionPages', function () {
80
80
  id: 'page3'
81
81
  });
82
82
  });
83
- it('should handle multiple collections', function () {
84
- var PAGES = [{
83
+ it('should handle multiple collections', () => {
84
+ const PAGES = [{
85
85
  id: 'page1',
86
86
  collection: {
87
87
  name: 'collection1'
@@ -106,7 +106,7 @@ describe('utils.CollectionPage.mergeCollectionPages', function () {
106
106
  },
107
107
  components: []
108
108
  }];
109
- var RESULT = (0, _mergeCollectionPages.default)(PAGES);
109
+ const RESULT = (0, _mergeCollectionPages.default)(PAGES);
110
110
  expect(RESULT.length).toEqual(2);
111
111
  expect(RESULT[0]).toEqual({
112
112
  id: 'page1',
@@ -4,12 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- 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); }
8
- 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; }
9
- 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; }
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
7
  /**
14
8
  * Adds a show_when to a component.
15
9
  * If the component has no show_when, then an array is created
@@ -21,14 +15,16 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
21
15
  * @returns The component with the new show_when added.
22
16
  * null if component or condition are invalid.
23
17
  */
24
- var addShowWhen = function addShowWhen(component, condition) {
18
+ const addShowWhen = (component, condition) => {
25
19
  if (!component) {
26
20
  return null;
27
21
  }
28
22
  if (!condition) {
29
23
  return component;
30
24
  }
31
- var result = _objectSpread({}, component);
25
+ const result = {
26
+ ...component
27
+ };
32
28
  if (result.show_when) {
33
29
  if (Array.isArray(condition)) {
34
30
  result.show_when = Array.isArray(result.show_when) ? [].concat(condition, result.show_when) : [].concat(condition, [result.show_when]);
@@ -40,5 +36,4 @@ var addShowWhen = function addShowWhen(component, condition) {
40
36
  }
41
37
  return result;
42
38
  };
43
- var _default = addShowWhen;
44
- exports.default = _default;
39
+ var _default = exports.default = addShowWhen;
@@ -1,53 +1,53 @@
1
1
  "use strict";
2
2
 
3
3
  var _addShowWhen = _interopRequireDefault(require("./addShowWhen"));
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.addShowWhen', function () {
8
- var NEW_SHOW_WHEN = {
7
+ describe('utils.Component.addShowWhen', () => {
8
+ const NEW_SHOW_WHEN = {
9
9
  field: 'field',
10
10
  op: '=',
11
11
  value: 'value'
12
12
  };
13
- it('should return null when component is undefined', function () {
14
- var result = (0, _addShowWhen.default)(undefined, {});
13
+ it('should return null when component is undefined', () => {
14
+ const result = (0, _addShowWhen.default)(undefined, {});
15
15
  expect(result).toEqual(null);
16
16
  });
17
- it('should return null when component is null', function () {
18
- var result = (0, _addShowWhen.default)(null, {});
17
+ it('should return null when component is null', () => {
18
+ const result = (0, _addShowWhen.default)(null, {});
19
19
  expect(result).toEqual(null);
20
20
  });
21
- it('should return component when condition is undefined', function () {
22
- var COMPONENT = {
21
+ it('should return component when condition is undefined', () => {
22
+ const COMPONENT = {
23
23
  alpha: 'bravo'
24
24
  };
25
- var result = (0, _addShowWhen.default)(COMPONENT, undefined);
25
+ const result = (0, _addShowWhen.default)(COMPONENT, undefined);
26
26
  expect(result).toEqual({
27
27
  alpha: 'bravo'
28
28
  });
29
29
  });
30
- it('should return component when condition is null', function () {
31
- var COMPONENT = {
30
+ it('should return component when condition is null', () => {
31
+ const COMPONENT = {
32
32
  alpha: 'bravo'
33
33
  };
34
- var result = (0, _addShowWhen.default)(COMPONENT, null);
34
+ const result = (0, _addShowWhen.default)(COMPONENT, null);
35
35
  expect(result).toEqual({
36
36
  alpha: 'bravo'
37
37
  });
38
38
  });
39
- it('should add the show_when to a component with no existing show_whens', function () {
40
- var COMPONENT = {
39
+ it('should add the show_when to a component with no existing show_whens', () => {
40
+ const COMPONENT = {
41
41
  alpha: 'bravo'
42
42
  };
43
- var result = (0, _addShowWhen.default)(COMPONENT, NEW_SHOW_WHEN);
43
+ const result = (0, _addShowWhen.default)(COMPONENT, NEW_SHOW_WHEN);
44
44
  expect(result).toEqual({
45
45
  alpha: 'bravo',
46
46
  show_when: NEW_SHOW_WHEN
47
47
  });
48
48
  });
49
- it('should add the array type show_when to a component with no existing show_whens', function () {
50
- var NEW_ARRAY_SHOW_WHEN = [{
49
+ it('should add the array type show_when to a component with no existing show_whens', () => {
50
+ const NEW_ARRAY_SHOW_WHEN = [{
51
51
  field: 'abc',
52
52
  op: '=',
53
53
  value: 'bcd'
@@ -56,17 +56,17 @@ describe('utils.Component.addShowWhen', function () {
56
56
  op: '=',
57
57
  value: 'efg'
58
58
  }];
59
- var COMPONENT = {
59
+ const COMPONENT = {
60
60
  alpha: 'bravo'
61
61
  };
62
- var result = (0, _addShowWhen.default)(COMPONENT, NEW_ARRAY_SHOW_WHEN);
62
+ const result = (0, _addShowWhen.default)(COMPONENT, NEW_ARRAY_SHOW_WHEN);
63
63
  expect(result).toEqual({
64
64
  alpha: 'bravo',
65
65
  show_when: NEW_ARRAY_SHOW_WHEN
66
66
  });
67
67
  });
68
- it('should add the show_when to a component with a single show_when', function () {
69
- var COMPONENT = {
68
+ it('should add the show_when to a component with a single show_when', () => {
69
+ const COMPONENT = {
70
70
  alpha: 'bravo',
71
71
  show_when: {
72
72
  field: 'abc',
@@ -74,7 +74,7 @@ describe('utils.Component.addShowWhen', function () {
74
74
  value: 'bcd'
75
75
  }
76
76
  };
77
- var result = (0, _addShowWhen.default)(COMPONENT, NEW_SHOW_WHEN);
77
+ const result = (0, _addShowWhen.default)(COMPONENT, NEW_SHOW_WHEN);
78
78
  expect(result).toEqual({
79
79
  alpha: 'bravo',
80
80
  show_when: [{
@@ -84,8 +84,8 @@ describe('utils.Component.addShowWhen', function () {
84
84
  }, NEW_SHOW_WHEN]
85
85
  });
86
86
  });
87
- it('should add the show_when to a component with an array of show_whens', function () {
88
- var COMPONENT = {
87
+ it('should add the show_when to a component with an array of show_whens', () => {
88
+ const COMPONENT = {
89
89
  alpha: 'bravo',
90
90
  show_when: [{
91
91
  field: 'abc',
@@ -97,7 +97,7 @@ describe('utils.Component.addShowWhen', function () {
97
97
  value: 'efg'
98
98
  }]
99
99
  };
100
- var result = (0, _addShowWhen.default)(COMPONENT, NEW_SHOW_WHEN);
100
+ const result = (0, _addShowWhen.default)(COMPONENT, NEW_SHOW_WHEN);
101
101
  expect(result).toEqual({
102
102
  alpha: 'bravo',
103
103
  show_when: [{
@@ -111,11 +111,11 @@ describe('utils.Component.addShowWhen', function () {
111
111
  }, NEW_SHOW_WHEN]
112
112
  });
113
113
  });
114
- it('should add the or type show_when to a component with no existing show_whens in an object not an array', function () {
115
- var COMPONENT = {
114
+ it('should add the or type show_when to a component with no existing show_whens in an object not an array', () => {
115
+ const COMPONENT = {
116
116
  alpha: 'bravo'
117
117
  };
118
- var SHOW_WHEN_OR = {
118
+ const SHOW_WHEN_OR = {
119
119
  type: 'or',
120
120
  condition: [{
121
121
  field: 'field1',
@@ -127,14 +127,14 @@ describe('utils.Component.addShowWhen', function () {
127
127
  value: 2
128
128
  }]
129
129
  };
130
- var result = (0, _addShowWhen.default)(COMPONENT, SHOW_WHEN_OR);
130
+ const result = (0, _addShowWhen.default)(COMPONENT, SHOW_WHEN_OR);
131
131
  expect(result).toEqual({
132
132
  alpha: 'bravo',
133
133
  show_when: SHOW_WHEN_OR
134
134
  });
135
135
  });
136
- it('should add an array of show_whens to a component with an array of show_whens', function () {
137
- var NEW_ARRAY_SHOW_WHEN = [{
136
+ it('should add an array of show_whens to a component with an array of show_whens', () => {
137
+ const NEW_ARRAY_SHOW_WHEN = [{
138
138
  field: 'hij',
139
139
  op: '=',
140
140
  value: 'klm'
@@ -143,7 +143,7 @@ describe('utils.Component.addShowWhen', function () {
143
143
  op: '=',
144
144
  value: 'qrs'
145
145
  }];
146
- var COMPONENT = {
146
+ const COMPONENT = {
147
147
  alpha: 'bravo',
148
148
  show_when: [{
149
149
  field: 'abc',
@@ -155,7 +155,7 @@ describe('utils.Component.addShowWhen', function () {
155
155
  value: 'efg'
156
156
  }]
157
157
  };
158
- var result = (0, _addShowWhen.default)(COMPONENT, NEW_ARRAY_SHOW_WHEN);
158
+ const result = (0, _addShowWhen.default)(COMPONENT, NEW_ARRAY_SHOW_WHEN);
159
159
  expect(result).toEqual({
160
160
  alpha: 'bravo',
161
161
  show_when: [{
@@ -177,8 +177,8 @@ describe('utils.Component.addShowWhen', function () {
177
177
  }]
178
178
  });
179
179
  });
180
- it('should add an array of show_whens to a component with a single show_when', function () {
181
- var NEW_ARRAY_SHOW_WHEN = [{
180
+ it('should add an array of show_whens to a component with a single show_when', () => {
181
+ const NEW_ARRAY_SHOW_WHEN = [{
182
182
  field: 'hij',
183
183
  op: '=',
184
184
  value: 'klm'
@@ -187,7 +187,7 @@ describe('utils.Component.addShowWhen', function () {
187
187
  op: '=',
188
188
  value: 'qrs'
189
189
  }];
190
- var COMPONENT = {
190
+ const COMPONENT = {
191
191
  alpha: 'bravo',
192
192
  show_when: {
193
193
  field: 'abc',
@@ -195,7 +195,7 @@ describe('utils.Component.addShowWhen', function () {
195
195
  value: 'bcd'
196
196
  }
197
197
  };
198
- var result = (0, _addShowWhen.default)(COMPONENT, NEW_ARRAY_SHOW_WHEN);
198
+ const result = (0, _addShowWhen.default)(COMPONENT, NEW_ARRAY_SHOW_WHEN);
199
199
  expect(result).toEqual({
200
200
  alpha: 'bravo',
201
201
  show_when: [{