defra_ruby_template 5.4.1 → 5.11.0

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 (427) hide show
  1. checksums.yaml +4 -4
  2. data/app/views/layouts/defra_ruby_template.html.erb +39 -18
  3. data/lib/defra_ruby_template/version.rb +1 -1
  4. data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +882 -492
  5. data/node_modules/govuk-frontend/dist/govuk/all.bundle.js.map +1 -1
  6. data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +877 -492
  7. data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs.map +1 -1
  8. data/node_modules/govuk-frontend/dist/govuk/all.mjs +5 -0
  9. data/node_modules/govuk-frontend/dist/govuk/all.mjs.map +1 -1
  10. data/node_modules/govuk-frontend/dist/govuk/all.scss +6 -0
  11. data/node_modules/govuk-frontend/dist/govuk/all.scss.map +1 -1
  12. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest.svg +1 -0
  13. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/favicon.ico +0 -0
  14. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/favicon.svg +1 -0
  15. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-crest.svg +1 -0
  16. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-180.png +0 -0
  17. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-192.png +0 -0
  18. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-512.png +0 -0
  19. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-icon-mask.svg +1 -0
  20. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/images/govuk-opengraph-image.png +0 -0
  21. data/node_modules/govuk-frontend/dist/govuk/assets/rebrand/manifest.json +39 -0
  22. data/node_modules/govuk-frontend/dist/govuk/common/closest-attribute-value.mjs.map +1 -1
  23. data/node_modules/govuk-frontend/dist/govuk/common/configuration.mjs +169 -0
  24. data/node_modules/govuk-frontend/dist/govuk/common/configuration.mjs.map +1 -0
  25. data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +1 -1
  26. data/node_modules/govuk-frontend/dist/govuk/common/index.mjs +20 -83
  27. data/node_modules/govuk-frontend/dist/govuk/common/index.mjs.map +1 -1
  28. data/node_modules/govuk-frontend/dist/govuk/component.mjs +60 -0
  29. data/node_modules/govuk-frontend/dist/govuk/component.mjs.map +1 -0
  30. data/node_modules/govuk-frontend/dist/govuk/components/_index.scss +1 -0
  31. data/node_modules/govuk-frontend/dist/govuk/components/_index.scss.map +1 -1
  32. data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss +35 -31
  33. data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss.map +1 -1
  34. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +296 -195
  35. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js.map +1 -1
  36. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +295 -194
  37. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs.map +1 -1
  38. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs +88 -110
  39. data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs.map +1 -1
  40. data/node_modules/govuk-frontend/dist/govuk/components/accordion/fixtures.json +16 -3
  41. data/node_modules/govuk-frontend/dist/govuk/components/back-link/fixtures.json +25 -15
  42. data/node_modules/govuk-frontend/dist/govuk/components/back-link/template-with-custom-link.html +1 -0
  43. data/node_modules/govuk-frontend/dist/govuk/components/back-link/template.njk +2 -2
  44. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/fixtures.json +53 -15
  45. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/macro-options.json +6 -0
  46. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-default.html +2 -2
  47. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-inverse.html +2 -2
  48. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-collapse-on-mobile.html +2 -2
  49. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-last-breadcrumb-as-current-page.html +2 -2
  50. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-multiple-levels.html +2 -2
  51. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-one-level.html +2 -2
  52. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-without-the-home-section.html +2 -2
  53. data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template.njk +2 -2
  54. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js +217 -106
  55. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js.map +1 -1
  56. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs +216 -105
  57. data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs.map +1 -1
  58. data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs +9 -22
  59. data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs.map +1 -1
  60. data/node_modules/govuk-frontend/dist/govuk/components/button/fixtures.json +38 -0
  61. data/node_modules/govuk-frontend/dist/govuk/components/button/macro-options.json +2 -1
  62. data/node_modules/govuk-frontend/dist/govuk/components/character-count/_index.scss +12 -4
  63. data/node_modules/govuk-frontend/dist/govuk/components/character-count/_index.scss.map +1 -1
  64. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +256 -145
  65. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js.map +1 -1
  66. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +255 -144
  67. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs.map +1 -1
  68. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +29 -34
  69. data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs.map +1 -1
  70. data/node_modules/govuk-frontend/dist/govuk/components/character-count/fixtures.json +80 -1
  71. data/node_modules/govuk-frontend/dist/govuk/components/character-count/macro-options.json +6 -6
  72. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-error.html +12 -0
  73. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-hint-and-error.html +15 -0
  74. data/node_modules/govuk-frontend/dist/govuk/components/character-count/template.njk +5 -4
  75. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_index.scss +6 -1
  76. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_index.scss.map +1 -1
  77. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js +96 -50
  78. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js.map +1 -1
  79. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs +95 -49
  80. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs.map +1 -1
  81. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs +9 -18
  82. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs.map +1 -1
  83. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/fixtures.json +88 -1
  84. data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/template-small-with-divider-and-none.html +34 -0
  85. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_index.scss +23 -14
  86. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_index.scss.map +1 -1
  87. data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/fixtures.json +23 -0
  88. data/node_modules/govuk-frontend/dist/govuk/components/date-input/_index.scss +2 -2
  89. data/node_modules/govuk-frontend/dist/govuk/components/date-input/_index.scss.map +1 -1
  90. data/node_modules/govuk-frontend/dist/govuk/components/date-input/fixtures.json +27 -0
  91. data/node_modules/govuk-frontend/dist/govuk/components/date-input/macro-options.json +2 -2
  92. data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss +7 -2
  93. data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss.map +1 -1
  94. data/node_modules/govuk-frontend/dist/govuk/components/details/fixtures.json +10 -0
  95. data/node_modules/govuk-frontend/dist/govuk/components/error-message/fixtures.json +9 -0
  96. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_index.scss +4 -0
  97. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_index.scss.map +1 -1
  98. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js +238 -127
  99. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js.map +1 -1
  100. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs +237 -126
  101. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs.map +1 -1
  102. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs +10 -22
  103. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs.map +1 -1
  104. data/node_modules/govuk-frontend/dist/govuk/components/error-summary/fixtures.json +19 -0
  105. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +218 -107
  106. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js.map +1 -1
  107. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +217 -106
  108. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs.map +1 -1
  109. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs +10 -22
  110. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs.map +1 -1
  111. data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/fixtures.json +4 -0
  112. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/_index.scss +3 -5
  113. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/_index.scss.map +1 -1
  114. data/node_modules/govuk-frontend/dist/govuk/components/fieldset/fixtures.json +18 -0
  115. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss +175 -9
  116. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss.map +1 -1
  117. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js +744 -0
  118. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.js.map +1 -0
  119. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs +736 -0
  120. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.bundle.mjs.map +1 -0
  121. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs +257 -0
  122. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/file-upload.mjs.map +1 -0
  123. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/fixtures.json +220 -16
  124. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/macro-options.json +52 -3
  125. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-allows-direct-media-capture.html +6 -0
  126. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-allows-image-files-only.html +6 -0
  127. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-allows-multiple-files.html +6 -0
  128. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-disabled.html +6 -0
  129. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-enhanced-disabled.html +13 -0
  130. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-enhanced-with-error-message-and-hint.html +16 -0
  131. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-enhanced.html +10 -0
  132. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-translated.html +10 -0
  133. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template.njk +42 -5
  134. data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss +61 -19
  135. data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss.map +1 -1
  136. data/node_modules/govuk-frontend/dist/govuk/components/footer/fixtures.json +34 -0
  137. data/node_modules/govuk-frontend/dist/govuk/components/footer/macro-options.json +6 -0
  138. data/node_modules/govuk-frontend/dist/govuk/components/footer/template.njk +10 -0
  139. data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss +223 -21
  140. data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss.map +1 -1
  141. data/node_modules/govuk-frontend/dist/govuk/components/header/fixtures.json +78 -32
  142. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js +90 -43
  143. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js.map +1 -1
  144. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs +89 -42
  145. data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs.map +1 -1
  146. data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs +10 -18
  147. data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs.map +1 -1
  148. data/node_modules/govuk-frontend/dist/govuk/components/header/macro-options.json +31 -12
  149. data/node_modules/govuk-frontend/dist/govuk/components/header/template-default.html +20 -12
  150. data/node_modules/govuk-frontend/dist/govuk/components/header/template-full-width-with-navigation.html +21 -15
  151. data/node_modules/govuk-frontend/dist/govuk/components/header/template-full-width.html +21 -15
  152. data/node_modules/govuk-frontend/dist/govuk/components/header/template-navigation-item-with-html.html +20 -12
  153. data/node_modules/govuk-frontend/dist/govuk/components/header/template-navigation-item-with-text-without-link.html +20 -12
  154. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-custom-menu-button-label.html +20 -12
  155. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-custom-menu-button-text.html +20 -12
  156. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-custom-navigation-label.html +20 -12
  157. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-full-width-border.html +30 -0
  158. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-large-navigation.html +20 -12
  159. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-navigation.html +20 -12
  160. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-product-name.html +21 -15
  161. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-service-name-and-navigation.html +20 -12
  162. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-service-name-but-no-service-url.html +20 -12
  163. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-service-name.html +20 -12
  164. data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-st-edwards-crown.html +10 -12
  165. data/node_modules/govuk-frontend/dist/govuk/components/header/template.njk +11 -41
  166. data/node_modules/govuk-frontend/dist/govuk/components/hint/fixtures.json +6 -0
  167. data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss +7 -4
  168. data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss.map +1 -1
  169. data/node_modules/govuk-frontend/dist/govuk/components/input/fixtures.json +97 -27
  170. data/node_modules/govuk-frontend/dist/govuk/components/input/macro-options.json +6 -6
  171. data/node_modules/govuk-frontend/dist/govuk/components/input/template-default.html +2 -2
  172. data/node_modules/govuk-frontend/dist/govuk/components/input/template-disabled.html +6 -0
  173. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-error-and-hint.html +12 -0
  174. data/node_modules/govuk-frontend/dist/govuk/components/input/template-with-error-message.html +2 -5
  175. data/node_modules/govuk-frontend/dist/govuk/components/input/template.njk +5 -4
  176. data/node_modules/govuk-frontend/dist/govuk/components/inset-text/fixtures.json +6 -0
  177. data/node_modules/govuk-frontend/dist/govuk/components/label/fixtures.json +17 -0
  178. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss +3 -2
  179. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss.map +1 -1
  180. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/fixtures.json +24 -0
  181. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js +238 -127
  182. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js.map +1 -1
  183. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs +237 -126
  184. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs.map +1 -1
  185. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs +10 -22
  186. data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs.map +1 -1
  187. data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss +24 -37
  188. data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss.map +1 -1
  189. data/node_modules/govuk-frontend/dist/govuk/components/pagination/fixtures.json +15 -0
  190. data/node_modules/govuk-frontend/dist/govuk/components/pagination/macro-options.json +4 -4
  191. data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss +13 -9
  192. data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss.map +1 -1
  193. data/node_modules/govuk-frontend/dist/govuk/components/panel/fixtures.json +9 -0
  194. data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss +12 -9
  195. data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss.map +1 -1
  196. data/node_modules/govuk-frontend/dist/govuk/components/password-input/fixtures.json +27 -2
  197. data/node_modules/govuk-frontend/dist/govuk/components/password-input/macro-options.json +3 -3
  198. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +220 -110
  199. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js.map +1 -1
  200. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +219 -109
  201. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs.map +1 -1
  202. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs +12 -25
  203. data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs.map +1 -1
  204. data/node_modules/govuk-frontend/dist/govuk/components/password-input/template-default.html +3 -3
  205. data/node_modules/govuk-frontend/dist/govuk/components/password-input/template.njk +4 -2
  206. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss +0 -8
  207. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss.map +1 -1
  208. data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/fixtures.json +7 -0
  209. data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss +7 -5
  210. data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss.map +1 -1
  211. data/node_modules/govuk-frontend/dist/govuk/components/radios/fixtures.json +51 -5
  212. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js +96 -50
  213. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js.map +1 -1
  214. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs +95 -49
  215. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs.map +1 -1
  216. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs +9 -18
  217. data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs.map +1 -1
  218. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-a-divider.html +1 -1
  219. data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-a-divider.html +1 -1
  220. data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss +5 -5
  221. data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss.map +1 -1
  222. data/node_modules/govuk-frontend/dist/govuk/components/select/fixtures.json +43 -9
  223. data/node_modules/govuk-frontend/dist/govuk/components/select/macro-options.json +2 -2
  224. data/node_modules/govuk-frontend/dist/govuk/components/select/template-id.html +7 -0
  225. data/node_modules/govuk-frontend/dist/govuk/components/select/template.njk +6 -4
  226. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/README.md +15 -0
  227. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss +187 -0
  228. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss.map +1 -0
  229. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_service-navigation.scss +4 -0
  230. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_service-navigation.scss.map +1 -0
  231. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/fixtures.json +515 -0
  232. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/macro-options.json +138 -0
  233. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/macro.njk +3 -0
  234. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +229 -0
  235. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js.map +1 -0
  236. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs +221 -0
  237. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs.map +1 -0
  238. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs +85 -0
  239. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs.map +1 -0
  240. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-default.html +57 -0
  241. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-html-navigation-items.html +49 -0
  242. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-large-navigation.html +153 -0
  243. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-long-service-name.html +20 -0
  244. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-navigation-with-a-current-item.html +58 -0
  245. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-navigation-with-an-active-item.html +58 -0
  246. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-non-link-navigation-items.html +49 -0
  247. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-link.html +20 -0
  248. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-name-and-navigation.html +63 -0
  249. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-name.html +18 -0
  250. data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template.njk +103 -0
  251. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_index.scss +6 -4
  252. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_index.scss.map +1 -1
  253. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/fixtures.json +9 -0
  254. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js +95 -48
  255. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js.map +1 -1
  256. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs +94 -47
  257. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs.map +1 -1
  258. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs +15 -23
  259. data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs.map +1 -1
  260. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss +14 -22
  261. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss.map +1 -1
  262. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/fixtures.json +174 -1
  263. data/node_modules/govuk-frontend/dist/govuk/components/summary-list/template-as-a-summary-card-extreme.html +106 -0
  264. data/node_modules/govuk-frontend/dist/govuk/components/table/fixtures.json +22 -1
  265. data/node_modules/govuk-frontend/dist/govuk/components/tabs/fixtures.json +15 -1
  266. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js +95 -53
  267. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js.map +1 -1
  268. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs +94 -52
  269. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs.map +1 -1
  270. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs +15 -28
  271. data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs.map +1 -1
  272. data/node_modules/govuk-frontend/dist/govuk/components/tag/_index.scss +11 -8
  273. data/node_modules/govuk-frontend/dist/govuk/components/tag/_index.scss.map +1 -1
  274. data/node_modules/govuk-frontend/dist/govuk/components/tag/fixtures.json +14 -0
  275. data/node_modules/govuk-frontend/dist/govuk/components/task-list/_index.scss +12 -10
  276. data/node_modules/govuk-frontend/dist/govuk/components/task-list/_index.scss.map +1 -1
  277. data/node_modules/govuk-frontend/dist/govuk/components/task-list/fixtures.json +44 -0
  278. data/node_modules/govuk-frontend/dist/govuk/components/task-list/template-with-empty-values.html +27 -0
  279. data/node_modules/govuk-frontend/dist/govuk/components/task-list/template.njk +1 -1
  280. data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss +3 -3
  281. data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss.map +1 -1
  282. data/node_modules/govuk-frontend/dist/govuk/components/textarea/fixtures.json +32 -1
  283. data/node_modules/govuk-frontend/dist/govuk/components/textarea/macro-options.json +3 -3
  284. data/node_modules/govuk-frontend/dist/govuk/components/textarea/template.njk +6 -4
  285. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss +6 -5
  286. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss.map +1 -1
  287. data/node_modules/govuk-frontend/dist/govuk/components/warning-text/fixtures.json +8 -0
  288. data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +1 -1
  289. data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss.map +1 -1
  290. data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs +16 -3
  291. data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs.map +1 -1
  292. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css +2 -2
  293. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css.map +1 -1
  294. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
  295. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js.map +1 -1
  296. data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss +55 -8
  297. data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss.map +1 -1
  298. data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss +14 -4
  299. data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss.map +1 -1
  300. data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss +1 -1
  301. data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss.map +1 -1
  302. data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss +2 -2
  303. data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss.map +1 -1
  304. data/node_modules/govuk-frontend/dist/govuk/helpers/_shape-arrow.scss +1 -1
  305. data/node_modules/govuk-frontend/dist/govuk/helpers/_shape-arrow.scss.map +1 -1
  306. data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss +18 -1
  307. data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss.map +1 -1
  308. data/node_modules/govuk-frontend/dist/govuk/helpers/_visually-hidden.scss +30 -62
  309. data/node_modules/govuk-frontend/dist/govuk/helpers/_visually-hidden.scss.map +1 -1
  310. data/node_modules/govuk-frontend/dist/govuk/i18n.mjs.map +1 -1
  311. data/node_modules/govuk-frontend/dist/govuk/init.mjs +90 -24
  312. data/node_modules/govuk-frontend/dist/govuk/init.mjs.map +1 -1
  313. data/node_modules/govuk-frontend/dist/govuk/macros/logo.njk +78 -0
  314. data/node_modules/govuk-frontend/dist/govuk/objects/_template.scss +5 -1
  315. data/node_modules/govuk-frontend/dist/govuk/objects/_template.scss.map +1 -1
  316. data/node_modules/govuk-frontend/dist/govuk/overrides/_typography.scss +5 -1
  317. data/node_modules/govuk-frontend/dist/govuk/overrides/_typography.scss.map +1 -1
  318. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-applied.scss +39 -1
  319. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-applied.scss.map +1 -1
  320. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +244 -10
  321. data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss.map +1 -1
  322. data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss +5 -10
  323. data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss.map +1 -1
  324. data/node_modules/govuk-frontend/dist/govuk/template.njk +20 -9
  325. data/node_modules/govuk-frontend/dist/govuk/tools/_index.scss +1 -0
  326. data/node_modules/govuk-frontend/dist/govuk/tools/_index.scss.map +1 -1
  327. data/node_modules/govuk-frontend/dist/govuk/tools/_rebrand.scss +65 -0
  328. data/node_modules/govuk-frontend/dist/govuk/tools/_rebrand.scss.map +1 -0
  329. data/node_modules/govuk-frontend/dist/govuk-prototype-kit/functions.js +25 -0
  330. data/node_modules/govuk-frontend/dist/govuk-prototype-kit/init.scss +1 -1
  331. data/node_modules/govuk-frontend/dist/govuk-prototype-kit/init.scss.map +1 -1
  332. data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +8 -1
  333. data/node_modules/govuk-frontend/package.json +16 -16
  334. data/spec/spec_helper.rb +98 -0
  335. data/spec/tasks/assets_spec.rb +53 -0
  336. data/vendor/assets/assets/fonts/bold-affa96571d-v2.woff +0 -0
  337. data/vendor/assets/assets/fonts/bold-b542beb274-v2.woff2 +0 -0
  338. data/vendor/assets/assets/fonts/light-94a07e06a1-v2.woff2 +0 -0
  339. data/vendor/assets/assets/fonts/light-f591b13f7d-v2.woff +0 -0
  340. data/vendor/assets/assets/images/favicon.ico +0 -0
  341. data/vendor/assets/assets/images/favicon.svg +1 -0
  342. data/vendor/assets/assets/images/govuk-crest.svg +1 -0
  343. data/vendor/assets/assets/images/govuk-icon-180.png +0 -0
  344. data/vendor/assets/assets/images/govuk-icon-192.png +0 -0
  345. data/vendor/assets/assets/images/govuk-icon-512.png +0 -0
  346. data/vendor/assets/assets/images/govuk-icon-mask.svg +1 -0
  347. data/vendor/assets/assets/images/govuk-opengraph-image.png +0 -0
  348. data/vendor/assets/assets/manifest.json +39 -0
  349. data/vendor/assets/assets/rebrand/images/favicon.ico +0 -0
  350. data/vendor/assets/assets/rebrand/images/favicon.svg +1 -0
  351. data/vendor/assets/assets/rebrand/images/govuk-crest.svg +1 -0
  352. data/vendor/assets/assets/rebrand/images/govuk-icon-180.png +0 -0
  353. data/vendor/assets/assets/rebrand/images/govuk-icon-192.png +0 -0
  354. data/vendor/assets/assets/rebrand/images/govuk-icon-512.png +0 -0
  355. data/vendor/assets/assets/rebrand/images/govuk-icon-mask.svg +1 -0
  356. data/vendor/assets/assets/rebrand/images/govuk-opengraph-image.png +0 -0
  357. data/vendor/assets/assets/rebrand/manifest.json +39 -0
  358. data/vendor/assets/images/govuk-crest.svg +1 -0
  359. data/vendor/assets/javascripts/defra_ruby_template.js +882 -492
  360. data/vendor/assets/stylesheets/all.scss +6 -0
  361. data/vendor/assets/stylesheets/components/_index.scss +1 -0
  362. data/vendor/assets/stylesheets/components/accordion/_index.scss +35 -31
  363. data/vendor/assets/stylesheets/components/character-count/_index.scss +12 -4
  364. data/vendor/assets/stylesheets/components/checkboxes/_index.scss +6 -1
  365. data/vendor/assets/stylesheets/components/cookie-banner/_index.scss +23 -14
  366. data/vendor/assets/stylesheets/components/date-input/_index.scss +2 -2
  367. data/vendor/assets/stylesheets/components/details/_index.scss +7 -2
  368. data/vendor/assets/stylesheets/components/error-summary/_index.scss +4 -0
  369. data/vendor/assets/stylesheets/components/fieldset/_index.scss +3 -5
  370. data/vendor/assets/stylesheets/components/file-upload/_index.scss +175 -9
  371. data/vendor/assets/stylesheets/components/footer/_index.scss +61 -19
  372. data/vendor/assets/stylesheets/components/header/_index.scss +223 -21
  373. data/vendor/assets/stylesheets/components/input/_index.scss +7 -4
  374. data/vendor/assets/stylesheets/components/notification-banner/_index.scss +3 -2
  375. data/vendor/assets/stylesheets/components/pagination/_index.scss +24 -37
  376. data/vendor/assets/stylesheets/components/panel/_index.scss +13 -9
  377. data/vendor/assets/stylesheets/components/password-input/_index.scss +12 -9
  378. data/vendor/assets/stylesheets/components/phase-banner/_index.scss +0 -8
  379. data/vendor/assets/stylesheets/components/radios/_index.scss +7 -5
  380. data/vendor/assets/stylesheets/components/select/_index.scss +5 -5
  381. data/vendor/assets/stylesheets/components/service-navigation/_index.scss +187 -0
  382. data/vendor/assets/stylesheets/components/service-navigation/_service-navigation.scss +4 -0
  383. data/vendor/assets/stylesheets/components/skip-link/_index.scss +6 -4
  384. data/vendor/assets/stylesheets/components/summary-list/_index.scss +14 -22
  385. data/vendor/assets/stylesheets/components/tag/_index.scss +11 -8
  386. data/vendor/assets/stylesheets/components/task-list/_index.scss +12 -10
  387. data/vendor/assets/stylesheets/components/textarea/_index.scss +3 -3
  388. data/vendor/assets/stylesheets/components/warning-text/_index.scss +6 -5
  389. data/vendor/assets/stylesheets/core/_govuk-frontend-properties.scss +1 -1
  390. data/vendor/assets/stylesheets/defra_ruby_template.scss +6 -0
  391. data/vendor/assets/stylesheets/govuk-frontend.min.css +2 -2
  392. data/vendor/assets/stylesheets/helpers/_colour.scss +55 -8
  393. data/vendor/assets/stylesheets/helpers/_focused.scss +14 -4
  394. data/vendor/assets/stylesheets/helpers/_grid.scss +1 -1
  395. data/vendor/assets/stylesheets/helpers/_links.scss +2 -2
  396. data/vendor/assets/stylesheets/helpers/_shape-arrow.scss +1 -1
  397. data/vendor/assets/stylesheets/helpers/_typography.scss +18 -1
  398. data/vendor/assets/stylesheets/helpers/_visually-hidden.scss +30 -62
  399. data/vendor/assets/stylesheets/objects/_template.scss +5 -1
  400. data/vendor/assets/stylesheets/overrides/_typography.scss +5 -1
  401. data/vendor/assets/stylesheets/settings/_colours-applied.scss +39 -1
  402. data/vendor/assets/stylesheets/settings/_colours-organisations.scss +244 -10
  403. data/vendor/assets/stylesheets/settings/_typography-responsive.scss +5 -10
  404. data/vendor/assets/stylesheets/tools/_index.scss +1 -0
  405. data/vendor/assets/stylesheets/tools/_rebrand.scss +65 -0
  406. metadata +100 -24
  407. data/.github/dependabot.yml +0 -14
  408. data/.github/workflows/ci.yml +0 -31
  409. data/.gitignore +0 -8
  410. data/.rspec +0 -1
  411. data/.rubocop.yml +0 -3
  412. data/.ruby-version +0 -1
  413. data/Gemfile +0 -9
  414. data/Gemfile.lock +0 -58
  415. data/defra_ruby_template.gemspec +0 -35
  416. data/node_modules/.package-lock.json +0 -16
  417. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest-2x.png +0 -0
  418. data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest.png +0 -0
  419. data/node_modules/govuk-frontend/dist/govuk/common/normalise-dataset.mjs +0 -18
  420. data/node_modules/govuk-frontend/dist/govuk/common/normalise-dataset.mjs.map +0 -1
  421. data/node_modules/govuk-frontend/dist/govuk/common/normalise-string.mjs +0 -31
  422. data/node_modules/govuk-frontend/dist/govuk/common/normalise-string.mjs.map +0 -1
  423. data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-with-value.html +0 -6
  424. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend-component.mjs +0 -16
  425. data/node_modules/govuk-frontend/dist/govuk/govuk-frontend-component.mjs.map +0 -1
  426. data/package-lock.json +0 -24
  427. data/package.json +0 -29
