defra_ruby_template 5.4.0 → 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 +43 -23
- data/lib/defra_ruby_template/version.rb +1 -1
- data/lib/defra_ruby_template.rb +3 -8
- 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 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/govuk/components/checkboxes/_index.scss"],"names":[],"mappings":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wD;MACxD,WAAW;MACX,aAAa;MACb,yBAAyB;IAC3B;;IAEA,4CAA4C;IAC5C,CAAC;IACD,2EAA2E;IAC3E,0EAA0E;IAC1E,uBAAuB;IACvB,CAAC;IACD,0EAA0E;IAC1E,iBAAiB;IACjB;MACE,4DAA4D;IAC9D;;IAEA,iDAAiD;IACjD;MACE,kFAAkF;MAClF,yBAAyB;MACzB,qGAAqG;IACvG;;IAEA,mCAAmC;IACnC,CAAC;IACD,yEAAyE;IACzE,sEAAsE;IACtE,uEAAuE;IACvE,wCAAwC;IACxC;MACE,iDAAiD;MACjD,kDAAkD;MAClD,8CAA8C;MAC9C,mBAAmB;MACnB,wDAAwD;IAC1D;;IAEA,yEAAyE;IACzE,+BAA+B;IAC/B,CAAC;IACD,wEAAwE;IACxE,oDAAoD;IACpD;MACE,wEAAwE;MACxE;QACE,wBAAwB;MAC1B;MACA,iBAAiB;MACjB;;oDAE8C,EAAE,GAAG;IACrD;;IAEA,wEAAwE;IACxE,yCAAyC;IACzC,CAAC;IACD,wEAAwE;IACxE,sEAAsE;IACtE,2DAA2D;IAC3D;MACE;QACE,mBAAmB;MACrB;;MAEA;QACE,wDAAwD;MAC1D;IACF;EACF;AACF","file":"_index.scss","sourcesContent":["@import \"../error-message/index\";\n@import \"../fieldset/index\";\n@import \"../hint/index\";\n@import \"../label/index\";\n\n@include govuk-exports(\"govuk/component/checkboxes\") {\n $govuk-touch-target-gutter: 4px;\n $govuk-checkboxes-size: 40px;\n $govuk-touch-target-size: ($govuk-checkboxes-size + $govuk-touch-target-gutter);\n $govuk-small-checkboxes-size: 24px;\n $govuk-checkboxes-label-padding-left-right: govuk-spacing(3);\n $govuk-checkbox-check-horizontal-position: 10px;\n\n .govuk-checkboxes__item {\n display: flex;\n flex-wrap: wrap;\n position: relative;\n margin-bottom: govuk-spacing(2);\n }\n\n .govuk-checkboxes__item:last-child,\n .govuk-checkboxes__item:last-of-type {\n margin-bottom: 0;\n }\n\n .govuk-checkboxes__input {\n // Allow the input to sit above the label, enabling its proper detection\n // when exploring by touch or using automation tools like Selenium\n z-index: 1;\n width: $govuk-touch-target-size;\n height: $govuk-touch-target-size;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n }\n\n .govuk-checkboxes__label {\n align-self: center;\n\n // Ensure that the width of the label is never more than the width of the\n // container minus the input width minus the padding on either side of\n // the label. This prevents the label from going onto the next line due to\n // __item using flex-wrap because we want hints on a separate line.\n max-width: calc(100% - #{(($govuk-checkboxes-label-padding-left-right * 2) + $govuk-touch-target-size)});\n margin-bottom: 0;\n padding: (govuk-spacing(1) + $govuk-border-width-form-element) govuk-spacing(3);\n cursor: pointer;\n // remove 300ms pause on mobile\n touch-action: manipulation;\n }\n\n // [ ] Check box\n .govuk-checkboxes__label::before {\n content: \"\";\n box-sizing: border-box;\n position: absolute;\n top: ($govuk-touch-target-gutter / 2);\n left: ($govuk-touch-target-gutter / 2);\n width: $govuk-checkboxes-size;\n height: $govuk-checkboxes-size;\n border: $govuk-border-width-form-element solid currentcolor;\n background: transparent;\n }\n\n // ✔ Check mark\n //\n // The check mark is a box with a border on the left and bottom side (└──),\n // rotated 45 degrees\n .govuk-checkboxes__label::after {\n content: \"\";\n box-sizing: border-box;\n position: absolute;\n\n // Use \"magic numbers\" to define shape and position of check mark because\n // the complexity of the shape makes it difficult to calculate dynamically.\n top: 13px;\n left: $govuk-checkbox-check-horizontal-position;\n width: 23px;\n height: 12px;\n transform: rotate(-45deg);\n border: solid;\n border-width: 0 0 5px 5px;\n // Fix bug in IE11 caused by transform rotate (-45deg).\n // See: alphagov/govuk_elements/issues/518\n border-top-color: transparent;\n opacity: 0;\n background: transparent;\n }\n\n .govuk-checkboxes__hint {\n display: block;\n width: 100%;\n margin-top: govuk-spacing(-1);\n padding-right: $govuk-checkboxes-label-padding-left-right;\n padding-left: ($govuk-checkboxes-label-padding-left-right + $govuk-touch-target-size);\n }\n\n // This is to bypass govuk-hint's specificity on hints following labels having\n // a margin bottom of 10px (govuk-spacing(2)). Because checkboxes are flexbox,\n // the margin doesn't collapse so we have to do this manually.\n .govuk-label:not(.govuk-label--m):not(.govuk-label--l):not(.govuk-label--xl) + .govuk-checkboxes__hint {\n margin-bottom: 0;\n }\n\n // Focused state\n .govuk-checkboxes__input:focus + .govuk-checkboxes__label::before {\n border-width: 4px;\n\n // When colours are overridden, the yellow box-shadow becomes invisible\n // which means the focus state is less obvious. By adding a transparent\n // outline, which becomes solid (text-coloured) in that context, we ensure\n // the focus remains clearly visible.\n outline: $govuk-focus-width solid transparent;\n outline-offset: 1px;\n\n // When in an explicit forced-color mode, we can use the Highlight system\n // color for the outline to better match focus states of native controls\n @media screen and (forced-colors: active), (-ms-high-contrast: active) {\n outline-color: Highlight;\n }\n\n box-shadow: 0 0 0 $govuk-focus-width $govuk-focus-colour;\n }\n\n // Selected state\n .govuk-checkboxes__input:checked + .govuk-checkboxes__label::after {\n opacity: 1;\n }\n\n // Disabled state\n .govuk-checkboxes__input:disabled,\n .govuk-checkboxes__input:disabled + .govuk-checkboxes__label {\n cursor: not-allowed;\n }\n\n .govuk-checkboxes__input:disabled + .govuk-checkboxes__label,\n .govuk-checkboxes__input:disabled ~ .govuk-hint {\n opacity: 0.5;\n }\n\n // =========================================================\n // Dividers ('or')\n // =========================================================\n\n .govuk-checkboxes__divider {\n @include govuk-font($size: 19);\n @include govuk-text-colour;\n $govuk-divider-size: $govuk-checkboxes-size !default;\n width: $govuk-divider-size;\n margin-bottom: govuk-spacing(2);\n text-align: center;\n }\n\n // =========================================================\n // Conditional reveals\n // =========================================================\n\n // The narrow border is used in the conditional reveals because the border has\n // to be an even number in order to be centred under the 40px checkbox or radio.\n $conditional-border-width: $govuk-border-width-narrow;\n // Calculate the amount of padding needed to keep the border centered against the checkbox.\n $conditional-border-padding: ($govuk-checkboxes-size / 2) - ($conditional-border-width / 2);\n // Move the border centered with the checkbox\n $conditional-margin-left: $conditional-border-padding;\n // Move the contents of the conditional inline with the label\n $conditional-padding-left: $conditional-border-padding + $govuk-checkboxes-label-padding-left-right;\n\n .govuk-checkboxes__conditional {\n @include govuk-responsive-margin(4, \"bottom\");\n margin-left: $conditional-margin-left;\n padding-left: $conditional-padding-left;\n border-left: $conditional-border-width solid $govuk-border-colour;\n\n .govuk-frontend-supported &--hidden {\n display: none;\n }\n\n & > :last-child {\n margin-bottom: 0;\n }\n }\n\n // =========================================================\n // Small checkboxes\n // =========================================================\n\n .govuk-checkboxes--small {\n $input-offset: ($govuk-touch-target-size - $govuk-small-checkboxes-size) / 2;\n\n .govuk-checkboxes__item {\n margin-bottom: 0;\n }\n\n // Shift the touch target into the left margin so that the visible edge of\n // the control is aligned\n //\n // ┆What colours do you like?\n // ┌┆───┐\n // │┆[] │ Purple\n // └┆▲──┘\n // ▲┆└─ Check box pseudo element, aligned with margin\n // └─── Touch target (invisible input), shifted into the margin\n .govuk-checkboxes__input {\n margin-left: $input-offset * -1;\n }\n\n .govuk-checkboxes__label {\n // Create a tiny space between the small checkbox hover state so that it\n // doesn't clash with the label\n padding-left: 1px;\n }\n\n // [ ] Check box\n //\n // Reduce the size of the check box [1], vertically center it within the\n // touch target [2]\n // Left here is 0 because we've shifted the input into the left margin\n .govuk-checkboxes__label::before {\n top: $input-offset; // 2\n left: 0;\n width: $govuk-small-checkboxes-size; // 1\n height: $govuk-small-checkboxes-size; // 1\n }\n\n // ✔ Check mark\n //\n // Reduce the size of the check mark and re-align within the checkbox\n .govuk-checkboxes__label::after {\n top: 17px;\n\n // Horizontal position is just the normal sized left value accounting for\n // the new width of the smaller checkbox\n left: (16px - $govuk-checkbox-check-horizontal-position);\n width: 12px;\n height: 6.5px;\n border-width: 0 0 3px 3px;\n }\n\n // Fix position of hint with small checkboxes\n //\n // Do not use hints with small checkboxes – because they're within the input\n // wrapper they trigger the hover state, but clicking them doesn't actually\n // activate the control.\n //\n // (If you do use them, they won't look completely broken... but seriously,\n // don't use them)\n .govuk-checkboxes__hint {\n padding-left: ($govuk-small-checkboxes-size + $input-offset);\n }\n\n // Align conditional reveals with small checkboxes\n .govuk-checkboxes__conditional {\n $margin-left: ($govuk-small-checkboxes-size / 2) - ($conditional-border-width / 2);\n margin-left: $margin-left;\n padding-left: ($govuk-touch-target-size - $input-offset) - ($margin-left + $conditional-border-width);\n }\n\n // Hover state for small checkboxes.\n //\n // We use a hover state for small checkboxes because the touch target size\n // is so much larger than their visible size, and so we need to provide\n // feedback to the user as to which checkbox they will select when their\n // cursor is outside of the visible area.\n .govuk-checkboxes__item:hover .govuk-checkboxes__input:not(:disabled) + .govuk-checkboxes__label::before {\n // Forced colours modes tend to ignore box-shadow.\n // Apply an outline for those modes to use instead.\n outline: $govuk-focus-width dashed transparent;\n outline-offset: 1px;\n box-shadow: 0 0 0 $govuk-hover-width $govuk-hover-colour;\n }\n\n // Because we've overridden the border-shadow provided by the focus state,\n // we need to redefine that too.\n //\n // We use two box shadows, one that restores the original focus state [1]\n // and another that then applies the hover state [2].\n .govuk-checkboxes__item:hover .govuk-checkboxes__input:focus + .govuk-checkboxes__label::before {\n // Set different HCM colour when we have both hover/focus applied at once\n @media screen and (forced-colors: active), (-ms-high-contrast: active) {\n outline-color: Highlight;\n }\n // prettier-ignore\n box-shadow:\n 0 0 0 $govuk-focus-width $govuk-focus-colour, // 1\n 0 0 0 $govuk-hover-width $govuk-hover-colour; // 2\n }\n\n // For devices that explicitly don't support hover, don't provide a hover\n // state (e.g. on touch devices like iOS).\n //\n // We can't use `@media (hover: hover)` because we wouldn't get the hover\n // state in browsers that don't support `@media (hover)` (like Internet\n // Explorer) – so we have to 'undo' the hover state instead.\n @media (hover: none), (pointer: coarse) {\n .govuk-checkboxes__item:hover .govuk-checkboxes__input:not(:disabled) + .govuk-checkboxes__label::before {\n box-shadow: initial;\n }\n\n .govuk-checkboxes__item:hover .govuk-checkboxes__input:focus + .govuk-checkboxes__label::before {\n box-shadow: 0 0 0 $govuk-focus-width $govuk-focus-colour;\n }\n }\n }\n}\n"]}
|
1
|
+
{"version":3,"sources":["../../../../src/govuk/components/checkboxes/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,uCAAuC;MACvC,wDAAwD;MACxD,WAAW;MACX,aAAa;MACb,yBAAyB;IAC3B;;IAEA,4CAA4C;IAC5C,CAAC;IACD,2EAA2E;IAC3E,0EAA0E;IAC1E,uBAAuB;IACvB,CAAC;IACD,0EAA0E;IAC1E,iBAAiB;IACjB;MACE,4DAA4D;IAC9D;;IAEA,iDAAiD;IACjD;MACE,kFAAkF;MAClF,yBAAyB;MACzB,qGAAqG;IACvG;;IAEA;MACE,mCAAmC;MACnC,+BAA+B;IACjC;;IAEA,mCAAmC;IACnC,CAAC;IACD,yEAAyE;IACzE,sEAAsE;IACtE,uEAAuE;IACvE,wCAAwC;IACxC;MACE,iDAAiD;MACjD,kDAAkD;MAClD,8CAA8C;MAC9C,mBAAmB;MACnB,wDAAwD;IAC1D;;IAEA,yEAAyE;IACzE,+BAA+B;IAC/B,CAAC;IACD,wEAAwE;IACxE,oDAAoD;IACpD;MACE,wEAAwE;MACxE;QACE,wBAAwB;MAC1B;MACA,iBAAiB;MACjB;;oDAE8C,EAAE,GAAG;IACrD;;IAEA,wEAAwE;IACxE,yCAAyC;IACzC,CAAC;IACD,wEAAwE;IACxE,sEAAsE;IACtE,2DAA2D;IAC3D;MACE;QACE,mBAAmB;MACrB;;MAEA;QACE,wDAAwD;MAC1D;IACF;EACF;AACF","file":"_index.scss","sourcesContent":["@import \"../error-message/index\";\n@import \"../fieldset/index\";\n@import \"../hint/index\";\n@import \"../label/index\";\n\n@include govuk-exports(\"govuk/component/checkboxes\") {\n $govuk-touch-target-gutter: 4px;\n $govuk-checkboxes-size: 40px;\n $govuk-touch-target-size: ($govuk-checkboxes-size + $govuk-touch-target-gutter);\n $govuk-small-checkboxes-size: 24px;\n $govuk-checkboxes-label-padding-left-right: govuk-spacing(3);\n $govuk-checkbox-check-horizontal-position: 10px;\n\n .govuk-checkboxes__item {\n display: flex;\n flex-wrap: wrap;\n position: relative;\n margin-bottom: govuk-spacing(2);\n }\n\n .govuk-checkboxes__item:last-child,\n .govuk-checkboxes__item:last-of-type {\n margin-bottom: 0;\n }\n\n .govuk-checkboxes__input {\n // Allow the input to sit above the label, enabling its proper detection\n // when exploring by touch or using automation tools like Selenium\n z-index: 1;\n width: $govuk-touch-target-size;\n height: $govuk-touch-target-size;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n }\n\n .govuk-checkboxes__label {\n align-self: center;\n\n // Ensure that the width of the label is never more than the width of the\n // container minus the input width minus the padding on either side of\n // the label. This prevents the label from going onto the next line due to\n // __item using flex-wrap because we want hints on a separate line.\n max-width: calc(100% - #{(($govuk-checkboxes-label-padding-left-right * 2) + $govuk-touch-target-size)});\n margin-bottom: 0;\n padding: (govuk-spacing(1) + $govuk-border-width-form-element) govuk-spacing(3);\n cursor: pointer;\n // remove 300ms pause on mobile\n touch-action: manipulation;\n }\n\n // [ ] Check box\n .govuk-checkboxes__label::before {\n content: \"\";\n box-sizing: border-box;\n position: absolute;\n top: ($govuk-touch-target-gutter / 2);\n left: ($govuk-touch-target-gutter / 2);\n width: $govuk-checkboxes-size;\n height: $govuk-checkboxes-size;\n border: $govuk-border-width-form-element solid currentcolor;\n background: transparent;\n }\n\n // ✔ Check mark\n //\n // The check mark is a box with a border on the left and bottom side (└──),\n // rotated 45 degrees\n .govuk-checkboxes__label::after {\n content: \"\";\n box-sizing: border-box;\n position: absolute;\n\n // Use \"magic numbers\" to define shape and position of check mark because\n // the complexity of the shape makes it difficult to calculate dynamically.\n top: 13px;\n left: $govuk-checkbox-check-horizontal-position;\n width: 23px;\n height: 12px;\n transform: rotate(-45deg);\n border: solid;\n border-width: 0 0 5px 5px;\n // Fix bug in IE11 caused by transform rotate (-45deg).\n // See: alphagov/govuk_elements/issues/518\n border-top-color: transparent;\n opacity: 0;\n background: transparent;\n }\n\n .govuk-checkboxes__hint {\n display: block;\n width: 100%;\n margin-top: govuk-spacing(-1);\n padding-right: $govuk-checkboxes-label-padding-left-right;\n padding-left: ($govuk-checkboxes-label-padding-left-right + $govuk-touch-target-size);\n }\n\n // This is to bypass govuk-hint's specificity on hints following labels having\n // a margin bottom of 10px (govuk-spacing(2)). Because checkboxes are flexbox,\n // the margin doesn't collapse so we have to do this manually.\n .govuk-label:not(.govuk-label--m):not(.govuk-label--l):not(.govuk-label--xl) + .govuk-checkboxes__hint {\n margin-bottom: 0;\n }\n\n // Focused state\n .govuk-checkboxes__input:focus + .govuk-checkboxes__label::before {\n border-width: 4px;\n\n // When colours are overridden, the yellow box-shadow becomes invisible\n // which means the focus state is less obvious. By adding a transparent\n // outline, which becomes solid (text-coloured) in that context, we ensure\n // the focus remains clearly visible.\n outline: $govuk-focus-width solid transparent;\n outline-offset: 1px;\n\n // When in an explicit forced-color mode, we can use the Highlight system\n // color for the outline to better match focus states of native controls\n @media screen and (forced-colors: active), (-ms-high-contrast: active) {\n outline-color: Highlight;\n }\n\n box-shadow: 0 0 0 $govuk-focus-width $govuk-focus-colour;\n }\n\n // Selected state\n .govuk-checkboxes__input:checked + .govuk-checkboxes__label::after {\n opacity: 1;\n }\n\n // Disabled state\n .govuk-checkboxes__input:disabled,\n .govuk-checkboxes__input:disabled + .govuk-checkboxes__label {\n cursor: not-allowed;\n }\n\n .govuk-checkboxes__input:disabled + .govuk-checkboxes__label,\n .govuk-checkboxes__input:disabled ~ .govuk-hint {\n opacity: 0.5;\n }\n\n // =========================================================\n // Dividers ('or')\n // =========================================================\n\n .govuk-checkboxes__divider {\n @include govuk-font($size: 19);\n @include govuk-text-colour;\n $govuk-divider-size: $govuk-checkboxes-size !default;\n width: $govuk-divider-size;\n margin-bottom: govuk-spacing(2);\n text-align: center;\n }\n\n // =========================================================\n // Conditional reveals\n // =========================================================\n\n // The narrow border is used in the conditional reveals because the border has\n // to be an even number in order to be centred under the 40px checkbox or radio.\n $conditional-border-width: $govuk-border-width-narrow;\n // Calculate the amount of padding needed to keep the border centered against the checkbox.\n $conditional-border-padding: ($govuk-touch-target-size / 2) - ($conditional-border-width / 2);\n // Move the border centered with the checkbox\n $conditional-margin-left: $conditional-border-padding;\n // Move the contents of the conditional inline with the label\n $conditional-padding-left: $conditional-border-padding + $govuk-checkboxes-label-padding-left-right;\n\n .govuk-checkboxes__conditional {\n @include govuk-responsive-margin(4, \"bottom\");\n margin-left: $conditional-margin-left;\n padding-left: $conditional-padding-left;\n border-left: $conditional-border-width solid $govuk-border-colour;\n\n .govuk-frontend-supported &--hidden {\n display: none;\n }\n\n & > :last-child {\n margin-bottom: 0;\n }\n }\n\n // =========================================================\n // Small checkboxes\n // =========================================================\n\n .govuk-checkboxes--small {\n $input-offset: ($govuk-touch-target-size - $govuk-small-checkboxes-size) / 2;\n\n .govuk-checkboxes__item {\n margin-bottom: 0;\n }\n\n // Shift the touch target into the left margin so that the visible edge of\n // the control is aligned\n //\n // ┆What colours do you like?\n // ┌┆───┐\n // │┆[] │ Purple\n // └┆▲──┘\n // ▲┆└─ Check box pseudo element, aligned with margin\n // └─── Touch target (invisible input), shifted into the margin\n .govuk-checkboxes__input {\n margin-left: $input-offset * -1;\n }\n\n .govuk-checkboxes__label {\n // Create a tiny space between the small checkbox hover state so that it\n // doesn't clash with the label\n padding-left: 1px;\n }\n\n // [ ] Check box\n //\n // Reduce the size of the check box [1], vertically center it within the\n // touch target [2]\n // Left here is 0 because we've shifted the input into the left margin\n .govuk-checkboxes__label::before {\n top: $input-offset; // 2\n left: 0;\n width: $govuk-small-checkboxes-size; // 1\n height: $govuk-small-checkboxes-size; // 1\n }\n\n // ✔ Check mark\n //\n // Reduce the size of the check mark and re-align within the checkbox\n .govuk-checkboxes__label::after {\n top: 17px;\n\n // Horizontal position is just the normal sized left value accounting for\n // the new width of the smaller checkbox\n left: (16px - $govuk-checkbox-check-horizontal-position);\n width: 12px;\n height: 6.5px;\n border-width: 0 0 3px 3px;\n }\n\n // Fix position of hint with small checkboxes\n //\n // Do not use hints with small checkboxes – because they're within the input\n // wrapper they trigger the hover state, but clicking them doesn't actually\n // activate the control.\n //\n // (If you do use them, they won't look completely broken... but seriously,\n // don't use them)\n .govuk-checkboxes__hint {\n padding-left: ($govuk-small-checkboxes-size + $input-offset);\n }\n\n // Align conditional reveals with small checkboxes\n .govuk-checkboxes__conditional {\n $margin-left: ($govuk-small-checkboxes-size / 2) - ($conditional-border-width / 2);\n margin-left: $margin-left;\n padding-left: ($govuk-touch-target-size - $input-offset) - ($margin-left + $conditional-border-width);\n }\n\n .govuk-checkboxes__divider {\n width: $govuk-small-checkboxes-size;\n margin-bottom: govuk-spacing(1);\n }\n\n // Hover state for small checkboxes.\n //\n // We use a hover state for small checkboxes because the touch target size\n // is so much larger than their visible size, and so we need to provide\n // feedback to the user as to which checkbox they will select when their\n // cursor is outside of the visible area.\n .govuk-checkboxes__item:hover .govuk-checkboxes__input:not(:disabled) + .govuk-checkboxes__label::before {\n // Forced colours modes tend to ignore box-shadow.\n // Apply an outline for those modes to use instead.\n outline: $govuk-focus-width dashed transparent;\n outline-offset: 1px;\n box-shadow: 0 0 0 $govuk-hover-width $govuk-hover-colour;\n }\n\n // Because we've overridden the border-shadow provided by the focus state,\n // we need to redefine that too.\n //\n // We use two box shadows, one that restores the original focus state [1]\n // and another that then applies the hover state [2].\n .govuk-checkboxes__item:hover .govuk-checkboxes__input:focus + .govuk-checkboxes__label::before {\n // Set different HCM colour when we have both hover/focus applied at once\n @media screen and (forced-colors: active), (-ms-high-contrast: active) {\n outline-color: Highlight;\n }\n // prettier-ignore\n box-shadow:\n 0 0 0 $govuk-focus-width $govuk-focus-colour, // 1\n 0 0 0 $govuk-hover-width $govuk-hover-colour; // 2\n }\n\n // For devices that explicitly don't support hover, don't provide a hover\n // state (e.g. on touch devices like iOS).\n //\n // We can't use `@media (hover: hover)` because we wouldn't get the hover\n // state in browsers that don't support `@media (hover)` (like Internet\n // Explorer) – so we have to 'undo' the hover state instead.\n @media (hover: none), (pointer: coarse) {\n .govuk-checkboxes__item:hover .govuk-checkboxes__input:not(:disabled) + .govuk-checkboxes__label::before {\n box-shadow: initial;\n }\n\n .govuk-checkboxes__item:hover .govuk-checkboxes__input:focus + .govuk-checkboxes__label::before {\n box-shadow: 0 0 0 $govuk-focus-width $govuk-focus-colour;\n }\n }\n }\n}\n"]}
|
@@ -1,9 +1,39 @@
|
|
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
|
+
function isInitialised($root, moduleName) {
|
8
|
+
return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
|
9
|
+
}
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Checks if GOV.UK Frontend is supported on this page
|
13
|
+
*
|
14
|
+
* Some browsers will load and run our JavaScript but GOV.UK Frontend
|
15
|
+
* won't be supported.
|
16
|
+
*
|
17
|
+
* @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support
|
18
|
+
* @returns {boolean} Whether GOV.UK Frontend is supported on this page
|
19
|
+
*/
|
20
|
+
function isSupported($scope = document.body) {
|
21
|
+
if (!$scope) {
|
22
|
+
return false;
|
23
|
+
}
|
24
|
+
return $scope.classList.contains('govuk-frontend-supported');
|
25
|
+
}
|
26
|
+
function formatErrorMessage(Component, message) {
|
27
|
+
return `${Component.moduleName}: ${message}`;
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* @typedef ComponentWithModuleName
|
31
|
+
* @property {string} moduleName - Name of the component
|
32
|
+
*/
|
33
|
+
/**
|
34
|
+
* @import { ObjectNested } from './configuration.mjs'
|
35
|
+
*/
|
36
|
+
|
7
37
|
class GOVUKFrontendError extends Error {
|
8
38
|
constructor(...args) {
|
9
39
|
super(...args);
|
@@ -27,66 +57,91 @@
|
|
27
57
|
let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
|
28
58
|
if (typeof messageOrOptions === 'object') {
|
29
59
|
const {
|
30
|
-
|
60
|
+
component,
|
31
61
|
identifier,
|
32
62
|
element,
|
33
63
|
expectedType
|
34
64
|
} = messageOrOptions;
|
35
|
-
message =
|
65
|
+
message = identifier;
|
36
66
|
message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
|
67
|
+
message = formatErrorMessage(component, message);
|
37
68
|
}
|
38
69
|
super(message);
|
39
70
|
this.name = 'ElementError';
|
40
71
|
}
|
41
72
|
}
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
73
|
+
class InitError extends GOVUKFrontendError {
|
74
|
+
constructor(componentOrMessage) {
|
75
|
+
const message = typeof componentOrMessage === 'string' ? componentOrMessage : formatErrorMessage(componentOrMessage, `Root element (\`$root\`) already initialised`);
|
76
|
+
super(message);
|
77
|
+
this.name = 'InitError';
|
46
78
|
}
|
47
|
-
return $scope.classList.contains('govuk-frontend-supported');
|
48
79
|
}
|
49
|
-
|
50
|
-
/**
|
51
|
-
* Schema for component config
|
52
|
-
*
|
53
|
-
* @typedef {object} Schema
|
54
|
-
* @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
|
55
|
-
* @property {SchemaCondition[]} [anyOf] - List of schema conditions
|
56
|
-
*/
|
57
|
-
|
58
80
|
/**
|
59
|
-
*
|
60
|
-
*
|
61
|
-
* @typedef {object} SchemaProperty
|
62
|
-
* @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
|
63
|
-
*/
|
64
|
-
|
65
|
-
/**
|
66
|
-
* Schema condition for component config
|
67
|
-
*
|
68
|
-
* @typedef {object} SchemaCondition
|
69
|
-
* @property {string[]} required - List of required config fields
|
70
|
-
* @property {string} errorMessage - Error message when required config fields not provided
|
81
|
+
* @import { ComponentWithModuleName } from '../common/index.mjs'
|
71
82
|
*/
|
72
83
|
|
73
|
-
class
|
74
|
-
|
75
|
-
|
84
|
+
class Component {
|
85
|
+
/**
|
86
|
+
* Returns the root element of the component
|
87
|
+
*
|
88
|
+
* @protected
|
89
|
+
* @returns {RootElementType} - the root element of component
|
90
|
+
*/
|
91
|
+
get $root() {
|
92
|
+
return this._$root;
|
76
93
|
}
|
77
|
-
|
94
|
+
constructor($root) {
|
95
|
+
this._$root = void 0;
|
96
|
+
const childConstructor = this.constructor;
|
97
|
+
if (typeof childConstructor.moduleName !== 'string') {
|
98
|
+
throw new InitError(`\`moduleName\` not defined in component`);
|
99
|
+
}
|
100
|
+
if (!($root instanceof childConstructor.elementType)) {
|
101
|
+
throw new ElementError({
|
102
|
+
element: $root,
|
103
|
+
component: childConstructor,
|
104
|
+
identifier: 'Root element (`$root`)',
|
105
|
+
expectedType: childConstructor.elementType.name
|
106
|
+
});
|
107
|
+
} else {
|
108
|
+
this._$root = $root;
|
109
|
+
}
|
110
|
+
childConstructor.checkSupport();
|
111
|
+
this.checkInitialised();
|
112
|
+
const moduleName = childConstructor.moduleName;
|
113
|
+
this.$root.setAttribute(`data-${moduleName}-init`, '');
|
114
|
+
}
|
115
|
+
checkInitialised() {
|
116
|
+
const constructor = this.constructor;
|
117
|
+
const moduleName = constructor.moduleName;
|
118
|
+
if (moduleName && isInitialised(this.$root, moduleName)) {
|
119
|
+
throw new InitError(constructor);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
static checkSupport() {
|
78
123
|
if (!isSupported()) {
|
79
124
|
throw new SupportError();
|
80
125
|
}
|
81
126
|
}
|
82
127
|
}
|
83
128
|
|
129
|
+
/**
|
130
|
+
* @typedef ChildClass
|
131
|
+
* @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
|
132
|
+
*/
|
133
|
+
|
134
|
+
/**
|
135
|
+
* @typedef {typeof Component & ChildClass} ChildClassConstructor
|
136
|
+
*/
|
137
|
+
Component.elementType = HTMLElement;
|
138
|
+
|
84
139
|
/**
|
85
140
|
* Checkboxes component
|
86
141
|
*
|
87
142
|
* @preserve
|
88
143
|
*/
|
89
|
-
class Checkboxes extends
|
144
|
+
class Checkboxes extends Component {
|
90
145
|
/**
|
91
146
|
* Checkboxes can be associated with a 'conditionally revealed' content block
|
92
147
|
* – for example, a checkbox for 'Phone' could reveal an additional form field
|
@@ -99,27 +154,18 @@
|
|
99
154
|
* (for example if the user has navigated back), and set up event handlers to
|
100
155
|
* keep the reveal in sync with the checkbox state.
|
101
156
|
*
|
102
|
-
* @param {Element | null} $
|
157
|
+
* @param {Element | null} $root - HTML element to use for checkboxes
|
103
158
|
*/
|
104
|
-
constructor($
|
105
|
-
super();
|
106
|
-
this.$module = void 0;
|
159
|
+
constructor($root) {
|
160
|
+
super($root);
|
107
161
|
this.$inputs = void 0;
|
108
|
-
|
109
|
-
throw new ElementError({
|
110
|
-
componentName: 'Checkboxes',
|
111
|
-
element: $module,
|
112
|
-
identifier: 'Root element (`$module`)'
|
113
|
-
});
|
114
|
-
}
|
115
|
-
const $inputs = $module.querySelectorAll('input[type="checkbox"]');
|
162
|
+
const $inputs = this.$root.querySelectorAll('input[type="checkbox"]');
|
116
163
|
if (!$inputs.length) {
|
117
164
|
throw new ElementError({
|
118
|
-
|
165
|
+
component: Checkboxes,
|
119
166
|
identifier: 'Form inputs (`<input type="checkbox">`)'
|
120
167
|
});
|
121
168
|
}
|
122
|
-
this.$module = $module;
|
123
169
|
this.$inputs = $inputs;
|
124
170
|
this.$inputs.forEach($input => {
|
125
171
|
const targetId = $input.getAttribute('data-aria-controls');
|
@@ -128,7 +174,7 @@
|
|
128
174
|
}
|
129
175
|
if (!document.getElementById(targetId)) {
|
130
176
|
throw new ElementError({
|
131
|
-
|
177
|
+
component: Checkboxes,
|
132
178
|
identifier: `Conditional reveal (\`id="${targetId}"\`)`
|
133
179
|
});
|
134
180
|
}
|
@@ -137,7 +183,7 @@
|
|
137
183
|
});
|
138
184
|
window.addEventListener('pageshow', () => this.syncAllConditionalReveals());
|
139
185
|
this.syncAllConditionalReveals();
|
140
|
-
this.$
|
186
|
+
this.$root.addEventListener('click', event => this.handleClick(event));
|
141
187
|
}
|
142
188
|
syncAllConditionalReveals() {
|
143
189
|
this.$inputs.forEach($input => this.syncConditionalRevealWithInputState($input));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"checkboxes.bundle.js","sources":["../../../../src/govuk/errors/index.mjs","../../../../src/govuk/common/index.mjs","../../../../src/govuk/govuk-frontend-component.mjs","../../../../src/govuk/components/checkboxes/checkboxes.mjs"],"sourcesContent":["/**\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 { 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","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 { ElementError } from '../../errors/index.mjs'\nimport { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'\n\n/**\n * Checkboxes component\n *\n * @preserve\n */\nexport class Checkboxes extends GOVUKFrontendComponent {\n /** @private */\n $module\n\n /** @private */\n $inputs\n\n /**\n * Checkboxes can be associated with a 'conditionally revealed' content block\n * – for example, a checkbox for 'Phone' could reveal an additional form field\n * for the user to enter their phone number.\n *\n * These associations are made using a `data-aria-controls` attribute, which\n * is promoted to an aria-controls attribute during initialisation.\n *\n * We also need to restore the state of any conditional reveals on the page\n * (for example if the user has navigated back), and set up event handlers to\n * keep the reveal in sync with the checkbox state.\n *\n * @param {Element | null} $module - HTML element to use for checkboxes\n */\n constructor($module) {\n super()\n\n if (!($module instanceof HTMLElement)) {\n throw new ElementError({\n componentName: 'Checkboxes',\n element: $module,\n identifier: 'Root element (`$module`)'\n })\n }\n\n const $inputs = $module.querySelectorAll('input[type=\"checkbox\"]')\n if (!$inputs.length) {\n throw new ElementError({\n componentName: 'Checkboxes',\n identifier: 'Form inputs (`<input type=\"checkbox\">`)'\n })\n }\n\n this.$module = $module\n this.$inputs = $inputs\n\n this.$inputs.forEach(($input) => {\n const targetId = $input.getAttribute('data-aria-controls')\n\n // Skip radios without data-aria-controls attributes\n if (!targetId) {\n return\n }\n\n // Throw if target conditional element does not exist.\n if (!document.getElementById(targetId)) {\n throw new ElementError({\n componentName: 'Checkboxes',\n identifier: `Conditional reveal (\\`id=\"${targetId}\"\\`)`\n })\n }\n\n // Promote the data-aria-controls attribute to a aria-controls attribute\n // so that the relationship is exposed in the AOM\n $input.setAttribute('aria-controls', targetId)\n $input.removeAttribute('data-aria-controls')\n })\n\n // When the page is restored after navigating 'back' in some browsers the\n // state of form controls is not restored until *after* the DOMContentLoaded\n // event is fired, so we need to sync after the pageshow event.\n window.addEventListener('pageshow', () => this.syncAllConditionalReveals())\n\n // Although we've set up handlers to sync state on the pageshow event, init\n // could be called after those events have fired, for example if they are\n // added to the page dynamically, so sync now too.\n this.syncAllConditionalReveals()\n\n // Handle events\n this.$module.addEventListener('click', (event) => this.handleClick(event))\n }\n\n /**\n * Sync the conditional reveal states for all checkboxes in this $module.\n *\n * @private\n */\n syncAllConditionalReveals() {\n this.$inputs.forEach(($input) =>\n this.syncConditionalRevealWithInputState($input)\n )\n }\n\n /**\n * Sync conditional reveal with the input state\n *\n * Synchronise the visibility of the conditional reveal, and its accessible\n * state, with the input's checked state.\n *\n * @private\n * @param {HTMLInputElement} $input - Checkbox input\n */\n syncConditionalRevealWithInputState($input) {\n const targetId = $input.getAttribute('aria-controls')\n if (!targetId) {\n return\n }\n\n const $target = document.getElementById(targetId)\n if ($target?.classList.contains('govuk-checkboxes__conditional')) {\n const inputIsChecked = $input.checked\n\n $input.setAttribute('aria-expanded', inputIsChecked.toString())\n $target.classList.toggle(\n 'govuk-checkboxes__conditional--hidden',\n !inputIsChecked\n )\n }\n }\n\n /**\n * Uncheck other checkboxes\n *\n * Find any other checkbox inputs with the same name value, and uncheck them.\n * This is useful for when a “None of these\" checkbox is checked.\n *\n * @private\n * @param {HTMLInputElement} $input - Checkbox input\n */\n unCheckAllInputsExcept($input) {\n const allInputsWithSameName = document.querySelectorAll(\n `input[type=\"checkbox\"][name=\"${$input.name}\"]`\n )\n\n allInputsWithSameName.forEach(($inputWithSameName) => {\n const hasSameFormOwner = $input.form === $inputWithSameName.form\n if (hasSameFormOwner && $inputWithSameName !== $input) {\n $inputWithSameName.checked = false\n this.syncConditionalRevealWithInputState($inputWithSameName)\n }\n })\n }\n\n /**\n * Uncheck exclusive checkboxes\n *\n * Find any checkbox inputs with the same name value and the 'exclusive'\n * behaviour, and uncheck them. This helps prevent someone checking both a\n * regular checkbox and a \"None of these\" checkbox in the same fieldset.\n *\n * @private\n * @param {HTMLInputElement} $input - Checkbox input\n */\n unCheckExclusiveInputs($input) {\n const allInputsWithSameNameAndExclusiveBehaviour =\n document.querySelectorAll(\n `input[data-behaviour=\"exclusive\"][type=\"checkbox\"][name=\"${$input.name}\"]`\n )\n\n allInputsWithSameNameAndExclusiveBehaviour.forEach(($exclusiveInput) => {\n const hasSameFormOwner = $input.form === $exclusiveInput.form\n if (hasSameFormOwner) {\n $exclusiveInput.checked = false\n this.syncConditionalRevealWithInputState($exclusiveInput)\n }\n })\n }\n\n /**\n * Click event handler\n *\n * Handle a click within the $module – if the click occurred on a checkbox,\n * sync the state of any associated conditional reveal with the checkbox\n * state.\n *\n * @private\n * @param {MouseEvent} event - Click event\n */\n handleClick(event) {\n const $clickedInput = event.target\n\n // Ignore clicks on things that aren't checkbox inputs\n if (\n !($clickedInput instanceof HTMLInputElement) ||\n $clickedInput.type !== 'checkbox'\n ) {\n return\n }\n\n // If the checkbox conditionally-reveals some content, sync the state\n const hasAriaControls = $clickedInput.getAttribute('aria-controls')\n if (hasAriaControls) {\n this.syncConditionalRevealWithInputState($clickedInput)\n }\n\n // No further behaviour needed for unchecking\n if (!$clickedInput.checked) {\n return\n }\n\n // Handle 'exclusive' checkbox behaviour (ie \"None of these\")\n const hasBehaviourExclusive =\n $clickedInput.getAttribute('data-behaviour') === 'exclusive'\n if (hasBehaviourExclusive) {\n this.unCheckAllInputsExcept($clickedInput)\n } else {\n this.unCheckExclusiveInputs($clickedInput)\n }\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-checkboxes'\n}\n"],"names":["GOVUKFrontendError","Error","constructor","args","name","SupportError","$scope","document","body","supportMessage","HTMLScriptElement","prototype","ElementError","messageOrOptions","message","componentName","identifier","element","expectedType","isSupported","classList","contains","GOVUKFrontendComponent","checkSupport","Checkboxes","$module","$inputs","HTMLElement","querySelectorAll","length","forEach","$input","targetId","getAttribute","getElementById","setAttribute","removeAttribute","window","addEventListener","syncAllConditionalReveals","event","handleClick","syncConditionalRevealWithInputState","$target","inputIsChecked","checked","toString","toggle","unCheckAllInputsExcept","allInputsWithSameName","$inputWithSameName","hasSameFormOwner","form","unCheckExclusiveInputs","allInputsWithSameNameAndExclusiveBehaviour","$exclusiveInput","$clickedInput","target","HTMLInputElement","type","hasAriaControls","hasBehaviourExclusive","moduleName"],"mappings":";;;;;;EAoBO,MAAMA,kBAAkB,SAASC,KA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../../src/govuk/common/index.mjs","../../../../src/govuk/errors/index.mjs","../../../../src/govuk/component.mjs","../../../../src/govuk/components/checkboxes/checkboxes.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 { Component } from '../../component.mjs'\nimport { ElementError } from '../../errors/index.mjs'\n\n/**\n * Checkboxes component\n *\n * @preserve\n */\nexport class Checkboxes extends Component {\n /** @private */\n $inputs\n\n /**\n * Checkboxes can be associated with a 'conditionally revealed' content block\n * – for example, a checkbox for 'Phone' could reveal an additional form field\n * for the user to enter their phone number.\n *\n * These associations are made using a `data-aria-controls` attribute, which\n * is promoted to an aria-controls attribute during initialisation.\n *\n * We also need to restore the state of any conditional reveals on the page\n * (for example if the user has navigated back), and set up event handlers to\n * keep the reveal in sync with the checkbox state.\n *\n * @param {Element | null} $root - HTML element to use for checkboxes\n */\n constructor($root) {\n super($root)\n\n const $inputs = this.$root.querySelectorAll('input[type=\"checkbox\"]')\n if (!$inputs.length) {\n throw new ElementError({\n component: Checkboxes,\n identifier: 'Form inputs (`<input type=\"checkbox\">`)'\n })\n }\n\n this.$inputs = $inputs\n\n this.$inputs.forEach(($input) => {\n const targetId = $input.getAttribute('data-aria-controls')\n\n // Skip radios without data-aria-controls attributes\n if (!targetId) {\n return\n }\n\n // Throw if target conditional element does not exist.\n if (!document.getElementById(targetId)) {\n throw new ElementError({\n component: Checkboxes,\n identifier: `Conditional reveal (\\`id=\"${targetId}\"\\`)`\n })\n }\n\n // Promote the data-aria-controls attribute to a aria-controls attribute\n // so that the relationship is exposed in the AOM\n $input.setAttribute('aria-controls', targetId)\n $input.removeAttribute('data-aria-controls')\n })\n\n // When the page is restored after navigating 'back' in some browsers the\n // state of form controls is not restored until *after* the DOMContentLoaded\n // event is fired, so we need to sync after the pageshow event.\n window.addEventListener('pageshow', () => this.syncAllConditionalReveals())\n\n // Although we've set up handlers to sync state on the pageshow event, init\n // could be called after those events have fired, for example if they are\n // added to the page dynamically, so sync now too.\n this.syncAllConditionalReveals()\n\n // Handle events\n this.$root.addEventListener('click', (event) => this.handleClick(event))\n }\n\n /**\n * Sync the conditional reveal states for all checkboxes in this component.\n *\n * @private\n */\n syncAllConditionalReveals() {\n this.$inputs.forEach(($input) =>\n this.syncConditionalRevealWithInputState($input)\n )\n }\n\n /**\n * Sync conditional reveal with the input state\n *\n * Synchronise the visibility of the conditional reveal, and its accessible\n * state, with the input's checked state.\n *\n * @private\n * @param {HTMLInputElement} $input - Checkbox input\n */\n syncConditionalRevealWithInputState($input) {\n const targetId = $input.getAttribute('aria-controls')\n if (!targetId) {\n return\n }\n\n const $target = document.getElementById(targetId)\n if ($target?.classList.contains('govuk-checkboxes__conditional')) {\n const inputIsChecked = $input.checked\n\n $input.setAttribute('aria-expanded', inputIsChecked.toString())\n $target.classList.toggle(\n 'govuk-checkboxes__conditional--hidden',\n !inputIsChecked\n )\n }\n }\n\n /**\n * Uncheck other checkboxes\n *\n * Find any other checkbox inputs with the same name value, and uncheck them.\n * This is useful for when a “None of these\" checkbox is checked.\n *\n * @private\n * @param {HTMLInputElement} $input - Checkbox input\n */\n unCheckAllInputsExcept($input) {\n const allInputsWithSameName = document.querySelectorAll(\n `input[type=\"checkbox\"][name=\"${$input.name}\"]`\n )\n\n allInputsWithSameName.forEach(($inputWithSameName) => {\n const hasSameFormOwner = $input.form === $inputWithSameName.form\n if (hasSameFormOwner && $inputWithSameName !== $input) {\n $inputWithSameName.checked = false\n this.syncConditionalRevealWithInputState($inputWithSameName)\n }\n })\n }\n\n /**\n * Uncheck exclusive checkboxes\n *\n * Find any checkbox inputs with the same name value and the 'exclusive'\n * behaviour, and uncheck them. This helps prevent someone checking both a\n * regular checkbox and a \"None of these\" checkbox in the same fieldset.\n *\n * @private\n * @param {HTMLInputElement} $input - Checkbox input\n */\n unCheckExclusiveInputs($input) {\n const allInputsWithSameNameAndExclusiveBehaviour =\n document.querySelectorAll(\n `input[data-behaviour=\"exclusive\"][type=\"checkbox\"][name=\"${$input.name}\"]`\n )\n\n allInputsWithSameNameAndExclusiveBehaviour.forEach(($exclusiveInput) => {\n const hasSameFormOwner = $input.form === $exclusiveInput.form\n if (hasSameFormOwner) {\n $exclusiveInput.checked = false\n this.syncConditionalRevealWithInputState($exclusiveInput)\n }\n })\n }\n\n /**\n * Click event handler\n *\n * Handle a click within the component root – if the click occurred on a checkbox,\n * sync the state of any associated conditional reveal with the checkbox\n * state.\n *\n * @private\n * @param {MouseEvent} event - Click event\n */\n handleClick(event) {\n const $clickedInput = event.target\n\n // Ignore clicks on things that aren't checkbox inputs\n if (\n !($clickedInput instanceof HTMLInputElement) ||\n $clickedInput.type !== 'checkbox'\n ) {\n return\n }\n\n // If the checkbox conditionally-reveals some content, sync the state\n const hasAriaControls = $clickedInput.getAttribute('aria-controls')\n if (hasAriaControls) {\n this.syncConditionalRevealWithInputState($clickedInput)\n }\n\n // No further behaviour needed for unchecking\n if (!$clickedInput.checked) {\n return\n }\n\n // Handle 'exclusive' checkbox behaviour (ie \"None of these\")\n const hasBehaviourExclusive =\n $clickedInput.getAttribute('data-behaviour') === 'exclusive'\n if (hasBehaviourExclusive) {\n this.unCheckAllInputsExcept($clickedInput)\n } else {\n this.unCheckExclusiveInputs($clickedInput)\n }\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-checkboxes'\n}\n"],"names":["isInitialised","$root","moduleName","HTMLElement","hasAttribute","isSupported","$scope","document","body","classList","contains","formatErrorMessage","Component","message","GOVUKFrontendError","Error","constructor","args","name","SupportError","supportMessage","HTMLScriptElement","prototype","ElementError","messageOrOptions","component","identifier","element","expectedType","InitError","componentOrMessage","_$root","childConstructor","elementType","checkSupport","checkInitialised","setAttribute","Checkboxes","$inputs","querySelectorAll","length","forEach","$input","targetId","getAttribute","getElementById","removeAttribute","window","addEventListener","syncAllConditionalReveals","event","handleClick","syncConditionalRevealWithInputState","$target","inputIsChecked","checked","toString","toggle","unCheckAllInputsExcept","allInputsWithSameName","$inputWithSameName","hasSameFormOwner","form","unCheckExclusiveInputs","allInputsWithSameNameAndExclusiveBehaviour","$exclusiveInput","$clickedInput","target","HTMLInputElement","type","hasAriaControls","hasBehaviourExclusive"],"mappings":";;;;;;EAqGO,SAASA,aAAaA,CAACC,KAAK,EAAEC,UAAU,EAAE;IAC/C,OACED,KAAK,YAAYE,WAAW,IAC5BF,KAAK,CAACG,YAAY,CAAC,CAAA,KAAA,EAAQF,UAAU,CAAA,KAAA,CAAO,CAAC;EAEjD;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACO,SAASG,WAAWA,CAACC,MAAM,GAAGC,QAAQ,CAACC,IAAI,EAAE;IAClD,IAAI,CAACF,MAAM,EAAE;EACX,IAAA,OAAO,KAAK;EACd;EAEA,EAAA,OAAOA,MAAM,CAACG,SAAS,CAACC,QAAQ,CAAC,0BAA0B,CAAC;EAC9D;EAiCO,SAASC,kBAAkBA,CAACC,SAAS,EAAEC,OAAO,EAAE;EACrD,EAAA,OAAO,GAAGD,SAAS,CAACV,UAAU,CAAA,EAAA,EAAKW,OAAO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AAA,IAAI0B,eAAe,EAAE;EACnB,MAAA,IAAI,CAAClB,mCAAmC,CAACc,aAAa,CAAC;EACzD;EAGA,IAAA,IAAI,CAACA,aAAa,CAACX,OAAO,EAAE;EAC1B,MAAA;EACF;MAGA,MAAMgB,qBAAqB,GACzBL,aAAa,CAACtB,YAAY,CAAC,gBAAgB,CAAC,KAAK,WAAW;EAC9D,IAAA,IAAI2B,qBAAqB,EAAE;EACzB,MAAA,IAAI,CAACb,sBAAsB,CAACQ,aAAa,CAAC;EAC5C,KAAC,MAAM;EACL,MAAA,IAAI,CAACH,sBAAsB,CAACG,aAAa,CAAC;EAC5C;EACF;EAMF;EAvMa7B,UAAU,CAsMdnC,UAAU,GAAG,kBAAkB;;;;;;;;"}
|
@@ -1,3 +1,33 @@
|
|
1
|
+
function isInitialised($root, moduleName) {
|
2
|
+
return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
|
3
|
+
}
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Checks if GOV.UK Frontend is supported on this page
|
7
|
+
*
|
8
|
+
* Some browsers will load and run our JavaScript but GOV.UK Frontend
|
9
|
+
* won't be supported.
|
10
|
+
*
|
11
|
+
* @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support
|
12
|
+
* @returns {boolean} Whether GOV.UK Frontend is supported on this page
|
13
|
+
*/
|
14
|
+
function isSupported($scope = document.body) {
|
15
|
+
if (!$scope) {
|
16
|
+
return false;
|
17
|
+
}
|
18
|
+
return $scope.classList.contains('govuk-frontend-supported');
|
19
|
+
}
|
20
|
+
function formatErrorMessage(Component, message) {
|
21
|
+
return `${Component.moduleName}: ${message}`;
|
22
|
+
}
|
23
|
+
/**
|
24
|
+
* @typedef ComponentWithModuleName
|
25
|
+
* @property {string} moduleName - Name of the component
|
26
|
+
*/
|
27
|
+
/**
|
28
|
+
* @import { ObjectNested } from './configuration.mjs'
|
29
|
+
*/
|
30
|
+
|
1
31
|
class GOVUKFrontendError extends Error {
|
2
32
|
constructor(...args) {
|
3
33
|
super(...args);
|
@@ -21,66 +51,91 @@ class ElementError extends GOVUKFrontendError {
|
|
21
51
|
let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
|
22
52
|
if (typeof messageOrOptions === 'object') {
|
23
53
|
const {
|
24
|
-
|
54
|
+
component,
|
25
55
|
identifier,
|
26
56
|
element,
|
27
57
|
expectedType
|
28
58
|
} = messageOrOptions;
|
29
|
-
message =
|
59
|
+
message = identifier;
|
30
60
|
message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
|
61
|
+
message = formatErrorMessage(component, message);
|
31
62
|
}
|
32
63
|
super(message);
|
33
64
|
this.name = 'ElementError';
|
34
65
|
}
|
35
66
|
}
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
67
|
+
class InitError extends GOVUKFrontendError {
|
68
|
+
constructor(componentOrMessage) {
|
69
|
+
const message = typeof componentOrMessage === 'string' ? componentOrMessage : formatErrorMessage(componentOrMessage, `Root element (\`$root\`) already initialised`);
|
70
|
+
super(message);
|
71
|
+
this.name = 'InitError';
|
40
72
|
}
|
41
|
-
return $scope.classList.contains('govuk-frontend-supported');
|
42
73
|
}
|
43
|
-
|
44
|
-
/**
|
45
|
-
* Schema for component config
|
46
|
-
*
|
47
|
-
* @typedef {object} Schema
|
48
|
-
* @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties
|
49
|
-
* @property {SchemaCondition[]} [anyOf] - List of schema conditions
|
50
|
-
*/
|
51
|
-
|
52
74
|
/**
|
53
|
-
*
|
54
|
-
*
|
55
|
-
* @typedef {object} SchemaProperty
|
56
|
-
* @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
|
57
|
-
*/
|
58
|
-
|
59
|
-
/**
|
60
|
-
* Schema condition for component config
|
61
|
-
*
|
62
|
-
* @typedef {object} SchemaCondition
|
63
|
-
* @property {string[]} required - List of required config fields
|
64
|
-
* @property {string} errorMessage - Error message when required config fields not provided
|
75
|
+
* @import { ComponentWithModuleName } from '../common/index.mjs'
|
65
76
|
*/
|
66
77
|
|
67
|
-
class
|
68
|
-
|
69
|
-
|
78
|
+
class Component {
|
79
|
+
/**
|
80
|
+
* Returns the root element of the component
|
81
|
+
*
|
82
|
+
* @protected
|
83
|
+
* @returns {RootElementType} - the root element of component
|
84
|
+
*/
|
85
|
+
get $root() {
|
86
|
+
return this._$root;
|
70
87
|
}
|
71
|
-
|
88
|
+
constructor($root) {
|
89
|
+
this._$root = void 0;
|
90
|
+
const childConstructor = this.constructor;
|
91
|
+
if (typeof childConstructor.moduleName !== 'string') {
|
92
|
+
throw new InitError(`\`moduleName\` not defined in component`);
|
93
|
+
}
|
94
|
+
if (!($root instanceof childConstructor.elementType)) {
|
95
|
+
throw new ElementError({
|
96
|
+
element: $root,
|
97
|
+
component: childConstructor,
|
98
|
+
identifier: 'Root element (`$root`)',
|
99
|
+
expectedType: childConstructor.elementType.name
|
100
|
+
});
|
101
|
+
} else {
|
102
|
+
this._$root = $root;
|
103
|
+
}
|
104
|
+
childConstructor.checkSupport();
|
105
|
+
this.checkInitialised();
|
106
|
+
const moduleName = childConstructor.moduleName;
|
107
|
+
this.$root.setAttribute(`data-${moduleName}-init`, '');
|
108
|
+
}
|
109
|
+
checkInitialised() {
|
110
|
+
const constructor = this.constructor;
|
111
|
+
const moduleName = constructor.moduleName;
|
112
|
+
if (moduleName && isInitialised(this.$root, moduleName)) {
|
113
|
+
throw new InitError(constructor);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
static checkSupport() {
|
72
117
|
if (!isSupported()) {
|
73
118
|
throw new SupportError();
|
74
119
|
}
|
75
120
|
}
|
76
121
|
}
|
77
122
|
|
123
|
+
/**
|
124
|
+
* @typedef ChildClass
|
125
|
+
* @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
|
126
|
+
*/
|
127
|
+
|
128
|
+
/**
|
129
|
+
* @typedef {typeof Component & ChildClass} ChildClassConstructor
|
130
|
+
*/
|
131
|
+
Component.elementType = HTMLElement;
|
132
|
+
|
78
133
|
/**
|
79
134
|
* Checkboxes component
|
80
135
|
*
|
81
136
|
* @preserve
|
82
137
|
*/
|
83
|
-
class Checkboxes extends
|
138
|
+
class Checkboxes extends Component {
|
84
139
|
/**
|
85
140
|
* Checkboxes can be associated with a 'conditionally revealed' content block
|
86
141
|
* – for example, a checkbox for 'Phone' could reveal an additional form field
|
@@ -93,27 +148,18 @@ class Checkboxes extends GOVUKFrontendComponent {
|
|
93
148
|
* (for example if the user has navigated back), and set up event handlers to
|
94
149
|
* keep the reveal in sync with the checkbox state.
|
95
150
|
*
|
96
|
-
* @param {Element | null} $
|
151
|
+
* @param {Element | null} $root - HTML element to use for checkboxes
|
97
152
|
*/
|
98
|
-
constructor($
|
99
|
-
super();
|
100
|
-
this.$module = void 0;
|
153
|
+
constructor($root) {
|
154
|
+
super($root);
|
101
155
|
this.$inputs = void 0;
|
102
|
-
|
103
|
-
throw new ElementError({
|
104
|
-
componentName: 'Checkboxes',
|
105
|
-
element: $module,
|
106
|
-
identifier: 'Root element (`$module`)'
|
107
|
-
});
|
108
|
-
}
|
109
|
-
const $inputs = $module.querySelectorAll('input[type="checkbox"]');
|
156
|
+
const $inputs = this.$root.querySelectorAll('input[type="checkbox"]');
|
110
157
|
if (!$inputs.length) {
|
111
158
|
throw new ElementError({
|
112
|
-
|
159
|
+
component: Checkboxes,
|
113
160
|
identifier: 'Form inputs (`<input type="checkbox">`)'
|
114
161
|
});
|
115
162
|
}
|
116
|
-
this.$module = $module;
|
117
163
|
this.$inputs = $inputs;
|
118
164
|
this.$inputs.forEach($input => {
|
119
165
|
const targetId = $input.getAttribute('data-aria-controls');
|
@@ -122,7 +168,7 @@ class Checkboxes extends GOVUKFrontendComponent {
|
|
122
168
|
}
|
123
169
|
if (!document.getElementById(targetId)) {
|
124
170
|
throw new ElementError({
|
125
|
-
|
171
|
+
component: Checkboxes,
|
126
172
|
identifier: `Conditional reveal (\`id="${targetId}"\`)`
|
127
173
|
});
|
128
174
|
}
|
@@ -131,7 +177,7 @@ class Checkboxes extends GOVUKFrontendComponent {
|
|
131
177
|
});
|
132
178
|
window.addEventListener('pageshow', () => this.syncAllConditionalReveals());
|
133
179
|
this.syncAllConditionalReveals();
|
134
|
-
this.$
|
180
|
+
this.$root.addEventListener('click', event => this.handleClick(event));
|
135
181
|
}
|
136
182
|
syncAllConditionalReveals() {
|
137
183
|
this.$inputs.forEach($input => this.syncConditionalRevealWithInputState($input));
|