govuk_publishing_components 35.3.2 → 35.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (271) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +11 -5
  3. data/app/assets/stylesheets/component_guide/application.scss +37 -1
  4. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +8 -59
  5. data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +10 -6
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss +2 -2
  7. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_brand-colours.scss +24 -0
  8. data/app/views/govuk_publishing_components/component_guide/example.html.erb +1 -1
  9. data/app/views/govuk_publishing_components/component_guide/preview.html.erb +1 -1
  10. data/app/views/govuk_publishing_components/component_guide/show.html.erb +1 -1
  11. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +49 -57
  12. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +3 -3
  13. data/app/views/govuk_publishing_components/components/_metadata.html.erb +1 -1
  14. data/app/views/govuk_publishing_components/components/_share_links.html.erb +6 -2
  15. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +1 -1
  16. data/app/views/govuk_publishing_components/components/docs/metadata.yml +1 -3
  17. data/app/views/govuk_publishing_components/components/docs/organisation_logo.yml +5 -5
  18. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_related.yml +1 -0
  19. data/app/views/layouts/govuk_publishing_components/application.html.erb +1 -0
  20. data/config/locales/cy.yml +1 -1
  21. data/lib/govuk_publishing_components/app_helpers/asset_helper.rb +4 -0
  22. data/lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb +1 -1
  23. data/lib/govuk_publishing_components/version.rb +1 -1
  24. data/node_modules/axe-core/axe.d.ts +77 -6
  25. data/node_modules/axe-core/axe.js +955 -600
  26. data/node_modules/axe-core/axe.min.js +2 -2
  27. data/node_modules/axe-core/locales/_template.json +6 -6
  28. data/node_modules/axe-core/locales/ja.json +91 -11
  29. data/node_modules/axe-core/package.json +5 -5
  30. data/node_modules/axe-core/sri-history.json +4 -0
  31. data/node_modules/govuk-frontend/README.md +4 -5
  32. data/node_modules/govuk-frontend/govuk/all-ie8.scss +8 -0
  33. data/node_modules/govuk-frontend/govuk/all.js +738 -258
  34. data/node_modules/govuk-frontend/govuk/all.js.map +1 -1
  35. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +11 -7
  36. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js.map +1 -1
  37. data/node_modules/govuk-frontend/govuk/common/govuk-frontend-version.js +17 -0
  38. data/node_modules/govuk-frontend/govuk/common/govuk-frontend-version.js.map +1 -0
  39. data/node_modules/govuk-frontend/govuk/common/index.js +16 -4
  40. data/node_modules/govuk-frontend/govuk/common/index.js.map +1 -1
  41. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +20 -10
  42. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js.map +1 -1
  43. data/node_modules/govuk-frontend/govuk/common.js +16 -4
  44. data/node_modules/govuk-frontend/govuk/common.js.map +1 -1
  45. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +3 -3
  46. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +234 -86
  47. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js.map +1 -1
  48. data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +32 -13
  49. data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +8 -2
  50. data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +1 -0
  51. data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +1 -1
  52. data/node_modules/govuk-frontend/govuk/components/back-link/fixtures.json +1 -1
  53. data/node_modules/govuk-frontend/govuk/components/back-link/macro-options.json +1 -1
  54. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +1 -1
  55. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +12 -12
  56. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/macro-options.json +1 -1
  57. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +8 -6
  58. data/node_modules/govuk-frontend/govuk/components/button/button.js +54 -19
  59. data/node_modules/govuk-frontend/govuk/components/button/button.js.map +1 -1
  60. data/node_modules/govuk-frontend/govuk/components/button/fixtures.json +11 -1
  61. data/node_modules/govuk-frontend/govuk/components/button/macro-options.json +7 -1
  62. data/node_modules/govuk-frontend/govuk/components/button/template.njk +1 -1
  63. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +170 -76
  64. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js.map +1 -1
  65. data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +24 -24
  66. data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +3 -3
  67. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +6 -6
  68. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +75 -24
  69. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js.map +1 -1
  70. data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +47 -47
  71. data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +1 -1
  72. data/node_modules/govuk-frontend/govuk/components/checkboxes/template.njk +3 -3
  73. data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +24 -24
  74. data/node_modules/govuk-frontend/govuk/components/cookie-banner/macro-options.json +1 -1
  75. data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +26 -26
  76. data/node_modules/govuk-frontend/govuk/components/date-input/macro-options.json +1 -1
  77. data/node_modules/govuk-frontend/govuk/components/date-input/template.njk +1 -1
  78. data/node_modules/govuk-frontend/govuk/components/details/details.js +39 -13
  79. data/node_modules/govuk-frontend/govuk/components/details/details.js.map +1 -1
  80. data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +1 -1
  81. data/node_modules/govuk-frontend/govuk/components/details/macro-options.json +1 -1
  82. data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +10 -10
  83. data/node_modules/govuk-frontend/govuk/components/error-message/macro-options.json +1 -1
  84. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +67 -27
  85. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js.map +1 -1
  86. data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +19 -19
  87. data/node_modules/govuk-frontend/govuk/components/error-summary/macro-options.json +1 -1
  88. data/node_modules/govuk-frontend/govuk/components/fieldset/fixtures.json +19 -19
  89. data/node_modules/govuk-frontend/govuk/components/fieldset/macro-options.json +1 -1
  90. data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +6 -1
  91. data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +14 -14
  92. data/node_modules/govuk-frontend/govuk/components/file-upload/macro-options.json +7 -1
  93. data/node_modules/govuk-frontend/govuk/components/file-upload/template.njk +2 -1
  94. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +0 -7
  95. data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +24 -24
  96. data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +1 -1
  97. data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +22 -22
  98. data/node_modules/govuk-frontend/govuk/components/header/header.js +46 -14
  99. data/node_modules/govuk-frontend/govuk/components/header/header.js.map +1 -1
  100. data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +1 -1
  101. data/node_modules/govuk-frontend/govuk/components/header/template.njk +1 -1
  102. data/node_modules/govuk-frontend/govuk/components/hint/fixtures.json +1 -1
  103. data/node_modules/govuk-frontend/govuk/components/hint/macro-options.json +1 -1
  104. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +15 -3
  105. data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +54 -41
  106. data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +7 -1
  107. data/node_modules/govuk-frontend/govuk/components/input/template.njk +2 -1
  108. data/node_modules/govuk-frontend/govuk/components/inset-text/fixtures.json +1 -1
  109. data/node_modules/govuk-frontend/govuk/components/inset-text/macro-options.json +1 -1
  110. data/node_modules/govuk-frontend/govuk/components/label/fixtures.json +6 -6
  111. data/node_modules/govuk-frontend/govuk/components/label/macro-options.json +1 -1
  112. data/node_modules/govuk-frontend/govuk/components/notification-banner/fixtures.json +1 -1
  113. data/node_modules/govuk-frontend/govuk/components/notification-banner/macro-options.json +1 -1
  114. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +49 -22
  115. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js.map +1 -1
  116. data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +16 -16
  117. data/node_modules/govuk-frontend/govuk/components/pagination/macro-options.json +1 -1
  118. data/node_modules/govuk-frontend/govuk/components/panel/fixtures.json +10 -10
  119. data/node_modules/govuk-frontend/govuk/components/panel/macro-options.json +1 -1
  120. data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +1 -1
  121. data/node_modules/govuk-frontend/govuk/components/phase-banner/macro-options.json +1 -1
  122. data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +5 -5
  123. data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +46 -46
  124. data/node_modules/govuk-frontend/govuk/components/radios/macro-options.json +1 -1
  125. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +65 -22
  126. data/node_modules/govuk-frontend/govuk/components/radios/radios.js.map +1 -1
  127. data/node_modules/govuk-frontend/govuk/components/radios/template.njk +2 -2
  128. data/node_modules/govuk-frontend/govuk/components/select/_index.scss +7 -1
  129. data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +19 -20
  130. data/node_modules/govuk-frontend/govuk/components/select/macro-options.json +7 -1
  131. data/node_modules/govuk-frontend/govuk/components/select/template.njk +5 -2
  132. data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +1 -1
  133. data/node_modules/govuk-frontend/govuk/components/skip-link/macro-options.json +1 -1
  134. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +41 -13
  135. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js.map +1 -1
  136. data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +34 -34
  137. data/node_modules/govuk-frontend/govuk/components/summary-list/macro-options.json +1 -1
  138. data/node_modules/govuk-frontend/govuk/components/table/fixtures.json +21 -21
  139. data/node_modules/govuk-frontend/govuk/components/table/macro-options.json +1 -1
  140. data/node_modules/govuk-frontend/govuk/components/tabs/fixtures.json +15 -15
  141. data/node_modules/govuk-frontend/govuk/components/tabs/macro-options.json +1 -1
  142. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +178 -60
  143. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js.map +1 -1
  144. data/node_modules/govuk-frontend/govuk/components/tabs/template.njk +1 -1
  145. data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +18 -18
  146. data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +1 -1
  147. data/node_modules/govuk-frontend/govuk/components/tag/macro-options.json +1 -1
  148. data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +8 -1
  149. data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +18 -18
  150. data/node_modules/govuk-frontend/govuk/components/textarea/macro-options.json +7 -1
  151. data/node_modules/govuk-frontend/govuk/components/textarea/template.njk +2 -1
  152. data/node_modules/govuk-frontend/govuk/components/warning-text/fixtures.json +9 -5
  153. data/node_modules/govuk-frontend/govuk/components/warning-text/macro-options.json +3 -3
  154. data/node_modules/govuk-frontend/govuk/components/warning-text/template.njk +1 -1
  155. data/node_modules/govuk-frontend/govuk/core/_all.scss +1 -0
  156. data/node_modules/govuk-frontend/govuk/core/_govuk-frontend-version.scss +5 -0
  157. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +5 -2
  158. data/node_modules/govuk-frontend/govuk/helpers/_focused.scss +1 -1
  159. data/node_modules/govuk-frontend/govuk/helpers/_font-faces.scss +1 -1
  160. data/node_modules/govuk-frontend/govuk/i18n.js +38 -30
  161. data/node_modules/govuk-frontend/govuk/i18n.js.map +1 -1
  162. data/node_modules/govuk-frontend/govuk/macros/i18n.njk +12 -11
  163. data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +1 -1
  164. data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +4 -0
  165. data/node_modules/govuk-frontend/govuk/settings/_ie8.scss +16 -0
  166. data/node_modules/govuk-frontend/govuk/settings/_links.scss +5 -1
  167. data/node_modules/govuk-frontend/govuk/tools/_ie8.scss +38 -2
  168. data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js +2 -1
  169. data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js.map +1 -1
  170. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +2 -1
  171. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js.map +1 -1
  172. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js +2 -1
  173. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js.map +1 -1
  174. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js +10 -3
  175. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js.map +1 -1
  176. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js +4 -1
  177. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js.map +1 -1
  178. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +13 -7
  179. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js.map +1 -1
  180. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js +2 -1
  181. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js.map +1 -1
  182. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +8 -2
  183. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js.map +1 -1
  184. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +8 -2
  185. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js.map +1 -1
  186. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js +4 -1
  187. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js.map +1 -1
  188. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js +10 -3
  189. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js.map +1 -1
  190. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js +4 -1
  191. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js.map +1 -1
  192. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js +2 -1
  193. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js.map +1 -1
  194. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +3 -2
  195. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js.map +1 -1
  196. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js +2 -1
  197. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js.map +1 -1
  198. data/node_modules/govuk-frontend/govuk-esm/all.mjs +81 -60
  199. data/node_modules/govuk-frontend/govuk-esm/all.mjs.map +1 -0
  200. data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs +12 -8
  201. data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs.map +1 -0
  202. data/node_modules/govuk-frontend/govuk-esm/common/govuk-frontend-version.mjs +9 -0
  203. data/node_modules/govuk-frontend/govuk-esm/common/govuk-frontend-version.mjs.map +1 -0
  204. data/node_modules/govuk-frontend/govuk-esm/common/index.mjs +44 -29
  205. data/node_modules/govuk-frontend/govuk-esm/common/index.mjs.map +1 -0
  206. data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs +15 -9
  207. data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs.map +1 -0
  208. data/node_modules/govuk-frontend/govuk-esm/common.mjs +3 -5
  209. data/node_modules/govuk-frontend/govuk-esm/common.mjs.map +1 -0
  210. data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +319 -211
  211. data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs.map +1 -0
  212. data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +47 -30
  213. data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs.map +1 -0
  214. data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +169 -115
  215. data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs.map +1 -0
  216. data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +88 -51
  217. data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs.map +1 -0
  218. data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +64 -54
  219. data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs.map +1 -0
  220. data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +69 -50
  221. data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs.map +1 -0
  222. data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +59 -35
  223. data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs.map +1 -0
  224. data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +36 -25
  225. data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs.map +1 -0
  226. data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +67 -38
  227. data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs.map +1 -0
  228. data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +49 -32
  229. data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs.map +1 -0
  230. data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +263 -163
  231. data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs.map +1 -0
  232. data/node_modules/govuk-frontend/govuk-esm/i18n.mjs +68 -57
  233. data/node_modules/govuk-frontend/govuk-esm/i18n.mjs.map +1 -0
  234. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/DOMTokenList.mjs +5 -3
  235. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/DOMTokenList.mjs.map +1 -0
  236. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs +4 -2
  237. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs.map +1 -0
  238. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Document.mjs +4 -2
  239. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Document.mjs.map +1 -0
  240. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.mjs +7 -4
  241. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.mjs.map +1 -0
  242. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/closest.mjs +5 -2
  243. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/closest.mjs.map +1 -0
  244. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs +13 -10
  245. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs.map +1 -0
  246. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/matches.mjs +4 -2
  247. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/matches.mjs.map +1 -0
  248. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.mjs +6 -3
  249. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.mjs.map +1 -0
  250. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/previousElementSibling.mjs +6 -3
  251. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/previousElementSibling.mjs.map +1 -0
  252. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element.mjs +5 -2
  253. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element.mjs.map +1 -0
  254. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Event.mjs +7 -4
  255. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Event.mjs.map +1 -0
  256. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/bind.mjs +5 -2
  257. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/bind.mjs.map +1 -0
  258. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/defineProperty.mjs +4 -2
  259. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/defineProperty.mjs.map +1 -0
  260. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs +5 -3
  261. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs.map +1 -0
  262. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Window.mjs +4 -2
  263. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Window.mjs.map +1 -0
  264. data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +1 -0
  265. data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +2 -1
  266. data/node_modules/govuk-frontend/package.json +3 -2
  267. metadata +43 -6
  268. /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_13px.png → dbt_crest_13px.png} +0 -0
  269. /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_13px_x2.png → dbt_crest_13px_x2.png} +0 -0
  270. /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_18px.png → dbt_crest_18px.png} +0 -0
  271. /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_18px_x2.png → dbt_crest_18px_x2.png} +0 -0
