@hmcts/opal-frontend-common 0.0.108 → 0.0.110

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 (417) hide show
  1. package/fesm2022/hmcts-opal-frontend-common-access-denied.component-DuQgLlU6.mjs +57 -0
  2. package/fesm2022/hmcts-opal-frontend-common-account-created.component-DtlFlzU9.mjs +47 -0
  3. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-account-summary-base.mjs +73 -81
  4. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-creditor-details-base.mjs +71 -92
  5. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base-interfaces.mjs +0 -4
  6. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base.mjs +133 -233
  7. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-array-base-interfaces.mjs +0 -4
  8. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-array-base.mjs +123 -251
  9. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-array-parent-base.mjs +24 -43
  10. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base-interfaces.mjs +0 -4
  11. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base.mjs +66 -94
  12. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-base-interfaces.mjs +0 -4
  13. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-base.mjs +340 -616
  14. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-parent-base.mjs +25 -61
  15. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-nested-form-base.mjs +88 -142
  16. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-report-instances-table-base.mjs +48 -29
  17. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-report-summary-list-base-constants.mjs +14 -19
  18. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-report-summary-list-base-interfaces.mjs +0 -4
  19. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-report-summary-list-base-types.mjs +0 -4
  20. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-report-summary-list-base.mjs +144 -273
  21. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table-interfaces.mjs +0 -4
  22. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table-pagination.mjs +104 -129
  23. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table-types.mjs +0 -4
  24. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table.mjs +123 -204
  25. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-tab-data.mjs +35 -121
  26. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-table-filter-interfaces.mjs +0 -4
  27. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-table-filter-types.mjs +0 -4
  28. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-table-filter.mjs +111 -183
  29. package/fesm2022/hmcts-opal-frontend-common-components-abstract-interfaces.mjs +0 -4
  30. package/fesm2022/hmcts-opal-frontend-common-components-alphagov-alphagov-accessible-autocomplete-interfaces.mjs +0 -4
  31. package/fesm2022/hmcts-opal-frontend-common-components-alphagov-alphagov-accessible-autocomplete.mjs +278 -263
  32. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-accessible-monetary.mjs +66 -53
  33. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-account-information-custom-account-information-item-custom-account-information-item-label.mjs +44 -21
  34. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-account-information-custom-account-information-item-custom-account-information-item-value.mjs +44 -21
  35. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-account-information-custom-account-information-item.mjs +54 -27
  36. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-account-information.mjs +38 -17
  37. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-action-links.mjs +70 -37
  38. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-deferred-live-region-announcement.mjs +109 -119
  39. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-horizontal-scroll-pane.mjs +38 -17
  40. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-page-header.mjs +40 -17
  41. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-scrollable-panes-custom-scrollable-panes-inner-pane.mjs +66 -27
  42. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-scrollable-panes.mjs +44 -21
  43. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar-custom-summary-metric-bar-item-custom-summary-metric-bar-item-label.mjs +54 -27
  44. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar-custom-summary-metric-bar-item-custom-summary-metric-bar-item-value.mjs +54 -27
  45. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar-custom-summary-metric-bar-item.mjs +67 -42
  46. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar.mjs +40 -17
  47. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-vertical-scroll-pane-custom-vertical-scroll-pane-inner-pane.mjs +66 -27
  48. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-vertical-scroll-pane-custom-vertical-scroll-pane-outer-pane.mjs +42 -21
  49. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-vertical-scroll-pane.mjs +36 -17
  50. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-accordion.mjs +125 -119
  51. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-back-link.mjs +46 -30
  52. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-button.mjs +72 -39
  53. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-cancel-link.mjs +54 -34
  54. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-checkboxes-interfaces.mjs +0 -4
  55. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-checkboxes.mjs +303 -134
  56. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-date-input-interfaces.mjs +0 -4
  57. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-date-input.mjs +163 -79
  58. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-details.mjs +45 -21
  59. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-error-summary.mjs +49 -33
  60. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-footer-interfaces.mjs +0 -4
  61. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-footer.mjs +42 -20
  62. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-header-interfaces.mjs +0 -4
  63. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-header.mjs +103 -41
  64. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-heading-with-caption-types.mjs +0 -4
  65. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-heading-with-caption.mjs +90 -39
  66. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-inset-text.mjs +60 -26
  67. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-list-govuk-list-link.mjs +53 -30
  68. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-list.mjs +36 -17
  69. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-notification-banner.mjs +75 -44
  70. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-pagination.mjs +80 -85
  71. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-panel.mjs +53 -25
  72. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-radio-interfaces.mjs +0 -4
  73. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-radio.mjs +397 -267
  74. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-select-interfaces.mjs +0 -4
  75. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-select.mjs +164 -80
  76. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-summary-card-list.mjs +153 -85
  77. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-summary-list.mjs +246 -121
  78. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-table.mjs +224 -90
  79. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.mjs +99 -76
  80. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-panel.mjs +78 -51
  81. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs.mjs +79 -72
  82. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tag.mjs +55 -25
  83. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-task-list.mjs +112 -46
  84. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-text-area.mjs +185 -104
  85. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-text-input-prefix-suffix.mjs +165 -95
  86. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-text-input.mjs +151 -81
  87. package/fesm2022/hmcts-opal-frontend-common-components-govuk-helpers.mjs +5 -16
  88. package/fesm2022/hmcts-opal-frontend-common-components-hod-hod-loading-spinner.mjs +65 -32
  89. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-alert.mjs +396 -243
  90. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-badge.mjs +55 -25
  91. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-button-menu-moj-button-menu-item.mjs +53 -28
  92. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-button-menu.mjs +92 -60
  93. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-date-picker.mjs +216 -165
  94. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-header.mjs +44 -21
  95. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-option-moj-filter-panel-option-form-group-item.mjs +64 -42
  96. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-option-moj-filter-panel-option-form-group-keyword.mjs +68 -47
  97. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-option.mjs +52 -33
  98. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-selected-moj-filter-panel-selected-tag.mjs +61 -40
  99. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-selected.mjs +63 -42
  100. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel.mjs +38 -17
  101. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter.mjs +56 -34
  102. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-header-interfaces.mjs +0 -4
  103. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-header.mjs +100 -41
  104. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-inset-text.mjs +62 -26
  105. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-notification-badge.mjs +46 -21
  106. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-page-header.mjs +47 -21
  107. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-pagination.mjs +119 -164
  108. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-primary-navigation.mjs +225 -172
  109. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-sortable-table.mjs +355 -188
  110. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-sub-navigation.mjs +152 -96
  111. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-ticket-panel.mjs +61 -29
  112. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-timeline.mjs +74 -26
  113. package/fesm2022/hmcts-opal-frontend-common-concurrency-failure.component-BqsP0gj2.mjs +41 -0
  114. package/fesm2022/hmcts-opal-frontend-common-constants.mjs +7 -13
  115. package/fesm2022/hmcts-opal-frontend-common-directives-capitalisation.mjs +55 -43
  116. package/fesm2022/hmcts-opal-frontend-common-directives-govuk-button.mjs +86 -60
  117. package/fesm2022/hmcts-opal-frontend-common-directives-moj-multi-select.mjs +184 -223
  118. package/fesm2022/hmcts-opal-frontend-common-directives-trim-leading-trailing-whitespace.mjs +56 -40
  119. package/fesm2022/hmcts-opal-frontend-common-guards-account.mjs +17 -37
  120. package/fesm2022/hmcts-opal-frontend-common-guards-auth.mjs +30 -41
  121. package/fesm2022/hmcts-opal-frontend-common-guards-business-unit-route-permissions.mjs +31 -90
  122. package/fesm2022/hmcts-opal-frontend-common-guards-can-deactivate-interfaces.mjs +0 -4
  123. package/fesm2022/hmcts-opal-frontend-common-guards-can-deactivate-types.mjs +0 -4
  124. package/fesm2022/hmcts-opal-frontend-common-guards-can-deactivate.mjs +3 -9
  125. package/fesm2022/hmcts-opal-frontend-common-guards-feature-flag.mjs +29 -64
  126. package/fesm2022/hmcts-opal-frontend-common-guards-has-flow-state.mjs +13 -20
  127. package/fesm2022/hmcts-opal-frontend-common-guards-has-url-state-match.mjs +19 -48
  128. package/fesm2022/hmcts-opal-frontend-common-guards-helpers.mjs +21 -54
  129. package/fesm2022/hmcts-opal-frontend-common-guards-route-permissions.mjs +20 -30
  130. package/fesm2022/hmcts-opal-frontend-common-guards-signed-in.mjs +13 -24
  131. package/fesm2022/hmcts-opal-frontend-common-guards-types.mjs +0 -4
  132. package/fesm2022/hmcts-opal-frontend-common-interceptors-content-digest.mjs +59 -107
  133. package/fesm2022/hmcts-opal-frontend-common-interceptors-http-error-constants.mjs +11 -17
  134. package/fesm2022/hmcts-opal-frontend-common-interceptors-http-error-interfaces.mjs +0 -4
  135. package/fesm2022/hmcts-opal-frontend-common-interceptors-http-error.mjs +74 -148
  136. package/fesm2022/hmcts-opal-frontend-common-interceptors-http-retry-constants.mjs +18 -13
  137. package/fesm2022/hmcts-opal-frontend-common-interceptors-http-retry-interfaces.mjs +0 -4
  138. package/fesm2022/hmcts-opal-frontend-common-interceptors-http-retry.mjs +65 -134
  139. package/fesm2022/hmcts-opal-frontend-common-internal-server-error.component-8EP_PgKk.mjs +55 -0
  140. package/fesm2022/hmcts-opal-frontend-common-pages-access-denied.component-DuQgLlU6.mjs +57 -0
  141. package/fesm2022/hmcts-opal-frontend-common-pages-account-created.component-DtlFlzU9.mjs +47 -0
  142. package/fesm2022/hmcts-opal-frontend-common-pages-concurrency-failure.component-BqsP0gj2.mjs +41 -0
  143. package/fesm2022/hmcts-opal-frontend-common-pages-dashboard-page-interfaces.mjs +0 -4
  144. package/fesm2022/hmcts-opal-frontend-common-pages-dashboard-page.mjs +112 -62
  145. package/fesm2022/hmcts-opal-frontend-common-pages-internal-server-error.component-8EP_PgKk.mjs +55 -0
  146. package/fesm2022/hmcts-opal-frontend-common-pages-permission-denied.component-B3EkD8uw.mjs +41 -0
  147. package/fesm2022/hmcts-opal-frontend-common-pages-routing-constants.mjs +22 -27
  148. package/fesm2022/hmcts-opal-frontend-common-pages-routing-interfaces.mjs +0 -4
  149. package/fesm2022/hmcts-opal-frontend-common-pages-sign-in-stub.component-CT2Bh7gD.mjs +127 -0
  150. package/fesm2022/hmcts-opal-frontend-common-pages-sign-in.component-BxpouMug.mjs +55 -0
  151. package/fesm2022/hmcts-opal-frontend-common-pages.mjs +51 -52
  152. package/fesm2022/hmcts-opal-frontend-common-permission-denied.component-B3EkD8uw.mjs +41 -0
  153. package/fesm2022/hmcts-opal-frontend-common-pipes-date-format.mjs +41 -28
  154. package/fesm2022/hmcts-opal-frontend-common-pipes-days-ago.mjs +43 -40
  155. package/fesm2022/hmcts-opal-frontend-common-pipes-monetary.mjs +43 -39
  156. package/fesm2022/hmcts-opal-frontend-common-pipes-national-insurance.mjs +41 -29
  157. package/fesm2022/hmcts-opal-frontend-common-resolvers-title.mjs +37 -25
  158. package/fesm2022/hmcts-opal-frontend-common-services-app-initializer-service.mjs +68 -91
  159. package/fesm2022/hmcts-opal-frontend-common-services-app-insights-service.mjs +74 -65
  160. package/fesm2022/hmcts-opal-frontend-common-services-auth-service-constants.mjs +6 -10
  161. package/fesm2022/hmcts-opal-frontend-common-services-auth-service-interfaces.mjs +0 -4
  162. package/fesm2022/hmcts-opal-frontend-common-services-auth-service.mjs +49 -42
  163. package/fesm2022/hmcts-opal-frontend-common-services-date-service-interfaces.mjs +0 -4
  164. package/fesm2022/hmcts-opal-frontend-common-services-date-service.mjs +118 -233
  165. package/fesm2022/hmcts-opal-frontend-common-services-history-transformation-service.mjs +185 -484
  166. package/fesm2022/hmcts-opal-frontend-common-services-launch-darkly-service-mocks.mjs +12 -11
  167. package/fesm2022/hmcts-opal-frontend-common-services-launch-darkly-service.mjs +77 -115
  168. package/fesm2022/hmcts-opal-frontend-common-services-opal-user-service-interfaces.mjs +0 -4
  169. package/fesm2022/hmcts-opal-frontend-common-services-opal-user-service-mocks.mjs +150 -159
  170. package/fesm2022/hmcts-opal-frontend-common-services-opal-user-service.mjs +119 -202
  171. package/fesm2022/hmcts-opal-frontend-common-services-permissions-service.mjs +47 -68
  172. package/fesm2022/hmcts-opal-frontend-common-services-session-service-constants.mjs +3 -9
  173. package/fesm2022/hmcts-opal-frontend-common-services-session-service-interfaces.mjs +0 -4
  174. package/fesm2022/hmcts-opal-frontend-common-services-session-service-mocks.mjs +4 -8
  175. package/fesm2022/hmcts-opal-frontend-common-services-session-service.mjs +50 -40
  176. package/fesm2022/hmcts-opal-frontend-common-services-sort-service-interfaces.mjs +0 -4
  177. package/fesm2022/hmcts-opal-frontend-common-services-sort-service.mjs +56 -96
  178. package/fesm2022/hmcts-opal-frontend-common-services-transfer-state-service-interfaces.mjs +0 -4
  179. package/fesm2022/hmcts-opal-frontend-common-services-transfer-state-service-mocks.mjs +19 -26
  180. package/fesm2022/hmcts-opal-frontend-common-services-transfer-state-service.mjs +71 -99
  181. package/fesm2022/hmcts-opal-frontend-common-services-transformation-service-constants.mjs +4 -8
  182. package/fesm2022/hmcts-opal-frontend-common-services-transformation-service-interfaces.mjs +0 -4
  183. package/fesm2022/hmcts-opal-frontend-common-services-transformation-service.mjs +65 -106
  184. package/fesm2022/hmcts-opal-frontend-common-services-utils-service.mjs +102 -193
  185. package/fesm2022/hmcts-opal-frontend-common-sign-in-stub.component-CT2Bh7gD.mjs +127 -0
  186. package/fesm2022/hmcts-opal-frontend-common-sign-in.component-Dz97ji3i.mjs +55 -0
  187. package/fesm2022/hmcts-opal-frontend-common-stores-global-constants.mjs +6 -10
  188. package/fesm2022/hmcts-opal-frontend-common-stores-global-interfaces.mjs +0 -4
  189. package/fesm2022/hmcts-opal-frontend-common-stores-global-types.mjs +0 -4
  190. package/fesm2022/hmcts-opal-frontend-common-stores-global.mjs +52 -57
  191. package/fesm2022/hmcts-opal-frontend-common-types.mjs +0 -4
  192. package/fesm2022/hmcts-opal-frontend-common-validators-amount.mjs +7 -18
  193. package/fesm2022/hmcts-opal-frontend-common-validators-date-after-year.mjs +8 -15
  194. package/fesm2022/hmcts-opal-frontend-common-validators-date-before.mjs +9 -18
  195. package/fesm2022/hmcts-opal-frontend-common-validators-date-of-birth.mjs +13 -21
  196. package/fesm2022/hmcts-opal-frontend-common-validators-future-date.mjs +9 -18
  197. package/fesm2022/hmcts-opal-frontend-common-validators-invalid-value.mjs +6 -12
  198. package/fesm2022/hmcts-opal-frontend-common-validators-national-insurance-number.mjs +9 -17
  199. package/fesm2022/hmcts-opal-frontend-common-validators-non-negative-value.mjs +10 -26
  200. package/fesm2022/hmcts-opal-frontend-common-validators-non-zero-value.mjs +10 -26
  201. package/fesm2022/hmcts-opal-frontend-common-validators-optional-max-length.mjs +7 -14
  202. package/fesm2022/hmcts-opal-frontend-common-validators-optional-valid-date.mjs +13 -26
  203. package/fesm2022/hmcts-opal-frontend-common-validators-optional-valid-telephone.mjs +12 -17
  204. package/fesm2022/hmcts-opal-frontend-common-validators-over-eighteen.mjs +19 -48
  205. package/fesm2022/hmcts-opal-frontend-common-validators-past-date.mjs +11 -19
  206. package/fesm2022/hmcts-opal-frontend-common-validators-pattern-validator.mjs +7 -26
  207. package/fesm2022/hmcts-opal-frontend-common-validators-valid-value.mjs +6 -12
  208. package/fesm2022/hmcts-opal-frontend-common.mjs +56 -76
  209. package/package.json +3 -3
  210. package/types/hmcts-opal-frontend-common-components-abstract-abstract-account-summary-base.d.ts +95 -104
  211. package/types/hmcts-opal-frontend-common-components-abstract-abstract-creditor-details-base.d.ts +75 -78
  212. package/types/hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base-interfaces.d.ts +4 -7
  213. package/types/hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base.d.ts +123 -126
  214. package/types/hmcts-opal-frontend-common-components-abstract-abstract-form-array-base-interfaces.d.ts +4 -7
  215. package/types/hmcts-opal-frontend-common-components-abstract-abstract-form-array-base.d.ts +156 -159
  216. package/types/hmcts-opal-frontend-common-components-abstract-abstract-form-array-parent-base.d.ts +13 -16
  217. package/types/hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base-interfaces.d.ts +5 -7
  218. package/types/hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base.d.ts +46 -50
  219. package/types/hmcts-opal-frontend-common-components-abstract-abstract-form-base-interfaces.d.ts +27 -35
  220. package/types/hmcts-opal-frontend-common-components-abstract-abstract-form-base.d.ts +323 -328
  221. package/types/hmcts-opal-frontend-common-components-abstract-abstract-form-parent-base.d.ts +33 -36
  222. package/types/hmcts-opal-frontend-common-components-abstract-abstract-nested-form-base.d.ts +75 -78
  223. package/types/hmcts-opal-frontend-common-components-abstract-abstract-report-instances-table-base.d.ts +15 -13
  224. package/types/hmcts-opal-frontend-common-components-abstract-abstract-report-summary-list-base-constants.d.ts +16 -19
  225. package/types/hmcts-opal-frontend-common-components-abstract-abstract-report-summary-list-base-interfaces.d.ts +23 -30
  226. package/types/hmcts-opal-frontend-common-components-abstract-abstract-report-summary-list-base-types.d.ts +1 -3
  227. package/types/hmcts-opal-frontend-common-components-abstract-abstract-report-summary-list-base.d.ts +179 -188
  228. package/types/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table-interfaces.d.ts +6 -9
  229. package/types/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table-pagination.d.ts +66 -66
  230. package/types/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table-types.d.ts +2 -5
  231. package/types/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table.d.ts +112 -113
  232. package/types/hmcts-opal-frontend-common-components-abstract-abstract-tab-data.d.ts +83 -86
  233. package/types/hmcts-opal-frontend-common-components-abstract-abstract-table-filter-interfaces.d.ts +12 -15
  234. package/types/hmcts-opal-frontend-common-components-abstract-abstract-table-filter-types.d.ts +1 -3
  235. package/types/hmcts-opal-frontend-common-components-abstract-abstract-table-filter.d.ts +113 -116
  236. package/types/hmcts-opal-frontend-common-components-abstract-interfaces.d.ts +16 -23
  237. package/types/hmcts-opal-frontend-common-components-alphagov-alphagov-accessible-autocomplete-interfaces.d.ts +4 -6
  238. package/types/hmcts-opal-frontend-common-components-alphagov-alphagov-accessible-autocomplete.d.ts +136 -93
  239. package/types/hmcts-opal-frontend-common-components-custom-custom-accessible-monetary.d.ts +35 -29
  240. package/types/hmcts-opal-frontend-common-components-custom-custom-account-information-custom-account-information-item-custom-account-information-item-label.d.ts +6 -9
  241. package/types/hmcts-opal-frontend-common-components-custom-custom-account-information-custom-account-information-item-custom-account-information-item-value.d.ts +6 -9
  242. package/types/hmcts-opal-frontend-common-components-custom-custom-account-information-custom-account-information-item.d.ts +12 -10
  243. package/types/hmcts-opal-frontend-common-components-custom-custom-account-information.d.ts +5 -8
  244. package/types/hmcts-opal-frontend-common-components-custom-custom-action-links.d.ts +18 -12
  245. package/types/hmcts-opal-frontend-common-components-custom-custom-deferred-live-region-announcement.d.ts +67 -57
  246. package/types/hmcts-opal-frontend-common-components-custom-custom-horizontal-scroll-pane.d.ts +5 -8
  247. package/types/hmcts-opal-frontend-common-components-custom-custom-page-header.d.ts +5 -8
  248. package/types/hmcts-opal-frontend-common-components-custom-custom-scrollable-panes-custom-scrollable-panes-inner-pane.d.ts +16 -10
  249. package/types/hmcts-opal-frontend-common-components-custom-custom-scrollable-panes.d.ts +11 -9
  250. package/types/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar-custom-summary-metric-bar-item-custom-summary-metric-bar-item-label.d.ts +12 -10
  251. package/types/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar-custom-summary-metric-bar-item-custom-summary-metric-bar-item-value.d.ts +12 -10
  252. package/types/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar-custom-summary-metric-bar-item.d.ts +26 -20
  253. package/types/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar.d.ts +5 -8
  254. package/types/hmcts-opal-frontend-common-components-custom-custom-vertical-scroll-pane-custom-vertical-scroll-pane-inner-pane.d.ts +16 -10
  255. package/types/hmcts-opal-frontend-common-components-custom-custom-vertical-scroll-pane-custom-vertical-scroll-pane-outer-pane.d.ts +11 -9
  256. package/types/hmcts-opal-frontend-common-components-custom-custom-vertical-scroll-pane.d.ts +5 -8
  257. package/types/hmcts-opal-frontend-common-components-govuk-govuk-accordion.d.ts +72 -64
  258. package/types/hmcts-opal-frontend-common-components-govuk-govuk-back-link.d.ts +16 -17
  259. package/types/hmcts-opal-frontend-common-components-govuk-govuk-button.d.ts +29 -17
  260. package/types/hmcts-opal-frontend-common-components-govuk-govuk-cancel-link.d.ts +22 -18
  261. package/types/hmcts-opal-frontend-common-components-govuk-govuk-checkboxes-interfaces.d.ts +14 -16
  262. package/types/hmcts-opal-frontend-common-components-govuk-govuk-checkboxes.d.ts +96 -43
  263. package/types/hmcts-opal-frontend-common-components-govuk-govuk-date-input-interfaces.d.ts +13 -15
  264. package/types/hmcts-opal-frontend-common-components-govuk-govuk-date-input.d.ts +75 -34
  265. package/types/hmcts-opal-frontend-common-components-govuk-govuk-details.d.ts +11 -9
  266. package/types/hmcts-opal-frontend-common-components-govuk-govuk-error-summary.d.ts +23 -19
  267. package/types/hmcts-opal-frontend-common-components-govuk-govuk-footer-interfaces.d.ts +5 -7
  268. package/types/hmcts-opal-frontend-common-components-govuk-govuk-footer.d.ts +14 -13
  269. package/types/hmcts-opal-frontend-common-components-govuk-govuk-header-interfaces.d.ts +4 -6
  270. package/types/hmcts-opal-frontend-common-components-govuk-govuk-header.d.ts +25 -23
  271. package/types/hmcts-opal-frontend-common-components-govuk-govuk-heading-with-caption-types.d.ts +1 -3
  272. package/types/hmcts-opal-frontend-common-components-govuk-govuk-heading-with-caption.d.ts +32 -14
  273. package/types/hmcts-opal-frontend-common-components-govuk-govuk-inset-text.d.ts +16 -10
  274. package/types/hmcts-opal-frontend-common-components-govuk-govuk-list-govuk-list-link.d.ts +16 -12
  275. package/types/hmcts-opal-frontend-common-components-govuk-govuk-list.d.ts +5 -8
  276. package/types/hmcts-opal-frontend-common-components-govuk-govuk-notification-banner.d.ts +37 -20
  277. package/types/hmcts-opal-frontend-common-components-govuk-govuk-pagination.d.ts +59 -47
  278. package/types/hmcts-opal-frontend-common-components-govuk-govuk-panel.d.ts +12 -10
  279. package/types/hmcts-opal-frontend-common-components-govuk-govuk-radio-interfaces.d.ts +17 -20
  280. package/types/hmcts-opal-frontend-common-components-govuk-govuk-radio.d.ts +162 -101
  281. package/types/hmcts-opal-frontend-common-components-govuk-govuk-select-interfaces.d.ts +4 -6
  282. package/types/hmcts-opal-frontend-common-components-govuk-govuk-select.d.ts +67 -26
  283. package/types/hmcts-opal-frontend-common-components-govuk-govuk-summary-card-list.d.ts +67 -35
  284. package/types/hmcts-opal-frontend-common-components-govuk-govuk-summary-list.d.ts +80 -47
  285. package/types/hmcts-opal-frontend-common-components-govuk-govuk-table.d.ts +47 -30
  286. package/types/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.d.ts +44 -34
  287. package/types/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-panel.d.ts +19 -17
  288. package/types/hmcts-opal-frontend-common-components-govuk-govuk-tabs.d.ts +44 -36
  289. package/types/hmcts-opal-frontend-common-components-govuk-govuk-tag.d.ts +16 -10
  290. package/types/hmcts-opal-frontend-common-components-govuk-govuk-task-list.d.ts +35 -17
  291. package/types/hmcts-opal-frontend-common-components-govuk-govuk-text-area.d.ts +83 -29
  292. package/types/hmcts-opal-frontend-common-components-govuk-govuk-text-input-prefix-suffix.d.ts +74 -28
  293. package/types/hmcts-opal-frontend-common-components-govuk-govuk-text-input.d.ts +65 -23
  294. package/types/hmcts-opal-frontend-common-components-govuk-helpers.d.ts +1 -3
  295. package/types/hmcts-opal-frontend-common-components-hod-hod-loading-spinner.d.ts +18 -12
  296. package/types/hmcts-opal-frontend-common-components-moj-moj-alert.d.ts +89 -69
  297. package/types/hmcts-opal-frontend-common-components-moj-moj-badge.d.ts +16 -10
  298. package/types/hmcts-opal-frontend-common-components-moj-moj-button-menu-moj-button-menu-item.d.ts +16 -12
  299. package/types/hmcts-opal-frontend-common-components-moj-moj-button-menu.d.ts +32 -26
  300. package/types/hmcts-opal-frontend-common-components-moj-moj-date-picker.d.ts +116 -60
  301. package/types/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-header.d.ts +11 -9
  302. package/types/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-option-moj-filter-panel-option-form-group-item.d.ts +33 -29
  303. package/types/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-option-moj-filter-panel-option-form-group-keyword.d.ts +34 -22
  304. package/types/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-option.d.ts +22 -18
  305. package/types/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-selected-moj-filter-panel-selected-tag.d.ts +32 -24
  306. package/types/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-selected.d.ts +29 -21
  307. package/types/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel.d.ts +5 -8
  308. package/types/hmcts-opal-frontend-common-components-moj-moj-filter.d.ts +23 -17
  309. package/types/hmcts-opal-frontend-common-components-moj-moj-header-interfaces.d.ts +4 -6
  310. package/types/hmcts-opal-frontend-common-components-moj-moj-header.d.ts +25 -23
  311. package/types/hmcts-opal-frontend-common-components-moj-moj-inset-text.d.ts +16 -10
  312. package/types/hmcts-opal-frontend-common-components-moj-moj-notification-badge.d.ts +11 -9
  313. package/types/hmcts-opal-frontend-common-components-moj-moj-page-header.d.ts +11 -9
  314. package/types/hmcts-opal-frontend-common-components-moj-moj-pagination.d.ts +99 -83
  315. package/types/hmcts-opal-frontend-common-components-moj-moj-primary-navigation.d.ts +102 -67
  316. package/types/hmcts-opal-frontend-common-components-moj-moj-sortable-table.d.ts +83 -51
  317. package/types/hmcts-opal-frontend-common-components-moj-moj-sub-navigation.d.ts +62 -42
  318. package/types/hmcts-opal-frontend-common-components-moj-moj-ticket-panel.d.ts +21 -11
  319. package/types/hmcts-opal-frontend-common-components-moj-moj-timeline.d.ts +8 -12
  320. package/types/hmcts-opal-frontend-common-constants.d.ts +20 -25
  321. package/types/hmcts-opal-frontend-common-directives-capitalisation.d.ts +17 -15
  322. package/types/hmcts-opal-frontend-common-directives-govuk-button.d.ts +33 -21
  323. package/types/hmcts-opal-frontend-common-directives-moj-multi-select.d.ts +92 -69
  324. package/types/hmcts-opal-frontend-common-directives-trim-leading-trailing-whitespace.d.ts +13 -11
  325. package/types/hmcts-opal-frontend-common-guards-account.d.ts +2 -5
  326. package/types/hmcts-opal-frontend-common-guards-auth.d.ts +4 -7
  327. package/types/hmcts-opal-frontend-common-guards-business-unit-route-permissions.d.ts +14 -19
  328. package/types/hmcts-opal-frontend-common-guards-can-deactivate-interfaces.d.ts +4 -7
  329. package/types/hmcts-opal-frontend-common-guards-can-deactivate-types.d.ts +3 -6
  330. package/types/hmcts-opal-frontend-common-guards-can-deactivate.d.ts +4 -8
  331. package/types/hmcts-opal-frontend-common-guards-feature-flag.d.ts +4 -7
  332. package/types/hmcts-opal-frontend-common-guards-has-flow-state.d.ts +2 -5
  333. package/types/hmcts-opal-frontend-common-guards-has-url-state-match.d.ts +2 -5
  334. package/types/hmcts-opal-frontend-common-guards-helpers.d.ts +8 -15
  335. package/types/hmcts-opal-frontend-common-guards-route-permissions.d.ts +2 -5
  336. package/types/hmcts-opal-frontend-common-guards-signed-in.d.ts +2 -5
  337. package/types/hmcts-opal-frontend-common-guards-types.d.ts +2 -5
  338. package/types/hmcts-opal-frontend-common-interceptors-content-digest.d.ts +2 -5
  339. package/types/hmcts-opal-frontend-common-interceptors-http-error-constants.d.ts +4 -9
  340. package/types/hmcts-opal-frontend-common-interceptors-http-error-interfaces.d.ts +9 -11
  341. package/types/hmcts-opal-frontend-common-interceptors-http-error.d.ts +2 -5
  342. package/types/hmcts-opal-frontend-common-interceptors-http-retry-constants.d.ts +5 -11
  343. package/types/hmcts-opal-frontend-common-interceptors-http-retry-interfaces.d.ts +7 -9
  344. package/types/hmcts-opal-frontend-common-interceptors-http-retry.d.ts +9 -15
  345. package/types/hmcts-opal-frontend-common-pages-dashboard-page-interfaces.d.ts +17 -21
  346. package/types/hmcts-opal-frontend-common-pages-dashboard-page.d.ts +89 -96
  347. package/types/hmcts-opal-frontend-common-pages-routing-constants.d.ts +3 -7
  348. package/types/hmcts-opal-frontend-common-pages-routing-interfaces.d.ts +24 -29
  349. package/types/hmcts-opal-frontend-common-pages.d.ts +2 -5
  350. package/types/hmcts-opal-frontend-common-pipes-date-format.d.ts +8 -11
  351. package/types/hmcts-opal-frontend-common-pipes-days-ago.d.ts +7 -10
  352. package/types/hmcts-opal-frontend-common-pipes-monetary.d.ts +8 -11
  353. package/types/hmcts-opal-frontend-common-pipes-national-insurance.d.ts +7 -10
  354. package/types/hmcts-opal-frontend-common-resolvers-title.d.ts +8 -11
  355. package/types/hmcts-opal-frontend-common-services-app-initializer-service.d.ts +37 -41
  356. package/types/hmcts-opal-frontend-common-services-app-insights-service.d.ts +14 -17
  357. package/types/hmcts-opal-frontend-common-services-auth-service-constants.d.ts +2 -5
  358. package/types/hmcts-opal-frontend-common-services-auth-service-interfaces.d.ts +6 -8
  359. package/types/hmcts-opal-frontend-common-services-auth-service.d.ts +8 -12
  360. package/types/hmcts-opal-frontend-common-services-date-service-interfaces.d.ts +7 -9
  361. package/types/hmcts-opal-frontend-common-services-date-service.d.ts +149 -153
  362. package/types/hmcts-opal-frontend-common-services-history-transformation-service.d.ts +104 -125
  363. package/types/hmcts-opal-frontend-common-services-launch-darkly-service-mocks.d.ts +13 -16
  364. package/types/hmcts-opal-frontend-common-services-launch-darkly-service.d.ts +46 -49
  365. package/types/hmcts-opal-frontend-common-services-opal-user-service-interfaces.d.ts +28 -36
  366. package/types/hmcts-opal-frontend-common-services-opal-user-service-mocks.d.ts +4 -9
  367. package/types/hmcts-opal-frontend-common-services-opal-user-service.d.ts +97 -104
  368. package/types/hmcts-opal-frontend-common-services-permissions-service.d.ts +33 -36
  369. package/types/hmcts-opal-frontend-common-services-session-service-constants.d.ts +2 -5
  370. package/types/hmcts-opal-frontend-common-services-session-service-interfaces.d.ts +6 -9
  371. package/types/hmcts-opal-frontend-common-services-session-service-mocks.d.ts +2 -5
  372. package/types/hmcts-opal-frontend-common-services-session-service.d.ts +17 -20
  373. package/types/hmcts-opal-frontend-common-services-sort-service-interfaces.d.ts +9 -13
  374. package/types/hmcts-opal-frontend-common-services-sort-service.d.ts +64 -67
  375. package/types/hmcts-opal-frontend-common-services-transfer-state-service-interfaces.d.ts +20 -26
  376. package/types/hmcts-opal-frontend-common-services-transfer-state-service-mocks.d.ts +11 -17
  377. package/types/hmcts-opal-frontend-common-services-transfer-state-service.d.ts +44 -47
  378. package/types/hmcts-opal-frontend-common-services-transformation-service-constants.d.ts +2 -5
  379. package/types/hmcts-opal-frontend-common-services-transformation-service-interfaces.d.ts +12 -14
  380. package/types/hmcts-opal-frontend-common-services-transformation-service.d.ts +41 -44
  381. package/types/hmcts-opal-frontend-common-services-utils-service.d.ts +111 -114
  382. package/types/hmcts-opal-frontend-common-stores-global-constants.d.ts +2 -5
  383. package/types/hmcts-opal-frontend-common-stores-global-interfaces.d.ts +6 -8
  384. package/types/hmcts-opal-frontend-common-stores-global-types.d.ts +2 -5
  385. package/types/hmcts-opal-frontend-common-stores-global.d.ts +52 -57
  386. package/types/hmcts-opal-frontend-common-types.d.ts +1 -3
  387. package/types/hmcts-opal-frontend-common-validators-amount.d.ts +2 -5
  388. package/types/hmcts-opal-frontend-common-validators-date-after-year.d.ts +2 -5
  389. package/types/hmcts-opal-frontend-common-validators-date-before.d.ts +2 -5
  390. package/types/hmcts-opal-frontend-common-validators-date-of-birth.d.ts +2 -5
  391. package/types/hmcts-opal-frontend-common-validators-future-date.d.ts +2 -5
  392. package/types/hmcts-opal-frontend-common-validators-invalid-value.d.ts +2 -5
  393. package/types/hmcts-opal-frontend-common-validators-national-insurance-number.d.ts +2 -5
  394. package/types/hmcts-opal-frontend-common-validators-non-negative-value.d.ts +2 -5
  395. package/types/hmcts-opal-frontend-common-validators-non-zero-value.d.ts +2 -5
  396. package/types/hmcts-opal-frontend-common-validators-optional-max-length.d.ts +2 -5
  397. package/types/hmcts-opal-frontend-common-validators-optional-valid-date.d.ts +2 -5
  398. package/types/hmcts-opal-frontend-common-validators-optional-valid-telephone.d.ts +2 -5
  399. package/types/hmcts-opal-frontend-common-validators-over-eighteen.d.ts +3 -6
  400. package/types/hmcts-opal-frontend-common-validators-past-date.d.ts +2 -5
  401. package/types/hmcts-opal-frontend-common-validators-pattern-validator.d.ts +2 -5
  402. package/types/hmcts-opal-frontend-common-validators-valid-value.d.ts +2 -5
  403. package/types/hmcts-opal-frontend-common.d.ts +23 -31
  404. package/fesm2022/hmcts-opal-frontend-common-access-denied.component-BDTGvQ4J.mjs +0 -21
  405. package/fesm2022/hmcts-opal-frontend-common-account-created.component-6jzTqXSI.mjs +0 -15
  406. package/fesm2022/hmcts-opal-frontend-common-concurrency-failure.component-D43W-peK.mjs +0 -14
  407. package/fesm2022/hmcts-opal-frontend-common-internal-server-error.component-DftC2eY-.mjs +0 -26
  408. package/fesm2022/hmcts-opal-frontend-common-pages-access-denied.component-BDTGvQ4J.mjs +0 -21
  409. package/fesm2022/hmcts-opal-frontend-common-pages-account-created.component-6jzTqXSI.mjs +0 -15
  410. package/fesm2022/hmcts-opal-frontend-common-pages-concurrency-failure.component-D43W-peK.mjs +0 -14
  411. package/fesm2022/hmcts-opal-frontend-common-pages-internal-server-error.component-DftC2eY-.mjs +0 -26
  412. package/fesm2022/hmcts-opal-frontend-common-pages-permission-denied.component-CNGPX5k_.mjs +0 -14
  413. package/fesm2022/hmcts-opal-frontend-common-pages-sign-in-stub.component-BIgTV7f1.mjs +0 -42
  414. package/fesm2022/hmcts-opal-frontend-common-pages-sign-in.component-0pu6fIcO.mjs +0 -28
  415. package/fesm2022/hmcts-opal-frontend-common-permission-denied.component-CNGPX5k_.mjs +0 -14
  416. package/fesm2022/hmcts-opal-frontend-common-sign-in-stub.component-BIgTV7f1.mjs +0 -42
  417. package/fesm2022/hmcts-opal-frontend-common-sign-in.component-BxUlQIYI.mjs +0 -28
