@hmcts/opal-frontend-common 0.0.26 → 0.0.28

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 (203) hide show
  1. package/README.md +55 -0
  2. package/components/moj/moj-pagination/index.d.ts +46 -128
  3. package/directives/capitalisation/index.d.ts +1 -3
  4. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base.mjs +3 -3
  5. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base.mjs.map +1 -1
  6. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-array-base.mjs +3 -3
  7. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-array-base.mjs.map +1 -1
  8. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base.mjs +3 -3
  9. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base.mjs.map +1 -1
  10. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-base.mjs +3 -3
  11. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-base.mjs.map +1 -1
  12. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table-pagination.mjs +8 -8
  13. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table-pagination.mjs.map +1 -1
  14. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table.mjs +10 -10
  15. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-sortable-table.mjs.map +1 -1
  16. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-table-filter.mjs +10 -10
  17. package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-table-filter.mjs.map +1 -1
  18. package/fesm2022/hmcts-opal-frontend-common-components-alphagov-alphagov-accessible-autocomplete.mjs +3 -3
  19. package/fesm2022/hmcts-opal-frontend-common-components-alphagov-alphagov-accessible-autocomplete.mjs.map +1 -1
  20. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-account-information-custom-account-information-item-custom-account-information-item-label.mjs +3 -3
  21. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-account-information-custom-account-information-item-custom-account-information-item-label.mjs.map +1 -1
  22. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-account-information-custom-account-information-item-custom-account-information-item-value.mjs +3 -3
  23. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-account-information-custom-account-information-item-custom-account-information-item-value.mjs.map +1 -1
  24. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-account-information-custom-account-information-item.mjs +3 -3
  25. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-account-information-custom-account-information-item.mjs.map +1 -1
  26. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-account-information.mjs +3 -3
  27. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-account-information.mjs.map +1 -1
  28. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-action-links.mjs +3 -3
  29. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-action-links.mjs.map +1 -1
  30. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-horizontal-scroll-pane.mjs +3 -3
  31. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-horizontal-scroll-pane.mjs.map +1 -1
  32. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-page-header.mjs +3 -3
  33. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-page-header.mjs.map +1 -1
  34. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-scrollable-panes-custom-scrollable-panes-inner-pane.mjs +3 -3
  35. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-scrollable-panes-custom-scrollable-panes-inner-pane.mjs.map +1 -1
  36. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-scrollable-panes.mjs +3 -3
  37. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-scrollable-panes.mjs.map +1 -1
  38. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar-custom-summary-metric-bar-item-custom-summary-metric-bar-item-label.mjs +3 -3
  39. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar-custom-summary-metric-bar-item-custom-summary-metric-bar-item-label.mjs.map +1 -1
  40. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar-custom-summary-metric-bar-item-custom-summary-metric-bar-item-value.mjs +3 -3
  41. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar-custom-summary-metric-bar-item-custom-summary-metric-bar-item-value.mjs.map +1 -1
  42. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar-custom-summary-metric-bar-item.mjs +3 -3
  43. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar-custom-summary-metric-bar-item.mjs.map +1 -1
  44. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar.mjs +3 -3
  45. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-summary-metric-bar.mjs.map +1 -1
  46. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-vertical-scroll-pane-custom-vertical-scroll-pane-inner-pane.mjs +3 -3
  47. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-vertical-scroll-pane-custom-vertical-scroll-pane-inner-pane.mjs.map +1 -1
  48. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-vertical-scroll-pane-custom-vertical-scroll-pane-outer-pane.mjs +3 -3
  49. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-vertical-scroll-pane-custom-vertical-scroll-pane-outer-pane.mjs.map +1 -1
  50. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-vertical-scroll-pane.mjs +3 -3
  51. package/fesm2022/hmcts-opal-frontend-common-components-custom-custom-vertical-scroll-pane.mjs.map +1 -1
  52. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-accordion.mjs +3 -3
  53. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-accordion.mjs.map +1 -1
  54. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-back-link.mjs +3 -3
  55. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-back-link.mjs.map +1 -1
  56. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-button.mjs +3 -3
  57. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-button.mjs.map +1 -1
  58. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-cancel-link.mjs +3 -3
  59. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-cancel-link.mjs.map +1 -1
  60. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-checkboxes.mjs +12 -12
  61. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-checkboxes.mjs.map +1 -1
  62. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-date-input.mjs +3 -3
  63. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-date-input.mjs.map +1 -1
  64. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-details.mjs +3 -3
  65. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-details.mjs.map +1 -1
  66. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-error-summary.mjs +3 -3
  67. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-error-summary.mjs.map +1 -1
  68. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-footer.mjs +3 -3
  69. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-footer.mjs.map +1 -1
  70. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-header.mjs +6 -6
  71. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-header.mjs.map +1 -1
  72. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-heading-with-caption.mjs +3 -3
  73. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-heading-with-caption.mjs.map +1 -1
  74. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-inset-text.mjs +3 -3
  75. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-inset-text.mjs.map +1 -1
  76. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-list-govuk-list-link.mjs +3 -3
  77. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-list-govuk-list-link.mjs.map +1 -1
  78. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-list.mjs +3 -3
  79. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-list.mjs.map +1 -1
  80. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-notification-banner.mjs +3 -3
  81. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-notification-banner.mjs.map +1 -1
  82. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-pagination.mjs +5 -5
  83. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-pagination.mjs.map +1 -1
  84. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-panel.mjs +3 -3
  85. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-panel.mjs.map +1 -1
  86. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-radio.mjs +12 -12
  87. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-radio.mjs.map +1 -1
  88. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-select.mjs +3 -3
  89. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-select.mjs.map +1 -1
  90. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-summary-card-list.mjs +6 -6
  91. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-summary-card-list.mjs.map +1 -1
  92. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-summary-list.mjs +12 -12
  93. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-summary-list.mjs.map +1 -1
  94. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-table.mjs +12 -12
  95. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-table.mjs.map +1 -1
  96. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.mjs +3 -3
  97. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.mjs.map +1 -1
  98. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-panel.mjs +3 -3
  99. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-panel.mjs.map +1 -1
  100. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs.mjs +3 -3
  101. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs.mjs.map +1 -1
  102. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tag.mjs +3 -3
  103. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tag.mjs.map +1 -1
  104. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-task-list.mjs +6 -6
  105. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-task-list.mjs.map +1 -1
  106. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-text-area.mjs +3 -3
  107. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-text-area.mjs.map +1 -1
  108. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-text-input-prefix-suffix.mjs +3 -3
  109. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-text-input-prefix-suffix.mjs.map +1 -1
  110. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-text-input.mjs +3 -3
  111. package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-text-input.mjs.map +1 -1
  112. package/fesm2022/hmcts-opal-frontend-common-components-hod-hod-loading-spinner.mjs +3 -3
  113. package/fesm2022/hmcts-opal-frontend-common-components-hod-hod-loading-spinner.mjs.map +1 -1
  114. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-alert.mjs +25 -29
  115. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-alert.mjs.map +1 -1
  116. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-badge.mjs +3 -3
  117. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-badge.mjs.map +1 -1
  118. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-button-menu-moj-button-menu-item.mjs +3 -3
  119. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-button-menu-moj-button-menu-item.mjs.map +1 -1
  120. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-button-menu.mjs +3 -3
  121. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-button-menu.mjs.map +1 -1
  122. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-date-picker.mjs +3 -3
  123. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-date-picker.mjs.map +1 -1
  124. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-header.mjs +3 -3
  125. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-header.mjs.map +1 -1
  126. 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 +3 -3
  127. 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.map +1 -1
  128. 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 +3 -3
  129. 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.map +1 -1
  130. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-option.mjs +3 -3
  131. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-option.mjs.map +1 -1
  132. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-selected-moj-filter-panel-selected-tag.mjs +3 -3
  133. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-selected-moj-filter-panel-selected-tag.mjs.map +1 -1
  134. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-selected.mjs +3 -3
  135. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel-moj-filter-panel-selected.mjs.map +1 -1
  136. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel.mjs +3 -3
  137. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter-moj-filter-panel.mjs.map +1 -1
  138. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter.mjs +3 -3
  139. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-filter.mjs.map +1 -1
  140. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-header.mjs +6 -6
  141. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-header.mjs.map +1 -1
  142. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-notification-badge.mjs +3 -3
  143. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-notification-badge.mjs.map +1 -1
  144. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-page-header.mjs +3 -3
  145. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-page-header.mjs.map +1 -1
  146. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-pagination.mjs +104 -226
  147. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-pagination.mjs.map +1 -1
  148. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-primary-navigation.mjs +6 -6
  149. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-primary-navigation.mjs.map +1 -1
  150. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-sortable-table.mjs +22 -26
  151. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-sortable-table.mjs.map +1 -1
  152. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-sub-navigation.mjs +6 -6
  153. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-sub-navigation.mjs.map +1 -1
  154. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-ticket-panel.mjs +3 -3
  155. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-ticket-panel.mjs.map +1 -1
  156. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-timeline.mjs +6 -6
  157. package/fesm2022/hmcts-opal-frontend-common-components-moj-moj-timeline.mjs.map +1 -1
  158. package/fesm2022/hmcts-opal-frontend-common-directives-capitalisation.mjs +7 -10
  159. package/fesm2022/hmcts-opal-frontend-common-directives-capitalisation.mjs.map +1 -1
  160. package/fesm2022/hmcts-opal-frontend-common-directives-govuk-button.mjs +3 -3
  161. package/fesm2022/hmcts-opal-frontend-common-directives-govuk-button.mjs.map +1 -1
  162. package/fesm2022/{hmcts-opal-frontend-common-pages-access-denied.component-hjYG8Hhi.mjs → hmcts-opal-frontend-common-pages-access-denied.component-0Pl64thA.mjs} +4 -4
  163. package/fesm2022/{hmcts-opal-frontend-common-pages-access-denied.component-hjYG8Hhi.mjs.map → hmcts-opal-frontend-common-pages-access-denied.component-0Pl64thA.mjs.map} +1 -1
  164. package/fesm2022/{hmcts-opal-frontend-common-pages-sign-in-stub.component-joWzJ-cV.mjs → hmcts-opal-frontend-common-pages-sign-in-stub.component-DvQOlQMW.mjs} +4 -4
  165. package/fesm2022/{hmcts-opal-frontend-common-pages-sign-in-stub.component-joWzJ-cV.mjs.map → hmcts-opal-frontend-common-pages-sign-in-stub.component-DvQOlQMW.mjs.map} +1 -1
  166. package/fesm2022/{hmcts-opal-frontend-common-pages-sign-in.component-JCBGIMBe.mjs → hmcts-opal-frontend-common-pages-sign-in.component-yuoev8a3.mjs} +4 -4
  167. package/fesm2022/{hmcts-opal-frontend-common-pages-sign-in.component-JCBGIMBe.mjs.map → hmcts-opal-frontend-common-pages-sign-in.component-yuoev8a3.mjs.map} +1 -1
  168. package/fesm2022/hmcts-opal-frontend-common-pages.mjs +2 -2
  169. package/fesm2022/hmcts-opal-frontend-common-pipes-date-format.mjs +7 -10
  170. package/fesm2022/hmcts-opal-frontend-common-pipes-date-format.mjs.map +1 -1
  171. package/fesm2022/hmcts-opal-frontend-common-pipes-days-ago.mjs +3 -3
  172. package/fesm2022/hmcts-opal-frontend-common-pipes-days-ago.mjs.map +1 -1
  173. package/fesm2022/hmcts-opal-frontend-common-pipes-national-insurance.mjs +3 -3
  174. package/fesm2022/hmcts-opal-frontend-common-pipes-national-insurance.mjs.map +1 -1
  175. package/fesm2022/hmcts-opal-frontend-common-resolvers-title.mjs +7 -10
  176. package/fesm2022/hmcts-opal-frontend-common-resolvers-title.mjs.map +1 -1
  177. package/fesm2022/hmcts-opal-frontend-common-services-app-initializer-service.mjs +3 -3
  178. package/fesm2022/hmcts-opal-frontend-common-services-app-initializer-service.mjs.map +1 -1
  179. package/fesm2022/hmcts-opal-frontend-common-services-app-insights-service.mjs +3 -3
  180. package/fesm2022/hmcts-opal-frontend-common-services-app-insights-service.mjs.map +1 -1
  181. package/fesm2022/hmcts-opal-frontend-common-services-auth-service.mjs +3 -3
  182. package/fesm2022/hmcts-opal-frontend-common-services-auth-service.mjs.map +1 -1
  183. package/fesm2022/hmcts-opal-frontend-common-services-date-service.mjs +3 -3
  184. package/fesm2022/hmcts-opal-frontend-common-services-date-service.mjs.map +1 -1
  185. package/fesm2022/hmcts-opal-frontend-common-services-launch-darkly-service.mjs +3 -3
  186. package/fesm2022/hmcts-opal-frontend-common-services-launch-darkly-service.mjs.map +1 -1
  187. package/fesm2022/hmcts-opal-frontend-common-services-permissions-service.mjs +3 -3
  188. package/fesm2022/hmcts-opal-frontend-common-services-permissions-service.mjs.map +1 -1
  189. package/fesm2022/hmcts-opal-frontend-common-services-session-service.mjs +3 -3
  190. package/fesm2022/hmcts-opal-frontend-common-services-session-service.mjs.map +1 -1
  191. package/fesm2022/hmcts-opal-frontend-common-services-sort-service.mjs +3 -3
  192. package/fesm2022/hmcts-opal-frontend-common-services-sort-service.mjs.map +1 -1
  193. package/fesm2022/hmcts-opal-frontend-common-services-transfer-state-service.mjs +12 -20
  194. package/fesm2022/hmcts-opal-frontend-common-services-transfer-state-service.mjs.map +1 -1
  195. package/fesm2022/hmcts-opal-frontend-common-services-transformation-service.mjs +3 -3
  196. package/fesm2022/hmcts-opal-frontend-common-services-transformation-service.mjs.map +1 -1
  197. package/fesm2022/hmcts-opal-frontend-common-services-utils-service.mjs +3 -3
  198. package/fesm2022/hmcts-opal-frontend-common-services-utils-service.mjs.map +1 -1
  199. package/package.json +3 -3
  200. package/pipes/date-format/index.d.ts +0 -2
  201. package/resolvers/title/index.d.ts +0 -2
  202. package/services/transfer-state-service/index.d.ts +3 -5
  203. package/styles/styles.scss +15 -1