@@ -1,14 +1,13 @@
1
- /* eslint-disable es-x/no-function-prototype-bind -- Polyfill imported */
2
- /* eslint-disable es-x/no-string-prototype-trim -- Polyfill imported */
1
+ import { nodeListForEach, mergeConfigs, extractConfigByNamespace } from '../../common/index.mjs';
2
+ import { normaliseDataset } from '../../common/normalise-dataset.mjs';
3
+ import { I18n } from '../../i18n.mjs';
4
+ import '../../vendor/polyfills/Element/prototype/classList.mjs';
5
+ import '../../vendor/polyfills/Element/prototype/closest.mjs';
6
+ import '../../vendor/polyfills/Event.mjs';
7
+ import '../../vendor/polyfills/Function/prototype/bind.mjs';
8
+ import '../../vendor/polyfills/String/prototype/trim.mjs';
3
9
 
4
- import { nodeListForEach, mergeConfigs, extractConfigByNamespace } from '../../common/index.mjs'
5
- import { normaliseDataset } from '../../common/normalise-dataset.mjs'
6
- import { I18n } from '../../i18n.mjs'
7
- import '../../vendor/polyfills/Element/prototype/classList.mjs'
8
- import '../../vendor/polyfills/Element/prototype/closest.mjs'
9
- import '../../vendor/polyfills/Event.mjs' // addEventListener, event.target normalization and DOMContentLoaded
10
- import '../../vendor/polyfills/Function/prototype/bind.mjs'
11
- import '../../vendor/polyfills/String/prototype/trim.mjs'
10
+ /* eslint-disable es-x/no-function-prototype-bind -- Polyfill imported */
12
11
 
