govuk_publishing_components 35.3.3 → 35.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (266) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/component_guide/application.scss +37 -1
  3. data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +10 -6
  4. data/app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss +2 -2
  5. data/app/views/govuk_publishing_components/component_guide/example.html.erb +1 -1
  6. data/app/views/govuk_publishing_components/component_guide/preview.html.erb +1 -1
  7. data/app/views/govuk_publishing_components/component_guide/show.html.erb +1 -1
  8. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +2 -2
  9. data/app/views/govuk_publishing_components/components/_metadata.html.erb +1 -1
  10. data/app/views/govuk_publishing_components/components/_share_links.html.erb +6 -2
  11. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +1 -1
  12. data/app/views/govuk_publishing_components/components/docs/metadata.yml +1 -3
  13. data/app/views/govuk_publishing_components/components/docs/organisation_logo.yml +5 -5
  14. data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_related.yml +1 -0
  15. data/app/views/layouts/govuk_publishing_components/application.html.erb +1 -0
  16. data/lib/govuk_publishing_components/app_helpers/asset_helper.rb +4 -0
  17. data/lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb +1 -1
  18. data/lib/govuk_publishing_components/version.rb +1 -1
  19. data/node_modules/axe-core/axe.d.ts +77 -6
  20. data/node_modules/axe-core/axe.js +955 -600
  21. data/node_modules/axe-core/axe.min.js +2 -2
  22. data/node_modules/axe-core/locales/_template.json +6 -6
  23. data/node_modules/axe-core/locales/ja.json +91 -11
  24. data/node_modules/axe-core/package.json +5 -5
  25. data/node_modules/axe-core/sri-history.json +4 -0
  26. data/node_modules/govuk-frontend/README.md +4 -5
  27. data/node_modules/govuk-frontend/govuk/all-ie8.scss +8 -0
  28. data/node_modules/govuk-frontend/govuk/all.js +738 -258
  29. data/node_modules/govuk-frontend/govuk/all.js.map +1 -1
  30. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +11 -7
  31. data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js.map +1 -1
  32. data/node_modules/govuk-frontend/govuk/common/govuk-frontend-version.js +17 -0
  33. data/node_modules/govuk-frontend/govuk/common/govuk-frontend-version.js.map +1 -0
  34. data/node_modules/govuk-frontend/govuk/common/index.js +16 -4
  35. data/node_modules/govuk-frontend/govuk/common/index.js.map +1 -1
  36. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +20 -10
  37. data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js.map +1 -1
  38. data/node_modules/govuk-frontend/govuk/common.js +16 -4
  39. data/node_modules/govuk-frontend/govuk/common.js.map +1 -1
  40. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +3 -3
  41. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +234 -86
  42. data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js.map +1 -1
  43. data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +32 -13
  44. data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +8 -2
  45. data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +1 -0
  46. data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +1 -1
  47. data/node_modules/govuk-frontend/govuk/components/back-link/fixtures.json +1 -1
  48. data/node_modules/govuk-frontend/govuk/components/back-link/macro-options.json +1 -1
  49. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +1 -1
  50. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +12 -12
  51. data/node_modules/govuk-frontend/govuk/components/breadcrumbs/macro-options.json +1 -1
  52. data/node_modules/govuk-frontend/govuk/components/button/_index.scss +8 -6
  53. data/node_modules/govuk-frontend/govuk/components/button/button.js +54 -19
  54. data/node_modules/govuk-frontend/govuk/components/button/button.js.map +1 -1
  55. data/node_modules/govuk-frontend/govuk/components/button/fixtures.json +11 -1
  56. data/node_modules/govuk-frontend/govuk/components/button/macro-options.json +7 -1
  57. data/node_modules/govuk-frontend/govuk/components/button/template.njk +1 -1
  58. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +170 -76
  59. data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js.map +1 -1
  60. data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +24 -24
  61. data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +3 -3
  62. data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +6 -6
  63. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +75 -24
  64. data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js.map +1 -1
  65. data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +47 -47
  66. data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +1 -1
  67. data/node_modules/govuk-frontend/govuk/components/checkboxes/template.njk +3 -3
  68. data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +24 -24
  69. data/node_modules/govuk-frontend/govuk/components/cookie-banner/macro-options.json +1 -1
  70. data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +26 -26
  71. data/node_modules/govuk-frontend/govuk/components/date-input/macro-options.json +1 -1
  72. data/node_modules/govuk-frontend/govuk/components/date-input/template.njk +1 -1
  73. data/node_modules/govuk-frontend/govuk/components/details/details.js +39 -13
  74. data/node_modules/govuk-frontend/govuk/components/details/details.js.map +1 -1
  75. data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +1 -1
  76. data/node_modules/govuk-frontend/govuk/components/details/macro-options.json +1 -1
  77. data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +10 -10
  78. data/node_modules/govuk-frontend/govuk/components/error-message/macro-options.json +1 -1
  79. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +67 -27
  80. data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js.map +1 -1
  81. data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +19 -19
  82. data/node_modules/govuk-frontend/govuk/components/error-summary/macro-options.json +1 -1
  83. data/node_modules/govuk-frontend/govuk/components/fieldset/fixtures.json +19 -19
  84. data/node_modules/govuk-frontend/govuk/components/fieldset/macro-options.json +1 -1
  85. data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +6 -1
  86. data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +14 -14
  87. data/node_modules/govuk-frontend/govuk/components/file-upload/macro-options.json +7 -1
  88. data/node_modules/govuk-frontend/govuk/components/file-upload/template.njk +2 -1
  89. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +0 -7
  90. data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +24 -24
  91. data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +1 -1
  92. data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +22 -22
  93. data/node_modules/govuk-frontend/govuk/components/header/header.js +46 -14
  94. data/node_modules/govuk-frontend/govuk/components/header/header.js.map +1 -1
  95. data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +1 -1
  96. data/node_modules/govuk-frontend/govuk/components/header/template.njk +1 -1
  97. data/node_modules/govuk-frontend/govuk/components/hint/fixtures.json +1 -1
  98. data/node_modules/govuk-frontend/govuk/components/hint/macro-options.json +1 -1
  99. data/node_modules/govuk-frontend/govuk/components/input/_index.scss +15 -3
  100. data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +54 -41
  101. data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +7 -1
  102. data/node_modules/govuk-frontend/govuk/components/input/template.njk +2 -1
  103. data/node_modules/govuk-frontend/govuk/components/inset-text/fixtures.json +1 -1
  104. data/node_modules/govuk-frontend/govuk/components/inset-text/macro-options.json +1 -1
  105. data/node_modules/govuk-frontend/govuk/components/label/fixtures.json +6 -6
  106. data/node_modules/govuk-frontend/govuk/components/label/macro-options.json +1 -1
  107. data/node_modules/govuk-frontend/govuk/components/notification-banner/fixtures.json +1 -1
  108. data/node_modules/govuk-frontend/govuk/components/notification-banner/macro-options.json +1 -1
  109. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +49 -22
  110. data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js.map +1 -1
  111. data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +16 -16
  112. data/node_modules/govuk-frontend/govuk/components/pagination/macro-options.json +1 -1
  113. data/node_modules/govuk-frontend/govuk/components/panel/fixtures.json +10 -10
  114. data/node_modules/govuk-frontend/govuk/components/panel/macro-options.json +1 -1
  115. data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +1 -1
  116. data/node_modules/govuk-frontend/govuk/components/phase-banner/macro-options.json +1 -1
  117. data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +5 -5
  118. data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +46 -46
  119. data/node_modules/govuk-frontend/govuk/components/radios/macro-options.json +1 -1
  120. data/node_modules/govuk-frontend/govuk/components/radios/radios.js +65 -22
  121. data/node_modules/govuk-frontend/govuk/components/radios/radios.js.map +1 -1
  122. data/node_modules/govuk-frontend/govuk/components/radios/template.njk +2 -2
  123. data/node_modules/govuk-frontend/govuk/components/select/_index.scss +7 -1
  124. data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +19 -20
  125. data/node_modules/govuk-frontend/govuk/components/select/macro-options.json +7 -1
  126. data/node_modules/govuk-frontend/govuk/components/select/template.njk +5 -2
  127. data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +1 -1
  128. data/node_modules/govuk-frontend/govuk/components/skip-link/macro-options.json +1 -1
  129. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +41 -13
  130. data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js.map +1 -1
  131. data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +34 -34
  132. data/node_modules/govuk-frontend/govuk/components/summary-list/macro-options.json +1 -1
  133. data/node_modules/govuk-frontend/govuk/components/table/fixtures.json +21 -21
  134. data/node_modules/govuk-frontend/govuk/components/table/macro-options.json +1 -1
  135. data/node_modules/govuk-frontend/govuk/components/tabs/fixtures.json +15 -15
  136. data/node_modules/govuk-frontend/govuk/components/tabs/macro-options.json +1 -1
  137. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +178 -60
  138. data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js.map +1 -1
  139. data/node_modules/govuk-frontend/govuk/components/tabs/template.njk +1 -1
  140. data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +18 -18
  141. data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +1 -1
  142. data/node_modules/govuk-frontend/govuk/components/tag/macro-options.json +1 -1
  143. data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +8 -1
  144. data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +18 -18
  145. data/node_modules/govuk-frontend/govuk/components/textarea/macro-options.json +7 -1
  146. data/node_modules/govuk-frontend/govuk/components/textarea/template.njk +2 -1
  147. data/node_modules/govuk-frontend/govuk/components/warning-text/fixtures.json +9 -5
  148. data/node_modules/govuk-frontend/govuk/components/warning-text/macro-options.json +3 -3
  149. data/node_modules/govuk-frontend/govuk/components/warning-text/template.njk +1 -1
  150. data/node_modules/govuk-frontend/govuk/core/_all.scss +1 -0
  151. data/node_modules/govuk-frontend/govuk/core/_govuk-frontend-version.scss +5 -0
  152. data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +5 -2
  153. data/node_modules/govuk-frontend/govuk/helpers/_focused.scss +1 -1
  154. data/node_modules/govuk-frontend/govuk/helpers/_font-faces.scss +1 -1
  155. data/node_modules/govuk-frontend/govuk/i18n.js +38 -30
  156. data/node_modules/govuk-frontend/govuk/i18n.js.map +1 -1
  157. data/node_modules/govuk-frontend/govuk/macros/i18n.njk +12 -11
  158. data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +1 -1
  159. data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +4 -0
  160. data/node_modules/govuk-frontend/govuk/settings/_ie8.scss +16 -0
  161. data/node_modules/govuk-frontend/govuk/settings/_links.scss +5 -1
  162. data/node_modules/govuk-frontend/govuk/tools/_ie8.scss +38 -2
  163. data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js +2 -1
  164. data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js.map +1 -1
  165. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +2 -1
  166. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js.map +1 -1
  167. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js +2 -1
  168. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js.map +1 -1
  169. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js +10 -3
  170. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js.map +1 -1
  171. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js +4 -1
  172. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js.map +1 -1
  173. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +13 -7
  174. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js.map +1 -1
  175. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js +2 -1
  176. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js.map +1 -1
  177. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +8 -2
  178. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js.map +1 -1
  179. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +8 -2
  180. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js.map +1 -1
  181. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js +4 -1
  182. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js.map +1 -1
  183. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js +10 -3
  184. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js.map +1 -1
  185. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js +4 -1
  186. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js.map +1 -1
  187. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js +2 -1
  188. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js.map +1 -1
  189. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +3 -2
  190. data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js.map +1 -1
  191. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js +2 -1
  192. data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js.map +1 -1
  193. data/node_modules/govuk-frontend/govuk-esm/all.mjs +81 -60
  194. data/node_modules/govuk-frontend/govuk-esm/all.mjs.map +1 -0
  195. data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs +12 -8
  196. data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs.map +1 -0
  197. data/node_modules/govuk-frontend/govuk-esm/common/govuk-frontend-version.mjs +9 -0
  198. data/node_modules/govuk-frontend/govuk-esm/common/govuk-frontend-version.mjs.map +1 -0
  199. data/node_modules/govuk-frontend/govuk-esm/common/index.mjs +44 -29
  200. data/node_modules/govuk-frontend/govuk-esm/common/index.mjs.map +1 -0
  201. data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs +15 -9
  202. data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs.map +1 -0
  203. data/node_modules/govuk-frontend/govuk-esm/common.mjs +3 -5
  204. data/node_modules/govuk-frontend/govuk-esm/common.mjs.map +1 -0
  205. data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +319 -211
  206. data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs.map +1 -0
  207. data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +47 -30
  208. data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs.map +1 -0
  209. data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +169 -115
  210. data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs.map +1 -0
  211. data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +88 -51
  212. data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs.map +1 -0
  213. data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +64 -54
  214. data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs.map +1 -0
  215. data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +69 -50
  216. data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs.map +1 -0
  217. data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +59 -35
  218. data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs.map +1 -0
  219. data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +36 -25
  220. data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs.map +1 -0
  221. data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +67 -38
  222. data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs.map +1 -0
  223. data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +49 -32
  224. data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs.map +1 -0
  225. data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +263 -163
  226. data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs.map +1 -0
  227. data/node_modules/govuk-frontend/govuk-esm/i18n.mjs +68 -57
  228. data/node_modules/govuk-frontend/govuk-esm/i18n.mjs.map +1 -0
  229. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/DOMTokenList.mjs +5 -3
  230. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/DOMTokenList.mjs.map +1 -0
  231. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs +4 -2
  232. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs.map +1 -0
  233. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Document.mjs +4 -2
  234. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Document.mjs.map +1 -0
  235. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.mjs +7 -4
  236. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.mjs.map +1 -0
  237. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/closest.mjs +5 -2
  238. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/closest.mjs.map +1 -0
  239. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs +13 -10
  240. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs.map +1 -0
  241. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/matches.mjs +4 -2
  242. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/matches.mjs.map +1 -0
  243. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.mjs +6 -3
  244. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.mjs.map +1 -0
  245. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/previousElementSibling.mjs +6 -3
  246. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/previousElementSibling.mjs.map +1 -0
  247. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element.mjs +5 -2
  248. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element.mjs.map +1 -0
  249. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Event.mjs +7 -4
  250. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Event.mjs.map +1 -0
  251. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/bind.mjs +5 -2
  252. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/bind.mjs.map +1 -0
  253. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/defineProperty.mjs +4 -2
  254. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/defineProperty.mjs.map +1 -0
  255. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs +5 -3
  256. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs.map +1 -0
  257. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Window.mjs +4 -2
  258. data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Window.mjs.map +1 -0
  259. data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +1 -0
  260. data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +2 -1
  261. data/node_modules/govuk-frontend/package.json +3 -2
  262. metadata +43 -6
  263. /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_13px.png → dbt_crest_13px.png} +0 -0
  264. /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_13px_x2.png → dbt_crest_13px_x2.png} +0 -0
  265. /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_18px.png → dbt_crest_18px.png} +0 -0
  266. /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_18px_x2.png → dbt_crest_18px_x2.png} +0 -0
