content_block_tools 0.17.0 → 1.0.1

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 (877) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/blocks/_contact.scss +13 -0
  3. data/app/assets/stylesheets/content_block_tools.scss +24 -0
  4. data/lib/content_block_tools/engine.rb +16 -0
  5. data/lib/content_block_tools/presenters/block_presenters/contact/address_presenter.rb +1 -7
  6. data/lib/content_block_tools/presenters/block_presenters/contact/block_level_contact_item.rb +10 -16
  7. data/lib/content_block_tools/presenters/block_presenters/contact/contact_link_presenter.rb +6 -4
  8. data/lib/content_block_tools/presenters/block_presenters/contact/email_address_presenter.rb +10 -4
  9. data/lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb +9 -26
  10. data/lib/content_block_tools/presenters/contact_presenter.rb +6 -10
  11. data/lib/content_block_tools/version.rb +1 -1
  12. data/lib/content_block_tools.rb +2 -8
  13. data/node_modules/govuk-frontend/README.md +92 -0
  14. data/node_modules/govuk-frontend/dist/govuk/_base.scss +5 -0
  15. data/node_modules/govuk-frontend/dist/govuk/_base.scss.map +1 -0
  16. data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +2847 -0
  17. data/node_modules/govuk-frontend/dist/govuk/all.bundle.js.map +1 -0
  18. data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +2820 -0
  19. data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs.map +1 -0
  20. data/node_modules/govuk-frontend/dist/govuk/all.mjs +20 -0
  21. data/node_modules/govuk-frontend/dist/govuk/all.mjs.map +1 -0
  22. data/node_modules/govuk-frontend/dist/govuk/all.scss +9 -0
  23. data/node_modules/govuk-frontend/dist/govuk/all.scss.map +1 -0
  24. data/node_modules/govuk-frontend/dist/govuk/assets/fonts/bold-affa96571d-v2.woff +0 -0
  25. data/node_modules/govuk-frontend/dist/govuk/assets/fonts/bold-b542beb274-v2.woff2 +0 -0
  26. data/node_modules/govuk-frontend/dist/govuk/assets/fonts/light-94a07e06a1-v2.woff2 +0 -0
  27. data/node_modules/govuk-frontend/dist/govuk/assets/fonts/light-f591b13f7d-v2.woff +0 -0
  28. data/node_modules/govuk-frontend/dist/govuk/assets/images/favicon.ico +0 -0
  29. data/node_modules/govuk-frontend/dist/govuk/assets/images/favicon.svg +1 -0
  30. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest.svg +1 -0
  31. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-180.png +0 -0
  32. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-192.png +0 -0
  33. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-512.png +0 -0
  34. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-icon-mask.svg +1 -0
  35. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-opengraph-image.png +0 -0
  36. data/node_modules/govuk-frontend/dist/govuk/assets/manifest.json +39 -0
  37. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/favicon.ico +0 -0
  38. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/favicon.svg +1 -0
  39. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-crest.svg +1 -0
  40. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-180.png +0 -0
  41. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-192.png +0 -0
  42. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-512.png +0 -0
  43. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-mask.svg +1 -0
  44. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-opengraph-image.png +0 -0
  45. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/manifest.json +39 -0
  46. data/node_modules/govuk-frontend/dist/govuk/common/closest-attribute-value.mjs +7 -0
  47. data/node_modules/govuk-frontend/dist/govuk/common/closest-attribute-value.mjs.map +1 -0
  48. data/node_modules/govuk-frontend/dist/govuk/common/configuration.mjs +169 -0
  49. data/node_modules/govuk-frontend/dist/govuk/common/configuration.mjs.map +1 -0
  50. data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +4 -0
  51. data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs.map +1 -0
  52. data/node_modules/govuk-frontend/dist/govuk/common/index.mjs +76 -0
  53. data/node_modules/govuk-frontend/dist/govuk/common/index.mjs.map +1 -0
  54. data/node_modules/govuk-frontend/dist/govuk/component.mjs +60 -0
  55. data/node_modules/govuk-frontend/dist/govuk/component.mjs.map +1 -0
  56. data/node_modules/govuk-frontend/dist/govuk/components/_all.scss +10 -0
  57. data/node_modules/govuk-frontend/dist/govuk/components/_all.scss.map +1 -0
  58. data/node_modules/govuk-frontend/dist/govuk/components/_index.scss +40 -0
  59. data/node_modules/govuk-frontend/dist/govuk/components/_index.scss.map +1 -0
  60. data/node_modules/govuk-frontend/dist/govuk/components/accordion/README.md +15 -0
  61. data/node_modules/govuk-frontend/dist/govuk/components/accordion/_accordion.scss +4 -0
  62. data/node_modules/govuk-frontend/dist/govuk/components/accordion/_accordion.scss.map +1 -0
  63. data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss +370 -0
  64. data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss.map +1 -0
  65. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +830 -0
  66. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js.map +1 -0
  67. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +822 -0
  68. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs.map +1 -0
  69. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs +346 -0
  70. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs.map +1 -0
  71. data/node_modules/govuk-frontend/dist/govuk/components/accordion/fixtures.json +377 -0
  72. data/node_modules/govuk-frontend/dist/govuk/components/accordion/macro-options.json +142 -0
  73. data/node_modules/govuk-frontend/dist/govuk/components/accordion/macro.njk +3 -0
  74. data/node_modules/govuk-frontend/dist/govuk/components/accordion/template-default.html +30 -0
  75. data/node_modules/govuk-frontend/dist/govuk/components/accordion/template-with-additional-descriptions.html +39 -0
  76. data/node_modules/govuk-frontend/dist/govuk/components/accordion/template-with-all-sections-already-open.html +30 -0
  77. data/node_modules/govuk-frontend/dist/govuk/components/accordion/template-with-long-content-and-description.html +36 -0
  78. data/node_modules/govuk-frontend/dist/govuk/components/accordion/template.njk +67 -0
  79. data/node_modules/govuk-frontend/dist/govuk/components/back-link/README.md +15 -0
  80. data/node_modules/govuk-frontend/dist/govuk/components/back-link/_back-link.scss +4 -0
  81. data/node_modules/govuk-frontend/dist/govuk/components/back-link/_back-link.scss.map +1 -0
  82. data/node_modules/govuk-frontend/dist/govuk/components/back-link/_index.scss +83 -0
  83. data/node_modules/govuk-frontend/dist/govuk/components/back-link/_index.scss.map +1 -0
  84. data/node_modules/govuk-frontend/dist/govuk/components/back-link/fixtures.json +86 -0
  85. data/node_modules/govuk-frontend/dist/govuk/components/back-link/macro-options.json +32 -0
  86. data/node_modules/govuk-frontend/dist/govuk/components/back-link/macro.njk +3 -0
  87. data/node_modules/govuk-frontend/dist/govuk/components/back-link/template-default.html +1 -0
  88. data/node_modules/govuk-frontend/dist/govuk/components/back-link/template-inverse.html +1 -0
  89. data/node_modules/govuk-frontend/dist/govuk/components/back-link/template.njk +6 -0
  90. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/README.md +15 -0
  91. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_breadcrumbs.scss +4 -0
  92. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_breadcrumbs.scss.map +1 -0
  93. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_index.scss +134 -0
  94. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/_index.scss.map +1 -0
  95. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/fixtures.json +258 -0
  96. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/macro-options.json +58 -0
  97. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/macro.njk +3 -0
  98. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-default.html +16 -0
  99. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-inverse.html +11 -0
  100. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-collapse-on-mobile.html +13 -0
  101. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-last-breadcrumb-as-current-page.html +11 -0
  102. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-one-level.html +7 -0
  103. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-without-the-home-section.html +10 -0
  104. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template.njk +30 -0
  105. data/node_modules/govuk-frontend/dist/govuk/components/button/README.md +15 -0
  106. data/node_modules/govuk-frontend/dist/govuk/components/button/_button.scss +4 -0
  107. data/node_modules/govuk-frontend/dist/govuk/components/button/_button.scss.map +1 -0
  108. data/node_modules/govuk-frontend/dist/govuk/components/button/_index.scss +262 -0
  109. data/node_modules/govuk-frontend/dist/govuk/components/button/_index.scss.map +1 -0
  110. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js +363 -0
  111. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js.map +1 -0
  112. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs +355 -0
  113. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs.map +1 -0
  114. data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs +70 -0
  115. data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs.map +1 -0
  116. data/node_modules/govuk-frontend/dist/govuk/components/button/fixtures.json +368 -0
  117. data/node_modules/govuk-frontend/dist/govuk/components/button/macro-options.json +81 -0
  118. data/node_modules/govuk-frontend/dist/govuk/components/button/macro.njk +3 -0
  119. data/node_modules/govuk-frontend/dist/govuk/components/button/template-default.html +3 -0
  120. data/node_modules/govuk-frontend/dist/govuk/components/button/template-disabled.html +3 -0
  121. data/node_modules/govuk-frontend/dist/govuk/components/button/template-input.html +1 -0
  122. data/node_modules/govuk-frontend/dist/govuk/components/button/template-inverse.html +3 -0
  123. data/node_modules/govuk-frontend/dist/govuk/components/button/template-link.html +3 -0
  124. data/node_modules/govuk-frontend/dist/govuk/components/button/template-secondary.html +3 -0
  125. data/node_modules/govuk-frontend/dist/govuk/components/button/template-start.html +6 -0
  126. data/node_modules/govuk-frontend/dist/govuk/components/button/template-warning.html +3 -0
  127. data/node_modules/govuk-frontend/dist/govuk/components/button/template.njk +58 -0
  128. data/node_modules/govuk-frontend/dist/govuk/components/character-count/README.md +15 -0
  129. data/node_modules/govuk-frontend/dist/govuk/components/character-count/_character-count.scss +4 -0
  130. data/node_modules/govuk-frontend/dist/govuk/components/character-count/_character-count.scss.map +1 -0
  131. data/node_modules/govuk-frontend/dist/govuk/components/character-count/_index.scss +44 -0
  132. data/node_modules/govuk-frontend/dist/govuk/components/character-count/_index.scss.map +1 -0
  133. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +806 -0
  134. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js.map +1 -0
  135. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +798 -0
  136. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs.map +1 -0
  137. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +299 -0
  138. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs.map +1 -0
  139. data/node_modules/govuk-frontend/dist/govuk/components/character-count/fixtures.json +463 -0
  140. data/node_modules/govuk-frontend/dist/govuk/components/character-count/macro-options.json +199 -0
  141. data/node_modules/govuk-frontend/dist/govuk/components/character-count/macro.njk +3 -0
  142. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-default.html +9 -0
  143. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-custom-rows.html +9 -0
  144. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-default-value-exceeding-limit.html +15 -0
  145. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-default-value.html +12 -0
  146. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-hint-and-error.html +15 -0
  147. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-hint.html +12 -0
  148. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-label-as-page-heading.html +11 -0
  149. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-threshold.html +9 -0
  150. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-word-count.html +9 -0
  151. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template.njk +121 -0
  152. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/README.md +15 -0
  153. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_checkboxes.scss +4 -0
  154. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_checkboxes.scss.map +1 -0
  155. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_index.scss +311 -0
  156. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_index.scss.map +1 -0
  157. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js +248 -0
  158. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js.map +1 -0
  159. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs +240 -0
  160. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs.map +1 -0
  161. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs +111 -0
  162. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs.map +1 -0
  163. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/fixtures.json +1339 -0
  164. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/macro-options.json +229 -0
  165. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/macro.njk +3 -0
  166. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-default.html +27 -0
  167. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-conditional-reveal.html +25 -0
  168. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-divider-and-none.html +34 -0
  169. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-error.html +30 -0
  170. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-hint.html +30 -0
  171. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-long-text.html +27 -0
  172. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small.html +27 -0
  173. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-conditional-items.html +39 -0
  174. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-divider-and-none.html +34 -0
  175. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-divider-none-and-conditional-items.html +44 -0
  176. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-error-message.html +39 -0
  177. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-hint.html +30 -0
  178. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-hints-on-items.html +27 -0
  179. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-legend-as-a-page-heading.html +32 -0
  180. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-optional-form-group-classes-showing-group-error.html +40 -0
  181. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-pre-checked-values.html +39 -0
  182. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-with-very-long-option-text.html +30 -0
  183. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template.njk +122 -0
  184. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/README.md +15 -0
  185. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_cookie-banner.scss +4 -0
  186. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_cookie-banner.scss.map +1 -0
  187. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_index.scss +59 -0
  188. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_index.scss.map +1 -0
  189. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/fixtures.json +543 -0
  190. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/macro-options.json +132 -0
  191. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/macro.njk +3 -0
  192. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/template-accepted-confirmation-banner.html +19 -0
  193. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/template-default.html +26 -0
  194. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/template-rejected-confirmation-banner.html +19 -0
  195. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/template-with-html.html +27 -0
  196. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/template.njk +57 -0
  197. data/node_modules/govuk-frontend/dist/govuk/components/date-input/README.md +15 -0
  198. data/node_modules/govuk-frontend/dist/govuk/components/date-input/_date-input.scss +4 -0
  199. data/node_modules/govuk-frontend/dist/govuk/components/date-input/_date-input.scss.map +1 -0
  200. data/node_modules/govuk-frontend/dist/govuk/components/date-input/_index.scss +28 -0
  201. data/node_modules/govuk-frontend/dist/govuk/components/date-input/_index.scss.map +1 -0
  202. data/node_modules/govuk-frontend/dist/govuk/components/date-input/fixtures.json +672 -0
  203. data/node_modules/govuk-frontend/dist/govuk/components/date-input/macro-options.json +163 -0
  204. data/node_modules/govuk-frontend/dist/govuk/components/date-input/macro.njk +3 -0
  205. data/node_modules/govuk-frontend/dist/govuk/components/date-input/template-day-and-month.html +28 -0
  206. data/node_modules/govuk-frontend/dist/govuk/components/date-input/template-default.html +36 -0
  207. data/node_modules/govuk-frontend/dist/govuk/components/date-input/template-month-and-year.html +28 -0
  208. data/node_modules/govuk-frontend/dist/govuk/components/date-input/template-with-error-on-day-input.html +39 -0
  209. data/node_modules/govuk-frontend/dist/govuk/components/date-input/template-with-error-on-month-input.html +39 -0
  210. data/node_modules/govuk-frontend/dist/govuk/components/date-input/template-with-error-on-year-input.html +39 -0
  211. data/node_modules/govuk-frontend/dist/govuk/components/date-input/template-with-errors-and-hint.html +39 -0
  212. data/node_modules/govuk-frontend/dist/govuk/components/date-input/template-with-errors-only.html +36 -0
  213. data/node_modules/govuk-frontend/dist/govuk/components/date-input/template-with-items.html +36 -0
  214. data/node_modules/govuk-frontend/dist/govuk/components/date-input/template.njk +106 -0
  215. data/node_modules/govuk-frontend/dist/govuk/components/details/README.md +15 -0
  216. data/node_modules/govuk-frontend/dist/govuk/components/details/_details.scss +4 -0
  217. data/node_modules/govuk-frontend/dist/govuk/components/details/_details.scss.map +1 -0
  218. data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss +139 -0
  219. data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss.map +1 -0
  220. data/node_modules/govuk-frontend/dist/govuk/components/details/fixtures.json +133 -0
  221. data/node_modules/govuk-frontend/dist/govuk/components/details/implementation.md +87 -0
  222. data/node_modules/govuk-frontend/dist/govuk/components/details/macro-options.json +56 -0
  223. data/node_modules/govuk-frontend/dist/govuk/components/details/macro.njk +3 -0
  224. data/node_modules/govuk-frontend/dist/govuk/components/details/template-default.html +10 -0
  225. data/node_modules/govuk-frontend/dist/govuk/components/details/template-expanded.html +10 -0
  226. data/node_modules/govuk-frontend/dist/govuk/components/details/template-with-html.html +18 -0
  227. data/node_modules/govuk-frontend/dist/govuk/components/details/template.njk +14 -0
  228. data/node_modules/govuk-frontend/dist/govuk/components/error-message/README.md +15 -0
  229. data/node_modules/govuk-frontend/dist/govuk/components/error-message/_error-message.scss +4 -0
  230. data/node_modules/govuk-frontend/dist/govuk/components/error-message/_error-message.scss.map +1 -0
  231. data/node_modules/govuk-frontend/dist/govuk/components/error-message/_index.scss +14 -0
  232. data/node_modules/govuk-frontend/dist/govuk/components/error-message/_index.scss.map +1 -0
  233. data/node_modules/govuk-frontend/dist/govuk/components/error-message/fixtures.json +113 -0
  234. data/node_modules/govuk-frontend/dist/govuk/components/error-message/macro-options.json +38 -0
  235. data/node_modules/govuk-frontend/dist/govuk/components/error-message/macro.njk +3 -0
  236. data/node_modules/govuk-frontend/dist/govuk/components/error-message/template-default.html +3 -0
  237. data/node_modules/govuk-frontend/dist/govuk/components/error-message/template-translated.html +3 -0
  238. data/node_modules/govuk-frontend/dist/govuk/components/error-message/template.njk +13 -0
  239. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/README.md +15 -0
  240. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_error-summary.scss +4 -0
  241. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_error-summary.scss.map +1 -0
  242. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_index.scss +56 -0
  243. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_index.scss.map +1 -0
  244. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js +423 -0
  245. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js.map +1 -0
  246. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs +415 -0
  247. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs.map +1 -0
  248. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs +101 -0
  249. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs.map +1 -0
  250. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/fixtures.json +326 -0
  251. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/macro-options.json +82 -0
  252. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/macro.njk +3 -0
  253. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/template-default.html +17 -0
  254. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/template-mixed-with-and-without-links.html +17 -0
  255. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/template-with-description-only.html +12 -0
  256. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/template-with-everything.html +20 -0
  257. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/template-without-links.html +14 -0
  258. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/template.njk +37 -0
  259. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/README.md +15 -0
  260. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/_exit-this-page.scss +4 -0
  261. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/_exit-this-page.scss.map +1 -0
  262. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/_index.scss +92 -0
  263. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/_index.scss.map +1 -0
  264. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +707 -0
  265. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js.map +1 -0
  266. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +699 -0
  267. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs.map +1 -0
  268. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs +223 -0
  269. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs.map +1 -0
  270. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/fixtures.json +62 -0
  271. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/macro-options.json +62 -0
  272. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/macro.njk +3 -0
  273. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/template-default.html +5 -0
  274. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/template.njk +25 -0
  275. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/README.md +15 -0
  276. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/_fieldset.scss +4 -0
  277. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/_fieldset.scss.map +1 -0
  278. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/_index.scss +69 -0
  279. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/_index.scss.map +1 -0
  280. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/fixtures.json +260 -0
  281. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/macro-options.json +70 -0
  282. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/macro.njk +3 -0
  283. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/template-as-page-heading-l.html +7 -0
  284. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/template-as-page-heading-m.html +7 -0
  285. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/template-as-page-heading-s.html +7 -0
  286. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/template-as-page-heading-without-class.html +7 -0
  287. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/template-as-page-heading-xl.html +7 -0
  288. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/template-default.html +5 -0
  289. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/template-styled-as-large-text.html +5 -0
  290. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/template-styled-as-medium-text.html +5 -0
  291. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/template-styled-as-small-text.html +5 -0
  292. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/template-styled-as-xl-text.html +5 -0
  293. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/template.njk +24 -0
  294. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/README.md +15 -0
  295. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_file-upload.scss +4 -0
  296. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_file-upload.scss.map +1 -0
  297. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss +218 -0
  298. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss.map +1 -0
  299. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js +744 -0
  300. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js.map +1 -0
  301. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs +736 -0
  302. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs.map +1 -0
  303. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs +257 -0
  304. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs.map +1 -0
  305. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/fixtures.json +378 -0
  306. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/macro-options.json +174 -0
  307. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/macro.njk +3 -0
  308. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-default.html +6 -0
  309. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-enhanced-with-error-message-and-hint.html +16 -0
  310. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-enhanced.html +10 -0
  311. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-translated.html +10 -0
  312. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-with-error-message-and-hint.html +12 -0
  313. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-with-hint-text.html +9 -0
  314. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-with-label-as-page-heading.html +8 -0
  315. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template.njk +90 -0
  316. data/node_modules/govuk-frontend/dist/govuk/components/footer/README.md +15 -0
  317. data/node_modules/govuk-frontend/dist/govuk/components/footer/_footer.scss +4 -0
  318. data/node_modules/govuk-frontend/dist/govuk/components/footer/_footer.scss.map +1 -0
  319. data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss +194 -0
  320. data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss.map +1 -0
  321. data/node_modules/govuk-frontend/dist/govuk/components/footer/fixtures.json +712 -0
  322. data/node_modules/govuk-frontend/dist/govuk/components/footer/macro-options.json +170 -0
  323. data/node_modules/govuk-frontend/dist/govuk/components/footer/macro.njk +3 -0
  324. data/node_modules/govuk-frontend/dist/govuk/components/footer/template-default.html +38 -0
  325. data/node_modules/govuk-frontend/dist/govuk/components/footer/template-full-gds-example.html +212 -0
  326. data/node_modules/govuk-frontend/dist/govuk/components/footer/template-three-equal-columns.html +146 -0
  327. data/node_modules/govuk-frontend/dist/govuk/components/footer/template-with-custom-html-content-licence-and-copyright-notice.html +33 -0
  328. data/node_modules/govuk-frontend/dist/govuk/components/footer/template-with-custom-meta.html +42 -0
  329. data/node_modules/govuk-frontend/dist/govuk/components/footer/template-with-custom-text-content-licence-and-copyright-notice.html +33 -0
  330. data/node_modules/govuk-frontend/dist/govuk/components/footer/template-with-default-width-navigation-one-column.html +76 -0
  331. data/node_modules/govuk-frontend/dist/govuk/components/footer/template-with-default-width-navigation-two-columns.html +76 -0
  332. data/node_modules/govuk-frontend/dist/govuk/components/footer/template-with-meta-links-and-meta-content.html +84 -0
  333. data/node_modules/govuk-frontend/dist/govuk/components/footer/template-with-navigation.html +96 -0
  334. data/node_modules/govuk-frontend/dist/govuk/components/footer/template.njk +107 -0
  335. data/node_modules/govuk-frontend/dist/govuk/components/header/README.md +15 -0
  336. data/node_modules/govuk-frontend/dist/govuk/components/header/_header.scss +4 -0
  337. data/node_modules/govuk-frontend/dist/govuk/components/header/_header.scss.map +1 -0
  338. data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss +548 -0
  339. data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss.map +1 -0
  340. data/node_modules/govuk-frontend/dist/govuk/components/header/fixtures.json +602 -0
  341. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js +233 -0
  342. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js.map +1 -0
  343. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs +225 -0
  344. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs.map +1 -0
  345. data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs +89 -0
  346. data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs.map +1 -0
  347. data/node_modules/govuk-frontend/dist/govuk/components/header/macro-options.json +131 -0
  348. data/node_modules/govuk-frontend/dist/govuk/components/header/macro.njk +3 -0
  349. data/node_modules/govuk-frontend/dist/govuk/components/header/template-default.html +29 -0
  350. data/node_modules/govuk-frontend/dist/govuk/components/header/template-full-width-with-navigation.html +54 -0
  351. data/node_modules/govuk-frontend/dist/govuk/components/header/template-full-width.html +29 -0
  352. data/node_modules/govuk-frontend/dist/govuk/components/header/template-navigation-item-with-html.html +54 -0
  353. data/node_modules/govuk-frontend/dist/govuk/components/header/template-navigation-item-with-text-without-link.html +48 -0
  354. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-custom-menu-button-text.html +59 -0
  355. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-full-width-border.html +29 -0
  356. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-large-navigation.html +119 -0
  357. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-navigation.html +59 -0
  358. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-product-name.html +30 -0
  359. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-service-name-and-navigation.html +62 -0
  360. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-service-name-but-no-service-url.html +34 -0
  361. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-service-name.html +34 -0
  362. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-st-edwards-crown.html +19 -0
  363. data/node_modules/govuk-frontend/dist/govuk/components/header/template.njk +66 -0
  364. data/node_modules/govuk-frontend/dist/govuk/components/hint/README.md +15 -0
  365. data/node_modules/govuk-frontend/dist/govuk/components/hint/_hint.scss +4 -0
  366. data/node_modules/govuk-frontend/dist/govuk/components/hint/_hint.scss.map +1 -0
  367. data/node_modules/govuk-frontend/dist/govuk/components/hint/_index.scss +45 -0
  368. data/node_modules/govuk-frontend/dist/govuk/components/hint/_index.scss.map +1 -0
  369. data/node_modules/govuk-frontend/dist/govuk/components/hint/fixtures.json +77 -0
  370. data/node_modules/govuk-frontend/dist/govuk/components/hint/macro-options.json +32 -0
  371. data/node_modules/govuk-frontend/dist/govuk/components/hint/macro.njk +3 -0
  372. data/node_modules/govuk-frontend/dist/govuk/components/hint/template-default.html +5 -0
  373. data/node_modules/govuk-frontend/dist/govuk/components/hint/template-with-html.html +4 -0
  374. data/node_modules/govuk-frontend/dist/govuk/components/hint/template.njk +6 -0
  375. data/node_modules/govuk-frontend/dist/govuk/components/input/README.md +15 -0
  376. data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss +168 -0
  377. data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss.map +1 -0
  378. data/node_modules/govuk-frontend/dist/govuk/components/input/_input.scss +4 -0
  379. data/node_modules/govuk-frontend/dist/govuk/components/input/_input.scss.map +1 -0
  380. data/node_modules/govuk-frontend/dist/govuk/components/input/fixtures.json +830 -0
  381. data/node_modules/govuk-frontend/dist/govuk/components/input/macro-options.json +245 -0
  382. data/node_modules/govuk-frontend/dist/govuk/components/input/macro.njk +3 -0
  383. data/node_modules/govuk-frontend/dist/govuk/components/input/template-default.html +6 -0
  384. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-error-and-hint.html +12 -0
  385. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-error-message.html +9 -0
  386. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-extra-letter-spacing.html +6 -0
  387. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-hint-text.html +9 -0
  388. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-label-as-page-heading.html +8 -0
  389. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-prefix-and-suffix-and-error.html +13 -0
  390. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-prefix-and-suffix-and-width-modifier.html +10 -0
  391. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-prefix-and-suffix.html +10 -0
  392. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-prefix.html +9 -0
  393. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-suffix.html +9 -0
  394. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-width-10-class.html +9 -0
  395. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-width-2-class.html +9 -0
  396. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-width-20-class.html +9 -0
  397. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-width-3-class.html +9 -0
  398. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-width-30-class.html +9 -0
  399. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-width-4-class.html +9 -0
  400. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-width-5-class.html +9 -0
  401. data/node_modules/govuk-frontend/dist/govuk/components/input/template.njk +133 -0
  402. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/README.md +15 -0
  403. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/_index.scss +26 -0
  404. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/_index.scss.map +1 -0
  405. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/_inset-text.scss +4 -0
  406. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/_inset-text.scss.map +1 -0
  407. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/fixtures.json +76 -0
  408. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/macro-options.json +38 -0
  409. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/macro.njk +3 -0
  410. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/template-default.html +3 -0
  411. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/template-with-html.html +11 -0
  412. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/template.njk +6 -0
  413. data/node_modules/govuk-frontend/dist/govuk/components/label/README.md +15 -0
  414. data/node_modules/govuk-frontend/dist/govuk/components/label/_index.scss +46 -0
  415. data/node_modules/govuk-frontend/dist/govuk/components/label/_index.scss.map +1 -0
  416. data/node_modules/govuk-frontend/dist/govuk/components/label/_label.scss +4 -0
  417. data/node_modules/govuk-frontend/dist/govuk/components/label/_label.scss.map +1 -0
  418. data/node_modules/govuk-frontend/dist/govuk/components/label/fixtures.json +210 -0
  419. data/node_modules/govuk-frontend/dist/govuk/components/label/macro-options.json +38 -0
  420. data/node_modules/govuk-frontend/dist/govuk/components/label/macro.njk +3 -0
  421. data/node_modules/govuk-frontend/dist/govuk/components/label/template-as-page-heading-l.html +5 -0
  422. data/node_modules/govuk-frontend/dist/govuk/components/label/template-as-page-heading-m.html +5 -0
  423. data/node_modules/govuk-frontend/dist/govuk/components/label/template-as-page-heading-s.html +5 -0
  424. data/node_modules/govuk-frontend/dist/govuk/components/label/template-as-page-heading-without-class.html +5 -0
  425. data/node_modules/govuk-frontend/dist/govuk/components/label/template-as-page-heading-xl.html +5 -0
  426. data/node_modules/govuk-frontend/dist/govuk/components/label/template-default.html +3 -0
  427. data/node_modules/govuk-frontend/dist/govuk/components/label/template-styled-as-large-text.html +3 -0
  428. data/node_modules/govuk-frontend/dist/govuk/components/label/template-styled-as-medium-text.html +3 -0
  429. data/node_modules/govuk-frontend/dist/govuk/components/label/template-styled-as-small-text.html +3 -0
  430. data/node_modules/govuk-frontend/dist/govuk/components/label/template-styled-as-xl-text.html +3 -0
  431. data/node_modules/govuk-frontend/dist/govuk/components/label/template-with-bold-text.html +3 -0
  432. data/node_modules/govuk-frontend/dist/govuk/components/label/template.njk +19 -0
  433. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/README.md +15 -0
  434. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss +93 -0
  435. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss.map +1 -0
  436. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_notification-banner.scss +4 -0
  437. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_notification-banner.scss.map +1 -0
  438. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/fixtures.json +260 -0
  439. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/macro-options.json +74 -0
  440. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/macro.njk +3 -0
  441. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js +365 -0
  442. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js.map +1 -0
  443. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs +357 -0
  444. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs.map +1 -0
  445. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs +49 -0
  446. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs.map +1 -0
  447. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/template-default.html +12 -0
  448. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/template-with-long-heading.html +12 -0
  449. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/template-with-lots-of-content.html +19 -0
  450. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/template-with-text-as-html.html +21 -0
  451. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/template-with-type-as-success.html +12 -0
  452. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/template.njk +49 -0
  453. data/node_modules/govuk-frontend/dist/govuk/components/pagination/README.md +15 -0
  454. data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss +228 -0
  455. data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss.map +1 -0
  456. data/node_modules/govuk-frontend/dist/govuk/components/pagination/_pagination.scss +4 -0
  457. data/node_modules/govuk-frontend/dist/govuk/components/pagination/_pagination.scss.map +1 -0
  458. data/node_modules/govuk-frontend/dist/govuk/components/pagination/fixtures.json +393 -0
  459. data/node_modules/govuk-frontend/dist/govuk/components/pagination/macro-options.json +140 -0
  460. data/node_modules/govuk-frontend/dist/govuk/components/pagination/macro.njk +3 -0
  461. data/node_modules/govuk-frontend/dist/govuk/components/pagination/template-default.html +39 -0
  462. data/node_modules/govuk-frontend/dist/govuk/components/pagination/template-first-page.html +29 -0
  463. data/node_modules/govuk-frontend/dist/govuk/components/pagination/template-last-page.html +29 -0
  464. data/node_modules/govuk-frontend/dist/govuk/components/pagination/template-with-custom-link-and-item-text.html +39 -0
  465. data/node_modules/govuk-frontend/dist/govuk/components/pagination/template-with-many-pages.html +65 -0
  466. data/node_modules/govuk-frontend/dist/govuk/components/pagination/template-with-next-only.html +12 -0
  467. data/node_modules/govuk-frontend/dist/govuk/components/pagination/template-with-prev-and-next-only-and-labels.html +26 -0
  468. data/node_modules/govuk-frontend/dist/govuk/components/pagination/template-with-prev-and-next-only-and-very-long-labels.html +26 -0
  469. data/node_modules/govuk-frontend/dist/govuk/components/pagination/template-with-prev-and-next-only.html +22 -0
  470. data/node_modules/govuk-frontend/dist/govuk/components/pagination/template-with-previous-only.html +12 -0
  471. data/node_modules/govuk-frontend/dist/govuk/components/pagination/template.njk +85 -0
  472. data/node_modules/govuk-frontend/dist/govuk/components/panel/README.md +15 -0
  473. data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss +58 -0
  474. data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss.map +1 -0
  475. data/node_modules/govuk-frontend/dist/govuk/components/panel/_panel.scss +4 -0
  476. data/node_modules/govuk-frontend/dist/govuk/components/panel/_panel.scss.map +1 -0
  477. data/node_modules/govuk-frontend/dist/govuk/components/panel/fixtures.json +118 -0
  478. data/node_modules/govuk-frontend/dist/govuk/components/panel/macro-options.json +50 -0
  479. data/node_modules/govuk-frontend/dist/govuk/components/panel/macro.njk +3 -0
  480. data/node_modules/govuk-frontend/dist/govuk/components/panel/template-default.html +8 -0
  481. data/node_modules/govuk-frontend/dist/govuk/components/panel/template.njk +16 -0
  482. data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss +57 -0
  483. data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss.map +1 -0
  484. data/node_modules/govuk-frontend/dist/govuk/components/password-input/_password-input.scss +4 -0
  485. data/node_modules/govuk-frontend/dist/govuk/components/password-input/_password-input.scss.map +1 -0
  486. data/node_modules/govuk-frontend/dist/govuk/components/password-input/fixtures.json +215 -0
  487. data/node_modules/govuk-frontend/dist/govuk/components/password-input/macro-options.json +181 -0
  488. data/node_modules/govuk-frontend/dist/govuk/components/password-input/macro.njk +3 -0
  489. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +638 -0
  490. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js.map +1 -0
  491. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +630 -0
  492. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs.map +1 -0
  493. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs +150 -0
  494. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs.map +1 -0
  495. data/node_modules/govuk-frontend/dist/govuk/components/password-input/template-default.html +11 -0
  496. data/node_modules/govuk-frontend/dist/govuk/components/password-input/template-with-error-message.html +17 -0
  497. data/node_modules/govuk-frontend/dist/govuk/components/password-input/template-with-hint-text.html +14 -0
  498. data/node_modules/govuk-frontend/dist/govuk/components/password-input/template-with-input-width-class.html +11 -0
  499. data/node_modules/govuk-frontend/dist/govuk/components/password-input/template-with-label-as-page-heading.html +13 -0
  500. data/node_modules/govuk-frontend/dist/govuk/components/password-input/template.njk +93 -0
  501. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/README.md +15 -0
  502. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss +36 -0
  503. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss.map +1 -0
  504. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_phase-banner.scss +4 -0
  505. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_phase-banner.scss.map +1 -0
  506. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/fixtures.json +97 -0
  507. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/macro-options.json +33 -0
  508. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/macro.njk +3 -0
  509. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/template-default.html +10 -0
  510. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/template.njk +17 -0
  511. data/node_modules/govuk-frontend/dist/govuk/components/radios/README.md +15 -0
  512. data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss +328 -0
  513. data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss.map +1 -0
  514. data/node_modules/govuk-frontend/dist/govuk/components/radios/_radios.scss +4 -0
  515. data/node_modules/govuk-frontend/dist/govuk/components/radios/_radios.scss.map +1 -0
  516. data/node_modules/govuk-frontend/dist/govuk/components/radios/fixtures.json +1334 -0
  517. data/node_modules/govuk-frontend/dist/govuk/components/radios/macro-options.json +211 -0
  518. data/node_modules/govuk-frontend/dist/govuk/components/radios/macro.njk +3 -0
  519. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js +225 -0
  520. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js.map +1 -0
  521. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs +217 -0
  522. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs.map +1 -0
  523. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs +88 -0
  524. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs.map +1 -0
  525. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-default.html +21 -0
  526. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-inline.html +24 -0
  527. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-inline.html +27 -0
  528. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-a-divider.html +28 -0
  529. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-conditional-reveal.html +31 -0
  530. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-error.html +30 -0
  531. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-hint.html +30 -0
  532. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-long-text.html +27 -0
  533. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small.html +27 -0
  534. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-a-divider.html +28 -0
  535. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-conditional-item-checked.html +39 -0
  536. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-conditional-items-and-pre-checked-value.html +39 -0
  537. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-conditional-items.html +39 -0
  538. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-fieldset-and-error-message.html +24 -0
  539. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-hint.html +24 -0
  540. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-hints-on-items.html +29 -0
  541. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-legend-as-page-heading.html +26 -0
  542. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-optional-form-group-classes-showing-group-error.html +40 -0
  543. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-very-long-option-text.html +33 -0
  544. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-without-fieldset.html +22 -0
  545. data/node_modules/govuk-frontend/dist/govuk/components/radios/template.njk +115 -0
  546. data/node_modules/govuk-frontend/dist/govuk/components/select/README.md +15 -0
  547. data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss +59 -0
  548. data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss.map +1 -0
  549. data/node_modules/govuk-frontend/dist/govuk/components/select/_select.scss +4 -0
  550. data/node_modules/govuk-frontend/dist/govuk/components/select/_select.scss.map +1 -0
  551. data/node_modules/govuk-frontend/dist/govuk/components/select/fixtures.json +550 -0
  552. data/node_modules/govuk-frontend/dist/govuk/components/select/macro-options.json +163 -0
  553. data/node_modules/govuk-frontend/dist/govuk/components/select/macro.njk +3 -0
  554. data/node_modules/govuk-frontend/dist/govuk/components/select/template-default.html +10 -0
  555. data/node_modules/govuk-frontend/dist/govuk/components/select/template-with-full-width-override.html +10 -0
  556. data/node_modules/govuk-frontend/dist/govuk/components/select/template-with-hint-text-and-error-message.html +16 -0
  557. data/node_modules/govuk-frontend/dist/govuk/components/select/template-with-label-as-page-heading.html +12 -0
  558. data/node_modules/govuk-frontend/dist/govuk/components/select/template.njk +68 -0
  559. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/README.md +15 -0
  560. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss +254 -0
  561. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss.map +1 -0
  562. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_service-navigation.scss +4 -0
  563. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_service-navigation.scss.map +1 -0
  564. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/fixtures.json +651 -0
  565. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/macro-options.json +144 -0
  566. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/macro.njk +3 -0
  567. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +229 -0
  568. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js.map +1 -0
  569. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs +221 -0
  570. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs.map +1 -0
  571. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs +85 -0
  572. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs.map +1 -0
  573. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-default.html +57 -0
  574. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-inverse.html +63 -0
  575. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-a-single-navigation-item-and-collapsenavigationonmobile-set-to-true.html +38 -0
  576. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-a-single-navigation-item.html +35 -0
  577. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-collapsenavigationonmobile-set-to-false.html +60 -0
  578. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-html-navigation-items.html +49 -0
  579. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-large-navigation.html +153 -0
  580. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-long-service-name.html +20 -0
  581. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-navigation-with-a-current-item.html +58 -0
  582. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-non-link-navigation-items.html +49 -0
  583. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-link.html +20 -0
  584. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-name-and-navigation.html +63 -0
  585. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-name.html +18 -0
  586. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template.njk +106 -0
  587. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/README.md +15 -0
  588. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_index.scss +52 -0
  589. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_index.scss.map +1 -0
  590. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_skip-link.scss +4 -0
  591. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_skip-link.scss.map +1 -0
  592. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/fixtures.json +113 -0
  593. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/macro-options.json +32 -0
  594. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/macro.njk +3 -0
  595. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js +224 -0
  596. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js.map +1 -0
  597. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs +216 -0
  598. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs.map +1 -0
  599. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs +58 -0
  600. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs.map +1 -0
  601. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/template-default.html +1 -0
  602. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/template-with-focus.html +1 -0
  603. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/template.njk +6 -0
  604. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/README.md +15 -0
  605. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss +269 -0
  606. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss.map +1 -0
  607. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_summary-list.scss +4 -0
  608. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_summary-list.scss.map +1 -0
  609. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/fixtures.json +1528 -0
  610. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/macro-options.json +248 -0
  611. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/macro.njk +3 -0
  612. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/template-as-a-summary-card-extreme.html +106 -0
  613. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/template-as-a-summary-card-with-a-html-header.html +28 -0
  614. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/template-as-a-summary-card-with-a-text-header.html +28 -0
  615. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/template-as-a-summary-card-with-actions-plus-summary-list-actions.html +49 -0
  616. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/template-as-a-summary-card-with-actions.html +36 -0
  617. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/template-default.html +35 -0
  618. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/template-extreme.html +261 -0
  619. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/template-no-border-on-last-row.html +35 -0
  620. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/template-no-border.html +35 -0
  621. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/template-with-actions.html +58 -0
  622. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/template.njk +94 -0
  623. data/node_modules/govuk-frontend/dist/govuk/components/table/README.md +15 -0
  624. data/node_modules/govuk-frontend/dist/govuk/components/table/_index.scss +75 -0
  625. data/node_modules/govuk-frontend/dist/govuk/components/table/_index.scss.map +1 -0
  626. data/node_modules/govuk-frontend/dist/govuk/components/table/_table.scss +4 -0
  627. data/node_modules/govuk-frontend/dist/govuk/components/table/_table.scss.map +1 -0
  628. data/node_modules/govuk-frontend/dist/govuk/components/table/fixtures.json +651 -0
  629. data/node_modules/govuk-frontend/dist/govuk/components/table/macro-options.json +132 -0
  630. data/node_modules/govuk-frontend/dist/govuk/components/table/macro.njk +3 -0
  631. data/node_modules/govuk-frontend/dist/govuk/components/table/template-default.html +19 -0
  632. data/node_modules/govuk-frontend/dist/govuk/components/table/template-with-head-and-caption.html +27 -0
  633. data/node_modules/govuk-frontend/dist/govuk/components/table/template-with-head.html +26 -0
  634. data/node_modules/govuk-frontend/dist/govuk/components/table/template.njk +57 -0
  635. data/node_modules/govuk-frontend/dist/govuk/components/tabs/README.md +15 -0
  636. data/node_modules/govuk-frontend/dist/govuk/components/tabs/_index.scss +134 -0
  637. data/node_modules/govuk-frontend/dist/govuk/components/tabs/_index.scss.map +1 -0
  638. data/node_modules/govuk-frontend/dist/govuk/components/tabs/_tabs.scss +4 -0
  639. data/node_modules/govuk-frontend/dist/govuk/components/tabs/_tabs.scss.map +1 -0
  640. data/node_modules/govuk-frontend/dist/govuk/components/tabs/fixtures.json +333 -0
  641. data/node_modules/govuk-frontend/dist/govuk/components/tabs/macro-options.json +84 -0
  642. data/node_modules/govuk-frontend/dist/govuk/components/tabs/macro.njk +3 -0
  643. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js +433 -0
  644. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js.map +1 -0
  645. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs +425 -0
  646. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs.map +1 -0
  647. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs +283 -0
  648. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs.map +1 -0
  649. data/node_modules/govuk-frontend/dist/govuk/components/tabs/template-default.html +117 -0
  650. data/node_modules/govuk-frontend/dist/govuk/components/tabs/template-tabs-with-anchor-in-panel.html +26 -0
  651. data/node_modules/govuk-frontend/dist/govuk/components/tabs/template.njk +48 -0
  652. data/node_modules/govuk-frontend/dist/govuk/components/tag/README.md +15 -0
  653. data/node_modules/govuk-frontend/dist/govuk/components/tag/_index.scss +97 -0
  654. data/node_modules/govuk-frontend/dist/govuk/components/tag/_index.scss.map +1 -0
  655. data/node_modules/govuk-frontend/dist/govuk/components/tag/_tag.scss +4 -0
  656. data/node_modules/govuk-frontend/dist/govuk/components/tag/_tag.scss.map +1 -0
  657. data/node_modules/govuk-frontend/dist/govuk/components/tag/fixtures.json +161 -0
  658. data/node_modules/govuk-frontend/dist/govuk/components/tag/macro-options.json +26 -0
  659. data/node_modules/govuk-frontend/dist/govuk/components/tag/macro.njk +3 -0
  660. data/node_modules/govuk-frontend/dist/govuk/components/tag/template-default.html +3 -0
  661. data/node_modules/govuk-frontend/dist/govuk/components/tag/template-green.html +3 -0
  662. data/node_modules/govuk-frontend/dist/govuk/components/tag/template-grey.html +3 -0
  663. data/node_modules/govuk-frontend/dist/govuk/components/tag/template-light-blue.html +3 -0
  664. data/node_modules/govuk-frontend/dist/govuk/components/tag/template-orange.html +3 -0
  665. data/node_modules/govuk-frontend/dist/govuk/components/tag/template-pink.html +3 -0
  666. data/node_modules/govuk-frontend/dist/govuk/components/tag/template-purple.html +3 -0
  667. data/node_modules/govuk-frontend/dist/govuk/components/tag/template-red.html +3 -0
  668. data/node_modules/govuk-frontend/dist/govuk/components/tag/template-turquoise.html +3 -0
  669. data/node_modules/govuk-frontend/dist/govuk/components/tag/template-yellow.html +3 -0
  670. data/node_modules/govuk-frontend/dist/govuk/components/tag/template.njk +6 -0
  671. data/node_modules/govuk-frontend/dist/govuk/components/task-list/README.md +15 -0
  672. data/node_modules/govuk-frontend/dist/govuk/components/task-list/_index.scss +79 -0
  673. data/node_modules/govuk-frontend/dist/govuk/components/task-list/_index.scss.map +1 -0
  674. data/node_modules/govuk-frontend/dist/govuk/components/task-list/_task-list.scss +4 -0
  675. data/node_modules/govuk-frontend/dist/govuk/components/task-list/_task-list.scss.map +1 -0
  676. data/node_modules/govuk-frontend/dist/govuk/components/task-list/fixtures.json +529 -0
  677. data/node_modules/govuk-frontend/dist/govuk/components/task-list/macro-options.json +119 -0
  678. data/node_modules/govuk-frontend/dist/govuk/components/task-list/macro.njk +3 -0
  679. data/node_modules/govuk-frontend/dist/govuk/components/task-list/template-default.html +37 -0
  680. data/node_modules/govuk-frontend/dist/govuk/components/task-list/template-with-all-possible-colours.html +143 -0
  681. data/node_modules/govuk-frontend/dist/govuk/components/task-list/template-with-empty-values.html +27 -0
  682. data/node_modules/govuk-frontend/dist/govuk/components/task-list/template-with-hint-text-and-additional-states.html +77 -0
  683. data/node_modules/govuk-frontend/dist/govuk/components/task-list/template-with-very-long-single-word-tags.html +37 -0
  684. data/node_modules/govuk-frontend/dist/govuk/components/task-list/template.njk +41 -0
  685. data/node_modules/govuk-frontend/dist/govuk/components/textarea/README.md +15 -0
  686. data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss +50 -0
  687. data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss.map +1 -0
  688. data/node_modules/govuk-frontend/dist/govuk/components/textarea/_textarea.scss +4 -0
  689. data/node_modules/govuk-frontend/dist/govuk/components/textarea/_textarea.scss.map +1 -0
  690. data/node_modules/govuk-frontend/dist/govuk/components/textarea/fixtures.json +316 -0
  691. data/node_modules/govuk-frontend/dist/govuk/components/textarea/macro-options.json +143 -0
  692. data/node_modules/govuk-frontend/dist/govuk/components/textarea/macro.njk +3 -0
  693. data/node_modules/govuk-frontend/dist/govuk/components/textarea/template-default.html +6 -0
  694. data/node_modules/govuk-frontend/dist/govuk/components/textarea/template-with-custom-rows.html +6 -0
  695. data/node_modules/govuk-frontend/dist/govuk/components/textarea/template-with-default-value.html +9 -0
  696. data/node_modules/govuk-frontend/dist/govuk/components/textarea/template-with-error-message.html +9 -0
  697. data/node_modules/govuk-frontend/dist/govuk/components/textarea/template-with-hint.html +9 -0
  698. data/node_modules/govuk-frontend/dist/govuk/components/textarea/template-with-label-as-page-heading.html +8 -0
  699. data/node_modules/govuk-frontend/dist/govuk/components/textarea/template.njk +56 -0
  700. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/README.md +15 -0
  701. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss +66 -0
  702. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss.map +1 -0
  703. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_warning-text.scss +4 -0
  704. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_warning-text.scss.map +1 -0
  705. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/fixtures.json +101 -0
  706. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/macro-options.json +32 -0
  707. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/macro.njk +3 -0
  708. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/template-default.html +7 -0
  709. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/template-multiple-lines.html +7 -0
  710. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/template.njk +10 -0
  711. data/node_modules/govuk-frontend/dist/govuk/core/_all.scss +10 -0
  712. data/node_modules/govuk-frontend/dist/govuk/core/_all.scss.map +1 -0
  713. data/node_modules/govuk-frontend/dist/govuk/core/_global-styles.scss +20 -0
  714. data/node_modules/govuk-frontend/dist/govuk/core/_global-styles.scss.map +1 -0
  715. data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +15 -0
  716. data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss.map +1 -0
  717. data/node_modules/govuk-frontend/dist/govuk/core/_index.scss +8 -0
  718. data/node_modules/govuk-frontend/dist/govuk/core/_index.scss.map +1 -0
  719. data/node_modules/govuk-frontend/dist/govuk/core/_links.scss +42 -0
  720. data/node_modules/govuk-frontend/dist/govuk/core/_links.scss.map +1 -0
  721. data/node_modules/govuk-frontend/dist/govuk/core/_lists.scss +67 -0
  722. data/node_modules/govuk-frontend/dist/govuk/core/_lists.scss.map +1 -0
  723. data/node_modules/govuk-frontend/dist/govuk/core/_section-break.scss +51 -0
  724. data/node_modules/govuk-frontend/dist/govuk/core/_section-break.scss.map +1 -0
  725. data/node_modules/govuk-frontend/dist/govuk/core/_typography.scss +189 -0
  726. data/node_modules/govuk-frontend/dist/govuk/core/_typography.scss.map +1 -0
  727. data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs +57 -0
  728. data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs.map +1 -0
  729. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css +3 -0
  730. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css.map +1 -0
  731. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -0
  732. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js.map +1 -0
  733. data/node_modules/govuk-frontend/dist/govuk/helpers/_all.scss +10 -0
  734. data/node_modules/govuk-frontend/dist/govuk/helpers/_all.scss.map +1 -0
  735. data/node_modules/govuk-frontend/dist/govuk/helpers/_clearfix.scss +17 -0
  736. data/node_modules/govuk-frontend/dist/govuk/helpers/_clearfix.scss.map +1 -0
  737. data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss +167 -0
  738. data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss.map +1 -0
  739. data/node_modules/govuk-frontend/dist/govuk/helpers/_device-pixels.scss +38 -0
  740. data/node_modules/govuk-frontend/dist/govuk/helpers/_device-pixels.scss.map +1 -0
  741. data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss +59 -0
  742. data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss.map +1 -0
  743. data/node_modules/govuk-frontend/dist/govuk/helpers/_font-faces.scss +41 -0
  744. data/node_modules/govuk-frontend/dist/govuk/helpers/_font-faces.scss.map +1 -0
  745. data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss +63 -0
  746. data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss.map +1 -0
  747. data/node_modules/govuk-frontend/dist/govuk/helpers/_index.scss +14 -0
  748. data/node_modules/govuk-frontend/dist/govuk/helpers/_index.scss.map +1 -0
  749. data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss +391 -0
  750. data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss.map +1 -0
  751. data/node_modules/govuk-frontend/dist/govuk/helpers/_media-queries.scss +82 -0
  752. data/node_modules/govuk-frontend/dist/govuk/helpers/_media-queries.scss.map +1 -0
  753. data/node_modules/govuk-frontend/dist/govuk/helpers/_shape-arrow.scss +82 -0
  754. data/node_modules/govuk-frontend/dist/govuk/helpers/_shape-arrow.scss.map +1 -0
  755. data/node_modules/govuk-frontend/dist/govuk/helpers/_spacing.scss +173 -0
  756. data/node_modules/govuk-frontend/dist/govuk/helpers/_spacing.scss.map +1 -0
  757. data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss +288 -0
  758. data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss.map +1 -0
  759. data/node_modules/govuk-frontend/dist/govuk/helpers/_visually-hidden.scss +88 -0
  760. data/node_modules/govuk-frontend/dist/govuk/helpers/_visually-hidden.scss.map +1 -0
  761. data/node_modules/govuk-frontend/dist/govuk/i18n.mjs +195 -0
  762. data/node_modules/govuk-frontend/dist/govuk/i18n.mjs.map +1 -0
  763. data/node_modules/govuk-frontend/dist/govuk/index.scss +11 -0
  764. data/node_modules/govuk-frontend/dist/govuk/index.scss.map +1 -0
  765. data/node_modules/govuk-frontend/dist/govuk/init.mjs +166 -0
  766. data/node_modules/govuk-frontend/dist/govuk/init.mjs.map +1 -0
  767. data/node_modules/govuk-frontend/dist/govuk/macros/attributes.njk +94 -0
  768. data/node_modules/govuk-frontend/dist/govuk/macros/i18n.njk +21 -0
  769. data/node_modules/govuk-frontend/dist/govuk/macros/logo.njk +78 -0
  770. data/node_modules/govuk-frontend/dist/govuk/objects/_all.scss +10 -0
  771. data/node_modules/govuk-frontend/dist/govuk/objects/_all.scss.map +1 -0
  772. data/node_modules/govuk-frontend/dist/govuk/objects/_button-group.scss +80 -0
  773. data/node_modules/govuk-frontend/dist/govuk/objects/_button-group.scss.map +1 -0
  774. data/node_modules/govuk-frontend/dist/govuk/objects/_form-group.scss +25 -0
  775. data/node_modules/govuk-frontend/dist/govuk/objects/_form-group.scss.map +1 -0
  776. data/node_modules/govuk-frontend/dist/govuk/objects/_grid.scss +26 -0
  777. data/node_modules/govuk-frontend/dist/govuk/objects/_grid.scss.map +1 -0
  778. data/node_modules/govuk-frontend/dist/govuk/objects/_index.scss +8 -0
  779. data/node_modules/govuk-frontend/dist/govuk/objects/_index.scss.map +1 -0
  780. data/node_modules/govuk-frontend/dist/govuk/objects/_main-wrapper.scss +55 -0
  781. data/node_modules/govuk-frontend/dist/govuk/objects/_main-wrapper.scss.map +1 -0
  782. data/node_modules/govuk-frontend/dist/govuk/objects/_template.scss +57 -0
  783. data/node_modules/govuk-frontend/dist/govuk/objects/_template.scss.map +1 -0
  784. data/node_modules/govuk-frontend/dist/govuk/objects/_width-container.scss +77 -0
  785. data/node_modules/govuk-frontend/dist/govuk/objects/_width-container.scss.map +1 -0
  786. data/node_modules/govuk-frontend/dist/govuk/overrides/_all.scss +9 -0
  787. data/node_modules/govuk-frontend/dist/govuk/overrides/_all.scss.map +1 -0
  788. data/node_modules/govuk-frontend/dist/govuk/overrides/_display.scss +26 -0
  789. data/node_modules/govuk-frontend/dist/govuk/overrides/_display.scss.map +1 -0
  790. data/node_modules/govuk-frontend/dist/govuk/overrides/_index.scss +7 -0
  791. data/node_modules/govuk-frontend/dist/govuk/overrides/_index.scss.map +1 -0
  792. data/node_modules/govuk-frontend/dist/govuk/overrides/_spacing.scss +86 -0
  793. data/node_modules/govuk-frontend/dist/govuk/overrides/_spacing.scss.map +1 -0
  794. data/node_modules/govuk-frontend/dist/govuk/overrides/_text-align.scss +16 -0
  795. data/node_modules/govuk-frontend/dist/govuk/overrides/_text-align.scss.map +1 -0
  796. data/node_modules/govuk-frontend/dist/govuk/overrides/_typography.scss +42 -0
  797. data/node_modules/govuk-frontend/dist/govuk/overrides/_typography.scss.map +1 -0
  798. data/node_modules/govuk-frontend/dist/govuk/overrides/_width.scss +48 -0
  799. data/node_modules/govuk-frontend/dist/govuk/overrides/_width.scss.map +1 -0
  800. data/node_modules/govuk-frontend/dist/govuk/settings/_all.scss +10 -0
  801. data/node_modules/govuk-frontend/dist/govuk/settings/_all.scss.map +1 -0
  802. data/node_modules/govuk-frontend/dist/govuk/settings/_assets.scss +84 -0
  803. data/node_modules/govuk-frontend/dist/govuk/settings/_assets.scss.map +1 -0
  804. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-applied.scss +195 -0
  805. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-applied.scss.map +1 -0
  806. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +382 -0
  807. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss.map +1 -0
  808. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-palette.scss +37 -0
  809. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-palette.scss.map +1 -0
  810. data/node_modules/govuk-frontend/dist/govuk/settings/_global-styles.scss +15 -0
  811. data/node_modules/govuk-frontend/dist/govuk/settings/_global-styles.scss.map +1 -0
  812. data/node_modules/govuk-frontend/dist/govuk/settings/_index.scss +36 -0
  813. data/node_modules/govuk-frontend/dist/govuk/settings/_index.scss.map +1 -0
  814. data/node_modules/govuk-frontend/dist/govuk/settings/_links.scss +49 -0
  815. data/node_modules/govuk-frontend/dist/govuk/settings/_links.scss.map +1 -0
  816. data/node_modules/govuk-frontend/dist/govuk/settings/_measurements.scss +107 -0
  817. data/node_modules/govuk-frontend/dist/govuk/settings/_measurements.scss.map +1 -0
  818. data/node_modules/govuk-frontend/dist/govuk/settings/_media-queries.scss +25 -0
  819. data/node_modules/govuk-frontend/dist/govuk/settings/_media-queries.scss.map +1 -0
  820. data/node_modules/govuk-frontend/dist/govuk/settings/_spacing.scss +78 -0
  821. data/node_modules/govuk-frontend/dist/govuk/settings/_spacing.scss.map +1 -0
  822. data/node_modules/govuk-frontend/dist/govuk/settings/_typography-font.scss +52 -0
  823. data/node_modules/govuk-frontend/dist/govuk/settings/_typography-font.scss.map +1 -0
  824. data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss +317 -0
  825. data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss.map +1 -0
  826. data/node_modules/govuk-frontend/dist/govuk/settings/_warnings.scss +78 -0
  827. data/node_modules/govuk-frontend/dist/govuk/settings/_warnings.scss.map +1 -0
  828. data/node_modules/govuk-frontend/dist/govuk/template.njk +69 -0
  829. data/node_modules/govuk-frontend/dist/govuk/tools/_all.scss +10 -0
  830. data/node_modules/govuk-frontend/dist/govuk/tools/_all.scss.map +1 -0
  831. data/node_modules/govuk-frontend/dist/govuk/tools/_exports.scss +35 -0
  832. data/node_modules/govuk-frontend/dist/govuk/tools/_exports.scss.map +1 -0
  833. data/node_modules/govuk-frontend/dist/govuk/tools/_font-url.scss +28 -0
  834. data/node_modules/govuk-frontend/dist/govuk/tools/_font-url.scss.map +1 -0
  835. data/node_modules/govuk-frontend/dist/govuk/tools/_image-url.scss +28 -0
  836. data/node_modules/govuk-frontend/dist/govuk/tools/_image-url.scss.map +1 -0
  837. data/node_modules/govuk-frontend/dist/govuk/tools/_index.scss +8 -0
  838. data/node_modules/govuk-frontend/dist/govuk/tools/_index.scss.map +1 -0
  839. data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-em.scss +22 -0
  840. data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-em.scss.map +1 -0
  841. data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-rem.scss +22 -0
  842. data/node_modules/govuk-frontend/dist/govuk/tools/_px-to-rem.scss.map +1 -0
  843. data/node_modules/govuk-frontend/dist/govuk/tools/_rebrand.scss +65 -0
  844. data/node_modules/govuk-frontend/dist/govuk/tools/_rebrand.scss.map +1 -0
  845. data/node_modules/govuk-frontend/dist/govuk/utilities/_all.scss +10 -0
  846. data/node_modules/govuk-frontend/dist/govuk/utilities/_all.scss.map +1 -0
  847. data/node_modules/govuk-frontend/dist/govuk/utilities/_clearfix.scss +7 -0
  848. data/node_modules/govuk-frontend/dist/govuk/utilities/_clearfix.scss.map +1 -0
  849. data/node_modules/govuk-frontend/dist/govuk/utilities/_index.scss +4 -0
  850. data/node_modules/govuk-frontend/dist/govuk/utilities/_index.scss.map +1 -0
  851. data/node_modules/govuk-frontend/dist/govuk/utilities/_visually-hidden.scss +11 -0
  852. data/node_modules/govuk-frontend/dist/govuk/utilities/_visually-hidden.scss.map +1 -0
  853. data/node_modules/govuk-frontend/dist/govuk/vendor/_sass-mq.scss +349 -0
  854. data/node_modules/govuk-frontend/dist/govuk/vendor/_sass-mq.scss.map +1 -0
  855. data/node_modules/govuk-frontend/dist/govuk-prototype-kit/functions.js +25 -0
  856. data/node_modules/govuk-frontend/dist/govuk-prototype-kit/init.js +15 -0
  857. data/node_modules/govuk-frontend/dist/govuk-prototype-kit/init.scss +13 -0
  858. data/node_modules/govuk-frontend/dist/govuk-prototype-kit/init.scss.map +1 -0
  859. data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +179 -0
  860. data/node_modules/govuk-frontend/package.json +92 -0
  861. metadata +852 -17
  862. data/.github/dependabot.yml +0 -10
  863. data/.github/pull_request_template.md +0 -1
  864. data/.github/workflows/actionlint.yml +0 -12
  865. data/.github/workflows/autorelease.yml +0 -12
  866. data/.github/workflows/ci.yml +0 -55
  867. data/.gitignore +0 -19
  868. data/.rspec +0 -3
  869. data/.rubocop.yml +0 -3
  870. data/.ruby-version +0 -1
  871. data/CHANGELOG.md +0 -163
  872. data/Gemfile +0 -7
  873. data/LICENSE.txt +0 -19
  874. data/Rakefile +0 -10
  875. data/bin/console +0 -15
  876. data/bin/setup +0 -8
  877. data/content_block_tools.gemspec +0 -35