13
12
  /**
14
13
  * @constant
@@ -23,7 +22,7 @@ var ACCORDION_TRANSLATIONS = {
23
22
  showAllSections: 'Show all sections',
24
23
  showSection: 'Show',
25
24
  showSectionAriaLabel: 'Show this section'
26
- }
25
+ };
27
26
 
28
27
  /**
29
28
  * Accordion component
@@ -38,372 +37,475 @@ var ACCORDION_TRANSLATIONS = {
38
37
  * attribute, which also provides accessibility.
39
38
  *
40
39
  * @class
41
- * @param {HTMLElement} $module - HTML element to use for accordion
40
+ * @param {Element} $module - HTML element to use for accordion
42
41
  * @param {AccordionConfig} [config] - Accordion config
43
42
  */
44
43
  function Accordion ($module, config) {
45
- this.$module = $module
44
+ if (!($module instanceof HTMLElement)) {
45
+ return this
46
+ }
47
+
48
+ /** @deprecated Will be made private in v5.0 */
49
+ this.$module = $module;
46
50
 
47
51
  var defaultConfig = {
48
- i18n: ACCORDION_TRANSLATIONS
49
- }
52
+ i18n: ACCORDION_TRANSLATIONS,
53
+ rememberExpanded: true
54
+ };
50
55
 