@@ -1,19 +1,31 @@
1
- /* eslint-disable es-x/no-function-prototype-bind -- Polyfill imported */
1
+ import { nodeListForEach } from '../../common/index.mjs';
2
+ import '../../vendor/polyfills/Element/prototype/classList.mjs';
3
+ import '../../vendor/polyfills/Event.mjs';
4
+ import '../../vendor/polyfills/Function/prototype/bind.mjs';
2
5
 
3
- import { nodeListForEach } from '../../common/index.mjs'
4
- import '../../vendor/polyfills/Element/prototype/classList.mjs'
5
- import '../../vendor/polyfills/Event.mjs' // addEventListener, event.target normalization and DOMContentLoaded
6
- import '../../vendor/polyfills/Function/prototype/bind.mjs'
6
+ /* eslint-disable es-x/no-function-prototype-bind -- Polyfill imported */
7
7
 
8
8
  /**
9
9
  * Checkboxes component
10
10
  *
11
11
  * @class
12
- * @param {HTMLElement} $module - HTML element to use for checkboxes
12
+ * @param {Element} $module - HTML element to use for checkboxes
13
13
  */
14
14
  function Checkboxes ($module) {
15
- this.$module = $module
16
- this.$inputs = $module.querySelectorAll('input[type="checkbox"]')
15
+ if (!($module instanceof HTMLElement)) {
16
+ return this
17
+ }
18
+
19
+ var $inputs = $module.querySelectorAll('input[type="checkbox"]');
20
+ if (!$inputs.length) {
21
+ return this
22
+ }
23
+
24
+ /** @deprecated Will be made private in v5.0 */
25
+ this.$module = $module;
26
+
27
+ /** @deprecated Will be made private in v5.0 */
28
+ this.$inputs = $inputs;
17
29
  }
