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
@@ -0,0 +1,744 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.GOVUKFrontend = global.GOVUKFrontend || {}));
|
5
|
+
})(this, (function (exports) { 'use strict';
|
6
|
+
|
7
|
+
function closestAttributeValue($element, attributeName) {
|
8
|
+
const $closestElementWithAttribute = $element.closest(`[${attributeName}]`);
|
9
|
+
return $closestElementWithAttribute ? $closestElementWithAttribute.getAttribute(attributeName) : null;
|
10
|
+
}
|
11
|
+
|
12
|
+
function isInitialised($root, moduleName) {
|
13
|
+
return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
|
14
|
+
}
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Checks if GOV.UK Frontend is supported on this page
|
18
|
+
*
|
19
|
+
* Some browsers will load and run our JavaScript but GOV.UK Frontend
|
20
|
+
* won't be supported.
|
21
|
+
*
|
22
|
+
* @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support
|
23
|
+
* @returns {boolean} Whether GOV.UK Frontend is supported on this page
|
24
|
+
*/
|
25
|
+
function isSupported($scope = document.body) {
|
26
|
+
if (!$scope) {
|
27
|
+
return false;
|
28
|
+
}
|
29
|
+
return $scope.classList.contains('govuk-frontend-supported');
|
30
|
+
}
|
31
|
+
function isArray(option) {
|
32
|
+
return Array.isArray(option);
|
33
|
+
}
|
34
|
+
function isObject(option) {
|
35
|
+
return !!option && typeof option === 'object' && !isArray(option);
|
36
|
+
}
|
37
|
+
function formatErrorMessage(Component, message) {
|
38
|
+
return `${Component.moduleName}: ${message}`;
|
39
|
+
}
|
40
|
+
/**
|
41
|
+
* @typedef ComponentWithModuleName
|
42
|
+
* @property {string} moduleName - Name of the component
|
43
|
+
*/
|
44
|
+
/**
|
45
|
+
* @import { ObjectNested } from './configuration.mjs'
|
46
|
+
*/
|
47
|
+
|
48
|
+
class GOVUKFrontendError extends Error {
|
49
|
+
constructor(...args) {
|
50
|
+
super(...args);
|
51
|
+
this.name = 'GOVUKFrontendError';
|
52
|
+
}
|
53
|
+
}
|
54
|
+
class SupportError extends GOVUKFrontendError {
|
55
|
+
/**
|
56
|
+
* Checks if GOV.UK Frontend is supported on this page
|
57
|
+
*
|
58
|
+
* @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support
|
59
|
+
*/
|
60
|
+
constructor($scope = document.body) {
|
61
|
+
const supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';
|
62
|
+
super($scope ? supportMessage : 'GOV.UK Frontend initialised without `<script type="module">`');
|
63
|
+
this.name = 'SupportError';
|
64
|
+
}
|
65
|
+
}
|
66
|
+
class ConfigError extends GOVUKFrontendError {
|
67
|
+
constructor(...args) {
|
68
|
+
super(...args);
|
69
|
+
this.name = 'ConfigError';
|
70
|
+
}
|
71
|
+
}
|
72
|
+
class ElementError extends GOVUKFrontendError {
|
73
|
+
constructor(messageOrOptions) {
|
74
|
+
let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
|
75
|
+
if (typeof messageOrOptions === 'object') {
|
76
|
+
const {
|
77
|
+
component,
|
78
|
+
identifier,
|
79
|
+
element,
|
80
|
+
expectedType
|
81
|
+
} = messageOrOptions;
|
82
|
+
message = identifier;
|
83
|
+
message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
|
84
|
+
message = formatErrorMessage(component, message);
|
85
|
+
}
|
86
|
+
super(message);
|
87
|
+
this.name = 'ElementError';
|
88
|
+
}
|
89
|
+
}
|
90
|
+
class InitError extends GOVUKFrontendError {
|
91
|
+
constructor(componentOrMessage) {
|
92
|
+
const message = typeof componentOrMessage === 'string' ? componentOrMessage : formatErrorMessage(componentOrMessage, `Root element (\`$root\`) already initialised`);
|
93
|
+
super(message);
|
94
|
+
this.name = 'InitError';
|
95
|
+
}
|
96
|
+
}
|
97
|
+
/**
|
98
|
+
* @import { ComponentWithModuleName } from '../common/index.mjs'
|
99
|
+
*/
|
100
|
+
|
101
|
+
class Component {
|
102
|
+
/**
|
103
|
+
* Returns the root element of the component
|
104
|
+
*
|
105
|
+
* @protected
|
106
|
+
* @returns {RootElementType} - the root element of component
|
107
|
+
*/
|
108
|
+
get $root() {
|
109
|
+
return this._$root;
|
110
|
+
}
|
111
|
+
constructor($root) {
|
112
|
+
this._$root = void 0;
|
113
|
+
const childConstructor = this.constructor;
|
114
|
+
if (typeof childConstructor.moduleName !== 'string') {
|
115
|
+
throw new InitError(`\`moduleName\` not defined in component`);
|
116
|
+
}
|
117
|
+
if (!($root instanceof childConstructor.elementType)) {
|
118
|
+
throw new ElementError({
|
119
|
+
element: $root,
|
120
|
+
component: childConstructor,
|
121
|
+
identifier: 'Root element (`$root`)',
|
122
|
+
expectedType: childConstructor.elementType.name
|
123
|
+
});
|
124
|
+
} else {
|
125
|
+
this._$root = $root;
|
126
|
+
}
|
127
|
+
childConstructor.checkSupport();
|
128
|
+
this.checkInitialised();
|
129
|
+
const moduleName = childConstructor.moduleName;
|
130
|
+
this.$root.setAttribute(`data-${moduleName}-init`, '');
|
131
|
+
}
|
132
|
+
checkInitialised() {
|
133
|
+
const constructor = this.constructor;
|
134
|
+
const moduleName = constructor.moduleName;
|
135
|
+
if (moduleName && isInitialised(this.$root, moduleName)) {
|
136
|
+
throw new InitError(constructor);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
static checkSupport() {
|
140
|
+
if (!isSupported()) {
|
141
|
+
throw new SupportError();
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
|
146
|
+
/**
|
147
|
+
* @typedef ChildClass
|
148
|
+
* @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
|
149
|
+
*/
|
150
|
+
|
151
|
+
/**
|
152
|
+
* @typedef {typeof Component & ChildClass} ChildClassConstructor
|
153
|
+
*/
|
154
|
+
Component.elementType = HTMLElement;
|
155
|
+
|
156
|
+
const configOverride = Symbol.for('configOverride');
|
157
|
+
class ConfigurableComponent extends Component {
|
158
|
+
[configOverride](param) {
|
159
|
+
return {};
|
160
|
+
}
|
161
|
+
|
162
|
+
/**
|
163
|
+
* Returns the root element of the component
|
164
|
+
*
|
165
|
+
* @protected
|
166
|
+
* @returns {ConfigurationType} - the root element of component
|
167
|
+
*/
|
168
|
+
get config() {
|
169
|
+
return this._config;
|
170
|
+
}
|
171
|
+
constructor($root, config) {
|
172
|
+
super($root);
|
173
|
+
this._config = void 0;
|
174
|
+
const childConstructor = this.constructor;
|
175
|
+
if (!isObject(childConstructor.defaults)) {
|
176
|
+
throw new ConfigError(formatErrorMessage(childConstructor, 'Config passed as parameter into constructor but no defaults defined'));
|
177
|
+
}
|
178
|
+
const datasetConfig = normaliseDataset(childConstructor, this._$root.dataset);
|
179
|
+
this._config = mergeConfigs(childConstructor.defaults, config != null ? config : {}, this[configOverride](datasetConfig), datasetConfig);
|
180
|
+
}
|
181
|
+
}
|
182
|
+
function normaliseString(value, property) {
|
183
|
+
const trimmedValue = value ? value.trim() : '';
|
184
|
+
let output;
|
185
|
+
let outputType = property == null ? void 0 : property.type;
|
186
|
+
if (!outputType) {
|
187
|
+
if (['true', 'false'].includes(trimmedValue)) {
|
188
|
+
outputType = 'boolean';
|
189
|
+
}
|
190
|
+
if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {
|
191
|
+
outputType = 'number';
|
192
|
+
}
|
193
|
+
}
|
194
|
+
switch (outputType) {
|
195
|
+
case 'boolean':
|
196
|
+
output = trimmedValue === 'true';
|
197
|
+
break;
|
198
|
+
case 'number':
|
199
|
+
output = Number(trimmedValue);
|
200
|
+
break;
|
201
|
+
default:
|
202
|
+
output = value;
|
203
|
+
}
|
204
|
+
return output;
|
205
|
+
}
|
206
|
+
function normaliseDataset(Component, dataset) {
|
207
|
+
if (!isObject(Component.schema)) {
|
208
|
+
throw new ConfigError(formatErrorMessage(Component, 'Config passed as parameter into constructor but no schema defined'));
|
209
|
+
}
|
210
|
+
const out = {};
|
211
|
+
const entries = Object.entries(Component.schema.properties);
|
212
|
+
for (const entry of entries) {
|
213
|
+
const [namespace, property] = entry;
|
214
|
+
const field = namespace.toString();
|
215
|
+
if (field in dataset) {
|
216
|
+
out[field] = normaliseString(dataset[field], property);
|
217
|
+
}
|
218
|
+
if ((property == null ? void 0 : property.type) === 'object') {
|
219
|
+
out[field] = extractConfigByNamespace(Component.schema, dataset, namespace);
|
220
|
+
}
|
221
|
+
}
|
222
|
+
return out;
|
223
|
+
}
|
224
|
+
function mergeConfigs(...configObjects) {
|
225
|
+
const formattedConfigObject = {};
|
226
|
+
for (const configObject of configObjects) {
|
227
|
+
for (const key of Object.keys(configObject)) {
|
228
|
+
const option = formattedConfigObject[key];
|
229
|
+
const override = configObject[key];
|
230
|
+
if (isObject(option) && isObject(override)) {
|
231
|
+
formattedConfigObject[key] = mergeConfigs(option, override);
|
232
|
+
} else {
|
233
|
+
formattedConfigObject[key] = override;
|
234
|
+
}
|
235
|
+
}
|
236
|
+
}
|
237
|
+
return formattedConfigObject;
|
238
|
+
}
|
239
|
+
function extractConfigByNamespace(schema, dataset, namespace) {
|
240
|
+
const property = schema.properties[namespace];
|
241
|
+
if ((property == null ? void 0 : property.type) !== 'object') {
|
242
|
+
return;
|
243
|
+
}
|
244
|
+
const newObject = {
|
245
|
+
[namespace]: {}
|
246
|
+
};
|
247
|
+
for (const [key, value] of Object.entries(dataset)) {
|
248
|
+
let current = newObject;
|
249
|
+
const keyParts = key.split('.');
|
250
|
+
for (const [index, name] of keyParts.entries()) {
|
251
|
+
if (isObject(current)) {
|
252
|
+
if (index < keyParts.length - 1) {
|
253
|
+
if (!isObject(current[name])) {
|
254
|
+
current[name] = {};
|
255
|
+
}
|
256
|
+
current = current[name];
|
257
|
+
} else if (key !== namespace) {
|
258
|
+
current[name] = normaliseString(value);
|
259
|
+
}
|
260
|
+
}
|
261
|
+
}
|
262
|
+
}
|
263
|
+
return newObject[namespace];
|
264
|
+
}
|
265
|
+
/**
|
266
|
+
* Schema for component config
|
267
|
+
*
|
268
|
+
* @template {Partial<Record<keyof ConfigurationType, unknown>>} ConfigurationType
|
269
|
+
* @typedef {object} Schema
|
270
|
+
* @property {Record<keyof ConfigurationType, SchemaProperty | undefined>} properties - Schema properties
|
271
|
+
* @property {SchemaCondition<ConfigurationType>[]} [anyOf] - List of schema conditions
|
272
|
+
*/
|
273
|
+
/**
|
274
|
+
* Schema property for component config
|
275
|
+
*
|
276
|
+
* @typedef {object} SchemaProperty
|
277
|
+
* @property {'string' | 'boolean' | 'number' | 'object'} type - Property type
|
278
|
+
*/
|
279
|
+
/**
|
280
|
+
* Schema condition for component config
|
281
|
+
*
|
282
|
+
* @template {Partial<Record<keyof ConfigurationType, unknown>>} ConfigurationType
|
283
|
+
* @typedef {object} SchemaCondition
|
284
|
+
* @property {(keyof ConfigurationType)[]} required - List of required config fields
|
285
|
+
* @property {string} errorMessage - Error message when required config fields not provided
|
286
|
+
*/
|
287
|
+
/**
|
288
|
+
* @template {Partial<Record<keyof ConfigurationType, unknown>>} [ConfigurationType=ObjectNested]
|
289
|
+
* @typedef ChildClass
|
290
|
+
* @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
|
291
|
+
* @property {Schema<ConfigurationType>} [schema] - The schema of the component configuration
|
292
|
+
* @property {ConfigurationType} [defaults] - The default values of the configuration of the component
|
293
|
+
*/
|
294
|
+
/**
|
295
|
+
* @template {Partial<Record<keyof ConfigurationType, unknown>>} [ConfigurationType=ObjectNested]
|
296
|
+
* @typedef {typeof Component & ChildClass<ConfigurationType>} ChildClassConstructor<ConfigurationType>
|
297
|
+
*/
|
298
|
+
|
299
|
+
class I18n {
|
300
|
+
constructor(translations = {}, config = {}) {
|
301
|
+
var _config$locale;
|
302
|
+
this.translations = void 0;
|
303
|
+
this.locale = void 0;
|
304
|
+
this.translations = translations;
|
305
|
+
this.locale = (_config$locale = config.locale) != null ? _config$locale : document.documentElement.lang || 'en';
|
306
|
+
}
|
307
|
+
t(lookupKey, options) {
|
308
|
+
if (!lookupKey) {
|
309
|
+
throw new Error('i18n: lookup key missing');
|
310
|
+
}
|
311
|
+
let translation = this.translations[lookupKey];
|
312
|
+
if (typeof (options == null ? void 0 : options.count) === 'number' && typeof translation === 'object') {
|
313
|
+
const translationPluralForm = translation[this.getPluralSuffix(lookupKey, options.count)];
|
314
|
+
if (translationPluralForm) {
|
315
|
+
translation = translationPluralForm;
|
316
|
+
}
|
317
|
+
}
|
318
|
+
if (typeof translation === 'string') {
|
319
|
+
if (translation.match(/%{(.\S+)}/)) {
|
320
|
+
if (!options) {
|
321
|
+
throw new Error('i18n: cannot replace placeholders in string if no option data provided');
|
322
|
+
}
|
323
|
+
return this.replacePlaceholders(translation, options);
|
324
|
+
}
|
325
|
+
return translation;
|
326
|
+
}
|
327
|
+
return lookupKey;
|
328
|
+
}
|
329
|
+
replacePlaceholders(translationString, options) {
|
330
|
+
const formatter = Intl.NumberFormat.supportedLocalesOf(this.locale).length ? new Intl.NumberFormat(this.locale) : undefined;
|
331
|
+
return translationString.replace(/%{(.\S+)}/g, function (placeholderWithBraces, placeholderKey) {
|
332
|
+
if (Object.prototype.hasOwnProperty.call(options, placeholderKey)) {
|
333
|
+
const placeholderValue = options[placeholderKey];
|
334
|
+
if (placeholderValue === false || typeof placeholderValue !== 'number' && typeof placeholderValue !== 'string') {
|
335
|
+
return '';
|
336
|
+
}
|
337
|
+
if (typeof placeholderValue === 'number') {
|
338
|
+
return formatter ? formatter.format(placeholderValue) : `${placeholderValue}`;
|
339
|
+
}
|
340
|
+
return placeholderValue;
|
341
|
+
}
|
342
|
+
throw new Error(`i18n: no data found to replace ${placeholderWithBraces} placeholder in string`);
|
343
|
+
});
|
344
|
+
}
|
345
|
+
hasIntlPluralRulesSupport() {
|
346
|
+
return Boolean('PluralRules' in window.Intl && Intl.PluralRules.supportedLocalesOf(this.locale).length);
|
347
|
+
}
|
348
|
+
getPluralSuffix(lookupKey, count) {
|
349
|
+
count = Number(count);
|
350
|
+
if (!isFinite(count)) {
|
351
|
+
return 'other';
|
352
|
+
}
|
353
|
+
const translation = this.translations[lookupKey];
|
354
|
+
const preferredForm = this.hasIntlPluralRulesSupport() ? new Intl.PluralRules(this.locale).select(count) : this.selectPluralFormUsingFallbackRules(count);
|
355
|
+
if (typeof translation === 'object') {
|
356
|
+
if (preferredForm in translation) {
|
357
|
+
return preferredForm;
|
358
|
+
} else if ('other' in translation) {
|
359
|
+
console.warn(`i18n: Missing plural form ".${preferredForm}" for "${this.locale}" locale. Falling back to ".other".`);
|
360
|
+
return 'other';
|
361
|
+
}
|
362
|
+
}
|
363
|
+
throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`);
|
364
|
+
}
|
365
|
+
selectPluralFormUsingFallbackRules(count) {
|
366
|
+
count = Math.abs(Math.floor(count));
|
367
|
+
const ruleset = this.getPluralRulesForLocale();
|
368
|
+
if (ruleset) {
|
369
|
+
return I18n.pluralRules[ruleset](count);
|
370
|
+
}
|
371
|
+
return 'other';
|
372
|
+
}
|
373
|
+
getPluralRulesForLocale() {
|
374
|
+
const localeShort = this.locale.split('-')[0];
|
375
|
+
for (const pluralRule in I18n.pluralRulesMap) {
|
376
|
+
const languages = I18n.pluralRulesMap[pluralRule];
|
377
|
+
if (languages.includes(this.locale) || languages.includes(localeShort)) {
|
378
|
+
return pluralRule;
|
379
|
+
}
|
380
|
+
}
|
381
|
+
}
|
382
|
+
}
|
383
|
+
I18n.pluralRulesMap = {
|
384
|
+
arabic: ['ar'],
|
385
|
+
chinese: ['my', 'zh', 'id', 'ja', 'jv', 'ko', 'ms', 'th', 'vi'],
|
386
|
+
french: ['hy', 'bn', 'fr', 'gu', 'hi', 'fa', 'pa', 'zu'],
|
387
|
+
german: ['af', 'sq', 'az', 'eu', 'bg', 'ca', 'da', 'nl', 'en', 'et', 'fi', 'ka', 'de', 'el', 'hu', 'lb', 'no', 'so', 'sw', 'sv', 'ta', 'te', 'tr', 'ur'],
|
388
|
+
irish: ['ga'],
|
389
|
+
russian: ['ru', 'uk'],
|
390
|
+
scottish: ['gd'],
|
391
|
+
spanish: ['pt-PT', 'it', 'es'],
|
392
|
+
welsh: ['cy']
|
393
|
+
};
|
394
|
+
I18n.pluralRules = {
|
395
|
+
arabic(n) {
|
396
|
+
if (n === 0) {
|
397
|
+
return 'zero';
|
398
|
+
}
|
399
|
+
if (n === 1) {
|
400
|
+
return 'one';
|
401
|
+
}
|
402
|
+
if (n === 2) {
|
403
|
+
return 'two';
|
404
|
+
}
|
405
|
+
if (n % 100 >= 3 && n % 100 <= 10) {
|
406
|
+
return 'few';
|
407
|
+
}
|
408
|
+
if (n % 100 >= 11 && n % 100 <= 99) {
|
409
|
+
return 'many';
|
410
|
+
}
|
411
|
+
return 'other';
|
412
|
+
},
|
413
|
+
chinese() {
|
414
|
+
return 'other';
|
415
|
+
},
|
416
|
+
french(n) {
|
417
|
+
return n === 0 || n === 1 ? 'one' : 'other';
|
418
|
+
},
|
419
|
+
german(n) {
|
420
|
+
return n === 1 ? 'one' : 'other';
|
421
|
+
},
|
422
|
+
irish(n) {
|
423
|
+
if (n === 1) {
|
424
|
+
return 'one';
|
425
|
+
}
|
426
|
+
if (n === 2) {
|
427
|
+
return 'two';
|
428
|
+
}
|
429
|
+
if (n >= 3 && n <= 6) {
|
430
|
+
return 'few';
|
431
|
+
}
|
432
|
+
if (n >= 7 && n <= 10) {
|
433
|
+
return 'many';
|
434
|
+
}
|
435
|
+
return 'other';
|
436
|
+
},
|
437
|
+
russian(n) {
|
438
|
+
const lastTwo = n % 100;
|
439
|
+
const last = lastTwo % 10;
|
440
|
+
if (last === 1 && lastTwo !== 11) {
|
441
|
+
return 'one';
|
442
|
+
}
|
443
|
+
if (last >= 2 && last <= 4 && !(lastTwo >= 12 && lastTwo <= 14)) {
|
444
|
+
return 'few';
|
445
|
+
}
|
446
|
+
if (last === 0 || last >= 5 && last <= 9 || lastTwo >= 11 && lastTwo <= 14) {
|
447
|
+
return 'many';
|
448
|
+
}
|
449
|
+
return 'other';
|
450
|
+
},
|
451
|
+
scottish(n) {
|
452
|
+
if (n === 1 || n === 11) {
|
453
|
+
return 'one';
|
454
|
+
}
|
455
|
+
if (n === 2 || n === 12) {
|
456
|
+
return 'two';
|
457
|
+
}
|
458
|
+
if (n >= 3 && n <= 10 || n >= 13 && n <= 19) {
|
459
|
+
return 'few';
|
460
|
+
}
|
461
|
+
return 'other';
|
462
|
+
},
|
463
|
+
spanish(n) {
|
464
|
+
if (n === 1) {
|
465
|
+
return 'one';
|
466
|
+
}
|
467
|
+
if (n % 1000000 === 0 && n !== 0) {
|
468
|
+
return 'many';
|
469
|
+
}
|
470
|
+
return 'other';
|
471
|
+
},
|
472
|
+
welsh(n) {
|
473
|
+
if (n === 0) {
|
474
|
+
return 'zero';
|
475
|
+
}
|
476
|
+
if (n === 1) {
|
477
|
+
return 'one';
|
478
|
+
}
|
479
|
+
if (n === 2) {
|
480
|
+
return 'two';
|
481
|
+
}
|
482
|
+
if (n === 3) {
|
483
|
+
return 'few';
|
484
|
+
}
|
485
|
+
if (n === 6) {
|
486
|
+
return 'many';
|
487
|
+
}
|
488
|
+
return 'other';
|
489
|
+
}
|
490
|
+
};
|
491
|
+
|
492
|
+
/**
|
493
|
+
* File upload component
|
494
|
+
*
|
495
|
+
* @preserve
|
496
|
+
* @augments ConfigurableComponent<FileUploadConfig>
|
497
|
+
*/
|
498
|
+
class FileUpload extends ConfigurableComponent {
|
499
|
+
/**
|
500
|
+
* @param {Element | null} $root - File input element
|
501
|
+
* @param {FileUploadConfig} [config] - File Upload config
|
502
|
+
*/
|
503
|
+
constructor($root, config = {}) {
|
504
|
+
super($root, config);
|
505
|
+
this.$input = void 0;
|
506
|
+
this.$button = void 0;
|
507
|
+
this.$status = void 0;
|
508
|
+
this.i18n = void 0;
|
509
|
+
this.id = void 0;
|
510
|
+
this.$announcements = void 0;
|
511
|
+
this.enteredAnotherElement = void 0;
|
512
|
+
const $input = this.$root.querySelector('input');
|
513
|
+
if ($input === null) {
|
514
|
+
throw new ElementError({
|
515
|
+
component: FileUpload,
|
516
|
+
identifier: 'File inputs (`<input type="file">`)'
|
517
|
+
});
|
518
|
+
}
|
519
|
+
if ($input.type !== 'file') {
|
520
|
+
throw new ElementError(formatErrorMessage(FileUpload, 'File input (`<input type="file">`) attribute (`type`) is not `file`'));
|
521
|
+
}
|
522
|
+
this.$input = $input;
|
523
|
+
this.$input.setAttribute('hidden', 'true');
|
524
|
+
if (!this.$input.id) {
|
525
|
+
throw new ElementError({
|
526
|
+
component: FileUpload,
|
527
|
+
identifier: 'File input (`<input type="file">`) attribute (`id`)'
|
528
|
+
});
|
529
|
+
}
|
530
|
+
this.id = this.$input.id;
|
531
|
+
this.i18n = new I18n(this.config.i18n, {
|
532
|
+
locale: closestAttributeValue(this.$root, 'lang')
|
533
|
+
});
|
534
|
+
const $label = this.findLabel();
|
535
|
+
if (!$label.id) {
|
536
|
+
$label.id = `${this.id}-label`;
|
537
|
+
}
|
538
|
+
this.$input.id = `${this.id}-input`;
|
539
|
+
const $button = document.createElement('button');
|
540
|
+
$button.classList.add('govuk-file-upload-button');
|
541
|
+
$button.type = 'button';
|
542
|
+
$button.id = this.id;
|
543
|
+
$button.classList.add('govuk-file-upload-button--empty');
|
544
|
+
const ariaDescribedBy = this.$input.getAttribute('aria-describedby');
|
545
|
+
if (ariaDescribedBy) {
|
546
|
+
$button.setAttribute('aria-describedby', ariaDescribedBy);
|
547
|
+
}
|
548
|
+
const $status = document.createElement('span');
|
549
|
+
$status.className = 'govuk-body govuk-file-upload-button__status';
|
550
|
+
$status.setAttribute('aria-live', 'polite');
|
551
|
+
$status.innerText = this.i18n.t('noFileChosen');
|
552
|
+
$button.appendChild($status);
|
553
|
+
const commaSpan = document.createElement('span');
|
554
|
+
commaSpan.className = 'govuk-visually-hidden';
|
555
|
+
commaSpan.innerText = ', ';
|
556
|
+
commaSpan.id = `${this.id}-comma`;
|
557
|
+
$button.appendChild(commaSpan);
|
558
|
+
const containerSpan = document.createElement('span');
|
559
|
+
containerSpan.className = 'govuk-file-upload-button__pseudo-button-container';
|
560
|
+
const buttonSpan = document.createElement('span');
|
561
|
+
buttonSpan.className = 'govuk-button govuk-button--secondary govuk-file-upload-button__pseudo-button';
|
562
|
+
buttonSpan.innerText = this.i18n.t('chooseFilesButton');
|
563
|
+
containerSpan.appendChild(buttonSpan);
|
564
|
+
containerSpan.insertAdjacentText('beforeend', ' ');
|
565
|
+
const instructionSpan = document.createElement('span');
|
566
|
+
instructionSpan.className = 'govuk-body govuk-file-upload-button__instruction';
|
567
|
+
instructionSpan.innerText = this.i18n.t('dropInstruction');
|
568
|
+
containerSpan.appendChild(instructionSpan);
|
569
|
+
$button.appendChild(containerSpan);
|
570
|
+
$button.setAttribute('aria-labelledby', `${$label.id} ${commaSpan.id} ${$button.id}`);
|
571
|
+
$button.addEventListener('click', this.onClick.bind(this));
|
572
|
+
$button.addEventListener('dragover', event => {
|
573
|
+
event.preventDefault();
|
574
|
+
});
|
575
|
+
this.$root.insertAdjacentElement('afterbegin', $button);
|
576
|
+
this.$input.setAttribute('tabindex', '-1');
|
577
|
+
this.$input.setAttribute('aria-hidden', 'true');
|
578
|
+
this.$button = $button;
|
579
|
+
this.$status = $status;
|
580
|
+
this.$input.addEventListener('change', this.onChange.bind(this));
|
581
|
+
this.updateDisabledState();
|
582
|
+
this.observeDisabledState();
|
583
|
+
this.$announcements = document.createElement('span');
|
584
|
+
this.$announcements.classList.add('govuk-file-upload-announcements');
|
585
|
+
this.$announcements.classList.add('govuk-visually-hidden');
|
586
|
+
this.$announcements.setAttribute('aria-live', 'assertive');
|
587
|
+
this.$root.insertAdjacentElement('afterend', this.$announcements);
|
588
|
+
this.$button.addEventListener('drop', this.onDrop.bind(this));
|
589
|
+
document.addEventListener('dragenter', this.updateDropzoneVisibility.bind(this));
|
590
|
+
document.addEventListener('dragenter', () => {
|
591
|
+
this.enteredAnotherElement = true;
|
592
|
+
});
|
593
|
+
document.addEventListener('dragleave', () => {
|
594
|
+
if (!this.enteredAnotherElement && !this.$button.disabled) {
|
595
|
+
this.hideDraggingState();
|
596
|
+
this.$announcements.innerText = this.i18n.t('leftDropZone');
|
597
|
+
}
|
598
|
+
this.enteredAnotherElement = false;
|
599
|
+
});
|
600
|
+
}
|
601
|
+
updateDropzoneVisibility(event) {
|
602
|
+
if (this.$button.disabled) return;
|
603
|
+
if (event.target instanceof Node) {
|
604
|
+
if (this.$root.contains(event.target)) {
|
605
|
+
if (event.dataTransfer && isContainingFiles(event.dataTransfer)) {
|
606
|
+
if (!this.$button.classList.contains('govuk-file-upload-button--dragging')) {
|
607
|
+
this.showDraggingState();
|
608
|
+
this.$announcements.innerText = this.i18n.t('enteredDropZone');
|
609
|
+
}
|
610
|
+
}
|
611
|
+
} else {
|
612
|
+
if (this.$button.classList.contains('govuk-file-upload-button--dragging')) {
|
613
|
+
this.hideDraggingState();
|
614
|
+
this.$announcements.innerText = this.i18n.t('leftDropZone');
|
615
|
+
}
|
616
|
+
}
|
617
|
+
}
|
618
|
+
}
|
619
|
+
showDraggingState() {
|
620
|
+
this.$button.classList.add('govuk-file-upload-button--dragging');
|
621
|
+
}
|
622
|
+
hideDraggingState() {
|
623
|
+
this.$button.classList.remove('govuk-file-upload-button--dragging');
|
624
|
+
}
|
625
|
+
onDrop(event) {
|
626
|
+
event.preventDefault();
|
627
|
+
if (event.dataTransfer && isContainingFiles(event.dataTransfer)) {
|
628
|
+
this.$input.files = event.dataTransfer.files;
|
629
|
+
this.$input.dispatchEvent(new CustomEvent('change'));
|
630
|
+
this.hideDraggingState();
|
631
|
+
}
|
632
|
+
}
|
633
|
+
onChange() {
|
634
|
+
const fileCount = this.$input.files.length;
|
635
|
+
if (fileCount === 0) {
|
636
|
+
this.$status.innerText = this.i18n.t('noFileChosen');
|
637
|
+
this.$button.classList.add('govuk-file-upload-button--empty');
|
638
|
+
} else {
|
639
|
+
if (fileCount === 1) {
|
640
|
+
this.$status.innerText = this.$input.files[0].name;
|
641
|
+
} else {
|
642
|
+
this.$status.innerText = this.i18n.t('multipleFilesChosen', {
|
643
|
+
count: fileCount
|
644
|
+
});
|
645
|
+
}
|
646
|
+
this.$button.classList.remove('govuk-file-upload-button--empty');
|
647
|
+
}
|
648
|
+
}
|
649
|
+
findLabel() {
|
650
|
+
const $label = document.querySelector(`label[for="${this.$input.id}"]`);
|
651
|
+
if (!$label) {
|
652
|
+
throw new ElementError({
|
653
|
+
component: FileUpload,
|
654
|
+
identifier: `Field label (\`<label for=${this.$input.id}>\`)`
|
655
|
+
});
|
656
|
+
}
|
657
|
+
return $label;
|
658
|
+
}
|
659
|
+
onClick() {
|
660
|
+
this.$input.click();
|
661
|
+
}
|
662
|
+
observeDisabledState() {
|
663
|
+
const observer = new MutationObserver(mutationList => {
|
664
|
+
for (const mutation of mutationList) {
|
665
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'disabled') {
|
666
|
+
this.updateDisabledState();
|
667
|
+
}
|
668
|
+
}
|
669
|
+
});
|
670
|
+
observer.observe(this.$input, {
|
671
|
+
attributes: true
|
672
|
+
});
|
673
|
+
}
|
674
|
+
updateDisabledState() {
|
675
|
+
this.$button.disabled = this.$input.disabled;
|
676
|
+
this.$root.classList.toggle('govuk-drop-zone--disabled', this.$button.disabled);
|
677
|
+
}
|
678
|
+
}
|
679
|
+
FileUpload.moduleName = 'govuk-file-upload';
|
680
|
+
FileUpload.defaults = Object.freeze({
|
681
|
+
i18n: {
|
682
|
+
chooseFilesButton: 'Choose file',
|
683
|
+
dropInstruction: 'or drop file',
|
684
|
+
noFileChosen: 'No file chosen',
|
685
|
+
multipleFilesChosen: {
|
686
|
+
one: '%{count} file chosen',
|
687
|
+
other: '%{count} files chosen'
|
688
|
+
},
|
689
|
+
enteredDropZone: 'Entered drop zone',
|
690
|
+
leftDropZone: 'Left drop zone'
|
691
|
+
}
|
692
|
+
});
|
693
|
+
FileUpload.schema = Object.freeze({
|
694
|
+
properties: {
|
695
|
+
i18n: {
|
696
|
+
type: 'object'
|
697
|
+
}
|
698
|
+
}
|
699
|
+
});
|
700
|
+
function isContainingFiles(dataTransfer) {
|
701
|
+
const hasNoTypesInfo = dataTransfer.types.length === 0;
|
702
|
+
const isDraggingFiles = dataTransfer.types.some(type => type === 'Files');
|
703
|
+
return hasNoTypesInfo || isDraggingFiles;
|
704
|
+
}
|
705
|
+
|
706
|
+
/**
|
707
|
+
* @typedef {HTMLInputElement & {files: FileList}} HTMLFileInputElement
|
708
|
+
*/
|
709
|
+
|
710
|
+
/**
|
711
|
+
* File upload config
|
712
|
+
*
|
713
|
+
* @see {@link FileUpload.defaults}
|
714
|
+
* @typedef {object} FileUploadConfig
|
715
|
+
* @property {FileUploadTranslations} [i18n=FileUpload.defaults.i18n] - File upload translations
|
716
|
+
*/
|
717
|
+
|
718
|
+
/**
|
719
|
+
* File upload translations
|
720
|
+
*
|
721
|
+
* @see {@link FileUpload.defaults.i18n}
|
722
|
+
* @typedef {object} FileUploadTranslations
|
723
|
+
*
|
724
|
+
* Messages used by the component
|
725
|
+
* @property {string} [chooseFile] - The text of the button that opens the file picker
|
726
|
+
* @property {string} [dropInstruction] - The text informing users they can drop files
|
727
|
+
* @property {TranslationPluralForms} [multipleFilesChosen] - The text displayed when multiple files
|
728
|
+
* have been chosen by the user
|
729
|
+
* @property {string} [noFileChosen] - The text to displayed when no file has been chosen by the user
|
730
|
+
* @property {string} [enteredDropZone] - The text announced by assistive technology
|
731
|
+
* when user drags files and enters the drop zone
|
732
|
+
* @property {string} [leftDropZone] - The text announced by assistive technology
|
733
|
+
* when user drags files and leaves the drop zone without dropping
|
734
|
+
*/
|
735
|
+
|
736
|
+
/**
|
737
|
+
* @import { Schema } from '../../common/configuration.mjs'
|
738
|
+
* @import { TranslationPluralForms } from '../../i18n.mjs'
|
739
|
+
*/
|
740
|
+
|
741
|
+
exports.FileUpload = FileUpload;
|
742
|
+
|
743
|
+
}));
|
744
|
+
//# sourceMappingURL=file-upload.bundle.js.map
|