56
+ /**
57
+ * @deprecated Will be made private in v5.0
58
+ * @type {AccordionConfig}
59
+ */
51
60
  this.config = mergeConfigs(
52
61
  defaultConfig,
53
62
  config || {},
54
63
  normaliseDataset($module.dataset)
55
- )
56
-
57
- this.i18n = new I18n(extractConfigByNamespace(this.config, 'i18n'))
58
-
59
- this.controlsClass = 'govuk-accordion__controls'
60
- this.showAllClass = 'govuk-accordion__show-all'
61
- this.showAllTextClass = 'govuk-accordion__show-all-text'
62
-
63
- this.sectionClass = 'govuk-accordion__section'
64
- this.sectionExpandedClass = 'govuk-accordion__section--expanded'
65
- this.sectionButtonClass = 'govuk-accordion__section-button'
66
- this.sectionHeaderClass = 'govuk-accordion__section-header'
67
- this.sectionHeadingClass = 'govuk-accordion__section-heading'
68
- this.sectionHeadingDividerClass = 'govuk-accordion__section-heading-divider'
69
- this.sectionHeadingTextClass = 'govuk-accordion__section-heading-text'
70
- this.sectionHeadingTextFocusClass = 'govuk-accordion__section-heading-text-focus'
71
-
72
- this.sectionShowHideToggleClass = 'govuk-accordion__section-toggle'
73
- this.sectionShowHideToggleFocusClass = 'govuk-accordion__section-toggle-focus'
74
- this.sectionShowHideTextClass = 'govuk-accordion__section-toggle-text'
75
- this.upChevronIconClass = 'govuk-accordion-nav__chevron'
76
- this.downChevronIconClass = 'govuk-accordion-nav__chevron--down'
77
-
78
- this.sectionSummaryClass = 'govuk-accordion__section-summary'
79
- this.sectionSummaryFocusClass = 'govuk-accordion__section-summary-focus'
80
- this.sectionContentClass = 'govuk-accordion__section-content'
81
-
82
- this.$sections = this.$module.querySelectorAll('.' + this.sectionClass)
83
- this.browserSupportsSessionStorage = helper.checkForSessionStorage()
64
+ );
65
+
66
+ /** @deprecated Will be made private in v5.0 */
67
+ this.i18n = new I18n(extractConfigByNamespace(this.config, 'i18n'));
68
+
69
+ /** @deprecated Will be made private in v5.0 */
70
+ this.controlsClass = 'govuk-accordion__controls';
71
+
72
+ /** @deprecated Will be made private in v5.0 */
73
+ this.showAllClass = 'govuk-accordion__show-all';
74
+
75
+ /** @deprecated Will be made private in v5.0 */
76
+ this.showAllTextClass = 'govuk-accordion__show-all-text';
77
+
78
+ /** @deprecated Will be made private in v5.0 */
79
+ this.sectionClass = 'govuk-accordion__section';
80
+
81
+ /** @deprecated Will be made private in v5.0 */
82
+ this.sectionExpandedClass = 'govuk-accordion__section--expanded';
83
+
84
+ /** @deprecated Will be made private in v5.0 */
85
+ this.sectionButtonClass = 'govuk-accordion__section-button';
86
+
87
+ /** @deprecated Will be made private in v5.0 */
88
+ this.sectionHeaderClass = 'govuk-accordion__section-header';
89
+
90
+ /** @deprecated Will be made private in v5.0 */
91
+ this.sectionHeadingClass = 'govuk-accordion__section-heading';
92
+
93
+ /** @deprecated Will be made private in v5.0 */
94
+ this.sectionHeadingDividerClass = 'govuk-accordion__section-heading-divider';
95
+
96
+ /** @deprecated Will be made private in v5.0 */
97
+ this.sectionHeadingTextClass = 'govuk-accordion__section-heading-text';
98
+
99
+ /** @deprecated Will be made private in v5.0 */
100
+ this.sectionHeadingTextFocusClass = 'govuk-accordion__section-heading-text-focus';
101
+
102
+ /** @deprecated Will be made private in v5.0 */
103
+ this.sectionShowHideToggleClass = 'govuk-accordion__section-toggle';
104
+
105
+ /** @deprecated Will be made private in v5.0 */
106
+ this.sectionShowHideToggleFocusClass = 'govuk-accordion__section-toggle-focus';
107
+
108
+ /** @deprecated Will be made private in v5.0 */
109
+ this.sectionShowHideTextClass = 'govuk-accordion__section-toggle-text';
110
+
111
+ /** @deprecated Will be made private in v5.0 */
112
+ this.upChevronIconClass = 'govuk-accordion-nav__chevron';
113
+
114
+ /** @deprecated Will be made private in v5.0 */
115
+ this.downChevronIconClass = 'govuk-accordion-nav__chevron--down';
116
+
117
+ /** @deprecated Will be made private in v5.0 */
118
+ this.sectionSummaryClass = 'govuk-accordion__section-summary';
119
+
120
+ /** @deprecated Will be made private in v5.0 */
121
+ this.sectionSummaryFocusClass = 'govuk-accordion__section-summary-focus';
122
+
123
+ /** @deprecated Will be made private in v5.0 */
124
+ this.sectionContentClass = 'govuk-accordion__section-content';
125
+
126
+ var $sections = this.$module.querySelectorAll('.' + this.sectionClass);
127
+ if (!$sections.length) {
128
+ return this
129
+ }
130
+
131
+ /** @deprecated Will be made private in v5.0 */
132
+ this.$sections = $sections;
133
+
134
+ /** @deprecated Will be made private in v5.0 */
135
+ this.browserSupportsSessionStorage = helper.checkForSessionStorage();
136
+
137
+ /** @deprecated Will be made private in v5.0 */
138
+ this.$showAllButton = null;
139
+
140
+ /** @deprecated Will be made private in v5.0 */
141
+ this.$showAllIcon = null;
142
+
143
+ /** @deprecated Will be made private in v5.0 */
144
+ this.$showAllText = null;
84
145
  }
85
146
 
86
147
  /**
87
148
  * Initialise component
88
149
  */
89
150
  Accordion.prototype.init = function () {
90
- // Check for module
91
- if (!this.$module) {
151
+ // Check that required elements are present
152
+ if (!this.$module || !this.$sections) {
92
153
  return
93
154
  }
94
155
 
95
- this.initControls()
96
- this.initSectionHeaders()
156
+ this.initControls();
157
+ this.initSectionHeaders();
97
158
 
98
159
  // See if "Show all sections" button text should be updated
99
- var areAllSectionsOpen = this.checkIfAllSectionsOpen()
100
- this.updateShowAllButton(areAllSectionsOpen)
101
- }
160
+ var areAllSectionsOpen = this.checkIfAllSectionsOpen();
161
+ this.updateShowAllButton(areAllSectionsOpen);
162
+ };
102
163
 
103
164
  /**
104
165
  * Initialise controls and set attributes
166
+ *
167
+ * @deprecated Will be made private in v5.0
105
168
  */
106
169
  Accordion.prototype.initControls = function () {
107
170
  // Create "Show all" button and set attributes
108
- this.$showAllButton = document.createElement('button')
109
- this.$showAllButton.setAttribute('type', 'button')
110
- this.$showAllButton.setAttribute('class', this.showAllClass)
111
- this.$showAllButton.setAttribute('aria-expanded', 'false')
171
+ this.$showAllButton = document.createElement('button');
172
+ this.$showAllButton.setAttribute('type', 'button');
173
+ this.$showAllButton.setAttribute('class', this.showAllClass);
174
+ this.$showAllButton.setAttribute('aria-expanded', 'false');
112
175
 
113
176
  // Create icon, add to element
114
- this.$showAllIcon = document.createElement('span')
115
- this.$showAllIcon.classList.add(this.upChevronIconClass)
116
- this.$showAllButton.appendChild(this.$showAllIcon)
177
+ this.$showAllIcon = document.createElement('span');
178
+ this.$showAllIcon.classList.add(this.upChevronIconClass);
179
+ this.$showAllButton.appendChild(this.$showAllIcon);
117
180
 
118
181
  // Create control wrapper and add controls to it
119
- var $accordionControls = document.createElement('div')
120
- $accordionControls.setAttribute('class', this.controlsClass)
121
- $accordionControls.appendChild(this.$showAllButton)
122
- this.$module.insertBefore($accordionControls, this.$module.firstChild)
182
+ var $accordionControls = document.createElement('div');
183
+ $accordionControls.setAttribute('class', this.controlsClass);
184
+ $accordionControls.appendChild(this.$showAllButton);
185
+ this.$module.insertBefore($accordionControls, this.$module.firstChild);
123
186
 
124
187
  // Build additional wrapper for Show all toggle text and place after icon
125
- this.$showAllText = document.createElement('span')
126
- this.$showAllText.classList.add(this.showAllTextClass)
127
- this.$showAllButton.appendChild(this.$showAllText)
188
+ this.$showAllText = document.createElement('span');
189
+ this.$showAllText.classList.add(this.showAllTextClass);
190
+ this.$showAllButton.appendChild(this.$showAllText);
128
191
 
129
192
  // Handle click events on the show/hide all button
130
- this.$showAllButton.addEventListener('click', this.onShowOrHideAllToggle.bind(this))
193
+ this.$showAllButton.addEventListener('click', this.onShowOrHideAllToggle.bind(this));
131
194
 
132
195
  // Handle 'beforematch' events, if the user agent supports them
133
196
  if ('onbeforematch' in document) {
134
- document.addEventListener('beforematch', this.onBeforeMatch.bind(this))
197
+ document.addEventListener('beforematch', this.onBeforeMatch.bind(this));
135
198
  }
136
- }
199
+ };
137
200
 