18
30
 
19
31
  /**
@@ -31,11 +43,16 @@ function Checkboxes ($module) {
31
43
  * the reveal in sync with the checkbox state.
32
44
  */
33
45
  Checkboxes.prototype.init = function () {
34
- var $module = this.$module
35
- var $inputs = this.$inputs
46
+ // Check that required elements are present
47
+ if (!this.$module || !this.$inputs) {
48
+ return
49
+ }
50
+
51
+ var $module = this.$module;
52
+ var $inputs = this.$inputs;
36
53
 
37
54
  nodeListForEach($inputs, function ($input) {
38
- var targetId = $input.getAttribute('data-aria-controls')
55
+ var targetId = $input.getAttribute('data-aria-controls');
39
56
 
40
57
  // Skip checkboxes without data-aria-controls attributes, or where the
41
58
  // target element does not exist.
@@ -45,35 +62,36 @@ Checkboxes.prototype.init = function () {
45
62
 
46
63
  // Promote the data-aria-controls attribute to a aria-controls attribute
47
64
  // so that the relationship is exposed in the AOM
48
- $input.setAttribute('aria-controls', targetId)
49
- $input.removeAttribute('data-aria-controls')
50
- })
65
+ $input.setAttribute('aria-controls', targetId);
66
+ $input.removeAttribute('data-aria-controls');
67
+ });
51
68
 
52
69
  // When the page is restored after navigating 'back' in some browsers the
53
70
  // state of form controls is not restored until *after* the DOMContentLoaded
54
71
  // event is fired, so we need to sync after the pageshow event in browsers
55
72
  // that support it.
56
- if ('onpageshow' in window) {
57
- window.addEventListener('pageshow', this.syncAllConditionalReveals.bind(this))
58
- } else {
59
- window.addEventListener('DOMContentLoaded', this.syncAllConditionalReveals.bind(this))
60
- }
73
+ window.addEventListener(
74
+ 'onpageshow' in window ? 'pageshow' : 'DOMContentLoaded',
75
+ this.syncAllConditionalReveals.bind(this)
76
+ );
61
77
 
62
78
  // Although we've set up handlers to sync state on the pageshow or
63
79
  // DOMContentLoaded event, init could be called after those events have fired,
64
80
  // for example if they are added to the page dynamically, so sync now too.
65
- this.syncAllConditionalReveals()
81
+ this.syncAllConditionalReveals();
66
82
 
67
83
  // Handle events
68
- $module.addEventListener('click', this.handleClick.bind(this))
69
- }
84
+ $module.addEventListener('click', this.handleClick.bind(this));
85
+ };
70
86
 
71
87
  /**
72
88
  * Sync the conditional reveal states for all checkboxes in this $module.
89
+ *
90
+ * @deprecated Will be made private in v5.0
73
91
  */
