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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +11 -5
- data/app/assets/stylesheets/component_guide/application.scss +37 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +8 -59
- data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +10 -6
- data/app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_brand-colours.scss +24 -0
- data/app/views/govuk_publishing_components/component_guide/example.html.erb +1 -1
- data/app/views/govuk_publishing_components/component_guide/preview.html.erb +1 -1
- data/app/views/govuk_publishing_components/component_guide/show.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +49 -57
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +3 -3
- data/app/views/govuk_publishing_components/components/_metadata.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_share_links.html.erb +6 -2
- data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/docs/metadata.yml +1 -3
- data/app/views/govuk_publishing_components/components/docs/organisation_logo.yml +5 -5
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_related.yml +1 -0
- data/app/views/layouts/govuk_publishing_components/application.html.erb +1 -0
- data/config/locales/cy.yml +1 -1
- data/lib/govuk_publishing_components/app_helpers/asset_helper.rb +4 -0
- data/lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb +1 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/axe-core/axe.d.ts +77 -6
- data/node_modules/axe-core/axe.js +955 -600
- data/node_modules/axe-core/axe.min.js +2 -2
- data/node_modules/axe-core/locales/_template.json +6 -6
- data/node_modules/axe-core/locales/ja.json +91 -11
- data/node_modules/axe-core/package.json +5 -5
- data/node_modules/axe-core/sri-history.json +4 -0
- data/node_modules/govuk-frontend/README.md +4 -5
- data/node_modules/govuk-frontend/govuk/all-ie8.scss +8 -0
- data/node_modules/govuk-frontend/govuk/all.js +738 -258
- data/node_modules/govuk-frontend/govuk/all.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +11 -7
- data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/common/govuk-frontend-version.js +17 -0
- data/node_modules/govuk-frontend/govuk/common/govuk-frontend-version.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/common/index.js +16 -4
- data/node_modules/govuk-frontend/govuk/common/index.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +20 -10
- data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/common.js +16 -4
- data/node_modules/govuk-frontend/govuk/common.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +3 -3
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +234 -86
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +32 -13
- data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +8 -2
- data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +1 -0
- data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/back-link/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/back-link/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +12 -12
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/button/_index.scss +8 -6
- data/node_modules/govuk-frontend/govuk/components/button/button.js +54 -19
- data/node_modules/govuk-frontend/govuk/components/button/button.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/button/fixtures.json +11 -1
- data/node_modules/govuk-frontend/govuk/components/button/macro-options.json +7 -1
- data/node_modules/govuk-frontend/govuk/components/button/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +170 -76
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +24 -24
- data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +3 -3
- data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +6 -6
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +75 -24
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +47 -47
- data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/checkboxes/template.njk +3 -3
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +24 -24
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +26 -26
- data/node_modules/govuk-frontend/govuk/components/date-input/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/date-input/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/details/details.js +39 -13
- data/node_modules/govuk-frontend/govuk/components/details/details.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/details/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +10 -10
- data/node_modules/govuk-frontend/govuk/components/error-message/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +67 -27
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +19 -19
- data/node_modules/govuk-frontend/govuk/components/error-summary/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/fieldset/fixtures.json +19 -19
- data/node_modules/govuk-frontend/govuk/components/fieldset/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +6 -1
- data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +14 -14
- data/node_modules/govuk-frontend/govuk/components/file-upload/macro-options.json +7 -1
- data/node_modules/govuk-frontend/govuk/components/file-upload/template.njk +2 -1
- data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +0 -7
- data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +24 -24
- data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +22 -22
- data/node_modules/govuk-frontend/govuk/components/header/header.js +46 -14
- data/node_modules/govuk-frontend/govuk/components/header/header.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/header/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/hint/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/hint/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/input/_index.scss +15 -3
- data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +54 -41
- data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +7 -1
- data/node_modules/govuk-frontend/govuk/components/input/template.njk +2 -1
- data/node_modules/govuk-frontend/govuk/components/inset-text/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/inset-text/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/label/fixtures.json +6 -6
- data/node_modules/govuk-frontend/govuk/components/label/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/notification-banner/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/notification-banner/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +49 -22
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +16 -16
- data/node_modules/govuk-frontend/govuk/components/pagination/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/panel/fixtures.json +10 -10
- data/node_modules/govuk-frontend/govuk/components/panel/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/phase-banner/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +5 -5
- data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +46 -46
- data/node_modules/govuk-frontend/govuk/components/radios/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js +65 -22
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/radios/template.njk +2 -2
- data/node_modules/govuk-frontend/govuk/components/select/_index.scss +7 -1
- data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +19 -20
- data/node_modules/govuk-frontend/govuk/components/select/macro-options.json +7 -1
- data/node_modules/govuk-frontend/govuk/components/select/template.njk +5 -2
- data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/skip-link/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +41 -13
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +34 -34
- data/node_modules/govuk-frontend/govuk/components/summary-list/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/table/fixtures.json +21 -21
- data/node_modules/govuk-frontend/govuk/components/table/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/tabs/fixtures.json +15 -15
- data/node_modules/govuk-frontend/govuk/components/tabs/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +178 -60
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/tabs/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +18 -18
- data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/tag/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +8 -1
- data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +18 -18
- data/node_modules/govuk-frontend/govuk/components/textarea/macro-options.json +7 -1
- data/node_modules/govuk-frontend/govuk/components/textarea/template.njk +2 -1
- data/node_modules/govuk-frontend/govuk/components/warning-text/fixtures.json +9 -5
- data/node_modules/govuk-frontend/govuk/components/warning-text/macro-options.json +3 -3
- data/node_modules/govuk-frontend/govuk/components/warning-text/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/core/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/core/_govuk-frontend-version.scss +5 -0
- data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +5 -2
- data/node_modules/govuk-frontend/govuk/helpers/_focused.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_font-faces.scss +1 -1
- data/node_modules/govuk-frontend/govuk/i18n.js +38 -30
- data/node_modules/govuk-frontend/govuk/i18n.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/macros/i18n.njk +12 -11
- data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +1 -1
- data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +4 -0
- data/node_modules/govuk-frontend/govuk/settings/_ie8.scss +16 -0
- data/node_modules/govuk-frontend/govuk/settings/_links.scss +5 -1
- data/node_modules/govuk-frontend/govuk/tools/_ie8.scss +38 -2
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js +2 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +2 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js +2 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js +10 -3
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js +4 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +13 -7
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js +2 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +8 -2
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +8 -2
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js +4 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js +10 -3
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js +4 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js +2 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +3 -2
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js +2 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js.map +1 -1
- data/node_modules/govuk-frontend/govuk-esm/all.mjs +81 -60
- data/node_modules/govuk-frontend/govuk-esm/all.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs +12 -8
- data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/common/govuk-frontend-version.mjs +9 -0
- data/node_modules/govuk-frontend/govuk-esm/common/govuk-frontend-version.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/common/index.mjs +44 -29
- data/node_modules/govuk-frontend/govuk-esm/common/index.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs +15 -9
- data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/common.mjs +3 -5
- data/node_modules/govuk-frontend/govuk-esm/common.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +319 -211
- data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +47 -30
- data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +169 -115
- data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +88 -51
- data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +64 -54
- data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +69 -50
- data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +59 -35
- data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +36 -25
- data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +67 -38
- data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +49 -32
- data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +263 -163
- data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/i18n.mjs +68 -57
- data/node_modules/govuk-frontend/govuk-esm/i18n.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/DOMTokenList.mjs +5 -3
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/DOMTokenList.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs +4 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Document.mjs +4 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Document.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.mjs +7 -4
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/closest.mjs +5 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/closest.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs +13 -10
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/matches.mjs +4 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/matches.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.mjs +6 -3
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/previousElementSibling.mjs +6 -3
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/previousElementSibling.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element.mjs +5 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Event.mjs +7 -4
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Event.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/bind.mjs +5 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/bind.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/defineProperty.mjs +4 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/defineProperty.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs +5 -3
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Window.mjs +4 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Window.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +1 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +2 -1
- data/node_modules/govuk-frontend/package.json +3 -2
- metadata +43 -6
- /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_13px.png → dbt_crest_13px.png} +0 -0
- /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_13px_x2.png → dbt_crest_13px_x2.png} +0 -0
- /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_18px.png → dbt_crest_18px.png} +0 -0
- /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
|
-
|
2
|
-
|
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
|
-
|
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 {
|
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
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
this.
|
62
|
-
|
63
|
-
|
64
|
-
this.
|
65
|
-
|
66
|
-
|
67
|
-
this.
|
68
|
-
|
69
|
-
|
70
|
-
this.
|
71
|
-
|
72
|
-
|
73
|
-
this.
|
74
|
-
|
75
|
-
|
76
|
-
this.
|
77
|
-
|
78
|
-
|
79
|
-
this.
|
80
|
-
|
81
|
-
|
82
|
-
this
|
83
|
-
|
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
|
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
|
-
|
143
|
-
|
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
|
-
|
146
|
-
|
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',
|
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
|
-
|
155
|
-
}
|
156
|
-
}
|
226
|
+
$component.setInitialState($section);
|
227
|
+
});
|
228
|
+
};
|
157
229
|
|
158
230
|
/**
|
159
231
|
* Construct section header
|
160
232
|
*
|
161
|
-
* @
|
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 (
|
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 $
|
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
|
-
* @
|
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 $
|
290
|
-
var $sections = this.$sections
|
291
|
-
|
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
|
-
$
|
385
|
+
$component.setExpanded(nowExpanded, $section);
|
295
386
|
// Store the state in sessionStorage when a change is triggered
|
296
|
-
$
|
297
|
-
})
|
387
|
+
$component.storeState($section);
|
388
|
+
});
|
298
389
|
|
299
|
-
$
|
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 {
|
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
|
-
* @
|
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
|
-
* @
|
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
|
-
* @
|
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
|
-
* @
|
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
|
-
*
|
611
|
+
* sections' button, used when at least one section is expanded.
|
507
612
|
* @property {string} [hideSection] - The text content for the 'Hide'
|
508
|
-
*
|
613
|
+
* button, used when a section is expanded.
|
509
614
|
* @property {string} [hideSectionAriaLabel] - The text content appended to the
|
510
|
-
*
|
615
|
+
* 'Hide' button's accessible name when a section is expanded.
|
511
616
|
* @property {string} [showAllSections] - The text content for the 'Show all
|
512
|
-
*
|
617
|
+
* sections' button, used when all sections are collapsed.
|
513
618
|
* @property {string} [showSection] - The text content for the 'Show'
|
514
|
-
*
|
619
|
+
* button, used when a section is collapsed.
|
515
620
|
* @property {string} [showSectionAriaLabel] - The text content appended to the
|
516
|
-
*
|
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
|