govuk_publishing_components 32.1.0 → 35.0.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/README.md +1 -0
- data/app/assets/config/govuk_publishing_components_manifest.js +75 -1
- data/app/assets/images/govuk_publishing_components/icon-search.svg +3 -0
- data/app/assets/images/govuk_publishing_components/youtube-play-icon.png +0 -0
- data/app/assets/images/govuk_publishing_components/youtube-play-icon.svg +4 -0
- data/app/assets/javascripts/component_guide/accessibility-test.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics/auto-scroll-tracker.js +2 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics/linked-domains.js +135 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-auto-tracker.js +49 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +341 -27
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-ecommerce-tracker.js +17 -92
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-event-tracker.js +11 -23
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-form-tracker.js +121 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +86 -305
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-page-views.js +13 -6
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-schemas.js +31 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-smart-answer-results-tracker.js +57 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-specialist-link-tracker.js +131 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/init-ga4.js +9 -4
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/pii-remover.js +4 -2
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4.js +4 -0
- data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +12 -1
- data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +2 -2
- data/app/assets/javascripts/govuk_publishing_components/components/image-card.js +19 -0
- data/app/assets/javascripts/govuk_publishing_components/components/layout-super-navigation-header.js +2 -81
- data/app/assets/javascripts/govuk_publishing_components/components/single-page-notification-button.js +24 -8
- data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +23 -1
- data/app/assets/javascripts/govuk_publishing_components/dependencies.js +13 -0
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +3 -2
- data/app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js +1 -0
- data/app/assets/javascripts/govuk_publishing_components/load-analytics.js +116 -0
- data/app/assets/javascripts/govuk_publishing_components/modules.js +7 -2
- data/app/assets/javascripts/govuk_publishing_components/vendor/lux/lux-reporter.js +140 -191
- data/app/assets/stylesheets/govuk_publishing_components/_individual_component_support.scss +10 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +29 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_attachment.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_back-link.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_big-number.scss +4 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_breadcrumbs.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_button.scss +12 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_cards.scss +20 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_character-count.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_checkboxes.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_contents-list.scss +21 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-guidance.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +7 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_date-input.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_details.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_devolved-nations.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_document-list.scss +8 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_emergency-banner.scss +8 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_error-alert.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_error-message.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_error-summary.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +17 -19
- data/app/assets/stylesheets/govuk_publishing_components/components/_fieldset.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_file-upload.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak-html-publication.scss +10 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_govspeak.scss +85 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_hint.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +85 -6
- data/app/assets/stylesheets/govuk_publishing_components/components/_input.scss +6 -6
- data/app/assets/stylesheets/govuk_publishing_components/components/_inset-text.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_intervention.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_inverse-header.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_label.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-footer.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-for-public.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +253 -483
- data/app/assets/stylesheets/govuk_publishing_components/components/_lead-paragraph.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_modal-dialogue.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_notice.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_panel.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_phase-banner.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_previous-and-next-navigation.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_print-link.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_radio.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_reorderable-list.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +2 -7
- data/app/assets/stylesheets/govuk_publishing_components/components/_select.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_show-password.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_signup-link.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_single-page-notification-button.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_skip-link.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +17 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +8 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.scss +2 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_success-alert.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_summary-list.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_table.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_tabs.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_textarea.scss +17 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_title.scss +12 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_translation-nav.scss +2 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_warning-text.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_steps.scss +26 -9
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_tables.scss +12 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_brand-colours.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_contents-list-helper.scss +0 -1
- data/app/controllers/govuk_publishing_components/application_controller.rb +0 -13
- data/app/controllers/govuk_publishing_components/audit_controller.rb +1 -1
- data/app/controllers/govuk_publishing_components/component_guide_controller.rb +6 -9
- data/app/models/govuk_publishing_components/audit_applications.rb +10 -19
- data/app/models/govuk_publishing_components/audit_comparer.rb +29 -24
- data/app/models/govuk_publishing_components/audit_components.rb +157 -82
- data/app/models/govuk_publishing_components/component_doc.rb +14 -0
- data/app/models/govuk_publishing_components/component_wrapper_helper_options.rb +15 -0
- data/app/views/govuk_publishing_components/audit/_applications.html.erb +3 -3
- data/app/views/govuk_publishing_components/audit/_component_contents.html.erb +47 -39
- data/app/views/govuk_publishing_components/audit/_components.html.erb +47 -2
- data/app/views/govuk_publishing_components/component_guide/_application_stylesheet.html.erb +0 -3
- data/app/views/govuk_publishing_components/component_guide/index.html.erb +0 -7
- data/app/views/govuk_publishing_components/component_guide/show.html.erb +21 -6
- data/app/views/govuk_publishing_components/components/_accordion.html.erb +30 -36
- data/app/views/govuk_publishing_components/components/_action_link.html.erb +7 -2
- data/app/views/govuk_publishing_components/components/_attachment.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_attachment_link.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_back_link.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_big_number.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +8 -2
- data/app/views/govuk_publishing_components/components/_button.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_cards.html.erb +6 -4
- data/app/views/govuk_publishing_components/components/_character_count.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_checkboxes.html.erb +6 -2
- data/app/views/govuk_publishing_components/components/_contents_list.html.erb +11 -15
- data/app/views/govuk_publishing_components/components/_contextual_breadcrumbs.html.erb +7 -4
- data/app/views/govuk_publishing_components/components/_contextual_footer.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_contextual_guidance.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb +13 -6
- data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +12 -6
- data/app/views/govuk_publishing_components/components/_date_input.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_details.html.erb +5 -1
- data/app/views/govuk_publishing_components/components/_devolved_nations.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_document_list.html.erb +3 -0
- data/app/views/govuk_publishing_components/components/_emergency_banner.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_error_alert.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_error_message.html.erb +4 -1
- data/app/views/govuk_publishing_components/components/_error_summary.html.erb +29 -26
- data/app/views/govuk_publishing_components/components/_feedback.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_fieldset.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_file_upload.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_google_tag_manager_script.html.erb +2 -2
- data/app/views/govuk_publishing_components/components/_govspeak.html.erb +1 -0
- data/app/views/govuk_publishing_components/components/_govspeak_html_publication.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_heading.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_hint.html.erb +4 -1
- data/app/views/govuk_publishing_components/components/_image_card.html.erb +17 -12
- data/app/views/govuk_publishing_components/components/_input.html.erb +10 -2
- data/app/views/govuk_publishing_components/components/_inset_text.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_intervention.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_inverse_header.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_label.html.erb +7 -3
- data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_layout_for_admin.html.erb +8 -5
- data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +8 -3
- data/app/views/govuk_publishing_components/components/_layout_header.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +238 -267
- data/app/views/govuk_publishing_components/components/_lead_paragraph.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_metadata.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_modal_dialogue.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_notice.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_organisation_logo.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_panel.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +6 -1
- data/app/views/govuk_publishing_components/components/_print_link.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_radio.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_related_navigation.html.erb +16 -6
- data/app/views/govuk_publishing_components/components/_reorderable_list.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_search.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_select.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_share_links.html.erb +13 -13
- data/app/views/govuk_publishing_components/components/_show_password.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_signup_link.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +8 -2
- data/app/views/govuk_publishing_components/components/_skip_link.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +8 -1
- data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +12 -2
- data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +21 -8
- data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_success_alert.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_summary_list.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_table.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/_tabs.html.erb +22 -2
- data/app/views/govuk_publishing_components/components/_textarea.html.erb +12 -2
- data/app/views/govuk_publishing_components/components/_title.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_warning_text.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/contextual_sidebar/_ukraine_cta.html.erb +16 -6
- data/app/views/govuk_publishing_components/components/docs/accordion.yml +16 -3
- data/app/views/govuk_publishing_components/components/docs/action_link.yml +1 -0
- data/app/views/govuk_publishing_components/components/docs/breadcrumbs.yml +2 -1
- data/app/views/govuk_publishing_components/components/docs/button.yml +10 -0
- data/app/views/govuk_publishing_components/components/docs/cards.yml +1 -0
- data/app/views/govuk_publishing_components/components/docs/checkboxes.yml +1 -0
- data/app/views/govuk_publishing_components/components/docs/contents_list.yml +1 -12
- data/app/views/govuk_publishing_components/components/docs/contextual_breadcrumbs.yml +13 -0
- data/app/views/govuk_publishing_components/components/docs/contextual_footer.yml +43 -0
- data/app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml +65 -0
- data/app/views/govuk_publishing_components/components/docs/details.yml +17 -0
- data/app/views/govuk_publishing_components/components/docs/document_list.yml +18 -1
- data/app/views/govuk_publishing_components/components/docs/emergency_banner.yml +3 -1
- data/app/views/govuk_publishing_components/components/docs/error_message.yml +13 -0
- data/app/views/govuk_publishing_components/components/docs/govspeak.yml +22 -1
- data/app/views/govuk_publishing_components/components/docs/hint.yml +6 -0
- data/app/views/govuk_publishing_components/components/docs/image_card.yml +24 -1
- data/app/views/govuk_publishing_components/components/docs/input.yml +32 -0
- data/app/views/govuk_publishing_components/components/docs/intervention.yml +2 -1
- data/app/views/govuk_publishing_components/components/docs/label.yml +17 -0
- data/app/views/govuk_publishing_components/components/docs/layout_header.yml +1 -0
- data/app/views/govuk_publishing_components/components/docs/previous_and_next_navigation.yml +2 -0
- data/app/views/govuk_publishing_components/components/docs/related_navigation.yml +47 -0
- data/app/views/govuk_publishing_components/components/docs/share_links.yml +59 -30
- data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml +16 -1
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav.yml +54 -0
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_header.yml +6 -0
- data/app/views/govuk_publishing_components/components/docs/step_by_step_nav_related.yml +10 -0
- data/app/views/govuk_publishing_components/components/docs/tabs.yml +15 -0
- data/app/views/govuk_publishing_components/components/docs/textarea.yml +31 -0
- data/app/views/govuk_publishing_components/components/docs/translation_nav.yml +2 -0
- data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +3 -3
- data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +4 -5
- data/app/views/govuk_publishing_components/components/metadata/_sentence.html.erb +4 -2
- data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +36 -16
- data/app/views/layouts/govuk_publishing_components/application.html.erb +3 -4
- data/config/locales/ar.yml +14 -14
- data/config/locales/az.yml +15 -14
- data/config/locales/be.yml +14 -14
- data/config/locales/bg.yml +14 -14
- data/config/locales/bn.yml +14 -14
- data/config/locales/cs.yml +14 -14
- data/config/locales/cy.yml +14 -14
- data/config/locales/da.yml +14 -14
- data/config/locales/de.yml +14 -14
- data/config/locales/dr.yml +14 -14
- data/config/locales/el.yml +14 -14
- data/config/locales/en.yml +21 -28
- data/config/locales/es-419.yml +14 -14
- data/config/locales/es.yml +14 -14
- data/config/locales/et.yml +14 -14
- data/config/locales/fa.yml +15 -14
- data/config/locales/fi.yml +14 -14
- data/config/locales/fr.yml +14 -14
- data/config/locales/gd.yml +14 -14
- data/config/locales/gu.yml +14 -14
- data/config/locales/he.yml +14 -14
- data/config/locales/hi.yml +14 -14
- data/config/locales/hr.yml +14 -14
- data/config/locales/hu.yml +14 -14
- data/config/locales/hy.yml +14 -14
- data/config/locales/id.yml +14 -14
- data/config/locales/is.yml +14 -14
- data/config/locales/it.yml +14 -14
- data/config/locales/ja.yml +14 -14
- data/config/locales/ka.yml +14 -14
- data/config/locales/kk.yml +14 -14
- data/config/locales/ko.yml +14 -14
- data/config/locales/lt.yml +14 -14
- data/config/locales/lv.yml +14 -14
- data/config/locales/ms.yml +14 -14
- data/config/locales/mt.yml +14 -14
- data/config/locales/nl.yml +14 -14
- data/config/locales/no.yml +14 -14
- data/config/locales/pa-pk.yml +14 -14
- data/config/locales/pa.yml +14 -14
- data/config/locales/pl.yml +14 -14
- data/config/locales/ps.yml +14 -14
- data/config/locales/pt.yml +14 -14
- data/config/locales/ro.yml +14 -14
- data/config/locales/ru.yml +14 -14
- data/config/locales/si.yml +14 -14
- data/config/locales/sk.yml +14 -14
- data/config/locales/sl.yml +14 -14
- data/config/locales/so.yml +14 -14
- data/config/locales/sq.yml +14 -14
- data/config/locales/sr.yml +14 -14
- data/config/locales/sv.yml +14 -14
- data/config/locales/sw.yml +14 -14
- data/config/locales/ta.yml +14 -14
- data/config/locales/th.yml +14 -14
- data/config/locales/tk.yml +14 -14
- data/config/locales/tr.yml +14 -14
- data/config/locales/uk.yml +14 -14
- data/config/locales/ur.yml +14 -14
- data/config/locales/uz.yml +14 -14
- data/config/locales/vi.yml +14 -14
- data/config/locales/zh-hk.yml +14 -14
- data/config/locales/zh-tw.yml +14 -14
- data/config/locales/zh.yml +14 -14
- data/lib/govuk_publishing_components/app_helpers/asset_helper.rb +86 -0
- data/lib/govuk_publishing_components/config.rb +3 -3
- data/lib/govuk_publishing_components/presenters/accordion_helper.rb +38 -0
- data/lib/govuk_publishing_components/presenters/breadcrumb_selector.rb +3 -2
- data/lib/govuk_publishing_components/presenters/{breadcrumbs.rb → breadcrumbs_helper.rb} +8 -0
- data/lib/govuk_publishing_components/presenters/button_helper.rb +9 -2
- data/lib/govuk_publishing_components/presenters/component_wrapper_helper.rb +95 -0
- data/lib/govuk_publishing_components/presenters/image_card_helper.rb +65 -2
- data/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb +3 -2
- data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +16 -7
- data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +43 -2
- data/lib/govuk_publishing_components/presenters/step_by_step_nav_helper.rb +16 -0
- data/lib/govuk_publishing_components/railtie.rb +7 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/lib/govuk_publishing_components.rb +6 -1
- data/node_modules/axe-core/README.md +1 -1
- data/node_modules/axe-core/axe.d.ts +76 -24
- data/node_modules/axe-core/axe.js +9200 -9059
- data/node_modules/axe-core/axe.min.js +3 -3
- data/node_modules/axe-core/package.json +29 -29
- data/node_modules/axe-core/sri-history.json +20 -0
- data/node_modules/govuk-frontend/README.md +1 -2
- data/node_modules/govuk-frontend/govuk/all.js +4035 -2673
- data/node_modules/govuk-frontend/govuk/all.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js +71 -0
- data/node_modules/govuk-frontend/govuk/common/closest-attribute-value.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/common/index.js +180 -0
- data/node_modules/govuk-frontend/govuk/common/index.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js +376 -0
- data/node_modules/govuk-frontend/govuk/common/normalise-dataset.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/common.js +173 -30
- data/node_modules/govuk-frontend/govuk/common.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/_all.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +23 -4
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js +2116 -983
- data/node_modules/govuk-frontend/govuk/components/accordion/accordion.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/accordion/fixtures.json +54 -22
- data/node_modules/govuk-frontend/govuk/components/accordion/macro-options.json +36 -0
- data/node_modules/govuk-frontend/govuk/components/accordion/template.njk +8 -2
- data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +19 -19
- data/node_modules/govuk-frontend/govuk/components/back-link/fixtures.json +12 -12
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +21 -10
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +22 -22
- data/node_modules/govuk-frontend/govuk/components/button/_index.scss +23 -5
- data/node_modules/govuk-frontend/govuk/components/button/button.js +958 -690
- data/node_modules/govuk-frontend/govuk/components/button/button.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/button/fixtures.json +85 -66
- data/node_modules/govuk-frontend/govuk/components/button/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +9 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +2083 -1161
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +112 -36
- data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +42 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +27 -3
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js +1155 -1119
- data/node_modules/govuk-frontend/govuk/components/checkboxes/checkboxes.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +96 -93
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +46 -46
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +50 -50
- data/node_modules/govuk-frontend/govuk/components/details/details.js +797 -766
- data/node_modules/govuk-frontend/govuk/components/details/details.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +20 -20
- data/node_modules/govuk-frontend/govuk/components/error-message/fixtures.json +20 -20
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js +1089 -814
- data/node_modules/govuk-frontend/govuk/components/error-summary/error-summary.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/error-summary/fixtures.json +44 -35
- data/node_modules/govuk-frontend/govuk/components/error-summary/template.njk +25 -21
- data/node_modules/govuk-frontend/govuk/components/fieldset/fixtures.json +51 -39
- data/node_modules/govuk-frontend/govuk/components/file-upload/fixtures.json +26 -26
- data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/footer/fixtures.json +46 -46
- data/node_modules/govuk-frontend/govuk/components/footer/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/header/_index.scss +6 -0
- data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +93 -38
- data/node_modules/govuk-frontend/govuk/components/header/header.js +646 -992
- data/node_modules/govuk-frontend/govuk/components/header/header.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +8 -2
- data/node_modules/govuk-frontend/govuk/components/header/template.njk +4 -2
- data/node_modules/govuk-frontend/govuk/components/hint/fixtures.json +12 -12
- data/node_modules/govuk-frontend/govuk/components/input/fixtures.json +80 -80
- data/node_modules/govuk-frontend/govuk/components/inset-text/fixtures.json +12 -12
- data/node_modules/govuk-frontend/govuk/components/label/fixtures.json +34 -34
- data/node_modules/govuk-frontend/govuk/components/notification-banner/fixtures.json +56 -46
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js +790 -532
- data/node_modules/govuk-frontend/govuk/components/notification-banner/notification-banner.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/notification-banner/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/pagination/_index.scss +10 -7
- data/node_modules/govuk-frontend/govuk/components/pagination/fixtures.json +94 -26
- data/node_modules/govuk-frontend/govuk/components/pagination/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/panel/fixtures.json +18 -18
- data/node_modules/govuk-frontend/govuk/components/phase-banner/fixtures.json +14 -14
- data/node_modules/govuk-frontend/govuk/components/phase-banner/macro-options.json +1 -1
- data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +94 -91
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js +1110 -1079
- data/node_modules/govuk-frontend/govuk/components/radios/radios.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/select/fixtures.json +32 -32
- data/node_modules/govuk-frontend/govuk/components/skip-link/fixtures.json +22 -20
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js +1017 -1008
- data/node_modules/govuk-frontend/govuk/components/skip-link/skip-link.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/summary-list/_index.scss +107 -0
- data/node_modules/govuk-frontend/govuk/components/summary-list/fixtures.json +345 -50
- data/node_modules/govuk-frontend/govuk/components/summary-list/macro-options.json +110 -0
- data/node_modules/govuk-frontend/govuk/components/summary-list/template.njk +72 -28
- data/node_modules/govuk-frontend/govuk/components/table/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/table/fixtures.json +40 -40
- data/node_modules/govuk-frontend/govuk/components/tabs/fixtures.json +29 -29
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js +1389 -1233
- data/node_modules/govuk-frontend/govuk/components/tabs/tabs.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/components/tag/fixtures.json +28 -28
- data/node_modules/govuk-frontend/govuk/components/textarea/fixtures.json +34 -34
- data/node_modules/govuk-frontend/govuk/components/warning-text/fixtures.json +14 -14
- data/node_modules/govuk-frontend/govuk/core/_section-break.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +2 -2
- data/node_modules/govuk-frontend/govuk/helpers/_focused.scss +5 -0
- data/node_modules/govuk-frontend/govuk/helpers/_links.scss +6 -6
- data/node_modules/govuk-frontend/govuk/i18n.js +389 -0
- data/node_modules/govuk-frontend/govuk/i18n.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/macros/i18n.njk +15 -0
- data/node_modules/govuk-frontend/govuk/settings/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/settings/_colours-palette.scss +12 -0
- data/node_modules/govuk-frontend/govuk/settings/_compatibility.scss +26 -0
- data/node_modules/govuk-frontend/govuk/settings/_measurements.scss +5 -5
- data/node_modules/govuk-frontend/govuk/settings/_typography-font.scss +23 -0
- data/node_modules/govuk-frontend/govuk/settings/_typography-responsive.scss +12 -0
- data/node_modules/govuk-frontend/govuk/settings/_warnings.scss +53 -0
- data/node_modules/govuk-frontend/govuk/tools/_compatibility.scss +20 -6
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js +242 -241
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/DOMTokenList.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js +22 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Date/now.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js +17 -16
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Document.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js +547 -546
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/classList.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js +37 -36
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/closest.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js +301 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/dataset.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js +21 -20
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/matches.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js +198 -197
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/nextElementSibling.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js +198 -197
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element/prototype/previousElementSibling.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js +106 -105
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Element.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js +400 -399
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Event.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js +239 -238
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Function/prototype/bind.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js +72 -71
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Object/defineProperty.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js +22 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/String/prototype/trim.js.map +1 -0
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js +17 -16
- data/node_modules/govuk-frontend/govuk/vendor/polyfills/Window.js.map +1 -0
- data/node_modules/govuk-frontend/govuk-esm/all.mjs +52 -29
- data/node_modules/govuk-frontend/govuk-esm/common/closest-attribute-value.mjs +15 -0
- data/node_modules/govuk-frontend/govuk-esm/common/index.mjs +166 -0
- data/node_modules/govuk-frontend/govuk-esm/common/normalise-dataset.mjs +60 -0
- data/node_modules/govuk-frontend/govuk-esm/common.mjs +6 -28
- data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +238 -85
- data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +73 -34
- data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +329 -124
- data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +32 -20
- data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +41 -20
- data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +60 -14
- data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +9 -2
- data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +33 -4
- data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +18 -11
- data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +15 -7
- data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +171 -38
- data/node_modules/govuk-frontend/govuk-esm/i18n.mjs +378 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Date/now.mjs +13 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/dataset.mjs +68 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/String/prototype/trim.mjs +13 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit/init.js +7 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit/init.scss +12 -0
- data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +138 -7
- data/node_modules/govuk-frontend/package.json +1 -1
- metadata +70 -19
- data/app/assets/stylesheets/component_guide/print.scss +0 -1
- data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +0 -18
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_accordion.scss +0 -28
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_button.scss +0 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_cards.scss +0 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_contents-list.scss +0 -19
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_emergency-banner.scss +0 -3
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_govspeak-html-publication.scss +0 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_govspeak.scss +0 -80
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_layout-super-navigation-header.scss +0 -3
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_organisation-logo.scss +0 -7
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav-header.scss +0 -7
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav.scss +0 -116
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_textarea.scss +0 -13
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_title.scss +0 -7
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
"text": "You can be fined up to £5,000 if you don’t register.",
|
|
8
8
|
"iconFallbackText": "Warning"
|
|
9
9
|
},
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"hidden": false,
|
|
11
|
+
"html": "<div class=\"govuk-warning-text\">\n <span class=\"govuk-warning-text__icon\" aria-hidden=\"true\">!</span>\n <strong class=\"govuk-warning-text__text\">\n <span class=\"govuk-warning-text__assistive\">Warning</span>\n You can be fined up to £5,000 if you don’t register.\n </strong>\n</div>"
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
"name": "multiple lines",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"text": "If you are not covered by this License), You must: (a) comply with the terms stated above for the purpose of this license. It explains, for example, the production of a Source form, including but not limited to, the implied warranties or conditions of this License, without any additional file created by such Respondent to you under Sections 2.1 and 2.2 above. Larger Works. You may choose to distribute such a notice and a brief idea of what it does.",
|
|
17
17
|
"iconFallbackText": "Warning"
|
|
18
18
|
},
|
|
19
|
-
"
|
|
20
|
-
"hidden":
|
|
19
|
+
"hidden": false,
|
|
20
|
+
"html": "<div class=\"govuk-warning-text\">\n <span class=\"govuk-warning-text__icon\" aria-hidden=\"true\">!</span>\n <strong class=\"govuk-warning-text__text\">\n <span class=\"govuk-warning-text__assistive\">Warning</span>\n If you are not covered by this License), You must: (a) comply with the terms stated above for the purpose of this license. It explains, for example, the production of a Source form, including but not limited to, the implied warranties or conditions of this License, without any additional file created by such Respondent to you under Sections 2.1 and 2.2 above. Larger Works. You may choose to distribute such a notice and a brief idea of what it does.\n </strong>\n</div>"
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
"name": "attributes",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"data-test": "attribute"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"hidden": true,
|
|
33
|
+
"html": "<div class=\"govuk-warning-text\" id=\"my-warning-text\" data-test=\"attribute\">\n <span class=\"govuk-warning-text__icon\" aria-hidden=\"true\">!</span>\n <strong class=\"govuk-warning-text__text\">\n <span class=\"govuk-warning-text__assistive\">Warning</span>\n You can be fined up to £5,000 if you don’t register.\n </strong>\n</div>"
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
"name": "classes",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"iconFallbackText": "Warning",
|
|
40
40
|
"classes": "govuk-warning-text--custom-class"
|
|
41
41
|
},
|
|
42
|
-
"
|
|
43
|
-
"
|
|
42
|
+
"hidden": true,
|
|
43
|
+
"html": "<div class=\"govuk-warning-text govuk-warning-text--custom-class\">\n <span class=\"govuk-warning-text__icon\" aria-hidden=\"true\">!</span>\n <strong class=\"govuk-warning-text__text\">\n <span class=\"govuk-warning-text__assistive\">Warning</span>\n Warning text\n </strong>\n</div>"
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
"name": "html",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"iconFallbackText": "Warning",
|
|
50
50
|
"html": "<span>Some custom warning text</span>"
|
|
51
51
|
},
|
|
52
|
-
"
|
|
53
|
-
"
|
|
52
|
+
"hidden": true,
|
|
53
|
+
"html": "<div class=\"govuk-warning-text\">\n <span class=\"govuk-warning-text__icon\" aria-hidden=\"true\">!</span>\n <strong class=\"govuk-warning-text__text\">\n <span class=\"govuk-warning-text__assistive\">Warning</span>\n <span>Some custom warning text</span>\n </strong>\n</div>"
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
"name": "html as text",
|
|
@@ -58,16 +58,16 @@
|
|
|
58
58
|
"iconFallbackText": "Warning",
|
|
59
59
|
"text": "<span>Some custom warning text</span>"
|
|
60
60
|
},
|
|
61
|
-
"
|
|
62
|
-
"
|
|
61
|
+
"hidden": true,
|
|
62
|
+
"html": "<div class=\"govuk-warning-text\">\n <span class=\"govuk-warning-text__icon\" aria-hidden=\"true\">!</span>\n <strong class=\"govuk-warning-text__text\">\n <span class=\"govuk-warning-text__assistive\">Warning</span>\n <span>Some custom warning text</span>\n </strong>\n</div>"
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"name": "icon fallback text only",
|
|
66
66
|
"options": {
|
|
67
67
|
"iconFallbackText": "Some custom fallback text"
|
|
68
68
|
},
|
|
69
|
-
"
|
|
70
|
-
"
|
|
69
|
+
"hidden": true,
|
|
70
|
+
"html": "<div class=\"govuk-warning-text\">\n <span class=\"govuk-warning-text__icon\" aria-hidden=\"true\">!</span>\n <strong class=\"govuk-warning-text__text\">\n <span class=\"govuk-warning-text__assistive\">Some custom fallback text</span>\n \n </strong>\n</div>"
|
|
71
71
|
}
|
|
72
72
|
]
|
|
73
73
|
}
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
/// Make a colour darker by mixing it with black
|
|
76
76
|
///
|
|
77
77
|
/// @param {Colour} $colour - colour to shade
|
|
78
|
-
/// @param {Number} $percentage - percentage of
|
|
78
|
+
/// @param {Number} $percentage - percentage of black to mix with $colour
|
|
79
79
|
/// @return {Colour}
|
|
80
80
|
/// @access public
|
|
81
81
|
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
/// Make a colour lighter by mixing it with white
|
|
87
87
|
///
|
|
88
88
|
/// @param {Colour} $colour - colour to tint
|
|
89
|
-
/// @param {Number} $percentage - percentage of
|
|
89
|
+
/// @param {Number} $percentage - percentage of white to mix with $colour
|
|
90
90
|
/// @return {Colour}
|
|
91
91
|
/// @access public
|
|
92
92
|
|
|
@@ -25,4 +25,9 @@
|
|
|
25
25
|
// When link is focussed, hide the default underline since the
|
|
26
26
|
// box shadow adds the "underline"
|
|
27
27
|
text-decoration: none;
|
|
28
|
+
|
|
29
|
+
// When a focused box is broken by e.g. a line break, ensure that the
|
|
30
|
+
// box-shadow is applied to each fragment independently.
|
|
31
|
+
-webkit-box-decoration-break: clone;
|
|
32
|
+
box-decoration-break: clone;
|
|
28
33
|
}
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
// we need to override the text colour for that combination of selectors so
|
|
105
105
|
// so that unvisited links styled as buttons do not end up with dark blue
|
|
106
106
|
// text when focussed.
|
|
107
|
-
@include
|
|
107
|
+
@include _govuk-compatibility(govuk_template) {
|
|
108
108
|
&:link:focus {
|
|
109
109
|
color: $govuk-focus-text-colour;
|
|
110
110
|
}
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
// we need to override the text colour for that combination of selectors so
|
|
153
153
|
// so that unvisited links styled as buttons do not end up with dark blue
|
|
154
154
|
// text when focussed.
|
|
155
|
-
@include
|
|
155
|
+
@include _govuk-compatibility(govuk_template) {
|
|
156
156
|
&:link:focus {
|
|
157
157
|
color: $govuk-focus-text-colour;
|
|
158
158
|
}
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
// we need to override the text colour for that combination of selectors so
|
|
201
201
|
// so that unvisited links styled as buttons do not end up with dark blue
|
|
202
202
|
// text when focussed.
|
|
203
|
-
@include
|
|
203
|
+
@include _govuk-compatibility(govuk_template) {
|
|
204
204
|
&:link:focus {
|
|
205
205
|
color: $govuk-focus-text-colour;
|
|
206
206
|
}
|
|
@@ -243,7 +243,7 @@
|
|
|
243
243
|
// alphagov/govuk_template includes a specific a:link:focus selector designed
|
|
244
244
|
// to make unvisited links a slightly darker blue when focussed, so we need to
|
|
245
245
|
// override the text colour for that combination of selectors.
|
|
246
|
-
@include
|
|
246
|
+
@include _govuk-compatibility(govuk_template) {
|
|
247
247
|
&:link:focus {
|
|
248
248
|
@include govuk-text-colour;
|
|
249
249
|
}
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
// alphagov/govuk_template includes a specific a:link:focus selector designed
|
|
289
289
|
// to make unvisited links a slightly darker blue when focussed, so we need to
|
|
290
290
|
// override the text colour for that combination of selectors.
|
|
291
|
-
@include
|
|
291
|
+
@include _govuk-compatibility(govuk_template) {
|
|
292
292
|
&:link:focus {
|
|
293
293
|
@include govuk-text-colour;
|
|
294
294
|
}
|
|
@@ -331,7 +331,7 @@
|
|
|
331
331
|
// alphagov/govuk_template includes a specific a:link:focus selector designed
|
|
332
332
|
// to make unvisited links a slightly darker blue when focussed, so we need to
|
|
333
333
|
// override the text colour for that combination of selectors.
|
|
334
|
-
@include
|
|
334
|
+
@include _govuk-compatibility(govuk_template) {
|
|
335
335
|
&:link:focus {
|
|
336
336
|
color: $govuk-focus-text-colour;
|
|
337
337
|
}
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('GOVUKFrontend', ['exports'], factory) :
|
|
4
|
+
(factory((global.GOVUKFrontend = {})));
|
|
5
|
+
}(this, (function (exports) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal support for selecting messages to render, with placeholder
|
|
9
|
+
* interpolation and locale-aware number formatting and pluralisation
|
|
10
|
+
*
|
|
11
|
+
* @class
|
|
12
|
+
* @private
|
|
13
|
+
* @param {Object<string, unknown>} translations - Key-value pairs of the translation strings to use.
|
|
14
|
+
* @param {object} [config] - Configuration options for the function.
|
|
15
|
+
* @param {string} [config.locale] - An overriding locale for the PluralRules functionality.
|
|
16
|
+
*/
|
|
17
|
+
function I18n (translations, config) {
|
|
18
|
+
// Make list of translations available throughout function
|
|
19
|
+
this.translations = translations || {};
|
|
20
|
+
|
|
21
|
+
// The locale to use for PluralRules and NumberFormat
|
|
22
|
+
this.locale = (config && config.locale) || document.documentElement.lang || 'en';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The most used function - takes the key for a given piece of UI text and
|
|
27
|
+
* returns the appropriate string.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} lookupKey - The lookup key of the string to use.
|
|
30
|
+
* @param {Object<string, unknown>} [options] - Any options passed with the translation string, e.g: for string interpolation.
|
|
31
|
+
* @returns {string} The appropriate translation string.
|
|
32
|
+
* @throws {Error} Lookup key required
|
|
33
|
+
* @throws {Error} Options required for `${}` placeholders
|
|
34
|
+
*/
|
|
35
|
+
I18n.prototype.t = function (lookupKey, options) {
|
|
36
|
+
if (!lookupKey) {
|
|
37
|
+
// Print a console error if no lookup key has been provided
|
|
38
|
+
throw new Error('i18n: lookup key missing')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// If the `count` option is set, determine which plural suffix is needed and
|
|
42
|
+
// change the lookupKey to match. We check to see if it's undefined instead of
|
|
43
|
+
// falsy, as this could legitimately be 0.
|
|
44
|
+
if (options && typeof options.count !== 'undefined') {
|
|
45
|
+
// Get the plural suffix
|
|
46
|
+
lookupKey = lookupKey + '.' + this.getPluralSuffix(lookupKey, options.count);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (lookupKey in this.translations) {
|
|
50
|
+
// Fetch the translation string for that lookup key
|
|
51
|
+
var translationString = this.translations[lookupKey];
|
|
52
|
+
|
|
53
|
+
// Check for ${} placeholders in the translation string
|
|
54
|
+
if (translationString.match(/%{(.\S+)}/)) {
|
|
55
|
+
if (!options) {
|
|
56
|
+
throw new Error('i18n: cannot replace placeholders in string if no option data provided')
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return this.replacePlaceholders(translationString, options)
|
|
60
|
+
} else {
|
|
61
|
+
return translationString
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
// If the key wasn't found in our translations object,
|
|
65
|
+
// return the lookup key itself as the fallback
|
|
66
|
+
return lookupKey
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Takes a translation string with placeholders, and replaces the placeholders
|
|
72
|
+
* with the provided data
|
|
73
|
+
*
|
|
74
|
+
* @param {string} translationString - The translation string
|
|
75
|
+
* @param {Object<string, unknown>} options - Any options passed with the translation string, e.g: for string interpolation.
|
|
76
|
+
* @returns {string} The translation string to output, with ${} placeholders replaced
|
|
77
|
+
*/
|
|
78
|
+
I18n.prototype.replacePlaceholders = function (translationString, options) {
|
|
79
|
+
var formatter;
|
|
80
|
+
|
|
81
|
+
if (this.hasIntlNumberFormatSupport()) {
|
|
82
|
+
formatter = new Intl.NumberFormat(this.locale);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return translationString.replace(/%{(.\S+)}/g, function (placeholderWithBraces, placeholderKey) {
|
|
86
|
+
if (Object.prototype.hasOwnProperty.call(options, placeholderKey)) {
|
|
87
|
+
var placeholderValue = options[placeholderKey];
|
|
88
|
+
|
|
89
|
+
// If a user has passed `false` as the value for the placeholder
|
|
90
|
+
// treat it as though the value should not be displayed
|
|
91
|
+
if (placeholderValue === false) {
|
|
92
|
+
return ''
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// If the placeholder's value is a number, localise the number formatting
|
|
96
|
+
if (typeof placeholderValue === 'number' && formatter) {
|
|
97
|
+
return formatter.format(placeholderValue)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return placeholderValue
|
|
101
|
+
} else {
|
|
102
|
+
throw new Error('i18n: no data found to replace ' + placeholderWithBraces + ' placeholder in string')
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Check to see if the browser supports Intl and Intl.PluralRules.
|
|
109
|
+
*
|
|
110
|
+
* It requires all conditions to be met in order to be supported:
|
|
111
|
+
* - The browser supports the Intl class (true in IE11)
|
|
112
|
+
* - The implementation of Intl supports PluralRules (NOT true in IE11)
|
|
113
|
+
* - The browser/OS has plural rules for the current locale (browser dependent)
|
|
114
|
+
*
|
|
115
|
+
* @returns {boolean} Returns true if all conditions are met. Returns false otherwise.
|
|
116
|
+
*/
|
|
117
|
+
I18n.prototype.hasIntlPluralRulesSupport = function () {
|
|
118
|
+
return Boolean(window.Intl && ('PluralRules' in window.Intl && Intl.PluralRules.supportedLocalesOf(this.locale).length))
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Check to see if the browser supports Intl and Intl.NumberFormat.
|
|
123
|
+
*
|
|
124
|
+
* It requires all conditions to be met in order to be supported:
|
|
125
|
+
* - The browser supports the Intl class (true in IE11)
|
|
126
|
+
* - The implementation of Intl supports NumberFormat (also true in IE11)
|
|
127
|
+
* - The browser/OS has number formatting rules for the current locale (browser dependent)
|
|
128
|
+
*
|
|
129
|
+
* @returns {boolean} Returns true if all conditions are met. Returns false otherwise.
|
|
130
|
+
*/
|
|
131
|
+
I18n.prototype.hasIntlNumberFormatSupport = function () {
|
|
132
|
+
return Boolean(window.Intl && ('NumberFormat' in window.Intl && Intl.NumberFormat.supportedLocalesOf(this.locale).length))
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Get the appropriate suffix for the plural form.
|
|
137
|
+
*
|
|
138
|
+
* Uses Intl.PluralRules (or our own fallback implementation) to get the
|
|
139
|
+
* 'preferred' form to use for the given count.
|
|
140
|
+
*
|
|
141
|
+
* Checks that a translation has been provided for that plural form – if it
|
|
142
|
+
* hasn't, it'll fall back to the 'other' plural form (unless that doesn't exist
|
|
143
|
+
* either, in which case an error will be thrown)
|
|
144
|
+
*
|
|
145
|
+
* @param {string} lookupKey - The lookup key of the string to use.
|
|
146
|
+
* @param {number} count - Number used to determine which pluralisation to use.
|
|
147
|
+
* @returns {PluralRule} The suffix associated with the correct pluralisation for this locale.
|
|
148
|
+
* @throws {Error} Plural form `.other` required when preferred plural form is missing
|
|
149
|
+
*/
|
|
150
|
+
I18n.prototype.getPluralSuffix = function (lookupKey, count) {
|
|
151
|
+
// Validate that the number is actually a number.
|
|
152
|
+
//
|
|
153
|
+
// Number(count) will turn anything that can't be converted to a Number type
|
|
154
|
+
// into 'NaN'. isFinite filters out NaN, as it isn't a finite number.
|
|
155
|
+
count = Number(count);
|
|
156
|
+
if (!isFinite(count)) { return 'other' }
|
|
157
|
+
|
|
158
|
+
var preferredForm;
|
|
159
|
+
|
|
160
|
+
// Check to verify that all the requirements for Intl.PluralRules are met.
|
|
161
|
+
// If so, we can use that instead of our custom implementation. Otherwise,
|
|
162
|
+
// use the hardcoded fallback.
|
|
163
|
+
if (this.hasIntlPluralRulesSupport()) {
|
|
164
|
+
preferredForm = new Intl.PluralRules(this.locale).select(count);
|
|
165
|
+
} else {
|
|
166
|
+
preferredForm = this.selectPluralFormUsingFallbackRules(count);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Use the correct plural form if provided
|
|
170
|
+
if (lookupKey + '.' + preferredForm in this.translations) {
|
|
171
|
+
return preferredForm
|
|
172
|
+
// Fall back to `other` if the plural form is missing, but log a warning
|
|
173
|
+
// to the console
|
|
174
|
+
} else if (lookupKey + '.other' in this.translations) {
|
|
175
|
+
if (console && 'warn' in console) {
|
|
176
|
+
console.warn('i18n: Missing plural form ".' + preferredForm + '" for "' +
|
|
177
|
+
this.locale + '" locale. Falling back to ".other".');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return 'other'
|
|
181
|
+
// If the required `other` plural form is missing, all we can do is error
|
|
182
|
+
} else {
|
|
183
|
+
throw new Error(
|
|
184
|
+
'i18n: Plural form ".other" is required for "' + this.locale + '" locale'
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Get the plural form using our fallback implementation
|
|
191
|
+
*
|
|
192
|
+
* This is split out into a separate function to make it easier to test the
|
|
193
|
+
* fallback behaviour in an environment where Intl.PluralRules exists.
|
|
194
|
+
*
|
|
195
|
+
* @param {number} count - Number used to determine which pluralisation to use.
|
|
196
|
+
* @returns {PluralRule} The pluralisation form for count in this locale.
|
|
197
|
+
*/
|
|
198
|
+
I18n.prototype.selectPluralFormUsingFallbackRules = function (count) {
|
|
199
|
+
// Currently our custom code can only handle positive integers, so let's
|
|
200
|
+
// make sure our number is one of those.
|
|
201
|
+
count = Math.abs(Math.floor(count));
|
|
202
|
+
|
|
203
|
+
var ruleset = this.getPluralRulesForLocale();
|
|
204
|
+
|
|
205
|
+
if (ruleset) {
|
|
206
|
+
return I18n.pluralRules[ruleset](count)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return 'other'
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Work out which pluralisation rules to use for the current locale
|
|
214
|
+
*
|
|
215
|
+
* The locale may include a regional indicator (such as en-GB), but we don't
|
|
216
|
+
* usually care about this part, as pluralisation rules are usually the same
|
|
217
|
+
* regardless of region. There are exceptions, however, (e.g. Portuguese) so
|
|
218
|
+
* this searches by both the full and shortened locale codes, just to be sure.
|
|
219
|
+
*
|
|
220
|
+
* @returns {PluralRuleName | undefined} The name of the pluralisation rule to use (a key for one
|
|
221
|
+
* of the functions in this.pluralRules)
|
|
222
|
+
*/
|
|
223
|
+
I18n.prototype.getPluralRulesForLocale = function () {
|
|
224
|
+
var locale = this.locale;
|
|
225
|
+
var localeShort = locale.split('-')[0];
|
|
226
|
+
|
|
227
|
+
// Look through the plural rules map to find which `pluralRule` is
|
|
228
|
+
// appropriate for our current `locale`.
|
|
229
|
+
for (var pluralRule in I18n.pluralRulesMap) {
|
|
230
|
+
if (Object.prototype.hasOwnProperty.call(I18n.pluralRulesMap, pluralRule)) {
|
|
231
|
+
var languages = I18n.pluralRulesMap[pluralRule];
|
|
232
|
+
for (var i = 0; i < languages.length; i++) {
|
|
233
|
+
if (languages[i] === locale || languages[i] === localeShort) {
|
|
234
|
+
return pluralRule
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Map of plural rules to languages where those rules apply.
|
|
243
|
+
*
|
|
244
|
+
* Note: These groups are named for the most dominant or recognisable language
|
|
245
|
+
* that uses each system. The groupings do not imply that the languages are
|
|
246
|
+
* related to one another. Many languages have evolved the same systems
|
|
247
|
+
* independently of one another.
|
|
248
|
+
*
|
|
249
|
+
* Code to support more languages can be found in the i18n spike:
|
|
250
|
+
* {@link https://github.com/alphagov/govuk-frontend/blob/spike-i18n-support/src/govuk/i18n.mjs}
|
|
251
|
+
*
|
|
252
|
+
* Languages currently supported:
|
|
253
|
+
*
|
|
254
|
+
* Arabic: Arabic (ar)
|
|
255
|
+
* Chinese: Burmese (my), Chinese (zh), Indonesian (id), Japanese (ja),
|
|
256
|
+
* Javanese (jv), Korean (ko), Malay (ms), Thai (th), Vietnamese (vi)
|
|
257
|
+
* French: Armenian (hy), Bangla (bn), French (fr), Gujarati (gu), Hindi (hi),
|
|
258
|
+
* Persian Farsi (fa), Punjabi (pa), Zulu (zu)
|
|
259
|
+
* German: Afrikaans (af), Albanian (sq), Azerbaijani (az), Basque (eu),
|
|
260
|
+
* Bulgarian (bg), Catalan (ca), Danish (da), Dutch (nl), English (en),
|
|
261
|
+
* Estonian (et), Finnish (fi), Georgian (ka), German (de), Greek (el),
|
|
262
|
+
* Hungarian (hu), Luxembourgish (lb), Norwegian (no), Somali (so),
|
|
263
|
+
* Swahili (sw), Swedish (sv), Tamil (ta), Telugu (te), Turkish (tr),
|
|
264
|
+
* Urdu (ur)
|
|
265
|
+
* Irish: Irish Gaelic (ga)
|
|
266
|
+
* Russian: Russian (ru), Ukrainian (uk)
|
|
267
|
+
* Scottish: Scottish Gaelic (gd)
|
|
268
|
+
* Spanish: European Portuguese (pt-PT), Italian (it), Spanish (es)
|
|
269
|
+
* Welsh: Welsh (cy)
|
|
270
|
+
*
|
|
271
|
+
* @type {Object<PluralRuleName, string[]>}
|
|
272
|
+
*/
|
|
273
|
+
I18n.pluralRulesMap = {
|
|
274
|
+
arabic: ['ar'],
|
|
275
|
+
chinese: ['my', 'zh', 'id', 'ja', 'jv', 'ko', 'ms', 'th', 'vi'],
|
|
276
|
+
french: ['hy', 'bn', 'fr', 'gu', 'hi', 'fa', 'pa', 'zu'],
|
|
277
|
+
german: [
|
|
278
|
+
'af', 'sq', 'az', 'eu', 'bg', 'ca', 'da', 'nl', 'en', 'et', 'fi', 'ka',
|
|
279
|
+
'de', 'el', 'hu', 'lb', 'no', 'so', 'sw', 'sv', 'ta', 'te', 'tr', 'ur'
|
|
280
|
+
],
|
|
281
|
+
irish: ['ga'],
|
|
282
|
+
russian: ['ru', 'uk'],
|
|
283
|
+
scottish: ['gd'],
|
|
284
|
+
spanish: ['pt-PT', 'it', 'es'],
|
|
285
|
+
welsh: ['cy']
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Different pluralisation rule sets
|
|
290
|
+
*
|
|
291
|
+
* Returns the appropriate suffix for the plural form associated with `n`.
|
|
292
|
+
* Possible suffixes: 'zero', 'one', 'two', 'few', 'many', 'other' (the actual
|
|
293
|
+
* meaning of each differs per locale). 'other' should always exist, even in
|
|
294
|
+
* languages without plurals, such as Chinese.
|
|
295
|
+
* {@link https://cldr.unicode.org/index/cldr-spec/plural-rules}
|
|
296
|
+
*
|
|
297
|
+
* The count must be a positive integer. Negative numbers and decimals aren't accounted for
|
|
298
|
+
*
|
|
299
|
+
* @type {Object<string, function(number): PluralRule>}
|
|
300
|
+
*/
|
|
301
|
+
I18n.pluralRules = {
|
|
302
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
303
|
+
arabic: function (n) {
|
|
304
|
+
if (n === 0) { return 'zero' }
|
|
305
|
+
if (n === 1) { return 'one' }
|
|
306
|
+
if (n === 2) { return 'two' }
|
|
307
|
+
if (n % 100 >= 3 && n % 100 <= 10) { return 'few' }
|
|
308
|
+
if (n % 100 >= 11 && n % 100 <= 99) { return 'many' }
|
|
309
|
+
return 'other'
|
|
310
|
+
},
|
|
311
|
+
chinese: function () {
|
|
312
|
+
return 'other'
|
|
313
|
+
},
|
|
314
|
+
french: function (n) {
|
|
315
|
+
return n === 0 || n === 1 ? 'one' : 'other'
|
|
316
|
+
},
|
|
317
|
+
german: function (n) {
|
|
318
|
+
return n === 1 ? 'one' : 'other'
|
|
319
|
+
},
|
|
320
|
+
irish: function (n) {
|
|
321
|
+
if (n === 1) { return 'one' }
|
|
322
|
+
if (n === 2) { return 'two' }
|
|
323
|
+
if (n >= 3 && n <= 6) { return 'few' }
|
|
324
|
+
if (n >= 7 && n <= 10) { return 'many' }
|
|
325
|
+
return 'other'
|
|
326
|
+
},
|
|
327
|
+
russian: function (n) {
|
|
328
|
+
var lastTwo = n % 100;
|
|
329
|
+
var last = lastTwo % 10;
|
|
330
|
+
if (last === 1 && lastTwo !== 11) { return 'one' }
|
|
331
|
+
if (last >= 2 && last <= 4 && !(lastTwo >= 12 && lastTwo <= 14)) { return 'few' }
|
|
332
|
+
if (last === 0 || (last >= 5 && last <= 9) || (lastTwo >= 11 && lastTwo <= 14)) { return 'many' }
|
|
333
|
+
// Note: The 'other' suffix is only used by decimal numbers in Russian.
|
|
334
|
+
// We don't anticipate it being used, but it's here for consistency.
|
|
335
|
+
return 'other'
|
|
336
|
+
},
|
|
337
|
+
scottish: function (n) {
|
|
338
|
+
if (n === 1 || n === 11) { return 'one' }
|
|
339
|
+
if (n === 2 || n === 12) { return 'two' }
|
|
340
|
+
if ((n >= 3 && n <= 10) || (n >= 13 && n <= 19)) { return 'few' }
|
|
341
|
+
return 'other'
|
|
342
|
+
},
|
|
343
|
+
spanish: function (n) {
|
|
344
|
+
if (n === 1) { return 'one' }
|
|
345
|
+
if (n % 1000000 === 0 && n !== 0) { return 'many' }
|
|
346
|
+
return 'other'
|
|
347
|
+
},
|
|
348
|
+
welsh: function (n) {
|
|
349
|
+
if (n === 0) { return 'zero' }
|
|
350
|
+
if (n === 1) { return 'one' }
|
|
351
|
+
if (n === 2) { return 'two' }
|
|
352
|
+
if (n === 3) { return 'few' }
|
|
353
|
+
if (n === 6) { return 'many' }
|
|
354
|
+
return 'other'
|
|
355
|
+
}
|
|
356
|
+
/* eslint-enable jsdoc/require-jsdoc */
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Supported languages for plural rules
|
|
361
|
+
*
|
|
362
|
+
* @typedef {'arabic' | 'chinese' | 'french' | 'german' | 'irish' | 'russian' | 'scottish' | 'spanish' | 'welsh'} PluralRuleName
|
|
363
|
+
*/
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Plural rule category mnemonic tags
|
|
367
|
+
*
|
|
368
|
+
* @typedef {'zero' | 'one' | 'two' | 'few' | 'many' | 'other'} PluralRule
|
|
369
|
+
*/
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Translated message by plural rule they correspond to.
|
|
373
|
+
*
|
|
374
|
+
* Allows to group pluralised messages under a single key when passing
|
|
375
|
+
* translations to a component's constructor
|
|
376
|
+
*
|
|
377
|
+
* @typedef {object} TranslationPluralForms
|
|
378
|
+
* @property {string} [other] - General plural form
|
|
379
|
+
* @property {string} [zero] - Plural form used with 0
|
|
380
|
+
* @property {string} [one] - Plural form used with 1
|
|
381
|
+
* @property {string} [two] - Plural form used with 2
|
|
382
|
+
* @property {string} [few] - Plural form used for a few
|
|
383
|
+
* @property {string} [many] - Plural form used for many
|
|
384
|
+
*/
|
|
385
|
+
|
|
386
|
+
exports.I18n = I18n;
|
|
387
|
+
|
|
388
|
+
})));
|
|
389
|
+
//# sourceMappingURL=i18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","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 undefined instead of\n // falsy, as this could legitimately be 0.\n if (options && typeof options.count !== 'undefined') {\n // Get the plural suffix\n lookupKey = lookupKey + '.' + this.getPluralSuffix(lookupKey, options.count)\n }\n\n if (lookupKey in this.translations) {\n // Fetch the translation string for that lookup key\n var translationString = this.translations[lookupKey]\n\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 var formatter\n\n if (this.hasIntlNumberFormatSupport()) {\n formatter = new Intl.NumberFormat(this.locale)\n }\n\n return translationString.replace(/%{(.\\S+)}/g, 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 return ''\n }\n\n // If the placeholder's value is a number, localise the number formatting\n if (typeof placeholderValue === 'number' && formatter) {\n return formatter.format(placeholderValue)\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 {PluralRuleName | 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<PluralRuleName, 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 * Supported languages for plural rules\n *\n * @typedef {'arabic' | 'chinese' | 'french' | 'german' | 'irish' | 'russian' | 'scottish' | 'spanish' | 'welsh'} PluralRuleName\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":";;;;;;EAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;AACA,EAAO,SAAS,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE;EAC5C;EACA,EAAE,IAAI,CAAC,YAAY,GAAG,YAAY,IAAI,GA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AAC,KAAK,CAAC,EAAE,EAAE,OAAO,MAAM,EAAE;EAClC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,KAAK,EAAE;EACjC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,KAAK,EAAE;EACjC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,KAAK,EAAE;EACjC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,MAAM,EAAE;EAClC,IAAI,OAAO,OAAO;EAClB,GAAG;EACH;EACA,EAAC;;EAED;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,GAAG;;;;;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{#
|
|
2
|
+
# Renders the data attributes for the different plural forms
|
|
3
|
+
# of the given translation key.
|
|
4
|
+
#
|
|
5
|
+
# Helps reduce the boilerplate in component templates as they're quite verbose
|
|
6
|
+
#
|
|
7
|
+
# @private
|
|
8
|
+
# @param {string} translationKey - The kebab-cased name of the translation key
|
|
9
|
+
# @param {object} pluralForms
|
|
10
|
+
# An object associating translation messages to the plural form they correspond to
|
|
11
|
+
# http://unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules
|
|
12
|
+
#}
|
|
13
|
+
{% macro govukPluralisedI18nAttributes(translationKey, pluralForms) %}
|
|
14
|
+
{% for pluralType, message in pluralForms %} data-i18n.{{translationKey}}.{{pluralType}}="{{message | escape}}"{% endfor %}
|
|
15
|
+
{% endmacro %}
|