138
201
  /**
139
202
  * Initialise section headers
203
+ *
204
+ * @deprecated Will be made private in v5.0
140
205
  */
141
206
  Accordion.prototype.initSectionHeaders = function () {
142
- // Loop through section headers
143
- nodeListForEach(this.$sections, function ($section, i) {
207
+ var $component = this;
208
+ var $sections = this.$sections;
209
+
210
+ // Loop through sections
211
+ nodeListForEach($sections, function ($section, i) {
212
+ var $header = $section.querySelector('.' + $component.sectionHeaderClass);
213
+ if (!$header) {
214
+ return
215
+ }
216
+
144
217
  // Set header attributes
145
- var $header = $section.querySelector('.' + this.sectionHeaderClass)
146
- this.constructHeaderMarkup($header, i)
147
- this.setExpanded(this.isExpanded($section), $section)
218
+ $component.constructHeaderMarkup($header, i);
219
+ $component.setExpanded($component.isExpanded($section), $section);
148
220
 
149
221
  // Handle events
150
- $header.addEventListener('click', this.onSectionToggle.bind(this, $section))
222
+ $header.addEventListener('click', $component.onSectionToggle.bind($component, $section));
151
223
 
152
224
  // See if there is any state stored in sessionStorage and set the sections to
153
225
  // open or closed.
154
- this.setInitialState($section)
155
- }.bind(this))
156
- }
226
+ $component.setInitialState($section);
227
+ });
228
+ };
157
229
 
158
230
  /**
159
231
  * Construct section header
160
232
  *
161
- * @param {HTMLDivElement} $header - Section header
233
+ * @deprecated Will be made private in v5.0
234
+ * @param {Element} $header - Section header
162
235
  * @param {number} index - Section index
163
236
  */
164
237
  Accordion.prototype.constructHeaderMarkup = function ($header, index) {
165
- var $span = $header.querySelector('.' + this.sectionButtonClass)
166
- var $heading = $header.querySelector('.' + this.sectionHeadingClass)
167
- var $summary = $header.querySelector('.' + this.sectionSummaryClass)
238
+ var $span = $header.querySelector('.' + this.sectionButtonClass);
239
+ var $heading = $header.querySelector('.' + this.sectionHeadingClass);
240
+ var $summary = $header.querySelector('.' + this.sectionSummaryClass);
241
+
242
+ if (!$span || !$heading) {
243
+ return
244
+ }
168
245
 
169
246
  // Create a button element that will replace the '.govuk-accordion__section-button' span
170
- var $button = document.createElement('button')
171
- $button.setAttribute('type', 'button')
172
- $button.setAttribute('aria-controls', this.$module.id + '-content-' + (index + 1))
247
+ var $button = document.createElement('button');
248
+ $button.setAttribute('type', 'button');
249
+ $button.setAttribute('aria-controls', this.$module.id + '-content-' + (index + 1).toString());
173
250
 
174
251
  // Copy all attributes (https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes) from $span to $button
175
252
  for (var i = 0; i < $span.attributes.length; i++) {
176
- var attr = $span.attributes.item(i)
253
+ var attr = $span.attributes.item(i);
177
254
  // Add all attributes but not ID as this is being added to
178
255
  // the section heading ($headingText)
179
256
  if (attr.nodeName !== 'id') {
180
- $button.setAttribute(attr.nodeName, attr.nodeValue)
257
+ $button.setAttribute(attr.nodeName, attr.nodeValue);
181
258
  }
182
259
  }
183
260
 
184
261
  // Create container for heading text so it can be styled
185
- var $headingText = document.createElement('span')
186
- $headingText.classList.add(this.sectionHeadingTextClass)
262
+ var $headingText = document.createElement('span');
263
+ $headingText.classList.add(this.sectionHeadingTextClass);
187
264
  // Copy the span ID to the heading text to allow it to be referenced by `aria-labelledby` on the
188
265
  // hidden content area without "Show this section"
189
- $headingText.id = $span.id
266
+ $headingText.id = $span.id;
190
267
 
191
268
  // Create an inner heading text container to limit the width of the focus state
192
- var $headingTextFocus = document.createElement('span')
193
- $headingTextFocus.classList.add(this.sectionHeadingTextFocusClass)
194
- $headingText.appendChild($headingTextFocus)
269
+ var $headingTextFocus = document.createElement('span');
270
+ $headingTextFocus.classList.add(this.sectionHeadingTextFocusClass);
271
+ $headingText.appendChild($headingTextFocus);
195
272
  // span could contain HTML elements (see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content)
196
- $headingTextFocus.innerHTML = $span.innerHTML
273
+ $headingTextFocus.innerHTML = $span.innerHTML;
197
274
 
198
275
  // Create container for show / hide icons and text.
199
- var $showHideToggle = document.createElement('span')
200
- $showHideToggle.classList.add(this.sectionShowHideToggleClass)
276
+ var $showHideToggle = document.createElement('span');
277
+ $showHideToggle.classList.add(this.sectionShowHideToggleClass);
201
278
  // Tell Google not to index the 'show' text as part of the heading
202
279
  // For the snippet to work with JavaScript, it must be added before adding the page element to the
203
280
  // page's DOM. See https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#data-nosnippet-attr
204
- $showHideToggle.setAttribute('data-nosnippet', '')
281
+ $showHideToggle.setAttribute('data-nosnippet', '');
205
282
  // Create an inner container to limit the width of the focus state
206
- var $showHideToggleFocus = document.createElement('span')
207
- $showHideToggleFocus.classList.add(this.sectionShowHideToggleFocusClass)
208
- $showHideToggle.appendChild($showHideToggleFocus)
283
+ var $showHideToggleFocus = document.createElement('span');
284
+ $showHideToggleFocus.classList.add(this.sectionShowHideToggleFocusClass);
285
+ $showHideToggle.appendChild($showHideToggleFocus);
209
286
  // Create wrapper for the show / hide text. Append text after the show/hide icon
210
- var $showHideText = document.createElement('span')
211
- var $showHideIcon = document.createElement('span')
212
- $showHideIcon.classList.add(this.upChevronIconClass)
213
- $showHideToggleFocus.appendChild($showHideIcon)
214
- $showHideText.classList.add(this.sectionShowHideTextClass)
215
- $showHideToggleFocus.appendChild($showHideText)
287
+ var $showHideText = document.createElement('span');
288
+ var $showHideIcon = document.createElement('span');
289
+ $showHideIcon.classList.add(this.upChevronIconClass);
290
+ $showHideToggleFocus.appendChild($showHideIcon);
291
+ $showHideText.classList.add(this.sectionShowHideTextClass);
292
+ $showHideToggleFocus.appendChild($showHideText);
216
293
 
217
294
  // Append elements to the button:
218
295
  // 1. Heading text
219
296
  // 2. Punctuation
220
297
  // 3. (Optional: Summary line followed by punctuation)
221
298
  // 4. Show / hide toggle
222
- $button.appendChild($headingText)
223
- $button.appendChild(this.getButtonPunctuationEl())
299
+ $button.appendChild($headingText);
300
+ $button.appendChild(this.getButtonPunctuationEl());
224
301
 
225
302
  // If summary content exists add to DOM in correct order
226
- if (typeof ($summary) !== 'undefined' && $summary !== null) {
303
+ if ($summary) {
227
304
  // Create a new `span` element and copy the summary line content from the original `div` to the
228
305
  // new `span`
229
306
  // This is because the summary line text is now inside a button element, which can only contain
230
307
  // phrasing content
231
- var $summarySpan = document.createElement('span')
308
+ var $summarySpan = document.createElement('span');
232
309
  // Create an inner summary container to limit the width of the summary focus state
233
- var $summarySpanFocus = document.createElement('span')
234
- $summarySpanFocus.classList.add(this.sectionSummaryFocusClass)
235
- $summarySpan.appendChild($summarySpanFocus)
310
+ var $summarySpanFocus = document.createElement('span');
311
+ $summarySpanFocus.classList.add(this.sectionSummaryFocusClass);
312
+ $summarySpan.appendChild($summarySpanFocus);
236
313
 
237
314
  // Get original attributes, and pass them to the replacement
238
315
  for (var j = 0, l = $summary.attributes.length; j < l; ++j) {
239
- var nodeName = $summary.attributes.item(j).nodeName
240
- var nodeValue = $summary.attributes.item(j).nodeValue
241
- $summarySpan.setAttribute(nodeName, nodeValue)
316
+ var nodeName = $summary.attributes.item(j).nodeName;
317
+ var nodeValue = $summary.attributes.item(j).nodeValue;
318
+ $summarySpan.setAttribute(nodeName, nodeValue);
242
319
  }
243
320
 
244
321
  // Copy original contents of summary to the new summary span
245
- $summarySpanFocus.innerHTML = $summary.innerHTML
322
+ $summarySpanFocus.innerHTML = $summary.innerHTML;
246
323
 
247
324
  // Replace the original summary `div` with the new summary `span`
248
- $summary.parentNode.replaceChild($summarySpan, $summary)
325
+ $summary.parentNode.replaceChild($summarySpan, $summary);
249
326
 
250
- $button.appendChild($summarySpan)
251
- $button.appendChild(this.getButtonPunctuationEl())
327
+ $button.appendChild($summarySpan);
328
+ $button.appendChild(this.getButtonPunctuationEl());
252
329
  }
253
330
 
254
- $button.appendChild($showHideToggle)
331
+ $button.appendChild($showHideToggle);
255
332
 
256
- $heading.removeChild($span)
257
- $heading.appendChild($button)
258
- }
333
+ $heading.removeChild($span);
334
+ $heading.appendChild($button);
335
+ };
259
336
 