74
92
  Checkboxes.prototype.syncAllConditionalReveals = function () {
75
- nodeListForEach(this.$inputs, this.syncConditionalRevealWithInputState.bind(this))
76
- }
93
+ nodeListForEach(this.$inputs, this.syncConditionalRevealWithInputState.bind(this));
94
+ };
77
95
 
78
96
  /**
79
97
  * Sync conditional reveal with the input state
@@ -81,18 +99,23 @@ Checkboxes.prototype.syncAllConditionalReveals = function () {
81
99
  * Synchronise the visibility of the conditional reveal, and its accessible
82
100
  * state, with the input's checked state.
83
101
  *
102
+ * @deprecated Will be made private in v5.0
84
103
  * @param {HTMLInputElement} $input - Checkbox input
85
104
  */
86
105
  Checkboxes.prototype.syncConditionalRevealWithInputState = function ($input) {
87
- var $target = document.getElementById($input.getAttribute('aria-controls'))
106
+ var targetId = $input.getAttribute('aria-controls');
107
+ if (!targetId) {
108
+ return
109
+ }
88
110
 
111
+ var $target = document.getElementById(targetId);
89
112
  if ($target && $target.classList.contains('govuk-checkboxes__conditional')) {
90
- var inputIsChecked = $input.checked
113
+ var inputIsChecked = $input.checked;
91
114
 
92
- $input.setAttribute('aria-expanded', inputIsChecked)
93
- $target.classList.toggle('govuk-checkboxes__conditional--hidden', !inputIsChecked)
115
+ $input.setAttribute('aria-expanded', inputIsChecked.toString());
116
+ $target.classList.toggle('govuk-checkboxes__conditional--hidden', !inputIsChecked);
94
117
  }
95
- }
118
+ };
96
119
 
97
120
  /**
98
121
  * Uncheck other checkboxes
@@ -100,19 +123,26 @@ Checkboxes.prototype.syncConditionalRevealWithInputState = function ($input) {
100
123
  * Find any other checkbox inputs with the same name value, and uncheck them.
101
124
  * This is useful for when a “None of these" checkbox is checked.
102
125
  *
103
- * @param {HTMLElement} $input - Checkbox input
126
+ * @deprecated Will be made private in v5.0
127
+ * @param {HTMLInputElement} $input - Checkbox input
104
128
  */
105
129
  Checkboxes.prototype.unCheckAllInputsExcept = function ($input) {
106
- var allInputsWithSameName = document.querySelectorAll('input[type="checkbox"][name="' + $input.name + '"]')
130
+ var $component = this;
131
+
132
+ /** @type {NodeListOf<HTMLInputElement>} */
133
+ // @ts-expect-error `NodeListOf<HTMLInputElement>` type expected
134
+ var allInputsWithSameName = document.querySelectorAll(
135
+ 'input[type="checkbox"][name="' + $input.name + '"]'
136
+ );
107
137
 
108
138
  nodeListForEach(allInputsWithSameName, function ($inputWithSameName) {
109
- var hasSameFormOwner = ($input.form === $inputWithSameName.form)
139
+ var hasSameFormOwner = ($input.form === $inputWithSameName.form);
110
140
  if (hasSameFormOwner && $inputWithSameName !== $input) {
111
- $inputWithSameName.checked = false
112
- this.syncConditionalRevealWithInputState($inputWithSameName)
141
+ $inputWithSameName.checked = false;
142
+ $component.syncConditionalRevealWithInputState($inputWithSameName);
113
143
  }
114
- }.bind(this))
115
- }
144
+ });
145
+ };
116
146
 
117
147
  /**
118
148
  * Uncheck exclusive checkboxes
@@ -121,21 +151,26 @@ Checkboxes.prototype.unCheckAllInputsExcept = function ($input) {
121
151
  * and uncheck them. This helps prevent someone checking both a regular checkbox and a
122
152
  * "None of these" checkbox in the same fieldset.
123
153
  *
154
+ * @deprecated Will be made private in v5.0
124
155
  * @param {HTMLInputElement} $input - Checkbox input
125
156
  */
126
157
  Checkboxes.prototype.unCheckExclusiveInputs = function ($input) {
158
+ var $component = this;
159
+
160
+ /** @type {NodeListOf<HTMLInputElement>} */
161
+ // @ts-expect-error `NodeListOf<HTMLInputElement>` type expected
127
162
  var allInputsWithSameNameAndExclusiveBehaviour = document.querySelectorAll(
128
163
  'input[data-behaviour="exclusive"][type="checkbox"][name="' + $input.name + '"]'
129
- )
164
+ );
130
165
 
131
166
  nodeListForEach(allInputsWithSameNameAndExclusiveBehaviour, function ($exclusiveInput) {
132
- var hasSameFormOwner = ($input.form === $exclusiveInput.form)
167
+ var hasSameFormOwner = ($input.form === $exclusiveInput.form);
133
168
  if (hasSameFormOwner) {
134
- $exclusiveInput.checked = false
135
- this.syncConditionalRevealWithInputState($exclusiveInput)
169
+ $exclusiveInput.checked = false;
170
+ $component.syncConditionalRevealWithInputState($exclusiveInput);
136
171
  }
137
- }.bind(this))
138
- }
172
+ });
173
+ };
139
174
 
140
175
  /**
141
176
  * Click event handler
@@ -143,20 +178,21 @@ Checkboxes.prototype.unCheckExclusiveInputs = function ($input) {
143
178
  * Handle a click within the $module – if the click occurred on a checkbox, sync
144
179
  * the state of any associated conditional reveal with the checkbox state.
145
180
  *
181
+ * @deprecated Will be made private in v5.0
146
182
  * @param {MouseEvent} event - Click event
147
183
  */
148
184
  Checkboxes.prototype.handleClick = function (event) {
149
- var $clickedInput = event.target
185
+ var $clickedInput = event.target;
150
186
 
151
187
  // Ignore clicks on things that aren't checkbox inputs
152
- if ($clickedInput.type !== 'checkbox') {
188
+ if (!($clickedInput instanceof HTMLInputElement) || $clickedInput.type !== 'checkbox') {
153
189
  return
154
190
  }
155
191
 
156
192
  // If the checkbox conditionally-reveals some content, sync the state
157
- var hasAriaControls = $clickedInput.getAttribute('aria-controls')
193
+ var hasAriaControls = $clickedInput.getAttribute('aria-controls');
158
194
  if (hasAriaControls) {
159
- this.syncConditionalRevealWithInputState($clickedInput)
195
+ this.syncConditionalRevealWithInputState($clickedInput);
160
196
  }
161
197
 
162
198
  // No further behaviour needed for unchecking
@@ -165,12 +201,13 @@ Checkboxes.prototype.handleClick = function (event) {
165
201
  }
166
202
 
167
203
  // Handle 'exclusive' checkbox behaviour (ie "None of these")
168
- var hasBehaviourExclusive = ($clickedInput.getAttribute('data-behaviour') === 'exclusive')
204
+ var hasBehaviourExclusive = ($clickedInput.getAttribute('data-behaviour') === 'exclusive');
169
205
  if (hasBehaviourExclusive) {
170
- this.unCheckAllInputsExcept($clickedInput)
206
+ this.unCheckAllInputsExcept($clickedInput);
171
207
  } else {
172
- this.unCheckExclusiveInputs($clickedInput)
208
+ this.unCheckExclusiveInputs($clickedInput);
173
209
  }
174
- }
210
+ };
175
211
 