package/README.md CHANGED
@@ -183,3 +183,58 @@ The following commands are available in the `package.json`:
183
183
 
184
184
  - `yarn prettier:fix`
185
185
  Automatically formats files using Prettier.
186
+
187
+ ## Angular code LLM prompts
188
+
189
+ https://angular.dev/ai/develop-with-ai
190
+
191
+ Paste the following prompt into your AI assistant of choice.
192
+
193
+ ```markdown
194
+ You are an expert in TypeScript, Angular, and scalable web application development. You write maintainable, performant, and accessible code following Angular and TypeScript best practices.
195
+
196
+ ## TypeScript Best Practices
197
+
198
+ - Use strict type checking
199
+ - Prefer type inference when the type is obvious
200
+ - Avoid the `any` type; use `unknown` when type is uncertain
201
+
202
+ ## Angular Best Practices
203
+
204
+ - Always use standalone components over NgModules
205
+ - Do NOT set `standalone: true` inside the `@Component`, `@Directive` and `@Pipe` decorators
206
+ - Use signals for state management
207
+ - Implement lazy loading for feature routes
208
+ - Use `NgOptimizedImage` for all static images.
209
+ - Do NOT use the `@HostBinding` and `@HostListener` decorators. Put host bindings inside the `host` object of the `@Component` or `@Directive` decorator instead
210
+
211
+ ## Components
212
+
213
+ - Keep components small and focused on a single responsibility
214
+ - Use `input()` and `output()` functions instead of decorators
215
+ - Use `computed()` for derived state
216
+ - Set `changeDetection: ChangeDetectionStrategy.OnPush` in `@Component` decorator
217
+ - Prefer inline templates for small components
218
+ - Prefer Reactive forms instead of Template-driven ones
219
+ - Do NOT use `ngClass`, use `class` bindings instead
220
+ - DO NOT use `ngStyle`, use `style` bindings instead
221
+
222
+ ## State Management
223
+
224
+ - Use signals for local component state
225
+ - Use `computed()` for derived state
226
+ - Keep state transformations pure and predictable
227
+ - Do NOT use `mutate` on signals, use `update` or `set` instead
228
+
229
+ ## Templates
230
+
231
+ - Keep templates simple and avoid complex logic
232
+ - Use native control flow (`@if`, `@for`, `@switch`) instead of `*ngIf`, `*ngFor`, `*ngSwitch`
233
+ - Use the async pipe to handle observables
234
+
235
+ ## Services
236
+
237
+ - Design services around a single responsibility
238
+ - Use the `providedIn: 'root'` option for singleton services
239
+ - Use the `inject()` function instead of constructor injection
240
+ ```
@@ -1,165 +1,83 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, OnChanges } from '@angular/core';
3
-
4
- declare class MojPaginationItemComponent {
5
- class: string;
6
- static ɵfac: i0.ɵɵFactoryDeclaration<MojPaginationItemComponent, never>;
7
- static ɵcmp: i0.ɵɵComponentDeclaration<MojPaginationItemComponent, "opal-lib-moj-pagination-item , [opal-lib-moj-pagination-item]", never, {}, {}, never, ["*"], true, never>;
8
- }
9
-
10
- declare class MojPaginationLinkComponent {
11
- page: number | string;
12
- currentPage: number;
13
- totalPages: number;
14
- changePage: EventEmitter<number>;
15
- /**
16
- * Checks if the given page number is not the current page.
17
- *
18
- * @param page - The page number to check.
19
- * @returns A boolean indicating whether the given page is not the current page.
20
- */
21
- private pageIsNotCurrentPage;
22
- /**
23
- * Checks if the given page number is not negative.
24
- *
25
- * @param page - The page number to check.
26
- * @returns `true` if the page number is greater than 0, otherwise `false`.
27
- */
28
- private pageIsNotNegative;
29
- /**
30
- * Checks if the given page number is not greater than the total number of pages.
31
- *
32
- * @param page - The page number to check.
33
- * @returns `true` if the page number is less than or equal to the total number of pages, otherwise `false`.
34
- */
35
- private pageIsNotGreaterThanTotalPages;
36
- /**
37
- * Handles the page change event.
38
- *
39
- * @param event - The mouse event that triggered the page change.
40
- * @param page - The page number to change to.
41
- *
42
- * Prevents the default action of the event and checks if the page number is valid.
43
- * A valid page number is one that is not the current page, is greater than 0,
44
- * and is less than or equal to the total number of pages.
45
- * If the page number is valid, emits the changePage event with the new page number.
46
- */
47
- changePageEvent(event: MouseEvent, page: number): void;
48
- static ɵfac: i0.ɵɵFactoryDeclaration<MojPaginationLinkComponent, never>;
49
- static ɵcmp: i0.ɵɵComponentDeclaration<MojPaginationLinkComponent, "opal-lib-moj-pagination-link", never, { "page": { "alias": "page"; "required": true; }; "currentPage": { "alias": "currentPage"; "required": true; }; "totalPages": { "alias": "totalPages"; "required": true; }; "changePage": { "alias": "changePage"; "required": false; }; }, {}, never, ["*"], true, never>;
50
- }
51
-
52
- declare class MojPaginationListComponent {
53
- class: string;
54
- static ɵfac: i0.ɵɵFactoryDeclaration<MojPaginationListComponent, never>;
55
- static ɵcmp: i0.ɵɵComponentDeclaration<MojPaginationListComponent, "opal-lib-moj-pagination-list , [opal-lib-moj-pagination-list]", never, {}, {}, never, ["*"], true, never>;
56
- }
2
+ import { OnChanges, EventEmitter } from '@angular/core';
57
3
 
