defra_ruby_template 5.4.1 → 5.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/views/layouts/defra_ruby_template.html.erb +39 -18
- data/lib/defra_ruby_template/version.rb +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +882 -492
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +877 -492
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.mjs +5 -0
- data/node_modules/govuk-frontend/dist/govuk/all.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.scss +6 -0
- data/node_modules/govuk-frontend/dist/govuk/all.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest.svg +1 -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.map +1 -1
- 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 +1 -1
- data/node_modules/govuk-frontend/dist/govuk/common/index.mjs +20 -83
- data/node_modules/govuk-frontend/dist/govuk/common/index.mjs.map +1 -1
- 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/_index.scss +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss +35 -31
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +296 -195
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +295 -194
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs +88 -110
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/fixtures.json +16 -3
- data/node_modules/govuk-frontend/dist/govuk/components/back-link/fixtures.json +25 -15
- data/node_modules/govuk-frontend/dist/govuk/components/back-link/template-with-custom-link.html +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/back-link/template.njk +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/fixtures.json +53 -15
- data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/macro-options.json +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-default.html +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-inverse.html +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-collapse-on-mobile.html +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-last-breadcrumb-as-current-page.html +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-multiple-levels.html +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-with-one-level.html +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template-without-the-home-section.html +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/breadcrumbs/template.njk +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js +217 -106
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs +216 -105
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs +9 -22
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/fixtures.json +38 -0
- data/node_modules/govuk-frontend/dist/govuk/components/button/macro-options.json +2 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/_index.scss +12 -4
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +256 -145
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +255 -144
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +29 -34
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/fixtures.json +80 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/macro-options.json +6 -6
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/template-with-error.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.njk +5 -4
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_index.scss +6 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js +96 -50
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs +95 -49
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs +9 -18
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/fixtures.json +88 -1
- 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/cookie-banner/_index.scss +23 -14
- data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/cookie-banner/fixtures.json +23 -0
- data/node_modules/govuk-frontend/dist/govuk/components/date-input/_index.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/date-input/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/date-input/fixtures.json +27 -0
- data/node_modules/govuk-frontend/dist/govuk/components/date-input/macro-options.json +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss +7 -2
- data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/details/fixtures.json +10 -0
- data/node_modules/govuk-frontend/dist/govuk/components/error-message/fixtures.json +9 -0
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_index.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js +238 -127
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs +237 -126
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs +10 -22
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/fixtures.json +19 -0
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +218 -107
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +217 -106
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs +10 -22
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/fixtures.json +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/fieldset/_index.scss +3 -5
- data/node_modules/govuk-frontend/dist/govuk/components/fieldset/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/fieldset/fixtures.json +18 -0
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss +175 -9
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/_index.scss.map +1 -1
- 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 +220 -16
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/macro-options.json +52 -3
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-allows-direct-media-capture.html +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-allows-image-files-only.html +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-allows-multiple-files.html +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-disabled.html +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-enhanced-disabled.html +13 -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.njk +42 -5
- data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss +61 -19
- data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/footer/fixtures.json +34 -0
- data/node_modules/govuk-frontend/dist/govuk/components/footer/macro-options.json +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/footer/template.njk +10 -0
- data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss +223 -21
- data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/fixtures.json +78 -32
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js +90 -43
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs +89 -42
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs +10 -18
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/macro-options.json +31 -12
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-default.html +20 -12
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-full-width-with-navigation.html +21 -15
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-full-width.html +21 -15
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-navigation-item-with-html.html +20 -12
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-navigation-item-with-text-without-link.html +20 -12
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-custom-menu-button-label.html +20 -12
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-custom-menu-button-text.html +20 -12
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-custom-navigation-label.html +20 -12
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-full-width-border.html +30 -0
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-large-navigation.html +20 -12
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-navigation.html +20 -12
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-product-name.html +21 -15
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-service-name-and-navigation.html +20 -12
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-service-name-but-no-service-url.html +20 -12
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-service-name.html +20 -12
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-st-edwards-crown.html +10 -12
- data/node_modules/govuk-frontend/dist/govuk/components/header/template.njk +11 -41
- data/node_modules/govuk-frontend/dist/govuk/components/hint/fixtures.json +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss +7 -4
- data/node_modules/govuk-frontend/dist/govuk/components/input/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/input/fixtures.json +97 -27
- data/node_modules/govuk-frontend/dist/govuk/components/input/macro-options.json +6 -6
- data/node_modules/govuk-frontend/dist/govuk/components/input/template-default.html +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/input/template-disabled.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 +2 -5
- data/node_modules/govuk-frontend/dist/govuk/components/input/template.njk +5 -4
- data/node_modules/govuk-frontend/dist/govuk/components/inset-text/fixtures.json +6 -0
- data/node_modules/govuk-frontend/dist/govuk/components/label/fixtures.json +17 -0
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss +3 -2
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/fixtures.json +24 -0
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js +238 -127
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs +237 -126
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs +10 -22
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss +24 -37
- data/node_modules/govuk-frontend/dist/govuk/components/pagination/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/pagination/fixtures.json +15 -0
- data/node_modules/govuk-frontend/dist/govuk/components/pagination/macro-options.json +4 -4
- data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss +13 -9
- data/node_modules/govuk-frontend/dist/govuk/components/panel/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/panel/fixtures.json +9 -0
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss +12 -9
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/fixtures.json +27 -2
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/macro-options.json +3 -3
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +220 -110
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +219 -109
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs +12 -25
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/template-default.html +3 -3
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/template.njk +4 -2
- data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss +0 -8
- data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/phase-banner/fixtures.json +7 -0
- data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss +7 -5
- data/node_modules/govuk-frontend/dist/govuk/components/radios/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/fixtures.json +51 -5
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js +96 -50
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs +95 -49
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs +9 -18
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-small-with-a-divider.html +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/template-with-a-divider.html +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss +5 -5
- data/node_modules/govuk-frontend/dist/govuk/components/select/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/select/fixtures.json +43 -9
- data/node_modules/govuk-frontend/dist/govuk/components/select/macro-options.json +2 -2
- data/node_modules/govuk-frontend/dist/govuk/components/select/template-id.html +7 -0
- data/node_modules/govuk-frontend/dist/govuk/components/select/template.njk +6 -4
- 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 +187 -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 +515 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/macro-options.json +138 -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-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-navigation-with-an-active-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 +103 -0
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_index.scss +6 -4
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/fixtures.json +9 -0
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js +95 -48
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs +94 -47
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs +15 -23
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss +14 -22
- data/node_modules/govuk-frontend/dist/govuk/components/summary-list/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/summary-list/fixtures.json +174 -1
- 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/table/fixtures.json +22 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/fixtures.json +15 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js +95 -53
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs +94 -52
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs +15 -28
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tag/_index.scss +11 -8
- data/node_modules/govuk-frontend/dist/govuk/components/tag/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tag/fixtures.json +14 -0
- data/node_modules/govuk-frontend/dist/govuk/components/task-list/_index.scss +12 -10
- data/node_modules/govuk-frontend/dist/govuk/components/task-list/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/task-list/fixtures.json +44 -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.njk +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss +3 -3
- data/node_modules/govuk-frontend/dist/govuk/components/textarea/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/textarea/fixtures.json +32 -1
- data/node_modules/govuk-frontend/dist/govuk/components/textarea/macro-options.json +3 -3
- data/node_modules/govuk-frontend/dist/govuk/components/textarea/template.njk +6 -4
- data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss +6 -5
- data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/warning-text/fixtures.json +8 -0
- data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs +16 -3
- data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css +2 -2
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss +55 -8
- data/node_modules/govuk-frontend/dist/govuk/helpers/_colour.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss +14 -4
- data/node_modules/govuk-frontend/dist/govuk/helpers/_focused.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_grid.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss +2 -2
- data/node_modules/govuk-frontend/dist/govuk/helpers/_links.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_shape-arrow.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_shape-arrow.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss +18 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_typography.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/helpers/_visually-hidden.scss +30 -62
- data/node_modules/govuk-frontend/dist/govuk/helpers/_visually-hidden.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/i18n.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/init.mjs +90 -24
- data/node_modules/govuk-frontend/dist/govuk/init.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/macros/logo.njk +78 -0
- data/node_modules/govuk-frontend/dist/govuk/objects/_template.scss +5 -1
- data/node_modules/govuk-frontend/dist/govuk/objects/_template.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/overrides/_typography.scss +5 -1
- data/node_modules/govuk-frontend/dist/govuk/overrides/_typography.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-applied.scss +39 -1
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-applied.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +244 -10
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss +5 -10
- data/node_modules/govuk-frontend/dist/govuk/settings/_typography-responsive.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/template.njk +20 -9
- data/node_modules/govuk-frontend/dist/govuk/tools/_index.scss +1 -0
- data/node_modules/govuk-frontend/dist/govuk/tools/_index.scss.map +1 -1
- 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-prototype-kit/functions.js +25 -0
- data/node_modules/govuk-frontend/dist/govuk-prototype-kit/init.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk-prototype-kit/init.scss.map +1 -1
- data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +8 -1
- data/node_modules/govuk-frontend/package.json +16 -16
- data/spec/spec_helper.rb +98 -0
- data/spec/tasks/assets_spec.rb +53 -0
- data/vendor/assets/assets/fonts/bold-affa96571d-v2.woff +0 -0
- data/vendor/assets/assets/fonts/bold-b542beb274-v2.woff2 +0 -0
- data/vendor/assets/assets/fonts/light-94a07e06a1-v2.woff2 +0 -0
- data/vendor/assets/assets/fonts/light-f591b13f7d-v2.woff +0 -0
- data/vendor/assets/assets/images/favicon.ico +0 -0
- data/vendor/assets/assets/images/favicon.svg +1 -0
- data/vendor/assets/assets/images/govuk-crest.svg +1 -0
- data/vendor/assets/assets/images/govuk-icon-180.png +0 -0
- data/vendor/assets/assets/images/govuk-icon-192.png +0 -0
- data/vendor/assets/assets/images/govuk-icon-512.png +0 -0
- data/vendor/assets/assets/images/govuk-icon-mask.svg +1 -0
- data/vendor/assets/assets/images/govuk-opengraph-image.png +0 -0
- data/vendor/assets/assets/manifest.json +39 -0
- data/vendor/assets/assets/rebrand/images/favicon.ico +0 -0
- data/vendor/assets/assets/rebrand/images/favicon.svg +1 -0
- data/vendor/assets/assets/rebrand/images/govuk-crest.svg +1 -0
- data/vendor/assets/assets/rebrand/images/govuk-icon-180.png +0 -0
- data/vendor/assets/assets/rebrand/images/govuk-icon-192.png +0 -0
- data/vendor/assets/assets/rebrand/images/govuk-icon-512.png +0 -0
- data/vendor/assets/assets/rebrand/images/govuk-icon-mask.svg +1 -0
- data/vendor/assets/assets/rebrand/images/govuk-opengraph-image.png +0 -0
- data/vendor/assets/assets/rebrand/manifest.json +39 -0
- data/vendor/assets/images/govuk-crest.svg +1 -0
- data/vendor/assets/javascripts/defra_ruby_template.js +882 -492
- data/vendor/assets/stylesheets/all.scss +6 -0
- data/vendor/assets/stylesheets/components/_index.scss +1 -0
- data/vendor/assets/stylesheets/components/accordion/_index.scss +35 -31
- data/vendor/assets/stylesheets/components/character-count/_index.scss +12 -4
- data/vendor/assets/stylesheets/components/checkboxes/_index.scss +6 -1
- data/vendor/assets/stylesheets/components/cookie-banner/_index.scss +23 -14
- data/vendor/assets/stylesheets/components/date-input/_index.scss +2 -2
- data/vendor/assets/stylesheets/components/details/_index.scss +7 -2
- data/vendor/assets/stylesheets/components/error-summary/_index.scss +4 -0
- data/vendor/assets/stylesheets/components/fieldset/_index.scss +3 -5
- data/vendor/assets/stylesheets/components/file-upload/_index.scss +175 -9
- data/vendor/assets/stylesheets/components/footer/_index.scss +61 -19
- data/vendor/assets/stylesheets/components/header/_index.scss +223 -21
- data/vendor/assets/stylesheets/components/input/_index.scss +7 -4
- data/vendor/assets/stylesheets/components/notification-banner/_index.scss +3 -2
- data/vendor/assets/stylesheets/components/pagination/_index.scss +24 -37
- data/vendor/assets/stylesheets/components/panel/_index.scss +13 -9
- data/vendor/assets/stylesheets/components/password-input/_index.scss +12 -9
- data/vendor/assets/stylesheets/components/phase-banner/_index.scss +0 -8
- data/vendor/assets/stylesheets/components/radios/_index.scss +7 -5
- data/vendor/assets/stylesheets/components/select/_index.scss +5 -5
- data/vendor/assets/stylesheets/components/service-navigation/_index.scss +187 -0
- data/vendor/assets/stylesheets/components/service-navigation/_service-navigation.scss +4 -0
- data/vendor/assets/stylesheets/components/skip-link/_index.scss +6 -4
- data/vendor/assets/stylesheets/components/summary-list/_index.scss +14 -22
- data/vendor/assets/stylesheets/components/tag/_index.scss +11 -8
- data/vendor/assets/stylesheets/components/task-list/_index.scss +12 -10
- data/vendor/assets/stylesheets/components/textarea/_index.scss +3 -3
- data/vendor/assets/stylesheets/components/warning-text/_index.scss +6 -5
- data/vendor/assets/stylesheets/core/_govuk-frontend-properties.scss +1 -1
- data/vendor/assets/stylesheets/defra_ruby_template.scss +6 -0
- data/vendor/assets/stylesheets/govuk-frontend.min.css +2 -2
- data/vendor/assets/stylesheets/helpers/_colour.scss +55 -8
- data/vendor/assets/stylesheets/helpers/_focused.scss +14 -4
- data/vendor/assets/stylesheets/helpers/_grid.scss +1 -1
- data/vendor/assets/stylesheets/helpers/_links.scss +2 -2
- data/vendor/assets/stylesheets/helpers/_shape-arrow.scss +1 -1
- data/vendor/assets/stylesheets/helpers/_typography.scss +18 -1
- data/vendor/assets/stylesheets/helpers/_visually-hidden.scss +30 -62
- data/vendor/assets/stylesheets/objects/_template.scss +5 -1
- data/vendor/assets/stylesheets/overrides/_typography.scss +5 -1
- data/vendor/assets/stylesheets/settings/_colours-applied.scss +39 -1
- data/vendor/assets/stylesheets/settings/_colours-organisations.scss +244 -10
- data/vendor/assets/stylesheets/settings/_typography-responsive.scss +5 -10
- data/vendor/assets/stylesheets/tools/_index.scss +1 -0
- data/vendor/assets/stylesheets/tools/_rebrand.scss +65 -0
- metadata +100 -24
- data/.github/dependabot.yml +0 -14
- data/.github/workflows/ci.yml +0 -31
- data/.gitignore +0 -8
- data/.rspec +0 -1
- data/.rubocop.yml +0 -3
- data/.ruby-version +0 -1
- data/Gemfile +0 -9
- data/Gemfile.lock +0 -58
- data/defra_ruby_template.gemspec +0 -35
- data/node_modules/.package-lock.json +0 -16
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest-2x.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/common/normalise-dataset.mjs +0 -18
- data/node_modules/govuk-frontend/dist/govuk/common/normalise-dataset.mjs.map +0 -1
- data/node_modules/govuk-frontend/dist/govuk/common/normalise-string.mjs +0 -31
- data/node_modules/govuk-frontend/dist/govuk/common/normalise-string.mjs.map +0 -1
- data/node_modules/govuk-frontend/dist/govuk/components/file-upload/template-with-value.html +0 -6
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend-component.mjs +0 -16
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend-component.mjs.map +0 -1
- data/package-lock.json +0 -24
- data/package.json +0 -29
@@ -1,7 +1,7 @@
|
|
1
1
|
(function (global, factory) {
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.GOVUKFrontend = {}));
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.GOVUKFrontend = global.GOVUKFrontend || {}));
|
5
5
|
})(this, (function (exports) { 'use strict';
|
6
6
|
|
7
7
|
function getBreakpoint(name) {
|
@@ -12,34 +12,34 @@
|
|
12
12
|
value: value || undefined
|
13
13
|
};
|
14
14
|
}
|
15
|
+
function isInitialised($root, moduleName) {
|
16
|
+
return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
|
17
|
+
}
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Checks if GOV.UK Frontend is supported on this page
|
21
|
+
*
|
22
|
+
* Some browsers will load and run our JavaScript but GOV.UK Frontend
|
23
|
+
* won't be supported.
|
24
|
+
*
|
25
|
+
* @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support
|
26
|
+
* @returns {boolean} Whether GOV.UK Frontend is supported on this page
|
27
|
+
*/
|
15
28
|
function isSupported($scope = document.body) {
|
16
29
|
if (!$scope) {
|
17
30
|
return false;
|
18
31
|
}
|
19
32
|
return $scope.classList.contains('govuk-frontend-supported');
|
20
33
|
}
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
*
|
25
|
-
* @typedef {object} Schema
|
26
|
-
* @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
|
27
|
-
* @property {SchemaCondition[]} [anyOf] - List of schema conditions
|
28
|
-
*/
|
29
|
-
|
34
|
+
function formatErrorMessage(Component, message) {
|
35
|
+
return `${Component.moduleName}: ${message}`;
|
36
|
+
}
|
30
37
|
/**
|
31
|
-
*
|
32
|
-
*
|
33
|
-
* @typedef {object} SchemaProperty
|
34
|
-
* @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
|
38
|
+
* @typedef ComponentWithModuleName
|
39
|
+
* @property {string} moduleName - Name of the component
|
35
40
|
*/
|
36
|
-
|
37
41
|
/**
|
38
|
-
*
|
39
|
-
*
|
40
|
-
* @typedef {object} SchemaCondition
|
41
|
-
* @property {string[]} required - List of required config fields
|
42
|
-
* @property {string} errorMessage - Error message when required config fields not provided
|
42
|
+
* @import { ObjectNested } from './configuration.mjs'
|
43
43
|
*/
|
44
44
|
|
45
45
|
class GOVUKFrontendError extends Error {
|
@@ -65,72 +65,119 @@
|
|
65
65
|
let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
|
66
66
|
if (typeof messageOrOptions === 'object') {
|
67
67
|
const {
|
68
|
-
|
68
|
+
component,
|
69
69
|
identifier,
|
70
70
|
element,
|
71
71
|
expectedType
|
72
72
|
} = messageOrOptions;
|
73
|
-
message =
|
73
|
+
message = identifier;
|
74
74
|
message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
|
75
|
+
message = formatErrorMessage(component, message);
|
75
76
|
}
|
76
77
|
super(message);
|
77
78
|
this.name = 'ElementError';
|
78
79
|
}
|
79
80
|
}
|
81
|
+
class InitError extends GOVUKFrontendError {
|
82
|
+
constructor(componentOrMessage) {
|
83
|
+
const message = typeof componentOrMessage === 'string' ? componentOrMessage : formatErrorMessage(componentOrMessage, `Root element (\`$root\`) already initialised`);
|
84
|
+
super(message);
|
85
|
+
this.name = 'InitError';
|
86
|
+
}
|
87
|
+
}
|
88
|
+
/**
|
89
|
+
* @import { ComponentWithModuleName } from '../common/index.mjs'
|
90
|
+
*/
|
80
91
|
|
81
|
-
class
|
82
|
-
|
83
|
-
|
92
|
+
class Component {
|
93
|
+
/**
|
94
|
+
* Returns the root element of the component
|
95
|
+
*
|
96
|
+
* @protected
|
97
|
+
* @returns {RootElementType} - the root element of component
|
98
|
+
*/
|
99
|
+
get $root() {
|
100
|
+
return this._$root;
|
101
|
+
}
|
102
|
+
constructor($root) {
|
103
|
+
this._$root = void 0;
|
104
|
+
const childConstructor = this.constructor;
|
105
|
+
if (typeof childConstructor.moduleName !== 'string') {
|
106
|
+
throw new InitError(`\`moduleName\` not defined in component`);
|
107
|
+
}
|
108
|
+
if (!($root instanceof childConstructor.elementType)) {
|
109
|
+
throw new ElementError({
|
110
|
+
element: $root,
|
111
|
+
component: childConstructor,
|
112
|
+
identifier: 'Root element (`$root`)',
|
113
|
+
expectedType: childConstructor.elementType.name
|
114
|
+
});
|
115
|
+
} else {
|
116
|
+
this._$root = $root;
|
117
|
+
}
|
118
|
+
childConstructor.checkSupport();
|
119
|
+
this.checkInitialised();
|
120
|
+
const moduleName = childConstructor.moduleName;
|
121
|
+
this.$root.setAttribute(`data-${moduleName}-init`, '');
|
122
|
+
}
|
123
|
+
checkInitialised() {
|
124
|
+
const constructor = this.constructor;
|
125
|
+
const moduleName = constructor.moduleName;
|
126
|
+
if (moduleName && isInitialised(this.$root, moduleName)) {
|
127
|
+
throw new InitError(constructor);
|
128
|
+
}
|
84
129
|
}
|
85
|
-
checkSupport() {
|
130
|
+
static checkSupport() {
|
86
131
|
if (!isSupported()) {
|
87
132
|
throw new SupportError();
|
88
133
|
}
|
89
134
|
}
|
90
135
|
}
|
91
136
|
|
137
|
+
/**
|
138
|
+
* @typedef ChildClass
|
139
|
+
* @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
|
140
|
+
*/
|
141
|
+
|
142
|
+
/**
|
143
|
+
* @typedef {typeof Component & ChildClass} ChildClassConstructor
|
144
|
+
*/
|
145
|
+
Component.elementType = HTMLElement;
|
146
|
+
|
92
147
|
/**
|
93
148
|
* Header component
|
94
149
|
*
|
95
150
|
* @preserve
|
96
151
|
*/
|
97
|
-
class Header extends
|
152
|
+
class Header extends Component {
|
98
153
|
/**
|
99
154
|
* Apply a matchMedia for desktop which will trigger a state sync if the
|
100
155
|
* browser viewport moves between states.
|
101
156
|
*
|
102
|
-
* @param {Element | null} $
|
157
|
+
* @param {Element | null} $root - HTML element to use for header
|
103
158
|
*/
|
104
|
-
constructor($
|
105
|
-
super();
|
106
|
-
this.$module = void 0;
|
159
|
+
constructor($root) {
|
160
|
+
super($root);
|
107
161
|
this.$menuButton = void 0;
|
108
162
|
this.$menu = void 0;
|
109
163
|
this.menuIsOpen = false;
|
110
164
|
this.mql = null;
|
111
|
-
|
112
|
-
throw new ElementError({
|
113
|
-
componentName: 'Header',
|
114
|
-
element: $module,
|
115
|
-
identifier: 'Root element (`$module`)'
|
116
|
-
});
|
117
|
-
}
|
118
|
-
this.$module = $module;
|
119
|
-
const $menuButton = $module.querySelector('.govuk-js-header-toggle');
|
165
|
+
const $menuButton = this.$root.querySelector('.govuk-js-header-toggle');
|
120
166
|
if (!$menuButton) {
|
121
167
|
return this;
|
122
168
|
}
|
169
|
+
this.$root.classList.add('govuk-header--with-js-navigation');
|
123
170
|
const menuId = $menuButton.getAttribute('aria-controls');
|
124
171
|
if (!menuId) {
|
125
172
|
throw new ElementError({
|
126
|
-
|
173
|
+
component: Header,
|
127
174
|
identifier: 'Navigation button (`<button class="govuk-js-header-toggle">`) attribute (`aria-controls`)'
|
128
175
|
});
|
129
176
|
}
|
130
177
|
const $menu = document.getElementById(menuId);
|
131
178
|
if (!$menu) {
|
132
179
|
throw new ElementError({
|
133
|
-
|
180
|
+
component: Header,
|
134
181
|
element: $menu,
|
135
182
|
identifier: `Navigation (\`<ul id="${menuId}">\`)`
|
136
183
|
});
|
@@ -144,7 +191,7 @@
|
|
144
191
|
const breakpoint = getBreakpoint('desktop');
|
145
192
|
if (!breakpoint.value) {
|
146
193
|
throw new ElementError({
|
147
|
-
|
194
|
+
component: Header,
|
148
195
|
identifier: `CSS custom property (\`${breakpoint.property}\`) on pseudo-class \`:root\``
|
149
196
|
});
|
150
197
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"header.bundle.js","sources":["../../../../src/govuk/common/index.mjs","../../../../src/govuk/errors/index.mjs","../../../../src/govuk/govuk-frontend-component.mjs","../../../../src/govuk/components/header/header.mjs"],"sourcesContent":["import { normaliseString } from './normalise-string.mjs'\n\n/**\n * Common helpers which do not require polyfill.\n *\n * IMPORTANT: If a helper require a polyfill, please isolate it in its own module\n * so that the polyfill can be properly tree-shaken and does not burden\n * the components that do not need that helper\n */\n\n/**\n * Config merging function\n *\n * Takes any number of objects and combines them together, with\n * greatest priority on the LAST item passed in.\n *\n * @internal\n * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge\n * @returns {{ [key: string]: unknown }} A merged config object\n */\nexport function mergeConfigs(...configObjects) {\n // Start with an empty object as our base\n /** @type {{ [key: string]: unknown }} */\n const formattedConfigObject = {}\n\n // Loop through each of the passed objects\n for (const configObject of configObjects) {\n for (const key of Object.keys(configObject)) {\n const option = formattedConfigObject[key]\n const override = configObject[key]\n\n // Push their keys one-by-one into formattedConfigObject. Any duplicate\n // keys with object values will be merged, otherwise the new value will\n // override the existing value.\n if (isObject(option) && isObject(override)) {\n // @ts-expect-error Index signature for type 'string' is missing\n formattedConfigObject[key] = mergeConfigs(option, override)\n } else {\n // Apply override\n formattedConfigObject[key] = override\n }\n }\n }\n\n return formattedConfigObject\n}\n\n/**\n * Extracts keys starting with a particular namespace from dataset ('data-*')\n * object, removing the namespace in the process, normalising all values\n *\n * @internal\n * @param {{ schema: Schema }} Component - Component class\n * @param {DOMStringMap} dataset - The object to extract key-value pairs from\n * @param {string} namespace - The namespace to filter keys with\n * @returns {ObjectNested | undefined} Nested object with dot-separated key namespace removed\n */\nexport function extractConfigByNamespace(Component, dataset, namespace) {\n const property = Component.schema.properties[namespace]\n\n // Only extract configs for object schema properties\n if (property?.type !== 'object') {\n return\n }\n\n // Add default empty config\n const newObject = {\n [namespace]: /** @type {ObjectNested} */ ({})\n }\n\n for (const [key, value] of Object.entries(dataset)) {\n /** @type {ObjectNested | ObjectNested[NestedKey]} */\n let current = newObject\n\n // Split the key into parts, using . as our namespace separator\n const keyParts = key.split('.')\n\n /**\n * Create new level per part\n *\n * e.g. 'i18n.textareaDescription.other' becomes\n * `{ i18n: { textareaDescription: { other } } }`\n */\n for (const [index, name] of keyParts.entries()) {\n if (typeof current === 'object') {\n // Drop down to nested object until the last part\n if (index < keyParts.length - 1) {\n // New nested object (optionally) replaces existing value\n if (!isObject(current[name])) {\n current[name] = {}\n }\n\n // Drop down into new or existing nested object\n current = current[name]\n } else if (key !== namespace) {\n // Normalised value (optionally) replaces existing value\n current[name] = normaliseString(value)\n }\n }\n }\n }\n\n return newObject[namespace]\n}\n\n/**\n * Get hash fragment from URL\n *\n * Extract the hash fragment (everything after the hash) from a URL,\n * but not including the hash symbol\n *\n * @private\n * @param {string} url - URL\n * @returns {string | undefined} Fragment from URL, without the hash\n */\nexport function getFragmentFromUrl(url) {\n if (!url.includes('#')) {\n return undefined\n }\n\n return url.split('#').pop()\n}\n\n/**\n * Get GOV.UK Frontend breakpoint value from CSS custom property\n *\n * @private\n * @param {string} name - Breakpoint name\n * @returns {{ property: string, value?: string }} Breakpoint object\n */\nexport function getBreakpoint(name) {\n const property = `--govuk-frontend-breakpoint-${name}`\n\n // Get value from `<html>` with breakpoints on CSS :root\n const value = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(property)\n\n return {\n property,\n value: value || undefined\n }\n}\n\n/**\n * Move focus to element\n *\n * Sets tabindex to -1 to make the element programmatically focusable,\n * but removes it on blur as the element doesn't need to be focused again.\n *\n * @private\n * @template {HTMLElement} FocusElement\n * @param {FocusElement} $element - HTML element\n * @param {object} [options] - Handler options\n * @param {function(this: FocusElement): void} [options.onBeforeFocus] - Callback before focus\n * @param {function(this: FocusElement): void} [options.onBlur] - Callback on blur\n */\nexport function setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute('tabindex')\n\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1')\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener('blur', onBlur, { once: true })\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n options.onBlur?.call($element)\n\n if (!isFocusable) {\n $element.removeAttribute('tabindex')\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener('focus', onFocus, { once: true })\n\n // Focus element\n options.onBeforeFocus?.call($element)\n $element.focus()\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @internal\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nexport function isSupported($scope = document.body) {\n if (!$scope) {\n return false\n }\n\n return $scope.classList.contains('govuk-frontend-supported')\n}\n\n/**\n * Validate component config by schema\n *\n * Follows limited examples in JSON schema for wider support in future\n *\n * {@link https://ajv.js.org/json-schema.html#compound-keywords}\n * {@link https://ajv.js.org/packages/ajv-errors.html#single-message}\n *\n * @internal\n * @param {Schema} schema - Config schema\n * @param {{ [key: string]: unknown }} config - Component config\n * @returns {string[]} List of validation errors\n */\nexport function validateConfig(schema, config) {\n const validationErrors = []\n\n // Check errors for each schema\n for (const [name, conditions] of Object.entries(schema)) {\n const errors = []\n\n // Check errors for each schema condition\n if (Array.isArray(conditions)) {\n for (const { required, errorMessage } of conditions) {\n if (!required.every((key) => !!config[key])) {\n errors.push(errorMessage) // Missing config key value\n }\n }\n\n // Check one condition passes or add errors\n if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {\n validationErrors.push(...errors)\n }\n }\n }\n\n return validationErrors\n}\n\n/**\n * Check for an array\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an array\n */\nfunction isArray(option) {\n return Array.isArray(option)\n}\n\n/**\n * Check for an object\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an object\n */\nfunction isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option)\n}\n\n/**\n * Schema for component config\n *\n * @typedef {object} Schema\n * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties\n * @property {SchemaCondition[]} [anyOf] - List of schema conditions\n */\n\n/**\n * Schema property for component config\n *\n * @typedef {object} SchemaProperty\n * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type\n */\n\n/**\n * Schema condition for component config\n *\n * @typedef {object} SchemaCondition\n * @property {string[]} required - List of required config fields\n * @property {string} errorMessage - Error message when required config fields not provided\n */\n\n/**\n * @internal\n * @typedef {keyof ObjectNested} NestedKey\n * @typedef {{ [key: string]: string | boolean | number | ObjectNested | undefined }} ObjectNested\n */\n","/**\n * GOV.UK Frontend error\n *\n * A base class for `Error`s thrown by GOV.UK Frontend.\n *\n * It is meant to be extended into specific types of errors\n * to be thrown by our code.\n *\n * @example\n * ```js\n * class MissingRootError extends GOVUKFrontendError {\n * // Setting an explicit name is important as extending the class will not\n * // set a new `name` on the subclass. The `name` property is important\n * // to ensure intelligible error names even if the class name gets\n * // mangled by a minifier\n * name = \"MissingRootError\"\n * }\n * ```\n * @abstract\n */\nexport class GOVUKFrontendError extends Error {\n name = 'GOVUKFrontendError'\n}\n\n/**\n * Indicates that GOV.UK Frontend is not supported\n */\nexport class SupportError extends GOVUKFrontendError {\n name = 'SupportError'\n\n /**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n */\n constructor($scope = document.body) {\n const supportMessage =\n 'noModule' in HTMLScriptElement.prototype\n ? 'GOV.UK Frontend initialised without `<body class=\"govuk-frontend-supported\">` from template `<script>` snippet'\n : 'GOV.UK Frontend is not supported in this browser'\n\n super(\n $scope\n ? supportMessage\n : 'GOV.UK Frontend initialised without `<script type=\"module\">`'\n )\n }\n}\n\n/**\n * Indicates that a component has received an illegal configuration\n */\nexport class ConfigError extends GOVUKFrontendError {\n name = 'ConfigError'\n}\n\n/**\n * Indicates an issue with an element (possibly `null` or `undefined`)\n */\nexport class ElementError extends GOVUKFrontendError {\n name = 'ElementError'\n\n /**\n * @internal\n * @overload\n * @param {string} message - Element error message\n */\n\n /**\n * @internal\n * @overload\n * @param {ElementErrorOptions} options - Element error options\n */\n\n /**\n * @internal\n * @param {string | ElementErrorOptions} messageOrOptions - Element error message or options\n */\n constructor(messageOrOptions) {\n let message = typeof messageOrOptions === 'string' ? messageOrOptions : ''\n\n // Build message from options\n if (typeof messageOrOptions === 'object') {\n const { componentName, identifier, element, expectedType } =\n messageOrOptions\n\n // Add prefix and identifier\n message = `${componentName}: ${identifier}`\n\n // Append reason\n message += element\n ? ` is not of type ${expectedType ?? 'HTMLElement'}`\n : ' not found'\n }\n\n super(message)\n }\n}\n\n/**\n * Element error options\n *\n * @internal\n * @typedef {object} ElementErrorOptions\n * @property {string} componentName - The name of the component throwing the error\n * @property {string} identifier - An identifier that'll let the user understand which element has an error. This is whatever makes the most sense\n * @property {Element | null} [element] - The element in error\n * @property {string} [expectedType] - The type that was expected for the identifier\n */\n","import { isSupported } from './common/index.mjs'\nimport { SupportError } from './errors/index.mjs'\n\n/**\n * Base Component class\n *\n * Centralises the behaviours shared by our components\n *\n * @internal\n * @abstract\n */\nexport class GOVUKFrontendComponent {\n /**\n * Constructs a new component, validating that GOV.UK Frontend is supported\n *\n * @internal\n */\n constructor() {\n this.checkSupport()\n }\n\n /**\n * Validates whether GOV.UK Frontend is supported\n *\n * @private\n * @throws {SupportError} when GOV.UK Frontend is not supported\n */\n checkSupport() {\n if (!isSupported()) {\n throw new SupportError()\n }\n }\n}\n","import { getBreakpoint } from '../../common/index.mjs'\nimport { ElementError } from '../../errors/index.mjs'\nimport { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'\n\n/**\n * Header component\n *\n * @preserve\n */\nexport class Header extends GOVUKFrontendComponent {\n /** @private */\n $module\n\n /** @private */\n $menuButton\n\n /** @private */\n $menu\n\n /**\n * Save the opened/closed state for the nav in memory so that we can\n * accurately maintain state when the screen is changed from small to big and\n * back to small\n *\n * @private\n */\n menuIsOpen = false\n\n /**\n * A global const for storing a matchMedia instance which we'll use to detect\n * when a screen size change happens. We rely on it being null if the feature\n * isn't available to initially apply hidden attributes\n *\n * @private\n * @type {MediaQueryList | null}\n */\n mql = null\n\n /**\n * Apply a matchMedia for desktop which will trigger a state sync if the\n * browser viewport moves between states.\n *\n * @param {Element | null} $module - HTML element to use for header\n */\n constructor($module) {\n super()\n\n if (!$module) {\n throw new ElementError({\n componentName: 'Header',\n element: $module,\n identifier: 'Root element (`$module`)'\n })\n }\n\n this.$module = $module\n const $menuButton = $module.querySelector('.govuk-js-header-toggle')\n\n // Headers don't necessarily have a navigation. When they don't, the menu\n // toggle won't be rendered by our macro (or may be omitted when writing\n // plain HTML)\n if (!$menuButton) {\n return this\n }\n\n const menuId = $menuButton.getAttribute('aria-controls')\n if (!menuId) {\n throw new ElementError({\n componentName: 'Header',\n identifier:\n 'Navigation button (`<button class=\"govuk-js-header-toggle\">`) attribute (`aria-controls`)'\n })\n }\n\n const $menu = document.getElementById(menuId)\n if (!$menu) {\n throw new ElementError({\n componentName: 'Header',\n element: $menu,\n identifier: `Navigation (\\`<ul id=\"${menuId}\">\\`)`\n })\n }\n\n this.$menu = $menu\n this.$menuButton = $menuButton\n\n this.setupResponsiveChecks()\n\n this.$menuButton.addEventListener('click', () =>\n this.handleMenuButtonClick()\n )\n }\n\n /**\n * Setup viewport resize check\n *\n * @private\n */\n setupResponsiveChecks() {\n const breakpoint = getBreakpoint('desktop')\n\n if (!breakpoint.value) {\n throw new ElementError({\n componentName: 'Header',\n identifier: `CSS custom property (\\`${breakpoint.property}\\`) on pseudo-class \\`:root\\``\n })\n }\n\n // Media query list for GOV.UK Frontend desktop breakpoint\n this.mql = window.matchMedia(`(min-width: ${breakpoint.value})`)\n\n // MediaQueryList.addEventListener isn't supported by Safari < 14 so we need\n // to be able to fall back to the deprecated MediaQueryList.addListener\n if ('addEventListener' in this.mql) {\n this.mql.addEventListener('change', () => this.checkMode())\n } else {\n // @ts-expect-error Property 'addListener' does not exist\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n this.mql.addListener(() => this.checkMode())\n }\n\n this.checkMode()\n }\n\n /**\n * Sync menu state\n *\n * Uses the global variable menuIsOpen to correctly set the accessible and\n * visual states of the menu and the menu button.\n * Additionally will force the menu to be visible and the menu button to be\n * hidden if the matchMedia is triggered to desktop.\n *\n * @private\n */\n checkMode() {\n if (!this.mql || !this.$menu || !this.$menuButton) {\n return\n }\n\n if (this.mql.matches) {\n this.$menu.removeAttribute('hidden')\n this.$menuButton.setAttribute('hidden', '')\n } else {\n this.$menuButton.removeAttribute('hidden')\n this.$menuButton.setAttribute('aria-expanded', this.menuIsOpen.toString())\n\n if (this.menuIsOpen) {\n this.$menu.removeAttribute('hidden')\n } else {\n this.$menu.setAttribute('hidden', '')\n }\n }\n }\n\n /**\n * Handle menu button click\n *\n * When the menu button is clicked, change the visibility of the menu and then\n * sync the accessibility state and menu button state\n *\n * @private\n */\n handleMenuButtonClick() {\n this.menuIsOpen = !this.menuIsOpen\n this.checkMode()\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-header'\n}\n"],"names":["getBreakpoint","name","property","value","window","getComputedStyle","document","documentElement","getPropertyValue","undefined","isSupported","$scope","body","classList","contains","GOVUKFrontendError","Error","constructor","args","SupportError","supportMessage","HTMLScriptElement","prototype","ElementError","messageOrOptions","message","componentName","identifier","element","expectedType","GOVUKFrontendComponent","checkSupport","Header","$module","$menuButton","$menu","menuIsOpen","mql","querySelector","menuId","getAttribute","getElementById","setupResponsiveChecks","addEventListener","handleMenuButtonClick","breakpoint","matchMedia","checkMode","addListener","matches","removeAttribute","setAttribute","toString","moduleName"],"mappings":";;;;;;EAkIO,SAASA,aAAaA,CAACC,IAAI,EAAE;EAClC,EAAA,MAAMC,QAAQ,GAAI,CAA8BD,4BAAAA,EAAAA,IAAK,CAAC,CAAA,CAAA;EAGtD,EAAA,MAAME,KAAK,GAAGC,MAAM,CACjBC,gBAAgB,CAACC,QAAQ,CAACC,eAAe,CAAC,CAC1CC,gBAAgB,CAACN,QAAQ,CAAC,CAAA;IAE7B,OAAO;MACLA,QAAQ;MACRC,KAAK,EAAEA,KAAK,IAAIM,SAAAA;KACjB,CAAA;EACH,CAAA;EA0D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ACgB,YAAY,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;EACvC,OAAA;EACF,KAAA;EACF,GAAA;EAUAP,EAAAA,qBAAqBA,GAAG;EACtB,IAAA,IAAI,CAACR,UAAU,GAAG,CAAC,IAAI,CAACA,UAAU,CAAA;MAClC,IAAI,CAACW,SAAS,EAAE,CAAA;EAClB,GAAA;EAMF,CAAA;EAlKaf,MAAM,CAiKVqB,UAAU,GAAG,cAAc;;;;;;;;"}
|
1
|
+
{"version":3,"file":"header.bundle.js","sources":["../../../../src/govuk/common/index.mjs","../../../../src/govuk/errors/index.mjs","../../../../src/govuk/component.mjs","../../../../src/govuk/components/header/header.mjs"],"sourcesContent":["/**\n * Common helpers which do not require polyfill.\n *\n * IMPORTANT: If a helper require a polyfill, please isolate it in its own module\n * so that the polyfill can be properly tree-shaken and does not burden\n * the components that do not need that helper\n */\n\n/**\n * Get hash fragment from URL\n *\n * Extract the hash fragment (everything after the hash) from a URL,\n * but not including the hash symbol\n *\n * @private\n * @param {string} url - URL\n * @returns {string | undefined} Fragment from URL, without the hash\n */\nexport function getFragmentFromUrl(url) {\n if (!url.includes('#')) {\n return undefined\n }\n\n return url.split('#').pop()\n}\n\n/**\n * Get GOV.UK Frontend breakpoint value from CSS custom property\n *\n * @private\n * @param {string} name - Breakpoint name\n * @returns {{ property: string, value?: string }} Breakpoint object\n */\nexport function getBreakpoint(name) {\n const property = `--govuk-frontend-breakpoint-${name}`\n\n // Get value from `<html>` with breakpoints on CSS :root\n const value = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(property)\n\n return {\n property,\n value: value || undefined\n }\n}\n\n/**\n * Move focus to element\n *\n * Sets tabindex to -1 to make the element programmatically focusable,\n * but removes it on blur as the element doesn't need to be focused again.\n *\n * @private\n * @template {HTMLElement} FocusElement\n * @param {FocusElement} $element - HTML element\n * @param {object} [options] - Handler options\n * @param {function(this: FocusElement): void} [options.onBeforeFocus] - Callback before focus\n * @param {function(this: FocusElement): void} [options.onBlur] - Callback on blur\n */\nexport function setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute('tabindex')\n\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1')\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener('blur', onBlur, { once: true })\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n options.onBlur?.call($element)\n\n if (!isFocusable) {\n $element.removeAttribute('tabindex')\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener('focus', onFocus, { once: true })\n\n // Focus element\n options.onBeforeFocus?.call($element)\n $element.focus()\n}\n\n/**\n * Checks if component is already initialised\n *\n * @internal\n * @param {Element} $root - HTML element to be checked\n * @param {string} moduleName - name of component module\n * @returns {boolean} Whether component is already initialised\n */\nexport function isInitialised($root, moduleName) {\n return (\n $root instanceof HTMLElement &&\n $root.hasAttribute(`data-${moduleName}-init`)\n )\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nexport function isSupported($scope = document.body) {\n if (!$scope) {\n return false\n }\n\n return $scope.classList.contains('govuk-frontend-supported')\n}\n\n/**\n * Check for an array\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an array\n */\nfunction isArray(option) {\n return Array.isArray(option)\n}\n\n/**\n * Check for an object\n *\n * @internal\n * @template {Partial<Record<keyof ObjectType, unknown>>} [ObjectType=ObjectNested]\n * @param {unknown | ObjectType} option - Option to check\n * @returns {option is ObjectType} Whether the option is an object\n */\nexport function isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option)\n}\n\n/**\n * Format error message\n *\n * @internal\n * @param {ComponentWithModuleName} Component - Component that threw the error\n * @param {string} message - Error message\n * @returns {string} - Formatted error message\n */\nexport function formatErrorMessage(Component, message) {\n return `${Component.moduleName}: ${message}`\n}\n\n/* eslint-disable jsdoc/valid-types --\n * `{new(...args: any[] ): object}` is not recognised as valid\n * https://github.com/gajus/eslint-plugin-jsdoc/issues/145#issuecomment-1308722878\n * https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/131\n **/\n\n/**\n * @typedef ComponentWithModuleName\n * @property {string} moduleName - Name of the component\n */\n\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * @import { ObjectNested } from './configuration.mjs'\n */\n","import { formatErrorMessage } from '../common/index.mjs'\n\n/**\n * GOV.UK Frontend error\n *\n * A base class for `Error`s thrown by GOV.UK Frontend.\n *\n * It is meant to be extended into specific types of errors\n * to be thrown by our code.\n *\n * @example\n * ```js\n * class MissingRootError extends GOVUKFrontendError {\n * // Setting an explicit name is important as extending the class will not\n * // set a new `name` on the subclass. The `name` property is important\n * // to ensure intelligible error names even if the class name gets\n * // mangled by a minifier\n * name = \"MissingRootError\"\n * }\n * ```\n * @virtual\n */\nexport class GOVUKFrontendError extends Error {\n name = 'GOVUKFrontendError'\n}\n\n/**\n * Indicates that GOV.UK Frontend is not supported\n */\nexport class SupportError extends GOVUKFrontendError {\n name = 'SupportError'\n\n /**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n */\n constructor($scope = document.body) {\n const supportMessage =\n 'noModule' in HTMLScriptElement.prototype\n ? 'GOV.UK Frontend initialised without `<body class=\"govuk-frontend-supported\">` from template `<script>` snippet'\n : 'GOV.UK Frontend is not supported in this browser'\n\n super(\n $scope\n ? supportMessage\n : 'GOV.UK Frontend initialised without `<script type=\"module\">`'\n )\n }\n}\n\n/**\n * Indicates that a component has received an illegal configuration\n */\nexport class ConfigError extends GOVUKFrontendError {\n name = 'ConfigError'\n}\n\n/**\n * Indicates an issue with an element (possibly `null` or `undefined`)\n */\nexport class ElementError extends GOVUKFrontendError {\n name = 'ElementError'\n\n /**\n * @internal\n * @overload\n * @param {string} message - Element error message\n */\n\n /**\n * @internal\n * @overload\n * @param {ElementErrorOptions} options - Element error options\n */\n\n /**\n * @internal\n * @param {string | ElementErrorOptions} messageOrOptions - Element error message or options\n */\n constructor(messageOrOptions) {\n let message = typeof messageOrOptions === 'string' ? messageOrOptions : ''\n\n // Build message from options\n if (typeof messageOrOptions === 'object') {\n const { component, identifier, element, expectedType } = messageOrOptions\n\n message = identifier\n\n // Append reason\n message += element\n ? ` is not of type ${expectedType ?? 'HTMLElement'}`\n : ' not found'\n\n message = formatErrorMessage(component, message)\n }\n\n super(message)\n }\n}\n\n/**\n * Indicates that a component is already initialised\n */\nexport class InitError extends GOVUKFrontendError {\n name = 'InitError'\n\n /**\n * @internal\n * @param {ComponentWithModuleName | string} componentOrMessage - name of the component module\n */\n constructor(componentOrMessage) {\n const message =\n typeof componentOrMessage === 'string'\n ? componentOrMessage\n : formatErrorMessage(\n componentOrMessage,\n `Root element (\\`$root\\`) already initialised`\n )\n\n super(message)\n }\n}\n\n/**\n * Element error options\n *\n * @internal\n * @typedef {object} ElementErrorOptions\n * @property {string} identifier - An identifier that'll let the user understand which element has an error. This is whatever makes the most sense\n * @property {Element | null} [element] - The element in error\n * @property {string} [expectedType] - The type that was expected for the identifier\n * @property {ComponentWithModuleName} component - Component throwing the error\n */\n\n/**\n * @import { ComponentWithModuleName } from '../common/index.mjs'\n */\n","import { isInitialised, isSupported } from './common/index.mjs'\nimport { ElementError, InitError, SupportError } from './errors/index.mjs'\n\n/**\n * Base Component class\n *\n * Centralises the behaviours shared by our components\n *\n * @virtual\n * @template {Element} [RootElementType=HTMLElement]\n */\nexport class Component {\n /**\n * @type {typeof Element}\n */\n static elementType = HTMLElement\n\n // allows Typescript user to work around the lack of types\n // in GOVUKFrontend package, Typescript is not aware of $root\n // in components that extend GOVUKFrontendComponent\n /**\n * Returns the root element of the component\n *\n * @protected\n * @returns {RootElementType} - the root element of component\n */\n get $root() {\n return this._$root\n }\n\n /**\n * @protected\n * @type {RootElementType}\n */\n _$root\n\n /**\n * Constructs a new component, validating that GOV.UK Frontend is supported\n *\n * @internal\n * @param {Element | null} [$root] - HTML element to use for component\n */\n constructor($root) {\n const childConstructor = /** @type {ChildClassConstructor} */ (\n this.constructor\n )\n\n // TypeScript does not enforce that inheriting classes will define a `moduleName`\n // (even if we add a `@virtual` `static moduleName` property to this class).\n // While we trust users to do this correctly, we do a little check to provide them\n // a helpful error message.\n //\n // After this, we'll be sure that `childConstructor` has a `moduleName`\n // as expected of the `ChildClassConstructor` we've cast `this.constructor` to.\n if (typeof childConstructor.moduleName !== 'string') {\n throw new InitError(`\\`moduleName\\` not defined in component`)\n }\n\n if (!($root instanceof childConstructor.elementType)) {\n throw new ElementError({\n element: $root,\n component: childConstructor,\n identifier: 'Root element (`$root`)',\n expectedType: childConstructor.elementType.name\n })\n } else {\n this._$root = /** @type {RootElementType} */ ($root)\n }\n\n childConstructor.checkSupport()\n\n this.checkInitialised()\n\n const moduleName = childConstructor.moduleName\n\n this.$root.setAttribute(`data-${moduleName}-init`, '')\n }\n\n /**\n * Validates whether component is already initialised\n *\n * @private\n * @throws {InitError} when component is already initialised\n */\n checkInitialised() {\n const constructor = /** @type {ChildClassConstructor} */ (this.constructor)\n const moduleName = constructor.moduleName\n\n if (moduleName && isInitialised(this.$root, moduleName)) {\n throw new InitError(constructor)\n }\n }\n\n /**\n * Validates whether components are supported\n *\n * @throws {SupportError} when the components are not supported\n */\n static checkSupport() {\n if (!isSupported()) {\n throw new SupportError()\n }\n }\n}\n\n/**\n * @typedef ChildClass\n * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component\n */\n\n/**\n * @typedef {typeof Component & ChildClass} ChildClassConstructor\n */\n","import { getBreakpoint } from '../../common/index.mjs'\nimport { Component } from '../../component.mjs'\nimport { ElementError } from '../../errors/index.mjs'\n\n/**\n * Header component\n *\n * @preserve\n */\nexport class Header extends Component {\n /** @private */\n $menuButton\n\n /** @private */\n $menu\n\n /**\n * Save the opened/closed state for the nav in memory so that we can\n * accurately maintain state when the screen is changed from small to big and\n * back to small\n *\n * @private\n */\n menuIsOpen = false\n\n /**\n * A global const for storing a matchMedia instance which we'll use to detect\n * when a screen size change happens. We rely on it being null if the feature\n * isn't available to initially apply hidden attributes\n *\n * @private\n * @type {MediaQueryList | null}\n */\n mql = null\n\n /**\n * Apply a matchMedia for desktop which will trigger a state sync if the\n * browser viewport moves between states.\n *\n * @param {Element | null} $root - HTML element to use for header\n */\n constructor($root) {\n super($root)\n\n const $menuButton = this.$root.querySelector('.govuk-js-header-toggle')\n\n // Headers don't necessarily have a navigation. When they don't, the menu\n // toggle won't be rendered by our macro (or may be omitted when writing\n // plain HTML)\n if (!$menuButton) {\n return this\n }\n\n // Pad the header logo so it doesn't overlap the menu button\n this.$root.classList.add('govuk-header--with-js-navigation')\n\n const menuId = $menuButton.getAttribute('aria-controls')\n if (!menuId) {\n throw new ElementError({\n component: Header,\n identifier:\n 'Navigation button (`<button class=\"govuk-js-header-toggle\">`) attribute (`aria-controls`)'\n })\n }\n\n const $menu = document.getElementById(menuId)\n if (!$menu) {\n throw new ElementError({\n component: Header,\n element: $menu,\n identifier: `Navigation (\\`<ul id=\"${menuId}\">\\`)`\n })\n }\n\n this.$menu = $menu\n this.$menuButton = $menuButton\n\n this.setupResponsiveChecks()\n\n this.$menuButton.addEventListener('click', () =>\n this.handleMenuButtonClick()\n )\n }\n\n /**\n * Setup viewport resize check\n *\n * @private\n */\n setupResponsiveChecks() {\n const breakpoint = getBreakpoint('desktop')\n\n if (!breakpoint.value) {\n throw new ElementError({\n component: Header,\n identifier: `CSS custom property (\\`${breakpoint.property}\\`) on pseudo-class \\`:root\\``\n })\n }\n\n // Media query list for GOV.UK Frontend desktop breakpoint\n this.mql = window.matchMedia(`(min-width: ${breakpoint.value})`)\n\n // MediaQueryList.addEventListener isn't supported by Safari < 14 so we need\n // to be able to fall back to the deprecated MediaQueryList.addListener\n if ('addEventListener' in this.mql) {\n this.mql.addEventListener('change', () => this.checkMode())\n } else {\n // @ts-expect-error Property 'addListener' does not exist\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n this.mql.addListener(() => this.checkMode())\n }\n\n this.checkMode()\n }\n\n /**\n * Sync menu state\n *\n * Uses the global variable menuIsOpen to correctly set the accessible and\n * visual states of the menu and the menu button.\n * Additionally will force the menu to be visible and the menu button to be\n * hidden if the matchMedia is triggered to desktop.\n *\n * @private\n */\n checkMode() {\n if (!this.mql || !this.$menu || !this.$menuButton) {\n return\n }\n\n if (this.mql.matches) {\n this.$menu.removeAttribute('hidden')\n this.$menuButton.setAttribute('hidden', '')\n } else {\n this.$menuButton.removeAttribute('hidden')\n this.$menuButton.setAttribute('aria-expanded', this.menuIsOpen.toString())\n\n if (this.menuIsOpen) {\n this.$menu.removeAttribute('hidden')\n } else {\n this.$menu.setAttribute('hidden', '')\n }\n }\n }\n\n /**\n * Handle menu button click\n *\n * When the menu button is clicked, change the visibility of the menu and then\n * sync the accessibility state and menu button state\n *\n * @private\n */\n handleMenuButtonClick() {\n this.menuIsOpen = !this.menuIsOpen\n this.checkMode()\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-header'\n}\n"],"names":["getBreakpoint","name","property","value","window","getComputedStyle","document","documentElement","getPropertyValue","undefined","isInitialised","$root","moduleName","HTMLElement","hasAttribute","isSupported","$scope","body","classList","contains","formatErrorMessage","Component","message","GOVUKFrontendError","Error","constructor","args","SupportError","supportMessage","HTMLScriptElement","prototype","ElementError","messageOrOptions","component","identifier","element","expectedType","InitError","componentOrMessage","_$root","childConstructor","elementType","checkSupport","checkInitialised","setAttribute","Header","$menuButton","$menu","menuIsOpen","mql","querySelector","add","menuId","getAttribute","getElementById","setupResponsiveChecks","addEventListener","handleMenuButtonClick","breakpoint","matchMedia","checkMode","addListener","matches","removeAttribute","toString"],"mappings":";;;;;;EAiCO,SAASA,aAAaA,CAACC,IAAI,EAAE;EAClC,EAAA,MAAMC,QAAQ,GAAG,CAA+BD,4BAAAA,EAAAA,IA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,eAAe,EAAE,IAAI,CAACI,UAAU,CAACgB,QAAQ,EAAE,CAAC;QAE1E,IAAI,IAAI,CAAChB,UAAU,EAAE;EACnB,QAAA,IAAI,CAACD,KAAK,CAACgB,eAAe,CAAC,QAAQ,CAAC;EACtC,OAAC,MAAM;UACL,IAAI,CAAChB,KAAK,CAACH,YAAY,CAAC,QAAQ,EAAE,EAAE,CAAC;EACvC;EACF;EACF;EAUAa,EAAAA,qBAAqBA,GAAG;EACtB,IAAA,IAAI,CAACT,UAAU,GAAG,CAAC,IAAI,CAACA,UAAU;MAClC,IAAI,CAACY,SAAS,EAAE;EAClB;EAMF;EAzJaf,MAAM,CAwJVjC,UAAU,GAAG,cAAc;;;;;;;;"}
|
@@ -6,34 +6,34 @@ function getBreakpoint(name) {
|
|
6
6
|
value: value || undefined
|
7
7
|
};
|
8
8
|
}
|
9
|
+
function isInitialised($root, moduleName) {
|
10
|
+
return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
|
11
|
+
}
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Checks if GOV.UK Frontend is supported on this page
|
15
|
+
*
|
16
|
+
* Some browsers will load and run our JavaScript but GOV.UK Frontend
|
17
|
+
* won't be supported.
|
18
|
+
*
|
19
|
+
* @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support
|
20
|
+
* @returns {boolean} Whether GOV.UK Frontend is supported on this page
|
21
|
+
*/
|
9
22
|
function isSupported($scope = document.body) {
|
10
23
|
if (!$scope) {
|
11
24
|
return false;
|
12
25
|
}
|
13
26
|
return $scope.classList.contains('govuk-frontend-supported');
|
14
27
|
}
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
*
|
19
|
-
* @typedef {object} Schema
|
20
|
-
* @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
|
21
|
-
* @property {SchemaCondition[]} [anyOf] - List of schema conditions
|
22
|
-
*/
|
23
|
-
|
28
|
+
function formatErrorMessage(Component, message) {
|
29
|
+
return `${Component.moduleName}: ${message}`;
|
30
|
+
}
|
24
31
|
/**
|
25
|
-
*
|
26
|
-
*
|
27
|
-
* @typedef {object} SchemaProperty
|
28
|
-
* @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
|
32
|
+
* @typedef ComponentWithModuleName
|
33
|
+
* @property {string} moduleName - Name of the component
|
29
34
|
*/
|
30
|
-
|
31
35
|
/**
|
32
|
-
*
|
33
|
-
*
|
34
|
-
* @typedef {object} SchemaCondition
|
35
|
-
* @property {string[]} required - List of required config fields
|
36
|
-
* @property {string} errorMessage - Error message when required config fields not provided
|
36
|
+
* @import { ObjectNested } from './configuration.mjs'
|
37
37
|
*/
|
38
38
|
|
39
39
|
class GOVUKFrontendError extends Error {
|
@@ -59,72 +59,119 @@ class ElementError extends GOVUKFrontendError {
|
|
59
59
|
let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
|
60
60
|
if (typeof messageOrOptions === 'object') {
|
61
61
|
const {
|
62
|
-
|
62
|
+
component,
|
63
63
|
identifier,
|
64
64
|
element,
|
65
65
|
expectedType
|
66
66
|
} = messageOrOptions;
|
67
|
-
message =
|
67
|
+
message = identifier;
|
68
68
|
message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
|
69
|
+
message = formatErrorMessage(component, message);
|
69
70
|
}
|
70
71
|
super(message);
|
71
72
|
this.name = 'ElementError';
|
72
73
|
}
|
73
74
|
}
|
75
|
+
class InitError extends GOVUKFrontendError {
|
76
|
+
constructor(componentOrMessage) {
|
77
|
+
const message = typeof componentOrMessage === 'string' ? componentOrMessage : formatErrorMessage(componentOrMessage, `Root element (\`$root\`) already initialised`);
|
78
|
+
super(message);
|
79
|
+
this.name = 'InitError';
|
80
|
+
}
|
81
|
+
}
|
82
|
+
/**
|
83
|
+
* @import { ComponentWithModuleName } from '../common/index.mjs'
|
84
|
+
*/
|
74
85
|
|
75
|
-
class
|
76
|
-
|
77
|
-
|
86
|
+
class Component {
|
87
|
+
/**
|
88
|
+
* Returns the root element of the component
|
89
|
+
*
|
90
|
+
* @protected
|
91
|
+
* @returns {RootElementType} - the root element of component
|
92
|
+
*/
|
93
|
+
get $root() {
|
94
|
+
return this._$root;
|
95
|
+
}
|
96
|
+
constructor($root) {
|
97
|
+
this._$root = void 0;
|
98
|
+
const childConstructor = this.constructor;
|
99
|
+
if (typeof childConstructor.moduleName !== 'string') {
|
100
|
+
throw new InitError(`\`moduleName\` not defined in component`);
|
101
|
+
}
|
102
|
+
if (!($root instanceof childConstructor.elementType)) {
|
103
|
+
throw new ElementError({
|
104
|
+
element: $root,
|
105
|
+
component: childConstructor,
|
106
|
+
identifier: 'Root element (`$root`)',
|
107
|
+
expectedType: childConstructor.elementType.name
|
108
|
+
});
|
109
|
+
} else {
|
110
|
+
this._$root = $root;
|
111
|
+
}
|
112
|
+
childConstructor.checkSupport();
|
113
|
+
this.checkInitialised();
|
114
|
+
const moduleName = childConstructor.moduleName;
|
115
|
+
this.$root.setAttribute(`data-${moduleName}-init`, '');
|
116
|
+
}
|
117
|
+
checkInitialised() {
|
118
|
+
const constructor = this.constructor;
|
119
|
+
const moduleName = constructor.moduleName;
|
120
|
+
if (moduleName && isInitialised(this.$root, moduleName)) {
|
121
|
+
throw new InitError(constructor);
|
122
|
+
}
|
78
123
|
}
|
79
|
-
checkSupport() {
|
124
|
+
static checkSupport() {
|
80
125
|
if (!isSupported()) {
|
81
126
|
throw new SupportError();
|
82
127
|
}
|
83
128
|
}
|
84
129
|
}
|
85
130
|
|
131
|
+
/**
|
132
|
+
* @typedef ChildClass
|
133
|
+
* @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
|
134
|
+
*/
|
135
|
+
|
136
|
+
/**
|
137
|
+
* @typedef {typeof Component & ChildClass} ChildClassConstructor
|
138
|
+
*/
|
139
|
+
Component.elementType = HTMLElement;
|
140
|
+
|
86
141
|
/**
|
87
142
|
* Header component
|
88
143
|
*
|
89
144
|
* @preserve
|
90
145
|
*/
|
91
|
-
class Header extends
|
146
|
+
class Header extends Component {
|
92
147
|
/**
|
93
148
|
* Apply a matchMedia for desktop which will trigger a state sync if the
|
94
149
|
* browser viewport moves between states.
|
95
150
|
*
|
96
|
-
* @param {Element | null} $
|
151
|
+
* @param {Element | null} $root - HTML element to use for header
|
97
152
|
*/
|
98
|
-
constructor($
|
99
|
-
super();
|
100
|
-
this.$module = void 0;
|
153
|
+
constructor($root) {
|
154
|
+
super($root);
|
101
155
|
this.$menuButton = void 0;
|
102
156
|
this.$menu = void 0;
|
103
157
|
this.menuIsOpen = false;
|
104
158
|
this.mql = null;
|
105
|
-
|
106
|
-
throw new ElementError({
|
107
|
-
componentName: 'Header',
|
108
|
-
element: $module,
|
109
|
-
identifier: 'Root element (`$module`)'
|
110
|
-
});
|
111
|
-
}
|
112
|
-
this.$module = $module;
|
113
|
-
const $menuButton = $module.querySelector('.govuk-js-header-toggle');
|
159
|
+
const $menuButton = this.$root.querySelector('.govuk-js-header-toggle');
|
114
160
|
if (!$menuButton) {
|
115
161
|
return this;
|
116
162
|
}
|
163
|
+
this.$root.classList.add('govuk-header--with-js-navigation');
|
117
164
|
const menuId = $menuButton.getAttribute('aria-controls');
|
118
165
|
if (!menuId) {
|
119
166
|
throw new ElementError({
|
120
|
-
|
167
|
+
component: Header,
|
121
168
|
identifier: 'Navigation button (`<button class="govuk-js-header-toggle">`) attribute (`aria-controls`)'
|
122
169
|
});
|
123
170
|
}
|
124
171
|
const $menu = document.getElementById(menuId);
|
125
172
|
if (!$menu) {
|
126
173
|
throw new ElementError({
|
127
|
-
|
174
|
+
component: Header,
|
128
175
|
element: $menu,
|
129
176
|
identifier: `Navigation (\`<ul id="${menuId}">\`)`
|
130
177
|
});
|
@@ -138,7 +185,7 @@ class Header extends GOVUKFrontendComponent {
|
|
138
185
|
const breakpoint = getBreakpoint('desktop');
|
139
186
|
if (!breakpoint.value) {
|
140
187
|
throw new ElementError({
|
141
|
-
|
188
|
+
component: Header,
|
142
189
|
identifier: `CSS custom property (\`${breakpoint.property}\`) on pseudo-class \`:root\``
|
143
190
|
});
|
144
191
|
}
|