176
- export default Checkboxes
212
+ export default Checkboxes;
213
+ //# sourceMappingURL=components/checkboxes/checkboxes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkboxes.mjs","sources":["../../../../src/govuk/components/checkboxes/checkboxes.mjs"],"sourcesContent":["/* eslint-disable es-x/no-function-prototype-bind -- Polyfill imported */\n\nimport { nodeListForEach } from '../../common/index.mjs'\nimport '../../vendor/polyfills/Element/prototype/classList.mjs'\nimport '../../vendor/polyfills/Event.mjs' // addEventListener, event.target normalization and DOMContentLoaded\nimport '../../vendor/polyfills/Function/prototype/bind.mjs'\n\n/**\n * Checkboxes component\n *\n * @class\n * @param {Element} $module - HTML element to use for checkboxes\n */\nfunction Checkboxes ($module) {\n if (!($module instanceof HTMLElement)) {\n return this\n }\n\n var $inputs = $module.querySelectorAll('input[type=\"checkbox\"]')\n if (!$inputs.length) {\n return this\n }\n\n /** @deprecated Will be made private in v5.0 */\n this.$module = $module\n\n /** @deprecated Will be made private in v5.0 */\n this.$inputs = $inputs\n}\n\n/**\n * Initialise component\n *\n * Checkboxes can be associated with a 'conditionally revealed' content block –\n * for example, a checkbox for 'Phone' could reveal an additional form field for\n * the user to enter their phone number.\n *\n * These associations are made using a `data-aria-controls` attribute, which is\n * promoted to an aria-controls attribute during initialisation.\n *\n * We also need to restore the state of any conditional reveals on the page (for\n * example if the user has navigated back), and set up event handlers to keep\n * the reveal in sync with the checkbox state.\n */\nCheckboxes.prototype.init = function () {\n // Check that required elements are present\n if (!this.$module || !this.$inputs) {\n return\n }\n\n var $module = this.$module\n var $inputs = this.$inputs\n\n nodeListForEach($inputs, function ($input) {\n var targetId = $input.getAttribute('data-aria-controls')\n\n // Skip checkboxes without data-aria-controls attributes, or where the\n // target element does not exist.\n if (!targetId || !document.getElementById(targetId)) {\n return\n }\n\n // Promote the data-aria-controls attribute to a aria-controls attribute\n // so that the relationship is exposed in the AOM\n $input.setAttribute('aria-controls', targetId)\n $input.removeAttribute('data-aria-controls')\n })\n\n // When the page is restored after navigating 'back' in some browsers the\n // state of form controls is not restored until *after* the DOMContentLoaded\n // event is fired, so we need to sync after the pageshow event in browsers\n // that support it.\n window.addEventListener(\n 'onpageshow' in window ? 'pageshow' : 'DOMContentLoaded',\n this.syncAllConditionalReveals.bind(this)\n )\n\n // Although we've set up handlers to sync state on the pageshow or\n // DOMContentLoaded event, init could be called after those events have fired,\n // for example if they are added to the page dynamically, so sync now too.\n this.syncAllConditionalReveals()\n\n // Handle events\n $module.addEventListener('click', this.handleClick.bind(this))\n}\n\n/**\n * Sync the conditional reveal states for all checkboxes in this $module.\n *\n * @deprecated Will be made private in v5.0\n */\nCheckboxes.prototype.syncAllConditionalReveals = function () {\n nodeListForEach(this.$inputs, this.syncConditionalRevealWithInputState.bind(this))\n}\n\n/**\n * Sync conditional reveal with the input state\n *\n * Synchronise the visibility of the conditional reveal, and its accessible\n * state, with the input's checked state.\n *\n * @deprecated Will be made private in v5.0\n * @param {HTMLInputElement} $input - Checkbox input\n */\nCheckboxes.prototype.syncConditionalRevealWithInputState = function ($input) {\n var targetId = $input.getAttribute('aria-controls')\n if (!targetId) {\n return\n }\n\n var $target = document.getElementById(targetId)\n if ($target && $target.classList.contains('govuk-checkboxes__conditional')) {\n var inputIsChecked = $input.checked\n\n $input.setAttribute('aria-expanded', inputIsChecked.toString())\n $target.classList.toggle('govuk-checkboxes__conditional--hidden', !inputIsChecked)\n }\n}\n\n/**\n * Uncheck other checkboxes\n *\n * Find any other checkbox inputs with the same name value, and uncheck them.\n * This is useful for when a “None of these\" checkbox is checked.\n *\n * @deprecated Will be made private in v5.0\n * @param {HTMLInputElement} $input - Checkbox input\n */\nCheckboxes.prototype.unCheckAllInputsExcept = function ($input) {\n var $component = this\n\n /** @type {NodeListOf<HTMLInputElement>} */\n // @ts-expect-error `NodeListOf<HTMLInputElement>` type expected\n var allInputsWithSameName = document.querySelectorAll(\n 'input[type=\"checkbox\"][name=\"' + $input.name + '\"]'\n )\n\n nodeListForEach(allInputsWithSameName, function ($inputWithSameName) {\n var hasSameFormOwner = ($input.form === $inputWithSameName.form)\n if (hasSameFormOwner && $inputWithSameName !== $input) {\n $inputWithSameName.checked = false\n $component.syncConditionalRevealWithInputState($inputWithSameName)\n }\n })\n}\n\n/**\n * Uncheck exclusive checkboxes\n *\n * Find any checkbox inputs with the same name value and the 'exclusive' behaviour,\n * and uncheck them. This helps prevent someone checking both a regular checkbox and a\n * \"None of these\" checkbox in the same fieldset.\n *\n * @deprecated Will be made private in v5.0\n * @param {HTMLInputElement} $input - Checkbox input\n */\nCheckboxes.prototype.unCheckExclusiveInputs = function ($input) {\n var $component = this\n\n /** @type {NodeListOf<HTMLInputElement>} */\n // @ts-expect-error `NodeListOf<HTMLInputElement>` type expected\n var allInputsWithSameNameAndExclusiveBehaviour = document.querySelectorAll(\n 'input[data-behaviour=\"exclusive\"][type=\"checkbox\"][name=\"' + $input.name + '\"]'\n )\n\n nodeListForEach(allInputsWithSameNameAndExclusiveBehaviour, function ($exclusiveInput) {\n var hasSameFormOwner = ($input.form === $exclusiveInput.form)\n if (hasSameFormOwner) {\n $exclusiveInput.checked = false\n $component.syncConditionalRevealWithInputState($exclusiveInput)\n }\n })\n}\n\n/**\n * Click event handler\n *\n * Handle a click within the $module – if the click occurred on a checkbox, sync\n * the state of any associated conditional reveal with the checkbox state.\n *\n * @deprecated Will be made private in v5.0\n * @param {MouseEvent} event - Click event\n */\nCheckboxes.prototype.handleClick = function (event) {\n var $clickedInput = event.target\n\n // Ignore clicks on things that aren't checkbox inputs\n if (!($clickedInput instanceof HTMLInputElement) || $clickedInput.type !== 'checkbox') {\n return\n }\n\n // If the checkbox conditionally-reveals some content, sync the state\n var hasAriaControls = $clickedInput.getAttribute('aria-controls')\n if (hasAriaControls) {\n this.syncConditionalRevealWithInputState($clickedInput)\n }\n\n // No further behaviour needed for unchecking\n if (!$clickedInput.checked) {\n return\n }\n\n // Handle 'exclusive' checkbox behaviour (ie \"None of these\")\n var hasBehaviourExclusive = ($clickedInput.getAttribute('data-behaviour') === 'exclusive')\n if (hasBehaviourExclusive) {\n this.unCheckAllInputsExcept($clickedInput)\n } else {\n this.unCheckExclusiveInputs($clickedInput)\n }\n}\n\nexport default Checkboxes\n"],"names":[],"mappings":";;;;;AAAA;AACA,AAKA;;;;;;;AAOA,SAAS,UAAU,EAAE,OAAO,EAAE;EAC5B,IAAI,EAAE,OAAO,YAAY,WAAW,CAAC,EAAE;IACrC,OAAO,IAAI;GACZ;;EAED,IAAI,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,wBAAwB,EAAC;EAChE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;IACnB,OAAO,IAAI;GACZ;;;EAGD,IAAI,CAAC,OAAO,GAAG,QAAO;;;EAGtB,IAAI,CAAC,OAAO,GAAG,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eAAe,CAAC,OAAO,GAAG,MAAK;MAC/B,UAAU,CAAC,mCAAmC,CAAC,eAAe,EAAC;KAChE;GACF,EAAC;EACH;;;;;;;;;;;AAWD,UAAU,CAAC,SAAS,CAAC,WAAW,GAAG,UAAU,KAAK,EAAE;EAClD,IAAI,aAAa,GAAG,KAAK,CAAC,OAAM;;;EAGhC,IAAI,EAAE,aAAa,YAAY,gBAAgB,CAAC,IAAI,aAAa,CAAC,IAAI,KAAK,UAAU,EAAE;IACrF,MAAM;GACP;;;EAGD,IAAI,eAAe,GAAG,aAAa,CAAC,YAAY,CAAC,eAAe,EAAC;EACjE,IAAI,eAAe,EAAE;IACnB,IAAI,CAAC,mCAAmC,CAAC,aAAa,EAAC;GACxD;;;EAGD,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;IAC1B,MAAM;GACP;;;EAGD,IAAI,qBAAqB,IAAI,aAAa,CAAC,YAAY,CAAC,gBAAgB,CAAC,KAAK,WAAW,EAAC;EAC1F,IAAI,qBAAqB,EAAE;IACzB,IAAI,CAAC,sBAAsB,CAAC,aAAa,EAAC;GAC3C,MAAM;IACL,IAAI,CAAC,sBAAsB,CAAC,aAAa,EAAC;GAC3C;CACF;;;;"}
@@ -1,55 +1,62 @@
1
- /* eslint-disable es-x/no-function-prototype-bind -- Polyfill imported */
1
+ import { generateUniqueID } from '../../common/index.mjs';
2
+ import '../../vendor/polyfills/Event.mjs';
3
+ import '../../vendor/polyfills/Function/prototype/bind.mjs';
2
4
 