58
4
  declare class MojPaginationComponent implements OnChanges {
5
+ private readonly pages;
6
+ id: string;
59
7
  currentPage: number;
60
8
  total: number;
61
- maxPagesToShow: number;
62
9
  limit: number;
63
- ariaLabel: string;
64
10
  changePage: EventEmitter<number>;
65
- pages: i0.WritableSignal<(string | number)[]>;
66
- totalPages: i0.WritableSignal<number>;
67
- startItem: i0.WritableSignal<number>;
68
- endItem: i0.WritableSignal<number>;
69
- totalItems: i0.WritableSignal<number>;
11
+ readonly elipsedPages: i0.WritableSignal<(string | number)[]>;
12
+ readonly ELIPSIS = "\u2026";
70
13
  /**
71
- * Updates the pagination signals based on the current state.
72
- *
73
- * This method recalculates and sets the following signals:
74
- * - `totalPages`: The total number of pages based on the total items and items per page limit.
75
- * - `startItem`: The index of the first item on the current page.
76
- * - `endItem`: The index of the last item on the current page.
77
- * - `pages`: The array of page numbers to be displayed.
78
- * - `totalItems`: The total number of items.
14
+ * Gets the total number of pages available.
79
15
  *
80
- * @private
16
+ * @returns The total count of pages as a number.
81
17
  */
82
- private setSignals;
18
+ get totalPages(): number;
83
19
  /**
84
- * Calculates the total number of pages based on the total number of items and the limit of items per page.
20
+ * Gets the starting item index for the current page in a paginated list.
85
21
  *
86
- * @param total - The total number of items.
87
- * @param limit - The number of items per page.
88
- * @returns The total number of pages.
89
- */
90
- private getTotalPages;
91
- /**
92
- * Sets the pagination pages based on the current page and total pages.
93
- * This method updates the `pages` property with the result of the `getPages` method.
22
+ * @returns {number} The index of the first item on the current page, or 0 if there are no items.
94
23
  *
95
- * @private
24
+ * If `total` is 0, returns 0. Otherwise, calculates the starting index based on the current page and the limit per page.
96
25
  */
97
- private setPages;
26
+ get pageStart(): number;
98
27
  /**
99
- * Calculates the starting item index for pagination.
28
+ * Gets the index of the last item on the current page.
100
29
  *
101
- * @param currentPage - The current page number.
102
- * @param limit - The number of items per page.
103
- * @returns The starting item index for the given page.
30
+ * @returns {number} The index of the last item displayed on the current page.
31
+ * Returns 0 if there are no items (`total` is 0). Otherwise, returns the lesser of
32
+ * `currentPage * limit` and `total`, ensuring the end index does not exceed the total number of items.
104
33
  */
105
- private getStartItem;
34
+ get pageEnd(): number;
106
35
  /**
107
- * Calculates the end item index for pagination.
36
+ * Calculates and updates the pagination pages and elided (skipped) pages based on the current limit and total items.
108
37
  *
109
- * @param currentPage - The current page number.
110
- * @param limit - The number of items per page.
111
- * @param total - The total number of items.
112
- * @returns The index of the last item on the current page, or the total number of items if the end of the list is reached.
113
- */
114
- private getEndItem;
115
- /**
116
- * Updates the total number of items by setting the value of `totalItems` to the current `total`.
38
+ * - If either `limit` or `total` is less than or equal to zero, clears the pages and elided pages.
39
+ * - Otherwise, computes the total number of pages, updates the `pages` observable with the full range,
40
+ * and updates the `elipsedPages` observable with the result of skipping pages for ellipsis display.
117
41
  *
118
42
  * @private
119
43
  */
120
- private setTotalItems;
44
+ private calculatePages;
121
45
  /**
122
- * Generates an array of page numbers and ellipses for pagination display.
46
+ * Generates an array of numbers starting from `start` up to, but not including, `end`.
123
47
  *
124
- * @param currentPage - The current active page number.
125
- * @param totalPages - The total number of pages available.
126
- * @returns An array of page numbers and ellipses representing the pagination.
127
- *
128
- * The function ensures that the pagination display shows a maximum of 5 pages at a time.
129
- * It calculates the range of pages to display based on the current page and total pages.
130
- * If the start page is greater than 1, it adds an ellipsis and the first page at the beginning.
131
- * If the end page is less than the total pages, it adds an ellipsis and the last page at the end.
48
+ * @param start - The starting number of the range (inclusive).
49
+ * @param end - The ending number of the range (exclusive).
50
+ * @returns An array of numbers from `start` to `end - 1`.
132
51
  */
133
- private getPages;
52
+ private range;
134
53
  /**
135
- * Calculates the start page for pagination based on the current page, total pages, and the number of pages to show on either side of the current page.
54
+ * Generates a pagination array with ellipses ("...") to represent skipped page ranges.
55
+ *
56
+ * The resulting array always includes the first and last page numbers, the current page,
57
+ * and up to one page before and after the current page. Ellipses are inserted where
58
+ * there are skipped ranges between the displayed pages.
136
59
  *
137
- * @param currentPage - The current active page number.
138
- * @param totalPages - The total number of pages available.
139
- * @param halfPagesToShow - The number of pages to show on either side of the current page.
140
- * @returns The start page number for pagination.
60
+ * @param pages - An array of page numbers representing all available pages.
61
+ * @param currentPage - The currently active page number.
62
+ * @returns An array containing page numbers and ellipsis strings ("...") to indicate skipped pages.
141
63
  */
142
- private calculateStartPage;
64
+ private elipseSkippedPages;
143
65
  /**
144
- * Calculates the end page number for pagination based on the current page, total pages, and the number of pages to show.
66
+ * Handles the page change event for the pagination component.
145
67
  *
146
- * @param currentPage - The current page number.
147
- * @param totalPages - The total number of pages.
148
- * @param halfPagesToShow - Half the number of pages to show around the current page.
149
- * @returns The calculated end page number.
68
+ * Prevents the default action of the event (if provided) and emits the selected page number.
69
+ *
70
+ * @param event - The event triggered by the page change action. If provided, its default behavior will be prevented.
71
+ * @param page - The page number to navigate to.
150
72
  */
151
- private calculateEndPage;
73
+ onPageChanged(event: Event, page: number): void;
152
74
  /**
153
- * Generates an array of page numbers from the startPage to the endPage.
154
- *
155
- * @param startPage - The starting page number.
156
- * @param endPage - The ending page number.
157
- * @returns An array of page numbers from startPage to endPage.
75
+ * Lifecycle hook that is called when any data-bound property of the component changes.
76
+ * Invokes the `calculatePages` method to update the pagination state based on the new input values.
158
77
  */
159
- private generatePageNumbers;
160
78
  ngOnChanges(): void;
161
79
  static ɵfac: i0.ɵɵFactoryDeclaration<MojPaginationComponent, never>;
162
- static ɵcmp: i0.ɵɵComponentDeclaration<MojPaginationComponent, "opal-lib-moj-pagination,", never, { "currentPage": { "alias": "currentPage"; "required": false; }; "total": { "alias": "total"; "required": false; }; "maxPagesToShow": { "alias": "maxPagesToShow"; "required": false; }; "limit": { "alias": "limit"; "required": false; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; }; }, { "changePage": "changePage"; }, never, never, true, never>;
80
+ static ɵcmp: i0.ɵɵComponentDeclaration<MojPaginationComponent, "opal-lib-moj-pagination", never, { "id": { "alias": "id"; "required": true; }; "currentPage": { "alias": "currentPage"; "required": true; }; "total": { "alias": "total"; "required": true; }; "limit": { "alias": "limit"; "required": true; }; }, { "changePage": "changePage"; }, never, never, true, never>;
163
81
  }
164
82
 
165
- export { MojPaginationComponent, MojPaginationItemComponent, MojPaginationLinkComponent, MojPaginationListComponent };
83
+ export { MojPaginationComponent };
@@ -1,13 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { OnInit, OnDestroy } from '@angular/core';
3
3
  import { AbstractControl } from '@angular/forms';
4
- import { UtilsService } from '@hmcts/opal-frontend-common/services/utils-service';
5
4
 
6
5
  declare class CapitalisationDirective implements OnInit, OnDestroy {
7
- private readonly utilsService;
8
6
  private readonly destroy$;
7
+ private readonly utilsService;
9
8
  control: AbstractControl;
10
- constructor(utilsService: UtilsService);
11
9
  ngOnInit(): void;
12
10
  ngOnDestroy(): void;
13
11
  static ɵfac: i0.ɵɵFactoryDeclaration<CapitalisationDirective, never>;
@@ -190,10 +190,10 @@ class AbstractFormAliasBaseComponent extends AbstractFormBaseComponent {
190
190
  this['ngUnsubscribe'].complete();
191
191
  super.ngOnDestroy();
192
192
  }
193
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AbstractFormAliasBaseComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
194
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: AbstractFormAliasBaseComponent, isStandalone: true, selector: "ng-component", usesInheritance: true, ngImport: i0, template: '', isInline: true });
193
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: AbstractFormAliasBaseComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
194
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.4", type: AbstractFormAliasBaseComponent, isStandalone: true, selector: "ng-component", usesInheritance: true, ngImport: i0, template: '', isInline: true });
195
195
  }