@@ -0,0 +1,2847 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.GOVUKFrontend = global.GOVUKFrontend || {}));
5
+ })(this, (function (exports) { 'use strict';
6
+
7
+ const version = '5.11.1';
8
+
9
+ function getFragmentFromUrl(url) {
10
+ if (!url.includes('#')) {
11
+ return undefined;
12
+ }
13
+ return url.split('#').pop();
14
+ }
15
+ function getBreakpoint(name) {
16
+ const property = `--govuk-breakpoint-${name}`;
17
+ const value = window.getComputedStyle(document.documentElement).getPropertyValue(property);
18
+ return {
19
+ property,
20
+ value: value || undefined
21
+ };
22
+ }
23
+ function setFocus($element, options = {}) {
24
+ var _options$onBeforeFocu;
25
+ const isFocusable = $element.getAttribute('tabindex');
26
+ if (!isFocusable) {
27
+ $element.setAttribute('tabindex', '-1');
28
+ }
29
+ function onFocus() {
30
+ $element.addEventListener('blur', onBlur, {
31
+ once: true
32
+ });
33
+ }
34
+ function onBlur() {
35
+ var _options$onBlur;
36
+ (_options$onBlur = options.onBlur) == null || _options$onBlur.call($element);
37
+ if (!isFocusable) {
38
+ $element.removeAttribute('tabindex');
39
+ }
40
+ }
41
+ $element.addEventListener('focus', onFocus, {
42
+ once: true
43
+ });
44
+ (_options$onBeforeFocu = options.onBeforeFocus) == null || _options$onBeforeFocu.call($element);
45
+ $element.focus();
46
+ }
47
+ function isInitialised($root, moduleName) {
48
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
49
+ }
50
+
51
+ /**
52
+ * Checks if GOV.UK Frontend is supported on this page
53
+ *
54
+ * Some browsers will load and run our JavaScript but GOV.UK Frontend
55
+ * won't be supported.
56
+ *
57
+ * @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support
58
+ * @returns {boolean} Whether GOV.UK Frontend is supported on this page
59
+ */
60
+ function isSupported($scope = document.body) {
61
+ if (!$scope) {
62
+ return false;
63
+ }
64
+ return $scope.classList.contains('govuk-frontend-supported');
65
+ }
66
+ function isArray(option) {
67
+ return Array.isArray(option);
68
+ }
69
+ function isObject(option) {
70
+ return !!option && typeof option === 'object' && !isArray(option);
71
+ }
72
+ function formatErrorMessage(Component, message) {
73
+ return `${Component.moduleName}: ${message}`;
74
+ }
75
+ /**
76
+ * @typedef ComponentWithModuleName
77
+ * @property {string} moduleName - Name of the component
78
+ */
79
+ /**
80
+ * @import { ObjectNested } from './configuration.mjs'
81
+ */
82
+
83
+ class GOVUKFrontendError extends Error {
84
+ constructor(...args) {
85
+ super(...args);
86
+ this.name = 'GOVUKFrontendError';
87
+ }
88
+ }
89
+ class SupportError extends GOVUKFrontendError {
90
+ /**
91
+ * Checks if GOV.UK Frontend is supported on this page
92
+ *
93
+ * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support
94
+ */
95
+ constructor($scope = document.body) {
96
+ const supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';
97
+ super($scope ? supportMessage : 'GOV.UK Frontend initialised without `<script type="module">`');
98
+ this.name = 'SupportError';
99
+ }
100
+ }
101
+ class ConfigError extends GOVUKFrontendError {
102
+ constructor(...args) {
103
+ super(...args);
104
+ this.name = 'ConfigError';
105
+ }
106
+ }
107
+ class ElementError extends GOVUKFrontendError {
108
+ constructor(messageOrOptions) {
109
+ let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
110
+ if (typeof messageOrOptions === 'object') {
111
+ const {
112
+ component,
113
+ identifier,
114
+ element,
115
+ expectedType
116
+ } = messageOrOptions;
117
+ message = identifier;
118
+ message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
119
+ message = formatErrorMessage(component, message);
120
+ }
121
+ super(message);
122
+ this.name = 'ElementError';
123
+ }
124
+ }
125
+ class InitError extends GOVUKFrontendError {
126
+ constructor(componentOrMessage) {
127
+ const message = typeof componentOrMessage === 'string' ? componentOrMessage : formatErrorMessage(componentOrMessage, `Root element (\`$root\`) already initialised`);
128
+ super(message);
129
+ this.name = 'InitError';
130
+ }
131
+ }
132
+ /**
133
+ * @import { ComponentWithModuleName } from '../common/index.mjs'
134
+ */
135
+
136
+ class Component {
137
+ /**
138
+ * Returns the root element of the component
139
+ *
140
+ * @protected
141
+ * @returns {RootElementType} - the root element of component
142
+ */
143
+ get $root() {
144
+ return this._$root;
145
+ }
146
+ constructor($root) {
147
+ this._$root = void 0;
148
+ const childConstructor = this.constructor;
149
+ if (typeof childConstructor.moduleName !== 'string') {
150
+ throw new InitError(`\`moduleName\` not defined in component`);
151
+ }
152
+ if (!($root instanceof childConstructor.elementType)) {
153
+ throw new ElementError({
154
+ element: $root,
155
+ component: childConstructor,
156
+ identifier: 'Root element (`$root`)',
157
+ expectedType: childConstructor.elementType.name
158
+ });
159
+ } else {
160
+ this._$root = $root;
161
+ }
162
+ childConstructor.checkSupport();
163
+ this.checkInitialised();
164
+ const moduleName = childConstructor.moduleName;
165
+ this.$root.setAttribute(`data-${moduleName}-init`, '');
166
+ }
167
+ checkInitialised() {
168
+ const constructor = this.constructor;
169
+ const moduleName = constructor.moduleName;
170
+ if (moduleName && isInitialised(this.$root, moduleName)) {
171
+ throw new InitError(constructor);
172
+ }
173
+ }
174
+ static checkSupport() {
175
+ if (!isSupported()) {
176
+ throw new SupportError();
177
+ }
178
+ }
179
+ }
180
+
181
+ /**
182
+ * @typedef ChildClass
183
+ * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
184
+ */
185
+
186
+ /**
187
+ * @typedef {typeof Component & ChildClass} ChildClassConstructor
188
+ */
189
+ Component.elementType = HTMLElement;
190
+
191
+ const configOverride = Symbol.for('configOverride');
192
+ class ConfigurableComponent extends Component {
193
+ [configOverride](param) {
194
+ return {};
195
+ }
196
+
197
+ /**
198
+ * Returns the root element of the component
199
+ *
200
+ * @protected
201
+ * @returns {ConfigurationType} - the root element of component
202
+ */
203
+ get config() {
204
+ return this._config;
205
+ }
206
+ constructor($root, config) {
207
+ super($root);
208
+ this._config = void 0;
209
+ const childConstructor = this.constructor;
210
+ if (!isObject(childConstructor.defaults)) {
211
+ throw new ConfigError(formatErrorMessage(childConstructor, 'Config passed as parameter into constructor but no defaults defined'));
212
+ }
213
+ const datasetConfig = normaliseDataset(childConstructor, this._$root.dataset);
214
+ this._config = mergeConfigs(childConstructor.defaults, config != null ? config : {}, this[configOverride](datasetConfig), datasetConfig);
215
+ }
216
+ }
217
+ function normaliseString(value, property) {
218
+ const trimmedValue = value ? value.trim() : '';
219
+ let output;
220
+ let outputType = property == null ? void 0 : property.type;
221
+ if (!outputType) {
222
+ if (['true', 'false'].includes(trimmedValue)) {
223
+ outputType = 'boolean';
224
+ }
225
+ if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {
226
+ outputType = 'number';
227
+ }
228
+ }
229
+ switch (outputType) {
230
+ case 'boolean':
231
+ output = trimmedValue === 'true';
232
+ break;
233
+ case 'number':
234
+ output = Number(trimmedValue);
235
+ break;
236
+ default:
237
+ output = value;
238
+ }
239
+ return output;
240
+ }
241
+ function normaliseDataset(Component, dataset) {
242
+ if (!isObject(Component.schema)) {
243
+ throw new ConfigError(formatErrorMessage(Component, 'Config passed as parameter into constructor but no schema defined'));
244
+ }
245
+ const out = {};
246
+ const entries = Object.entries(Component.schema.properties);
247
+ for (const entry of entries) {
248
+ const [namespace, property] = entry;
249
+ const field = namespace.toString();
250
+ if (field in dataset) {
251
+ out[field] = normaliseString(dataset[field], property);
252
+ }
253
+ if ((property == null ? void 0 : property.type) === 'object') {
254
+ out[field] = extractConfigByNamespace(Component.schema, dataset, namespace);
255
+ }
256
+ }
257
+ return out;
258
+ }
259
+ function mergeConfigs(...configObjects) {
260
+ const formattedConfigObject = {};
261
+ for (const configObject of configObjects) {
262
+ for (const key of Object.keys(configObject)) {
263
+ const option = formattedConfigObject[key];
264
+ const override = configObject[key];
265
+ if (isObject(option) && isObject(override)) {
266
+ formattedConfigObject[key] = mergeConfigs(option, override);
267
+ } else {
268
+ formattedConfigObject[key] = override;
269
+ }
270
+ }
271
+ }
272
+ return formattedConfigObject;
273
+ }
274
+ function validateConfig(schema, config) {
275
+ const validationErrors = [];
276
+ for (const [name, conditions] of Object.entries(schema)) {
277
+ const errors = [];
278
+ if (Array.isArray(conditions)) {
279
+ for (const {
280
+ required,
281
+ errorMessage
282
+ } of conditions) {
283
+ if (!required.every(key => !!config[key])) {
284
+ errors.push(errorMessage);
285
+ }
286
+ }
287
+ if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {
288
+ validationErrors.push(...errors);
289
+ }
290
+ }
291
+ }
292
+ return validationErrors;
293
+ }
294
+ function extractConfigByNamespace(schema, dataset, namespace) {
295
+ const property = schema.properties[namespace];
296
+ if ((property == null ? void 0 : property.type) !== 'object') {
297
+ return;
298
+ }
299
+ const newObject = {
300
+ [namespace]: {}
301
+ };
302
+ for (const [key, value] of Object.entries(dataset)) {
303
+ let current = newObject;
304
+ const keyParts = key.split('.');
305
+ for (const [index, name] of keyParts.entries()) {
306
+ if (isObject(current)) {
307
+ if (index < keyParts.length - 1) {
308
+ if (!isObject(current[name])) {
309
+ current[name] = {};
310
+ }
311
+ current = current[name];
312
+ } else if (key !== namespace) {
313
+ current[name] = normaliseString(value);
314
+ }
315
+ }
316
+ }
317
+ }
318
+ return newObject[namespace];
319
+ }
320
+ /**
321
+ * Schema for component config
322
+ *
323
+ * @template {Partial<Record<keyof ConfigurationType, unknown>>} ConfigurationType
324
+ * @typedef {object} Schema
325
+ * @property {Record<keyof ConfigurationType, SchemaProperty | undefined>} properties - Schema properties
326
+ * @property {SchemaCondition<ConfigurationType>[]} [anyOf] - List of schema conditions
327
+ */
328
+ /**
329
+ * Schema property for component config
330
+ *
331
+ * @typedef {object} SchemaProperty
332
+ * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
333
+ */
334
+ /**
335
+ * Schema condition for component config
336
+ *
337
+ * @template {Partial<Record<keyof ConfigurationType, unknown>>} ConfigurationType
338
+ * @typedef {object} SchemaCondition
339
+ * @property {(keyof ConfigurationType)[]} required - List of required config fields
340
+ * @property {string} errorMessage - Error message when required config fields not provided
341
+ */
342
+ /**
343
+ * @template {Partial<Record<keyof ConfigurationType, unknown>>} [ConfigurationType=ObjectNested]
344
+ * @typedef ChildClass
345
+ * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
346
+ * @property {Schema<ConfigurationType>} [schema] - The schema of the component configuration
347
+ * @property {ConfigurationType} [defaults] - The default values of the configuration of the component
348
+ */
349
+ /**
350
+ * @template {Partial<Record<keyof ConfigurationType, unknown>>} [ConfigurationType=ObjectNested]
351
+ * @typedef {typeof Component & ChildClass<ConfigurationType>} ChildClassConstructor<ConfigurationType>
352
+ */
353
+
354
+ class I18n {
355
+ constructor(translations = {}, config = {}) {
356
+ var _config$locale;
357
+ this.translations = void 0;
358
+ this.locale = void 0;
359
+ this.translations = translations;
360
+ this.locale = (_config$locale = config.locale) != null ? _config$locale : document.documentElement.lang || 'en';
361
+ }
362
+ t(lookupKey, options) {
363
+ if (!lookupKey) {
364
+ throw new Error('i18n: lookup key missing');
365
+ }
366
+ let translation = this.translations[lookupKey];
367
+ if (typeof (options == null ? void 0 : options.count) === 'number' && typeof translation === 'object') {
368
+ const translationPluralForm = translation[this.getPluralSuffix(lookupKey, options.count)];
369
+ if (translationPluralForm) {
370
+ translation = translationPluralForm;
371
+ }
372
+ }
373
+ if (typeof translation === 'string') {
374
+ if (translation.match(/%{(.\S+)}/)) {
375
+ if (!options) {
376
+ throw new Error('i18n: cannot replace placeholders in string if no option data provided');
377
+ }
378
+ return this.replacePlaceholders(translation, options);
379
+ }
380
+ return translation;
381
+ }
382
+ return lookupKey;
383
+ }
384
+ replacePlaceholders(translationString, options) {
385
+ const formatter = Intl.NumberFormat.supportedLocalesOf(this.locale).length ? new Intl.NumberFormat(this.locale) : undefined;
386
+ return translationString.replace(/%{(.\S+)}/g, function (placeholderWithBraces, placeholderKey) {
387
+ if (Object.prototype.hasOwnProperty.call(options, placeholderKey)) {
388
+ const placeholderValue = options[placeholderKey];
389
+ if (placeholderValue === false || typeof placeholderValue !== 'number' && typeof placeholderValue !== 'string') {
390
+ return '';
391
+ }
392
+ if (typeof placeholderValue === 'number') {
393
+ return formatter ? formatter.format(placeholderValue) : `${placeholderValue}`;
394
+ }
395
+ return placeholderValue;
396
+ }
397
+ throw new Error(`i18n: no data found to replace ${placeholderWithBraces} placeholder in string`);
398
+ });
399
+ }
400
+ hasIntlPluralRulesSupport() {
401
+ return Boolean('PluralRules' in window.Intl && Intl.PluralRules.supportedLocalesOf(this.locale).length);
402
+ }
403
+ getPluralSuffix(lookupKey, count) {
404
+ count = Number(count);
405
+ if (!isFinite(count)) {
406
+ return 'other';
407
+ }
408
+ const translation = this.translations[lookupKey];
409
+ const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : this.selectPluralFormUsingFallbackRules(count);
410
+ if (typeof translation === 'object') {
411
+ if (preferredForm in translation) {
412
+ return preferredForm;
413
+ } else if ('other' in translation) {
414
+ console.warn(`i18n: Missing plural form ".${preferredForm}" for "${this.locale}" locale. Falling back to ".other".`);
415
+ return 'other';
416
+ }
417
+ }
418
+ throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`);
419
+ }
420
+ selectPluralFormUsingFallbackRules(count) {
421
+ count = Math.abs(Math.floor(count));
422
+ const ruleset = this.getPluralRulesForLocale();
423
+ if (ruleset) {
424
+ return I18n.pluralRules[ruleset](count);
425
+ }
426
+ return 'other';
427
+ }
428
+ getPluralRulesForLocale() {
429
+ const localeShort = this.locale.split('-')[0];
430
+ for (const pluralRule in I18n.pluralRulesMap) {
431
+ const languages = I18n.pluralRulesMap[pluralRule];
432
+ if (languages.includes(this.locale) || languages.includes(localeShort)) {
433
+ return pluralRule;
434
+ }
435
+ }
436
+ }
437
+ }
438
+ I18n.pluralRulesMap = {
439
+ arabic: ['ar'],
440
+ chinese: ['my', 'zh', 'id', 'ja', 'jv', 'ko', 'ms', 'th', 'vi'],
441
+ french: ['hy', 'bn', 'fr', 'gu', 'hi', 'fa', 'pa', 'zu'],
442
+ german: ['af', 'sq', 'az', 'eu', 'bg', 'ca', 'da', 'nl', 'en', 'et', 'fi', 'ka', 'de', 'el', 'hu', 'lb', 'no', 'so', 'sw', 'sv', 'ta', 'te', 'tr', 'ur'],
443
+ irish: ['ga'],
444
+ russian: ['ru', 'uk'],
445
+ scottish: ['gd'],
446
+ spanish: ['pt-PT', 'it', 'es'],
447
+ welsh: ['cy']
448
+ };
449
+ I18n.pluralRules = {
450
+ arabic(n) {
451
+ if (n === 0) {
452
+ return 'zero';
453
+ }
454
+ if (n === 1) {
455
+ return 'one';
456
+ }
457
+ if (n === 2) {
458
+ return 'two';
459
+ }
460
+ if (n % 100 >= 3 && n % 100 <= 10) {
461
+ return 'few';
462
+ }
463
+ if (n % 100 >= 11 && n % 100 <= 99) {
464
+ return 'many';
465
+ }
466
+ return 'other';
467
+ },
468
+ chinese() {
469
+ return 'other';
470
+ },
471
+ french(n) {
472
+ return n === 0 || n === 1 ? 'one' : 'other';
473
+ },
474
+ german(n) {
475
+ return n === 1 ? 'one' : 'other';
476
+ },
477
+ irish(n) {
478
+ if (n === 1) {
479
+ return 'one';
480
+ }
481
+ if (n === 2) {
482
+ return 'two';
483
+ }
484
+ if (n >= 3 && n <= 6) {
485
+ return 'few';
486
+ }
487
+ if (n >= 7 && n <= 10) {
488
+ return 'many';
489
+ }
490
+ return 'other';
491
+ },
492
+ russian(n) {
493
+ const lastTwo = n % 100;
494
+ const last = lastTwo % 10;
495
+ if (last === 1 && lastTwo !== 11) {
496
+ return 'one';
497
+ }
498
+ if (last >= 2 && last <= 4 && !(lastTwo >= 12 && lastTwo <= 14)) {
499
+ return 'few';
500
+ }
501
+ if (last === 0 || last >= 5 && last <= 9 || lastTwo >= 11 && lastTwo <= 14) {
502
+ return 'many';
503
+ }
504
+ return 'other';
505
+ },
506
+ scottish(n) {
507
+ if (n === 1 || n === 11) {
508
+ return 'one';
509
+ }
510
+ if (n === 2 || n === 12) {
511
+ return 'two';
512
+ }
513
+ if (n >= 3 && n <= 10 || n >= 13 && n <= 19) {
514
+ return 'few';
515
+ }
516
+ return 'other';
517
+ },
518
+ spanish(n) {
519
+ if (n === 1) {
520
+ return 'one';
521
+ }
522
+ if (n % 1000000 === 0 && n !== 0) {
523
+ return 'many';
524
+ }
525
+ return 'other';
526
+ },
527
+ welsh(n) {
528
+ if (n === 0) {
529
+ return 'zero';
530
+ }
531
+ if (n === 1) {
532
+ return 'one';
533
+ }
534
+ if (n === 2) {
535
+ return 'two';
536
+ }
537
+ if (n === 3) {
538
+ return 'few';
539
+ }
540
+ if (n === 6) {
541
+ return 'many';
542
+ }
543
+ return 'other';
544
+ }
545
+ };
546
+
547
+ /**
548
+ * Accordion component
549
+ *
550
+ * This allows a collection of sections to be collapsed by default, showing only
551
+ * their headers. Sections can be expanded or collapsed individually by clicking
552
+ * their headers. A "Show all sections" button is also added to the top of the
553
+ * accordion, which switches to "Hide all sections" when all the sections are
554
+ * expanded.
555
+ *
556
+ * The state of each section is saved to the DOM via the `aria-expanded`
557
+ * attribute, which also provides accessibility.
558
+ *
559
+ * @preserve
560
+ * @augments ConfigurableComponent<AccordionConfig>
561
+ */
562
+ class Accordion extends ConfigurableComponent {
563
+ /**
564
+ * @param {Element | null} $root - HTML element to use for accordion
565
+ * @param {AccordionConfig} [config] - Accordion config
566
+ */
567
+ constructor($root, config = {}) {
568
+ super($root, config);
569
+ this.i18n = void 0;
570
+ this.controlsClass = 'govuk-accordion__controls';
571
+ this.showAllClass = 'govuk-accordion__show-all';
572
+ this.showAllTextClass = 'govuk-accordion__show-all-text';
573
+ this.sectionClass = 'govuk-accordion__section';
574
+ this.sectionExpandedClass = 'govuk-accordion__section--expanded';
575
+ this.sectionButtonClass = 'govuk-accordion__section-button';
576
+ this.sectionHeaderClass = 'govuk-accordion__section-header';
577
+ this.sectionHeadingClass = 'govuk-accordion__section-heading';
578
+ this.sectionHeadingDividerClass = 'govuk-accordion__section-heading-divider';
579
+ this.sectionHeadingTextClass = 'govuk-accordion__section-heading-text';
580
+ this.sectionHeadingTextFocusClass = 'govuk-accordion__section-heading-text-focus';
581
+ this.sectionShowHideToggleClass = 'govuk-accordion__section-toggle';
582
+ this.sectionShowHideToggleFocusClass = 'govuk-accordion__section-toggle-focus';
583
+ this.sectionShowHideTextClass = 'govuk-accordion__section-toggle-text';
584
+ this.upChevronIconClass = 'govuk-accordion-nav__chevron';
585
+ this.downChevronIconClass = 'govuk-accordion-nav__chevron--down';
586
+ this.sectionSummaryClass = 'govuk-accordion__section-summary';
587
+ this.sectionSummaryFocusClass = 'govuk-accordion__section-summary-focus';
588
+ this.sectionContentClass = 'govuk-accordion__section-content';
589
+ this.$sections = void 0;
590
+ this.$showAllButton = null;
591
+ this.$showAllIcon = null;
592
+ this.$showAllText = null;
593
+ this.i18n = new I18n(this.config.i18n);
594
+ const $sections = this.$root.querySelectorAll(`.${this.sectionClass}`);
595
+ if (!$sections.length) {
596
+ throw new ElementError({
597
+ component: Accordion,
598
+ identifier: `Sections (\`<div class="${this.sectionClass}">\`)`
599
+ });
600
+ }
601
+ this.$sections = $sections;
602
+ this.initControls();
603
+ this.initSectionHeaders();
604
+ this.updateShowAllButton(this.areAllSectionsOpen());
605
+ }
606
+ initControls() {
607
+ this.$showAllButton = document.createElement('button');
608
+ this.$showAllButton.setAttribute('type', 'button');
609
+ this.$showAllButton.setAttribute('class', this.showAllClass);
610
+ this.$showAllButton.setAttribute('aria-expanded', 'false');
611
+ this.$showAllIcon = document.createElement('span');
612
+ this.$showAllIcon.classList.add(this.upChevronIconClass);
613
+ this.$showAllButton.appendChild(this.$showAllIcon);
614
+ const $accordionControls = document.createElement('div');
615
+ $accordionControls.setAttribute('class', this.controlsClass);
616
+ $accordionControls.appendChild(this.$showAllButton);
617
+ this.$root.insertBefore($accordionControls, this.$root.firstChild);
618
+ this.$showAllText = document.createElement('span');
619
+ this.$showAllText.classList.add(this.showAllTextClass);
620
+ this.$showAllButton.appendChild(this.$showAllText);
621
+ this.$showAllButton.addEventListener('click', () => this.onShowOrHideAllToggle());
622
+ if ('onbeforematch' in document) {
623
+ document.addEventListener('beforematch', event => this.onBeforeMatch(event));
624
+ }
625
+ }
626
+ initSectionHeaders() {
627
+ this.$sections.forEach(($section, i) => {
628
+ const $header = $section.querySelector(`.${this.sectionHeaderClass}`);
629
+ if (!$header) {
630
+ throw new ElementError({
631
+ component: Accordion,
632
+ identifier: `Section headers (\`<div class="${this.sectionHeaderClass}">\`)`
633
+ });
634
+ }
635
+ this.constructHeaderMarkup($header, i);
636
+ this.setExpanded(this.isExpanded($section), $section);
637
+ $header.addEventListener('click', () => this.onSectionToggle($section));
638
+ this.setInitialState($section);
639
+ });
640
+ }
641
+ constructHeaderMarkup($header, index) {
642
+ const $span = $header.querySelector(`.${this.sectionButtonClass}`);
643
+ const $heading = $header.querySelector(`.${this.sectionHeadingClass}`);
644
+ const $summary = $header.querySelector(`.${this.sectionSummaryClass}`);
645
+ if (!$heading) {
646
+ throw new ElementError({
647
+ component: Accordion,
648
+ identifier: `Section heading (\`.${this.sectionHeadingClass}\`)`
649
+ });
650
+ }
651
+ if (!$span) {
652
+ throw new ElementError({
653
+ component: Accordion,
654
+ identifier: `Section button placeholder (\`<span class="${this.sectionButtonClass}">\`)`
655
+ });
656
+ }
657
+ const $button = document.createElement('button');
658
+ $button.setAttribute('type', 'button');
659
+ $button.setAttribute('aria-controls', `${this.$root.id}-content-${index + 1}`);
660
+ for (const attr of Array.from($span.attributes)) {
661
+ if (attr.name !== 'id') {
662
+ $button.setAttribute(attr.name, attr.value);
663
+ }
664
+ }
665
+ const $headingText = document.createElement('span');
666
+ $headingText.classList.add(this.sectionHeadingTextClass);
667
+ $headingText.id = $span.id;
668
+ const $headingTextFocus = document.createElement('span');
669
+ $headingTextFocus.classList.add(this.sectionHeadingTextFocusClass);
670
+ $headingText.appendChild($headingTextFocus);
671
+ Array.from($span.childNodes).forEach($child => $headingTextFocus.appendChild($child));
672
+ const $showHideToggle = document.createElement('span');
673
+ $showHideToggle.classList.add(this.sectionShowHideToggleClass);
674
+ $showHideToggle.setAttribute('data-nosnippet', '');
675
+ const $showHideToggleFocus = document.createElement('span');
676
+ $showHideToggleFocus.classList.add(this.sectionShowHideToggleFocusClass);
677
+ $showHideToggle.appendChild($showHideToggleFocus);
678
+ const $showHideText = document.createElement('span');
679
+ const $showHideIcon = document.createElement('span');
680
+ $showHideIcon.classList.add(this.upChevronIconClass);
681
+ $showHideToggleFocus.appendChild($showHideIcon);
682
+ $showHideText.classList.add(this.sectionShowHideTextClass);
683
+ $showHideToggleFocus.appendChild($showHideText);
684
+ $button.appendChild($headingText);
685
+ $button.appendChild(this.getButtonPunctuationEl());
686
+ if ($summary) {
687
+ const $summarySpan = document.createElement('span');
688
+ const $summarySpanFocus = document.createElement('span');
689
+ $summarySpanFocus.classList.add(this.sectionSummaryFocusClass);
690
+ $summarySpan.appendChild($summarySpanFocus);
691
+ for (const attr of Array.from($summary.attributes)) {
692
+ $summarySpan.setAttribute(attr.name, attr.value);
693
+ }
694
+ Array.from($summary.childNodes).forEach($child => $summarySpanFocus.appendChild($child));
695
+ $summary.remove();
696
+ $button.appendChild($summarySpan);
697
+ $button.appendChild(this.getButtonPunctuationEl());
698
+ }
699
+ $button.appendChild($showHideToggle);
700
+ $heading.removeChild($span);
701
+ $heading.appendChild($button);
702
+ }
703
+ onBeforeMatch(event) {
704
+ const $fragment = event.target;
705
+ if (!($fragment instanceof Element)) {
706
+ return;
707
+ }
708
+ const $section = $fragment.closest(`.${this.sectionClass}`);
709
+ if ($section) {
710
+ this.setExpanded(true, $section);
711
+ }
712
+ }
713
+ onSectionToggle($section) {
714
+ const nowExpanded = !this.isExpanded($section);
715
+ this.setExpanded(nowExpanded, $section);
716
+ this.storeState($section, nowExpanded);
717
+ }
718
+ onShowOrHideAllToggle() {
719
+ const nowExpanded = !this.areAllSectionsOpen();
720
+ this.$sections.forEach($section => {
721
+ this.setExpanded(nowExpanded, $section);
722
+ this.storeState($section, nowExpanded);
723
+ });
724
+ this.updateShowAllButton(nowExpanded);
725
+ }
726
+ setExpanded(expanded, $section) {
727
+ const $showHideIcon = $section.querySelector(`.${this.upChevronIconClass}`);
728
+ const $showHideText = $section.querySelector(`.${this.sectionShowHideTextClass}`);
729
+ const $button = $section.querySelector(`.${this.sectionButtonClass}`);
730
+ const $content = $section.querySelector(`.${this.sectionContentClass}`);
731
+ if (!$content) {
732
+ throw new ElementError({
733
+ component: Accordion,
734
+ identifier: `Section content (\`<div class="${this.sectionContentClass}">\`)`
735
+ });
736
+ }
737
+ if (!$showHideIcon || !$showHideText || !$button) {
738
+ return;
739
+ }
740
+ const newButtonText = expanded ? this.i18n.t('hideSection') : this.i18n.t('showSection');
741
+ $showHideText.textContent = newButtonText;
742
+ $button.setAttribute('aria-expanded', `${expanded}`);
743
+ const ariaLabelParts = [];
744
+ const $headingText = $section.querySelector(`.${this.sectionHeadingTextClass}`);
745
+ if ($headingText) {
746
+ ariaLabelParts.push(`${$headingText.textContent}`.trim());
747
+ }
748
+ const $summary = $section.querySelector(`.${this.sectionSummaryClass}`);
749
+ if ($summary) {
750
+ ariaLabelParts.push(`${$summary.textContent}`.trim());
751
+ }
752
+ const ariaLabelMessage = expanded ? this.i18n.t('hideSectionAriaLabel') : this.i18n.t('showSectionAriaLabel');
753
+ ariaLabelParts.push(ariaLabelMessage);
754
+ $button.setAttribute('aria-label', ariaLabelParts.join(' , '));
755
+ if (expanded) {
756
+ $content.removeAttribute('hidden');
757
+ $section.classList.add(this.sectionExpandedClass);
758
+ $showHideIcon.classList.remove(this.downChevronIconClass);
759
+ } else {
760
+ $content.setAttribute('hidden', 'until-found');
761
+ $section.classList.remove(this.sectionExpandedClass);
762
+ $showHideIcon.classList.add(this.downChevronIconClass);
763
+ }
764
+ this.updateShowAllButton(this.areAllSectionsOpen());
765
+ }
766
+ isExpanded($section) {
767
+ return $section.classList.contains(this.sectionExpandedClass);
768
+ }
769
+ areAllSectionsOpen() {
770
+ return Array.from(this.$sections).every($section => this.isExpanded($section));
771
+ }
772
+ updateShowAllButton(expanded) {
773
+ if (!this.$showAllButton || !this.$showAllText || !this.$showAllIcon) {
774
+ return;
775
+ }
776
+ this.$showAllButton.setAttribute('aria-expanded', expanded.toString());
777
+ this.$showAllText.textContent = expanded ? this.i18n.t('hideAllSections') : this.i18n.t('showAllSections');
778
+ this.$showAllIcon.classList.toggle(this.downChevronIconClass, !expanded);
779
+ }
780
+
781
+ /**
782
+ * Get the identifier for a section
783
+ *
784
+ * We need a unique way of identifying each content in the Accordion.
785
+ * Since an `#id` should be unique and an `id` is required for `aria-`
786
+ * attributes `id` can be safely used.
787
+ *
788
+ * @param {Element} $section - Section element
789
+ * @returns {string | undefined | null} Identifier for section
790
+ */
791
+ getIdentifier($section) {
792
+ const $button = $section.querySelector(`.${this.sectionButtonClass}`);
793
+ return $button == null ? void 0 : $button.getAttribute('aria-controls');
794
+ }
795
+ storeState($section, isExpanded) {
796
+ if (!this.config.rememberExpanded) {
797
+ return;
798
+ }
799
+ const id = this.getIdentifier($section);
800
+ if (id) {
801
+ try {
802
+ window.sessionStorage.setItem(id, isExpanded.toString());
803
+ } catch (exception) {}
804
+ }
805
+ }
806
+ setInitialState($section) {
807
+ if (!this.config.rememberExpanded) {
808
+ return;
809
+ }
810
+ const id = this.getIdentifier($section);
811
+ if (id) {
812
+ try {
813
+ const state = window.sessionStorage.getItem(id);
814
+ if (state !== null) {
815
+ this.setExpanded(state === 'true', $section);
816
+ }
817
+ } catch (exception) {}
818
+ }
819
+ }
820
+ getButtonPunctuationEl() {
821
+ const $punctuationEl = document.createElement('span');
822
+ $punctuationEl.classList.add('govuk-visually-hidden', this.sectionHeadingDividerClass);
823
+ $punctuationEl.textContent = ', ';
824
+ return $punctuationEl;
825
+ }
826
+ }
827
+
828
+ /**
829
+ * Accordion config
830
+ *
831
+ * @see {@link Accordion.defaults}
832
+ * @typedef {object} AccordionConfig
833
+ * @property {AccordionTranslations} [i18n=Accordion.defaults.i18n] - Accordion translations
834
+ * @property {boolean} [rememberExpanded] - Whether the expanded and collapsed
835
+ * state of each section is remembered and restored when navigating.
836
+ */
837
+
838
+ /**
839
+ * Accordion translations
840
+ *
841
+ * @see {@link Accordion.defaults.i18n}
842
+ * @typedef {object} AccordionTranslations
843
+ *
844
+ * Messages used by the component for the labels of its buttons. This includes
845
+ * the visible text shown on screen, and text to help assistive technology users
846
+ * for the buttons toggling each section.
847
+ * @property {string} [hideAllSections] - The text content for the 'Hide all
848
+ * sections' button, used when at least one section is expanded.
849
+ * @property {string} [hideSection] - The text content for the 'Hide'
850
+ * button, used when a section is expanded.
851
+ * @property {string} [hideSectionAriaLabel] - The text content appended to the
852
+ * 'Hide' button's accessible name when a section is expanded.
853
+ * @property {string} [showAllSections] - The text content for the 'Show all
854
+ * sections' button, used when all sections are collapsed.
855
+ * @property {string} [showSection] - The text content for the 'Show'
856
+ * button, used when a section is collapsed.
857
+ * @property {string} [showSectionAriaLabel] - The text content appended to the
858
+ * 'Show' button's accessible name when a section is expanded.
859
+ */
860
+
861
+ /**
862
+ * @import { Schema } from '../../common/configuration.mjs'
863
+ */
864
+ Accordion.moduleName = 'govuk-accordion';
865
+ Accordion.defaults = Object.freeze({
866
+ i18n: {
867
+ hideAllSections: 'Hide all sections',
868
+ hideSection: 'Hide',
869
+ hideSectionAriaLabel: 'Hide this section',
870
+ showAllSections: 'Show all sections',
871
+ showSection: 'Show',
872
+ showSectionAriaLabel: 'Show this section'
873
+ },
874
+ rememberExpanded: true
875
+ });
876
+ Accordion.schema = Object.freeze({
877
+ properties: {
878
+ i18n: {
879
+ type: 'object'
880
+ },
881
+ rememberExpanded: {
882
+ type: 'boolean'
883
+ }
884
+ }
885
+ });
886
+
887
+ const DEBOUNCE_TIMEOUT_IN_SECONDS = 1;
888
+
889
+ /**
890
+ * JavaScript enhancements for the Button component
891
+ *
892
+ * @preserve
893
+ * @augments ConfigurableComponent<ButtonConfig>
894
+ */
895
+ class Button extends ConfigurableComponent {
896
+ /**
897
+ * @param {Element | null} $root - HTML element to use for button
898
+ * @param {ButtonConfig} [config] - Button config
899
+ */
900
+ constructor($root, config = {}) {
901
+ super($root, config);
902
+ this.debounceFormSubmitTimer = null;
903
+ this.$root.addEventListener('keydown', event => this.handleKeyDown(event));
904
+ this.$root.addEventListener('click', event => this.debounce(event));
905
+ }
906
+ handleKeyDown(event) {
907
+ const $target = event.target;
908
+ if (event.key !== ' ') {
909
+ return;
910
+ }
911
+ if ($target instanceof HTMLElement && $target.getAttribute('role') === 'button') {
912
+ event.preventDefault();
913
+ $target.click();
914
+ }
915
+ }
916
+ debounce(event) {
917
+ if (!this.config.preventDoubleClick) {
918
+ return;
919
+ }
920
+ if (this.debounceFormSubmitTimer) {
921
+ event.preventDefault();
922
+ return false;
923
+ }
924
+ this.debounceFormSubmitTimer = window.setTimeout(() => {
925
+ this.debounceFormSubmitTimer = null;
926
+ }, DEBOUNCE_TIMEOUT_IN_SECONDS * 1000);
927
+ }
928
+ }
929
+
930
+ /**
931
+ * Button config
932
+ *
933
+ * @typedef {object} ButtonConfig
934
+ * @property {boolean} [preventDoubleClick=false] - Prevent accidental double
935
+ * clicks on submit buttons from submitting forms multiple times.
936
+ */
937
+
938
+ /**
939
+ * @import { Schema } from '../../common/configuration.mjs'
940
+ */
941
+ Button.moduleName = 'govuk-button';
942
+ Button.defaults = Object.freeze({
943
+ preventDoubleClick: false
944
+ });
945
+ Button.schema = Object.freeze({
946
+ properties: {
947
+ preventDoubleClick: {
948
+ type: 'boolean'
949
+ }
950
+ }
951
+ });
952
+
953
+ function closestAttributeValue($element, attributeName) {
954
+ const $closestElementWithAttribute = $element.closest(`[${attributeName}]`);
955
+ return $closestElementWithAttribute ? $closestElementWithAttribute.getAttribute(attributeName) : null;
956
+ }
957
+
958
+ /**
959
+ * Character count component
960
+ *
961
+ * Tracks the number of characters or words in the `.govuk-js-character-count`
962
+ * `<textarea>` inside the element. Displays a message with the remaining number
963
+ * of characters/words available, or the number of characters/words in excess.
964
+ *
965
+ * You can configure the message to only appear after a certain percentage
966
+ * of the available characters/words has been entered.
967
+ *
968
+ * @preserve
969
+ * @augments ConfigurableComponent<CharacterCountConfig>
970
+ */
971
+ class CharacterCount extends ConfigurableComponent {
972
+ [configOverride](datasetConfig) {
973
+ let configOverrides = {};
974
+ if ('maxwords' in datasetConfig || 'maxlength' in datasetConfig) {
975
+ configOverrides = {
976
+ maxlength: undefined,
977
+ maxwords: undefined
978
+ };
979
+ }
980
+ return configOverrides;
981
+ }
982
+
983
+ /**
984
+ * @param {Element | null} $root - HTML element to use for character count
985
+ * @param {CharacterCountConfig} [config] - Character count config
986
+ */
987
+ constructor($root, config = {}) {
988
+ var _ref, _this$config$maxwords;
989
+ super($root, config);
990
+ this.$textarea = void 0;
991
+ this.$visibleCountMessage = void 0;
992
+ this.$screenReaderCountMessage = void 0;
993
+ this.lastInputTimestamp = null;
994
+ this.lastInputValue = '';
995
+ this.valueChecker = null;
996
+ this.i18n = void 0;
997
+ this.maxLength = void 0;
998
+ const $textarea = this.$root.querySelector('.govuk-js-character-count');
999
+ if (!($textarea instanceof HTMLTextAreaElement || $textarea instanceof HTMLInputElement)) {
1000
+ throw new ElementError({
1001
+ component: CharacterCount,
1002
+ element: $textarea,
1003
+ expectedType: 'HTMLTextareaElement or HTMLInputElement',
1004
+ identifier: 'Form field (`.govuk-js-character-count`)'
1005
+ });
1006
+ }
1007
+ const errors = validateConfig(CharacterCount.schema, this.config);
1008
+ if (errors[0]) {
1009
+ throw new ConfigError(formatErrorMessage(CharacterCount, errors[0]));
1010
+ }
1011
+ this.i18n = new I18n(this.config.i18n, {
1012
+ locale: closestAttributeValue(this.$root, 'lang')
1013
+ });
1014
+ this.maxLength = (_ref = (_this$config$maxwords = this.config.maxwords) != null ? _this$config$maxwords : this.config.maxlength) != null ? _ref : Infinity;
1015
+ this.$textarea = $textarea;
1016
+ const textareaDescriptionId = `${this.$textarea.id}-info`;
1017
+ const $textareaDescription = document.getElementById(textareaDescriptionId);
1018
+ if (!$textareaDescription) {
1019
+ throw new ElementError({
1020
+ component: CharacterCount,
1021
+ element: $textareaDescription,
1022
+ identifier: `Count message (\`id="${textareaDescriptionId}"\`)`
1023
+ });
1024
+ }
1025
+ this.$errorMessage = this.$root.querySelector('.govuk-error-message');
1026
+ if (`${$textareaDescription.textContent}`.match(/^\s*$/)) {
1027
+ $textareaDescription.textContent = this.i18n.t('textareaDescription', {
1028
+ count: this.maxLength
1029
+ });
1030
+ }
1031
+ this.$textarea.insertAdjacentElement('afterend', $textareaDescription);
1032
+ const $screenReaderCountMessage = document.createElement('div');
1033
+ $screenReaderCountMessage.className = 'govuk-character-count__sr-status govuk-visually-hidden';
1034
+ $screenReaderCountMessage.setAttribute('aria-live', 'polite');
1035
+ this.$screenReaderCountMessage = $screenReaderCountMessage;
1036
+ $textareaDescription.insertAdjacentElement('afterend', $screenReaderCountMessage);
1037
+ const $visibleCountMessage = document.createElement('div');
1038
+ $visibleCountMessage.className = $textareaDescription.className;
1039
+ $visibleCountMessage.classList.add('govuk-character-count__status');
1040
+ $visibleCountMessage.setAttribute('aria-hidden', 'true');
1041
+ this.$visibleCountMessage = $visibleCountMessage;
1042
+ $textareaDescription.insertAdjacentElement('afterend', $visibleCountMessage);
1043
+ $textareaDescription.classList.add('govuk-visually-hidden');
1044
+ this.$textarea.removeAttribute('maxlength');
1045
+ this.bindChangeEvents();
1046
+ window.addEventListener('pageshow', () => this.updateCountMessage());
1047
+ this.updateCountMessage();
1048
+ }
1049
+ bindChangeEvents() {
1050
+ this.$textarea.addEventListener('keyup', () => this.handleKeyUp());
1051
+ this.$textarea.addEventListener('focus', () => this.handleFocus());
1052
+ this.$textarea.addEventListener('blur', () => this.handleBlur());
1053
+ }
1054
+ handleKeyUp() {
1055
+ this.updateVisibleCountMessage();
1056
+ this.lastInputTimestamp = Date.now();
1057
+ }
1058
+ handleFocus() {
1059
+ this.valueChecker = window.setInterval(() => {
1060
+ if (!this.lastInputTimestamp || Date.now() - 500 >= this.lastInputTimestamp) {
1061
+ this.updateIfValueChanged();
1062
+ }
1063
+ }, 1000);
1064
+ }
1065
+ handleBlur() {
1066
+ if (this.valueChecker) {
1067
+ window.clearInterval(this.valueChecker);
1068
+ }
1069
+ }
1070
+ updateIfValueChanged() {
1071
+ if (this.$textarea.value !== this.lastInputValue) {
1072
+ this.lastInputValue = this.$textarea.value;
1073
+ this.updateCountMessage();
1074
+ }
1075
+ }
1076
+ updateCountMessage() {
1077
+ this.updateVisibleCountMessage();
1078
+ this.updateScreenReaderCountMessage();
1079
+ }
1080
+ updateVisibleCountMessage() {
1081
+ const remainingNumber = this.maxLength - this.count(this.$textarea.value);
1082
+ const isError = remainingNumber < 0;
1083
+ this.$visibleCountMessage.classList.toggle('govuk-character-count__message--disabled', !this.isOverThreshold());
1084
+ if (!this.$errorMessage) {
1085
+ this.$textarea.classList.toggle('govuk-textarea--error', isError);
1086
+ }
1087
+ this.$visibleCountMessage.classList.toggle('govuk-error-message', isError);
1088
+ this.$visibleCountMessage.classList.toggle('govuk-hint', !isError);
1089
+ this.$visibleCountMessage.textContent = this.getCountMessage();
1090
+ }
1091
+ updateScreenReaderCountMessage() {
1092
+ if (this.isOverThreshold()) {
1093
+ this.$screenReaderCountMessage.removeAttribute('aria-hidden');
1094
+ } else {
1095
+ this.$screenReaderCountMessage.setAttribute('aria-hidden', 'true');
1096
+ }
1097
+ this.$screenReaderCountMessage.textContent = this.getCountMessage();
1098
+ }
1099
+ count(text) {
1100
+ if (this.config.maxwords) {
1101
+ var _text$match;
1102
+ const tokens = (_text$match = text.match(/\S+/g)) != null ? _text$match : [];
1103
+ return tokens.length;
1104
+ }
1105
+ return text.length;
1106
+ }
1107
+ getCountMessage() {
1108
+ const remainingNumber = this.maxLength - this.count(this.$textarea.value);
1109
+ const countType = this.config.maxwords ? 'words' : 'characters';
1110
+ return this.formatCountMessage(remainingNumber, countType);
1111
+ }
1112
+ formatCountMessage(remainingNumber, countType) {
1113
+ if (remainingNumber === 0) {
1114
+ return this.i18n.t(`${countType}AtLimit`);
1115
+ }
1116
+ const translationKeySuffix = remainingNumber < 0 ? 'OverLimit' : 'UnderLimit';
1117
+ return this.i18n.t(`${countType}${translationKeySuffix}`, {
1118
+ count: Math.abs(remainingNumber)
1119
+ });
1120
+ }
1121
+ isOverThreshold() {
1122
+ if (!this.config.threshold) {
1123
+ return true;
1124
+ }
1125
+ const currentLength = this.count(this.$textarea.value);
1126
+ const maxLength = this.maxLength;
1127
+ const thresholdValue = maxLength * this.config.threshold / 100;
1128
+ return thresholdValue <= currentLength;
1129
+ }
1130
+ }
1131
+
1132
+ /**
1133
+ * Character count config
1134
+ *
1135
+ * @see {@link CharacterCount.defaults}
1136
+ * @typedef {object} CharacterCountConfig
1137
+ * @property {number} [maxlength] - The maximum number of characters.
1138
+ * If maxwords is provided, the maxlength option will be ignored.
1139
+ * @property {number} [maxwords] - The maximum number of words. If maxwords is
1140
+ * provided, the maxlength option will be ignored.
1141
+ * @property {number} [threshold=0] - The percentage value of the limit at
1142
+ * which point the count message is displayed. If this attribute is set, the
1143
+ * count message will be hidden by default.
1144
+ * @property {CharacterCountTranslations} [i18n=CharacterCount.defaults.i18n] - Character count translations
1145
+ */
1146
+
1147
+ /**
1148
+ * Character count translations
1149
+ *
1150
+ * @see {@link CharacterCount.defaults.i18n}
1151
+ * @typedef {object} CharacterCountTranslations
1152
+ *
1153
+ * Messages shown to users as they type. It provides feedback on how many words
1154
+ * or characters they have remaining or if they are over the limit. This also
1155
+ * includes a message used as an accessible description for the textarea.
1156
+ * @property {TranslationPluralForms} [charactersUnderLimit] - Message displayed
1157
+ * when the number of characters is under the configured maximum, `maxlength`.
1158
+ * This message is displayed visually and through assistive technologies. The
1159
+ * component will replace the `%{count}` placeholder with the number of
1160
+ * remaining characters. This is a [pluralised list of
1161
+ * messages](https://frontend.design-system.service.gov.uk/localise-govuk-frontend).
1162
+ * @property {string} [charactersAtLimit] - Message displayed when the number of
1163
+ * characters reaches the configured maximum, `maxlength`. This message is
1164
+ * displayed visually and through assistive technologies.
1165
+ * @property {TranslationPluralForms} [charactersOverLimit] - Message displayed
1166
+ * when the number of characters is over the configured maximum, `maxlength`.
1167
+ * This message is displayed visually and through assistive technologies. The
1168
+ * component will replace the `%{count}` placeholder with the number of
1169
+ * remaining characters. This is a [pluralised list of
1170
+ * messages](https://frontend.design-system.service.gov.uk/localise-govuk-frontend).
1171
+ * @property {TranslationPluralForms} [wordsUnderLimit] - Message displayed when
1172
+ * the number of words is under the configured maximum, `maxlength`. This
1173
+ * message is displayed visually and through assistive technologies. The
1174
+ * component will replace the `%{count}` placeholder with the number of
1175
+ * remaining words. This is a [pluralised list of
1176
+ * messages](https://frontend.design-system.service.gov.uk/localise-govuk-frontend).
1177
+ * @property {string} [wordsAtLimit] - Message displayed when the number of
1178
+ * words reaches the configured maximum, `maxlength`. This message is
1179
+ * displayed visually and through assistive technologies.
1180
+ * @property {TranslationPluralForms} [wordsOverLimit] - Message displayed when
1181
+ * the number of words is over the configured maximum, `maxlength`. This
1182
+ * message is displayed visually and through assistive technologies. The
1183
+ * component will replace the `%{count}` placeholder with the number of
1184
+ * remaining words. This is a [pluralised list of
1185
+ * messages](https://frontend.design-system.service.gov.uk/localise-govuk-frontend).
1186
+ * @property {TranslationPluralForms} [textareaDescription] - Message made
1187
+ * available to assistive technologies, if none is already present in the
1188
+ * HTML, to describe that the component accepts only a limited amount of
1189
+ * content. It is visible on the page when JavaScript is unavailable. The
1190
+ * component will replace the `%{count}` placeholder with the value of the
1191
+ * `maxlength` or `maxwords` parameter.
1192
+ */
1193
+
1194
+ /**
1195
+ * @import { Schema } from '../../common/configuration.mjs'
1196
+ * @import { TranslationPluralForms } from '../../i18n.mjs'
1197
+ */
1198
+ CharacterCount.moduleName = 'govuk-character-count';
1199
+ CharacterCount.defaults = Object.freeze({
1200
+ threshold: 0,
1201
+ i18n: {
1202
+ charactersUnderLimit: {
1203
+ one: 'You have %{count} character remaining',
1204
+ other: 'You have %{count} characters remaining'
1205
+ },
1206
+ charactersAtLimit: 'You have 0 characters remaining',
1207
+ charactersOverLimit: {
1208
+ one: 'You have %{count} character too many',
1209
+ other: 'You have %{count} characters too many'
1210
+ },
1211
+ wordsUnderLimit: {
1212
+ one: 'You have %{count} word remaining',
1213
+ other: 'You have %{count} words remaining'
1214
+ },
1215
+ wordsAtLimit: 'You have 0 words remaining',
1216
+ wordsOverLimit: {
1217
+ one: 'You have %{count} word too many',
1218
+ other: 'You have %{count} words too many'
1219
+ },
1220
+ textareaDescription: {
1221
+ other: ''
1222
+ }
1223
+ }
1224
+ });
1225
+ CharacterCount.schema = Object.freeze({
1226
+ properties: {
1227
+ i18n: {
1228
+ type: 'object'
1229
+ },
1230
+ maxwords: {
1231
+ type: 'number'
1232
+ },
1233
+ maxlength: {
1234
+ type: 'number'
1235
+ },
1236
+ threshold: {
1237
+ type: 'number'
1238
+ }
1239
+ },
1240
+ anyOf: [{
1241
+ required: ['maxwords'],
1242
+ errorMessage: 'Either "maxlength" or "maxwords" must be provided'
1243
+ }, {
1244
+ required: ['maxlength'],
1245
+ errorMessage: 'Either "maxlength" or "maxwords" must be provided'
1246
+ }]
1247
+ });
1248
+
1249
+ /**
1250
+ * Checkboxes component
1251
+ *
1252
+ * @preserve
1253
+ */
1254
+ class Checkboxes extends Component {
1255
+ /**
1256
+ * Checkboxes can be associated with a 'conditionally revealed' content block
1257
+ * – for example, a checkbox for 'Phone' could reveal an additional form field
1258
+ * for the user to enter their phone number.
1259
+ *
1260
+ * These associations are made using a `data-aria-controls` attribute, which
1261
+ * is promoted to an aria-controls attribute during initialisation.
1262
+ *
1263
+ * We also need to restore the state of any conditional reveals on the page
1264
+ * (for example if the user has navigated back), and set up event handlers to
1265
+ * keep the reveal in sync with the checkbox state.
1266
+ *
1267
+ * @param {Element | null} $root - HTML element to use for checkboxes
1268
+ */
1269
+ constructor($root) {
1270
+ super($root);
1271
+ this.$inputs = void 0;
1272
+ const $inputs = this.$root.querySelectorAll('input[type="checkbox"]');
1273
+ if (!$inputs.length) {
1274
+ throw new ElementError({
1275
+ component: Checkboxes,
1276
+ identifier: 'Form inputs (`<input type="checkbox">`)'
1277
+ });
1278
+ }
1279
+ this.$inputs = $inputs;
1280
+ this.$inputs.forEach($input => {
1281
+ const targetId = $input.getAttribute('data-aria-controls');
1282
+ if (!targetId) {
1283
+ return;
1284
+ }
1285
+ if (!document.getElementById(targetId)) {
1286
+ throw new ElementError({
1287
+ component: Checkboxes,
1288
+ identifier: `Conditional reveal (\`id="${targetId}"\`)`
1289
+ });
1290
+ }
1291
+ $input.setAttribute('aria-controls', targetId);
1292
+ $input.removeAttribute('data-aria-controls');
1293
+ });
1294
+ window.addEventListener('pageshow', () => this.syncAllConditionalReveals());
1295
+ this.syncAllConditionalReveals();
1296
+ this.$root.addEventListener('click', event => this.handleClick(event));
1297
+ }
1298
+ syncAllConditionalReveals() {
1299
+ this.$inputs.forEach($input => this.syncConditionalRevealWithInputState($input));
1300
+ }
1301
+ syncConditionalRevealWithInputState($input) {
1302
+ const targetId = $input.getAttribute('aria-controls');
1303
+ if (!targetId) {
1304
+ return;
1305
+ }
1306
+ const $target = document.getElementById(targetId);
1307
+ if ($target != null && $target.classList.contains('govuk-checkboxes__conditional')) {
1308
+ const inputIsChecked = $input.checked;
1309
+ $input.setAttribute('aria-expanded', inputIsChecked.toString());
1310
+ $target.classList.toggle('govuk-checkboxes__conditional--hidden', !inputIsChecked);
1311
+ }
1312
+ }
1313
+ unCheckAllInputsExcept($input) {
1314
+ const allInputsWithSameName = document.querySelectorAll(`input[type="checkbox"][name="${$input.name}"]`);
1315
+ allInputsWithSameName.forEach($inputWithSameName => {
1316
+ const hasSameFormOwner = $input.form === $inputWithSameName.form;
1317
+ if (hasSameFormOwner && $inputWithSameName !== $input) {
1318
+ $inputWithSameName.checked = false;
1319
+ this.syncConditionalRevealWithInputState($inputWithSameName);
1320
+ }
1321
+ });
1322
+ }
1323
+ unCheckExclusiveInputs($input) {
1324
+ const allInputsWithSameNameAndExclusiveBehaviour = document.querySelectorAll(`input[data-behaviour="exclusive"][type="checkbox"][name="${$input.name}"]`);
1325
+ allInputsWithSameNameAndExclusiveBehaviour.forEach($exclusiveInput => {
1326
+ const hasSameFormOwner = $input.form === $exclusiveInput.form;
1327
+ if (hasSameFormOwner) {
1328
+ $exclusiveInput.checked = false;
1329
+ this.syncConditionalRevealWithInputState($exclusiveInput);
1330
+ }
1331
+ });
1332
+ }
1333
+ handleClick(event) {
1334
+ const $clickedInput = event.target;
1335
+ if (!($clickedInput instanceof HTMLInputElement) || $clickedInput.type !== 'checkbox') {
1336
+ return;
1337
+ }
1338
+ const hasAriaControls = $clickedInput.getAttribute('aria-controls');
1339
+ if (hasAriaControls) {
1340
+ this.syncConditionalRevealWithInputState($clickedInput);
1341
+ }
1342
+ if (!$clickedInput.checked) {
1343
+ return;
1344
+ }
1345
+ const hasBehaviourExclusive = $clickedInput.getAttribute('data-behaviour') === 'exclusive';
1346
+ if (hasBehaviourExclusive) {
1347
+ this.unCheckAllInputsExcept($clickedInput);
1348
+ } else {
1349
+ this.unCheckExclusiveInputs($clickedInput);
1350
+ }
1351
+ }
1352
+ }
1353
+ Checkboxes.moduleName = 'govuk-checkboxes';
1354
+
1355
+ /**
1356
+ * Error summary component
1357
+ *
1358
+ * Takes focus on initialisation for accessible announcement, unless disabled in
1359
+ * configuration.
1360
+ *
1361
+ * @preserve
1362
+ * @augments ConfigurableComponent<ErrorSummaryConfig>
1363
+ */
1364
+ class ErrorSummary extends ConfigurableComponent {
1365
+ /**
1366
+ * @param {Element | null} $root - HTML element to use for error summary
1367
+ * @param {ErrorSummaryConfig} [config] - Error summary config
1368
+ */
1369
+ constructor($root, config = {}) {
1370
+ super($root, config);
1371
+ if (!this.config.disableAutoFocus) {
1372
+ setFocus(this.$root);
1373
+ }
1374
+ this.$root.addEventListener('click', event => this.handleClick(event));
1375
+ }
1376
+ handleClick(event) {
1377
+ const $target = event.target;
1378
+ if ($target && this.focusTarget($target)) {
1379
+ event.preventDefault();
1380
+ }
1381
+ }
1382
+ focusTarget($target) {
1383
+ if (!($target instanceof HTMLAnchorElement)) {
1384
+ return false;
1385
+ }
1386
+ const inputId = getFragmentFromUrl($target.href);
1387
+ if (!inputId) {
1388
+ return false;
1389
+ }
1390
+ const $input = document.getElementById(inputId);
1391
+ if (!$input) {
1392
+ return false;
1393
+ }
1394
+ const $legendOrLabel = this.getAssociatedLegendOrLabel($input);
1395
+ if (!$legendOrLabel) {
1396
+ return false;
1397
+ }
1398
+ $legendOrLabel.scrollIntoView();
1399
+ $input.focus({
1400
+ preventScroll: true
1401
+ });
1402
+ return true;
1403
+ }
1404
+ getAssociatedLegendOrLabel($input) {
1405
+ var _document$querySelect;
1406
+ const $fieldset = $input.closest('fieldset');
1407
+ if ($fieldset) {
1408
+ const $legends = $fieldset.getElementsByTagName('legend');
1409
+ if ($legends.length) {
1410
+ const $candidateLegend = $legends[0];
1411
+ if ($input instanceof HTMLInputElement && ($input.type === 'checkbox' || $input.type === 'radio')) {
1412
+ return $candidateLegend;
1413
+ }
1414
+ const legendTop = $candidateLegend.getBoundingClientRect().top;
1415
+ const inputRect = $input.getBoundingClientRect();
1416
+ if (inputRect.height && window.innerHeight) {
1417
+ const inputBottom = inputRect.top + inputRect.height;
1418
+ if (inputBottom - legendTop < window.innerHeight / 2) {
1419
+ return $candidateLegend;
1420
+ }
1421
+ }
1422
+ }
1423
+ }
1424
+ return (_document$querySelect = document.querySelector(`label[for='${$input.getAttribute('id')}']`)) != null ? _document$querySelect : $input.closest('label');
1425
+ }
1426
+ }
1427
+
1428
+ /**
1429
+ * Error summary config
1430
+ *
1431
+ * @typedef {object} ErrorSummaryConfig
1432
+ * @property {boolean} [disableAutoFocus=false] - If set to `true` the error
1433
+ * summary will not be focussed when the page loads.
1434
+ */
1435
+
1436
+ /**
1437
+ * @import { Schema } from '../../common/configuration.mjs'
1438
+ */
1439
+ ErrorSummary.moduleName = 'govuk-error-summary';
1440
+ ErrorSummary.defaults = Object.freeze({
1441
+ disableAutoFocus: false
1442
+ });
1443
+ ErrorSummary.schema = Object.freeze({
1444
+ properties: {
1445
+ disableAutoFocus: {
1446
+ type: 'boolean'
1447
+ }
1448
+ }
1449
+ });
1450
+
1451
+ /**
1452
+ * Exit this page component
1453
+ *
1454
+ * @preserve
1455
+ * @augments ConfigurableComponent<ExitThisPageConfig>
1456
+ */
1457
+ class ExitThisPage extends ConfigurableComponent {
1458
+ /**
1459
+ * @param {Element | null} $root - HTML element that wraps the Exit This Page button
1460
+ * @param {ExitThisPageConfig} [config] - Exit This Page config
1461
+ */
1462
+ constructor($root, config = {}) {
1463
+ super($root, config);
1464
+ this.i18n = void 0;
1465
+ this.$button = void 0;
1466
+ this.$skiplinkButton = null;
1467
+ this.$updateSpan = null;
1468
+ this.$indicatorContainer = null;
1469
+ this.$overlay = null;
1470
+ this.keypressCounter = 0;
1471
+ this.lastKeyWasModified = false;
1472
+ this.timeoutTime = 5000;
1473
+ this.keypressTimeoutId = null;
1474
+ this.timeoutMessageId = null;
1475
+ const $button = this.$root.querySelector('.govuk-exit-this-page__button');
1476
+ if (!($button instanceof HTMLAnchorElement)) {
1477
+ throw new ElementError({
1478
+ component: ExitThisPage,
1479
+ element: $button,
1480
+ expectedType: 'HTMLAnchorElement',
1481
+ identifier: 'Button (`.govuk-exit-this-page__button`)'
1482
+ });
1483
+ }
1484
+ this.i18n = new I18n(this.config.i18n);
1485
+ this.$button = $button;
1486
+ const $skiplinkButton = document.querySelector('.govuk-js-exit-this-page-skiplink');
1487
+ if ($skiplinkButton instanceof HTMLAnchorElement) {
1488
+ this.$skiplinkButton = $skiplinkButton;
1489
+ }
1490
+ this.buildIndicator();
1491
+ this.initUpdateSpan();
1492
+ this.initButtonClickHandler();
1493
+ if (!('govukFrontendExitThisPageKeypress' in document.body.dataset)) {
1494
+ document.addEventListener('keyup', this.handleKeypress.bind(this), true);
1495
+ document.body.dataset.govukFrontendExitThisPageKeypress = 'true';
1496
+ }
1497
+ window.addEventListener('pageshow', this.resetPage.bind(this));
1498
+ }
1499
+ initUpdateSpan() {
1500
+ this.$updateSpan = document.createElement('span');
1501
+ this.$updateSpan.setAttribute('role', 'status');
1502
+ this.$updateSpan.className = 'govuk-visually-hidden';
1503
+ this.$root.appendChild(this.$updateSpan);
1504
+ }
1505
+ initButtonClickHandler() {
1506
+ this.$button.addEventListener('click', this.handleClick.bind(this));
1507
+ if (this.$skiplinkButton) {
1508
+ this.$skiplinkButton.addEventListener('click', this.handleClick.bind(this));
1509
+ }
1510
+ }
1511
+ buildIndicator() {
1512
+ this.$indicatorContainer = document.createElement('div');
1513
+ this.$indicatorContainer.className = 'govuk-exit-this-page__indicator';
1514
+ this.$indicatorContainer.setAttribute('aria-hidden', 'true');
1515
+ for (let i = 0; i < 3; i++) {
1516
+ const $indicator = document.createElement('div');
1517
+ $indicator.className = 'govuk-exit-this-page__indicator-light';
1518
+ this.$indicatorContainer.appendChild($indicator);
1519
+ }
1520
+ this.$button.appendChild(this.$indicatorContainer);
1521
+ }
1522
+ updateIndicator() {
1523
+ if (!this.$indicatorContainer) {
1524
+ return;
1525
+ }
1526
+ this.$indicatorContainer.classList.toggle('govuk-exit-this-page__indicator--visible', this.keypressCounter > 0);
1527
+ const $indicators = this.$indicatorContainer.querySelectorAll('.govuk-exit-this-page__indicator-light');
1528
+ $indicators.forEach(($indicator, index) => {
1529
+ $indicator.classList.toggle('govuk-exit-this-page__indicator-light--on', index < this.keypressCounter);
1530
+ });
1531
+ }
1532
+ exitPage() {
1533
+ if (!this.$updateSpan) {
1534
+ return;
1535
+ }
1536
+ this.$updateSpan.textContent = '';
1537
+ document.body.classList.add('govuk-exit-this-page-hide-content');
1538
+ this.$overlay = document.createElement('div');
1539
+ this.$overlay.className = 'govuk-exit-this-page-overlay';
1540
+ this.$overlay.setAttribute('role', 'alert');
1541
+ document.body.appendChild(this.$overlay);
1542
+ this.$overlay.textContent = this.i18n.t('activated');
1543
+ window.location.href = this.$button.href;
1544
+ }
1545
+ handleClick(event) {
1546
+ event.preventDefault();
1547
+ this.exitPage();
1548
+ }
1549
+ handleKeypress(event) {
1550
+ if (!this.$updateSpan) {
1551
+ return;
1552
+ }
1553
+ if (event.key === 'Shift' && !this.lastKeyWasModified) {
1554
+ this.keypressCounter += 1;
1555
+ this.updateIndicator();
1556
+ if (this.timeoutMessageId) {
1557
+ window.clearTimeout(this.timeoutMessageId);
1558
+ this.timeoutMessageId = null;
1559
+ }
1560
+ if (this.keypressCounter >= 3) {
1561
+ this.keypressCounter = 0;
1562
+ if (this.keypressTimeoutId) {
1563
+ window.clearTimeout(this.keypressTimeoutId);
1564
+ this.keypressTimeoutId = null;
1565
+ }
1566
+ this.exitPage();
1567
+ } else {
1568
+ if (this.keypressCounter === 1) {
1569
+ this.$updateSpan.textContent = this.i18n.t('pressTwoMoreTimes');
1570
+ } else {
1571
+ this.$updateSpan.textContent = this.i18n.t('pressOneMoreTime');
1572
+ }
1573
+ }
1574
+ this.setKeypressTimer();
1575
+ } else if (this.keypressTimeoutId) {
1576
+ this.resetKeypressTimer();
1577
+ }
1578
+ this.lastKeyWasModified = event.shiftKey;
1579
+ }
1580
+ setKeypressTimer() {
1581
+ if (this.keypressTimeoutId) {
1582
+ window.clearTimeout(this.keypressTimeoutId);
1583
+ }
1584
+ this.keypressTimeoutId = window.setTimeout(this.resetKeypressTimer.bind(this), this.timeoutTime);
1585
+ }
1586
+ resetKeypressTimer() {
1587
+ if (!this.$updateSpan) {
1588
+ return;
1589
+ }
1590
+ if (this.keypressTimeoutId) {
1591
+ window.clearTimeout(this.keypressTimeoutId);
1592
+ this.keypressTimeoutId = null;
1593
+ }
1594
+ const $updateSpan = this.$updateSpan;
1595
+ this.keypressCounter = 0;
1596
+ $updateSpan.textContent = this.i18n.t('timedOut');
1597
+ this.timeoutMessageId = window.setTimeout(() => {
1598
+ $updateSpan.textContent = '';
1599
+ }, this.timeoutTime);
1600
+ this.updateIndicator();
1601
+ }
1602
+ resetPage() {
1603
+ document.body.classList.remove('govuk-exit-this-page-hide-content');
1604
+ if (this.$overlay) {
1605
+ this.$overlay.remove();
1606
+ this.$overlay = null;
1607
+ }
1608
+ if (this.$updateSpan) {
1609
+ this.$updateSpan.setAttribute('role', 'status');
1610
+ this.$updateSpan.textContent = '';
1611
+ }
1612
+ this.updateIndicator();
1613
+ if (this.keypressTimeoutId) {
1614
+ window.clearTimeout(this.keypressTimeoutId);
1615
+ }
1616
+ if (this.timeoutMessageId) {
1617
+ window.clearTimeout(this.timeoutMessageId);
1618
+ }
1619
+ }
1620
+ }
1621
+
1622
+ /**
1623
+ * Exit this Page config
1624
+ *
1625
+ * @see {@link ExitThisPage.defaults}
1626
+ * @typedef {object} ExitThisPageConfig
1627
+ * @property {ExitThisPageTranslations} [i18n=ExitThisPage.defaults.i18n] - Exit this page translations
1628
+ */
1629
+
1630
+ /**
1631
+ * Exit this Page translations
1632
+ *
1633
+ * @see {@link ExitThisPage.defaults.i18n}
1634
+ * @typedef {object} ExitThisPageTranslations
1635
+ *
1636
+ * Messages used by the component programatically inserted text, including
1637
+ * overlay text and screen reader announcements.
1638
+ * @property {string} [activated] - Screen reader announcement for when EtP
1639
+ * keypress functionality has been successfully activated.
1640
+ * @property {string} [timedOut] - Screen reader announcement for when the EtP
1641
+ * keypress functionality has timed out.
1642
+ * @property {string} [pressTwoMoreTimes] - Screen reader announcement informing
1643
+ * the user they must press the activation key two more times.
1644
+ * @property {string} [pressOneMoreTime] - Screen reader announcement informing
1645
+ * the user they must press the activation key one more time.
1646
+ */
1647
+
1648
+ /**
1649
+ * @import { Schema } from '../../common/configuration.mjs'
1650
+ */
1651
+ ExitThisPage.moduleName = 'govuk-exit-this-page';
1652
+ ExitThisPage.defaults = Object.freeze({
1653
+ i18n: {
1654
+ activated: 'Loading.',
1655
+ timedOut: 'Exit this page expired.',
1656
+ pressTwoMoreTimes: 'Shift, press 2 more times to exit.',
1657
+ pressOneMoreTime: 'Shift, press 1 more time to exit.'
1658
+ }
1659
+ });
1660
+ ExitThisPage.schema = Object.freeze({
1661
+ properties: {
1662
+ i18n: {
1663
+ type: 'object'
1664
+ }
1665
+ }
1666
+ });
1667
+
1668
+ /**
1669
+ * File upload component
1670
+ *
1671
+ * @preserve
1672
+ * @augments ConfigurableComponent<FileUploadConfig>
1673
+ */
1674
+ class FileUpload extends ConfigurableComponent {
1675
+ /**
1676
+ * @param {Element | null} $root - File input element
1677
+ * @param {FileUploadConfig} [config] - File Upload config
1678
+ */
1679
+ constructor($root, config = {}) {
1680
+ super($root, config);
1681
+ this.$input = void 0;
1682
+ this.$button = void 0;
1683
+ this.$status = void 0;
1684
+ this.i18n = void 0;
1685
+ this.id = void 0;
1686
+ this.$announcements = void 0;
1687
+ this.enteredAnotherElement = void 0;
1688
+ const $input = this.$root.querySelector('input');
1689
+ if ($input === null) {
1690
+ throw new ElementError({
1691
+ component: FileUpload,
1692
+ identifier: 'File inputs (`<input type="file">`)'
1693
+ });
1694
+ }
1695
+ if ($input.type !== 'file') {
1696
+ throw new ElementError(formatErrorMessage(FileUpload, 'File input (`<input type="file">`) attribute (`type`) is not `file`'));
1697
+ }
1698
+ this.$input = $input;
1699
+ this.$input.setAttribute('hidden', 'true');
1700
+ if (!this.$input.id) {
1701
+ throw new ElementError({
1702
+ component: FileUpload,
1703
+ identifier: 'File input (`<input type="file">`) attribute (`id`)'
1704
+ });
1705
+ }
1706
+ this.id = this.$input.id;
1707
+ this.i18n = new I18n(this.config.i18n, {
1708
+ locale: closestAttributeValue(this.$root, 'lang')
1709
+ });
1710
+ const $label = this.findLabel();
1711
+ if (!$label.id) {
1712
+ $label.id = `${this.id}-label`;
1713
+ }
1714
+ this.$input.id = `${this.id}-input`;
1715
+ const $button = document.createElement('button');
1716
+ $button.classList.add('govuk-file-upload-button');
1717
+ $button.type = 'button';
1718
+ $button.id = this.id;
1719
+ $button.classList.add('govuk-file-upload-button--empty');
1720
+ const ariaDescribedBy = this.$input.getAttribute('aria-describedby');
1721
+ if (ariaDescribedBy) {
1722
+ $button.setAttribute('aria-describedby', ariaDescribedBy);
1723
+ }
1724
+ const $status = document.createElement('span');
1725
+ $status.className = 'govuk-body govuk-file-upload-button__status';
1726
+ $status.setAttribute('aria-live', 'polite');
1727
+ $status.innerText = this.i18n.t('noFileChosen');
1728
+ $button.appendChild($status);
1729
+ const commaSpan = document.createElement('span');
1730
+ commaSpan.className = 'govuk-visually-hidden';
1731
+ commaSpan.innerText = ', ';
1732
+ commaSpan.id = `${this.id}-comma`;
1733
+ $button.appendChild(commaSpan);
1734
+ const containerSpan = document.createElement('span');
1735
+ containerSpan.className = 'govuk-file-upload-button__pseudo-button-container';
1736
+ const buttonSpan = document.createElement('span');
1737
+ buttonSpan.className = 'govuk-button govuk-button--secondary govuk-file-upload-button__pseudo-button';
1738
+ buttonSpan.innerText = this.i18n.t('chooseFilesButton');
1739
+ containerSpan.appendChild(buttonSpan);
1740
+ containerSpan.insertAdjacentText('beforeend', ' ');
1741
+ const instructionSpan = document.createElement('span');
1742
+ instructionSpan.className = 'govuk-body govuk-file-upload-button__instruction';
1743
+ instructionSpan.innerText = this.i18n.t('dropInstruction');
1744
+ containerSpan.appendChild(instructionSpan);
1745
+ $button.appendChild(containerSpan);
1746
+ $button.setAttribute('aria-labelledby', `${$label.id} ${commaSpan.id} ${$button.id}`);
1747
+ $button.addEventListener('click', this.onClick.bind(this));
1748
+ $button.addEventListener('dragover', event => {
1749
+ event.preventDefault();
1750
+ });
1751
+ this.$root.insertAdjacentElement('afterbegin', $button);
1752
+ this.$input.setAttribute('tabindex', '-1');
1753
+ this.$input.setAttribute('aria-hidden', 'true');
1754
+ this.$button = $button;
1755
+ this.$status = $status;
1756
+ this.$input.addEventListener('change', this.onChange.bind(this));
1757
+ this.updateDisabledState();
1758
+ this.observeDisabledState();
1759
+ this.$announcements = document.createElement('span');
1760
+ this.$announcements.classList.add('govuk-file-upload-announcements');
1761
+ this.$announcements.classList.add('govuk-visually-hidden');
1762
+ this.$announcements.setAttribute('aria-live', 'assertive');
1763
+ this.$root.insertAdjacentElement('afterend', this.$announcements);
1764
+ this.$button.addEventListener('drop', this.onDrop.bind(this));
1765
+ document.addEventListener('dragenter', this.updateDropzoneVisibility.bind(this));
1766
+ document.addEventListener('dragenter', () => {
1767
+ this.enteredAnotherElement = true;
1768
+ });
1769
+ document.addEventListener('dragleave', () => {
1770
+ if (!this.enteredAnotherElement && !this.$button.disabled) {
1771
+ this.hideDraggingState();
1772
+ this.$announcements.innerText = this.i18n.t('leftDropZone');
1773
+ }
1774
+ this.enteredAnotherElement = false;
1775
+ });
1776
+ }
1777
+ updateDropzoneVisibility(event) {
1778
+ if (this.$button.disabled) return;
1779
+ if (event.target instanceof Node) {
1780
+ if (this.$root.contains(event.target)) {
1781
+ if (event.dataTransfer && isContainingFiles(event.dataTransfer)) {
1782
+ if (!this.$button.classList.contains('govuk-file-upload-button--dragging')) {
1783
+ this.showDraggingState();
1784
+ this.$announcements.innerText = this.i18n.t('enteredDropZone');
1785
+ }
1786
+ }
1787
+ } else {
1788
+ if (this.$button.classList.contains('govuk-file-upload-button--dragging')) {
1789
+ this.hideDraggingState();
1790
+ this.$announcements.innerText = this.i18n.t('leftDropZone');
1791
+ }
1792
+ }
1793
+ }
1794
+ }
1795
+ showDraggingState() {
1796
+ this.$button.classList.add('govuk-file-upload-button--dragging');
1797
+ }
1798
+ hideDraggingState() {
1799
+ this.$button.classList.remove('govuk-file-upload-button--dragging');
1800
+ }
1801
+ onDrop(event) {
1802
+ event.preventDefault();
1803
+ if (event.dataTransfer && isContainingFiles(event.dataTransfer)) {
1804
+ this.$input.files = event.dataTransfer.files;
1805
+ this.$input.dispatchEvent(new CustomEvent('change'));
1806
+ this.hideDraggingState();
1807
+ }
1808
+ }
1809
+ onChange() {
1810
+ const fileCount = this.$input.files.length;
1811
+ if (fileCount === 0) {
1812
+ this.$status.innerText = this.i18n.t('noFileChosen');
1813
+ this.$button.classList.add('govuk-file-upload-button--empty');
1814
+ } else {
1815
+ if (fileCount === 1) {
1816
+ this.$status.innerText = this.$input.files[0].name;
1817
+ } else {
1818
+ this.$status.innerText = this.i18n.t('multipleFilesChosen', {
1819
+ count: fileCount
1820
+ });
1821
+ }
1822
+ this.$button.classList.remove('govuk-file-upload-button--empty');
1823
+ }
1824
+ }
1825
+ findLabel() {
1826
+ const $label = document.querySelector(`label[for="${this.$input.id}"]`);
1827
+ if (!$label) {
1828
+ throw new ElementError({
1829
+ component: FileUpload,
1830
+ identifier: `Field label (\`<label for=${this.$input.id}>\`)`
1831
+ });
1832
+ }
1833
+ return $label;
1834
+ }
1835
+ onClick() {
1836
+ this.$input.click();
1837
+ }
1838
+ observeDisabledState() {
1839
+ const observer = new MutationObserver(mutationList => {
1840
+ for (const mutation of mutationList) {
1841
+ if (mutation.type === 'attributes' && mutation.attributeName === 'disabled') {
1842
+ this.updateDisabledState();
1843
+ }
1844
+ }
1845
+ });
1846
+ observer.observe(this.$input, {
1847
+ attributes: true
1848
+ });
1849
+ }
1850
+ updateDisabledState() {
1851
+ this.$button.disabled = this.$input.disabled;
1852
+ this.$root.classList.toggle('govuk-drop-zone--disabled', this.$button.disabled);
1853
+ }
1854
+ }
1855
+ FileUpload.moduleName = 'govuk-file-upload';
1856
+ FileUpload.defaults = Object.freeze({
1857
+ i18n: {
1858
+ chooseFilesButton: 'Choose file',
1859
+ dropInstruction: 'or drop file',
1860
+ noFileChosen: 'No file chosen',
1861
+ multipleFilesChosen: {
1862
+ one: '%{count} file chosen',
1863
+ other: '%{count} files chosen'
1864
+ },
1865
+ enteredDropZone: 'Entered drop zone',
1866
+ leftDropZone: 'Left drop zone'
1867
+ }
1868
+ });
1869
+ FileUpload.schema = Object.freeze({
1870
+ properties: {
1871
+ i18n: {
1872
+ type: 'object'
1873
+ }
1874
+ }
1875
+ });
1876
+ function isContainingFiles(dataTransfer) {
1877
+ const hasNoTypesInfo = dataTransfer.types.length === 0;
1878
+ const isDraggingFiles = dataTransfer.types.some(type => type === 'Files');
1879
+ return hasNoTypesInfo || isDraggingFiles;
1880
+ }
1881
+
1882
+ /**
1883
+ * @typedef {HTMLInputElement & {files: FileList}} HTMLFileInputElement
1884
+ */
1885
+
1886
+ /**
1887
+ * File upload config
1888
+ *
1889
+ * @see {@link FileUpload.defaults}
1890
+ * @typedef {object} FileUploadConfig
1891
+ * @property {FileUploadTranslations} [i18n=FileUpload.defaults.i18n] - File upload translations
1892
+ */
1893
+
1894
+ /**
1895
+ * File upload translations
1896
+ *
1897
+ * @see {@link FileUpload.defaults.i18n}
1898
+ * @typedef {object} FileUploadTranslations
1899
+ *
1900
+ * Messages used by the component
1901
+ * @property {string} [chooseFile] - The text of the button that opens the file picker
1902
+ * @property {string} [dropInstruction] - The text informing users they can drop files
1903
+ * @property {TranslationPluralForms} [multipleFilesChosen] - The text displayed when multiple files
1904
+ * have been chosen by the user
1905
+ * @property {string} [noFileChosen] - The text to displayed when no file has been chosen by the user
1906
+ * @property {string} [enteredDropZone] - The text announced by assistive technology
1907
+ * when user drags files and enters the drop zone
1908
+ * @property {string} [leftDropZone] - The text announced by assistive technology
1909
+ * when user drags files and leaves the drop zone without dropping
1910
+ */
1911
+
1912
+ /**
1913
+ * @import { Schema } from '../../common/configuration.mjs'
1914
+ * @import { TranslationPluralForms } from '../../i18n.mjs'
1915
+ */
1916
+
1917
+ /**
1918
+ * Header component
1919
+ *
1920
+ * @preserve
1921
+ */
1922
+ class Header extends Component {
1923
+ /**
1924
+ * Apply a matchMedia for desktop which will trigger a state sync if the
1925
+ * browser viewport moves between states.
1926
+ *
1927
+ * @param {Element | null} $root - HTML element to use for header
1928
+ */
1929
+ constructor($root) {
1930
+ super($root);
1931
+ this.$menuButton = void 0;
1932
+ this.$menu = void 0;
1933
+ this.menuIsOpen = false;
1934
+ this.mql = null;
1935
+ const $menuButton = this.$root.querySelector('.govuk-js-header-toggle');
1936
+ if (!$menuButton) {
1937
+ return this;
1938
+ }
1939
+ this.$root.classList.add('govuk-header--with-js-navigation');
1940
+ const menuId = $menuButton.getAttribute('aria-controls');
1941
+ if (!menuId) {
1942
+ throw new ElementError({
1943
+ component: Header,
1944
+ identifier: 'Navigation button (`<button class="govuk-js-header-toggle">`) attribute (`aria-controls`)'
1945
+ });
1946
+ }
1947
+ const $menu = document.getElementById(menuId);
1948
+ if (!$menu) {
1949
+ throw new ElementError({
1950
+ component: Header,
1951
+ element: $menu,
1952
+ identifier: `Navigation (\`<ul id="${menuId}">\`)`
1953
+ });
1954
+ }
1955
+ this.$menu = $menu;
1956
+ this.$menuButton = $menuButton;
1957
+ this.setupResponsiveChecks();
1958
+ this.$menuButton.addEventListener('click', () => this.handleMenuButtonClick());
1959
+ }
1960
+ setupResponsiveChecks() {
1961
+ const breakpoint = getBreakpoint('desktop');
1962
+ if (!breakpoint.value) {
1963
+ throw new ElementError({
1964
+ component: Header,
1965
+ identifier: `CSS custom property (\`${breakpoint.property}\`) on pseudo-class \`:root\``
1966
+ });
1967
+ }
1968
+ this.mql = window.matchMedia(`(min-width: ${breakpoint.value})`);
1969
+ if ('addEventListener' in this.mql) {
1970
+ this.mql.addEventListener('change', () => this.checkMode());
1971
+ } else {
1972
+ this.mql.addListener(() => this.checkMode());
1973
+ }
1974
+ this.checkMode();
1975
+ }
1976
+ checkMode() {
1977
+ if (!this.mql || !this.$menu || !this.$menuButton) {
1978
+ return;
1979
+ }
1980
+ if (this.mql.matches) {
1981
+ this.$menu.removeAttribute('hidden');
1982
+ this.$menuButton.setAttribute('hidden', '');
1983
+ } else {
1984
+ this.$menuButton.removeAttribute('hidden');
1985
+ this.$menuButton.setAttribute('aria-expanded', this.menuIsOpen.toString());
1986
+ if (this.menuIsOpen) {
1987
+ this.$menu.removeAttribute('hidden');
1988
+ } else {
1989
+ this.$menu.setAttribute('hidden', '');
1990
+ }
1991
+ }
1992
+ }
1993
+ handleMenuButtonClick() {
1994
+ this.menuIsOpen = !this.menuIsOpen;
1995
+ this.checkMode();
1996
+ }
1997
+ }
1998
+ Header.moduleName = 'govuk-header';
1999
+
2000
+ /**
2001
+ * Notification Banner component
2002
+ *
2003
+ * @preserve
2004
+ * @augments ConfigurableComponent<NotificationBannerConfig>
2005
+ */
2006
+ class NotificationBanner extends ConfigurableComponent {
2007
+ /**
2008
+ * @param {Element | null} $root - HTML element to use for notification banner
2009
+ * @param {NotificationBannerConfig} [config] - Notification banner config
2010
+ */
2011
+ constructor($root, config = {}) {
2012
+ super($root, config);
2013
+ if (this.$root.getAttribute('role') === 'alert' && !this.config.disableAutoFocus) {
2014
+ setFocus(this.$root);
2015
+ }
2016
+ }
2017
+ }
2018
+
2019
+ /**
2020
+ * Notification banner config
2021
+ *
2022
+ * @typedef {object} NotificationBannerConfig
2023
+ * @property {boolean} [disableAutoFocus=false] - If set to `true` the
2024
+ * notification banner will not be focussed when the page loads. This only
2025
+ * applies if the component has a `role` of `alert` – in other cases the
2026
+ * component will not be focused on page load, regardless of this option.
2027
+ */
2028
+
2029
+ /**
2030
+ * @import { Schema } from '../../common/configuration.mjs'
2031
+ */
2032
+ NotificationBanner.moduleName = 'govuk-notification-banner';
2033
+ NotificationBanner.defaults = Object.freeze({
2034
+ disableAutoFocus: false
2035
+ });
2036
+ NotificationBanner.schema = Object.freeze({
2037
+ properties: {
2038
+ disableAutoFocus: {
2039
+ type: 'boolean'
2040
+ }
2041
+ }
2042
+ });
2043
+
2044
+ /**
2045
+ * Password input component
2046
+ *
2047
+ * @preserve
2048
+ * @augments ConfigurableComponent<PasswordInputConfig>
2049
+ */
2050
+ class PasswordInput extends ConfigurableComponent {
2051
+ /**
2052
+ * @param {Element | null} $root - HTML element to use for password input
2053
+ * @param {PasswordInputConfig} [config] - Password input config
2054
+ */
2055
+ constructor($root, config = {}) {
2056
+ super($root, config);
2057
+ this.i18n = void 0;
2058
+ this.$input = void 0;
2059
+ this.$showHideButton = void 0;
2060
+ this.$screenReaderStatusMessage = void 0;
2061
+ const $input = this.$root.querySelector('.govuk-js-password-input-input');
2062
+ if (!($input instanceof HTMLInputElement)) {
2063
+ throw new ElementError({
2064
+ component: PasswordInput,
2065
+ element: $input,
2066
+ expectedType: 'HTMLInputElement',
2067
+ identifier: 'Form field (`.govuk-js-password-input-input`)'
2068
+ });
2069
+ }
2070
+ if ($input.type !== 'password') {
2071
+ throw new ElementError('Password input: Form field (`.govuk-js-password-input-input`) must be of type `password`.');
2072
+ }
2073
+ const $showHideButton = this.$root.querySelector('.govuk-js-password-input-toggle');
2074
+ if (!($showHideButton instanceof HTMLButtonElement)) {
2075
+ throw new ElementError({
2076
+ component: PasswordInput,
2077
+ element: $showHideButton,
2078
+ expectedType: 'HTMLButtonElement',
2079
+ identifier: 'Button (`.govuk-js-password-input-toggle`)'
2080
+ });
2081
+ }
2082
+ if ($showHideButton.type !== 'button') {
2083
+ throw new ElementError('Password input: Button (`.govuk-js-password-input-toggle`) must be of type `button`.');
2084
+ }
2085
+ this.$input = $input;
2086
+ this.$showHideButton = $showHideButton;
2087
+ this.i18n = new I18n(this.config.i18n, {
2088
+ locale: closestAttributeValue(this.$root, 'lang')
2089
+ });
2090
+ this.$showHideButton.removeAttribute('hidden');
2091
+ const $screenReaderStatusMessage = document.createElement('div');
2092
+ $screenReaderStatusMessage.className = 'govuk-password-input__sr-status govuk-visually-hidden';
2093
+ $screenReaderStatusMessage.setAttribute('aria-live', 'polite');
2094
+ this.$screenReaderStatusMessage = $screenReaderStatusMessage;
2095
+ this.$input.insertAdjacentElement('afterend', $screenReaderStatusMessage);
2096
+ this.$showHideButton.addEventListener('click', this.toggle.bind(this));
2097
+ if (this.$input.form) {
2098
+ this.$input.form.addEventListener('submit', () => this.hide());
2099
+ }
2100
+ window.addEventListener('pageshow', event => {
2101
+ if (event.persisted && this.$input.type !== 'password') {
2102
+ this.hide();
2103
+ }
2104
+ });
2105
+ this.hide();
2106
+ }
2107
+ toggle(event) {
2108
+ event.preventDefault();
2109
+ if (this.$input.type === 'password') {
2110
+ this.show();
2111
+ return;
2112
+ }
2113
+ this.hide();
2114
+ }
2115
+ show() {
2116
+ this.setType('text');
2117
+ }
2118
+ hide() {
2119
+ this.setType('password');
2120
+ }
2121
+ setType(type) {
2122
+ if (type === this.$input.type) {
2123
+ return;
2124
+ }
2125
+ this.$input.setAttribute('type', type);
2126
+ const isHidden = type === 'password';
2127
+ const prefixButton = isHidden ? 'show' : 'hide';
2128
+ const prefixStatus = isHidden ? 'passwordHidden' : 'passwordShown';
2129
+ this.$showHideButton.innerText = this.i18n.t(`${prefixButton}Password`);
2130
+ this.$showHideButton.setAttribute('aria-label', this.i18n.t(`${prefixButton}PasswordAriaLabel`));
2131
+ this.$screenReaderStatusMessage.innerText = this.i18n.t(`${prefixStatus}Announcement`);
2132
+ }
2133
+ }
2134
+
2135
+ /**
2136
+ * Password input config
2137
+ *
2138
+ * @typedef {object} PasswordInputConfig
2139
+ * @property {PasswordInputTranslations} [i18n=PasswordInput.defaults.i18n] - Password input translations
2140
+ */
2141
+
2142
+ /**
2143
+ * Password input translations
2144
+ *
2145
+ * @see {@link PasswordInput.defaults.i18n}
2146
+ * @typedef {object} PasswordInputTranslations
2147
+ *
2148
+ * Messages displayed to the user indicating the state of the show/hide toggle.
2149
+ * @property {string} [showPassword] - Visible text of the button when the
2150
+ * password is currently hidden. Plain text only.
2151
+ * @property {string} [hidePassword] - Visible text of the button when the
2152
+ * password is currently visible. Plain text only.
2153
+ * @property {string} [showPasswordAriaLabel] - aria-label of the button when
2154
+ * the password is currently hidden. Plain text only.
2155
+ * @property {string} [hidePasswordAriaLabel] - aria-label of the button when
2156
+ * the password is currently visible. Plain text only.
2157
+ * @property {string} [passwordShownAnnouncement] - Screen reader
2158
+ * announcement to make when the password has just become visible.
2159
+ * Plain text only.
2160
+ * @property {string} [passwordHiddenAnnouncement] - Screen reader
2161
+ * announcement to make when the password has just been hidden.
2162
+ * Plain text only.
2163
+ */
2164
+
2165
+ /**
2166
+ * @import { Schema } from '../../common/configuration.mjs'
2167
+ */
2168
+ PasswordInput.moduleName = 'govuk-password-input';
2169
+ PasswordInput.defaults = Object.freeze({
2170
+ i18n: {
2171
+ showPassword: 'Show',
2172
+ hidePassword: 'Hide',
2173
+ showPasswordAriaLabel: 'Show password',
2174
+ hidePasswordAriaLabel: 'Hide password',
2175
+ passwordShownAnnouncement: 'Your password is visible',
2176
+ passwordHiddenAnnouncement: 'Your password is hidden'
2177
+ }
2178
+ });
2179
+ PasswordInput.schema = Object.freeze({
2180
+ properties: {
2181
+ i18n: {
2182
+ type: 'object'
2183
+ }
2184
+ }
2185
+ });
2186
+
2187
+ /**
2188
+ * Radios component
2189
+ *
2190
+ * @preserve
2191
+ */
2192
+ class Radios extends Component {
2193
+ /**
2194
+ * Radios can be associated with a 'conditionally revealed' content block –
2195
+ * for example, a radio for 'Phone' could reveal an additional form field for
2196
+ * the user to enter their phone number.
2197
+ *
2198
+ * These associations are made using a `data-aria-controls` attribute, which
2199
+ * is promoted to an aria-controls attribute during initialisation.
2200
+ *
2201
+ * We also need to restore the state of any conditional reveals on the page
2202
+ * (for example if the user has navigated back), and set up event handlers to
2203
+ * keep the reveal in sync with the radio state.
2204
+ *
2205
+ * @param {Element | null} $root - HTML element to use for radios
2206
+ */
2207
+ constructor($root) {
2208
+ super($root);
2209
+ this.$inputs = void 0;
2210
+ const $inputs = this.$root.querySelectorAll('input[type="radio"]');
2211
+ if (!$inputs.length) {
2212
+ throw new ElementError({
2213
+ component: Radios,
2214
+ identifier: 'Form inputs (`<input type="radio">`)'
2215
+ });
2216
+ }
2217
+ this.$inputs = $inputs;
2218
+ this.$inputs.forEach($input => {
2219
+ const targetId = $input.getAttribute('data-aria-controls');
2220
+ if (!targetId) {
2221
+ return;
2222
+ }
2223
+ if (!document.getElementById(targetId)) {
2224
+ throw new ElementError({
2225
+ component: Radios,
2226
+ identifier: `Conditional reveal (\`id="${targetId}"\`)`
2227
+ });
2228
+ }
2229
+ $input.setAttribute('aria-controls', targetId);
2230
+ $input.removeAttribute('data-aria-controls');
2231
+ });
2232
+ window.addEventListener('pageshow', () => this.syncAllConditionalReveals());
2233
+ this.syncAllConditionalReveals();
2234
+ this.$root.addEventListener('click', event => this.handleClick(event));
2235
+ }
2236
+ syncAllConditionalReveals() {
2237
+ this.$inputs.forEach($input => this.syncConditionalRevealWithInputState($input));
2238
+ }
2239
+ syncConditionalRevealWithInputState($input) {
2240
+ const targetId = $input.getAttribute('aria-controls');
2241
+ if (!targetId) {
2242
+ return;
2243
+ }
2244
+ const $target = document.getElementById(targetId);
2245
+ if ($target != null && $target.classList.contains('govuk-radios__conditional')) {
2246
+ const inputIsChecked = $input.checked;
2247
+ $input.setAttribute('aria-expanded', inputIsChecked.toString());
2248
+ $target.classList.toggle('govuk-radios__conditional--hidden', !inputIsChecked);
2249
+ }
2250
+ }
2251
+ handleClick(event) {
2252
+ const $clickedInput = event.target;
2253
+ if (!($clickedInput instanceof HTMLInputElement) || $clickedInput.type !== 'radio') {
2254
+ return;
2255
+ }
2256
+ const $allInputs = document.querySelectorAll('input[type="radio"][aria-controls]');
2257
+ const $clickedInputForm = $clickedInput.form;
2258
+ const $clickedInputName = $clickedInput.name;
2259
+ $allInputs.forEach($input => {
2260
+ const hasSameFormOwner = $input.form === $clickedInputForm;
2261
+ const hasSameName = $input.name === $clickedInputName;
2262
+ if (hasSameName && hasSameFormOwner) {
2263
+ this.syncConditionalRevealWithInputState($input);
2264
+ }
2265
+ });
2266
+ }
2267
+ }
2268
+ Radios.moduleName = 'govuk-radios';
2269
+
2270
+ /**
2271
+ * Service Navigation component
2272
+ *
2273
+ * @preserve
2274
+ */
2275
+ class ServiceNavigation extends Component {
2276
+ /**
2277
+ * @param {Element | null} $root - HTML element to use for header
2278
+ */
2279
+ constructor($root) {
2280
+ super($root);
2281
+ this.$menuButton = void 0;
2282
+ this.$menu = void 0;
2283
+ this.menuIsOpen = false;
2284
+ this.mql = null;
2285
+ const $menuButton = this.$root.querySelector('.govuk-js-service-navigation-toggle');
2286
+ if (!$menuButton) {
2287
+ return this;
2288
+ }
2289
+ const menuId = $menuButton.getAttribute('aria-controls');
2290
+ if (!menuId) {
2291
+ throw new ElementError({
2292
+ component: ServiceNavigation,
2293
+ identifier: 'Navigation button (`<button class="govuk-js-service-navigation-toggle">`) attribute (`aria-controls`)'
2294
+ });
2295
+ }
2296
+ const $menu = document.getElementById(menuId);
2297
+ if (!$menu) {
2298
+ throw new ElementError({
2299
+ component: ServiceNavigation,
2300
+ element: $menu,
2301
+ identifier: `Navigation (\`<ul id="${menuId}">\`)`
2302
+ });
2303
+ }
2304
+ this.$menu = $menu;
2305
+ this.$menuButton = $menuButton;
2306
+ this.setupResponsiveChecks();
2307
+ this.$menuButton.addEventListener('click', () => this.handleMenuButtonClick());
2308
+ }
2309
+ setupResponsiveChecks() {
2310
+ const breakpoint = getBreakpoint('tablet');
2311
+ if (!breakpoint.value) {
2312
+ throw new ElementError({
2313
+ component: ServiceNavigation,
2314
+ identifier: `CSS custom property (\`${breakpoint.property}\`) on pseudo-class \`:root\``
2315
+ });
2316
+ }
2317
+ this.mql = window.matchMedia(`(min-width: ${breakpoint.value})`);
2318
+ if ('addEventListener' in this.mql) {
2319
+ this.mql.addEventListener('change', () => this.checkMode());
2320
+ } else {
2321
+ this.mql.addListener(() => this.checkMode());
2322
+ }
2323
+ this.checkMode();
2324
+ }
2325
+ checkMode() {
2326
+ if (!this.mql || !this.$menu || !this.$menuButton) {
2327
+ return;
2328
+ }
2329
+ if (this.mql.matches) {
2330
+ this.$menu.removeAttribute('hidden');
2331
+ this.$menuButton.setAttribute('hidden', '');
2332
+ } else {
2333
+ this.$menuButton.removeAttribute('hidden');
2334
+ this.$menuButton.setAttribute('aria-expanded', this.menuIsOpen.toString());
2335
+ if (this.menuIsOpen) {
2336
+ this.$menu.removeAttribute('hidden');
2337
+ } else {
2338
+ this.$menu.setAttribute('hidden', '');
2339
+ }
2340
+ }
2341
+ }
2342
+ handleMenuButtonClick() {
2343
+ this.menuIsOpen = !this.menuIsOpen;
2344
+ this.checkMode();
2345
+ }
2346
+ }
2347
+ ServiceNavigation.moduleName = 'govuk-service-navigation';
2348
+
2349
+ /**
2350
+ * Skip link component
2351
+ *
2352
+ * @preserve
2353
+ * @augments Component<HTMLAnchorElement>
2354
+ */
2355
+ class SkipLink extends Component {
2356
+ /**
2357
+ * @param {Element | null} $root - HTML element to use for skip link
2358
+ * @throws {ElementError} when $root is not set or the wrong type
2359
+ * @throws {ElementError} when $root.hash does not contain a hash
2360
+ * @throws {ElementError} when the linked element is missing or the wrong type
2361
+ */
2362
+ constructor($root) {
2363
+ var _this$$root$getAttrib;
2364
+ super($root);
2365
+ const hash = this.$root.hash;
2366
+ const href = (_this$$root$getAttrib = this.$root.getAttribute('href')) != null ? _this$$root$getAttrib : '';
2367
+ let url;
2368
+ try {
2369
+ url = new window.URL(this.$root.href);
2370
+ } catch (error) {
2371
+ throw new ElementError(`Skip link: Target link (\`href="${href}"\`) is invalid`);
2372
+ }
2373
+ if (url.origin !== window.location.origin || url.pathname !== window.location.pathname) {
2374
+ return;
2375
+ }
2376
+ const linkedElementId = getFragmentFromUrl(hash);
2377
+ if (!linkedElementId) {
2378
+ throw new ElementError(`Skip link: Target link (\`href="${href}"\`) has no hash fragment`);
2379
+ }
2380
+ const $linkedElement = document.getElementById(linkedElementId);
2381
+ if (!$linkedElement) {
2382
+ throw new ElementError({
2383
+ component: SkipLink,
2384
+ element: $linkedElement,
2385
+ identifier: `Target content (\`id="${linkedElementId}"\`)`
2386
+ });
2387
+ }
2388
+ this.$root.addEventListener('click', () => setFocus($linkedElement, {
2389
+ onBeforeFocus() {
2390
+ $linkedElement.classList.add('govuk-skip-link-focused-element');
2391
+ },
2392
+ onBlur() {
2393
+ $linkedElement.classList.remove('govuk-skip-link-focused-element');
2394
+ }
2395
+ }));
2396
+ }
2397
+ }
2398
+ SkipLink.elementType = HTMLAnchorElement;
2399
+ SkipLink.moduleName = 'govuk-skip-link';
2400
+
2401
+ /**
2402
+ * Tabs component
2403
+ *
2404
+ * @preserve
2405
+ */
2406
+ class Tabs extends Component {
2407
+ /**
2408
+ * @param {Element | null} $root - HTML element to use for tabs
2409
+ */
2410
+ constructor($root) {
2411
+ super($root);
2412
+ this.$tabs = void 0;
2413
+ this.$tabList = void 0;
2414
+ this.$tabListItems = void 0;
2415
+ this.jsHiddenClass = 'govuk-tabs__panel--hidden';
2416
+ this.changingHash = false;
2417
+ this.boundTabClick = void 0;
2418
+ this.boundTabKeydown = void 0;
2419
+ this.boundOnHashChange = void 0;
2420
+ this.mql = null;
2421
+ const $tabs = this.$root.querySelectorAll('a.govuk-tabs__tab');
2422
+ if (!$tabs.length) {
2423
+ throw new ElementError({
2424
+ component: Tabs,
2425
+ identifier: 'Links (`<a class="govuk-tabs__tab">`)'
2426
+ });
2427
+ }
2428
+ this.$tabs = $tabs;
2429
+ this.boundTabClick = this.onTabClick.bind(this);
2430
+ this.boundTabKeydown = this.onTabKeydown.bind(this);
2431
+ this.boundOnHashChange = this.onHashChange.bind(this);
2432
+ const $tabList = this.$root.querySelector('.govuk-tabs__list');
2433
+ const $tabListItems = this.$root.querySelectorAll('li.govuk-tabs__list-item');
2434
+ if (!$tabList) {
2435
+ throw new ElementError({
2436
+ component: Tabs,
2437
+ identifier: 'List (`<ul class="govuk-tabs__list">`)'
2438
+ });
2439
+ }
2440
+ if (!$tabListItems.length) {
2441
+ throw new ElementError({
2442
+ component: Tabs,
2443
+ identifier: 'List items (`<li class="govuk-tabs__list-item">`)'
2444
+ });
2445
+ }
2446
+ this.$tabList = $tabList;
2447
+ this.$tabListItems = $tabListItems;
2448
+ this.setupResponsiveChecks();
2449
+ }
2450
+ setupResponsiveChecks() {
2451
+ const breakpoint = getBreakpoint('tablet');
2452
+ if (!breakpoint.value) {
2453
+ throw new ElementError({
2454
+ component: Tabs,
2455
+ identifier: `CSS custom property (\`${breakpoint.property}\`) on pseudo-class \`:root\``
2456
+ });
2457
+ }
2458
+ this.mql = window.matchMedia(`(min-width: ${breakpoint.value})`);
2459
+ if ('addEventListener' in this.mql) {
2460
+ this.mql.addEventListener('change', () => this.checkMode());
2461
+ } else {
2462
+ this.mql.addListener(() => this.checkMode());
2463
+ }
2464
+ this.checkMode();
2465
+ }
2466
+ checkMode() {
2467
+ var _this$mql;
2468
+ if ((_this$mql = this.mql) != null && _this$mql.matches) {
2469
+ this.setup();
2470
+ } else {
2471
+ this.teardown();
2472
+ }
2473
+ }
2474
+ setup() {
2475
+ var _this$getTab;
2476
+ this.$tabList.setAttribute('role', 'tablist');
2477
+ this.$tabListItems.forEach($item => {
2478
+ $item.setAttribute('role', 'presentation');
2479
+ });
2480
+ this.$tabs.forEach($tab => {
2481
+ this.setAttributes($tab);
2482
+ $tab.addEventListener('click', this.boundTabClick, true);
2483
+ $tab.addEventListener('keydown', this.boundTabKeydown, true);
2484
+ this.hideTab($tab);
2485
+ });
2486
+ const $activeTab = (_this$getTab = this.getTab(window.location.hash)) != null ? _this$getTab : this.$tabs[0];
2487
+ this.showTab($activeTab);
2488
+ window.addEventListener('hashchange', this.boundOnHashChange, true);
2489
+ }
2490
+ teardown() {
2491
+ this.$tabList.removeAttribute('role');
2492
+ this.$tabListItems.forEach($item => {
2493
+ $item.removeAttribute('role');
2494
+ });
2495
+ this.$tabs.forEach($tab => {
2496
+ $tab.removeEventListener('click', this.boundTabClick, true);
2497
+ $tab.removeEventListener('keydown', this.boundTabKeydown, true);
2498
+ this.unsetAttributes($tab);
2499
+ });
2500
+ window.removeEventListener('hashchange', this.boundOnHashChange, true);
2501
+ }
2502
+ onHashChange() {
2503
+ const hash = window.location.hash;
2504
+ const $tabWithHash = this.getTab(hash);
2505
+ if (!$tabWithHash) {
2506
+ return;
2507
+ }
2508
+ if (this.changingHash) {
2509
+ this.changingHash = false;
2510
+ return;
2511
+ }
2512
+ const $previousTab = this.getCurrentTab();
2513
+ if (!$previousTab) {
2514
+ return;
2515
+ }
2516
+ this.hideTab($previousTab);
2517
+ this.showTab($tabWithHash);
2518
+ $tabWithHash.focus();
2519
+ }
2520
+ hideTab($tab) {
2521
+ this.unhighlightTab($tab);
2522
+ this.hidePanel($tab);
2523
+ }
2524
+ showTab($tab) {
2525
+ this.highlightTab($tab);
2526
+ this.showPanel($tab);
2527
+ }
2528
+ getTab(hash) {
2529
+ return this.$root.querySelector(`a.govuk-tabs__tab[href="${hash}"]`);
2530
+ }
2531
+ setAttributes($tab) {
2532
+ const panelId = getFragmentFromUrl($tab.href);
2533
+ if (!panelId) {
2534
+ return;
2535
+ }
2536
+ $tab.setAttribute('id', `tab_${panelId}`);
2537
+ $tab.setAttribute('role', 'tab');
2538
+ $tab.setAttribute('aria-controls', panelId);
2539
+ $tab.setAttribute('aria-selected', 'false');
2540
+ $tab.setAttribute('tabindex', '-1');
2541
+ const $panel = this.getPanel($tab);
2542
+ if (!$panel) {
2543
+ return;
2544
+ }
2545
+ $panel.setAttribute('role', 'tabpanel');
2546
+ $panel.setAttribute('aria-labelledby', $tab.id);
2547
+ $panel.classList.add(this.jsHiddenClass);
2548
+ }
2549
+ unsetAttributes($tab) {
2550
+ $tab.removeAttribute('id');
2551
+ $tab.removeAttribute('role');
2552
+ $tab.removeAttribute('aria-controls');
2553
+ $tab.removeAttribute('aria-selected');
2554
+ $tab.removeAttribute('tabindex');
2555
+ const $panel = this.getPanel($tab);
2556
+ if (!$panel) {
2557
+ return;
2558
+ }
2559
+ $panel.removeAttribute('role');
2560
+ $panel.removeAttribute('aria-labelledby');
2561
+ $panel.classList.remove(this.jsHiddenClass);
2562
+ }
2563
+ onTabClick(event) {
2564
+ const $currentTab = this.getCurrentTab();
2565
+ const $nextTab = event.currentTarget;
2566
+ if (!$currentTab || !($nextTab instanceof HTMLAnchorElement)) {
2567
+ return;
2568
+ }
2569
+ event.preventDefault();
2570
+ this.hideTab($currentTab);
2571
+ this.showTab($nextTab);
2572
+ this.createHistoryEntry($nextTab);
2573
+ }
2574
+ createHistoryEntry($tab) {
2575
+ const $panel = this.getPanel($tab);
2576
+ if (!$panel) {
2577
+ return;
2578
+ }
2579
+ const panelId = $panel.id;
2580
+ $panel.id = '';
2581
+ this.changingHash = true;
2582
+ window.location.hash = panelId;
2583
+ $panel.id = panelId;
2584
+ }
2585
+ onTabKeydown(event) {
2586
+ switch (event.key) {
2587
+ case 'ArrowLeft':
2588
+ case 'Left':
2589
+ this.activatePreviousTab();
2590
+ event.preventDefault();
2591
+ break;
2592
+ case 'ArrowRight':
2593
+ case 'Right':
2594
+ this.activateNextTab();
2595
+ event.preventDefault();
2596
+ break;
2597
+ }
2598
+ }
2599
+ activateNextTab() {
2600
+ const $currentTab = this.getCurrentTab();
2601
+ if (!($currentTab != null && $currentTab.parentElement)) {
2602
+ return;
2603
+ }
2604
+ const $nextTabListItem = $currentTab.parentElement.nextElementSibling;
2605
+ if (!$nextTabListItem) {
2606
+ return;
2607
+ }
2608
+ const $nextTab = $nextTabListItem.querySelector('a.govuk-tabs__tab');
2609
+ if (!$nextTab) {
2610
+ return;
2611
+ }
2612
+ this.hideTab($currentTab);
2613
+ this.showTab($nextTab);
2614
+ $nextTab.focus();
2615
+ this.createHistoryEntry($nextTab);
2616
+ }
2617
+ activatePreviousTab() {
2618
+ const $currentTab = this.getCurrentTab();
2619
+ if (!($currentTab != null && $currentTab.parentElement)) {
2620
+ return;
2621
+ }
2622
+ const $previousTabListItem = $currentTab.parentElement.previousElementSibling;
2623
+ if (!$previousTabListItem) {
2624
+ return;
2625
+ }
2626
+ const $previousTab = $previousTabListItem.querySelector('a.govuk-tabs__tab');
2627
+ if (!$previousTab) {
2628
+ return;
2629
+ }
2630
+ this.hideTab($currentTab);
2631
+ this.showTab($previousTab);
2632
+ $previousTab.focus();
2633
+ this.createHistoryEntry($previousTab);
2634
+ }
2635
+ getPanel($tab) {
2636
+ const panelId = getFragmentFromUrl($tab.href);
2637
+ if (!panelId) {
2638
+ return null;
2639
+ }
2640
+ return this.$root.querySelector(`#${panelId}`);
2641
+ }
2642
+ showPanel($tab) {
2643
+ const $panel = this.getPanel($tab);
2644
+ if (!$panel) {
2645
+ return;
2646
+ }
2647
+ $panel.classList.remove(this.jsHiddenClass);
2648
+ }
2649
+ hidePanel($tab) {
2650
+ const $panel = this.getPanel($tab);
2651
+ if (!$panel) {
2652
+ return;
2653
+ }
2654
+ $panel.classList.add(this.jsHiddenClass);
2655
+ }
2656
+ unhighlightTab($tab) {
2657
+ if (!$tab.parentElement) {
2658
+ return;
2659
+ }
2660
+ $tab.setAttribute('aria-selected', 'false');
2661
+ $tab.parentElement.classList.remove('govuk-tabs__list-item--selected');
2662
+ $tab.setAttribute('tabindex', '-1');
2663
+ }
2664
+ highlightTab($tab) {
2665
+ if (!$tab.parentElement) {
2666
+ return;
2667
+ }
2668
+ $tab.setAttribute('aria-selected', 'true');
2669
+ $tab.parentElement.classList.add('govuk-tabs__list-item--selected');
2670
+ $tab.setAttribute('tabindex', '0');
2671
+ }
2672
+ getCurrentTab() {
2673
+ return this.$root.querySelector('.govuk-tabs__list-item--selected a.govuk-tabs__tab');
2674
+ }
2675
+ }
2676
+ Tabs.moduleName = 'govuk-tabs';
2677
+
2678
+ /**
2679
+ * Initialise all components
2680
+ *
2681
+ * Use the `data-module` attributes to find, instantiate and init all of the
2682
+ * components provided as part of GOV.UK Frontend.
2683
+ *
2684
+ * @param {Config & { scope?: Element, onError?: OnErrorCallback<CompatibleClass> }} [config] - Config for all components (with optional scope)
2685
+ */
2686
+ function initAll(config) {
2687
+ var _config$scope;
2688
+ config = typeof config !== 'undefined' ? config : {};
2689
+ if (!isSupported()) {
2690
+ if (config.onError) {
2691
+ config.onError(new SupportError(), {
2692
+ config
2693
+ });
2694
+ } else {
2695
+ console.log(new SupportError());
2696
+ }
2697
+ return;
2698
+ }
2699
+ const components = [[Accordion, config.accordion], [Button, config.button], [CharacterCount, config.characterCount], [Checkboxes], [ErrorSummary, config.errorSummary], [ExitThisPage, config.exitThisPage], [FileUpload, config.fileUpload], [Header], [NotificationBanner, config.notificationBanner], [PasswordInput, config.passwordInput], [Radios], [ServiceNavigation], [SkipLink], [Tabs]];
2700
+ const options = {
2701
+ scope: (_config$scope = config.scope) != null ? _config$scope : document,
2702
+ onError: config.onError
2703
+ };
2704
+ components.forEach(([Component, config]) => {
2705
+ createAll(Component, config, options);
2706
+ });
2707
+ }
2708
+
2709
+ /**
2710
+ * Create all instances of a specific component on the page
2711
+ *
2712
+ * Uses the `data-module` attribute to find all elements matching the specified
2713
+ * component on the page, creating instances of the component object for each
2714
+ * of them.
2715
+ *
2716
+ * Any component errors will be caught and logged to the console.
2717
+ *
2718
+ * @template {CompatibleClass} ComponentClass
2719
+ * @param {ComponentClass} Component - class of the component to create
2720
+ * @param {ComponentConfig<ComponentClass>} [config] - Config supplied to component
2721
+ * @param {OnErrorCallback<ComponentClass> | Element | Document | CreateAllOptions<ComponentClass> } [createAllOptions] - options for createAll including scope of the document to search within and callback function if error throw by component on init
2722
+ * @returns {Array<InstanceType<ComponentClass>>} - array of instantiated components
2723
+ */
2724
+ function createAll(Component, config, createAllOptions) {
2725
+ let $scope = document;
2726
+ let onError;
2727
+ if (typeof createAllOptions === 'object') {
2728
+ var _createAllOptions$sco;
2729
+ createAllOptions = createAllOptions;
2730
+ $scope = (_createAllOptions$sco = createAllOptions.scope) != null ? _createAllOptions$sco : $scope;
2731
+ onError = createAllOptions.onError;
2732
+ }
2733
+ if (typeof createAllOptions === 'function') {
2734
+ onError = createAllOptions;
2735
+ }
2736
+ if (createAllOptions instanceof HTMLElement) {
2737
+ $scope = createAllOptions;
2738
+ }
2739
+ const $elements = $scope.querySelectorAll(`[data-module="${Component.moduleName}"]`);
2740
+ if (!isSupported()) {
2741
+ if (onError) {
2742
+ onError(new SupportError(), {
2743
+ component: Component,
2744
+ config
2745
+ });
2746
+ } else {
2747
+ console.log(new SupportError());
2748
+ }
2749
+ return [];
2750
+ }
2751
+ return Array.from($elements).map($element => {
2752
+ try {
2753
+ return typeof config !== 'undefined' ? new Component($element, config) : new Component($element);
2754
+ } catch (error) {
2755
+ if (onError) {
2756
+ onError(error, {
2757
+ element: $element,
2758
+ component: Component,
2759
+ config
2760
+ });
2761
+ } else {
2762
+ console.log(error);
2763
+ }
2764
+ return null;
2765
+ }
2766
+ }).filter(Boolean);
2767
+ }
2768
+ /**
2769
+ * @typedef {{new (...args: any[]): any, moduleName: string}} CompatibleClass
2770
+ */
2771
+ /**
2772
+ * Config for all components via `initAll()`
2773
+ *
2774
+ * @typedef {object} Config
2775
+ * @property {AccordionConfig} [accordion] - Accordion config
2776
+ * @property {ButtonConfig} [button] - Button config
2777
+ * @property {CharacterCountConfig} [characterCount] - Character Count config
2778
+ * @property {ErrorSummaryConfig} [errorSummary] - Error Summary config
2779
+ * @property {ExitThisPageConfig} [exitThisPage] - Exit This Page config
2780
+ * @property {FileUploadConfig} [fileUpload] - File Upload config
2781
+ * @property {NotificationBannerConfig} [notificationBanner] - Notification Banner config
2782
+ * @property {PasswordInputConfig} [passwordInput] - Password input config
2783
+ */
2784
+ /**
2785
+ * Config for individual components
2786
+ *
2787
+ * @import { AccordionConfig } from './components/accordion/accordion.mjs'
2788
+ * @import { ButtonConfig } from './components/button/button.mjs'
2789
+ * @import { CharacterCountConfig } from './components/character-count/character-count.mjs'
2790
+ * @import { ErrorSummaryConfig } from './components/error-summary/error-summary.mjs'
2791
+ * @import { ExitThisPageConfig } from './components/exit-this-page/exit-this-page.mjs'
2792
+ * @import { NotificationBannerConfig } from './components/notification-banner/notification-banner.mjs'
2793
+ * @import { PasswordInputConfig } from './components/password-input/password-input.mjs'
2794
+ * @import { FileUploadConfig } from './components/file-upload/file-upload.mjs'
2795
+ */
2796
+ /**
2797
+ * Component config keys, e.g. `accordion` and `characterCount`
2798
+ *
2799
+ * @typedef {keyof Config} ConfigKey
2800
+ */
2801
+ /**
2802
+ * @template {CompatibleClass} ComponentClass
2803
+ * @typedef {ConstructorParameters<ComponentClass>[1]} ComponentConfig
2804
+ */
2805
+ /**
2806
+ * @template {CompatibleClass} ComponentClass
2807
+ * @typedef {object} ErrorContext
2808
+ * @property {Element} [element] - Element used for component module initialisation
2809
+ * @property {ComponentClass} [component] - Class of component
2810
+ * @property {ComponentConfig<ComponentClass>} config - Config supplied to component
2811
+ */
2812
+ /**
2813
+ * @template {CompatibleClass} ComponentClass
2814
+ * @callback OnErrorCallback
2815
+ * @param {unknown} error - Thrown error
2816
+ * @param {ErrorContext<ComponentClass>} context - Object containing the element, component class and configuration
2817
+ */
2818
+ /**
2819
+ * @template {CompatibleClass} ComponentClass
2820
+ * @typedef {object} CreateAllOptions
2821
+ * @property {Element | Document} [scope] - scope of the document to search within
2822
+ * @property {OnErrorCallback<ComponentClass>} [onError] - callback function if error throw by component on init
2823
+ */
2824
+
2825
+ exports.Accordion = Accordion;
2826
+ exports.Button = Button;
2827
+ exports.CharacterCount = CharacterCount;
2828
+ exports.Checkboxes = Checkboxes;
2829
+ exports.Component = Component;
2830
+ exports.ConfigurableComponent = ConfigurableComponent;
2831
+ exports.ErrorSummary = ErrorSummary;
2832
+ exports.ExitThisPage = ExitThisPage;
2833
+ exports.FileUpload = FileUpload;
2834
+ exports.Header = Header;
2835
+ exports.NotificationBanner = NotificationBanner;
2836
+ exports.PasswordInput = PasswordInput;
2837
+ exports.Radios = Radios;
2838
+ exports.ServiceNavigation = ServiceNavigation;
2839
+ exports.SkipLink = SkipLink;
2840
+ exports.Tabs = Tabs;
2841
+ exports.createAll = createAll;
2842
+ exports.initAll = initAll;
2843
+ exports.isSupported = isSupported;
2844
+ exports.version = version;
2845
+
2846
+ }));
2847
+ //# sourceMappingURL=all.bundle.js.map