3
- /**
4
- * JavaScript 'polyfill' for HTML5's <details> and <summary> elements
5
- * and 'shim' to add accessiblity enhancements for all browsers
6
- *
7
- * http://caniuse.com/#feat=details
8
- */
9
- import { generateUniqueID } from '../../common/index.mjs'
10
- import '../../vendor/polyfills/Event.mjs' // addEventListener, event.target normalization and DOMContentLoaded
11
- import '../../vendor/polyfills/Function/prototype/bind.mjs'
5
+ /* eslint-disable es-x/no-function-prototype-bind -- Polyfill imported */
12
6
 
13
- var KEY_ENTER = 13
14
- var KEY_SPACE = 32
7
+ var KEY_ENTER = 13;
8
+ var KEY_SPACE = 32;
15
9
 
16
10
  /**
17
11
  * Details component
18
12
  *
19
13
  * @class
20
- * @param {HTMLElement} $module - HTML element to use for details
14
+ * @param {Element} $module - HTML element to use for details
21
15
  */
22
16
  function Details ($module) {
23
- this.$module = $module
17
+ if (!($module instanceof HTMLElement)) {
18
+ return this
19
+ }
20
+
21
+ /** @deprecated Will be made private in v5.0 */
22
+ this.$module = $module;
23
+
24
+ /** @deprecated Will be made private in v5.0 */
25
+ this.$summary = null;
26
+
27
+ /** @deprecated Will be made private in v5.0 */
28
+ this.$content = null;
24
29
  }
25
30
 
26
31
  /**
27
32
  * Initialise component
28
33
  */
29
34
  Details.prototype.init = function () {
35
+ // Check that required elements are present
30
36
  if (!this.$module) {
31
37
  return
32
38
  }
33
39
 
34
40
  // If there is native details support, we want to avoid running code to polyfill native behaviour.
35
- var hasNativeDetails = typeof this.$module.open === 'boolean'
41
+ var hasNativeDetails = 'HTMLDetailsElement' in window &&
42
+ this.$module instanceof HTMLDetailsElement;
36
43
 
37
- if (hasNativeDetails) {
38
- return
44
+ if (!hasNativeDetails) {
45
+ this.polyfillDetails();
39
46
  }
40
-
41
- this.polyfillDetails()
42
- }
47
+ };
43
48
 