260
337
  /**
261
338
  * When a section is opened by the user agent via the 'beforematch' event
262
339
  *
340
+ * @deprecated Will be made private in v5.0
263
341
  * @param {Event} event - Generic event
264
342
  */
265
343
  Accordion.prototype.onBeforeMatch = function (event) {
266
- var $section = event.target.closest('.' + this.sectionClass)
344
+ var $fragment = event.target;
345
+
346
+ // Handle elements with `.closest()` support only
347
+ if (!($fragment instanceof Element)) {
348
+ return
349
+ }
350
+
351
+ // Handle when fragment is inside section
352
+ var $section = $fragment.closest('.' + this.sectionClass);
267
353
  if ($section) {
268
- this.setExpanded(true, $section)
354
+ this.setExpanded(true, $section);
269
355
  }
270
- }
356
+ };
271
357
 
272
358
  /**
273
359
  * When section toggled, set and store state
274
360
  *
275
- * @param {HTMLElement} $section - Section element
361
+ * @deprecated Will be made private in v5.0
362
+ * @param {Element} $section - Section element
276
363
  */
277
364
  Accordion.prototype.onSectionToggle = function ($section) {
278
- var expanded = this.isExpanded($section)
279
- this.setExpanded(!expanded, $section)
365
+ var expanded = this.isExpanded($section);
366
+ this.setExpanded(!expanded, $section);
280
367
 
281
368
  // Store the state in sessionStorage when a change is triggered
282
- this.storeState($section)
283
- }
369
+ this.storeState($section);
370
+ };
284
371
 
285
372
  /**
286
373
  * When Open/Close All toggled, set and store state
374
+ *
375
+ * @deprecated Will be made private in v5.0
287
376
  */
288
377
  Accordion.prototype.onShowOrHideAllToggle = function () {
289
- var $module = this
290
- var $sections = this.$sections
291
- var nowExpanded = !this.checkIfAllSectionsOpen()
378
+ var $component = this;
379
+ var $sections = this.$sections;
380
+
381
+ var nowExpanded = !this.checkIfAllSectionsOpen();
292
382
 
383
+ // Loop through sections
293
384
  nodeListForEach($sections, function ($section) {
294
- $module.setExpanded(nowExpanded, $section)
385
+ $component.setExpanded(nowExpanded, $section);
295
386
  // Store the state in sessionStorage when a change is triggered
296
- $module.storeState($section)
297
- })
387
+ $component.storeState($section);
388
+ });
298
389
 
299
- $module.updateShowAllButton(nowExpanded)
300
- }
390
+ $component.updateShowAllButton(nowExpanded);
391
+ };
301
392
 
302
393
  /**
303
394
  * Set section attributes when opened/closed
304
395
  *
396
+ * @deprecated Will be made private in v5.0
305
397
  * @param {boolean} expanded - Section expanded
306
- * @param {HTMLElement} $section - Section element
398
+ * @param {Element} $section - Section element
307
399
  */