@@ -1,9 +1,179 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
3
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.GOVUKFrontend = {}));
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.GOVUKFrontend = global.GOVUKFrontend || {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
+ function isInitialised($root, moduleName) {
8
+ return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
9
+ }
10
+
11
+ /**
12
+ * Checks if GOV.UK Frontend is supported on this page
13
+ *
14
+ * Some browsers will load and run our JavaScript but GOV.UK Frontend
15
+ * won't be supported.
16
+ *
17
+ * @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support
18
+ * @returns {boolean} Whether GOV.UK Frontend is supported on this page
19
+ */
20
+ function isSupported($scope = document.body) {
21
+ if (!$scope) {
22
+ return false;
23
+ }
24
+ return $scope.classList.contains('govuk-frontend-supported');
25
+ }
26
+ function isArray(option) {
27
+ return Array.isArray(option);
28
+ }
29
+ function isObject(option) {
30
+ return !!option && typeof option === 'object' && !isArray(option);
31
+ }
32
+ function formatErrorMessage(Component, message) {
33
+ return `${Component.moduleName}: ${message}`;
34
+ }
35
+ /**
36
+ * @typedef ComponentWithModuleName
37
+ * @property {string} moduleName - Name of the component
38
+ */
39
+ /**
40
+ * @import { ObjectNested } from './configuration.mjs'
41
+ */
42
+
43
+ class GOVUKFrontendError extends Error {
44
+ constructor(...args) {
45
+ super(...args);
46
+ this.name = 'GOVUKFrontendError';
47
+ }
48
+ }
49
+ class SupportError extends GOVUKFrontendError {
50
+ /**
51
+ * Checks if GOV.UK Frontend is supported on this page
52
+ *
53
+ * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support
54
+ */
55
+ constructor($scope = document.body) {
56
+ 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';
57
+ super($scope ? supportMessage : 'GOV.UK Frontend initialised without `<script type="module">`');
58
+ this.name = 'SupportError';
59
+ }
60
+ }
61
+ class ConfigError extends GOVUKFrontendError {
62
+ constructor(...args) {
63
+ super(...args);
64
+ this.name = 'ConfigError';
65
+ }
66
+ }
67
+ class ElementError extends GOVUKFrontendError {
68
+ constructor(messageOrOptions) {
69
+ let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
70
+ if (typeof messageOrOptions === 'object') {
71
+ const {
72
+ component,
73
+ identifier,
74
+ element,
75
+ expectedType
76
+ } = messageOrOptions;
77
+ message = identifier;
78
+ message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
79
+ message = formatErrorMessage(component, message);
80
+ }
81
+ super(message);
82
+ this.name = 'ElementError';
83
+ }
84
+ }
85
+ class InitError extends GOVUKFrontendError {
86
+ constructor(componentOrMessage) {
87
+ const message = typeof componentOrMessage === 'string' ? componentOrMessage : formatErrorMessage(componentOrMessage, `Root element (\`$root\`) already initialised`);
88
+ super(message);
89
+ this.name = 'InitError';
90
+ }
91
+ }
92
+ /**
93
+ * @import { ComponentWithModuleName } from '../common/index.mjs'
94
+ */
95
+
96
+ class Component {
97
+ /**
98
+ * Returns the root element of the component
99
+ *
100
+ * @protected
101
+ * @returns {RootElementType} - the root element of component
102
+ */
103
+ get $root() {
104
+ return this._$root;
105
+ }
106
+ constructor($root) {
107
+ this._$root = void 0;
108
+ const childConstructor = this.constructor;
109
+ if (typeof childConstructor.moduleName !== 'string') {
110
+ throw new InitError(`\`moduleName\` not defined in component`);
111
+ }
112
+ if (!($root instanceof childConstructor.elementType)) {
113
+ throw new ElementError({
114
+ element: $root,
115
+ component: childConstructor,
116
+ identifier: 'Root element (`$root`)',
117
+ expectedType: childConstructor.elementType.name
118
+ });
119
+ } else {
120
+ this._$root = $root;
121
+ }
122
+ childConstructor.checkSupport();
123
+ this.checkInitialised();
124
+ const moduleName = childConstructor.moduleName;
125
+ this.$root.setAttribute(`data-${moduleName}-init`, '');
126
+ }
127
+ checkInitialised() {
128
+ const constructor = this.constructor;
129
+ const moduleName = constructor.moduleName;
130
+ if (moduleName && isInitialised(this.$root, moduleName)) {
131
+ throw new InitError(constructor);
132
+ }
133
+ }
134
+ static checkSupport() {
135
+ if (!isSupported()) {
136
+ throw new SupportError();
137
+ }
138
+ }
139
+ }
140
+
141
+ /**
142
+ * @typedef ChildClass
143
+ * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
144
+ */
145
+
146
+ /**
147
+ * @typedef {typeof Component & ChildClass} ChildClassConstructor
148
+ */
149
+ Component.elementType = HTMLElement;
150
+
151
+ const configOverride = Symbol.for('configOverride');
152
+ class ConfigurableComponent extends Component {
153
+ [configOverride](param) {
154
+ return {};
155
+ }
156
+
157
+ /**
158
+ * Returns the root element of the component
159
+ *
160
+ * @protected
161
+ * @returns {ConfigurationType} - the root element of component
162
+ */
163
+ get config() {
164
+ return this._config;
165
+ }
166
+ constructor($root, config) {
167
+ super($root);
168
+ this._config = void 0;
169
+ const childConstructor = this.constructor;
170
+ if (!isObject(childConstructor.defaults)) {
171
+ throw new ConfigError(formatErrorMessage(childConstructor, 'Config passed as parameter into constructor but no defaults defined'));
172
+ }
173
+ const datasetConfig = normaliseDataset(childConstructor, this._$root.dataset);
174
+ this._config = mergeConfigs(childConstructor.defaults, config != null ? config : {}, this[configOverride](datasetConfig), datasetConfig);
175
+ }
176
+ }
7
177
  function normaliseString(value, property) {
8
178
  const trimmedValue = value ? value.trim() : '';
9
179
  let output;
@@ -28,11 +198,24 @@
28
198
  }
29
199
  return output;
30
200
  }