44
49
  /**
45
50
  * Polyfill component in older browsers
51
+ *
52
+ * @deprecated Will be made private in v5.0
46
53
  */
47
54
  Details.prototype.polyfillDetails = function () {
48
- var $module = this.$module
55
+ var $module = this.$module;
49
56
 
50
57
  // Save shortcuts to the inner summary and content elements
51
- var $summary = this.$summary = $module.getElementsByTagName('summary').item(0)
52
- var $content = this.$content = $module.getElementsByTagName('div').item(0)
58
+ var $summary = this.$summary = $module.getElementsByTagName('summary').item(0);
59
+ var $content = this.$content = $module.getElementsByTagName('div').item(0);
53
60
 
54
61
  // If <details> doesn't have a <summary> and a <div> representing the content
55
62
  // it means the required HTML structure is not met so the script will stop
@@ -60,97 +67,100 @@ Details.prototype.polyfillDetails = function () {
60
67
  // If the content doesn't have an ID, assign it one now
61
68
  // which we'll need for the summary's aria-controls assignment
62
69
  if (!$content.id) {
63
- $content.id = 'details-content-' + generateUniqueID()
70
+ $content.id = 'details-content-' + generateUniqueID();
64
71
  }
65
72
 
66
73
  // Add ARIA role="group" to details
67
- $module.setAttribute('role', 'group')
74
+ $module.setAttribute('role', 'group');
68
75
 
69
76
  // Add role=button to summary
70
- $summary.setAttribute('role', 'button')
77
+ $summary.setAttribute('role', 'button');
71
78
 
72
79
  // Add aria-controls
73
- $summary.setAttribute('aria-controls', $content.id)
80
+ $summary.setAttribute('aria-controls', $content.id);
74
81
 
75
82
  // Set tabIndex so the summary is keyboard accessible for non-native elements
76
83
  //
77
84
  // We have to use the camelcase `tabIndex` property as there is a bug in IE6/IE7 when we set the correct attribute lowercase:
78
85
  // See http://web.archive.org/web/20170120194036/http://www.saliences.com/browserBugs/tabIndex.html for more information.
79
- $summary.tabIndex = 0
86
+ $summary.tabIndex = 0;
80
87
 
81
88
  // Detect initial open state
82
89
  if (this.$module.hasAttribute('open')) {
83
- $summary.setAttribute('aria-expanded', 'true')
90
+ $summary.setAttribute('aria-expanded', 'true');
84
91
  } else {
85
- $summary.setAttribute('aria-expanded', 'false')
86
- $content.style.display = 'none'
92
+ $summary.setAttribute('aria-expanded', 'false');
93
+ $content.style.display = 'none';
87
94
  }
88
95
 
89
96
  // Bind an event to handle summary elements
90
- this.polyfillHandleInputs(this.polyfillSetAttributes.bind(this))
91
- }
97
+ this.polyfillHandleInputs(this.polyfillSetAttributes.bind(this));
98
+ };
92
99
 
93
100
  /**
94
101
  * Define a statechange function that updates aria-expanded and style.display
95
102
  *
103
+ * @deprecated Will be made private in v5.0
96
104
  * @returns {boolean} Returns true
97
105
  */
98
106
  Details.prototype.polyfillSetAttributes = function () {
99
107
  if (this.$module.hasAttribute('open')) {
100
- this.$module.removeAttribute('open')
101
- this.$summary.setAttribute('aria-expanded', 'false')
102
- this.$content.style.display = 'none'
108
+ this.$module.removeAttribute('open');
109
+ this.$summary.setAttribute('aria-expanded', 'false');
110
+ this.$content.style.display = 'none';
103
111
  } else {
104
- this.$module.setAttribute('open', 'open')
105
- this.$summary.setAttribute('aria-expanded', 'true')
106
- this.$content.style.display = ''
112
+ this.$module.setAttribute('open', 'open');
113
+ this.$summary.setAttribute('aria-expanded', 'true');
114
+ this.$content.style.display = '';
107
115
  }
108
116
 
109
117
  return true
110
- }
118
+ };
111
119
 
112
120
  /**
113
121
  * Handle cross-modal click events
114
122
  *
123
+ * @deprecated Will be made private in v5.0
115
124
  * @param {polyfillHandleInputsCallback} callback - function
116
125
  */
117
126
  Details.prototype.polyfillHandleInputs = function (callback) {
118
127
  this.$summary.addEventListener('keypress', function (event) {
119
- var $target = event.target
128
+ var $target = event.target;
120
129
  // When the key gets pressed - check if it is enter or space
121
130
  if (event.keyCode === KEY_ENTER || event.keyCode === KEY_SPACE) {
122
- if ($target.nodeName.toLowerCase() === 'summary') {
131
+ if ($target instanceof HTMLElement && $target.nodeName.toLowerCase() === 'summary') {
123
132
  // Prevent space from scrolling the page
124
133
  // and enter from submitting a form
125
- event.preventDefault()
134
+ event.preventDefault();
126
135
  // Click to let the click event do all the necessary action
127
136
  if ($target.click) {
128
- $target.click()
137
+ $target.click();
129
138
  } else {
130
139
  // except Safari 5.1 and under don't support .click() here
131
- callback(event)
140
+ callback(event);
132
141
  }
133
142
  }
134
143
  }
135
- })
144
+ });
136
145
 
137
146
  // Prevent keyup to prevent clicking twice in Firefox when using space key
138
147
  this.$summary.addEventListener('keyup', function (event) {
139
- var $target = event.target
148
+ var $target = event.target;
140
149
  if (event.keyCode === KEY_SPACE) {
141
- if ($target.nodeName.toLowerCase() === 'summary') {
142
- event.preventDefault()
150
+ if ($target instanceof HTMLElement && $target.nodeName.toLowerCase() === 'summary') {
151
+ event.preventDefault();
143
152
  }
144
153
  }
145
- })
146
-
147
- this.$summary.addEventListener('click', callback)
148
- }
154
+ });
149
155
 
150
- export default Details
156
+ this.$summary.addEventListener('click', callback);
157
+ };
151
158
 
152
159
  /**
153
160
  * @callback polyfillHandleInputsCallback
154
161
  * @param {UIEvent} event - Keyboard or mouse event
155
162
  * @returns {void}
156
163
  */