308
400
  Accordion.prototype.setExpanded = function (expanded, $section) {
309
- var $showHideIcon = $section.querySelector('.' + this.upChevronIconClass)
310
- var $showHideText = $section.querySelector('.' + this.sectionShowHideTextClass)
311
- var $button = $section.querySelector('.' + this.sectionButtonClass)
312
- var $content = $section.querySelector('.' + this.sectionContentClass)
401
+ var $showHideIcon = $section.querySelector('.' + this.upChevronIconClass);
402
+ var $showHideText = $section.querySelector('.' + this.sectionShowHideTextClass);
403
+ var $button = $section.querySelector('.' + this.sectionButtonClass);
404
+ var $content = $section.querySelector('.' + this.sectionContentClass);
405
+
406
+ if (!$showHideIcon ||
407
+ !($showHideText instanceof HTMLElement) ||
408
+ !$button ||
409
+ !$content) {
410
+ return
411
+ }
313
412
 
314
413
  var newButtonText = expanded
315
414
  ? this.i18n.t('hideSection')
316
- : this.i18n.t('showSection')
415
+ : this.i18n.t('showSection');
317
416
 
318
- $showHideText.innerText = newButtonText
319
- $button.setAttribute('aria-expanded', expanded)
417
+ $showHideText.innerText = newButtonText;
418
+ $button.setAttribute('aria-expanded', expanded.toString());
320
419
 
321
420
  // Update aria-label combining
322
- var ariaLabelParts = []
421
+ var ariaLabelParts = [];
323
422
 
324
- var $headingText = $section.querySelector('.' + this.sectionHeadingTextClass)
325
- if ($headingText) {
326
- ariaLabelParts.push($headingText.innerText.trim())
423
+ var $headingText = $section.querySelector('.' + this.sectionHeadingTextClass);
424
+ if ($headingText instanceof HTMLElement) {
425
+ ariaLabelParts.push($headingText.innerText.trim());
327
426
  }
328
427
 
329
- var $summary = $section.querySelector('.' + this.sectionSummaryClass)
330
- if ($summary) {
331
- ariaLabelParts.push($summary.innerText.trim())
428
+ var $summary = $section.querySelector('.' + this.sectionSummaryClass);
429
+ if ($summary instanceof HTMLElement) {
430
+ ariaLabelParts.push($summary.innerText.trim());
332
431
  }
333
432
 
334
433
  var ariaLabelMessage = expanded
335
434
  ? this.i18n.t('hideSectionAriaLabel')
336
- : this.i18n.t('showSectionAriaLabel')
337
- ariaLabelParts.push(ariaLabelMessage)
435
+ : this.i18n.t('showSectionAriaLabel');
436
+ ariaLabelParts.push(ariaLabelMessage);
338
437
 
339
438
  /*
340
439
  * Join with a comma to add pause for assistive technology.
341
440
  * Example: [heading]Section A ,[pause] Show this section.
342
441
  * https://accessibility.blog.gov.uk/2017/12/18/what-working-on-gov-uk-navigation-taught-us-about-accessibility/
343
442
  */
344
- $button.setAttribute('aria-label', ariaLabelParts.join(' , '))
443
+ $button.setAttribute('aria-label', ariaLabelParts.join(' , '));
345
444
 
346
445
  // Swap icon, change class
347
446
  if (expanded) {
348
- $content.removeAttribute('hidden')
349
- $section.classList.add(this.sectionExpandedClass)
350
- $showHideIcon.classList.remove(this.downChevronIconClass)
447
+ $content.removeAttribute('hidden');
448
+ $section.classList.add(this.sectionExpandedClass);
449
+ $showHideIcon.classList.remove(this.downChevronIconClass);
351
450
  } else {
352
- $content.setAttribute('hidden', 'until-found')
353
- $section.classList.remove(this.sectionExpandedClass)
354
- $showHideIcon.classList.add(this.downChevronIconClass)
451
+ $content.setAttribute('hidden', 'until-found');
452
+ $section.classList.remove(this.sectionExpandedClass);
453
+ $showHideIcon.classList.add(this.downChevronIconClass);
355
454
  }
356
455
 
357
456
  // See if "Show all sections" button text should be updated
358
- var areAllSectionsOpen = this.checkIfAllSectionsOpen()
359
- this.updateShowAllButton(areAllSectionsOpen)
360
- }
457
+ var areAllSectionsOpen = this.checkIfAllSectionsOpen();
458
+ this.updateShowAllButton(areAllSectionsOpen);
459
+ };
361
460
 
362
461
  /**
363
462
  * Get state of section
364
463
  *
365
- * @param {HTMLElement} $section - Section element
464
+ * @deprecated Will be made private in v5.0
465
+ * @param {Element} $section - Section element
366
466
  * @returns {boolean} True if expanded
367
467
  */
368
468
  Accordion.prototype.isExpanded = function ($section) {
369
469
  return $section.classList.contains(this.sectionExpandedClass)
370
- }
470
+ };
371
471
 
372
472
  /**
373
473
  * Check if all sections are open
374
474
  *
475
+ * @deprecated Will be made private in v5.0
375
476
  * @returns {boolean} True if all sections are open
376
477
  */
377
478
  Accordion.prototype.checkIfAllSectionsOpen = function () {
378
479
  // Get a count of all the Accordion sections
379
- var sectionsCount = this.$sections.length
480
+ var sectionsCount = this.$sections.length;
380
481
  // Get a count of all Accordion sections that are expanded
381
- var expandedSectionCount = this.$module.querySelectorAll('.' + this.sectionExpandedClass).length
382
- var areAllSectionsOpen = sectionsCount === expandedSectionCount
482
+ var expandedSectionCount = this.$module.querySelectorAll('.' + this.sectionExpandedClass).length;
483
+ var areAllSectionsOpen = sectionsCount === expandedSectionCount;
383
484
 
384
485
  return areAllSectionsOpen
385
- }
486
+ };
386
487
 
387
488
  /**
388
489
  * Update "Show all sections" button
389
490
  *
491
+ * @deprecated Will be made private in v5.0
390
492
  * @param {boolean} expanded - Section expanded
391
493
  */
392
494
  Accordion.prototype.updateShowAllButton = function (expanded) {
393
495
  var newButtonText = expanded
394
496
  ? this.i18n.t('hideAllSections')
395
- : this.i18n.t('showAllSections')
497
+ : this.i18n.t('showAllSections');
396
498
 
397
- this.$showAllButton.setAttribute('aria-expanded', expanded)
398
- this.$showAllText.innerText = newButtonText
499
+ this.$showAllButton.setAttribute('aria-expanded', expanded.toString());
500
+ this.$showAllText.innerText = newButtonText;
399
501
 
400
502
  // Swap icon, toggle class
401
503
  if (expanded) {
402
- this.$showAllIcon.classList.remove(this.downChevronIconClass)
504
+ this.$showAllIcon.classList.remove(this.downChevronIconClass);
403
505
  } else {
404
- this.$showAllIcon.classList.add(this.downChevronIconClass)
506
+ this.$showAllIcon.classList.add(this.downChevronIconClass);
405
507
  }
406
- }
508
+ };
407
509
 