196
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AbstractFormAliasBaseComponent, decorators: [{
196
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: AbstractFormAliasBaseComponent, decorators: [{
197
197
  type: Component,
198
198
  args: [{
199
199
  template: '',
@@ -1 +1 @@
1
- {"version":3,"file":"hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base.mjs","sources":["../../../projects/opal-frontend-common/components/abstract/abstract-form-alias-base/abstract-form-alias-base.component.ts","../../../projects/opal-frontend-common/components/abstract/abstract-form-alias-base/hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base.ts"],"sourcesContent":["import { FormArray, FormControl, FormGroup, ValidatorFn } from '@angular/forms';\nimport { takeUntil } from 'rxjs';\nimport { Component, OnDestroy, OnInit } from '@angular/core';\nimport { IAbstractFormAliasBaseAliasControls } from '@hmcts/opal-frontend-common/components/abstract/abstract-form-alias-base/interfaces';\nimport { AbstractFormBaseComponent } from '@hmcts/opal-frontend-common/components/abstract/abstract-form-base';\nimport {\n IAbstractFormArrayControlValidation,\n IAbstractFormArrayControls,\n IAbstractFormArrayControl,\n} from '@hmcts/opal-frontend-common/components/abstract/interfaces';\n\n@Component({\n template: '',\n})\nexport abstract class AbstractFormAliasBaseComponent extends AbstractFormBaseComponent implements OnInit, OnDestroy {\n public aliasControls: IAbstractFormAliasBaseAliasControls[] = [];\n public aliasControlsValidation: IAbstractFormArrayControlValidation[] = [];\n public aliasFields: string[] = [];\n\n /**\n * Builds an array of form controls for the given form array.\n *\n * @param formControlCount - An array of numbers representing the number of form controls to create.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - An array of field names.\n * @param controlValidation - An array of control validation objects.\n * @returns An array of form controls for the given form array.\n */\n private buildFormAliasControls(\n formControlCount: number[],\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): IAbstractFormArrayControls[] {\n // Directly map each index to a control\n return formControlCount.map((_element, index) =>\n this.addAliasControls(index, formArrayName, fieldNames, controlValidation),\n );\n }\n\n /**\n * Adds alias controls to the form array.\n *\n * @param index - The index of the form array.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - The names of the fields for the alias controls.\n * @param controlValidation - The validation rules for the alias controls.\n * @returns An object containing the form controls.\n */\n private addAliasControls(\n index: number,\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): { [key: string]: IAbstractFormArrayControl } {\n const formAliases = this.form.get(formArrayName) as FormArray;\n const formAliasesFormGroup = new FormGroup({});\n\n // Create the form controls...\n const controls = this.createAliasControls(fieldNames, index);\n\n // Add the controls to the form group...\n this.addControlsToFormGroup(formAliasesFormGroup, controlValidation, index);\n\n // Add the form group to the form array...\n formAliases.push(formAliasesFormGroup);\n\n // Return the form controls...\n return controls;\n }\n\n /**\n * Removes all form alias controls from a FormArray and clears any associated error messages.\n *\n * @param formArrayControls - An array of form array controls.\n * @param formArrayName - The name of the FormArray.\n * @param fieldNames - An array of field names associated with the form array controls.\n * @returns An empty array of form array controls.\n */\n private removeAllFormAliasControls(\n formArrayControls: IAbstractFormArrayControls[],\n formArrayName: string,\n fieldNames: string[],\n ): [] {\n const control = this.form.get(formArrayName) as FormArray;\n\n // Clear the error messages...\n [...formArrayControls].forEach((_element, index) => {\n this.removeFormAliasControlsErrors(index, formArrayControls, fieldNames);\n });\n\n // Reset the form array controls...\n control.clear();\n\n // Return en empty array of form array controls...\n return [];\n }\n\n /**\n * Creates a FormArray with the specified validators and controls.\n *\n * @param validators - An array of validators to apply to the FormArray.\n * @param controls - An optional array of initial FormControl instances to add to the FormArray.\n * @returns A new FormArray instance.\n */\n protected createFormAlias(validators: ValidatorFn[], controls: FormControl[] = []): FormArray {\n return new FormArray(controls, { validators: [...validators] });\n }\n\n /**\n * Removes a form alias control at the specified index from the given form array controls.\n *\n * @param index - The index of the form alias control to remove.\n * @param formArrayControls - The array of form array controls.\n * @returns The updated array of form array controls after removing the specified control.\n */\n protected removeFormAliasControl(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n ): IAbstractFormArrayControls[] {\n formArrayControls.splice(index, 1);\n return formArrayControls;\n }\n\n /**\n * Sets up the alias form controls based on the provided alias count array and form array name.\n * If there are any aliases, the alias controls will be re-populated.\n *\n * @param aliasCountArray - An array containing the count of aliases.\n * @param formArrayName - The name of the form array.\n */\n protected setupAliasFormControls(aliasCountArray: number[], formArrayName: string): void {\n // Re-populate the alias controls if there are any aliases\n if (aliasCountArray.length) {\n this.aliasControls = this.buildFormAliasControls(\n aliasCountArray,\n formArrayName,\n this.aliasFields,\n this.aliasControlsValidation,\n );\n }\n }\n\n /**\n * Removes the form alias controls errors for a specific index in a form array.\n *\n * @param index - The index of the form array control.\n * @param formArrayControls - An array of form array controls.\n * @param fieldNames - An array of field names to remove errors from.\n */\n protected removeFormAliasControlsErrors(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): void {\n const formArrayControl = formArrayControls[index];\n\n if (formArrayControl) {\n fieldNames.forEach((field) => {\n delete this.formControlErrorMessages?.[formArrayControl[field].controlName];\n });\n }\n }\n\n /**\n * Creates alias controls for the given fields and index.\n * @param fields - The list of fields for which alias controls need to be created.\n * @param index - The index value used to generate unique identifiers for the controls.\n * @returns An object containing the alias controls.\n */\n protected createAliasControls(fields: string[], index: number): { [key: string]: IAbstractFormArrayControl } {\n return fields.reduce(\n (controls, field) => ({\n ...controls,\n [field]: {\n inputId: `${field}_${index}`,\n inputName: `${field}_${index}`,\n controlName: `${field}_${index}`,\n },\n }),\n {},\n );\n }\n\n /**\n * Sets up the alias checkbox listener.\n *\n * @param formCheckboxName - The name of the checkbox control in the form.\n * @param formArrayName - The name of the form array control in the form.\n */\n protected setUpAliasCheckboxListener(formCheckboxName: string, formArrayName: string): void {\n // Ensure any existing subscription is cleared to avoid memory leaks\n this['ngUnsubscribe'].next();\n this['ngUnsubscribe'].complete();\n\n const addAliasControl = this.form.get(formCheckboxName);\n if (!addAliasControl) {\n return;\n }\n\n addAliasControl.valueChanges.pipe(takeUntil(this['ngUnsubscribe'])).subscribe((shouldAddAlias) => {\n this.aliasControls = shouldAddAlias\n ? this.buildFormAliasControls([0], formArrayName, this.aliasFields, this.aliasControlsValidation)\n : this.removeAllFormAliasControls(this.aliasControls, formArrayName, this.aliasFields);\n });\n }\n\n /**\n * Removes a form alias control from a form array and updates the list of form array controls.\n * @param index - The index of the form alias control to be removed.\n * @param formArrayName - The name of the form array.\n * @param formArrayControls - The list of form array controls.\n * @param fieldNames - The names of the fields associated with the form array controls.\n * @returns The updated list of form array controls after removing the specified control.\n */\n public removeFormAliasControls(\n index: number,\n formArrayName: string,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): IAbstractFormArrayControls[] {\n // Get the form array...\n const control = this.form.get(formArrayName) as FormArray;\n\n // Remove the form array control based on index\n control.removeAt(index);\n\n // Then remove the form array controls errors...\n this.removeFormAliasControlsErrors(index, formArrayControls, fieldNames);\n\n // Return the new list of form array controls...\n return this.removeFormAliasControl(index, formArrayControls);\n }\n\n /**\n * Adds an alias to the specified index of the form array.\n *\n * @param index - The index at which to add the alias.\n * @param formArrayName - The name of the form array.\n */\n public addAlias(index: number, formArrayName: string): void {\n this.aliasControls.push(\n this.addAliasControls(index, formArrayName, this.aliasFields, this.aliasControlsValidation),\n );\n }\n\n /**\n * Removes an alias from the form array.\n *\n * @param index - The index of the alias to remove.\n * @param formArrayName - The name of the form array.\n */\n public removeAlias(index: number, formArrayName: string): void {\n this.aliasControls = this.removeFormAliasControls(index, formArrayName, this.aliasControls, this.aliasFields);\n }\n\n public override ngOnInit(): void {\n super.ngOnInit();\n }\n\n public override ngOnDestroy(): void {\n this['ngUnsubscribe'].next();\n this['ngUnsubscribe'].complete();\n super.ngOnDestroy();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAcM,MAAgB,8BAA+B,SAAQ,yBAAyB,CAAA;IAC7E,aAAa,GAA0C,EAAE;IACzD,uBAAuB,GAA0C,EAAE;IACnE,WAAW,GAAa,EAAE;AAEjC;;;;;;;;AAQG;AACK,IAAA,sBAAsB,CAC5B,gBAA0B,EAC1B,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;;QAGxD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,KAC1C,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,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Aa,GAAG,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC;IAC/G;IAEgB,QAAQ,GAAA;QACtB,KAAK,CAAC,QAAQ,EAAE;IAClB;IAEgB,WAAW,GAAA;AACzB,QAAA,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE;AAC5B,QAAA,IAAI,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE;QAChC,KAAK,CAAC,WAAW,EAAE;IACrB;wGA1PoB,8BAA8B,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAA9B,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,8BAA8B,+FAFxC,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA;;4FAEQ,8BAA8B,EAAA,UAAA,EAAA,CAAA;kBAHnD,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,EAAE;AACb,iBAAA;;;ACbD;;AAEG;;;;"}
1
+ {"version":3,"file":"hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base.mjs","sources":["../../../projects/opal-frontend-common/components/abstract/abstract-form-alias-base/abstract-form-alias-base.component.ts","../../../projects/opal-frontend-common/components/abstract/abstract-form-alias-base/hmcts-opal-frontend-common-components-abstract-abstract-form-alias-base.ts"],"sourcesContent":["import { FormArray, FormControl, FormGroup, ValidatorFn } from '@angular/forms';\nimport { takeUntil } from 'rxjs';\nimport { Component, OnDestroy, OnInit } from '@angular/core';\nimport { IAbstractFormAliasBaseAliasControls } from '@hmcts/opal-frontend-common/components/abstract/abstract-form-alias-base/interfaces';\nimport { AbstractFormBaseComponent } from '@hmcts/opal-frontend-common/components/abstract/abstract-form-base';\nimport {\n IAbstractFormArrayControlValidation,\n IAbstractFormArrayControls,\n IAbstractFormArrayControl,\n} from '@hmcts/opal-frontend-common/components/abstract/interfaces';\n\n@Component({\n template: '',\n})\nexport abstract class AbstractFormAliasBaseComponent extends AbstractFormBaseComponent implements OnInit, OnDestroy {\n public aliasControls: IAbstractFormAliasBaseAliasControls[] = [];\n public aliasControlsValidation: IAbstractFormArrayControlValidation[] = [];\n public aliasFields: string[] = [];\n\n /**\n * Builds an array of form controls for the given form array.\n *\n * @param formControlCount - An array of numbers representing the number of form controls to create.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - An array of field names.\n * @param controlValidation - An array of control validation objects.\n * @returns An array of form controls for the given form array.\n */\n private buildFormAliasControls(\n formControlCount: number[],\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): IAbstractFormArrayControls[] {\n // Directly map each index to a control\n return formControlCount.map((_element, index) =>\n this.addAliasControls(index, formArrayName, fieldNames, controlValidation),\n );\n }\n\n /**\n * Adds alias controls to the form array.\n *\n * @param index - The index of the form array.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - The names of the fields for the alias controls.\n * @param controlValidation - The validation rules for the alias controls.\n * @returns An object containing the form controls.\n */\n private addAliasControls(\n index: number,\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): { [key: string]: IAbstractFormArrayControl } {\n const formAliases = this.form.get(formArrayName) as FormArray;\n const formAliasesFormGroup = new FormGroup({});\n\n // Create the form controls...\n const controls = this.createAliasControls(fieldNames, index);\n\n // Add the controls to the form group...\n this.addControlsToFormGroup(formAliasesFormGroup, controlValidation, index);\n\n // Add the form group to the form array...\n formAliases.push(formAliasesFormGroup);\n\n // Return the form controls...\n return controls;\n }\n\n /**\n * Removes all form alias controls from a FormArray and clears any associated error messages.\n *\n * @param formArrayControls - An array of form array controls.\n * @param formArrayName - The name of the FormArray.\n * @param fieldNames - An array of field names associated with the form array controls.\n * @returns An empty array of form array controls.\n */\n private removeAllFormAliasControls(\n formArrayControls: IAbstractFormArrayControls[],\n formArrayName: string,\n fieldNames: string[],\n ): [] {\n const control = this.form.get(formArrayName) as FormArray;\n\n // Clear the error messages...\n [...formArrayControls].forEach((_element, index) => {\n this.removeFormAliasControlsErrors(index, formArrayControls, fieldNames);\n });\n\n // Reset the form array controls...\n control.clear();\n\n // Return en empty array of form array controls...\n return [];\n }\n\n /**\n * Creates a FormArray with the specified validators and controls.\n *\n * @param validators - An array of validators to apply to the FormArray.\n * @param controls - An optional array of initial FormControl instances to add to the FormArray.\n * @returns A new FormArray instance.\n */\n protected createFormAlias(validators: ValidatorFn[], controls: FormControl[] = []): FormArray {\n return new FormArray(controls, { validators: [...validators] });\n }\n\n /**\n * Removes a form alias control at the specified index from the given form array controls.\n *\n * @param index - The index of the form alias control to remove.\n * @param formArrayControls - The array of form array controls.\n * @returns The updated array of form array controls after removing the specified control.\n */\n protected removeFormAliasControl(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n ): IAbstractFormArrayControls[] {\n formArrayControls.splice(index, 1);\n return formArrayControls;\n }\n\n /**\n * Sets up the alias form controls based on the provided alias count array and form array name.\n * If there are any aliases, the alias controls will be re-populated.\n *\n * @param aliasCountArray - An array containing the count of aliases.\n * @param formArrayName - The name of the form array.\n */\n protected setupAliasFormControls(aliasCountArray: number[], formArrayName: string): void {\n // Re-populate the alias controls if there are any aliases\n if (aliasCountArray.length) {\n this.aliasControls = this.buildFormAliasControls(\n aliasCountArray,\n formArrayName,\n this.aliasFields,\n this.aliasControlsValidation,\n );\n }\n }\n\n /**\n * Removes the form alias controls errors for a specific index in a form array.\n *\n * @param index - The index of the form array control.\n * @param formArrayControls - An array of form array controls.\n * @param fieldNames - An array of field names to remove errors from.\n */\n protected removeFormAliasControlsErrors(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): void {\n const formArrayControl = formArrayControls[index];\n\n if (formArrayControl) {\n fieldNames.forEach((field) => {\n delete this.formControlErrorMessages?.[formArrayControl[field].controlName];\n });\n }\n }\n\n /**\n * Creates alias controls for the given fields and index.\n * @param fields - The list of fields for which alias controls need to be created.\n * @param index - The index value used to generate unique identifiers for the controls.\n * @returns An object containing the alias controls.\n */\n protected createAliasControls(fields: string[], index: number): { [key: string]: IAbstractFormArrayControl } {\n return fields.reduce(\n (controls, field) => ({\n ...controls,\n [field]: {\n inputId: `${field}_${index}`,\n inputName: `${field}_${index}`,\n controlName: `${field}_${index}`,\n },\n }),\n {},\n );\n }\n\n /**\n * Sets up the alias checkbox listener.\n *\n * @param formCheckboxName - The name of the checkbox control in the form.\n * @param formArrayName - The name of the form array control in the form.\n */\n protected setUpAliasCheckboxListener(formCheckboxName: string, formArrayName: string): void {\n // Ensure any existing subscription is cleared to avoid memory leaks\n this['ngUnsubscribe'].next();\n this['ngUnsubscribe'].complete();\n\n const addAliasControl = this.form.get(formCheckboxName);\n if (!addAliasControl) {\n return;\n }\n\n addAliasControl.valueChanges.pipe(takeUntil(this['ngUnsubscribe'])).subscribe((shouldAddAlias) => {\n this.aliasControls = shouldAddAlias\n ? this.buildFormAliasControls([0], formArrayName, this.aliasFields, this.aliasControlsValidation)\n : this.removeAllFormAliasControls(this.aliasControls, formArrayName, this.aliasFields);\n });\n }\n\n /**\n * Removes a form alias control from a form array and updates the list of form array controls.\n * @param index - The index of the form alias control to be removed.\n * @param formArrayName - The name of the form array.\n * @param formArrayControls - The list of form array controls.\n * @param fieldNames - The names of the fields associated with the form array controls.\n * @returns The updated list of form array controls after removing the specified control.\n */\n public removeFormAliasControls(\n index: number,\n formArrayName: string,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): IAbstractFormArrayControls[] {\n // Get the form array...\n const control = this.form.get(formArrayName) as FormArray;\n\n // Remove the form array control based on index\n control.removeAt(index);\n\n // Then remove the form array controls errors...\n this.removeFormAliasControlsErrors(index, formArrayControls, fieldNames);\n\n // Return the new list of form array controls...\n return this.removeFormAliasControl(index, formArrayControls);\n }\n\n /**\n * Adds an alias to the specified index of the form array.\n *\n * @param index - The index at which to add the alias.\n * @param formArrayName - The name of the form array.\n */\n public addAlias(index: number, formArrayName: string): void {\n this.aliasControls.push(\n this.addAliasControls(index, formArrayName, this.aliasFields, this.aliasControlsValidation),\n );\n }\n\n /**\n * Removes an alias from the form array.\n *\n * @param index - The index of the alias to remove.\n * @param formArrayName - The name of the form array.\n */\n public removeAlias(index: number, formArrayName: string): void {\n this.aliasControls = this.removeFormAliasControls(index, formArrayName, this.aliasControls, this.aliasFields);\n }\n\n public override ngOnInit(): void {\n super.ngOnInit();\n }\n\n public override ngOnDestroy(): void {\n this['ngUnsubscribe'].next();\n this['ngUnsubscribe'].complete();\n super.ngOnDestroy();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAcM,MAAgB,8BAA+B,SAAQ,yBAAyB,CAAA;IAC7E,aAAa,GAA0C,EAAE;IACzD,uBAAuB,GAA0C,EAAE;IACnE,WAAW,GAAa,EAAE;AAEjC;;;;;;;;AAQG;AACK,IAAA,sBAAsB,CAC5B,gBAA0B,EAC1B,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;;QAGxD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,KAC1C,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAC3E;IACH;AAEA;;;;;;;;AAQG;AACK,IAAA,gBAAgB,CACtB,KAAa,EACb,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;QAExD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAc;AAC7D,QAAA,MAAM,oBAAoB,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC;;QAG9C,MAAM,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,KAAK,CA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,EAAE;IACrB;uGA1PoB,8BAA8B,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAA9B,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,8BAA8B,+FAFxC,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA;;2FAEQ,8BAA8B,EAAA,UAAA,EAAA,CAAA;kBAHnD,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,EAAE;AACb,iBAAA;;;ACbD;;AAEG;;;;"}
@@ -234,10 +234,10 @@ class AbstractFormArrayBaseComponent extends AbstractFormBaseComponent {
234
234
  this.ngUnsubscribe.complete();
235
235
  super.ngOnDestroy();
236
236
  }
237
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AbstractFormArrayBaseComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
238
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: AbstractFormArrayBaseComponent, isStandalone: true, selector: "ng-component", usesInheritance: true, ngImport: i0, template: '', isInline: true });
237
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: AbstractFormArrayBaseComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
238
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.4", type: AbstractFormArrayBaseComponent, isStandalone: true, selector: "ng-component", usesInheritance: true, ngImport: i0, template: '', isInline: true });
239
239
  }
240
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AbstractFormArrayBaseComponent, decorators: [{
240
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: AbstractFormArrayBaseComponent, decorators: [{
241
241
  type: Component,
242
242
  args: [{
243
243
  template: '',
@@ -1 +1 @@
1
- {"version":3,"file":"hmcts-opal-frontend-common-components-abstract-abstract-form-array-base.mjs","sources":["../../../projects/opal-frontend-common/components/abstract/abstract-form-array-base/abstract-form-array-base.component.ts","../../../projects/opal-frontend-common/components/abstract/abstract-form-array-base/hmcts-opal-frontend-common-components-abstract-abstract-form-array-base.ts"],"sourcesContent":["import { Component, OnDestroy, OnInit } from '@angular/core';\nimport { AbstractFormBaseComponent } from '@hmcts/opal-frontend-common/components/abstract/abstract-form-base';\nimport {\n IAbstractFormArrayControls,\n IAbstractFormArrayControlValidation,\n IAbstractFormArrayControl,\n} from '@hmcts/opal-frontend-common/components/abstract/interfaces';\nimport { AbstractControl, FormArray, FormControl, FormGroup, ValidatorFn } from '@angular/forms';\n\n@Component({\n template: '',\n})\nexport abstract class AbstractFormArrayBaseComponent extends AbstractFormBaseComponent implements OnInit, OnDestroy {\n public formArrayControls: IAbstractFormArrayControls[] = [];\n public formArrayControlsValidation: IAbstractFormArrayControlValidation[] = [];\n public formArrayFields: string[] = [];\n\n /**\n * Builds an array of form controls for a form array.\n *\n * @param formControlCount - An array of numbers representing the number of form controls to create.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - An array of field names for the form controls.\n * @param controlValidation - An array of control validation configurations.\n * @returns An array of form controls for the form array.\n */\n private buildFormArrayControls(\n formControlCount: number[],\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): IAbstractFormArrayControls[] {\n // Directly map each index to a control\n return formControlCount.map((_element, index) =>\n this.addFormArrayControls(index, formArrayName, fieldNames, controlValidation),\n );\n }\n\n /**\n * Adds form array controls to the specified form array.\n *\n * @param index - The index at which the form array controls should be added.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - The names of the form controls to be created.\n * @param controlValidation - The validation rules for the form controls.\n * @returns An object containing the form controls that were added.\n */\n private addFormArrayControls(\n index: number,\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): { [key: string]: IAbstractFormArrayControl } {\n const formArray = this.form.get(formArrayName) as FormArray;\n const formArrayFormGroup = new FormGroup({});\n\n // Create the form controls...\n const controls = this.createFormArrayControls(fieldNames, index);\n\n // Add the controls to the form group...\n this.addControlsToFormGroup(formArrayFormGroup, controlValidation, index);\n\n // Add the form group to the form array...\n formArray.push(formArrayFormGroup);\n\n // Return the form controls...\n return controls;\n }\n\n /**\n * Creates a new instance of FormArray with the specified validators and controls.\n *\n * @param validators - An array of validator functions to be applied to the form array.\n * @param controls - An optional array of form controls to initialize the form array with.\n * @returns A new instance of FormArray.\n */\n protected createFormArray(validators: ValidatorFn[], controls: FormControl[] = []): FormArray {\n return new FormArray(controls, { validators: [...validators] });\n }\n\n /**\n * Sets up the form array form controls based on the provided parameters.\n *\n * @param formArrayCountArray - An array of numbers representing the count of form array controls.\n * @param formArrayName - The name of the form array.\n */\n protected setupFormArrayFormControls(formArrayCountArray: number[], formArrayName: string): void {\n if (formArrayCountArray.length) {\n this.formArrayControls = this.buildFormArrayControls(\n formArrayCountArray,\n formArrayName,\n this.formArrayFields,\n this.formArrayControlsValidation,\n );\n }\n }\n\n /**\n * Creates an object with form array controls based on the given fields and index.\n *\n * @param fields - An array of field names.\n * @param index - The index of the form array.\n * @returns An object with form array controls.\n */\n protected createFormArrayControls(fields: string[], index: number): { [key: string]: IAbstractFormArrayControl } {\n return fields.reduce(\n (controls, field) => ({\n ...controls,\n [field]: {\n inputId: `${field}_${index}`,\n inputName: `${field}_${index}`,\n controlName: `${field}_${index}`,\n },\n }),\n {},\n );\n }\n\n /**\n * Removes form array controls errors for a specific index.\n *\n * @param index - The index of the form array control.\n * @param formArrayControls - An array of form array controls.\n * @param fieldNames - An array of field names to remove errors from.\n */\n protected removeFormArrayControlsErrors(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): void {\n const formArrayControl = formArrayControls[index];\n\n if (formArrayControl) {\n fieldNames.forEach((field) => {\n delete this.formControlErrorMessages?.[formArrayControl[field].controlName];\n });\n }\n }\n\n /**\n * Removes a form array control at the specified index from the given array of form array controls.\n *\n * @param index - The index of the form array control to be removed.\n * @param formArrayControls - The array of form array controls.\n * @returns The updated array of form array controls after removing the specified control.\n */\n protected removeFormArrayControl(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n ): IAbstractFormArrayControls[] {\n formArrayControls.splice(index, 1);\n return formArrayControls;\n }\n\n /**\n * Retrieves the value of a form control or returns a default value if the control is null or undefined.\n *\n * @param control - The form control to retrieve the value from.\n * @param defaultValue - The default value to return if the control is null or undefined.\n * @returns The value of the control if it exists, otherwise the default value.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected getControlValueOrDefault(control: AbstractControl | null, defaultValue: any): any {\n return control?.value ?? defaultValue;\n }\n\n /**\n * Removes a form array control at the specified index and updates the form array controls and errors.\n *\n * @param index - The index of the form array control to remove.\n * @param formArrayName - The name of the form array.\n * @param formArrayControls - The list of form array controls.\n * @param fieldNames - The names of the fields associated with the form array controls.\n * @returns The updated list of form array controls.\n */\n public removeFormArrayControls(\n index: number,\n formArrayName: string,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): IAbstractFormArrayControls[] {\n // Get the form array...\n const control = this.form.get(formArrayName) as FormArray;\n\n // Remove the form array control based on index\n control.removeAt(index);\n\n // Then remove the form array controls errors...\n this.removeFormArrayControlsErrors(index, formArrayControls, fieldNames);\n\n // Return the new list of form array controls...\n return this.removeFormArrayControl(index, formArrayControls);\n }\n\n /**\n * Removes controls from a form array at the specified index.\n *\n * @param index - The index at which to remove the controls.\n * @param formArrayName - The name of the form array.\n */\n public removeControlsFromFormArray(index: number, formArrayName: string): void {\n this.formArrayControls = this.removeFormArrayControls(\n index,\n formArrayName,\n this.formArrayControls,\n this.formArrayFields,\n );\n }\n\n /**\n * Removes a form array control from the specified form array.\n *\n * @param formArrayControl - The form array control to remove.\n * @param formArrayName - The name of the form array.\n */\n public removeFormArrayControlFromArray(formArrayControl: IAbstractFormArrayControls, formArrayName: string): void {\n const formArrayControlIndex = this.formArrayControls.findIndex((control) => control === formArrayControl);\n this.removeFormArrayControls(formArrayControlIndex, formArrayName, this.formArrayControls, this.formArrayFields);\n }\n\n /**\n * Retrieves the FormGroup at the specified index from a FormArray.\n *\n * @param index - The index of the FormGroup to retrieve.\n * @param formArrayName - The name of the FormArray.\n * @returns The FormGroup at the specified index.\n */\n public getFormArrayFormGroup(index: number, formArrayName: string): FormGroup {\n const formArray = this.form.get(formArrayName) as FormArray;\n return formArray.controls[index] as FormGroup;\n }\n\n /**\n * Retrieves the FormControl from a FormGroup within a FormArray at the specified index.\n *\n * @param formGroup - The FormGroup containing the FormControl.\n * @param controlName - The name of the FormControl.\n * @param index - The index of the FormArray.\n * @returns The FormControl at the specified index.\n */\n public getFormArrayFormGroupControl(formGroup: FormGroup, controlName: string, index: number): FormControl {\n return formGroup.controls[`${controlName}_${index}`] as FormControl;\n }\n\n /**\n * Adds validators to a specific form control within a form array group.\n *\n * @param formGroup - The form group containing the form array.\n * @param controlName - The name of the form control within the form array group.\n * @param index - The index of the form array group within the form array.\n * @param validators - An array of validator functions to be added to the form control.\n */\n public addFormArrayFormGroupControlValidators(formControl: FormControl, validators: ValidatorFn[]): void {\n formControl.setValidators(validators);\n formControl.updateValueAndValidity({ emitEvent: false });\n }\n\n /**\n * Removes validators from a specific form control within a form array group.\n * @param formGroup - The form group containing the form array.\n * @param controlName - The name of the form control within the form array group.\n * @param index - The index of the form array group within the form array.\n */\n public removeFormArrayFormGroupControlValidators(formControl: FormControl): void {\n formControl.clearValidators();\n formControl.setErrors(null);\n formControl.setValue(null, { emitEvent: false });\n formControl.updateValueAndValidity({ emitEvent: false });\n }\n\n /**\n * Reverses the form array data by appending the index to each key in the objects.\n *\n * @param data - An array of objects containing form data.\n * @returns An array of objects with keys modified to include their index in the original array.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public addIndexToFormArrayData(data: any[]): { [key: string]: any }[] {\n return data.map((item, index) =>\n Object.entries(item).reduce(\n (indexedObject, [key, value]) => {\n if (value !== undefined) {\n indexedObject[`${key}_${index}`] = value;\n }\n return indexedObject;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {} as { [key: string]: any },\n ),\n );\n }\n\n /**\n * Adds controls to the form array at the specified index.\n *\n * @param index - The index at which the controls should be added.\n * @param formArrayName - The name of the form array.\n */\n public addControlsToFormArray(index: number, formArrayName: string): void {\n this.formArrayControls.push(\n this.addFormArrayControls(index, formArrayName, this.formArrayFields, this.formArrayControlsValidation),\n );\n }\n\n public override ngOnInit(): void {\n super.ngOnInit();\n }\n\n public override ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n super.ngOnDestroy();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAYM,MAAgB,8BAA+B,SAAQ,yBAAyB,CAAA;IAC7E,iBAAiB,GAAiC,EAAE;IACpD,2BAA2B,GAA0C,EAAE;IACvE,eAAe,GAAa,EAAE;AAErC;;;;;;;;AAQG;AACK,IAAA,sBAAsB,CAC5B,gBAA0B,EAC1B,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;;QAGxD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,KAC1C,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAC/E;IACH;AAEA;;;;;;;;AAQG;AACK,IAAA,oBAAoB,CAC1B,KAAa,EACb,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;QAExD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAc;AAC3D,QAAA,MAAM,kBAAkB,GAAG,IAAI,SAA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ects/opal-frontend-common/components/abstract/abstract-form-array-base/abstract-form-array-base.component.ts","../../../projects/opal-frontend-common/components/abstract/abstract-form-array-base/hmcts-opal-frontend-common-components-abstract-abstract-form-array-base.ts"],"sourcesContent":["import { Component, OnDestroy, OnInit } from '@angular/core';\nimport { AbstractFormBaseComponent } from '@hmcts/opal-frontend-common/components/abstract/abstract-form-base';\nimport {\n IAbstractFormArrayControls,\n IAbstractFormArrayControlValidation,\n IAbstractFormArrayControl,\n} from '@hmcts/opal-frontend-common/components/abstract/interfaces';\nimport { AbstractControl, FormArray, FormControl, FormGroup, ValidatorFn } from '@angular/forms';\n\n@Component({\n template: '',\n})\nexport abstract class AbstractFormArrayBaseComponent extends AbstractFormBaseComponent implements OnInit, OnDestroy {\n public formArrayControls: IAbstractFormArrayControls[] = [];\n public formArrayControlsValidation: IAbstractFormArrayControlValidation[] = [];\n public formArrayFields: string[] = [];\n\n /**\n * Builds an array of form controls for a form array.\n *\n * @param formControlCount - An array of numbers representing the number of form controls to create.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - An array of field names for the form controls.\n * @param controlValidation - An array of control validation configurations.\n * @returns An array of form controls for the form array.\n */\n private buildFormArrayControls(\n formControlCount: number[],\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): IAbstractFormArrayControls[] {\n // Directly map each index to a control\n return formControlCount.map((_element, index) =>\n this.addFormArrayControls(index, formArrayName, fieldNames, controlValidation),\n );\n }\n\n /**\n * Adds form array controls to the specified form array.\n *\n * @param index - The index at which the form array controls should be added.\n * @param formArrayName - The name of the form array.\n * @param fieldNames - The names of the form controls to be created.\n * @param controlValidation - The validation rules for the form controls.\n * @returns An object containing the form controls that were added.\n */\n private addFormArrayControls(\n index: number,\n formArrayName: string,\n fieldNames: string[],\n controlValidation: IAbstractFormArrayControlValidation[],\n ): { [key: string]: IAbstractFormArrayControl } {\n const formArray = this.form.get(formArrayName) as FormArray;\n const formArrayFormGroup = new FormGroup({});\n\n // Create the form controls...\n const controls = this.createFormArrayControls(fieldNames, index);\n\n // Add the controls to the form group...\n this.addControlsToFormGroup(formArrayFormGroup, controlValidation, index);\n\n // Add the form group to the form array...\n formArray.push(formArrayFormGroup);\n\n // Return the form controls...\n return controls;\n }\n\n /**\n * Creates a new instance of FormArray with the specified validators and controls.\n *\n * @param validators - An array of validator functions to be applied to the form array.\n * @param controls - An optional array of form controls to initialize the form array with.\n * @returns A new instance of FormArray.\n */\n protected createFormArray(validators: ValidatorFn[], controls: FormControl[] = []): FormArray {\n return new FormArray(controls, { validators: [...validators] });\n }\n\n /**\n * Sets up the form array form controls based on the provided parameters.\n *\n * @param formArrayCountArray - An array of numbers representing the count of form array controls.\n * @param formArrayName - The name of the form array.\n */\n protected setupFormArrayFormControls(formArrayCountArray: number[], formArrayName: string): void {\n if (formArrayCountArray.length) {\n this.formArrayControls = this.buildFormArrayControls(\n formArrayCountArray,\n formArrayName,\n this.formArrayFields,\n this.formArrayControlsValidation,\n );\n }\n }\n\n /**\n * Creates an object with form array controls based on the given fields and index.\n *\n * @param fields - An array of field names.\n * @param index - The index of the form array.\n * @returns An object with form array controls.\n */\n protected createFormArrayControls(fields: string[], index: number): { [key: string]: IAbstractFormArrayControl } {\n return fields.reduce(\n (controls, field) => ({\n ...controls,\n [field]: {\n inputId: `${field}_${index}`,\n inputName: `${field}_${index}`,\n controlName: `${field}_${index}`,\n },\n }),\n {},\n );\n }\n\n /**\n * Removes form array controls errors for a specific index.\n *\n * @param index - The index of the form array control.\n * @param formArrayControls - An array of form array controls.\n * @param fieldNames - An array of field names to remove errors from.\n */\n protected removeFormArrayControlsErrors(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): void {\n const formArrayControl = formArrayControls[index];\n\n if (formArrayControl) {\n fieldNames.forEach((field) => {\n delete this.formControlErrorMessages?.[formArrayControl[field].controlName];\n });\n }\n }\n\n /**\n * Removes a form array control at the specified index from the given array of form array controls.\n *\n * @param index - The index of the form array control to be removed.\n * @param formArrayControls - The array of form array controls.\n * @returns The updated array of form array controls after removing the specified control.\n */\n protected removeFormArrayControl(\n index: number,\n formArrayControls: IAbstractFormArrayControls[],\n ): IAbstractFormArrayControls[] {\n formArrayControls.splice(index, 1);\n return formArrayControls;\n }\n\n /**\n * Retrieves the value of a form control or returns a default value if the control is null or undefined.\n *\n * @param control - The form control to retrieve the value from.\n * @param defaultValue - The default value to return if the control is null or undefined.\n * @returns The value of the control if it exists, otherwise the default value.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected getControlValueOrDefault(control: AbstractControl | null, defaultValue: any): any {\n return control?.value ?? defaultValue;\n }\n\n /**\n * Removes a form array control at the specified index and updates the form array controls and errors.\n *\n * @param index - The index of the form array control to remove.\n * @param formArrayName - The name of the form array.\n * @param formArrayControls - The list of form array controls.\n * @param fieldNames - The names of the fields associated with the form array controls.\n * @returns The updated list of form array controls.\n */\n public removeFormArrayControls(\n index: number,\n formArrayName: string,\n formArrayControls: IAbstractFormArrayControls[],\n fieldNames: string[],\n ): IAbstractFormArrayControls[] {\n // Get the form array...\n const control = this.form.get(formArrayName) as FormArray;\n\n // Remove the form array control based on index\n control.removeAt(index);\n\n // Then remove the form array controls errors...\n this.removeFormArrayControlsErrors(index, formArrayControls, fieldNames);\n\n // Return the new list of form array controls...\n return this.removeFormArrayControl(index, formArrayControls);\n }\n\n /**\n * Removes controls from a form array at the specified index.\n *\n * @param index - The index at which to remove the controls.\n * @param formArrayName - The name of the form array.\n */\n public removeControlsFromFormArray(index: number, formArrayName: string): void {\n this.formArrayControls = this.removeFormArrayControls(\n index,\n formArrayName,\n this.formArrayControls,\n this.formArrayFields,\n );\n }\n\n /**\n * Removes a form array control from the specified form array.\n *\n * @param formArrayControl - The form array control to remove.\n * @param formArrayName - The name of the form array.\n */\n public removeFormArrayControlFromArray(formArrayControl: IAbstractFormArrayControls, formArrayName: string): void {\n const formArrayControlIndex = this.formArrayControls.findIndex((control) => control === formArrayControl);\n this.removeFormArrayControls(formArrayControlIndex, formArrayName, this.formArrayControls, this.formArrayFields);\n }\n\n /**\n * Retrieves the FormGroup at the specified index from a FormArray.\n *\n * @param index - The index of the FormGroup to retrieve.\n * @param formArrayName - The name of the FormArray.\n * @returns The FormGroup at the specified index.\n */\n public getFormArrayFormGroup(index: number, formArrayName: string): FormGroup {\n const formArray = this.form.get(formArrayName) as FormArray;\n return formArray.controls[index] as FormGroup;\n }\n\n /**\n * Retrieves the FormControl from a FormGroup within a FormArray at the specified index.\n *\n * @param formGroup - The FormGroup containing the FormControl.\n * @param controlName - The name of the FormControl.\n * @param index - The index of the FormArray.\n * @returns The FormControl at the specified index.\n */\n public getFormArrayFormGroupControl(formGroup: FormGroup, controlName: string, index: number): FormControl {\n return formGroup.controls[`${controlName}_${index}`] as FormControl;\n }\n\n /**\n * Adds validators to a specific form control within a form array group.\n *\n * @param formGroup - The form group containing the form array.\n * @param controlName - The name of the form control within the form array group.\n * @param index - The index of the form array group within the form array.\n * @param validators - An array of validator functions to be added to the form control.\n */\n public addFormArrayFormGroupControlValidators(formControl: FormControl, validators: ValidatorFn[]): void {\n formControl.setValidators(validators);\n formControl.updateValueAndValidity({ emitEvent: false });\n }\n\n /**\n * Removes validators from a specific form control within a form array group.\n * @param formGroup - The form group containing the form array.\n * @param controlName - The name of the form control within the form array group.\n * @param index - The index of the form array group within the form array.\n */\n public removeFormArrayFormGroupControlValidators(formControl: FormControl): void {\n formControl.clearValidators();\n formControl.setErrors(null);\n formControl.setValue(null, { emitEvent: false });\n formControl.updateValueAndValidity({ emitEvent: false });\n }\n\n /**\n * Reverses the form array data by appending the index to each key in the objects.\n *\n * @param data - An array of objects containing form data.\n * @returns An array of objects with keys modified to include their index in the original array.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public addIndexToFormArrayData(data: any[]): { [key: string]: any }[] {\n return data.map((item, index) =>\n Object.entries(item).reduce(\n (indexedObject, [key, value]) => {\n if (value !== undefined) {\n indexedObject[`${key}_${index}`] = value;\n }\n return indexedObject;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {} as { [key: string]: any },\n ),\n );\n }\n\n /**\n * Adds controls to the form array at the specified index.\n *\n * @param index - The index at which the controls should be added.\n * @param formArrayName - The name of the form array.\n */\n public addControlsToFormArray(index: number, formArrayName: string): void {\n this.formArrayControls.push(\n this.addFormArrayControls(index, formArrayName, this.formArrayFields, this.formArrayControlsValidation),\n );\n }\n\n public override ngOnInit(): void {\n super.ngOnInit();\n }\n\n public override ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n super.ngOnDestroy();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAYM,MAAgB,8BAA+B,SAAQ,yBAAyB,CAAA;IAC7E,iBAAiB,GAAiC,EAAE;IACpD,2BAA2B,GAA0C,EAAE;IACvE,eAAe,GAAa,EAAE;AAErC;;;;;;;;AAQG;AACK,IAAA,sBAAsB,CAC5B,gBAA0B,EAC1B,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;;QAGxD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,KAC1C,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAC/E;IACH;AAEA;;;;;;;;AAQG;AACK,IAAA,oBAAoB,CAC1B,KAAa,EACb,aAAqB,EACrB,UAAoB,EACpB,iBAAwD,EAAA;QAExD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,CAAc;AAC3D,QAAA,MAAM,kBAAkB,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC;;QAG5C,MAAM,QAAQ,GAAG,IAAI,CAAC,uBAAuB,CAAC,UAAU,EAAE,KAAK,CAAC;;QAGhE,IAAI,CAAC,sBAAsB,CAAC,kBAAkB,EAAE,iBAAiB,EAAE,KA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,GAAG,CAAA,CAAA,EAAI,KAAK,CAAA,CAAE,CAAC,GAAG,KAAK;YAC1C;AACA,YAAA,OAAO,aAAa;QACtB,CAAC;;QAED,EAA4B,CAC7B,CACF;IACH;AAEA;;;;;AAKG;IACI,sBAAsB,CAAC,KAAa,EAAE,aAAqB,EAAA;QAChE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CACzB,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,2BAA2B,CAAC,CACxG;IACH;IAEgB,QAAQ,GAAA;QACtB,KAAK,CAAC,QAAQ,EAAE;IAClB;IAEgB,WAAW,GAAA;AACzB,QAAA,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE;AACzB,QAAA,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE;QAC7B,KAAK,CAAC,WAAW,EAAE;IACrB;uGA5SoB,8BAA8B,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAA9B,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,8BAA8B,+FAFxC,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA;;2FAEQ,8BAA8B,EAAA,UAAA,EAAA,CAAA;kBAHnD,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,EAAE;AACb,iBAAA;;;ACXD;;AAEG;;;;"}
@@ -77,10 +77,10 @@ class AbstractFormArrayRemovalComponent {
77
77
  this.router.navigate([route], { relativeTo: this.activatedRoute.parent });
78
78
  }
79
79
  }
80
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AbstractFormArrayRemovalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
81
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: AbstractFormArrayRemovalComponent, isStandalone: true, selector: "ng-component", ngImport: i0, template: '', isInline: true });
80
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: AbstractFormArrayRemovalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
81
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.4", type: AbstractFormArrayRemovalComponent, isStandalone: true, selector: "ng-component", ngImport: i0, template: '', isInline: true });
82
82
  }
83
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AbstractFormArrayRemovalComponent, decorators: [{
83
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: AbstractFormArrayRemovalComponent, decorators: [{
84
84
  type: Component,
85
85
  args: [{
86
86
  template: '',
@@ -1 +1 @@
1
- {"version":3,"file":"hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base.mjs","sources":["../../../projects/opal-frontend-common/components/abstract/abstract-form-array-removal-base/abstract-form-array-removal-base.component.ts","../../../projects/opal-frontend-common/components/abstract/abstract-form-array-removal-base/hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base.ts"],"sourcesContent":["import { FormArray, FormGroup } from '@angular/forms';\nimport { Component, inject } from '@angular/core';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { IAbstractFormArrayRemovalBaseControlValue } from './interfaces/abstract-form-array-removal-base-control-value.interface';\n\n@Component({\n template: '',\n})\nexport abstract class AbstractFormArrayRemovalComponent {\n private readonly router = inject(Router);\n private readonly activatedRoute = inject(ActivatedRoute);\n\n protected getFormArrayControlValue(\n formArray: FormArray,\n controlName: string,\n rowIndex: number,\n defaultValue: IAbstractFormArrayRemovalBaseControlValue[keyof IAbstractFormArrayRemovalBaseControlValue],\n ): IAbstractFormArrayRemovalBaseControlValue[keyof IAbstractFormArrayRemovalBaseControlValue] {\n const value = formArray.controls[rowIndex]?.get(controlName)?.value;\n\n if (typeof value === 'string' && !isNaN(Number(value))) {\n return Number(value);\n }\n\n return value ?? defaultValue;\n }\n\n /**\n * Removes a control from the given form array at the specified index and renumbers the remaining controls.\n *\n * @param formArray - The form array from which to remove the control.\n * @param removeIndex - The index of the control to remove.\n * @param fieldNames - The names of the fields associated with the controls.\n * @param dynamicFieldPrefix - The prefix used for dynamically generated field names.\n */\n protected removeControlAndRenumber(\n formArray: FormArray,\n removeIndex: number,\n fieldNames: string[],\n dynamicFieldPrefix: string,\n ): void {\n formArray.removeAt(removeIndex);\n this.renumberControls(formArray, removeIndex, fieldNames, dynamicFieldPrefix);\n }\n\n /**\n * Renumber the controls in a FormArray starting from a specific index.\n * This method updates the control keys of each FormGroup within the FormArray.\n *\n * @param formArray - The FormArray to renumber the controls for.\n * @param startIndex - The index to start renumbering the controls from.\n * @param fieldNames - The names of the fields in the FormGroup.\n * @param dynamicFieldPrefix - The prefix to use for dynamic field names.\n */\n protected renumberControls(\n formArray: FormArray,\n startIndex: number,\n fieldNames: string[],\n dynamicFieldPrefix: string,\n ): void {\n const formGroups = formArray.controls.slice(startIndex);\n for (const [index, formGroup] of formGroups.entries()) {\n this.updateControlKeys(formGroup as FormGroup, index + startIndex, fieldNames, dynamicFieldPrefix);\n }\n }\n\n /**\n * Updates the control keys in a form group based on the provided parameters.\n * @param formGroup - The form group to update.\n * @param index - The index of the form group within an array.\n * @param fieldNames - An array of field names to update.\n * @param dynamicFieldPrefix - The prefix to use for dynamic field keys.\n */\n protected updateControlKeys(\n formGroup: FormGroup,\n index: number,\n fieldNames: string[],\n dynamicFieldPrefix: string,\n ): void {\n fieldNames.forEach((field) => {\n const currentKey = `${dynamicFieldPrefix}_${field}_${index + 1}`;\n const newKey = `${dynamicFieldPrefix}_${field}_${index}`;\n\n // Retrieve the current control, if it exists\n const control = formGroup.get(currentKey);\n\n if (control) {\n // Remove the old control first, then add it with the new key\n formGroup.removeControl(currentKey);\n\n // Add the control with the updated key\n formGroup.addControl(newKey, control);\n }\n });\n }\n\n /**\n * Handles route with the supplied route\n *\n * @param route string of route\n * @param nonRelative boolean indicating if route is relative to the parent\n */\n public handleRoute(route: string, nonRelative: boolean = false, event?: Event): void {\n if (event) {\n event.preventDefault();\n }\n if (nonRelative) {\n this.router.navigate([route]);\n } else {\n this.router.navigate([route], { relativeTo: this.activatedRoute.parent });\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAQsB,iCAAiC,CAAA;AACpC,IAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACvB,IAAA,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;AAE9C,IAAA,wBAAwB,CAChC,SAAoB,EACpB,WAAmB,EACnB,QAAgB,EAChB,YAAwG,EAAA;AAExG,QAAA,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,EAAE,KAAK;AAEnE,QAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;AACtD,YAAA,OAAO,MAAM,CAAC,KAAK,CAAC;QACtB;QAEA,OAAO,KAAK,IAAI,YAAY;IAC9B;AAEA;;;;;;;AAOG;AACO,IAAA,wBAAwB,CAChC,SAAoB,EACpB,WAAmB,EACnB,UAAoB,EACpB,kBAA0B,EAAA;AAE1B,QAAA,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC/B,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,CAAC;IAC/E;AAEA;;;;;;;;AAQG;AACO,IAAA,gBAAgB,CACxB,SAAoB,EACpB,UAAkB,EAClB,UAAoB,EACpB,kBAA0B,EAAA;QAE1B,MAAM,UAAU,GA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CAAC;QAC3E;IACF;wGAvGoB,iCAAiC,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAjC,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,iCAAiC,wEAF3C,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA;;4FAEQ,iCAAiC,EAAA,UAAA,EAAA,CAAA;kBAHtD,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,EAAE;AACb,iBAAA;;;ACPD;;AAEG;;;;"}
1
+ {"version":3,"file":"hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base.mjs","sources":["../../../projects/opal-frontend-common/components/abstract/abstract-form-array-removal-base/abstract-form-array-removal-base.component.ts","../../../projects/opal-frontend-common/components/abstract/abstract-form-array-removal-base/hmcts-opal-frontend-common-components-abstract-abstract-form-array-removal-base.ts"],"sourcesContent":["import { FormArray, FormGroup } from '@angular/forms';\nimport { Component, inject } from '@angular/core';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { IAbstractFormArrayRemovalBaseControlValue } from './interfaces/abstract-form-array-removal-base-control-value.interface';\n\n@Component({\n template: '',\n})\nexport abstract class AbstractFormArrayRemovalComponent {\n private readonly router = inject(Router);\n private readonly activatedRoute = inject(ActivatedRoute);\n\n protected getFormArrayControlValue(\n formArray: FormArray,\n controlName: string,\n rowIndex: number,\n defaultValue: IAbstractFormArrayRemovalBaseControlValue[keyof IAbstractFormArrayRemovalBaseControlValue],\n ): IAbstractFormArrayRemovalBaseControlValue[keyof IAbstractFormArrayRemovalBaseControlValue] {\n const value = formArray.controls[rowIndex]?.get(controlName)?.value;\n\n if (typeof value === 'string' && !isNaN(Number(value))) {\n return Number(value);\n }\n\n return value ?? defaultValue;\n }\n\n /**\n * Removes a control from the given form array at the specified index and renumbers the remaining controls.\n *\n * @param formArray - The form array from which to remove the control.\n * @param removeIndex - The index of the control to remove.\n * @param fieldNames - The names of the fields associated with the controls.\n * @param dynamicFieldPrefix - The prefix used for dynamically generated field names.\n */\n protected removeControlAndRenumber(\n formArray: FormArray,\n removeIndex: number,\n fieldNames: string[],\n dynamicFieldPrefix: string,\n ): void {\n formArray.removeAt(removeIndex);\n this.renumberControls(formArray, removeIndex, fieldNames, dynamicFieldPrefix);\n }\n\n /**\n * Renumber the controls in a FormArray starting from a specific index.\n * This method updates the control keys of each FormGroup within the FormArray.\n *\n * @param formArray - The FormArray to renumber the controls for.\n * @param startIndex - The index to start renumbering the controls from.\n * @param fieldNames - The names of the fields in the FormGroup.\n * @param dynamicFieldPrefix - The prefix to use for dynamic field names.\n */\n protected renumberControls(\n formArray: FormArray,\n startIndex: number,\n fieldNames: string[],\n dynamicFieldPrefix: string,\n ): void {\n const formGroups = formArray.controls.slice(startIndex);\n for (const [index, formGroup] of formGroups.entries()) {\n this.updateControlKeys(formGroup as FormGroup, index + startIndex, fieldNames, dynamicFieldPrefix);\n }\n }\n\n /**\n * Updates the control keys in a form group based on the provided parameters.\n * @param formGroup - The form group to update.\n * @param index - The index of the form group within an array.\n * @param fieldNames - An array of field names to update.\n * @param dynamicFieldPrefix - The prefix to use for dynamic field keys.\n */\n protected updateControlKeys(\n formGroup: FormGroup,\n index: number,\n fieldNames: string[],\n dynamicFieldPrefix: string,\n ): void {\n fieldNames.forEach((field) => {\n const currentKey = `${dynamicFieldPrefix}_${field}_${index + 1}`;\n const newKey = `${dynamicFieldPrefix}_${field}_${index}`;\n\n // Retrieve the current control, if it exists\n const control = formGroup.get(currentKey);\n\n if (control) {\n // Remove the old control first, then add it with the new key\n formGroup.removeControl(currentKey);\n\n // Add the control with the updated key\n formGroup.addControl(newKey, control);\n }\n });\n }\n\n /**\n * Handles route with the supplied route\n *\n * @param route string of route\n * @param nonRelative boolean indicating if route is relative to the parent\n */\n public handleRoute(route: string, nonRelative: boolean = false, event?: Event): void {\n if (event) {\n event.preventDefault();\n }\n if (nonRelative) {\n this.router.navigate([route]);\n } else {\n this.router.navigate([route], { relativeTo: this.activatedRoute.parent });\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAQsB,iCAAiC,CAAA;AACpC,IAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACvB,IAAA,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;AAE9C,IAAA,wBAAwB,CAChC,SAAoB,EACpB,WAAmB,EACnB,QAAgB,EAChB,YAAwG,EAAA;AAExG,QAAA,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,EAAE,KAAK;AAEnE,QAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;AACtD,YAAA,OAAO,MAAM,CAAC,KAAK,CAAC;QACtB;QAEA,OAAO,KAAK,IAAI,YAAY;IAC9B;AAEA;;;;;;;AAOG;AACO,IAAA,wBAAwB,CAChC,SAAoB,EACpB,WAAmB,EACnB,UAAoB,EACpB,kBAA0B,EAAA;AAE1B,QAAA,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC/B,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,CAAC;IAC/E;AAEA;;;;;;;;AAQG;AACO,IAAA,gBAAgB,CACxB,SAAoB,EACpB,UAAkB,EAClB,UAAoB,EACpB,kBAA0B,EAAA;QAE1B,MAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;AACvD,QAAA,KAAK,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,EAAE;AACrD,YAAA,IAAI,CAAC,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AA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,iCAAiC,wEAF3C,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA;;2FAEQ,iCAAiC,EAAA,UAAA,EAAA,CAAA;kBAHtD,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,EAAE;AACb,iBAAA;;;ACPD;;AAEG;;;;"}
@@ -474,10 +474,10 @@ class AbstractFormBaseComponent {
474
474
  this.ngUnsubscribe.next();
475
475
  this.ngUnsubscribe.complete();
476
476
  }
477
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AbstractFormBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
478
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: AbstractFormBaseComponent, isStandalone: true, selector: "ng-component", outputs: { unsavedChanges: "unsavedChanges", formSubmit: "formSubmit" }, ngImport: i0, template: '', isInline: true });
477
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: AbstractFormBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
478
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.4", type: AbstractFormBaseComponent, isStandalone: true, selector: "ng-component", outputs: { unsavedChanges: "unsavedChanges", formSubmit: "formSubmit" }, ngImport: i0, template: '', isInline: true });
479
479
  }
480
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: AbstractFormBaseComponent, decorators: [{
480
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: AbstractFormBaseComponent, decorators: [{
481
481
  type: Component,
482
482
  args: [{
483
483
  template: '',