31
-
32
- /**
33
- * @typedef {import('./index.mjs').SchemaProperty} SchemaProperty
34
- */
35
-
201
+ function normaliseDataset(Component, dataset) {
202
+ if (!isObject(Component.schema)) {
203
+ throw new ConfigError(formatErrorMessage(Component, 'Config passed as parameter into constructor but no schema defined'));
204
+ }
205
+ const out = {};
206
+ const entries = Object.entries(Component.schema.properties);
207
+ for (const entry of entries) {
208
+ const [namespace, property] = entry;
209
+ const field = namespace.toString();
210
+ if (field in dataset) {
211
+ out[field] = normaliseString(dataset[field], property);
212
+ }
213
+ if ((property == null ? void 0 : property.type) === 'object') {
214
+ out[field] = extractConfigByNamespace(Component.schema, dataset, namespace);
215
+ }
216
+ }
217
+ return out;
218
+ }
36
219
  function mergeConfigs(...configObjects) {
37
220
  const formattedConfigObject = {};
38
221
  for (const configObject of configObjects) {
@@ -48,19 +231,19 @@
48
231
  }
49
232
  return formattedConfigObject;
50
233
  }
51
- function extractConfigByNamespace(Component, dataset, namespace) {
52
- const property = Component.schema.properties[namespace];
234
+ function extractConfigByNamespace(schema, dataset, namespace) {
235
+ const property = schema.properties[namespace];
53
236
  if ((property == null ? void 0 : property.type) !== 'object') {
54
237
  return;
55
238
  }
56
239
  const newObject = {
57
- [namespace]: ({})
240
+ [namespace]: {}
58
241
  };
59
242
  for (const [key, value] of Object.entries(dataset)) {
60
243
  let current = newObject;
61
244
  const keyParts = key.split('.');
62
245
  for (const [index, name] of keyParts.entries()) {
63
- if (typeof current === 'object') {
246
+ if (isObject(current)) {
64
247
  if (index < keyParts.length - 1) {
65
248
  if (!isObject(current[name])) {
66
249
  current[name] = {};
@@ -74,101 +257,39 @@
74
257
  }
75
258
  return newObject[namespace];
76
259
  }
77
- function isSupported($scope = document.body) {
78
- if (!$scope) {
79
- return false;
80
- }
81
- return $scope.classList.contains('govuk-frontend-supported');
82
- }
83
- function isArray(option) {
84
- return Array.isArray(option);
85
- }
86
- function isObject(option) {
87
- return !!option && typeof option === 'object' && !isArray(option);
88
- }
89
-
90
260
  /**
91
261
  * Schema for component config
92
262
  *
263
+ * @template {Partial<Record<keyof ConfigurationType, unknown>>} ConfigurationType
93
264
  * @typedef {object} Schema
94
- * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
95
- * @property {SchemaCondition[]} [anyOf] - List of schema conditions
265
+ * @property {Record<keyof ConfigurationType, SchemaProperty | undefined>} properties - Schema properties
266
+ * @property {SchemaCondition<ConfigurationType>[]} [anyOf] - List of schema conditions
96
267
  */
97
-
98
268
  /**
99
269
  * Schema property for component config
100
270
  *
101
271
  * @typedef {object} SchemaProperty
102
272
  * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
103
273
  */
104
-
105
274
  /**
106
275
  * Schema condition for component config
107
276
  *
277
+ * @template {Partial<Record<keyof ConfigurationType, unknown>>} ConfigurationType
108
278
  * @typedef {object} SchemaCondition
109
- * @property {string[]} required - List of required config fields
279
+ * @property {(keyof ConfigurationType)[]} required - List of required config fields
110
280
  * @property {string} errorMessage - Error message when required config fields not provided
111
281
  */
112
-
113
- function normaliseDataset(Component, dataset) {
114
- const out = {};
115
- for (const [field, property] of Object.entries(Component.schema.properties)) {
116
- if (field in dataset) {
117
- out[field] = normaliseString(dataset[field], property);
118
- }
119
- if ((property == null ? void 0 : property.type) === 'object') {
120
- out[field] = extractConfigByNamespace(Component, dataset, field);
121
- }
122
- }
123
- return out;
124
- }
125
-
126
- class GOVUKFrontendError extends Error {
127
- constructor(...args) {
128
- super(...args);
129
- this.name = 'GOVUKFrontendError';
130
- }
131
- }
132
- class SupportError extends GOVUKFrontendError {
133
- /**
134
- * Checks if GOV.UK Frontend is supported on this page
135
- *
136
- * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support
137
- */
138
- constructor($scope = document.body) {
139
- 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';
140
- super($scope ? supportMessage : 'GOV.UK Frontend initialised without `<script type="module">`');
141
- this.name = 'SupportError';
142
- }
143
- }
144
- class ElementError extends GOVUKFrontendError {
145
- constructor(messageOrOptions) {
146
- let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
147
- if (typeof messageOrOptions === 'object') {
148
- const {
149
- componentName,
150
- identifier,
151
- element,
152
- expectedType
153
- } = messageOrOptions;
154
- message = `${componentName}: ${identifier}`;
155
- message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
156
- }
157
- super(message);
158
- this.name = 'ElementError';
159
- }
160
- }
161
-
162
- class GOVUKFrontendComponent {
163
- constructor() {
164
- this.checkSupport();
165
- }
166
- checkSupport() {
167
- if (!isSupported()) {
168
- throw new SupportError();
169
- }
170
- }
171
- }
282
+ /**
283
+ * @template {Partial<Record<keyof ConfigurationType, unknown>>} [ConfigurationType=ObjectNested]
284
+ * @typedef ChildClass
285
+ * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
286
+ * @property {Schema<ConfigurationType>} [schema] - The schema of the component configuration
287
+ * @property {ConfigurationType} [defaults] - The default values of the configuration of the component
288
+ */
289
+ /**
290
+ * @template {Partial<Record<keyof ConfigurationType, unknown>>} [ConfigurationType=ObjectNested]
291
+ * @typedef {typeof Component & ChildClass<ConfigurationType>} ChildClassConstructor<ConfigurationType>
292
+ */
172
293
 
173
294
  const DEBOUNCE_TIMEOUT_IN_SECONDS = 1;
174
295
 
@@ -176,28 +297,18 @@
176
297
  * JavaScript enhancements for the Button component
177
298
  *
178
299
  * @preserve
300
+ * @augments ConfigurableComponent<ButtonConfig>
179
301
  */
180
- class Button extends GOVUKFrontendComponent {
302
+ class Button extends ConfigurableComponent {
181
303
  /**
182
- * @param {Element | null} $module - HTML element to use for button
304
+ * @param {Element | null} $root - HTML element to use for button
183
305
  * @param {ButtonConfig} [config] - Button config
184
306
  */
185
- constructor($module, config = {}) {
186
- super();
187
- this.$module = void 0;
188
- this.config = void 0;
307
+ constructor($root, config = {}) {
308
+ super($root, config);
189
309
  this.debounceFormSubmitTimer = null;
190
- if (!($module instanceof HTMLElement)) {
191
- throw new ElementError({
192
- componentName: 'Button',
193
- element: $module,
194
- identifier: 'Root element (`$module`)'
195
- });
196
- }
197
- this.$module = $module;
198
- this.config = mergeConfigs(Button.defaults, config, normaliseDataset(Button, $module.dataset));
199
- this.$module.addEventListener('keydown', event => this.handleKeyDown(event));
200
- this.$module.addEventListener('click', event => this.debounce(event));
310
+ this.$root.addEventListener('keydown', event => this.handleKeyDown(event));
311
+ this.$root.addEventListener('click', event => this.debounce(event));
201
312
  }
202
313
  handleKeyDown(event) {
203
314
  const $target = event.target;
@@ -232,7 +343,7 @@
232
343
  */
233
344
 
234
345
  /**
235
- * @typedef {import('../../common/index.mjs').Schema} Schema
346
+ * @import { Schema } from '../../common/configuration.mjs'
236
347
  */
237
348
  Button.moduleName = 'govuk-button';
238
349
  Button.defaults = Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"button.bundle.js","sources":["../../../../src/govuk/common/normalise-string.mjs","../../../../src/govuk/common/index.mjs","../../../../src/govuk/common/normalise-dataset.mjs","../../../../src/govuk/errors/index.mjs","../../../../src/govuk/govuk-frontend-component.mjs","../../../../src/govuk/components/button/button.mjs"],"sourcesContent":["/**\n * Normalise string\n *\n * 'If it looks like a duck, and it quacks like a duck…' 🦆\n *\n * If the passed value looks like a boolean or a number, convert it to a boolean\n * or number.\n *\n * Designed to be used to convert config passed via data attributes (which are\n * always strings) into something sensible.\n *\n * @internal\n * @param {DOMStringMap[string]} value - The value to normalise\n * @param {SchemaProperty} [property] - Component schema property\n * @returns {string | boolean | number | undefined} Normalised data\n */\nexport function normaliseString(value, property) {\n const trimmedValue = value ? value.trim() : ''\n\n let output\n let outputType = property?.type\n\n // No schema type set? Determine automatically\n if (!outputType) {\n if (['true', 'false'].includes(trimmedValue)) {\n outputType = 'boolean'\n }\n\n // Empty / whitespace-only strings are considered finite so we need to check\n // the length of the trimmed string as well\n if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {\n outputType = 'number'\n }\n }\n\n switch (outputType) {\n case 'boolean':\n output = trimmedValue === 'true'\n break\n\n case 'number':\n output = Number(trimmedValue)\n break\n\n default:\n output = value\n }\n\n return output\n}\n\n/**\n * @typedef {import('./index.mjs').SchemaProperty} SchemaProperty\n */\n","import { normaliseString } from './normalise-string.mjs'\n\n/**\n * Common helpers which do not require polyfill.\n *\n * IMPORTANT: If a helper require a polyfill, please isolate it in its own module\n * so that the polyfill can be properly tree-shaken and does not burden\n * the components that do not need that helper\n */\n\n/**\n * Config merging function\n *\n * Takes any number of objects and combines them together, with\n * greatest priority on the LAST item passed in.\n *\n * @internal\n * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge\n * @returns {{ [key: string]: unknown }} A merged config object\n */\nexport function mergeConfigs(...configObjects) {\n // Start with an empty object as our base\n /** @type {{ [key: string]: unknown }} */\n const formattedConfigObject = {}\n\n // Loop through each of the passed objects\n for (const configObject of configObjects) {\n for (const key of Object.keys(configObject)) {\n const option = formattedConfigObject[key]\n const override = configObject[key]\n\n // Push their keys one-by-one into formattedConfigObject. Any duplicate\n // keys with object values will be merged, otherwise the new value will\n // override the existing value.\n if (isObject(option) && isObject(override)) {\n // @ts-expect-error Index signature for type 'string' is missing\n formattedConfigObject[key] = mergeConfigs(option, override)\n } else {\n // Apply override\n formattedConfigObject[key] = override\n }\n }\n }\n\n return formattedConfigObject\n}\n\n/**\n * Extracts keys starting with a particular namespace from dataset ('data-*')\n * object, removing the namespace in the process, normalising all values\n *\n * @internal\n * @param {{ schema: Schema }} Component - Component class\n * @param {DOMStringMap} dataset - The object to extract key-value pairs from\n * @param {string} namespace - The namespace to filter keys with\n * @returns {ObjectNested | undefined} Nested object with dot-separated key namespace removed\n */\nexport function extractConfigByNamespace(Component, dataset, namespace) {\n const property = Component.schema.properties[namespace]\n\n // Only extract configs for object schema properties\n if (property?.type !== 'object') {\n return\n }\n\n // Add default empty config\n const newObject = {\n [namespace]: /** @type {ObjectNested} */ ({})\n }\n\n for (const [key, value] of Object.entries(dataset)) {\n /** @type {ObjectNested | ObjectNested[NestedKey]} */\n let current = newObject\n\n // Split the key into parts, using . as our namespace separator\n const keyParts = key.split('.')\n\n /**\n * Create new level per part\n *\n * e.g. 'i18n.textareaDescription.other' becomes\n * `{ i18n: { textareaDescription: { other } } }`\n */\n for (const [index, name] of keyParts.entries()) {\n if (typeof current === 'object') {\n // Drop down to nested object until the last part\n if (index < keyParts.length - 1) {\n // New nested object (optionally) replaces existing value\n if (!isObject(current[name])) {\n current[name] = {}\n }\n\n // Drop down into new or existing nested object\n current = current[name]\n } else if (key !== namespace) {\n // Normalised value (optionally) replaces existing value\n current[name] = normaliseString(value)\n }\n }\n }\n }\n\n return newObject[namespace]\n}\n\n/**\n * Get hash fragment from URL\n *\n * Extract the hash fragment (everything after the hash) from a URL,\n * but not including the hash symbol\n *\n * @private\n * @param {string} url - URL\n * @returns {string | undefined} Fragment from URL, without the hash\n */\nexport function getFragmentFromUrl(url) {\n if (!url.includes('#')) {\n return undefined\n }\n\n return url.split('#').pop()\n}\n\n/**\n * Get GOV.UK Frontend breakpoint value from CSS custom property\n *\n * @private\n * @param {string} name - Breakpoint name\n * @returns {{ property: string, value?: string }} Breakpoint object\n */\nexport function getBreakpoint(name) {\n const property = `--govuk-frontend-breakpoint-${name}`\n\n // Get value from `<html>` with breakpoints on CSS :root\n const value = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(property)\n\n return {\n property,\n value: value || undefined\n }\n}\n\n/**\n * Move focus to element\n *\n * Sets tabindex to -1 to make the element programmatically focusable,\n * but removes it on blur as the element doesn't need to be focused again.\n *\n * @private\n * @template {HTMLElement} FocusElement\n * @param {FocusElement} $element - HTML element\n * @param {object} [options] - Handler options\n * @param {function(this: FocusElement): void} [options.onBeforeFocus] - Callback before focus\n * @param {function(this: FocusElement): void} [options.onBlur] - Callback on blur\n */\nexport function setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute('tabindex')\n\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1')\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener('blur', onBlur, { once: true })\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n options.onBlur?.call($element)\n\n if (!isFocusable) {\n $element.removeAttribute('tabindex')\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener('focus', onFocus, { once: true })\n\n // Focus element\n options.onBeforeFocus?.call($element)\n $element.focus()\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @internal\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nexport function isSupported($scope = document.body) {\n if (!$scope) {\n return false\n }\n\n return $scope.classList.contains('govuk-frontend-supported')\n}\n\n/**\n * Validate component config by schema\n *\n * Follows limited examples in JSON schema for wider support in future\n *\n * {@link https://ajv.js.org/json-schema.html#compound-keywords}\n * {@link https://ajv.js.org/packages/ajv-errors.html#single-message}\n *\n * @internal\n * @param {Schema} schema - Config schema\n * @param {{ [key: string]: unknown }} config - Component config\n * @returns {string[]} List of validation errors\n */\nexport function validateConfig(schema, config) {\n const validationErrors = []\n\n // Check errors for each schema\n for (const [name, conditions] of Object.entries(schema)) {\n const errors = []\n\n // Check errors for each schema condition\n if (Array.isArray(conditions)) {\n for (const { required, errorMessage } of conditions) {\n if (!required.every((key) => !!config[key])) {\n errors.push(errorMessage) // Missing config key value\n }\n }\n\n // Check one condition passes or add errors\n if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {\n validationErrors.push(...errors)\n }\n }\n }\n\n return validationErrors\n}\n\n/**\n * Check for an array\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an array\n */\nfunction isArray(option) {\n return Array.isArray(option)\n}\n\n/**\n * Check for an object\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an object\n */\nfunction isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option)\n}\n\n/**\n * Schema for component config\n *\n * @typedef {object} Schema\n * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties\n * @property {SchemaCondition[]} [anyOf] - List of schema conditions\n */\n\n/**\n * Schema property for component config\n *\n * @typedef {object} SchemaProperty\n * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type\n */\n\n/**\n * Schema condition for component config\n *\n * @typedef {object} SchemaCondition\n * @property {string[]} required - List of required config fields\n * @property {string} errorMessage - Error message when required config fields not provided\n */\n\n/**\n * @internal\n * @typedef {keyof ObjectNested} NestedKey\n * @typedef {{ [key: string]: string | boolean | number | ObjectNested | undefined }} ObjectNested\n */\n","import { extractConfigByNamespace } from './index.mjs'\nimport { normaliseString } from './normalise-string.mjs'\n\n/**\n * Normalise dataset\n *\n * Loop over an object and normalise each value using {@link normaliseString},\n * optionally expanding nested `i18n.field`\n *\n * @internal\n * @param {{ schema: Schema }} Component - Component class\n * @param {DOMStringMap} dataset - HTML element dataset\n * @returns {ObjectNested} Normalised dataset\n */\nexport function normaliseDataset(Component, dataset) {\n const out = /** @type {ReturnType<typeof normaliseDataset>} */ ({})\n\n // Normalise top-level dataset ('data-*') values using schema types\n for (const [field, property] of Object.entries(Component.schema.properties)) {\n if (field in dataset) {\n out[field] = normaliseString(dataset[field], property)\n }\n\n /**\n * Extract and normalise nested object values automatically using\n * {@link normaliseString} but only schema object types are allowed\n */\n if (property?.type === 'object') {\n out[field] = extractConfigByNamespace(Component, dataset, field)\n }\n }\n\n return out\n}\n\n/**\n * @internal\n * @typedef {import('./index.mjs').ObjectNested} ObjectNested\n * @typedef {import('./index.mjs').Schema} Schema\n */\n","/**\n * GOV.UK Frontend error\n *\n * A base class for `Error`s thrown by GOV.UK Frontend.\n *\n * It is meant to be extended into specific types of errors\n * to be thrown by our code.\n *\n * @example\n * ```js\n * class MissingRootError extends GOVUKFrontendError {\n * // Setting an explicit name is important as extending the class will not\n * // set a new `name` on the subclass. The `name` property is important\n * // to ensure intelligible error names even if the class name gets\n * // mangled by a minifier\n * name = \"MissingRootError\"\n * }\n * ```\n * @abstract\n */\nexport class GOVUKFrontendError extends Error {\n name = 'GOVUKFrontendError'\n}\n\n/**\n * Indicates that GOV.UK Frontend is not supported\n */\nexport class SupportError extends GOVUKFrontendError {\n name = 'SupportError'\n\n /**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n */\n constructor($scope = document.body) {\n const supportMessage =\n 'noModule' in HTMLScriptElement.prototype\n ? 'GOV.UK Frontend initialised without `<body class=\"govuk-frontend-supported\">` from template `<script>` snippet'\n : 'GOV.UK Frontend is not supported in this browser'\n\n super(\n $scope\n ? supportMessage\n : 'GOV.UK Frontend initialised without `<script type=\"module\">`'\n )\n }\n}\n\n/**\n * Indicates that a component has received an illegal configuration\n */\nexport class ConfigError extends GOVUKFrontendError {\n name = 'ConfigError'\n}\n\n/**\n * Indicates an issue with an element (possibly `null` or `undefined`)\n */\nexport class ElementError extends GOVUKFrontendError {\n name = 'ElementError'\n\n /**\n * @internal\n * @overload\n * @param {string} message - Element error message\n */\n\n /**\n * @internal\n * @overload\n * @param {ElementErrorOptions} options - Element error options\n */\n\n /**\n * @internal\n * @param {string | ElementErrorOptions} messageOrOptions - Element error message or options\n */\n constructor(messageOrOptions) {\n let message = typeof messageOrOptions === 'string' ? messageOrOptions : ''\n\n // Build message from options\n if (typeof messageOrOptions === 'object') {\n const { componentName, identifier, element, expectedType } =\n messageOrOptions\n\n // Add prefix and identifier\n message = `${componentName}: ${identifier}`\n\n // Append reason\n message += element\n ? ` is not of type ${expectedType ?? 'HTMLElement'}`\n : ' not found'\n }\n\n super(message)\n }\n}\n\n/**\n * Element error options\n *\n * @internal\n * @typedef {object} ElementErrorOptions\n * @property {string} componentName - The name of the component throwing the error\n * @property {string} identifier - An identifier that'll let the user understand which element has an error. This is whatever makes the most sense\n * @property {Element | null} [element] - The element in error\n * @property {string} [expectedType] - The type that was expected for the identifier\n */\n","import { isSupported } from './common/index.mjs'\nimport { SupportError } from './errors/index.mjs'\n\n/**\n * Base Component class\n *\n * Centralises the behaviours shared by our components\n *\n * @internal\n * @abstract\n */\nexport class GOVUKFrontendComponent {\n /**\n * Constructs a new component, validating that GOV.UK Frontend is supported\n *\n * @internal\n */\n constructor() {\n this.checkSupport()\n }\n\n /**\n * Validates whether GOV.UK Frontend is supported\n *\n * @private\n * @throws {SupportError} when GOV.UK Frontend is not supported\n */\n checkSupport() {\n if (!isSupported()) {\n throw new SupportError()\n }\n }\n}\n","import { mergeConfigs } from '../../common/index.mjs'\nimport { normaliseDataset } from '../../common/normalise-dataset.mjs'\nimport { ElementError } from '../../errors/index.mjs'\nimport { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'\n\nconst DEBOUNCE_TIMEOUT_IN_SECONDS = 1\n\n/**\n * JavaScript enhancements for the Button component\n *\n * @preserve\n */\nexport class Button extends GOVUKFrontendComponent {\n /** @private */\n $module\n\n /**\n * @private\n * @type {ButtonConfig}\n */\n config\n\n /**\n * @private\n * @type {number | null}\n */\n debounceFormSubmitTimer = null\n\n /**\n * @param {Element | null} $module - HTML element to use for button\n * @param {ButtonConfig} [config] - Button config\n */\n constructor($module, config = {}) {\n super()\n\n if (!($module instanceof HTMLElement)) {\n throw new ElementError({\n componentName: 'Button',\n element: $module,\n identifier: 'Root element (`$module`)'\n })\n }\n\n this.$module = $module\n\n this.config = mergeConfigs(\n Button.defaults,\n config,\n normaliseDataset(Button, $module.dataset)\n )\n\n this.$module.addEventListener('keydown', (event) =>\n this.handleKeyDown(event)\n )\n this.$module.addEventListener('click', (event) => this.debounce(event))\n }\n\n /**\n * Trigger a click event when the space key is pressed\n *\n * Some screen readers tell users they can use the space bar to activate\n * things with the 'button' role, so we need to match the functionality of\n * native HTML buttons.\n *\n * See https://github.com/alphagov/govuk_elements/pull/272#issuecomment-233028270\n *\n * @private\n * @param {KeyboardEvent} event - Keydown event\n */\n handleKeyDown(event) {\n const $target = event.target\n\n // Handle space bar only\n if (event.key !== ' ') {\n return\n }\n\n // Handle elements with [role=\"button\"] only\n if (\n $target instanceof HTMLElement &&\n $target.getAttribute('role') === 'button'\n ) {\n event.preventDefault() // prevent the page from scrolling\n $target.click()\n }\n }\n\n /**\n * Debounce double-clicks\n *\n * If the click quickly succeeds a previous click then nothing will happen.\n * This stops people accidentally causing multiple form submissions by double\n * clicking buttons.\n *\n * @private\n * @param {MouseEvent} event - Mouse click event\n * @returns {undefined | false} Returns undefined, or false when debounced\n */\n debounce(event) {\n // Check the button that was clicked has preventDoubleClick enabled\n if (!this.config.preventDoubleClick) {\n return\n }\n\n // If the timer is still running, prevent the click from submitting the form\n if (this.debounceFormSubmitTimer) {\n event.preventDefault()\n return false\n }\n\n this.debounceFormSubmitTimer = window.setTimeout(() => {\n this.debounceFormSubmitTimer = null\n }, DEBOUNCE_TIMEOUT_IN_SECONDS * 1000)\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-button'\n\n /**\n * Button default config\n *\n * @see {@link ButtonConfig}\n * @constant\n * @type {ButtonConfig}\n */\n static defaults = Object.freeze({\n preventDoubleClick: false\n })\n\n /**\n * Button config schema\n *\n * @constant\n * @satisfies {Schema}\n */\n static schema = Object.freeze({\n properties: {\n preventDoubleClick: { type: 'boolean' }\n }\n })\n}\n\n/**\n * Button config\n *\n * @typedef {object} ButtonConfig\n * @property {boolean} [preventDoubleClick=false] - Prevent accidental double\n * clicks on submit buttons from submitting forms multiple times.\n */\n\n/**\n * @typedef {import('../../common/index.mjs').Schema} Schema\n */\n"],"names":["normaliseString","value","property","trimmedValue","trim","output","outputType","type","includes","length","isFinite","Number","mergeConfigs","configObjects","formattedConfigObject","configObject","key","Object","keys","option","override","isObject","extractConfigByNamespace","Component","dataset","namespace","schema","properties","newObject","entries","current","keyParts","split","index","name","isSupported","$scope","document","body","classList","contains","isArray","Array","normaliseDataset","out","field","GOVUKFrontendError","Error","constructor","args","SupportError","supportMessage","HTMLScriptElement","prototype","ElementError","messageOrOptions","message","componentName","identifier","element","expectedType","GOVUKFrontendComponent","checkSupport","DEBOUNCE_TIMEOUT_IN_SECONDS","Button","$module","config","debounceFormSubmitTimer","HTMLElement","defaults","addEventListener","event","handleKeyDown","debounce","$target","target","getAttribute","preventDefault","click","preventDoubleClick","window","setTimeout","moduleName","freeze"],"mappings":";;;;;;EAgBO,SAASA,eAAeA,CAACC,KAAK,EAAEC,QAAQ,EAAE;IAC/C,MAAMC,YAAY,GAAGF,KAAK,GAAGA,KAAK,CAACG,IAAI,EAAE,GAAG,EAAE,CAAA;EAE9C,EAAA,IAAIC,MAA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ACA;EACA;EA9IaC,MAAM,CA0GVkB,UAAU,GAAG,cAAc,CAAA;EA1GvBlB,MAAM,CAmHVK,QAAQ,GAAGpD,MAAM,CAACkE,MAAM,CAAC;EAC9BJ,EAAAA,kBAAkB,EAAE,KAAA;EACtB,CAAC,CAAC,CAAA;EArHSf,MAAM,CA6HVtC,MAAM,GAAGT,MAAM,CAACkE,MAAM,CAAC;EAC5BxD,EAAAA,UAAU,EAAE;EACVoD,IAAAA,kBAAkB,EAAE;EAAExE,MAAAA,IAAI,EAAE,SAAA;EAAU,KAAA;EACxC,GAAA;EACF,CAAC,CAAC;;;;;;;;"}
1
+ {"version":3,"file":"button.bundle.js","sources":["../../../../src/govuk/common/index.mjs","../../../../src/govuk/errors/index.mjs","../../../../src/govuk/component.mjs","../../../../src/govuk/common/configuration.mjs","../../../../src/govuk/components/button/button.mjs"],"sourcesContent":["/**\n * Common helpers which do not require polyfill.\n *\n * IMPORTANT: If a helper require a polyfill, please isolate it in its own module\n * so that the polyfill can be properly tree-shaken and does not burden\n * the components that do not need that helper\n */\n\n/**\n * Get hash fragment from URL\n *\n * Extract the hash fragment (everything after the hash) from a URL,\n * but not including the hash symbol\n *\n * @private\n * @param {string} url - URL\n * @returns {string | undefined} Fragment from URL, without the hash\n */\nexport function getFragmentFromUrl(url) {\n if (!url.includes('#')) {\n return undefined\n }\n\n return url.split('#').pop()\n}\n\n/**\n * Get GOV.UK Frontend breakpoint value from CSS custom property\n *\n * @private\n * @param {string} name - Breakpoint name\n * @returns {{ property: string, value?: string }} Breakpoint object\n */\nexport function getBreakpoint(name) {\n const property = `--govuk-frontend-breakpoint-${name}`\n\n // Get value from `<html>` with breakpoints on CSS :root\n const value = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(property)\n\n return {\n property,\n value: value || undefined\n }\n}\n\n/**\n * Move focus to element\n *\n * Sets tabindex to -1 to make the element programmatically focusable,\n * but removes it on blur as the element doesn't need to be focused again.\n *\n * @private\n * @template {HTMLElement} FocusElement\n * @param {FocusElement} $element - HTML element\n * @param {object} [options] - Handler options\n * @param {function(this: FocusElement): void} [options.onBeforeFocus] - Callback before focus\n * @param {function(this: FocusElement): void} [options.onBlur] - Callback on blur\n */\nexport function setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute('tabindex')\n\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1')\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener('blur', onBlur, { once: true })\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n options.onBlur?.call($element)\n\n if (!isFocusable) {\n $element.removeAttribute('tabindex')\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener('focus', onFocus, { once: true })\n\n // Focus element\n options.onBeforeFocus?.call($element)\n $element.focus()\n}\n\n/**\n * Checks if component is already initialised\n *\n * @internal\n * @param {Element} $root - HTML element to be checked\n * @param {string} moduleName - name of component module\n * @returns {boolean} Whether component is already initialised\n */\nexport function isInitialised($root, moduleName) {\n return (\n $root instanceof HTMLElement &&\n $root.hasAttribute(`data-${moduleName}-init`)\n )\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nexport function isSupported($scope = document.body) {\n if (!$scope) {\n return false\n }\n\n return $scope.classList.contains('govuk-frontend-supported')\n}\n\n/**\n * Check for an array\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an array\n */\nfunction isArray(option) {\n return Array.isArray(option)\n}\n\n/**\n * Check for an object\n *\n * @internal\n * @template {Partial<Record<keyof ObjectType, unknown>>} [ObjectType=ObjectNested]\n * @param {unknown | ObjectType} option - Option to check\n * @returns {option is ObjectType} Whether the option is an object\n */\nexport function isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option)\n}\n\n/**\n * Format error message\n *\n * @internal\n * @param {ComponentWithModuleName} Component - Component that threw the error\n * @param {string} message - Error message\n * @returns {string} - Formatted error message\n */\nexport function formatErrorMessage(Component, message) {\n return `${Component.moduleName}: ${message}`\n}\n\n/* eslint-disable jsdoc/valid-types --\n * `{new(...args: any[] ): object}` is not recognised as valid\n * https://github.com/gajus/eslint-plugin-jsdoc/issues/145#issuecomment-1308722878\n * https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/131\n **/\n\n/**\n * @typedef ComponentWithModuleName\n * @property {string} moduleName - Name of the component\n */\n\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * @import { ObjectNested } from './configuration.mjs'\n */\n","import { formatErrorMessage } from '../common/index.mjs'\n\n/**\n * GOV.UK Frontend error\n *\n * A base class for `Error`s thrown by GOV.UK Frontend.\n *\n * It is meant to be extended into specific types of errors\n * to be thrown by our code.\n *\n * @example\n * ```js\n * class MissingRootError extends GOVUKFrontendError {\n * // Setting an explicit name is important as extending the class will not\n * // set a new `name` on the subclass. The `name` property is important\n * // to ensure intelligible error names even if the class name gets\n * // mangled by a minifier\n * name = \"MissingRootError\"\n * }\n * ```\n * @virtual\n */\nexport class GOVUKFrontendError extends Error {\n name = 'GOVUKFrontendError'\n}\n\n/**\n * Indicates that GOV.UK Frontend is not supported\n */\nexport class SupportError extends GOVUKFrontendError {\n name = 'SupportError'\n\n /**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n */\n constructor($scope = document.body) {\n const supportMessage =\n 'noModule' in HTMLScriptElement.prototype\n ? 'GOV.UK Frontend initialised without `<body class=\"govuk-frontend-supported\">` from template `<script>` snippet'\n : 'GOV.UK Frontend is not supported in this browser'\n\n super(\n $scope\n ? supportMessage\n : 'GOV.UK Frontend initialised without `<script type=\"module\">`'\n )\n }\n}\n\n/**\n * Indicates that a component has received an illegal configuration\n */\nexport class ConfigError extends GOVUKFrontendError {\n name = 'ConfigError'\n}\n\n/**\n * Indicates an issue with an element (possibly `null` or `undefined`)\n */\nexport class ElementError extends GOVUKFrontendError {\n name = 'ElementError'\n\n /**\n * @internal\n * @overload\n * @param {string} message - Element error message\n */\n\n /**\n * @internal\n * @overload\n * @param {ElementErrorOptions} options - Element error options\n */\n\n /**\n * @internal\n * @param {string | ElementErrorOptions} messageOrOptions - Element error message or options\n */\n constructor(messageOrOptions) {\n let message = typeof messageOrOptions === 'string' ? messageOrOptions : ''\n\n // Build message from options\n if (typeof messageOrOptions === 'object') {\n const { component, identifier, element, expectedType } = messageOrOptions\n\n message = identifier\n\n // Append reason\n message += element\n ? ` is not of type ${expectedType ?? 'HTMLElement'}`\n : ' not found'\n\n message = formatErrorMessage(component, message)\n }\n\n super(message)\n }\n}\n\n/**\n * Indicates that a component is already initialised\n */\nexport class InitError extends GOVUKFrontendError {\n name = 'InitError'\n\n /**\n * @internal\n * @param {ComponentWithModuleName | string} componentOrMessage - name of the component module\n */\n constructor(componentOrMessage) {\n const message =\n typeof componentOrMessage === 'string'\n ? componentOrMessage\n : formatErrorMessage(\n componentOrMessage,\n `Root element (\\`$root\\`) already initialised`\n )\n\n super(message)\n }\n}\n\n/**\n * Element error options\n *\n * @internal\n * @typedef {object} ElementErrorOptions\n * @property {string} identifier - An identifier that'll let the user understand which element has an error. This is whatever makes the most sense\n * @property {Element | null} [element] - The element in error\n * @property {string} [expectedType] - The type that was expected for the identifier\n * @property {ComponentWithModuleName} component - Component throwing the error\n */\n\n/**\n * @import { ComponentWithModuleName } from '../common/index.mjs'\n */\n","import { isInitialised, isSupported } from './common/index.mjs'\nimport { ElementError, InitError, SupportError } from './errors/index.mjs'\n\n/**\n * Base Component class\n *\n * Centralises the behaviours shared by our components\n *\n * @virtual\n * @template {Element} [RootElementType=HTMLElement]\n */\nexport class Component {\n /**\n * @type {typeof Element}\n */\n static elementType = HTMLElement\n\n // allows Typescript user to work around the lack of types\n // in GOVUKFrontend package, Typescript is not aware of $root\n // in components that extend GOVUKFrontendComponent\n /**\n * Returns the root element of the component\n *\n * @protected\n * @returns {RootElementType} - the root element of component\n */\n get $root() {\n return this._$root\n }\n\n /**\n * @protected\n * @type {RootElementType}\n */\n _$root\n\n /**\n * Constructs a new component, validating that GOV.UK Frontend is supported\n *\n * @internal\n * @param {Element | null} [$root] - HTML element to use for component\n */\n constructor($root) {\n const childConstructor = /** @type {ChildClassConstructor} */ (\n this.constructor\n )\n\n // TypeScript does not enforce that inheriting classes will define a `moduleName`\n // (even if we add a `@virtual` `static moduleName` property to this class).\n // While we trust users to do this correctly, we do a little check to provide them\n // a helpful error message.\n //\n // After this, we'll be sure that `childConstructor` has a `moduleName`\n // as expected of the `ChildClassConstructor` we've cast `this.constructor` to.\n if (typeof childConstructor.moduleName !== 'string') {\n throw new InitError(`\\`moduleName\\` not defined in component`)\n }\n\n if (!($root instanceof childConstructor.elementType)) {\n throw new ElementError({\n element: $root,\n component: childConstructor,\n identifier: 'Root element (`$root`)',\n expectedType: childConstructor.elementType.name\n })\n } else {\n this._$root = /** @type {RootElementType} */ ($root)\n }\n\n childConstructor.checkSupport()\n\n this.checkInitialised()\n\n const moduleName = childConstructor.moduleName\n\n this.$root.setAttribute(`data-${moduleName}-init`, '')\n }\n\n /**\n * Validates whether component is already initialised\n *\n * @private\n * @throws {InitError} when component is already initialised\n */\n checkInitialised() {\n const constructor = /** @type {ChildClassConstructor} */ (this.constructor)\n const moduleName = constructor.moduleName\n\n if (moduleName && isInitialised(this.$root, moduleName)) {\n throw new InitError(constructor)\n }\n }\n\n /**\n * Validates whether components are supported\n *\n * @throws {SupportError} when the components are not supported\n */\n static checkSupport() {\n if (!isSupported()) {\n throw new SupportError()\n }\n }\n}\n\n/**\n * @typedef ChildClass\n * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component\n */\n\n/**\n * @typedef {typeof Component & ChildClass} ChildClassConstructor\n */\n","import { Component } from '../component.mjs'\nimport { ConfigError } from '../errors/index.mjs'\n\nimport { isObject, formatErrorMessage } from './index.mjs'\n\nexport const configOverride = Symbol.for('configOverride')\n\n/**\n * Base Component class\n *\n * Centralises the behaviours shared by our components\n *\n * @virtual\n * @template {Partial<Record<keyof ConfigurationType, unknown>>} [ConfigurationType=ObjectNested]\n * @template {Element & { dataset: DOMStringMap }} [RootElementType=HTMLElement]\n * @augments Component<RootElementType>\n */\nexport class ConfigurableComponent extends Component {\n /**\n * configOverride\n *\n * Function which defines configuration overrides to prioritize\n * properties from the root element's dataset.\n *\n * It should take a subset of configuration as input and return\n * a new configuration object with properties that should be\n * overridden based on the root element's dataset. A Symbol\n * is used for indexing to prevent conflicts.\n *\n * @internal\n * @virtual\n * @param {Partial<ConfigurationType>} [param] - Configuration object\n * @returns {Partial<ConfigurationType>} return - Configuration object\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n [configOverride](param) {\n return {}\n }\n\n /**\n * Returns the root element of the component\n *\n * @protected\n * @returns {ConfigurationType} - the root element of component\n */\n get config() {\n return this._config\n }\n\n /**\n *\n * @type {ConfigurationType}\n */\n _config\n\n /**\n * Constructs a new component, validating that GOV.UK Frontend is supported\n *\n * @internal\n * @param {Element | null} [$root] - HTML element to use for component\n * @param {ConfigurationType} [config] - HTML element to use for component\n */\n constructor($root, config) {\n super($root)\n\n const childConstructor =\n /** @type {ChildClassConstructor<ConfigurationType>} */ (this.constructor)\n\n if (!isObject(childConstructor.defaults)) {\n throw new ConfigError(\n formatErrorMessage(\n childConstructor,\n 'Config passed as parameter into constructor but no defaults defined'\n )\n )\n }\n\n const datasetConfig = /** @type {ConfigurationType} */ (\n normaliseDataset(childConstructor, this._$root.dataset)\n )\n\n this._config = /** @type {ConfigurationType} */ (\n mergeConfigs(\n childConstructor.defaults,\n config ?? {},\n this[configOverride](datasetConfig),\n datasetConfig\n )\n )\n }\n}\n\n/**\n * Normalise string\n *\n * 'If it looks like a duck, and it quacks like a duck…' 🦆\n *\n * If the passed value looks like a boolean or a number, convert it to a boolean\n * or number.\n *\n * Designed to be used to convert config passed via data attributes (which are\n * always strings) into something sensible.\n *\n * @internal\n * @param {DOMStringMap[string]} value - The value to normalise\n * @param {SchemaProperty} [property] - Component schema property\n * @returns {string | boolean | number | undefined} Normalised data\n */\nexport function normaliseString(value, property) {\n const trimmedValue = value ? value.trim() : ''\n\n let output\n let outputType = property?.type\n\n // No schema type set? Determine automatically\n if (!outputType) {\n if (['true', 'false'].includes(trimmedValue)) {\n outputType = 'boolean'\n }\n\n // Empty / whitespace-only strings are considered finite so we need to check\n // the length of the trimmed string as well\n if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {\n outputType = 'number'\n }\n }\n\n switch (outputType) {\n case 'boolean':\n output = trimmedValue === 'true'\n break\n\n case 'number':\n output = Number(trimmedValue)\n break\n\n default:\n output = value\n }\n\n return output\n}\n\n/**\n * Normalise dataset\n *\n * Loop over an object and normalise each value using {@link normaliseString},\n * optionally expanding nested `i18n.field`\n *\n * @internal\n * @template {Partial<Record<keyof ConfigurationType, unknown>>} ConfigurationType\n * @template {[keyof ConfigurationType, SchemaProperty | undefined][]} SchemaEntryType\n * @param {{ schema?: Schema<ConfigurationType>, moduleName: string }} Component - Component class\n * @param {DOMStringMap} dataset - HTML element dataset\n * @returns {ObjectNested} Normalised dataset\n */\nexport function normaliseDataset(Component, dataset) {\n if (!isObject(Component.schema)) {\n throw new ConfigError(\n formatErrorMessage(\n Component,\n 'Config passed as parameter into constructor but no schema defined'\n )\n )\n }\n\n const out = /** @type {ObjectNested} */ ({})\n const entries = /** @type {SchemaEntryType} */ (\n Object.entries(Component.schema.properties)\n )\n\n // Normalise top-level dataset ('data-*') values using schema types\n for (const entry of entries) {\n const [namespace, property] = entry\n\n // Cast the `namespace` to string so it can be used to access the dataset\n const field = namespace.toString()\n\n if (field in dataset) {\n out[field] = normaliseString(dataset[field], property)\n }\n\n /**\n * Extract and normalise nested object values automatically using\n * {@link normaliseString} but only schema object types are allowed\n */\n if (property?.type === 'object') {\n out[field] = extractConfigByNamespace(\n Component.schema,\n dataset,\n namespace\n )\n }\n }\n\n return out\n}\n\n/**\n * Config merging function\n *\n * Takes any number of objects and combines them together, with\n * greatest priority on the LAST item passed in.\n *\n * @internal\n * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge\n * @returns {{ [key: string]: unknown }} A merged config object\n */\nexport function mergeConfigs(...configObjects) {\n // Start with an empty object as our base\n /** @type {{ [key: string]: unknown }} */\n const formattedConfigObject = {}\n\n // Loop through each of the passed objects\n for (const configObject of configObjects) {\n for (const key of Object.keys(configObject)) {\n const option = formattedConfigObject[key]\n const override = configObject[key]\n\n // Push their keys one-by-one into formattedConfigObject. Any duplicate\n // keys with object values will be merged, otherwise the new value will\n // override the existing value.\n if (isObject(option) && isObject(override)) {\n formattedConfigObject[key] = mergeConfigs(option, override)\n } else {\n // Apply override\n formattedConfigObject[key] = override\n }\n }\n }\n\n return formattedConfigObject\n}\n\n/**\n * Validate component config by schema\n *\n * Follows limited examples in JSON schema for wider support in future\n *\n * {@link https://ajv.js.org/json-schema.html#compound-keywords}\n * {@link https://ajv.js.org/packages/ajv-errors.html#single-message}\n *\n * @internal\n * @template {Partial<Record<keyof ConfigurationType, unknown>>} ConfigurationType\n * @param {Schema<ConfigurationType>} schema - The schema of a component\n * @param {ConfigurationType} config - Component config\n * @returns {string[]} List of validation errors\n */\nexport function validateConfig(schema, config) {\n const validationErrors = []\n\n // Check errors for each schema\n for (const [name, conditions] of Object.entries(schema)) {\n const errors = []\n\n // Check errors for each schema condition\n if (Array.isArray(conditions)) {\n for (const { required, errorMessage } of conditions) {\n if (!required.every((key) => !!config[key])) {\n errors.push(errorMessage) // Missing config key value\n }\n }\n\n // Check one condition passes or add errors\n if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {\n validationErrors.push(...errors)\n }\n }\n }\n\n return validationErrors\n}\n\n/**\n * Extracts keys starting with a particular namespace from dataset ('data-*')\n * object, removing the namespace in the process, normalising all values\n *\n * @internal\n * @template {Partial<Record<keyof ConfigurationType, unknown>>} ConfigurationType\n * @param {Schema<ConfigurationType>} schema - The schema of a component\n * @param {DOMStringMap} dataset - The object to extract key-value pairs from\n * @param {keyof ConfigurationType} namespace - The namespace to filter keys with\n * @returns {ObjectNested | undefined} Nested object with dot-separated key namespace removed\n */\nexport function extractConfigByNamespace(schema, dataset, namespace) {\n const property = schema.properties[namespace]\n\n // Only extract configs for object schema properties\n if (property?.type !== 'object') {\n return\n }\n\n // Add default empty config\n const newObject = /** @type {Record<typeof namespace, ObjectNested>} */ ({\n [namespace]: {}\n })\n\n for (const [key, value] of Object.entries(dataset)) {\n /** @type {ObjectNested | ObjectNested[NestedKey]} */\n let current = newObject\n\n // Split the key into parts, using . as our namespace separator\n const keyParts = key.split('.')\n\n /**\n * Create new level per part\n *\n * e.g. 'i18n.textareaDescription.other' becomes\n * `{ i18n: { textareaDescription: { other } } }`\n */\n for (const [index, name] of keyParts.entries()) {\n if (isObject(current)) {\n // Drop down to nested object until the last part\n if (index < keyParts.length - 1) {\n // New nested object (optionally) replaces existing value\n if (!isObject(current[name])) {\n current[name] = {}\n }\n\n // Drop down into new or existing nested object\n current = current[name]\n } else if (key !== namespace) {\n // Normalised value (optionally) replaces existing value\n current[name] = normaliseString(value)\n }\n }\n }\n }\n\n return newObject[namespace]\n}\n\n/**\n * @internal\n * @typedef {keyof ObjectNested} NestedKey\n * @typedef {{ [key: string]: string | boolean | number | ObjectNested | undefined }} ObjectNested\n */\n\n/**\n * Schema for component config\n *\n * @template {Partial<Record<keyof ConfigurationType, unknown>>} ConfigurationType\n * @typedef {object} Schema\n * @property {Record<keyof ConfigurationType, SchemaProperty | undefined>} properties - Schema properties\n * @property {SchemaCondition<ConfigurationType>[]} [anyOf] - List of schema conditions\n */\n\n/**\n * Schema property for component config\n *\n * @typedef {object} SchemaProperty\n * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type\n */\n\n/**\n * Schema condition for component config\n *\n * @template {Partial<Record<keyof ConfigurationType, unknown>>} ConfigurationType\n * @typedef {object} SchemaCondition\n * @property {(keyof ConfigurationType)[]} required - List of required config fields\n * @property {string} errorMessage - Error message when required config fields not provided\n */\n\n/**\n * @template {Partial<Record<keyof ConfigurationType, unknown>>} [ConfigurationType=ObjectNested]\n * @typedef ChildClass\n * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component\n * @property {Schema<ConfigurationType>} [schema] - The schema of the component configuration\n * @property {ConfigurationType} [defaults] - The default values of the configuration of the component\n */\n\n/**\n * @template {Partial<Record<keyof ConfigurationType, unknown>>} [ConfigurationType=ObjectNested]\n * @typedef {typeof Component & ChildClass<ConfigurationType>} ChildClassConstructor<ConfigurationType>\n */\n","import { ConfigurableComponent } from '../../common/configuration.mjs'\n\nconst DEBOUNCE_TIMEOUT_IN_SECONDS = 1\n\n/**\n * JavaScript enhancements for the Button component\n *\n * @preserve\n * @augments ConfigurableComponent<ButtonConfig>\n */\nexport class Button extends ConfigurableComponent {\n /**\n * @private\n * @type {number | null}\n */\n debounceFormSubmitTimer = null\n\n /**\n * @param {Element | null} $root - HTML element to use for button\n * @param {ButtonConfig} [config] - Button config\n */\n constructor($root, config = {}) {\n super($root, config)\n\n this.$root.addEventListener('keydown', (event) => this.handleKeyDown(event))\n this.$root.addEventListener('click', (event) => this.debounce(event))\n }\n\n /**\n * Trigger a click event when the space key is pressed\n *\n * Some screen readers tell users they can use the space bar to activate\n * things with the 'button' role, so we need to match the functionality of\n * native HTML buttons.\n *\n * See https://github.com/alphagov/govuk_elements/pull/272#issuecomment-233028270\n *\n * @private\n * @param {KeyboardEvent} event - Keydown event\n */\n handleKeyDown(event) {\n const $target = event.target\n\n // Handle space bar only\n if (event.key !== ' ') {\n return\n }\n\n // Handle elements with [role=\"button\"] only\n if (\n $target instanceof HTMLElement &&\n $target.getAttribute('role') === 'button'\n ) {\n event.preventDefault() // prevent the page from scrolling\n $target.click()\n }\n }\n\n /**\n * Debounce double-clicks\n *\n * If the click quickly succeeds a previous click then nothing will happen.\n * This stops people accidentally causing multiple form submissions by double\n * clicking buttons.\n *\n * @private\n * @param {MouseEvent} event - Mouse click event\n * @returns {undefined | false} Returns undefined, or false when debounced\n */\n debounce(event) {\n // Check the button that was clicked has preventDoubleClick enabled\n if (!this.config.preventDoubleClick) {\n return\n }\n\n // If the timer is still running, prevent the click from submitting the form\n if (this.debounceFormSubmitTimer) {\n event.preventDefault()\n return false\n }\n\n this.debounceFormSubmitTimer = window.setTimeout(() => {\n this.debounceFormSubmitTimer = null\n }, DEBOUNCE_TIMEOUT_IN_SECONDS * 1000)\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-button'\n\n /**\n * Button default config\n *\n * @see {@link ButtonConfig}\n * @constant\n * @type {ButtonConfig}\n */\n static defaults = Object.freeze({\n preventDoubleClick: false\n })\n\n /**\n * Button config schema\n *\n * @constant\n * @satisfies {Schema<ButtonConfig>}\n */\n static schema = Object.freeze({\n properties: {\n preventDoubleClick: { type: 'boolean' }\n }\n })\n}\n\n/**\n * Button config\n *\n * @typedef {object} ButtonConfig\n * @property {boolean} [preventDoubleClick=false] - Prevent accidental double\n * clicks on submit buttons from submitting forms multiple times.\n */\n\n/**\n * @import { Schema } from '../../common/configuration.mjs'\n */\n"],"names":["isInitialised","$root","moduleName","HTMLElement","hasAttribute","isSupported","$scope","document","body","classList","contains","isArray","option","Array","isObject","formatErrorMessage","Component","message","GOVUKFrontendError","Error","constructor","args","name","SupportError","supportMessage","HTMLScriptElement","prototype","ConfigError","ElementError","messageOrOptions","component","identifier","element","expectedType","InitError","componentOrMessage","_$root","childConstructor","elementType","checkSupport","checkInitialised","setAttribute","configOverride","Symbol","for","ConfigurableComponent","param","config","_config","defaults","datasetConfig","normaliseDataset","dataset","mergeConfigs","normaliseString","value","property","trimmedValue","trim","output","outputType","type","includes","length","isFinite","Number","schema","out","entries","Object","properties","entry","namespace","field","toString","extractConfigByNamespace","configObjects","formattedConfigObject","configObject","key","keys","override","newObject","current","keyParts","split","index","DEBOUNCE_TIMEOUT_IN_SECONDS","Button","debounceFormSubmitTimer","addEventListener","event","handleKeyDown","debounce","$target","target","getAttribute","preventDefault","click","preventDoubleClick","window","setTimeout","freeze"],"mappings":";;;;;;EAqGO,SAASA,aAAaA,CAACC,KAAK,EAAEC,UAAU,EAAE;IAC/C,OACED,KAAK,YAAYE,WAAW,IAC5BF,KAAK,CAACG,YAAY,CAAC,CAAA,KAAA,EAAQF,UAAU,CAAA,KAAA,CAAO,CAAC;EAEjD;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACO,SAASG,WAAWA,CAACC,MAAM,GAAGC,QAAQ,CAACC,IAAI,EAAE;IAClD,IAAI,CAACF,MAAM,EAAE;EACX,IAAA,OAAO,KAAK;EACd;EAEA,EAAA,OAAOA,MAAM,CAACG,SAAS,CAACC,QAAQ,CAAC,0BAA0B,CAAC;EAC9D;EASA,SAASC,OAAOA,CAACC,MAAM,EAAE;EACvB,EAAA,OAAOC,KAAK,CAACF,OAAO,CAACC,MAAM,CAAC;EAC9B;EAUO,SAASE,QAAQA,CAACF,MAAM,EAAE;EAC/B,EAAA,OAAO,CAAC,CAACA,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAI,CAACD,OAAO,CAACC,MAAM,CAAC;EACnE;EAUO,SAASG,kBAAkBA,CAACC,SAAS,EAAEC,OAAO,EAAE;EACrD,EAAA,OAAO,GAAGD,SAAS,CAACd,UAAU,CAAA,EAAA,EAAKe,OAAO,CAAE,CAAA;EAC9C;EAQA;EACA;EACA;EACA;EAIA;EACA;EACA;;ECzJO,MAAMC,kBAAkB,SAASC,KAAK,CAAC;EAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;EAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;MAAA,IAC5CC,CAAAA,IAAI,GAAG,oBAAoB;EAAA;EAC7B;EAKO,MAAMC,YAAY,SAASL,kBAAkB,CAAC;EAGnD;EACF;EACA;EACA;EACA;EACEE,EAAAA,WAAWA,CAACd,MAAM,GAAGC,QAAQ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