408
510
  var helper = {
409
511
  /**
@@ -412,62 +514,64 @@ var helper = {
412
514
  * @returns {boolean} True if session storage is available
413
515
  */
414
516
  checkForSessionStorage: function () {
415
- var testString = 'this is the test string'
416
- var result
517
+ var testString = 'this is the test string';
518
+ var result;
417
519
  try {
418
- window.sessionStorage.setItem(testString, testString)
419
- result = window.sessionStorage.getItem(testString) === testString.toString()
420
- window.sessionStorage.removeItem(testString)
520
+ window.sessionStorage.setItem(testString, testString);
521
+ result = window.sessionStorage.getItem(testString) === testString.toString();
522
+ window.sessionStorage.removeItem(testString);
421
523
  return result
422
524
  } catch (exception) {
423
525
  return false
424
526
  }
425
527
  }
426
- }
528
+ };
427
529
 
428
530
  /**
429
531
  * Set the state of the accordions in sessionStorage
430
532
  *
431
- * @param {HTMLElement} $section - Section element
533
+ * @deprecated Will be made private in v5.0
534
+ * @param {Element} $section - Section element
432
535
  */
433
536
  Accordion.prototype.storeState = function ($section) {
434
- if (this.browserSupportsSessionStorage) {
537
+ if (this.browserSupportsSessionStorage && this.config.rememberExpanded) {
435
538
  // We need a unique way of identifying each content in the Accordion. Since
436
539
  // an `#id` should be unique and an `id` is required for `aria-` attributes
437
540
  // `id` can be safely used.
438
- var $button = $section.querySelector('.' + this.sectionButtonClass)
541
+ var $button = $section.querySelector('.' + this.sectionButtonClass);
439
542
 
440
543
  if ($button) {
441
- var contentId = $button.getAttribute('aria-controls')
442
- var contentState = $button.getAttribute('aria-expanded')
544
+ var contentId = $button.getAttribute('aria-controls');
545
+ var contentState = $button.getAttribute('aria-expanded');
443
546
 
444
547
  // Only set the state when both `contentId` and `contentState` are taken from the DOM.
445
548
  if (contentId && contentState) {
446
- window.sessionStorage.setItem(contentId, contentState)
549
+ window.sessionStorage.setItem(contentId, contentState);
447
550
  }
448
551
  }
449
552
  }
450
- }
553
+ };
451
554
 
452
555
  /**
453
556
  * Read the state of the accordions from sessionStorage
454
557
  *
455
- * @param {HTMLElement} $section - Section element
558
+ * @deprecated Will be made private in v5.0
559
+ * @param {Element} $section - Section element
456
560
  */
457
561
  Accordion.prototype.setInitialState = function ($section) {
458
- if (this.browserSupportsSessionStorage) {
459
- var $button = $section.querySelector('.' + this.sectionButtonClass)
562
+ if (this.browserSupportsSessionStorage && this.config.rememberExpanded) {
563
+ var $button = $section.querySelector('.' + this.sectionButtonClass);
460
564
 
461
565
  if ($button) {
462
- var contentId = $button.getAttribute('aria-controls')
463
- var contentState = contentId ? window.sessionStorage.getItem(contentId) : null
566
+ var contentId = $button.getAttribute('aria-controls');
567
+ var contentState = contentId ? window.sessionStorage.getItem(contentId) : null;
464
568
 
465
569
  if (contentState !== null) {
466
- this.setExpanded(contentState === 'true', $section)
570
+ this.setExpanded(contentState === 'true', $section);
467
571
  }
468
572
  }
469
573
  }
470
- }
574
+ };
471
575
 
472
576
  /**
473
577
  * Create an element to improve semantics of the section button with punctuation
@@ -476,22 +580,23 @@ Accordion.prototype.setInitialState = function ($section) {
476
580
  * into thematic chunks.
477
581
  * See https://github.com/alphagov/govuk-frontend/issues/2327#issuecomment-922957442
478
582
  *
479
- * @returns {HTMLElement} DOM element
583
+ * @deprecated Will be made private in v5.0
584
+ * @returns {Element} DOM element
480
585
  */
481
586
  Accordion.prototype.getButtonPunctuationEl = function () {
482
- var $punctuationEl = document.createElement('span')
483
- $punctuationEl.classList.add('govuk-visually-hidden', this.sectionHeadingDividerClass)
484
- $punctuationEl.innerHTML = ', '
587
+ var $punctuationEl = document.createElement('span');
588
+ $punctuationEl.classList.add('govuk-visually-hidden', this.sectionHeadingDividerClass);
589
+ $punctuationEl.innerHTML = ', ';
485
590
  return $punctuationEl
486
- }
487
-
488
- export default Accordion
591
+ };
489
592
 
490
593
  /**
491
594
  * Accordion config
492
595
  *
493
596
  * @typedef {object} AccordionConfig
494
597
  * @property {AccordionTranslations} [i18n = ACCORDION_TRANSLATIONS] - See constant {@link ACCORDION_TRANSLATIONS}
598
+ * @property {boolean} [rememberExpanded] - Whether the expanded and collapsed
599
+ * state of each section is remembered and restored when navigating.
495
600
  */
496
601
 
497
602
  /**
@@ -503,15 +608,18 @@ export default Accordion
503
608
  * the visible text shown on screen, and text to help assistive technology users
504
609
  * for the buttons toggling each section.
505
610
  * @property {string} [hideAllSections] - The text content for the 'Hide all
506
- * sections' button, used when at least one section is expanded.
611
+ * sections' button, used when at least one section is expanded.
507
612
  * @property {string} [hideSection] - The text content for the 'Hide'
508
- * button, used when a section is expanded.
613
+ * button, used when a section is expanded.
509
614
  * @property {string} [hideSectionAriaLabel] - The text content appended to the
510
- * 'Hide' button's accessible name when a section is expanded.
615
+ * 'Hide' button's accessible name when a section is expanded.
511
616
  * @property {string} [showAllSections] - The text content for the 'Show all
512
- * sections' button, used when all sections are collapsed.
617
+ * sections' button, used when all sections are collapsed.
513
618
  * @property {string} [showSection] - The text content for the 'Show'
514
- * button, used when a section is collapsed.
619
+ * button, used when a section is collapsed.
515
620
  * @property {string} [showSectionAriaLabel] - The text content appended to the
516
- * 'Show' button's accessible name when a section is expanded.
621
+ * 'Show' button's accessible name when a section is expanded.
517
622
  */
623
+
624
+ export default Accordion;
625
+ //# sourceMappingURL=components/accordion/accordion.mjs.map