164
+
165
+ export default Details;
166
+ //# sourceMappingURL=components/details/details.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"details.mjs","sources":["../../../../src/govuk/components/details/details.mjs"],"sourcesContent":["/* eslint-disable es-x/no-function-prototype-bind -- Polyfill imported */\n\n/**\n * JavaScript 'polyfill' for HTML5's <details> and <summary> elements\n * and 'shim' to add accessiblity enhancements for all browsers\n *\n * http://caniuse.com/#feat=details\n */\nimport { generateUniqueID } from '../../common/index.mjs'\nimport '../../vendor/polyfills/Event.mjs' // addEventListener, event.target normalization and DOMContentLoaded\nimport '../../vendor/polyfills/Function/prototype/bind.mjs'\n\nvar KEY_ENTER = 13\nvar KEY_SPACE = 32\n\n/**\n * Details component\n *\n * @class\n * @param {Element} $module - HTML element to use for details\n */\nfunction Details ($module) {\n if (!($module instanceof HTMLElement)) {\n return this\n }\n\n /** @deprecated Will be made private in v5.0 */\n this.$module = $module\n\n /** @deprecated Will be made private in v5.0 */\n this.$summary = null\n\n /** @deprecated Will be made private in v5.0 */\n this.$content = null\n}\n\n/**\n * Initialise component\n */\nDetails.prototype.init = function () {\n // Check that required elements are present\n if (!this.$module) {\n return\n }\n\n // If there is native details support, we want to avoid running code to polyfill native behaviour.\n var hasNativeDetails = 'HTMLDetailsElement' in window &&\n this.$module instanceof HTMLDetailsElement\n\n if (!hasNativeDetails) {\n this.polyfillDetails()\n }\n}\n\n/**\n * Polyfill component in older browsers\n *\n * @deprecated Will be made private in v5.0\n */\nDetails.prototype.polyfillDetails = function () {\n var $module = this.$module\n\n // Save shortcuts to the inner summary and content elements\n var $summary = this.$summary = $module.getElementsByTagName('summary').item(0)\n var $content = this.$content = $module.getElementsByTagName('div').item(0)\n\n // If <details> doesn't have a <summary> and a <div> representing the content\n // it means the required HTML structure is not met so the script will stop\n if (!$summary || !$content) {\n return\n }\n\n // If the content doesn't have an ID, assign it one now\n // which we'll need for the summary's aria-controls assignment\n if (!$content.id) {\n $content.id = 'details-content-' + generateUniqueID()\n }\n\n // Add ARIA role=\"group\" to details\n $module.setAttribute('role', 'group')\n\n // Add role=button to summary\n $summary.setAttribute('role', 'button')\n\n // Add aria-controls\n $summary.setAttribute('aria-controls', $content.id)\n\n // Set tabIndex so the summary is keyboard accessible for non-native elements\n //\n // We have to use the camelcase `tabIndex` property as there is a bug in IE6/IE7 when we set the correct attribute lowercase:\n // See http://web.archive.org/web/20170120194036/http://www.saliences.com/browserBugs/tabIndex.html for more information.\n $summary.tabIndex = 0\n\n // Detect initial open state\n if (this.$module.hasAttribute('open')) {\n $summary.setAttribute('aria-expanded', 'true')\n } else {\n $summary.setAttribute('aria-expanded', 'false')\n $content.style.display = 'none'\n }\n\n // Bind an event to handle summary elements\n this.polyfillHandleInputs(this.polyfillSetAttributes.bind(this))\n}\n\n/**\n * Define a statechange function that updates aria-expanded and style.display\n *\n * @deprecated Will be made private in v5.0\n * @returns {boolean} Returns true\n */\nDetails.prototype.polyfillSetAttributes = function () {\n if (this.$module.hasAttribute('open')) {\n this.$module.removeAttribute('open')\n this.$summary.setAttribute('aria-expanded', 'false')\n this.$content.style.display = 'none'\n } else {\n this.$module.setAttribute('open', 'open')\n this.$summary.setAttribute('aria-expanded', 'true')\n this.$content.style.display = ''\n }\n\n return true\n}\n\n/**\n * Handle cross-modal click events\n *\n * @deprecated Will be made private in v5.0\n * @param {polyfillHandleInputsCallback} callback - function\n */\nDetails.prototype.polyfillHandleInputs = function (callback) {\n this.$summary.addEventListener('keypress', function (event) {\n var $target = event.target\n // When the key gets pressed - check if it is enter or space\n if (event.keyCode === KEY_ENTER || event.keyCode === KEY_SPACE) {\n if ($target instanceof HTMLElement && $target.nodeName.toLowerCase() === 'summary') {\n // Prevent space from scrolling the page\n // and enter from submitting a form\n event.preventDefault()\n // Click to let the click event do all the necessary action\n if ($target.click) {\n $target.click()\n } else {\n // except Safari 5.1 and under don't support .click() here\n callback(event)\n }\n }\n }\n })\n\n // Prevent keyup to prevent clicking twice in Firefox when using space key\n this.$summary.addEventListener('keyup', function (event) {\n var $target = event.target\n if (event.keyCode === KEY_SPACE) {\n if ($target instanceof HTMLElement && $target.nodeName.toLowerCase() === 'summary') {\n event.preventDefault()\n }\n }\n })\n\n this.$summary.addEventListener('click', callback)\n}\n\nexport default Details\n\n/**\n * @callback polyfillHandleInputsCallback\n * @param {UIEvent} event - Keyboard or mouse event\n * @returns {void}\n */\n"],"names":[],"mappings":";;;;AAAA;AACA,AAUA;AACA,IAAI,SAAS,GAAG,GAAE;AAClB,IAAI,SAAS,GAAG,GAAE;;;;;;;;AAQlB,SAAS,OAAO,EAAE,OAAO,EAAE;EACzB,IAAI,EAAE,OAAO,YAAY,WAAW,CAAC,EAAE;IACrC,OAAO,IAAI;GACZ;;;EAGD,IAAI,CAAC,OAAO,GAAG,QAAO;;;EAGtB,IAAI,CAAC,QAAQ,GAAG,KAAI;;;EAGpB,IAAI,CAAC,QAAQ,GAAG,KAAI;CACrB;;;;;AAKD,OAAO,CAAC,SAAS,CAAC,IAAI,GAAG,YAAY;;EAEnC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;IACjB,MAAM;GACP;;;EAGD,IAAI,gBAAgB,GAAG,oBAAoB,IAAI,MAAM;IACnD,IAAI,CAAC,OAAO,YAAY,mBAAkB;;EAE5C,IAAI,CAAC,gBAAgB,EAAE;IACrB,IAAI,CAAC,eAAe,GAAE;GACvB;EACF;;;;;;;AAOD,OAAO,CAAC,SAAS,CAAC,eAAe,GAAG,YAAY;EAC9C,IAAI,OAAO,GAAG,IAAI,CAAC,QAAO;;;EAG1B,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,EAAC;EAC9E,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ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