govuk_publishing_components 35.3.3 → 35.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +4 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js +1 -1
- data/app/assets/stylesheets/component_guide/application.scss +37 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +10 -6
- data/app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_brand-colours.scss +0 -24
- data/app/views/govuk_publishing_components/component_guide/example.html.erb +1 -1
- data/app/views/govuk_publishing_components/component_guide/preview.html.erb +1 -1
- data/app/views/govuk_publishing_components/component_guide/show.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +2 -2
- data/app/views/govuk_publishing_components/components/_metadata.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_related_navigation.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_share_links.html.erb +6 -2
- data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/docs/metadata.yml +1 -3
- data/app/views/govuk_publishing_components/components/docs/organisation_logo.yml +5 -5
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_related.yml +1 -0
- data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +1 -1
- data/app/views/layouts/govuk_publishing_components/application.html.erb +1 -0
- data/config/locales/en.yml +2 -2
- data/lib/govuk_publishing_components/app_helpers/asset_helper.rb +4 -0
- data/lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb +1 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/axe-core/axe.d.ts +77 -6
- data/node_modules/axe-core/axe.js +955 -600
- data/node_modules/axe-core/axe.min.js +2 -2
- data/node_modules/axe-core/locales/_template.json +6 -6
- data/node_modules/axe-core/locales/ja.json +91 -11
- data/node_modules/axe-core/package.json +5 -5
- data/node_modules/axe-core/sri-history.json +4 -0
- data/node_modules/govuk-frontend/README.md +4 -5
- data/node_modules/govuk-frontend/govuk/all-ie8.scss +8 -0
- data/node_modules/govuk-frontend/govuk/all.js +738 -258
- data/node_modules/govuk-frontend/govuk/all.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +11 -7
- data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/common/govuk-frontend-version.js +17 -0
- data/node_modules/govuk-frontend/govuk/common/govuk-frontend-version.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/common/index.js +16 -4
- data/node_modules/govuk-frontend/govuk/common/index.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +20 -10
- data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/common.js +16 -4
- data/node_modules/govuk-frontend/govuk/common.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +3 -3
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +234 -86
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +32 -13
- data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +8 -2
- data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +1 -0
- data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/back-link/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/back-link/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +12 -12
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/button/_index.scss +8 -6
- data/node_modules/govuk-frontend/govuk/components/button/button.js +54 -19
- data/node_modules/govuk-frontend/govuk/components/button/button.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/button/fixtures.json +11 -1
- data/node_modules/govuk-frontend/govuk/components/button/macro-options.json +7 -1
- data/node_modules/govuk-frontend/govuk/components/button/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +170 -76
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +24 -24
- data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +3 -3
- data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +6 -6
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +75 -24
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +47 -47
- data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/checkboxes/template.njk +3 -3
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +24 -24
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +26 -26
- data/node_modules/govuk-frontend/govuk/components/date-input/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/date-input/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/details/details.js +39 -13
- data/node_modules/govuk-frontend/govuk/components/details/details.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/details/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +10 -10
- data/node_modules/govuk-frontend/govuk/components/error-message/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +67 -27
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +19 -19
- data/node_modules/govuk-frontend/govuk/components/error-summary/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/fieldset/fixtures.json +19 -19
- data/node_modules/govuk-frontend/govuk/components/fieldset/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +6 -1
- data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +14 -14
- data/node_modules/govuk-frontend/govuk/components/file-upload/macro-options.json +7 -1
- data/node_modules/govuk-frontend/govuk/components/file-upload/template.njk +2 -1
- data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +0 -7
- data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +24 -24
- data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +22 -22
- data/node_modules/govuk-frontend/govuk/components/header/header.js +46 -14
- data/node_modules/govuk-frontend/govuk/components/header/header.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/header/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/hint/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/hint/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/input/_index.scss +15 -3
- data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +54 -41
- data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +7 -1
- data/node_modules/govuk-frontend/govuk/components/input/template.njk +2 -1
- data/node_modules/govuk-frontend/govuk/components/inset-text/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/inset-text/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/label/fixtures.json +6 -6
- data/node_modules/govuk-frontend/govuk/components/label/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/notification-banner/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/notification-banner/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +49 -22
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +16 -16
- data/node_modules/govuk-frontend/govuk/components/pagination/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/panel/fixtures.json +10 -10
- data/node_modules/govuk-frontend/govuk/components/panel/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/phase-banner/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +5 -5
- data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +46 -46
- data/node_modules/govuk-frontend/govuk/components/radios/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js +65 -22
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/radios/template.njk +2 -2
- data/node_modules/govuk-frontend/govuk/components/select/_index.scss +7 -1
- data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +19 -20
- data/node_modules/govuk-frontend/govuk/components/select/macro-options.json +7 -1
- data/node_modules/govuk-frontend/govuk/components/select/template.njk +5 -2
- data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/skip-link/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +41 -13
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +34 -34
- data/node_modules/govuk-frontend/govuk/components/summary-list/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/table/fixtures.json +21 -21
- data/node_modules/govuk-frontend/govuk/components/table/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/tabs/fixtures.json +15 -15
- data/node_modules/govuk-frontend/govuk/components/tabs/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +178 -60
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/components/tabs/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/tag/_index.scss +18 -18
- data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/tag/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/textarea/_index.scss +8 -1
- data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +18 -18
- data/node_modules/govuk-frontend/govuk/components/textarea/macro-options.json +7 -1
- data/node_modules/govuk-frontend/govuk/components/textarea/template.njk +2 -1
- data/node_modules/govuk-frontend/govuk/components/warning-text/fixtures.json +9 -5
- data/node_modules/govuk-frontend/govuk/components/warning-text/macro-options.json +3 -3
- data/node_modules/govuk-frontend/govuk/components/warning-text/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/core/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/core/_govuk-frontend-version.scss +5 -0
- data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +5 -2
- data/node_modules/govuk-frontend/govuk/helpers/_focused.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_font-faces.scss +1 -1
- data/node_modules/govuk-frontend/govuk/i18n.js +38 -30
- data/node_modules/govuk-frontend/govuk/i18n.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/macros/i18n.njk +12 -11
- data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +1 -1
- data/node_modules/govuk-frontend/govuk/settings/_colours-organisations.scss +4 -0
- data/node_modules/govuk-frontend/govuk/settings/_ie8.scss +16 -0
- data/node_modules/govuk-frontend/govuk/settings/_links.scss +5 -1
- data/node_modules/govuk-frontend/govuk/tools/_ie8.scss +38 -2
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js +2 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +2 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js +2 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js +10 -3
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js +4 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +13 -7
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js +2 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +8 -2
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +8 -2
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js +4 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js +10 -3
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js +4 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js +2 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +3 -2
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js.map +1 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js +2 -1
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js.map +1 -1
- data/node_modules/govuk-frontend/govuk-esm/all.mjs +81 -60
- data/node_modules/govuk-frontend/govuk-esm/all.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs +12 -8
- data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/common/govuk-frontend-version.mjs +9 -0
- data/node_modules/govuk-frontend/govuk-esm/common/govuk-frontend-version.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/common/index.mjs +44 -29
- data/node_modules/govuk-frontend/govuk-esm/common/index.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs +15 -9
- data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/common.mjs +3 -5
- data/node_modules/govuk-frontend/govuk-esm/common.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +319 -211
- data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +47 -30
- data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +169 -115
- data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +88 -51
- data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +64 -54
- data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +69 -50
- data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +59 -35
- data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +36 -25
- data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +67 -38
- data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +49 -32
- data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +263 -163
- data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/i18n.mjs +68 -57
- data/node_modules/govuk-frontend/govuk-esm/i18n.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/DOMTokenList.mjs +5 -3
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/DOMTokenList.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs +4 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Document.mjs +4 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Document.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.mjs +7 -4
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/closest.mjs +5 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/closest.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs +13 -10
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/matches.mjs +4 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/matches.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.mjs +6 -3
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/previousElementSibling.mjs +6 -3
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/previousElementSibling.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element.mjs +5 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Event.mjs +7 -4
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Event.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/bind.mjs +5 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/bind.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/defineProperty.mjs +4 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/defineProperty.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs +5 -3
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Window.mjs +4 -2
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Window.mjs.map +1 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +1 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +2 -1
- data/node_modules/govuk-frontend/package.json +3 -2
- metadata +44 -7
- /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_13px.png → dbt_crest_13px.png} +0 -0
- /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_13px_x2.png → dbt_crest_13px_x2.png} +0 -0
- /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_18px.png → dbt_crest_18px.png} +0 -0
- /data/app/assets/images/govuk_publishing_components/crests/{dit_crest_18px_x2.png → dbt_crest_18px_x2.png} +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"tabs.mjs","sources":["../../../../src/govuk/components/tabs/tabs.mjs"],"sourcesContent":["/* eslint-disable es-x/no-function-prototype-bind -- Polyfill imported */\n\nimport { nodeListForEach } from '../../common/index.mjs'\nimport '../../vendor/polyfills/Element/prototype/classList.mjs'\nimport '../../vendor/polyfills/Element/prototype/nextElementSibling.mjs'\nimport '../../vendor/polyfills/Element/prototype/previousElementSibling.mjs'\nimport '../../vendor/polyfills/Event.mjs' // addEventListener, event.target normalization and DOMContentLoaded\nimport '../../vendor/polyfills/Function/prototype/bind.mjs'\n\n/**\n * Tabs component\n *\n * @class\n * @param {Element} $module - HTML element to use for tabs\n */\nfunction Tabs ($module) {\n if (!($module instanceof HTMLElement)) {\n return this\n }\n\n var $tabs = $module.querySelectorAll('a.govuk-tabs__tab')\n if (!$tabs.length) {\n return this\n }\n\n /** @deprecated Will be made private in v5.0 */\n this.$module = $module\n\n /** @deprecated Will be made private in v5.0 */\n this.$tabs = $tabs\n\n /** @deprecated Will be made private in v5.0 */\n this.keys = { left: 37, right: 39, up: 38, down: 40 }\n\n /** @deprecated Will be made private in v5.0 */\n this.jsHiddenClass = 'govuk-tabs__panel--hidden'\n\n // Save bounded functions to use when removing event listeners during teardown\n\n /** @deprecated Will be made private in v5.0 */\n this.boundTabClick = this.onTabClick.bind(this)\n\n /** @deprecated Will be made private in v5.0 */\n this.boundTabKeydown = this.onTabKeydown.bind(this)\n\n /** @deprecated Will be made private in v5.0 */\n this.boundOnHashChange = this.onHashChange.bind(this)\n\n /** @deprecated Will be made private in v5.0 */\n this.changingHash = false\n}\n\n/**\n * Initialise component\n */\nTabs.prototype.init = function () {\n // Check that required elements are present\n if (!this.$module || !this.$tabs) {\n return\n }\n\n if (typeof window.matchMedia === 'function') {\n this.setupResponsiveChecks()\n } else {\n this.setup()\n }\n}\n\n/**\n * Setup viewport resize check\n *\n * @deprecated Will be made private in v5.0\n */\nTabs.prototype.setupResponsiveChecks = function () {\n /** @deprecated Will be made private in v5.0 */\n this.mql = window.matchMedia('(min-width: 40.0625em)')\n this.mql.addListener(this.checkMode.bind(this))\n this.checkMode()\n}\n\n/**\n * Setup or teardown handler for viewport resize check\n *\n * @deprecated Will be made private in v5.0\n */\nTabs.prototype.checkMode = function () {\n if (this.mql.matches) {\n this.setup()\n } else {\n this.teardown()\n }\n}\n\n/**\n * Setup tab component\n *\n * @deprecated Will be made private in v5.0\n */\nTabs.prototype.setup = function () {\n var $component = this\n var $module = this.$module\n var $tabs = this.$tabs\n var $tabList = $module.querySelector('.govuk-tabs__list')\n var $tabListItems = $module.querySelectorAll('.govuk-tabs__list-item')\n\n if (!$tabs || !$tabList || !$tabListItems) {\n return\n }\n\n $tabList.setAttribute('role', 'tablist')\n\n nodeListForEach($tabListItems, function ($item) {\n $item.setAttribute('role', 'presentation')\n })\n\n nodeListForEach($tabs, function ($tab) {\n // Set HTML attributes\n $component.setAttributes($tab)\n\n // Handle events\n $tab.addEventListener('click', $component.boundTabClick, true)\n $tab.addEventListener('keydown', $component.boundTabKeydown, true)\n\n // Remove old active panels\n $component.hideTab($tab)\n })\n\n // Show either the active tab according to the URL's hash or the first tab\n var $activeTab = this.getTab(window.location.hash) || this.$tabs[0]\n if (!$activeTab) {\n return\n }\n\n this.showTab($activeTab)\n\n // Handle hashchange events\n window.addEventListener('hashchange', this.boundOnHashChange, true)\n}\n\n/**\n * Teardown tab component\n *\n * @deprecated Will be made private in v5.0\n */\nTabs.prototype.teardown = function () {\n var $component = this\n var $module = this.$module\n var $tabs = this.$tabs\n var $tabList = $module.querySelector('.govuk-tabs__list')\n var $tabListItems = $module.querySelectorAll('a.govuk-tabs__list-item')\n\n if (!$tabs || !$tabList || !$tabListItems) {\n return\n }\n\n $tabList.removeAttribute('role')\n\n nodeListForEach($tabListItems, function ($item) {\n $item.removeAttribute('role')\n })\n\n nodeListForEach($tabs, function ($tab) {\n // Remove events\n $tab.removeEventListener('click', $component.boundTabClick, true)\n $tab.removeEventListener('keydown', $component.boundTabKeydown, true)\n\n // Unset HTML attributes\n $component.unsetAttributes($tab)\n })\n\n // Remove hashchange event handler\n window.removeEventListener('hashchange', this.boundOnHashChange, true)\n}\n\n/**\n * Handle hashchange event\n *\n * @deprecated Will be made private in v5.0\n * @returns {void | undefined} Returns void, or undefined when prevented\n */\nTabs.prototype.onHashChange = function () {\n var hash = window.location.hash\n var $tabWithHash = this.getTab(hash)\n if (!$tabWithHash) {\n return\n }\n\n // Prevent changing the hash\n if (this.changingHash) {\n this.changingHash = false\n return\n }\n\n // Show either the active tab according to the URL's hash or the first tab\n var $previousTab = this.getCurrentTab()\n if (!$previousTab) {\n return\n }\n\n this.hideTab($previousTab)\n this.showTab($tabWithHash)\n $tabWithHash.focus()\n}\n\n/**\n * Hide panel for tab link\n *\n * @deprecated Will be made private in v5.0\n * @param {HTMLAnchorElement} $tab - Tab link\n */\nTabs.prototype.hideTab = function ($tab) {\n this.unhighlightTab($tab)\n this.hidePanel($tab)\n}\n\n/**\n * Show panel for tab link\n *\n * @deprecated Will be made private in v5.0\n * @param {HTMLAnchorElement} $tab - Tab link\n */\nTabs.prototype.showTab = function ($tab) {\n this.highlightTab($tab)\n this.showPanel($tab)\n}\n\n/**\n * Get tab link by hash\n *\n * @deprecated Will be made private in v5.0\n * @param {string} hash - Hash fragment including #\n * @returns {HTMLAnchorElement | null} Tab link\n */\nTabs.prototype.getTab = function (hash) {\n // @ts-expect-error `HTMLAnchorElement` type expected\n return this.$module.querySelector('a.govuk-tabs__tab[href=\"' + hash + '\"]')\n}\n\n/**\n * Set tab link and panel attributes\n *\n * @deprecated Will be made private in v5.0\n * @param {HTMLAnchorElement} $tab - Tab link\n */\nTabs.prototype.setAttributes = function ($tab) {\n // set tab attributes\n var panelId = this.getHref($tab).slice(1)\n $tab.setAttribute('id', 'tab_' + panelId)\n $tab.setAttribute('role', 'tab')\n $tab.setAttribute('aria-controls', panelId)\n $tab.setAttribute('aria-selected', 'false')\n $tab.setAttribute('tabindex', '-1')\n\n // set panel attributes\n var $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.setAttribute('role', 'tabpanel')\n $panel.setAttribute('aria-labelledby', $tab.id)\n $panel.classList.add(this.jsHiddenClass)\n}\n\n/**\n * Unset tab link and panel attributes\n *\n * @deprecated Will be made private in v5.0\n * @param {HTMLAnchorElement} $tab - Tab link\n */\nTabs.prototype.unsetAttributes = function ($tab) {\n // unset tab attributes\n $tab.removeAttribute('id')\n $tab.removeAttribute('role')\n $tab.removeAttribute('aria-controls')\n $tab.removeAttribute('aria-selected')\n $tab.removeAttribute('tabindex')\n\n // unset panel attributes\n var $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.removeAttribute('role')\n $panel.removeAttribute('aria-labelledby')\n $panel.classList.remove(this.jsHiddenClass)\n}\n\n/**\n * Handle tab link clicks\n *\n * @deprecated Will be made private in v5.0\n * @param {MouseEvent} event - Mouse click event\n * @returns {void} Returns void\n */\nTabs.prototype.onTabClick = function (event) {\n var $currentTab = this.getCurrentTab()\n var $nextTab = event.currentTarget\n\n if (!$currentTab || !($nextTab instanceof HTMLAnchorElement)) {\n return\n }\n\n event.preventDefault()\n\n this.hideTab($currentTab)\n this.showTab($nextTab)\n this.createHistoryEntry($nextTab)\n}\n\n/**\n * Update browser URL hash fragment for tab\n *\n * - Allows back/forward to navigate tabs\n * - Avoids page jump when hash changes\n *\n * @deprecated Will be made private in v5.0\n * @param {HTMLAnchorElement} $tab - Tab link\n */\nTabs.prototype.createHistoryEntry = function ($tab) {\n var $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n // Save and restore the id\n // so the page doesn't jump when a user clicks a tab (which changes the hash)\n var panelId = $panel.id\n $panel.id = ''\n this.changingHash = true\n window.location.hash = this.getHref($tab).slice(1)\n $panel.id = panelId\n}\n\n/**\n * Handle tab keydown event\n *\n * - Press right/down arrow for next tab\n * - Press left/up arrow for previous tab\n *\n * @deprecated Will be made private in v5.0\n * @param {KeyboardEvent} event - Keydown event\n */\nTabs.prototype.onTabKeydown = function (event) {\n switch (event.keyCode) {\n case this.keys.left:\n case this.keys.up:\n this.activatePreviousTab()\n event.preventDefault()\n break\n case this.keys.right:\n case this.keys.down:\n this.activateNextTab()\n event.preventDefault()\n break\n }\n}\n\n/**\n * Activate next tab\n *\n * @deprecated Will be made private in v5.0\n */\nTabs.prototype.activateNextTab = function () {\n var $currentTab = this.getCurrentTab()\n if (!$currentTab || !$currentTab.parentElement) {\n return\n }\n\n var $nextTabListItem = $currentTab.parentElement.nextElementSibling\n if (!$nextTabListItem) {\n return\n }\n\n var $nextTab = $nextTabListItem.querySelector('a.govuk-tabs__tab')\n if (!$nextTab) {\n return\n }\n\n this.hideTab($currentTab)\n this.showTab($nextTab)\n $nextTab.focus()\n this.createHistoryEntry($nextTab)\n}\n\n/**\n * Activate previous tab\n *\n * @deprecated Will be made private in v5.0\n */\nTabs.prototype.activatePreviousTab = function () {\n var $currentTab = this.getCurrentTab()\n if (!$currentTab || !$currentTab.parentElement) {\n return\n }\n\n var $previousTabListItem = $currentTab.parentElement.previousElementSibling\n if (!$previousTabListItem) {\n return\n }\n\n var $previousTab = $previousTabListItem.querySelector('a.govuk-tabs__tab')\n if (!$previousTab) {\n return\n }\n\n this.hideTab($currentTab)\n this.showTab($previousTab)\n $previousTab.focus()\n this.createHistoryEntry($previousTab)\n}\n\n/**\n * Get tab panel for tab link\n *\n * @deprecated Will be made private in v5.0\n * @param {HTMLAnchorElement} $tab - Tab link\n * @returns {Element | null} Tab panel\n */\nTabs.prototype.getPanel = function ($tab) {\n return this.$module.querySelector(this.getHref($tab))\n}\n\n/**\n * Show tab panel for tab link\n *\n * @deprecated Will be made private in v5.0\n * @param {HTMLAnchorElement} $tab - Tab link\n */\nTabs.prototype.showPanel = function ($tab) {\n var $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.classList.remove(this.jsHiddenClass)\n}\n\n/**\n * Hide tab panel for tab link\n *\n * @deprecated Will be made private in v5.0\n * @param {HTMLAnchorElement} $tab - Tab link\n */\nTabs.prototype.hidePanel = function ($tab) {\n var $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.classList.add(this.jsHiddenClass)\n}\n\n/**\n * Unset 'selected' state for tab link\n *\n * @deprecated Will be made private in v5.0\n * @param {HTMLAnchorElement} $tab - Tab link\n */\nTabs.prototype.unhighlightTab = function ($tab) {\n if (!$tab.parentElement) {\n return\n }\n\n $tab.setAttribute('aria-selected', 'false')\n $tab.parentElement.classList.remove('govuk-tabs__list-item--selected')\n $tab.setAttribute('tabindex', '-1')\n}\n\n/**\n * Set 'selected' state for tab link\n *\n * @deprecated Will be made private in v5.0\n * @param {HTMLAnchorElement} $tab - Tab link\n */\nTabs.prototype.highlightTab = function ($tab) {\n if (!$tab.parentElement) {\n return\n }\n\n $tab.setAttribute('aria-selected', 'true')\n $tab.parentElement.classList.add('govuk-tabs__list-item--selected')\n $tab.setAttribute('tabindex', '0')\n}\n\n/**\n * Get current tab link\n *\n * @deprecated Will be made private in v5.0\n * @returns {HTMLAnchorElement | null} Tab link\n */\nTabs.prototype.getCurrentTab = function () {\n return this.$module.querySelector('.govuk-tabs__list-item--selected a.govuk-tabs__tab')\n}\n\n/**\n * Get link hash fragment for href attribute\n *\n * this is because IE doesn't always return the actual value but a relative full path\n * should be a utility function most prob\n * {@link http://labs.thesedays.com/blog/2010/01/08/getting-the-href-value-with-jquery-in-ie/}\n *\n * @deprecated Will be made private in v5.0\n * @param {HTMLAnchorElement} $tab - Tab link\n * @returns {string} Hash fragment including #\n */\nTabs.prototype.getHref = function ($tab) {\n var href = $tab.getAttribute('href')\n var hash = href.slice(href.indexOf('#'), href.length)\n return hash\n}\n\nexport default Tabs\n"],"names":[],"mappings":";;;;;;;AAAA;AACA,AAOA;;;;;;;AAOA,SAAS,IAAI,EAAE,OAAO,EAAE;EACtB,IAAI,EAAE,OAAO,YAAY,WAAW,CAAC,EAAE;IACrC,OAAO,IAAI;GACZ;;EAED,IAAI,KAAK,GAAG,OAAO,CAAC,gBAAgB,CAAC,mBAAmB,EAAC;EACzD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;IACjB,OAAO,IAAI;GACZ;;;EAGD,IAAI,CAAC,OAAO,GAAG,QAAO;;;EAGtB,IAAI,CAAC,KAAK,GAAG,MAAK;;;EAGlB,IAAI,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,GAAE;;;EAGrD,IAAI,CAAC,aAAa,GAAG,4BAA2B;;;;;EAKhD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAC;;;EAG/C,IAAI,CAAC,eAAe,GAAG,IAAI,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AI,CAAC,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,iCAAiC,EAAC;EACtE,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,EAAC;EACpC;;;;;;;;AAQD,IAAI,CAAC,SAAS,CAAC,YAAY,GAAG,UAAU,IAAI,EAAE;EAC5C,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;IACvB,MAAM;GACP;;EAED,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,EAAC;EAC1C,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,iCAAiC,EAAC;EACnE,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,EAAC;EACnC;;;;;;;;AAQD,IAAI,CAAC,SAAS,CAAC,aAAa,GAAG,YAAY;EACzC,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,oDAAoD,CAAC;EACxF;;;;;;;;;;;;;AAaD,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,IAAI,EAAE;EACvC,IAAI,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAC;EACpC,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,EAAC;EACrD,OAAO,IAAI;CACZ;;;;"}
|
@@ -8,12 +8,12 @@
|
|
8
8
|
* @param {object} [config] - Configuration options for the function.
|
9
9
|
* @param {string} [config.locale] - An overriding locale for the PluralRules functionality.
|
10
10
|
*/
|
11
|
-
|
11
|
+
function I18n (translations, config) {
|
12
12
|
// Make list of translations available throughout function
|
13
|
-
this.translations = translations || {}
|
13
|
+
this.translations = translations || {};
|
14
14
|
|
15
15
|
// The locale to use for PluralRules and NumberFormat
|
16
|
-
this.locale = (config && config.locale) || document.documentElement.lang || 'en'
|
16
|
+
this.locale = (config && config.locale) || document.documentElement.lang || 'en';
|
17
17
|
}
|
18
18
|
|
19
19
|
/**
|
@@ -33,17 +33,17 @@ I18n.prototype.t = function (lookupKey, options) {
|
|
33
33
|
}
|
34
34
|
|
35
35
|
// If the `count` option is set, determine which plural suffix is needed and
|
36
|
-
// change the lookupKey to match. We check to see if it's
|
36
|
+
// change the lookupKey to match. We check to see if it's numeric instead of
|
37
37
|
// falsy, as this could legitimately be 0.
|
38
|
-
if (options && typeof options.count
|
38
|
+
if (options && typeof options.count === 'number') {
|
39
39
|
// Get the plural suffix
|
40
|
-
lookupKey = lookupKey + '.' + this.getPluralSuffix(lookupKey, options.count)
|
40
|
+
lookupKey = lookupKey + '.' + this.getPluralSuffix(lookupKey, options.count);
|
41
41
|
}
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
var translationString = this.translations[lookupKey]
|
43
|
+
// Fetch the translation string for that lookup key
|
44
|
+
var translationString = this.translations[lookupKey];
|
46
45
|
|
46
|
+
if (typeof translationString === 'string') {
|
47
47
|
// Check for ${} placeholders in the translation string
|
48
48
|
if (translationString.match(/%{(.\S+)}/)) {
|
49
49
|
if (!options) {
|
@@ -59,7 +59,7 @@ I18n.prototype.t = function (lookupKey, options) {
|
|
59
59
|
// return the lookup key itself as the fallback
|
60
60
|
return lookupKey
|
61
61
|
}
|
62
|
-
}
|
62
|
+
};
|
63
63
|
|
64
64
|
/**
|
65
65
|
* Takes a translation string with placeholders, and replaces the placeholders
|
@@ -70,33 +70,47 @@ I18n.prototype.t = function (lookupKey, options) {
|
|
70
70
|
* @returns {string} The translation string to output, with ${} placeholders replaced
|
71
71
|
*/
|
72
72
|
I18n.prototype.replacePlaceholders = function (translationString, options) {
|
73
|
-
|
73
|
+
/** @type {Intl.NumberFormat | undefined} */
|
74
|
+
var formatter;
|
74
75
|
|
75
76
|
if (this.hasIntlNumberFormatSupport()) {
|
76
|
-
formatter = new Intl.NumberFormat(this.locale)
|
77
|
+
formatter = new Intl.NumberFormat(this.locale);
|
77
78
|
}
|
78
79
|
|
79
|
-
return translationString.replace(
|
80
|
-
|
81
|
-
var placeholderValue = options[placeholderKey]
|
80
|
+
return translationString.replace(
|
81
|
+
/%{(.\S+)}/g,
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
83
|
+
/**
|
84
|
+
* Replace translation string placeholders
|
85
|
+
*
|
86
|
+
* @param {string} placeholderWithBraces - Placeholder with braces
|
87
|
+
* @param {string} placeholderKey - Placeholder key
|
88
|
+
* @returns {string} Placeholder value
|
89
|
+
*/
|
90
|
+
function (placeholderWithBraces, placeholderKey) {
|
91
|
+
if (Object.prototype.hasOwnProperty.call(options, placeholderKey)) {
|
92
|
+
var placeholderValue = options[placeholderKey];
|
88
93
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
94
|
+
// If a user has passed `false` as the value for the placeholder
|
95
|
+
// treat it as though the value should not be displayed
|
96
|
+
if (placeholderValue === false || (
|
97
|
+
typeof placeholderValue !== 'number' &&
|
98
|
+
typeof placeholderValue !== 'string')
|
99
|
+
) {
|
100
|
+
return ''
|
101
|
+
}
|
93
102
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
103
|
+
// If the placeholder's value is a number, localise the number formatting
|
104
|
+
if (typeof placeholderValue === 'number') {
|
105
|
+
return formatter ? formatter.format(placeholderValue) : placeholderValue.toString()
|
106
|
+
}
|
107
|
+
|
108
|
+
return placeholderValue
|
109
|
+
} else {
|
110
|
+
throw new Error('i18n: no data found to replace ' + placeholderWithBraces + ' placeholder in string')
|
111
|
+
}
|
112
|
+
})
|
113
|
+
};
|
100
114
|
|
101
115
|
/**
|
102
116
|
* Check to see if the browser supports Intl and Intl.PluralRules.
|
@@ -110,7 +124,7 @@ I18n.prototype.replacePlaceholders = function (translationString, options) {
|
|
110
124
|
*/
|
111
125
|
I18n.prototype.hasIntlPluralRulesSupport = function () {
|
112
126
|
return Boolean(window.Intl && ('PluralRules' in window.Intl && Intl.PluralRules.supportedLocalesOf(this.locale).length))
|
113
|
-
}
|
127
|
+
};
|
114
128
|
|
115
129
|
/**
|
116
130
|
* Check to see if the browser supports Intl and Intl.NumberFormat.
|
@@ -124,7 +138,7 @@ I18n.prototype.hasIntlPluralRulesSupport = function () {
|
|
124
138
|
*/
|
125
139
|
I18n.prototype.hasIntlNumberFormatSupport = function () {
|
126
140
|
return Boolean(window.Intl && ('NumberFormat' in window.Intl && Intl.NumberFormat.supportedLocalesOf(this.locale).length))
|
127
|
-
}
|
141
|
+
};
|
128
142
|
|
129
143
|
/**
|
130
144
|
* Get the appropriate suffix for the plural form.
|
@@ -146,18 +160,18 @@ I18n.prototype.getPluralSuffix = function (lookupKey, count) {
|
|
146
160
|
//
|
147
161
|
// Number(count) will turn anything that can't be converted to a Number type
|
148
162
|
// into 'NaN'. isFinite filters out NaN, as it isn't a finite number.
|
149
|
-
count = Number(count)
|
163
|
+
count = Number(count);
|
150
164
|
if (!isFinite(count)) { return 'other' }
|
151
165
|
|
152
|
-
var preferredForm
|
166
|
+
var preferredForm;
|
153
167
|
|
154
168
|
// Check to verify that all the requirements for Intl.PluralRules are met.
|
155
169
|
// If so, we can use that instead of our custom implementation. Otherwise,
|
156
170
|
// use the hardcoded fallback.
|
157
171
|
if (this.hasIntlPluralRulesSupport()) {
|
158
|
-
preferredForm = new Intl.PluralRules(this.locale).select(count)
|
172
|
+
preferredForm = new Intl.PluralRules(this.locale).select(count);
|
159
173
|
} else {
|
160
|
-
preferredForm = this.selectPluralFormUsingFallbackRules(count)
|
174
|
+
preferredForm = this.selectPluralFormUsingFallbackRules(count);
|
161
175
|
}
|
162
176
|
|
163
177
|
// Use the correct plural form if provided
|
@@ -168,7 +182,7 @@ I18n.prototype.getPluralSuffix = function (lookupKey, count) {
|
|
168
182
|
} else if (lookupKey + '.other' in this.translations) {
|
169
183
|
if (console && 'warn' in console) {
|
170
184
|
console.warn('i18n: Missing plural form ".' + preferredForm + '" for "' +
|
171
|
-
this.locale + '" locale. Falling back to ".other".')
|
185
|
+
this.locale + '" locale. Falling back to ".other".');
|
172
186
|
}
|
173
187
|
|
174
188
|
return 'other'
|
@@ -178,7 +192,7 @@ I18n.prototype.getPluralSuffix = function (lookupKey, count) {
|
|
178
192
|
'i18n: Plural form ".other" is required for "' + this.locale + '" locale'
|
179
193
|
)
|
180
194
|
}
|
181
|
-
}
|
195
|
+
};
|
182
196
|
|
183
197
|
/**
|
184
198
|
* Get the plural form using our fallback implementation
|
@@ -192,16 +206,16 @@ I18n.prototype.getPluralSuffix = function (lookupKey, count) {
|
|
192
206
|
I18n.prototype.selectPluralFormUsingFallbackRules = function (count) {
|
193
207
|
// Currently our custom code can only handle positive integers, so let's
|
194
208
|
// make sure our number is one of those.
|
195
|
-
count = Math.abs(Math.floor(count))
|
209
|
+
count = Math.abs(Math.floor(count));
|
196
210
|
|
197
|
-
var ruleset = this.getPluralRulesForLocale()
|
211
|
+
var ruleset = this.getPluralRulesForLocale();
|
198
212
|
|
199
213
|
if (ruleset) {
|
200
214
|
return I18n.pluralRules[ruleset](count)
|
201
215
|
}
|
202
216
|
|
203
217
|
return 'other'
|
204
|
-
}
|
218
|
+
};
|
205
219
|
|
206
220
|
/**
|
207
221
|
* Work out which pluralisation rules to use for the current locale
|
@@ -211,18 +225,18 @@ I18n.prototype.selectPluralFormUsingFallbackRules = function (count) {
|
|
211
225
|
* regardless of region. There are exceptions, however, (e.g. Portuguese) so
|
212
226
|
* this searches by both the full and shortened locale codes, just to be sure.
|
213
227
|
*
|
214
|
-
* @returns {
|
228
|
+
* @returns {string | undefined} The name of the pluralisation rule to use (a key for one
|
215
229
|
* of the functions in this.pluralRules)
|
216
230
|
*/
|
217
231
|
I18n.prototype.getPluralRulesForLocale = function () {
|
218
|
-
var locale = this.locale
|
219
|
-
var localeShort = locale.split('-')[0]
|
232
|
+
var locale = this.locale;
|
233
|
+
var localeShort = locale.split('-')[0];
|
220
234
|
|
221
235
|
// Look through the plural rules map to find which `pluralRule` is
|
222
236
|
// appropriate for our current `locale`.
|
223
237
|
for (var pluralRule in I18n.pluralRulesMap) {
|
224
238
|
if (Object.prototype.hasOwnProperty.call(I18n.pluralRulesMap, pluralRule)) {
|
225
|
-
var languages = I18n.pluralRulesMap[pluralRule]
|
239
|
+
var languages = I18n.pluralRulesMap[pluralRule];
|
226
240
|
for (var i = 0; i < languages.length; i++) {
|
227
241
|
if (languages[i] === locale || languages[i] === localeShort) {
|
228
242
|
return pluralRule
|
@@ -230,7 +244,7 @@ I18n.prototype.getPluralRulesForLocale = function () {
|
|
230
244
|
}
|
231
245
|
}
|
232
246
|
}
|
233
|
-
}
|
247
|
+
};
|
234
248
|
|
235
249
|
/**
|
236
250
|
* Map of plural rules to languages where those rules apply.
|
@@ -262,7 +276,7 @@ I18n.prototype.getPluralRulesForLocale = function () {
|
|
262
276
|
* Spanish: European Portuguese (pt-PT), Italian (it), Spanish (es)
|
263
277
|
* Welsh: Welsh (cy)
|
264
278
|
*
|
265
|
-
* @type {Object<
|
279
|
+
* @type {Object<string, string[]>}
|
266
280
|
*/
|
267
281
|
I18n.pluralRulesMap = {
|
268
282
|
arabic: ['ar'],
|
@@ -277,7 +291,7 @@ I18n.pluralRulesMap = {
|
|
277
291
|
scottish: ['gd'],
|
278
292
|
spanish: ['pt-PT', 'it', 'es'],
|
279
293
|
welsh: ['cy']
|
280
|
-
}
|
294
|
+
};
|
281
295
|
|
282
296
|
/**
|
283
297
|
* Different pluralisation rule sets
|
@@ -319,8 +333,8 @@ I18n.pluralRules = {
|
|
319
333
|
return 'other'
|
320
334
|
},
|
321
335
|
russian: function (n) {
|
322
|
-
var lastTwo = n % 100
|
323
|
-
var last = lastTwo % 10
|
336
|
+
var lastTwo = n % 100;
|
337
|
+
var last = lastTwo % 10;
|
324
338
|
if (last === 1 && lastTwo !== 11) { return 'one' }
|
325
339
|
if (last >= 2 && last <= 4 && !(lastTwo >= 12 && lastTwo <= 14)) { return 'few' }
|
326
340
|
if (last === 0 || (last >= 5 && last <= 9) || (lastTwo >= 11 && lastTwo <= 14)) { return 'many' }
|
@@ -348,13 +362,7 @@ I18n.pluralRules = {
|
|
348
362
|
return 'other'
|
349
363
|
}
|
350
364
|
/* eslint-enable jsdoc/require-jsdoc */
|
351
|
-
}
|
352
|
-
|
353
|
-
/**
|
354
|
-
* Supported languages for plural rules
|
355
|
-
*
|
356
|
-
* @typedef {'arabic' | 'chinese' | 'french' | 'german' | 'irish' | 'russian' | 'scottish' | 'spanish' | 'welsh'} PluralRuleName
|
357
|
-
*/
|
365
|
+
};
|
358
366
|
|
359
367
|
/**
|
360
368
|
* Plural rule category mnemonic tags
|
@@ -376,3 +384,6 @@ I18n.pluralRules = {
|
|
376
384
|
* @property {string} [few] - Plural form used for a few
|
377
385
|
* @property {string} [many] - Plural form used for many
|
378
386
|
*/
|
387
|
+
|
388
|
+
export { I18n };
|
389
|
+
//# sourceMappingURL=i18n.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"i18n.mjs","sources":["../../src/govuk/i18n.mjs"],"sourcesContent":["/**\n * Internal support for selecting messages to render, with placeholder\n * interpolation and locale-aware number formatting and pluralisation\n *\n * @class\n * @private\n * @param {Object<string, unknown>} translations - Key-value pairs of the translation strings to use.\n * @param {object} [config] - Configuration options for the function.\n * @param {string} [config.locale] - An overriding locale for the PluralRules functionality.\n */\nexport function I18n (translations, config) {\n // Make list of translations available throughout function\n this.translations = translations || {}\n\n // The locale to use for PluralRules and NumberFormat\n this.locale = (config && config.locale) || document.documentElement.lang || 'en'\n}\n\n/**\n * The most used function - takes the key for a given piece of UI text and\n * returns the appropriate string.\n *\n * @param {string} lookupKey - The lookup key of the string to use.\n * @param {Object<string, unknown>} [options] - Any options passed with the translation string, e.g: for string interpolation.\n * @returns {string} The appropriate translation string.\n * @throws {Error} Lookup key required\n * @throws {Error} Options required for `${}` placeholders\n */\nI18n.prototype.t = function (lookupKey, options) {\n if (!lookupKey) {\n // Print a console error if no lookup key has been provided\n throw new Error('i18n: lookup key missing')\n }\n\n // If the `count` option is set, determine which plural suffix is needed and\n // change the lookupKey to match. We check to see if it's numeric instead of\n // falsy, as this could legitimately be 0.\n if (options && typeof options.count === 'number') {\n // Get the plural suffix\n lookupKey = lookupKey + '.' + this.getPluralSuffix(lookupKey, options.count)\n }\n\n // Fetch the translation string for that lookup key\n var translationString = this.translations[lookupKey]\n\n if (typeof translationString === 'string') {\n // Check for ${} placeholders in the translation string\n if (translationString.match(/%{(.\\S+)}/)) {\n if (!options) {\n throw new Error('i18n: cannot replace placeholders in string if no option data provided')\n }\n\n return this.replacePlaceholders(translationString, options)\n } else {\n return translationString\n }\n } else {\n // If the key wasn't found in our translations object,\n // return the lookup key itself as the fallback\n return lookupKey\n }\n}\n\n/**\n * Takes a translation string with placeholders, and replaces the placeholders\n * with the provided data\n *\n * @param {string} translationString - The translation string\n * @param {Object<string, unknown>} options - Any options passed with the translation string, e.g: for string interpolation.\n * @returns {string} The translation string to output, with ${} placeholders replaced\n */\nI18n.prototype.replacePlaceholders = function (translationString, options) {\n /** @type {Intl.NumberFormat | undefined} */\n var formatter\n\n if (this.hasIntlNumberFormatSupport()) {\n formatter = new Intl.NumberFormat(this.locale)\n }\n\n return translationString.replace(\n /%{(.\\S+)}/g,\n\n /**\n * Replace translation string placeholders\n *\n * @param {string} placeholderWithBraces - Placeholder with braces\n * @param {string} placeholderKey - Placeholder key\n * @returns {string} Placeholder value\n */\n function (placeholderWithBraces, placeholderKey) {\n if (Object.prototype.hasOwnProperty.call(options, placeholderKey)) {\n var placeholderValue = options[placeholderKey]\n\n // If a user has passed `false` as the value for the placeholder\n // treat it as though the value should not be displayed\n if (placeholderValue === false || (\n typeof placeholderValue !== 'number' &&\n typeof placeholderValue !== 'string')\n ) {\n return ''\n }\n\n // If the placeholder's value is a number, localise the number formatting\n if (typeof placeholderValue === 'number') {\n return formatter ? formatter.format(placeholderValue) : placeholderValue.toString()\n }\n\n return placeholderValue\n } else {\n throw new Error('i18n: no data found to replace ' + placeholderWithBraces + ' placeholder in string')\n }\n })\n}\n\n/**\n * Check to see if the browser supports Intl and Intl.PluralRules.\n *\n * It requires all conditions to be met in order to be supported:\n * - The browser supports the Intl class (true in IE11)\n * - The implementation of Intl supports PluralRules (NOT true in IE11)\n * - The browser/OS has plural rules for the current locale (browser dependent)\n *\n * @returns {boolean} Returns true if all conditions are met. Returns false otherwise.\n */\nI18n.prototype.hasIntlPluralRulesSupport = function () {\n return Boolean(window.Intl && ('PluralRules' in window.Intl && Intl.PluralRules.supportedLocalesOf(this.locale).length))\n}\n\n/**\n * Check to see if the browser supports Intl and Intl.NumberFormat.\n *\n * It requires all conditions to be met in order to be supported:\n * - The browser supports the Intl class (true in IE11)\n * - The implementation of Intl supports NumberFormat (also true in IE11)\n * - The browser/OS has number formatting rules for the current locale (browser dependent)\n *\n * @returns {boolean} Returns true if all conditions are met. Returns false otherwise.\n */\nI18n.prototype.hasIntlNumberFormatSupport = function () {\n return Boolean(window.Intl && ('NumberFormat' in window.Intl && Intl.NumberFormat.supportedLocalesOf(this.locale).length))\n}\n\n/**\n * Get the appropriate suffix for the plural form.\n *\n * Uses Intl.PluralRules (or our own fallback implementation) to get the\n * 'preferred' form to use for the given count.\n *\n * Checks that a translation has been provided for that plural form – if it\n * hasn't, it'll fall back to the 'other' plural form (unless that doesn't exist\n * either, in which case an error will be thrown)\n *\n * @param {string} lookupKey - The lookup key of the string to use.\n * @param {number} count - Number used to determine which pluralisation to use.\n * @returns {PluralRule} The suffix associated with the correct pluralisation for this locale.\n * @throws {Error} Plural form `.other` required when preferred plural form is missing\n */\nI18n.prototype.getPluralSuffix = function (lookupKey, count) {\n // Validate that the number is actually a number.\n //\n // Number(count) will turn anything that can't be converted to a Number type\n // into 'NaN'. isFinite filters out NaN, as it isn't a finite number.\n count = Number(count)\n if (!isFinite(count)) { return 'other' }\n\n var preferredForm\n\n // Check to verify that all the requirements for Intl.PluralRules are met.\n // If so, we can use that instead of our custom implementation. Otherwise,\n // use the hardcoded fallback.\n if (this.hasIntlPluralRulesSupport()) {\n preferredForm = new Intl.PluralRules(this.locale).select(count)\n } else {\n preferredForm = this.selectPluralFormUsingFallbackRules(count)\n }\n\n // Use the correct plural form if provided\n if (lookupKey + '.' + preferredForm in this.translations) {\n return preferredForm\n // Fall back to `other` if the plural form is missing, but log a warning\n // to the console\n } else if (lookupKey + '.other' in this.translations) {\n if (console && 'warn' in console) {\n console.warn('i18n: Missing plural form \".' + preferredForm + '\" for \"' +\n this.locale + '\" locale. Falling back to \".other\".')\n }\n\n return 'other'\n // If the required `other` plural form is missing, all we can do is error\n } else {\n throw new Error(\n 'i18n: Plural form \".other\" is required for \"' + this.locale + '\" locale'\n )\n }\n}\n\n/**\n * Get the plural form using our fallback implementation\n *\n * This is split out into a separate function to make it easier to test the\n * fallback behaviour in an environment where Intl.PluralRules exists.\n *\n * @param {number} count - Number used to determine which pluralisation to use.\n * @returns {PluralRule} The pluralisation form for count in this locale.\n */\nI18n.prototype.selectPluralFormUsingFallbackRules = function (count) {\n // Currently our custom code can only handle positive integers, so let's\n // make sure our number is one of those.\n count = Math.abs(Math.floor(count))\n\n var ruleset = this.getPluralRulesForLocale()\n\n if (ruleset) {\n return I18n.pluralRules[ruleset](count)\n }\n\n return 'other'\n}\n\n/**\n * Work out which pluralisation rules to use for the current locale\n *\n * The locale may include a regional indicator (such as en-GB), but we don't\n * usually care about this part, as pluralisation rules are usually the same\n * regardless of region. There are exceptions, however, (e.g. Portuguese) so\n * this searches by both the full and shortened locale codes, just to be sure.\n *\n * @returns {string | undefined} The name of the pluralisation rule to use (a key for one\n * of the functions in this.pluralRules)\n */\nI18n.prototype.getPluralRulesForLocale = function () {\n var locale = this.locale\n var localeShort = locale.split('-')[0]\n\n // Look through the plural rules map to find which `pluralRule` is\n // appropriate for our current `locale`.\n for (var pluralRule in I18n.pluralRulesMap) {\n if (Object.prototype.hasOwnProperty.call(I18n.pluralRulesMap, pluralRule)) {\n var languages = I18n.pluralRulesMap[pluralRule]\n for (var i = 0; i < languages.length; i++) {\n if (languages[i] === locale || languages[i] === localeShort) {\n return pluralRule\n }\n }\n }\n }\n}\n\n/**\n * Map of plural rules to languages where those rules apply.\n *\n * Note: These groups are named for the most dominant or recognisable language\n * that uses each system. The groupings do not imply that the languages are\n * related to one another. Many languages have evolved the same systems\n * independently of one another.\n *\n * Code to support more languages can be found in the i18n spike:\n * {@link https://github.com/alphagov/govuk-frontend/blob/spike-i18n-support/src/govuk/i18n.mjs}\n *\n * Languages currently supported:\n *\n * Arabic: Arabic (ar)\n * Chinese: Burmese (my), Chinese (zh), Indonesian (id), Japanese (ja),\n * Javanese (jv), Korean (ko), Malay (ms), Thai (th), Vietnamese (vi)\n * French: Armenian (hy), Bangla (bn), French (fr), Gujarati (gu), Hindi (hi),\n * Persian Farsi (fa), Punjabi (pa), Zulu (zu)\n * German: Afrikaans (af), Albanian (sq), Azerbaijani (az), Basque (eu),\n * Bulgarian (bg), Catalan (ca), Danish (da), Dutch (nl), English (en),\n * Estonian (et), Finnish (fi), Georgian (ka), German (de), Greek (el),\n * Hungarian (hu), Luxembourgish (lb), Norwegian (no), Somali (so),\n * Swahili (sw), Swedish (sv), Tamil (ta), Telugu (te), Turkish (tr),\n * Urdu (ur)\n * Irish: Irish Gaelic (ga)\n * Russian: Russian (ru), Ukrainian (uk)\n * Scottish: Scottish Gaelic (gd)\n * Spanish: European Portuguese (pt-PT), Italian (it), Spanish (es)\n * Welsh: Welsh (cy)\n *\n * @type {Object<string, string[]>}\n */\nI18n.pluralRulesMap = {\n arabic: ['ar'],\n chinese: ['my', 'zh', 'id', 'ja', 'jv', 'ko', 'ms', 'th', 'vi'],\n french: ['hy', 'bn', 'fr', 'gu', 'hi', 'fa', 'pa', 'zu'],\n german: [\n 'af', 'sq', 'az', 'eu', 'bg', 'ca', 'da', 'nl', 'en', 'et', 'fi', 'ka',\n 'de', 'el', 'hu', 'lb', 'no', 'so', 'sw', 'sv', 'ta', 'te', 'tr', 'ur'\n ],\n irish: ['ga'],\n russian: ['ru', 'uk'],\n scottish: ['gd'],\n spanish: ['pt-PT', 'it', 'es'],\n welsh: ['cy']\n}\n\n/**\n * Different pluralisation rule sets\n *\n * Returns the appropriate suffix for the plural form associated with `n`.\n * Possible suffixes: 'zero', 'one', 'two', 'few', 'many', 'other' (the actual\n * meaning of each differs per locale). 'other' should always exist, even in\n * languages without plurals, such as Chinese.\n * {@link https://cldr.unicode.org/index/cldr-spec/plural-rules}\n *\n * The count must be a positive integer. Negative numbers and decimals aren't accounted for\n *\n * @type {Object<string, function(number): PluralRule>}\n */\nI18n.pluralRules = {\n /* eslint-disable jsdoc/require-jsdoc */\n arabic: function (n) {\n if (n === 0) { return 'zero' }\n if (n === 1) { return 'one' }\n if (n === 2) { return 'two' }\n if (n % 100 >= 3 && n % 100 <= 10) { return 'few' }\n if (n % 100 >= 11 && n % 100 <= 99) { return 'many' }\n return 'other'\n },\n chinese: function () {\n return 'other'\n },\n french: function (n) {\n return n === 0 || n === 1 ? 'one' : 'other'\n },\n german: function (n) {\n return n === 1 ? 'one' : 'other'\n },\n irish: function (n) {\n if (n === 1) { return 'one' }\n if (n === 2) { return 'two' }\n if (n >= 3 && n <= 6) { return 'few' }\n if (n >= 7 && n <= 10) { return 'many' }\n return 'other'\n },\n russian: function (n) {\n var lastTwo = n % 100\n var last = lastTwo % 10\n if (last === 1 && lastTwo !== 11) { return 'one' }\n if (last >= 2 && last <= 4 && !(lastTwo >= 12 && lastTwo <= 14)) { return 'few' }\n if (last === 0 || (last >= 5 && last <= 9) || (lastTwo >= 11 && lastTwo <= 14)) { return 'many' }\n // Note: The 'other' suffix is only used by decimal numbers in Russian.\n // We don't anticipate it being used, but it's here for consistency.\n return 'other'\n },\n scottish: function (n) {\n if (n === 1 || n === 11) { return 'one' }\n if (n === 2 || n === 12) { return 'two' }\n if ((n >= 3 && n <= 10) || (n >= 13 && n <= 19)) { return 'few' }\n return 'other'\n },\n spanish: function (n) {\n if (n === 1) { return 'one' }\n if (n % 1000000 === 0 && n !== 0) { return 'many' }\n return 'other'\n },\n welsh: function (n) {\n if (n === 0) { return 'zero' }\n if (n === 1) { return 'one' }\n if (n === 2) { return 'two' }\n if (n === 3) { return 'few' }\n if (n === 6) { return 'many' }\n return 'other'\n }\n /* eslint-enable jsdoc/require-jsdoc */\n}\n\n/**\n * Plural rule category mnemonic tags\n *\n * @typedef {'zero' | 'one' | 'two' | 'few' | 'many' | 'other'} PluralRule\n */\n\n/**\n * Translated message by plural rule they correspond to.\n *\n * Allows to group pluralised messages under a single key when passing\n * translations to a component's constructor\n *\n * @typedef {object} TranslationPluralForms\n * @property {string} [other] - General plural form\n * @property {string} [zero] - Plural form used with 0\n * @property {string} [one] - Plural form used with 1\n * @property {string} [two] - Plural form used with 2\n * @property {string} [few] - Plural form used for a few\n * @property {string} [many] - Plural form used for many\n */\n"],"names":[],"mappings":"AAAA;;;;;;;;;;AAUA,AAAO,SAAS,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE;;EAE1C,IAAI,CAAC,YAAY,GAAG,YAAY,IAAI,GAAE;;;EAGtC,IAAI,CAAC,MAAM,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,eAAe,CAAC,IAAI,IAAI,KAAI;CACjF;;;;;;;;;;;;AAYD,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,UAAU,SAAS,EAAE,OAAO,EAAE;EAC/C,IAAI,CAAC,SAAS,EAAE;;IAEd,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC;GAC5C;;;;;EAKD,IAAI,OAAO,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE;;IAEhD,SAAS,GAAG,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,EAAC;GAC7E;;;EAGD,IAAI,iBAAiB,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,EAAC;;EAEpD,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE;;IAEzC,IAAI,iBAAiB,CAAC,KAAK,CAAC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AO,KAAK,EAAE;IACzC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,KAAK,EAAE;IACzC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,EAAE;IACjE,OAAO,OAAO;GACf;EACD,OAAO,EAAE,UAAU,CAAC,EAAE;IACpB,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,KAAK,EAAE;IAC7B,IAAI,CAAC,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,MAAM,EAAE;IACnD,OAAO,OAAO;GACf;EACD,KAAK,EAAE,UAAU,CAAC,EAAE;IAClB,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,MAAM,EAAE;IAC9B,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,KAAK,EAAE;IAC7B,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,KAAK,EAAE;IAC7B,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,KAAK,EAAE;IAC7B,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,MAAM,EAAE;IAC9B,OAAO,OAAO;GACf;;EAEF;;;;;;;;;;;;;;;;;;;;;GAqBE;;;;"}
|
@@ -1,11 +1,12 @@
|
|
1
|
-
|
1
|
+
// @ts-nocheck
|
2
|
+
(function (undefined) {
|
2
3
|
|
3
4
|
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
|
4
5
|
var detect = (
|
5
6
|
'DOMTokenList' in this && (function (x) {
|
6
7
|
return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;
|
7
8
|
})(document.createElement('x'))
|
8
|
-
)
|
9
|
+
);
|
9
10
|
|
10
11
|
if (detect) return
|
11
12
|
|
@@ -261,4 +262,5 @@
|
|
261
262
|
|
262
263
|
}(this));
|
263
264
|
|
264
|
-
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
265
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
266
|
+
//# sourceMappingURL=vendor/polyfills/DOMTokenList.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"DOMTokenList.mjs","sources":["../../../../src/govuk/vendor/polyfills/DOMTokenList.mjs"],"sourcesContent":["// @ts-nocheck\n(function (undefined) {\n\n // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js\n var detect = (\n 'DOMTokenList' in this && (function (x) {\n return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;\n })(document.createElement('x'))\n )\n\n if (detect) return\n\n // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/polyfill.js\n (function (global) {\n var nativeImpl = \"DOMTokenList\" in global && global.DOMTokenList;\n\n if (\n !nativeImpl ||\n (\n !!document.createElementNS &&\n !!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&\n !(document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\").classList instanceof DOMTokenList)\n )\n ) {\n global.DOMTokenList = (function() { // eslint-disable-line no-unused-vars\n var dpSupport = true;\n var defineGetter = function (object, name, fn, configurable) {\n if (Object.defineProperty)\n Object.defineProperty(object, name, {\n configurable: false === dpSupport ? true : !!configurable,\n get: fn\n });\n\n else object.__defineGetter__(name, fn);\n };\n\n /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */\n try {\n defineGetter({}, \"support\");\n }\n catch (e) {\n dpSupport = false;\n }\n\n\n var _DOMTokenList = function (el, prop) {\n var that = this;\n var tokens = [];\n var tokenMap = {};\n var length = 0;\n var maxLength = 0;\n var addIndexGetter = function (i) {\n defineGetter(that, i, function () {\n preop();\n return tokens[i];\n }, false);\n\n };\n var reindex = function () {\n\n /** Define getter functions for array-like access to the tokenList's contents. */\n if (length >= maxLength)\n for (; maxLength < length; ++maxLength) {\n addIndexGetter(maxLength);\n }\n };\n\n /** Helper function called at the start of each class method. Internal use only. */\n var preop = function () {\n var error;\n var i;\n var args = arguments;\n var rSpace = /\\s+/;\n\n /** Validate the token/s passed to an instance method, if any. */\n if (args.length)\n for (i = 0; i < args.length; ++i)\n if (rSpace.test(args[i])) {\n error = new SyntaxError('String \"' + args[i] + '\" ' + \"contains\" + ' an invalid character');\n error.code = 5;\n error.name = \"InvalidCharacterError\";\n throw error;\n }\n\n\n /** Split the new value apart by whitespace*/\n if (typeof el[prop] === \"object\") {\n tokens = (\"\" + el[prop].baseVal).replace(/^\\s+|\\s+$/g, \"\").split(rSpace);\n } else {\n tokens = (\"\" + el[prop]).replace(/^\\s+|\\s+$/g, \"\").split(rSpace);\n }\n\n /** Avoid treating blank strings as single-item token lists */\n if (\"\" === tokens[0]) tokens = [];\n\n /** Repopulate the internal token lists */\n tokenMap = {};\n for (i = 0; i < tokens.length; ++i)\n tokenMap[tokens[i]] = true;\n length = tokens.length;\n reindex();\n };\n\n /** Populate our internal token list if the targeted attribute of the subject element isn't empty. */\n preop();\n\n /** Return the number of tokens in the underlying string. Read-only. */\n defineGetter(that, \"length\", function () {\n preop();\n return length;\n });\n\n /** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */\n that.toLocaleString =\n that.toString = function () {\n preop();\n return tokens.join(\" \");\n };\n\n that.item = function (idx) {\n preop();\n return tokens[idx];\n };\n\n that.contains = function (token) {\n preop();\n return !!tokenMap[token];\n };\n\n that.add = function () {\n preop.apply(that, args = arguments);\n\n for (var args, token, i = 0, l = args.length; i < l; ++i) {\n token = args[i];\n if (!tokenMap[token]) {\n tokens.push(token);\n tokenMap[token] = true;\n }\n }\n\n /** Update the targeted attribute of the attached element if the token list's changed. */\n if (length !== tokens.length) {\n length = tokens.length >>> 0;\n if (typeof el[prop] === \"object\") {\n el[prop].baseVal = tokens.join(\" \");\n } else {\n el[prop] = tokens.join(\" \");\n }\n reindex();\n }\n };\n\n that.remove = function () {\n preop.apply(that, args = arguments);\n\n /** Build a hash of token names to compare against when recollecting our token list. */\n for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {\n ignore[args[i]] = true;\n delete tokenMap[args[i]];\n }\n\n /** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */\n for (i = 0; i < tokens.length; ++i)\n if (!ignore[tokens[i]]) t.push(tokens[i]);\n\n tokens = t;\n length = t.length >>> 0;\n\n /** Update the targeted attribute of the attached element. */\n if (typeof el[prop] === \"object\") {\n el[prop].baseVal = tokens.join(\" \");\n } else {\n el[prop] = tokens.join(\" \");\n }\n reindex();\n };\n\n that.toggle = function (token, force) {\n preop.apply(that, [token]);\n\n /** Token state's being forced. */\n if (undefined !== force) {\n if (force) {\n that.add(token);\n return true;\n } else {\n that.remove(token);\n return false;\n }\n }\n\n /** Token already exists in tokenList. Remove it, and return FALSE. */\n if (tokenMap[token]) {\n that.remove(token);\n return false;\n }\n\n /** Otherwise, add the token and return TRUE. */\n that.add(token);\n return true;\n };\n\n return that;\n };\n\n return _DOMTokenList;\n }());\n }\n\n // Add second argument to native DOMTokenList.toggle() if necessary\n (function () {\n var e = document.createElement('span');\n if (!('classList' in e)) return;\n e.classList.toggle('x', false);\n if (!e.classList.contains('x')) return;\n e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {\n var force = arguments[1];\n if (force === undefined) {\n var add = !this.contains(token);\n this[add ? 'add' : 'remove'](token);\n return add;\n }\n force = !!force;\n this[force ? 'add' : 'remove'](token);\n return force;\n };\n }());\n\n // Add multiple arguments to native DOMTokenList.add() if necessary\n (function () {\n var e = document.createElement('span');\n if (!('classList' in e)) return;\n e.classList.add('a', 'b');\n if (e.classList.contains('b')) return;\n var native = e.classList.constructor.prototype.add;\n e.classList.constructor.prototype.add = function () {\n var args = arguments;\n var l = arguments.length;\n for (var i = 0; i < l; i++) {\n native.call(this, args[i]);\n }\n };\n }());\n\n // Add multiple arguments to native DOMTokenList.remove() if necessary\n (function () {\n var e = document.createElement('span');\n if (!('classList' in e)) return;\n e.classList.add('a');\n e.classList.add('b');\n e.classList.remove('a', 'b');\n if (!e.classList.contains('b')) return;\n var native = e.classList.constructor.prototype.remove;\n e.classList.constructor.prototype.remove = function () {\n var args = arguments;\n var l = arguments.length;\n for (var i = 0; i < l; i++) {\n native.call(this, args[i]);\n }\n };\n }());\n\n }(this));\n\n}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});"],"names":[],"mappings":"AAAA;AACA,CAAC,UAAU,SAAS,EAAE;;;IAGlB,IAAI,MAAM;MACR,cAAc,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE;QACtC,OAAO,WAAW,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC;OAClF,EAAE,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;MAChC;;IAED,IAAI,MAAM,EAAE,MAAM;;;IAGlB,CAAC,UAAU,MAAM,EAAE;MACjB,IAAI,UAAU,GAAG,cAAc,IAAI,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC;;MAEjE;UACI,CAAC,UAAU;;YAET,CAAC,CAAC,QAAQ,CAAC,eAAe;YAC1B,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,4BAA4B,EAAE,KAAK,CAAC;YAC/D,EAAE,QAAQ,CAAC,eAAe,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC,SAAS,YAAY,YAAY,CAAC;WACnG;UACD;QACF,MAAM,CAAC,YAAY,IAAI,WAAW;UAChC,IAAI,SAAS,GAAG,IAAI,CAAC;UACrB,IAAI,YAAY,GAAG,UAAU,MAAM,EAAE,IAAI,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AAC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO;QACvC,IAAI,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC;QACtD,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,GAAG,YAAY;UACrD,IAAI,IAAI,GAAG,SAAS,CAAC;UACrB,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC;UACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1B,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;WAC5B;SACF,CAAC;OACH,EAAE,EAAE;;KAEN,CAAC,IAAI,CAAC,EAAE;;CAEZ,EAAE,IAAI,CAAC,QAAQ,KAAK,OAAO,MAAM,IAAI,MAAM,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,IAAI,IAAI,QAAQ,KAAK,OAAO,MAAM,IAAI,MAAM,IAAI,EAAE,CAAC"}
|
@@ -1,7 +1,8 @@
|
|
1
|
-
|
1
|
+
// @ts-nocheck
|
2
|
+
(function (undefined) {
|
2
3
|
|
3
4
|
// Detection from https://github.com/Financial-Times/polyfill-library/blob/v3.111.0/polyfills/Date/now/detect.js
|
4
|
-
var detect = ('Date' in self && 'now' in self.Date && 'getTime' in self.Date.prototype)
|
5
|
+
var detect = ('Date' in self && 'now' in self.Date && 'getTime' in self.Date.prototype);
|
5
6
|
|
6
7
|
if (detect) return
|
7
8
|
|
@@ -11,3 +12,4 @@
|
|
11
12
|
};
|
12
13
|
|
13
14
|
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
15
|
+
//# sourceMappingURL=vendor/polyfills/Date/now.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"now.mjs","sources":["../../../../../src/govuk/vendor/polyfills/Date/now.mjs"],"sourcesContent":["// @ts-nocheck\n(function (undefined) {\n\n // Detection from https://github.com/Financial-Times/polyfill-library/blob/v3.111.0/polyfills/Date/now/detect.js\n var detect = ('Date' in self && 'now' in self.Date && 'getTime' in self.Date.prototype)\n\n if (detect) return\n\n // Polyfill from https://polyfill.io/v3/polyfill.js?version=3.111.0&features=Date.now&flags=always\n Date.now = function () {\n return new Date().getTime();\n };\n\n}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});\n"],"names":[],"mappings":"AAAA;AACA,CAAC,UAAU,SAAS,EAAE;;;IAGlB,IAAI,MAAM,IAAI,MAAM,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,IAAI,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC;;IAEvF,IAAI,MAAM,EAAE,MAAM;;;IAGlB,IAAI,CAAC,GAAG,GAAG,YAAY;QACnB,OAAO,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;KAC/B,CAAC;;CAEL,EAAE,IAAI,CAAC,QAAQ,KAAK,OAAO,MAAM,IAAI,MAAM,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,IAAI,IAAI,QAAQ,KAAK,OAAO,MAAM,IAAI,MAAM,IAAI,EAAE,CAAC,CAAC"}
|
@@ -1,7 +1,8 @@
|
|
1
|
-
|
1
|
+
// @ts-nocheck
|
2
|
+
(function (undefined) {
|
2
3
|
|
3
4
|
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
|
4
|
-
var detect = ("Document" in this)
|
5
|
+
var detect = ("Document" in this);
|
5
6
|
|
6
7
|
if (detect) return
|
7
8
|
|
@@ -24,3 +25,4 @@ if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "fun
|
|
24
25
|
|
25
26
|
})
|
26
27
|
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
28
|
+
//# sourceMappingURL=vendor/polyfills/Document.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Document.mjs","sources":["../../../../src/govuk/vendor/polyfills/Document.mjs"],"sourcesContent":["// @ts-nocheck\n(function (undefined) {\n\n// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js\nvar detect = (\"Document\" in this)\n\nif (detect) return\n\n// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always\nif ((typeof WorkerGlobalScope === \"undefined\") && (typeof importScripts !== \"function\")) {\n\n\tif (this.HTMLDocument) { // IE8\n\n\t\t// HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.\n\t\tthis.Document = this.HTMLDocument;\n\n\t} else {\n\n\t\t// Create an empty function to act as the missing constructor for the document object, attach the document object as its prototype. The function needs to be anonymous else it is hoisted and causes the feature detect to prematurely pass, preventing the assignments below being made.\n\t\tthis.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());\n\t\tthis.Document.prototype = document;\n\t}\n}\n\n\n})\n.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});\n"],"names":[],"mappings":"AAAA;AACA,CAAC,UAAU,SAAS,EAAE;;;AAGtB,IAAI,MAAM,IAAI,UAAU,IAAI,IAAI,EAAC;;AAEjC,IAAI,MAAM,EAAE,MAAM;;;AAGlB,IAAI,CAAC,OAAO,iBAAiB,KAAK,WAAW,MAAM,OAAO,aAAa,KAAK,UAAU,CAAC,EAAE;;CAExF,IAAI,IAAI,CAAC,YAAY,EAAE;;;EAGtB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC;;EAElC,MAAM;;;EAGN,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,WAAW,IAAI,IAAI,QAAQ,CAAC,+BAA+B,CAAC,EAAE,CAAC,CAAC;EAC7G,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG,QAAQ,CAAC;EACnC;CACD;;;CAGA;CACA,IAAI,CAAC,QAAQ,KAAK,OAAO,MAAM,IAAI,MAAM,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,IAAI,IAAI,QAAQ,KAAK,OAAO,MAAM,IAAI,MAAM,IAAI,EAAE,CAAC,CAAC"}
|
@@ -1,6 +1,8 @@
|
|
1
|
-
import '../../Object/defineProperty.mjs'
|
2
|
-
import '../../DOMTokenList.mjs'
|
3
|
-
import '../../Element.mjs'
|
1
|
+
import '../../Object/defineProperty.mjs';
|
2
|
+
import '../../DOMTokenList.mjs';
|
3
|
+
import '../../Element.mjs';
|
4
|
+
|
5
|
+
// @ts-nocheck
|
4
6
|
|
5
7
|
(function(undefined) {
|
6
8
|
|
@@ -11,7 +13,7 @@ import '../../Element.mjs'
|
|
11
13
|
e.classList.add('a', 'b');
|
12
14
|
return e.classList.contains('b');
|
13
15
|
}())
|
14
|
-
)
|
16
|
+
);
|
15
17
|
|
16
18
|
if (detect) return
|
17
19
|
|
@@ -91,3 +93,4 @@ import '../../Element.mjs'
|
|
91
93
|
}(this));
|
92
94
|
|
93
95
|
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
96
|
+
//# sourceMappingURL=vendor/polyfills/Element/prototype/classList.mjs.map
|
data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.mjs.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"classList.mjs","sources":["../../../../../../src/govuk/vendor/polyfills/Element/prototype/classList.mjs"],"sourcesContent":["// @ts-nocheck\nimport '../../Object/defineProperty.mjs'\nimport '../../DOMTokenList.mjs'\nimport '../../Element.mjs'\n\n(function(undefined) {\n\n // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/detect.js\n var detect = (\n 'document' in this && \"classList\" in document.documentElement && 'Element' in this && 'classList' in Element.prototype && (function () {\n var e = document.createElement('span');\n e.classList.add('a', 'b');\n return e.classList.contains('b');\n }())\n )\n\n if (detect) return\n\n // Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element.prototype.classList&flags=always\n (function (global) {\n var dpSupport = true;\n var defineGetter = function (object, name, fn, configurable) {\n if (Object.defineProperty)\n Object.defineProperty(object, name, {\n configurable: false === dpSupport ? true : !!configurable,\n get: fn\n });\n\n else object.__defineGetter__(name, fn);\n };\n /** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */\n try {\n defineGetter({}, \"support\");\n }\n catch (e) {\n dpSupport = false;\n }\n /** Polyfills a property with a DOMTokenList */\n var addProp = function (o, name, attr) {\n\n defineGetter(o.prototype, name, function () {\n var tokenList;\n\n var THIS = this,\n\n /** Prevent this from firing twice for some reason. What the hell, IE. */\n gibberishProperty = \"__defineGetter__\" + \"DEFINE_PROPERTY\" + name;\n if(THIS[gibberishProperty]) return tokenList;\n THIS[gibberishProperty] = true;\n\n /**\n * IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.\n *\n * What this is doing is creating a dummy element (\"reflection\") inside a detached phantom node (\"mirror\")\n * that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML\n * element instead, this would conflict with element types which use indexed properties (such as forms and\n * select lists).\n */\n if (false === dpSupport) {\n\n var visage;\n var mirror = addProp.mirror || document.createElement(\"div\");\n var reflections = mirror.childNodes;\n var l = reflections.length;\n\n for (var i = 0; i < l; ++i)\n if (reflections[i]._R === THIS) {\n visage = reflections[i];\n break;\n }\n\n /** Couldn't find an element's reflection inside the mirror. Materialise one. */\n visage || (visage = mirror.appendChild(document.createElement(\"div\")));\n\n tokenList = DOMTokenList.call(visage, THIS, attr);\n } else tokenList = new DOMTokenList(THIS, attr);\n\n defineGetter(THIS, name, function () {\n return tokenList;\n });\n delete THIS[gibberishProperty];\n\n return tokenList;\n }, true);\n };\n\n addProp(global.Element, \"classList\", \"className\");\n addProp(global.HTMLElement, \"classList\", \"className\");\n addProp(global.HTMLLinkElement, \"relList\", \"rel\");\n addProp(global.HTMLAnchorElement, \"relList\", \"rel\");\n addProp(global.HTMLAreaElement, \"relList\", \"rel\");\n }(this));\n\n}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});\n"],"names":[],"mappings":";;;;AAAA;AACA,AAGA;AACA,CAAC,SAAS,SAAS,EAAE;;;IAGjB,IAAI,MAAM;MACR,UAAU,IAAI,IAAI,IAAI,WAAW,IAAI,QAAQ,CAAC,eAAe,IAAI,SAAS,IAAI,IAAI,IAAI,WAAW,IAAI,OAAO,CAAC,SAAS,KAAK,YAAY;QACrI,IAAI,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1B,OAAO,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;OAClC,EAAE,CAAC;MACL;;IAED,IAAI,MAAM,EAAE,MAAM;;;IAGlB,CAAC,UAAU,MAAM,EAAE;MACjB,IAAI,SAAS,GAAG,IAAI,CAAC;MACrB,IAAI,YAAY,GAAG,UAAU,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE;QAC3D,IAAI,MAAM,CAAC,cAAc;UACvB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE;YAClC,YAAY,EAAE,KAAK,KAAK,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY;YACzD,GAAG,EAAE,EAAE;WACR,CAAC,CAAC;;aAEA,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;OACxC,CAAC;;MAEF,IAAI;QACF,YAAY,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;OAC7B;MACD,OAAO,CAAC,EAAE;QACR,SAAS,GAAG,KAAK,CAAC;OACnB;;MAED,IAAI,OAAO,GAAG,UAAU,CA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S,CAAC;SAClB,EAAE,IAAI,CAAC,CAAC;OACV,CAAC;;MAEF,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;MAClD,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;MACtD,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;MAClD,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;MACpD,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;KACnD,CAAC,IAAI,CAAC,EAAE;;CAEZ,EAAE,IAAI,CAAC,QAAQ,KAAK,OAAO,MAAM,IAAI,MAAM,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,IAAI,IAAI,QAAQ,KAAK,OAAO,MAAM,IAAI,MAAM,IAAI,EAAE,CAAC,CAAC"}
|
@@ -1,11 +1,13 @@
|
|
1
|
-
import './matches.mjs'
|
1
|
+
import './matches.mjs';
|
2
|
+
|
3
|
+
// @ts-nocheck
|
2
4
|
|
3
5
|
(function(undefined) {
|
4
6
|
|
5
7
|
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/closest/detect.js
|
6
8
|
var detect = (
|
7
9
|
'document' in this && "closest" in document.documentElement
|
8
|
-
)
|
10
|
+
);
|
9
11
|
|
10
12
|
if (detect) return
|
11
13
|
|
@@ -22,3 +24,4 @@ import './matches.mjs'
|
|
22
24
|
};
|
23
25
|
|
24
26
|
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
27
|
+
//# sourceMappingURL=vendor/polyfills/Element/prototype/closest.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"closest.mjs","sources":["../../../../../../src/govuk/vendor/polyfills/Element/prototype/closest.mjs"],"sourcesContent":["// @ts-nocheck\nimport './matches.mjs'\n\n(function(undefined) {\n\n // Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/closest/detect.js\n var detect = (\n 'document' in this && \"closest\" in document.documentElement\n )\n\n if (detect) return\n\n // Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/closest/polyfill.js\n Element.prototype.closest = function closest(selector) {\n var node = this;\n\n while (node) {\n if (node.matches(selector)) return node;\n else node = 'SVGElement' in window && node instanceof SVGElement ? node.parentNode : node.parentElement;\n }\n\n return null;\n };\n\n}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});\n"],"names":[],"mappings":";;AAAA;AACA,AACA;AACA,CAAC,SAAS,SAAS,EAAE;;;EAGnB,IAAI,MAAM;IACR,UAAU,IAAI,IAAI,IAAI,SAAS,IAAI,QAAQ,CAAC,eAAe;IAC5D;;EAED,IAAI,MAAM,EAAE,MAAM;;;EAGlB,OAAO,CAAC,SAAS,CAAC,OAAO,GAAG,SAAS,OAAO,CAAC,QAAQ,EAAE;IACrD,IAAI,IAAI,GAAG,IAAI,CAAC;;IAEhB,OAAO,IAAI,EAAE;MACX,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,IAAI,CAAC;WACnC,IAAI,GAAG,YAAY,IAAI,MAAM,IAAI,IAAI,YAAY,UAAU,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC;KACzG;;IAED,OAAO,IAAI,CAAC;GACb,CAAC;;CAEH,EAAE,IAAI,CAAC,QAAQ,KAAK,OAAO,MAAM,IAAI,MAAM,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,IAAI,IAAI,QAAQ,KAAK,OAAO,MAAM,IAAI,MAAM,IAAI,EAAE,CAAC,CAAC"}
|