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