@@ -1,617 +1,341 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, ChangeDetectorRef, EventEmitter, Output, Component } from '@angular/core';
3
- import { FormRecord, FormGroup, FormArray, FormControl } from '@angular/forms';
4
- import { Router, ActivatedRoute } from '@angular/router';
5
- import { Subject, takeUntil } from 'rxjs';
6
- import { UtilsService } from '@hmcts/opal-frontend-common/services/utils-service';
7
-
8
- class AbstractFormBaseComponent {
9
- changeDetectorRef = inject(ChangeDetectorRef);
10
- router = inject(Router);
11
- activatedRoute = inject(ActivatedRoute);
12
- unsavedChanges = new EventEmitter();
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- formSubmit = new EventEmitter();
15
- utilsService = inject(UtilsService);
16
- fieldErrors;
17
- formSubmitted = false;
18
- ngUnsubscribe = new Subject();
19
- form;
20
- formControlErrorMessages;
21
- formErrorSummaryMessage;
22
- formErrors;
23
- constructor() { }
24
- /**
25
- * Scrolls to a specific form field and attempts to focus on it.
26
- *
27
- * This method locates the target field or its associated label/legend
28
- * based on the provided `fieldId`. It ensures that the field or its
29
- * nested focusable element is brought into view and focused, if possible.
30
- *
31
- * The scrolling behavior is smooth, and the method prioritizes the following
32
- * elements in order:
33
- * 1. A label associated with an autocomplete field (`label[for="${fieldId}-autocomplete"]`).
34
- * 2. A regular label associated with the field (`label[for="${fieldId}"]`).
35
- * 3. A legend within a fieldset associated with the field (`[id="${fieldId}"] .govuk-fieldset__legend`).
36
- * 4. The field itself or its nested focusable element.
37
- *
38
- * @param fieldId - The ID of the form field to scroll to and focus on.
39
- */
40
- scroll(fieldId) {
41
- const autocompleteLabel = document.querySelector(`label[for="${fieldId}-autocomplete"]`);
42
- const regularLabel = document.querySelector(`label[for="${fieldId}"]`);
43
- const fieldsetLegend = document.querySelector(`[id="${fieldId}"] .govuk-fieldset__legend`);
44
- const labelTarget = autocompleteLabel ?? regularLabel ?? fieldsetLegend ?? null;
45
- const focusableSelector = 'input:not([type="hidden"]), select, textarea, button, [tabindex]:not([tabindex="-1"])';
46
- let fieldElement = document.getElementById(`${fieldId}-autocomplete`) ?? document.getElementById(fieldId);
47
- if (fieldElement && !this.canReceiveFocus(fieldElement)) {
48
- const nestedFocusable = fieldElement.querySelector(focusableSelector);
49
- if (nestedFocusable) {
50
- fieldElement = nestedFocusable;
51
- }
52
- }
53
- fieldElement ??= document.querySelector(`[id="${fieldId}"] ${focusableSelector}`);
54
- if (labelTarget) {
55
- labelTarget.scrollIntoView({ behavior: 'smooth' });
56
- }
57
- else if (fieldElement) {
58
- fieldElement.scrollIntoView({ behavior: 'smooth' });
59
- }
60
- fieldElement?.focus();
61
- }
62
- /**
63
- * Determines whether a given HTML element can receive focus.
64
- *
65
- * An element is considered focusable if:
66
- * - It has a `tabIndex` greater than or equal to 0 and does not have the `disabled` attribute.
67
- * - It is an anchor (`<a>`) element with a valid `href` attribute.
68
- * - It is one of the following tags: `INPUT`, `SELECT`, `TEXTAREA`, or `BUTTON`,
69
- * and it is not disabled.
70
- *
71
- * @param element - The HTML element to check for focusability.
72
- * @returns `true` if the element can receive focus, otherwise `false`.
73
- */
74
- canReceiveFocus(element) {
75
- if (element.tabIndex >= 0 && !element.hasAttribute('disabled')) {
76
- return true;
77
- }
78
- if (element instanceof HTMLAnchorElement && element.hasAttribute('href') && element.href) {
79
- return !!element.href;
80
- }
81
- const focusableTags = ['INPUT', 'SELECT', 'TEXTAREA', 'BUTTON'];
82
- if (focusableTags.includes(element.tagName)) {
83
- return !element.disabled;
84
- }
85
- return false;
86
- }
87
- /**
88
- * Returns the highest priority form error from the given error keys and field errors.
89
- * @param errorKeys - An array of error keys.
90
- * @param fieldErrors - An object containing field errors.
91
- * @returns The highest priority form error or null if no errors are found.
92
- */
93
- getHighestPriorityError(errorKeys = [], fieldErrors = {}) {
94
- if (errorKeys.length && Object.keys(fieldErrors).length) {
95
- const errors = errorKeys.map((errorType) => {
96
- return {
97
- ...fieldErrors[errorType],
98
- type: errorType,
99
- };
100
- });
101
- const sortedErrors = [...errors].sort((a, b) => a.priority - b.priority);
102
- return sortedErrors[0];
103
- }
104
- return null;
105
- }
106
- /**
107
- * Retrieves the details of the highest priority form error for a given control path.
108
- * @param controlPath - The path to the control in the form.
109
- * @returns The details of the highest priority form error, or null if there are no errors.
110
- */
111
- getFieldErrorDetails(controlPath) {
112
- // Get the control
113
- const control = this.form.get(controlPath);
114
- // If we have errors
115
- const controlErrors = control?.errors;
116
- if (controlErrors) {
117
- /// Get all the error keys
118
- // Use Array.prototype.at for clarity when accessing the last segment of the control path
119
- const controlKey = controlPath.at(-1);
120
- const errorKeys = Object.keys(controlErrors) || [];
121
- const fieldErrors = controlKey === undefined ? {} : this.fieldErrors[controlKey] || {};
122
- if (errorKeys.length && Object.keys(fieldErrors).length) {
123
- return this.getHighestPriorityError(errorKeys, fieldErrors);
124
- }
125
- }
126
- return null;
127
- }
128
- /**
129
- * Retrieves all form errors from the provided form and its nested form groups.
130
- *
131
- * @param form - The form group to retrieve errors from.
132
- * @param controlPath - An optional array representing the path to the current control within the form group.
133
- * @returns An array of form errors, each containing the field ID, error message, priority, and type.
134
- */
135
- getFormErrors(form, controlPath = []) {
136
- // recursively get all errors from all controls in the form including nested form group controls
137
- const formControls = form.controls;
138
- const errorSummary = Object.keys(formControls)
139
- .filter((controlName) => formControls[controlName].invalid)
140
- .flatMap((controlName) => {
141
- const control = formControls[controlName];
142
- if (control instanceof FormRecord) {
143
- // We only support FormControls in FormRecords
144
- const recordFieldErrorDetails = this.getFieldErrorDetails([...controlPath, controlName]);
145
- return {
146
- fieldId: controlName,
147
- message: recordFieldErrorDetails?.message ?? null,
148
- priority: recordFieldErrorDetails?.priority ?? 999999999,
149
- type: recordFieldErrorDetails?.type ?? null,
150
- };
151
- }
152
- if (control instanceof FormGroup) {
153
- return this.getFormErrors(control, [...controlPath, controlName]);
154
- }
155
- if (control instanceof FormArray) {
156
- return control.controls.flatMap((controlItem, index) => {
157
- // We only support FormGroups in FormArrays
158
- if (controlItem instanceof FormGroup) {
159
- return this.getFormErrors(controlItem, [...controlPath, controlName, index]);
160
- }
161
- return [];
162
- });
163
- }
164
- const getFieldErrorDetails = this.getFieldErrorDetails([...controlPath, controlName]);
165
- // Return the error summary entry
166
- // If we don't have the error details, return a null message
167
- return {
168
- fieldId: controlName,
169
- message: getFieldErrorDetails?.message ?? null,
170
- priority: getFieldErrorDetails?.priority ?? 999999999,
171
- type: getFieldErrorDetails?.type ?? null,
172
- };
173
- });
174
- // Remove any null errors
175
- return errorSummary.filter((item) => item?.message !== null);
176
- }
177
- /**
178
- * Sets the error messages for the form controls and error summary based on the provided form errors.
179
- * @param formErrors - An array of form errors containing field IDs and error messages.
180
- */
181
- setErrorMessages(formErrors) {
182
- // Reset the form error messages
183
- this.formControlErrorMessages = {};
184
- this.formErrorSummaryMessage = [];
185
- // Set the form error messages based on the error summary entries
186
- for (const entry of formErrors) {
187
- this.formControlErrorMessages[entry.fieldId] = entry.message;
188
- this.formErrorSummaryMessage.push({ fieldId: entry.fieldId, message: entry.message });
189
- }
190
- }
191
- /**
192
- * Gets the indexes of the date fields to remove based on the form error summary message.
193
- * @returns An array of indexes representing the date fields to remove.
194
- */
195
- getDateFieldsToRemoveIndexes() {
196
- const indexesToRemove = [];
197
- // The order of the field ids is important
198
- // this is the order in which we want to remove them
199
- const foundIndexes = this.getFormErrorSummaryIndex(['dayOfMonth', 'monthOfYear', 'year'], this.formErrorSummaryMessage);
200
- // Determine which indexes to remove based on the found fields
201
- switch (foundIndexes.length) {
202
- case 3:
203
- // All three date fields are present
204
- indexesToRemove.push(foundIndexes[1], foundIndexes[2]);
205
- break;
206
- case 2:
207
- // Two date fields are present
208
- indexesToRemove.push(foundIndexes[1]);
209
- break;
210
- }
211
- return indexesToRemove;
212
- }
213
- /**
214
- * Returns an array of indices corresponding to the positions of the given field IDs in the form error summary message array.
215
- *
216
- * @param fieldIds - An array of field IDs to search for in the form error summary message array.
217
- * @param formErrorSummaryMessage - An array of form error summary messages.
218
- * @returns An array of indices corresponding to the positions of the field IDs in the form error summary message array.
219
- */
220
- getFormErrorSummaryIndex(fieldIds, formErrorSummaryMessage) {
221
- return fieldIds.reduce((acc, field) => {
222
- const index = formErrorSummaryMessage.findIndex((error) => error.fieldId === field);
223
- if (index === -1) {
224
- return acc;
225
- }
226
- return [...acc, index];
227
- }, []);
228
- }
229
- /**
230
- * Removes error summary messages from the given array based on the specified indexes.
231
- *
232
- * @param formErrorSummaryMessage - The array of error summary messages.
233
- * @param indexes - The indexes of the error summary messages to be removed.
234
- * @returns The updated array of error summary messages.
235
- */
236
- removeErrorSummaryMessages(formErrorSummaryMessage, indexes) {
237
- return formErrorSummaryMessage.filter((_, index) => !indexes.includes(index));
238
- }
239
- /**
240
- * Splits the form errors into two arrays based on the provided field IDs.
241
- * Errors with field IDs included in the fieldIds array will be moved to the removedFormErrors array,
242
- * while the remaining errors will be moved to the cleanFormErrors array.
243
- *
244
- * @param fieldIds - An array of field IDs to filter the form errors.
245
- * @param formErrors - An array of form errors to be split.
246
- * @returns An array containing two arrays: cleanFormErrors and removedFormErrors.
247
- */
248
- splitFormErrors(fieldIds, formErrors) {
249
- const cleanFormErrors = [];
250
- const removedFormErrors = [];
251
- for (const error of formErrors) {
252
- if (fieldIds.includes(error.fieldId)) {
253
- removedFormErrors.push(error);
254
- }
255
- else {
256
- cleanFormErrors.push(error);
257
- }
258
- }
259
- return [cleanFormErrors, removedFormErrors];
260
- }
261
- /**
262
- * Manipulates the error message for specific fields in the formErrors array.
263
- * @param fields - An array of field IDs to target for error message manipulation.
264
- * @param messageOverride - The new error message to be used for the targeted fields.
265
- * @param errorType - The type of error to match for the targeted fields.
266
- * @param formErrors - An array of IFormError objects representing the form errors.
267
- * @returns An array of IFormError objects with the manipulated error messages.
268
- */
269
- manipulateFormErrorMessage(fields, messageOverride, errorType, formErrors) {
270
- const manipulatedFields = [];
271
- for (const field of formErrors) {
272
- if (fields.includes(field.fieldId)) {
273
- if (field.type === errorType) {
274
- manipulatedFields.push({ ...field, message: messageOverride });
275
- }
276
- else {
277
- manipulatedFields.push(field);
278
- }
279
- continue;
280
- }
281
- manipulatedFields.push(field);
282
- }
283
- return manipulatedFields;
284
- }
285
- /**
286
- * Retrieves the form errors with the highest priority.
287
- *
288
- * @param formErrors - An array of form errors.
289
- * @returns An array of form errors with the highest priority.
290
- */
291
- getHighPriorityFormErrors(formErrors) {
292
- // Get the lowest priority (1 is the highest priority, 3 is the lowest priority)
293
- const lowestPriority = Math.min(...formErrors.map((item) => item.priority));
294
- return formErrors.filter((item) => item.priority === lowestPriority);
295
- }
296
- /**
297
- * Focuses on the error summary element and scrolls to the top of the page.
298
- *
299
- * This method first triggers change detection to ensure the view is up-to-date.
300
- * It then selects the error summary element with the class 'govuk-error-summary'.
301
- * If the error summary element is found, it sets focus on it without scrolling the page.
302
- * Finally, it calls a utility service to scroll to the top of the page.
303
- *
304
- * @private
305
- */
306
- focusAndScrollToErrorSummary() {
307
- this.changeDetectorRef.detectChanges();
308
- const errorSummary = document.querySelector('.govuk-error-summary');
309
- if (errorSummary) {
310
- errorSummary.focus({ preventScroll: true });
311
- this.utilsService.scrollToTop();
312
- }
313
- }
314
- /**
315
- * Setup listener for the form value changes and to emit hasUnsavedChanges
316
- */
317
- setupListener() {
318
- this.form.valueChanges.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => {
319
- this.unsavedChanges.emit(this.hasUnsavedChanges());
320
- });
321
- }
322
- /**
323
- * Adds controls to a form group.
324
- *
325
- * @param formGroup - The form group to add controls to.
326
- * @param controls - An array of form array control validations.
327
- * @param index - The index of the form array control.
328
- */
329
- addControlsToFormGroup(formGroup, controls, index) {
330
- for (const { controlName, validators } of controls) {
331
- formGroup.addControl(`${controlName}_${index}`, new FormControl(null, validators));
332
- }
333
- }
334
- /**
335
- * Creates a form control with the specified validators and initial value.
336
- *
337
- * @param validators - An array of validator functions.
338
- * @param initialValue - The initial value for the form control. Defaults to null.
339
- * @returns The created form control.
340
- */
341
- createFormControl(validators, initialValue = null) {
342
- return new FormControl(initialValue, { validators: [...validators] });
343
- }
344
- /**
345
- * Handles the error messages and populates the relevant variables
346
- */
347
- handleErrorMessages() {
348
- this.formErrors = this.getFormErrors(this.form);
349
- this.setErrorMessages(this.formErrors);
350
- this.formErrorSummaryMessage = this.removeErrorSummaryMessages(this.formErrorSummaryMessage, this.getDateFieldsToRemoveIndexes());
351
- }
352
- /**
353
- * Checks whether the form has been touched and submitted
354
- *
355
- * @returns boolean
356
- */
357
- hasUnsavedChanges() {
358
- return this.form.dirty && !this.formSubmitted;
359
- }
360
- /**
361
- * Sets the value of a form control specified by its path and marks it as touched.
362
- *
363
- * @param value - The value to set for the form control.
364
- * @param controlPath - The dot-delimited path to the form control within the form group.
365
- */
366
- setInputValue(value, controlPath) {
367
- const control = this.form.get(controlPath);
368
- if (control) {
369
- control.patchValue(value);
370
- control.markAsTouched();
371
- }
372
- }
373
- /**
374
- * Handles the form errors for the date input fields.
375
- * @param formErrors - An array of form errors.
376
- * @returns An array of form errors with the manipulated error messages.
377
- */
378
- handleDateInputFormErrors() {
379
- const dateInputFields = ['dayOfMonth', 'monthOfYear', 'year'];
380
- const splitFormErrors = this.splitFormErrors(dateInputFields, this.formErrors);
381
- const highPriorityDateControlErrors = this.getHighPriorityFormErrors(splitFormErrors[1]);
382
- let manipulatedFormErrors = highPriorityDateControlErrors;
383
- // If we have more than one error then we want to manipulate the error message
384
- if (highPriorityDateControlErrors.length > 1) {
385
- manipulatedFormErrors = this.manipulateFormErrorMessage(dateInputFields, 'Please enter a DOB', 'required', manipulatedFormErrors);
386
- }
387
- return [...splitFormErrors[0], ...manipulatedFormErrors];
388
- }
389
- /**
390
- * Sets the initial error messages for the form controls.
391
- *
392
- * @param form - The FormGroup instance.
393
- */
394
- setInitialErrorMessages() {
395
- const formControls = this.form.controls;
396
- const initialFormControlErrorMessages = {};
397
- for (const controlName of Object.keys(formControls)) {
398
- initialFormControlErrorMessages[controlName] = null;
399
- }
400
- this.formControlErrorMessages = initialFormControlErrorMessages;
401
- this.formErrorSummaryMessage = [];
402
- }
403
- /**
404
- * Repopulates the search form with the data from the account enquiry search.
405
- * @param state - The state object containing the search form data.
406
- */
407
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
408
- rePopulateForm(state) {
409
- this.form.patchValue(state);
410
- }
411
- /**
412
- * Adds a new form control to the form group.
413
- *
414
- * @param controlName - The name of the control to add.
415
- * @param validators - An array of validators to apply to the control.
416
- */
417
- createControl(controlName, validators) {
418
- this.form.addControl(controlName, new FormControl(null, validators));
419
- }
420
- /**
421
- * Updates the validators of an existing form control.
422
- *
423
- * @param controlName - The name of the control to update.
424
- * @param validators - An array of validators to apply to the control.
425
- */
426
- updateControl(controlName, validators) {
427
- const control = this.form.get(controlName);
428
- if (control) {
429
- control.setValidators(validators);
430
- control.updateValueAndValidity();
431
- }
432
- else {
433
- this.createControl(controlName, validators);
434
- }
435
- }
436
- /**
437
- * Removes a control from the form.
438
- *
439
- * @param controlName - The name of the control to remove.
440
- */
441
- removeControl(controlName) {
442
- if (this.formControlErrorMessages[controlName]) {
443
- this.removeControlErrors(controlName);
444
- }
445
- this.form.removeControl(controlName);
446
- }
447
- /**
448
- * Removes the error message associated with the specified control name from the formControlErrorMessages object.
449
- *
450
- * @param controlName - The name of the control for which to remove the error message.
451
- */
452
- removeControlErrors(controlName) {
453
- delete this.formControlErrorMessages[controlName];
454
- }
455
- /**
456
- * Clears all error messages from the form.
457
- */
458
- clearAllErrorMessages() {
459
- this.formControlErrorMessages = {};
460
- this.formErrorSummaryMessage = [];
461
- this.formErrors = [];
462
- this.form.updateValueAndValidity({ onlySelf: false, emitEvent: false });
463
- }
464
- /**
465
- * Create a plain object from a FormRecord of FormControls.
466
- *
467
- * What it does: copies each control's current value onto a plain object.
468
- * When to use: when you need the raw values from a FormRecord (e.g. to send to an API).
469
- *
470
- * Example
471
- * -------
472
- * // record: FormRecord<FormControl<string | null>> with a single control 'firstName'
473
- * const out = this.objectFromFormRecord(record, {
474
- * mapKey: k => k, // optional (defaults to identity)
475
- * mapValue: v => v ?? '' // turn null/undefined into ''
476
- * });
477
- * // out -> { firstName: '' }
478
- *
479
- * @typeParam T - Control value type.
480
- * @typeParam U - Output value type (defaults to T).
481
- * @typeParam K - Output key type (defaults to string). Control names are strings; provide `mapKey` if you need numbers.
482
- */
483
- objectFromFormRecord(controlRecord, options) {
484
- const mapKey = options?.mapKey ?? ((k) => k);
485
- const mapValue = options?.mapValue ?? ((v) => v);
486
- const result = {};
487
- for (const [name, control] of Object.entries(controlRecord.controls)) {
488
- result[mapKey(name)] = mapValue(control.value);
489
- }
490
- return result;
491
- }
492
- /**
493
- * Patch a FormRecord of FormControls from a plain object.
494
- *
495
- * What it does: for each entry in `values`, finds the matching control by name
496
- * (optionally mapped via `mapKey`) and sets its value **only if** it changes.
497
- * When to use: when you need to patch many controls at once, without
498
- * triggering extra updates for unchanged values.
499
- *
500
- * Example
501
- * -------
502
- * // controlRecord: FormRecord<FormControl<string>> with controls 'firstName', 'lastName'
503
- * this.patchFormRecordFromObject(controlRecord, { firstName: 'Ada', lastName: 'Lovelace' }, {
504
- * emitEvent: true,
505
- * isEqual: (a, b) => a === b,
506
- * // mapKey: k => `ctrl_${k as string}` // optional: map incoming keys to control names
507
- * });
508
- *
509
- * @typeParam T - Control value type.
510
- * @typeParam K - Keys present in the `values` object (string or number).
511
- */
512
- patchFormRecordFromObject(controlRecord, values, options) {
513
- const emitEvent = options?.emitEvent ?? false;
514
- const mapKey = options?.mapKey ?? String;
515
- const isEqual = options?.isEqual ?? Object.is;
516
- for (const [k, v] of Object.entries(values)) {
517
- const controlName = mapKey(k);
518
- const ctrl = controlRecord.get(controlName);
519
- if (!ctrl) {
520
- // If the control isn't present, skip silently. Callers can validate separately.
521
- continue;
522
- }
523
- if (!isEqual(ctrl.value, v)) {
524
- ctrl.setValue(v, { emitEvent });
525
- }
526
- }
527
- }
528
- /**
529
- * Clears the search form.
530
- */
531
- handleClearForm() {
532
- this.form.reset();
533
- }
534
- /**
535
- * Handles the scroll of the component error from the summary
536
- *
537
- * @param fieldId - Field id of the component
538
- */
539
- scrollTo(fieldId) {
540
- this['scroll'](fieldId);
541
- }
542
- /**
543
- * Handles route with the supplied route
544
- *
545
- * @param route string of route
546
- * @param options optional parameters
547
- */
548
- handleRoute(route, options) {
549
- const { nonRelative = false, event, routeData, fragment } = options ?? {};
550
- if (event) {
551
- event.preventDefault();
552
- }
553
- this.unsavedChanges.emit(this.hasUnsavedChanges());
554
- const navigationExtras = {
555
- ...(nonRelative ? {} : { relativeTo: this.activatedRoute.parent }),
556
- ...(routeData ? { state: routeData } : {}),
557
- ...(fragment ? { fragment } : {}),
558
- };
559
- this.router.navigate([route], navigationExtras);
560
- }
561
- /**
562
- * Handles the form submission event.
563
- *
564
- * @param event - The form submission event.
565
- * @returns void
566
- */
567
- handleFormSubmit(event) {
568
- this.handleErrorMessages();
569
- if (this.form.valid) {
570
- this.formSubmitted = true;
571
- const nestedFlow = event.submitter ? event.submitter.className.includes('nested-flow') : false;
572
- this.unsavedChanges.emit(this.hasUnsavedChanges());
573
- this.formSubmit.emit({ formData: this.form.value, nestedFlow: nestedFlow });
574
- }
575
- else {
576
- this.focusAndScrollToErrorSummary();
577
- }
578
- }
579
- /**
580
- * Handles the input event to convert all letters in the input value to uppercase.
581
- * This method is triggered by an input event and modifies the input value directly.
582
- *
583
- * @param event - The input event triggered by the user.
584
- */
585
- handleUppercaseInputMask(event) {
586
- const input = event.target;
587
- input.value = this.utilsService.upperCaseAllLetters(input.value);
588
- }
589
- ngOnInit() {
590
- if (this.form) {
591
- this.setupListener();
592
- }
593
- }
594
- ngOnDestroy() {
595
- this.ngUnsubscribe.next();
596
- this.ngUnsubscribe.complete();
597
- }
598
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.21", ngImport: i0, type: AbstractFormBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
599
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.21", type: AbstractFormBaseComponent, isStandalone: true, selector: "ng-component", outputs: { unsavedChanges: "unsavedChanges", formSubmit: "formSubmit" }, ngImport: i0, template: '', isInline: true });
600
- }
601
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.21", ngImport: i0, type: AbstractFormBaseComponent, decorators: [{
602
- type: Component,
603
- args: [{
604
- template: '',
605
- }]
606
- }], ctorParameters: () => [], propDecorators: { unsavedChanges: [{
607
- type: Output
608
- }], formSubmit: [{
609
- type: Output
610
- }] } });
611
-
612
- /**
613
- * Generated bundle index. Do not edit.
614
- */
615
-
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectorRef, Component, EventEmitter, Output, inject } from "@angular/core";
3
+ import { FormArray, FormControl, FormGroup, FormRecord } from "@angular/forms";
4
+ import { ActivatedRoute, Router } from "@angular/router";
5
+ import { Subject, takeUntil } from "rxjs";
6
+ import { UtilsService } from "@hmcts/opal-frontend-common/services/utils-service";
7
+ var AbstractFormBaseComponent = class AbstractFormBaseComponent {
8
+ changeDetectorRef = inject(ChangeDetectorRef);
9
+ router = inject(Router);
10
+ activatedRoute = inject(ActivatedRoute);
11
+ unsavedChanges = new EventEmitter();
12
+ formSubmit = new EventEmitter();
13
+ utilsService = inject(UtilsService);
14
+ fieldErrors;
15
+ formSubmitted = false;
16
+ ngUnsubscribe = new Subject();
17
+ form;
18
+ formControlErrorMessages;
19
+ formErrorSummaryMessage;
20
+ formErrors;
21
+ constructor() {}
22
+ scroll(fieldId) {
23
+ const autocompleteLabel = document.querySelector(`label[for="${fieldId}-autocomplete"]`);
24
+ const regularLabel = document.querySelector(`label[for="${fieldId}"]`);
25
+ const fieldsetLegend = document.querySelector(`[id="${fieldId}"] .govuk-fieldset__legend`);
26
+ const labelTarget = autocompleteLabel ?? regularLabel ?? fieldsetLegend ?? null;
27
+ const focusableSelector = "input:not([type=\"hidden\"]), select, textarea, button, [tabindex]:not([tabindex=\"-1\"])";
28
+ let fieldElement = document.getElementById(`${fieldId}-autocomplete`) ?? document.getElementById(fieldId);
29
+ if (fieldElement && !this.canReceiveFocus(fieldElement)) {
30
+ const nestedFocusable = fieldElement.querySelector(focusableSelector);
31
+ if (nestedFocusable) fieldElement = nestedFocusable;
32
+ }
33
+ fieldElement ??= document.querySelector(`[id="${fieldId}"] ${focusableSelector}`);
34
+ if (labelTarget) labelTarget.scrollIntoView({ behavior: "smooth" });
35
+ else if (fieldElement) fieldElement.scrollIntoView({ behavior: "smooth" });
36
+ fieldElement?.focus();
37
+ }
38
+ canReceiveFocus(element) {
39
+ if (element.tabIndex >= 0 && !element.hasAttribute("disabled")) return true;
40
+ if (element instanceof HTMLAnchorElement && element.hasAttribute("href") && element.href) return !!element.href;
41
+ if ([
42
+ "INPUT",
43
+ "SELECT",
44
+ "TEXTAREA",
45
+ "BUTTON"
46
+ ].includes(element.tagName)) return !element.disabled;
47
+ return false;
48
+ }
49
+ getHighestPriorityError(errorKeys = [], fieldErrors = {}) {
50
+ if (errorKeys.length && Object.keys(fieldErrors).length) return [...errorKeys.map((errorType) => {
51
+ return {
52
+ ...fieldErrors[errorType],
53
+ type: errorType
54
+ };
55
+ })].sort((a, b) => a.priority - b.priority)[0];
56
+ return null;
57
+ }
58
+ getFieldErrorDetails(controlPath) {
59
+ const controlErrors = this.form.get(controlPath)?.errors;
60
+ if (controlErrors) {
61
+ const controlKey = controlPath.at(-1);
62
+ const errorKeys = Object.keys(controlErrors) || [];
63
+ const fieldErrors = controlKey === void 0 ? {} : this.fieldErrors[controlKey] || {};
64
+ if (errorKeys.length && Object.keys(fieldErrors).length) return this.getHighestPriorityError(errorKeys, fieldErrors);
65
+ }
66
+ return null;
67
+ }
68
+ getFormErrors(form, controlPath = []) {
69
+ const formControls = form.controls;
70
+ return Object.keys(formControls).filter((controlName) => formControls[controlName].invalid).flatMap((controlName) => {
71
+ const control = formControls[controlName];
72
+ if (control instanceof FormRecord) {
73
+ const recordFieldErrorDetails = this.getFieldErrorDetails([...controlPath, controlName]);
74
+ return {
75
+ fieldId: controlName,
76
+ message: recordFieldErrorDetails?.message ?? null,
77
+ priority: recordFieldErrorDetails?.priority ?? 999999999,
78
+ type: recordFieldErrorDetails?.type ?? null
79
+ };
80
+ }
81
+ if (control instanceof FormGroup) return this.getFormErrors(control, [...controlPath, controlName]);
82
+ if (control instanceof FormArray) return control.controls.flatMap((controlItem, index) => {
83
+ if (controlItem instanceof FormGroup) return this.getFormErrors(controlItem, [
84
+ ...controlPath,
85
+ controlName,
86
+ index
87
+ ]);
88
+ return [];
89
+ });
90
+ const getFieldErrorDetails = this.getFieldErrorDetails([...controlPath, controlName]);
91
+ return {
92
+ fieldId: controlName,
93
+ message: getFieldErrorDetails?.message ?? null,
94
+ priority: getFieldErrorDetails?.priority ?? 999999999,
95
+ type: getFieldErrorDetails?.type ?? null
96
+ };
97
+ }).filter((item) => item?.message !== null);
98
+ }
99
+ setErrorMessages(formErrors) {
100
+ this.formControlErrorMessages = {};
101
+ this.formErrorSummaryMessage = [];
102
+ for (const entry of formErrors) {
103
+ this.formControlErrorMessages[entry.fieldId] = entry.message;
104
+ this.formErrorSummaryMessage.push({
105
+ fieldId: entry.fieldId,
106
+ message: entry.message
107
+ });
108
+ }
109
+ }
110
+ getDateFieldsToRemoveIndexes() {
111
+ const indexesToRemove = [];
112
+ const foundIndexes = this.getFormErrorSummaryIndex([
113
+ "dayOfMonth",
114
+ "monthOfYear",
115
+ "year"
116
+ ], this.formErrorSummaryMessage);
117
+ switch (foundIndexes.length) {
118
+ case 3:
119
+ indexesToRemove.push(foundIndexes[1], foundIndexes[2]);
120
+ break;
121
+ case 2: indexesToRemove.push(foundIndexes[1]);
122
+ }
123
+ return indexesToRemove;
124
+ }
125
+ getFormErrorSummaryIndex(fieldIds, formErrorSummaryMessage) {
126
+ return fieldIds.reduce((acc, field) => {
127
+ const index = formErrorSummaryMessage.findIndex((error) => error.fieldId === field);
128
+ if (index === -1) return acc;
129
+ return [...acc, index];
130
+ }, []);
131
+ }
132
+ removeErrorSummaryMessages(formErrorSummaryMessage, indexes) {
133
+ return formErrorSummaryMessage.filter((_, index) => !indexes.includes(index));
134
+ }
135
+ splitFormErrors(fieldIds, formErrors) {
136
+ const cleanFormErrors = [];
137
+ const removedFormErrors = [];
138
+ for (const error of formErrors) if (fieldIds.includes(error.fieldId)) removedFormErrors.push(error);
139
+ else cleanFormErrors.push(error);
140
+ return [cleanFormErrors, removedFormErrors];
141
+ }
142
+ manipulateFormErrorMessage(fields, messageOverride, errorType, formErrors) {
143
+ const manipulatedFields = [];
144
+ for (const field of formErrors) {
145
+ if (fields.includes(field.fieldId)) {
146
+ if (field.type === errorType) manipulatedFields.push({
147
+ ...field,
148
+ message: messageOverride
149
+ });
150
+ else manipulatedFields.push(field);
151
+ continue;
152
+ }
153
+ manipulatedFields.push(field);
154
+ }
155
+ return manipulatedFields;
156
+ }
157
+ getHighPriorityFormErrors(formErrors) {
158
+ const lowestPriority = Math.min(...formErrors.map((item) => item.priority));
159
+ return formErrors.filter((item) => item.priority === lowestPriority);
160
+ }
161
+ focusAndScrollToErrorSummary() {
162
+ this.changeDetectorRef.detectChanges();
163
+ const errorSummary = document.querySelector(".govuk-error-summary");
164
+ if (errorSummary) {
165
+ errorSummary.focus({ preventScroll: true });
166
+ this.utilsService.scrollToTop();
167
+ }
168
+ }
169
+ setupListener() {
170
+ this.form.valueChanges.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => {
171
+ this.unsavedChanges.emit(this.hasUnsavedChanges());
172
+ });
173
+ }
174
+ addControlsToFormGroup(formGroup, controls, index) {
175
+ for (const { controlName, validators } of controls) formGroup.addControl(`${controlName}_${index}`, new FormControl(null, validators));
176
+ }
177
+ createFormControl(validators, initialValue = null) {
178
+ return new FormControl(initialValue, { validators: [...validators] });
179
+ }
180
+ handleErrorMessages() {
181
+ this.formErrors = this.getFormErrors(this.form);
182
+ this.setErrorMessages(this.formErrors);
183
+ this.formErrorSummaryMessage = this.removeErrorSummaryMessages(this.formErrorSummaryMessage, this.getDateFieldsToRemoveIndexes());
184
+ }
185
+ hasUnsavedChanges() {
186
+ return this.form.dirty && !this.formSubmitted;
187
+ }
188
+ setInputValue(value, controlPath) {
189
+ const control = this.form.get(controlPath);
190
+ if (control) {
191
+ control.patchValue(value);
192
+ control.markAsTouched();
193
+ }
194
+ }
195
+ handleDateInputFormErrors() {
196
+ const dateInputFields = [
197
+ "dayOfMonth",
198
+ "monthOfYear",
199
+ "year"
200
+ ];
201
+ const splitFormErrors = this.splitFormErrors(dateInputFields, this.formErrors);
202
+ const highPriorityDateControlErrors = this.getHighPriorityFormErrors(splitFormErrors[1]);
203
+ let manipulatedFormErrors = highPriorityDateControlErrors;
204
+ if (highPriorityDateControlErrors.length > 1) manipulatedFormErrors = this.manipulateFormErrorMessage(dateInputFields, "Please enter a DOB", "required", manipulatedFormErrors);
205
+ return [...splitFormErrors[0], ...manipulatedFormErrors];
206
+ }
207
+ setInitialErrorMessages() {
208
+ const formControls = this.form.controls;
209
+ const initialFormControlErrorMessages = {};
210
+ for (const controlName of Object.keys(formControls)) initialFormControlErrorMessages[controlName] = null;
211
+ this.formControlErrorMessages = initialFormControlErrorMessages;
212
+ this.formErrorSummaryMessage = [];
213
+ }
214
+ rePopulateForm(state) {
215
+ this.form.patchValue(state);
216
+ }
217
+ createControl(controlName, validators) {
218
+ this.form.addControl(controlName, new FormControl(null, validators));
219
+ }
220
+ updateControl(controlName, validators) {
221
+ const control = this.form.get(controlName);
222
+ if (control) {
223
+ control.setValidators(validators);
224
+ control.updateValueAndValidity();
225
+ } else this.createControl(controlName, validators);
226
+ }
227
+ removeControl(controlName) {
228
+ if (this.formControlErrorMessages[controlName]) this.removeControlErrors(controlName);
229
+ this.form.removeControl(controlName);
230
+ }
231
+ removeControlErrors(controlName) {
232
+ delete this.formControlErrorMessages[controlName];
233
+ }
234
+ clearAllErrorMessages() {
235
+ this.formControlErrorMessages = {};
236
+ this.formErrorSummaryMessage = [];
237
+ this.formErrors = [];
238
+ this.form.updateValueAndValidity({
239
+ onlySelf: false,
240
+ emitEvent: false
241
+ });
242
+ }
243
+ objectFromFormRecord(controlRecord, options) {
244
+ const mapKey = options?.mapKey ?? ((k) => k);
245
+ const mapValue = options?.mapValue ?? ((v) => v);
246
+ const result = {};
247
+ for (const [name, control] of Object.entries(controlRecord.controls)) result[mapKey(name)] = mapValue(control.value);
248
+ return result;
249
+ }
250
+ patchFormRecordFromObject(controlRecord, values, options) {
251
+ const emitEvent = options?.emitEvent ?? false;
252
+ const mapKey = options?.mapKey ?? String;
253
+ const isEqual = options?.isEqual ?? Object.is;
254
+ for (const [k, v] of Object.entries(values)) {
255
+ const controlName = mapKey(k);
256
+ const ctrl = controlRecord.get(controlName);
257
+ if (!ctrl) continue;
258
+ if (!isEqual(ctrl.value, v)) ctrl.setValue(v, { emitEvent });
259
+ }
260
+ }
261
+ handleClearForm() {
262
+ this.form.reset();
263
+ }
264
+ scrollTo(fieldId) {
265
+ this["scroll"](fieldId);
266
+ }
267
+ handleRoute(route, options) {
268
+ const { nonRelative = false, event, routeData, fragment } = options ?? {};
269
+ if (event) event.preventDefault();
270
+ this.unsavedChanges.emit(this.hasUnsavedChanges());
271
+ const navigationExtras = {
272
+ ...nonRelative ? {} : { relativeTo: this.activatedRoute.parent },
273
+ ...routeData ? { state: routeData } : {},
274
+ ...fragment ? { fragment } : {}
275
+ };
276
+ this.router.navigate([route], navigationExtras);
277
+ }
278
+ handleFormSubmit(event) {
279
+ this.handleErrorMessages();
280
+ if (this.form.valid) {
281
+ this.formSubmitted = true;
282
+ const nestedFlow = event.submitter ? event.submitter.className.includes("nested-flow") : false;
283
+ this.unsavedChanges.emit(this.hasUnsavedChanges());
284
+ this.formSubmit.emit({
285
+ formData: this.form.value,
286
+ nestedFlow
287
+ });
288
+ } else this.focusAndScrollToErrorSummary();
289
+ }
290
+ handleUppercaseInputMask(event) {
291
+ const input = event.target;
292
+ input.value = this.utilsService.upperCaseAllLetters(input.value);
293
+ }
294
+ ngOnInit() {
295
+ if (this.form) this.setupListener();
296
+ }
297
+ ngOnDestroy() {
298
+ this.ngUnsubscribe.next();
299
+ this.ngUnsubscribe.complete();
300
+ }
301
+ static ɵfac = i0.ɵɵngDeclareFactory({
302
+ minVersion: "12.0.0",
303
+ version: "21.2.25",
304
+ ngImport: i0,
305
+ type: AbstractFormBaseComponent,
306
+ deps: [],
307
+ target: i0.ɵɵFactoryTarget.Component
308
+ });
309
+ static ɵcmp = i0.ɵɵngDeclareComponent({
310
+ minVersion: "14.0.0",
311
+ version: "21.2.25",
312
+ type: AbstractFormBaseComponent,
313
+ isStandalone: true,
314
+ selector: "ng-component",
315
+ outputs: {
316
+ unsavedChanges: "unsavedChanges",
317
+ formSubmit: "formSubmit"
318
+ },
319
+ ngImport: i0,
320
+ template: "",
321
+ isInline: true
322
+ });
323
+ };
324
+ i0.ɵɵngDeclareClassMetadata({
325
+ minVersion: "12.0.0",
326
+ version: "21.2.25",
327
+ ngImport: i0,
328
+ type: AbstractFormBaseComponent,
329
+ decorators: [{
330
+ type: Component,
331
+ args: [{ template: "" }]
332
+ }],
333
+ ctorParameters: () => [],
334
+ propDecorators: {
335
+ unsavedChanges: [{ type: Output }],
336
+ formSubmit: [{ type: Output }]
337
+ }
338
+ });
616
339
  export { AbstractFormBaseComponent };
617
- //# sourceMappingURL=hmcts-opal-frontend-common-components-abstract-abstract-form-base.mjs.map
340
+
341
+ //# sourceMappingURL=hmcts-opal-frontend-common-components-abstract-abstract-form-base.mjs.map