govuk_publishing_components 44.1.0 → 44.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +336 -225
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +334 -226
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.mjs +3 -0
- data/node_modules/govuk-frontend/dist/govuk/all.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest.svg +1 -0
- data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +1 -1
- data/node_modules/govuk-frontend/dist/govuk/common/index.mjs +21 -1
- data/node_modules/govuk-frontend/dist/govuk/common/index.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/_index.scss +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +92 -26
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +92 -26
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs +12 -21
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs +6 -16
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +89 -23
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +89 -23
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +10 -19
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js +113 -47
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs +113 -47
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs +7 -16
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss +7 -2
- data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs +6 -16
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +87 -21
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +87 -21
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs +7 -16
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss +8 -10
- data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss +8 -0
- data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/fixtures.json +12 -0
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js +87 -21
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs +87 -21
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs +7 -16
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-full-width-border.html +24 -0
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs +6 -16
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +89 -23
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +89 -23
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs +9 -18
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js +113 -47
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs +113 -47
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs +7 -16
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/README.md +15 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss +168 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_service-navigation.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_service-navigation.scss.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/fixtures.json +464 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/macro-options.json +138 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/macro.njk +3 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +249 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs +241 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs +85 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-default.html +57 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-html-navigation-items.html +49 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-large-navigation.html +153 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-long-service-name.html +20 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-navigation-with-a-current-item.html +58 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-navigation-with-an-active-item.html +58 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-non-link-navigation-items.html +49 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-link.html +20 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-name-and-navigation.html +63 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-name.html +18 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template.njk +102 -0
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js +93 -26
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs +93 -26
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs +13 -21
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js +93 -27
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs +93 -27
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs +13 -22
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss +4 -3
- data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs +16 -3
- data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend-component.mjs +49 -5
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend-component.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css +2 -2
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/init.mjs +72 -10
- data/node_modules/govuk-frontend/dist/govuk/init.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +3 -0
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss.map +1 -1
- data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +5 -1
- data/node_modules/govuk-frontend/package.json +8 -8
- metadata +29 -4
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest-2x.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest.png +0 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"accordion.mjs","sources":["../../../../src/govuk/components/accordion/accordion.mjs"],"sourcesContent":["import { mergeConfigs } from '../../common/index.mjs'\nimport { normaliseDataset } from '../../common/normalise-dataset.mjs'\nimport { ElementError } from '../../errors/index.mjs'\nimport { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'\nimport { I18n } from '../../i18n.mjs'\n\n/**\n * Accordion component\n *\n * This allows a collection of sections to be collapsed by default, showing only\n * their headers. Sections can be expanded or collapsed individually by clicking\n * their headers. A \"Show all sections\" button is also added to the top of the\n * accordion, which switches to \"Hide all sections\" when all the sections are\n * expanded.\n *\n * The state of each section is saved to the DOM via the `aria-expanded`\n * attribute, which also provides accessibility.\n *\n * @preserve\n */\nexport class Accordion extends GOVUKFrontendComponent {\n /** @private */\n $module\n\n /**\n * @private\n * @type {AccordionConfig}\n */\n config\n\n /** @private */\n i18n\n\n /** @private */\n controlsClass = 'govuk-accordion__controls'\n\n /** @private */\n showAllClass = 'govuk-accordion__show-all'\n\n /** @private */\n showAllTextClass = 'govuk-accordion__show-all-text'\n\n /** @private */\n sectionClass = 'govuk-accordion__section'\n\n /** @private */\n sectionExpandedClass = 'govuk-accordion__section--expanded'\n\n /** @private */\n sectionButtonClass = 'govuk-accordion__section-button'\n\n /** @private */\n sectionHeaderClass = 'govuk-accordion__section-header'\n\n /** @private */\n sectionHeadingClass = 'govuk-accordion__section-heading'\n\n /** @private */\n sectionHeadingDividerClass = 'govuk-accordion__section-heading-divider'\n\n /** @private */\n sectionHeadingTextClass = 'govuk-accordion__section-heading-text'\n\n /** @private */\n sectionHeadingTextFocusClass = 'govuk-accordion__section-heading-text-focus'\n\n /** @private */\n sectionShowHideToggleClass = 'govuk-accordion__section-toggle'\n\n /** @private */\n sectionShowHideToggleFocusClass = 'govuk-accordion__section-toggle-focus'\n\n /** @private */\n sectionShowHideTextClass = 'govuk-accordion__section-toggle-text'\n\n /** @private */\n upChevronIconClass = 'govuk-accordion-nav__chevron'\n\n /** @private */\n downChevronIconClass = 'govuk-accordion-nav__chevron--down'\n\n /** @private */\n sectionSummaryClass = 'govuk-accordion__section-summary'\n\n /** @private */\n sectionSummaryFocusClass = 'govuk-accordion__section-summary-focus'\n\n /** @private */\n sectionContentClass = 'govuk-accordion__section-content'\n\n /** @private */\n $sections\n\n /**\n * @private\n * @type {HTMLButtonElement | null}\n */\n $showAllButton = null\n\n /**\n * @private\n * @type {HTMLElement | null}\n */\n $showAllIcon = null\n\n /**\n * @private\n * @type {HTMLElement | null}\n */\n $showAllText = null\n\n /**\n * @param {Element | null} $module - HTML element to use for accordion\n * @param {AccordionConfig} [config] - Accordion config\n */\n constructor($module, config = {}) {\n super()\n\n if (!($module instanceof HTMLElement)) {\n throw new ElementError({\n componentName: 'Accordion',\n element: $module,\n identifier: 'Root element (`$module`)'\n })\n }\n\n this.$module = $module\n\n this.config = mergeConfigs(\n Accordion.defaults,\n config,\n normaliseDataset(Accordion, $module.dataset)\n )\n\n this.i18n = new I18n(this.config.i18n)\n\n const $sections = this.$module.querySelectorAll(`.${this.sectionClass}`)\n if (!$sections.length) {\n throw new ElementError({\n componentName: 'Accordion',\n identifier: `Sections (\\`<div class=\"${this.sectionClass}\">\\`)`\n })\n }\n\n this.$sections = $sections\n\n this.initControls()\n this.initSectionHeaders()\n\n this.updateShowAllButton(this.areAllSectionsOpen())\n }\n\n /**\n * Initialise controls and set attributes\n *\n * @private\n */\n initControls() {\n // Create \"Show all\" button and set attributes\n this.$showAllButton = document.createElement('button')\n this.$showAllButton.setAttribute('type', 'button')\n this.$showAllButton.setAttribute('class', this.showAllClass)\n this.$showAllButton.setAttribute('aria-expanded', 'false')\n\n // Create icon, add to element\n this.$showAllIcon = document.createElement('span')\n this.$showAllIcon.classList.add(this.upChevronIconClass)\n this.$showAllButton.appendChild(this.$showAllIcon)\n\n // Create control wrapper and add controls to it\n const $accordionControls = document.createElement('div')\n $accordionControls.setAttribute('class', this.controlsClass)\n $accordionControls.appendChild(this.$showAllButton)\n this.$module.insertBefore($accordionControls, this.$module.firstChild)\n\n // Build additional wrapper for Show all toggle text and place after icon\n this.$showAllText = document.createElement('span')\n this.$showAllText.classList.add(this.showAllTextClass)\n this.$showAllButton.appendChild(this.$showAllText)\n\n // Handle click events on the show/hide all button\n this.$showAllButton.addEventListener('click', () =>\n this.onShowOrHideAllToggle()\n )\n\n // Handle 'beforematch' events, if the user agent supports them\n if ('onbeforematch' in document) {\n document.addEventListener('beforematch', (event) =>\n this.onBeforeMatch(event)\n )\n }\n }\n\n /**\n * Initialise section headers\n *\n * @private\n */\n initSectionHeaders() {\n this.$sections.forEach(($section, i) => {\n const $header = $section.querySelector(`.${this.sectionHeaderClass}`)\n if (!$header) {\n throw new ElementError({\n componentName: 'Accordion',\n identifier: `Section headers (\\`<div class=\"${this.sectionHeaderClass}\">\\`)`\n })\n }\n\n // Set header attributes\n this.constructHeaderMarkup($header, i)\n this.setExpanded(this.isExpanded($section), $section)\n\n // Handle events\n $header.addEventListener('click', () => this.onSectionToggle($section))\n\n // See if there is any state stored in sessionStorage and set the sections\n // to open or closed.\n this.setInitialState($section)\n })\n }\n\n /**\n * Construct section header\n *\n * @private\n * @param {Element} $header - Section header\n * @param {number} index - Section index\n */\n constructHeaderMarkup($header, index) {\n const $span = $header.querySelector(`.${this.sectionButtonClass}`)\n const $heading = $header.querySelector(`.${this.sectionHeadingClass}`)\n const $summary = $header.querySelector(`.${this.sectionSummaryClass}`)\n\n if (!$heading) {\n throw new ElementError({\n componentName: 'Accordion',\n identifier: `Section heading (\\`.${this.sectionHeadingClass}\\`)`\n })\n }\n\n if (!$span) {\n throw new ElementError({\n componentName: 'Accordion',\n identifier: `Section button placeholder (\\`<span class=\"${this.sectionButtonClass}\">\\`)`\n })\n }\n\n // Create a button element that will replace the\n // '.govuk-accordion__section-button' span\n const $button = document.createElement('button')\n $button.setAttribute('type', 'button')\n $button.setAttribute(\n 'aria-controls',\n `${this.$module.id}-content-${index + 1}`\n )\n\n // Copy all attributes from $span to $button (except `id`, which gets added\n // to the `$headingText` element)\n for (const attr of Array.from($span.attributes)) {\n if (attr.name !== 'id') {\n $button.setAttribute(attr.name, attr.value)\n }\n }\n\n // Create container for heading text so it can be styled\n const $headingText = document.createElement('span')\n $headingText.classList.add(this.sectionHeadingTextClass)\n // Copy the span ID to the heading text to allow it to be referenced by\n // `aria-labelledby` on the hidden content area without \"Show this section\"\n $headingText.id = $span.id\n\n // Create an inner heading text container to limit the width of the focus\n // state\n const $headingTextFocus = document.createElement('span')\n $headingTextFocus.classList.add(this.sectionHeadingTextFocusClass)\n $headingText.appendChild($headingTextFocus)\n // span could contain HTML elements\n // (see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content)\n Array.from($span.childNodes).forEach(($child) =>\n $headingTextFocus.appendChild($child)\n )\n\n // Create container for show / hide icons and text.\n const $showHideToggle = document.createElement('span')\n $showHideToggle.classList.add(this.sectionShowHideToggleClass)\n // Tell Google not to index the 'show' text as part of the heading. Must be\n // set on the element before it's added to the DOM.\n // See https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#data-nosnippet-attr\n $showHideToggle.setAttribute('data-nosnippet', '')\n // Create an inner container to limit the width of the focus state\n const $showHideToggleFocus = document.createElement('span')\n $showHideToggleFocus.classList.add(this.sectionShowHideToggleFocusClass)\n $showHideToggle.appendChild($showHideToggleFocus)\n // Create wrapper for the show / hide text. Append text after the show/hide icon\n const $showHideText = document.createElement('span')\n const $showHideIcon = document.createElement('span')\n $showHideIcon.classList.add(this.upChevronIconClass)\n $showHideToggleFocus.appendChild($showHideIcon)\n $showHideText.classList.add(this.sectionShowHideTextClass)\n $showHideToggleFocus.appendChild($showHideText)\n\n // Append elements to the button:\n // 1. Heading text\n // 2. Punctuation\n // 3. (Optional: Summary line followed by punctuation)\n // 4. Show / hide toggle\n $button.appendChild($headingText)\n $button.appendChild(this.getButtonPunctuationEl())\n\n // If summary content exists add to DOM in correct order\n if ($summary) {\n // Create a new `span` element and copy the summary line content from the\n // original `div` to the new `span`. This is because the summary line text\n // is now inside a button element, which can only contain phrasing\n // content.\n const $summarySpan = document.createElement('span')\n // Create an inner summary container to limit the width of the summary\n // focus state\n const $summarySpanFocus = document.createElement('span')\n $summarySpanFocus.classList.add(this.sectionSummaryFocusClass)\n $summarySpan.appendChild($summarySpanFocus)\n\n // Get original attributes, and pass them to the replacement\n for (const attr of Array.from($summary.attributes)) {\n $summarySpan.setAttribute(attr.name, attr.value)\n }\n\n // Copy original contents of summary to the new summary span\n Array.from($summary.childNodes).forEach(($child) =>\n $summarySpanFocus.appendChild($child)\n )\n\n // Replace the original summary `div` with the new summary `span`\n $summary.remove()\n\n $button.appendChild($summarySpan)\n $button.appendChild(this.getButtonPunctuationEl())\n }\n\n $button.appendChild($showHideToggle)\n\n $heading.removeChild($span)\n $heading.appendChild($button)\n }\n\n /**\n * When a section is opened by the user agent via the 'beforematch' event\n *\n * @private\n * @param {Event} event - Generic event\n */\n onBeforeMatch(event) {\n const $fragment = event.target\n\n // Handle elements with `.closest()` support only\n if (!($fragment instanceof Element)) {\n return\n }\n\n // Handle when fragment is inside section\n const $section = $fragment.closest(`.${this.sectionClass}`)\n if ($section) {\n this.setExpanded(true, $section)\n }\n }\n\n /**\n * When section toggled, set and store state\n *\n * @private\n * @param {Element} $section - Section element\n */\n onSectionToggle($section) {\n const nowExpanded = !this.isExpanded($section)\n this.setExpanded(nowExpanded, $section)\n\n // Store the state in sessionStorage when a change is triggered\n this.storeState($section, nowExpanded)\n }\n\n /**\n * When Open/Close All toggled, set and store state\n *\n * @private\n */\n onShowOrHideAllToggle() {\n const nowExpanded = !this.areAllSectionsOpen()\n\n this.$sections.forEach(($section) => {\n this.setExpanded(nowExpanded, $section)\n this.storeState($section, nowExpanded)\n })\n\n this.updateShowAllButton(nowExpanded)\n }\n\n /**\n * Set section attributes when opened/closed\n *\n * @private\n * @param {boolean} expanded - Section expanded\n * @param {Element} $section - Section element\n */\n setExpanded(expanded, $section) {\n const $showHideIcon = $section.querySelector(`.${this.upChevronIconClass}`)\n const $showHideText = $section.querySelector(\n `.${this.sectionShowHideTextClass}`\n )\n const $button = $section.querySelector(`.${this.sectionButtonClass}`)\n const $content = $section.querySelector(`.${this.sectionContentClass}`)\n\n if (!$content) {\n throw new ElementError({\n componentName: 'Accordion',\n identifier: `Section content (\\`<div class=\"${this.sectionContentClass}\">\\`)`\n })\n }\n\n if (!$showHideIcon || !$showHideText || !$button) {\n // Return early for elements we create\n return\n }\n\n const newButtonText = expanded\n ? this.i18n.t('hideSection')\n : this.i18n.t('showSection')\n\n $showHideText.textContent = newButtonText\n $button.setAttribute('aria-expanded', `${expanded}`)\n\n // Update aria-label combining\n const ariaLabelParts = []\n\n const $headingText = $section.querySelector(\n `.${this.sectionHeadingTextClass}`\n )\n if ($headingText) {\n ariaLabelParts.push(`${$headingText.textContent}`.trim())\n }\n\n const $summary = $section.querySelector(`.${this.sectionSummaryClass}`)\n if ($summary) {\n ariaLabelParts.push(`${$summary.textContent}`.trim())\n }\n\n const ariaLabelMessage = expanded\n ? this.i18n.t('hideSectionAriaLabel')\n : this.i18n.t('showSectionAriaLabel')\n ariaLabelParts.push(ariaLabelMessage)\n\n /*\n * Join with a comma to add pause for assistive technology.\n * Example: [heading]Section A ,[pause] Show this section.\n * https://accessibility.blog.gov.uk/2017/12/18/what-working-on-gov-uk-navigation-taught-us-about-accessibility/\n */\n $button.setAttribute('aria-label', ariaLabelParts.join(' , '))\n\n // Swap icon, change class\n if (expanded) {\n $content.removeAttribute('hidden')\n $section.classList.add(this.sectionExpandedClass)\n $showHideIcon.classList.remove(this.downChevronIconClass)\n } else {\n $content.setAttribute('hidden', 'until-found')\n $section.classList.remove(this.sectionExpandedClass)\n $showHideIcon.classList.add(this.downChevronIconClass)\n }\n\n // See if \"Show all sections\" button text should be updated\n this.updateShowAllButton(this.areAllSectionsOpen())\n }\n\n /**\n * Get state of section\n *\n * @private\n * @param {Element} $section - Section element\n * @returns {boolean} True if expanded\n */\n isExpanded($section) {\n return $section.classList.contains(this.sectionExpandedClass)\n }\n\n /**\n * Check if all sections are open\n *\n * @private\n * @returns {boolean} True if all sections are open\n */\n areAllSectionsOpen() {\n return Array.from(this.$sections).every(($section) =>\n this.isExpanded($section)\n )\n }\n\n /**\n * Update \"Show all sections\" button\n *\n * @private\n * @param {boolean} expanded - Section expanded\n */\n updateShowAllButton(expanded) {\n if (!this.$showAllButton || !this.$showAllText || !this.$showAllIcon) {\n return\n }\n\n this.$showAllButton.setAttribute('aria-expanded', expanded.toString())\n this.$showAllText.textContent = expanded\n ? this.i18n.t('hideAllSections')\n : this.i18n.t('showAllSections')\n this.$showAllIcon.classList.toggle(this.downChevronIconClass, !expanded)\n }\n\n /**\n * Get the identifier for a section\n *\n * We need a unique way of identifying each content in the Accordion.\n * Since an `#id` should be unique and an `id` is required for `aria-`\n * attributes `id` can be safely used.\n *\n * @param {Element} $section - Section element\n * @returns {string | undefined | null} Identifier for section\n */\n getIdentifier($section) {\n const $button = $section.querySelector(`.${this.sectionButtonClass}`)\n\n return $button?.getAttribute('aria-controls')\n }\n\n /**\n * Set the state of the accordions in sessionStorage\n *\n * @private\n * @param {Element} $section - Section element\n * @param {boolean} isExpanded - Whether the section is expanded\n */\n storeState($section, isExpanded) {\n if (!this.config.rememberExpanded) {\n return\n }\n\n const id = this.getIdentifier($section)\n\n if (id) {\n try {\n window.sessionStorage.setItem(id, isExpanded.toString())\n } catch (exception) {}\n }\n }\n\n /**\n * Read the state of the accordions from sessionStorage\n *\n * @private\n * @param {Element} $section - Section element\n */\n setInitialState($section) {\n if (!this.config.rememberExpanded) {\n return\n }\n\n const id = this.getIdentifier($section)\n\n if (id) {\n try {\n const state = window.sessionStorage.getItem(id)\n\n if (state !== null) {\n this.setExpanded(state === 'true', $section)\n }\n } catch (exception) {}\n }\n }\n\n /**\n * Create an element to improve semantics of the section button with\n * punctuation\n *\n * Adding punctuation to the button can also improve its general semantics by\n * dividing its contents into thematic chunks. See\n * https://github.com/alphagov/govuk-frontend/issues/2327#issuecomment-922957442\n *\n * @private\n * @returns {Element} DOM element\n */\n getButtonPunctuationEl() {\n const $punctuationEl = document.createElement('span')\n $punctuationEl.classList.add(\n 'govuk-visually-hidden',\n this.sectionHeadingDividerClass\n )\n $punctuationEl.textContent = ', '\n return $punctuationEl\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-accordion'\n\n /**\n * Accordion default config\n *\n * @see {@link AccordionConfig}\n * @constant\n * @type {AccordionConfig}\n */\n static defaults = Object.freeze({\n i18n: {\n hideAllSections: 'Hide all sections',\n hideSection: 'Hide',\n hideSectionAriaLabel: 'Hide this section',\n showAllSections: 'Show all sections',\n showSection: 'Show',\n showSectionAriaLabel: 'Show this section'\n },\n rememberExpanded: true\n })\n\n /**\n * Accordion config schema\n *\n * @constant\n * @satisfies {Schema}\n */\n static schema = Object.freeze({\n properties: {\n i18n: { type: 'object' },\n rememberExpanded: { type: 'boolean' }\n }\n })\n}\n\n/**\n * Accordion config\n *\n * @see {@link Accordion.defaults}\n * @typedef {object} AccordionConfig\n * @property {AccordionTranslations} [i18n=Accordion.defaults.i18n] - Accordion translations\n * @property {boolean} [rememberExpanded] - Whether the expanded and collapsed\n * state of each section is remembered and restored when navigating.\n */\n\n/**\n * Accordion translations\n *\n * @see {@link Accordion.defaults.i18n}\n * @typedef {object} AccordionTranslations\n *\n * Messages used by the component for the labels of its buttons. This includes\n * the visible text shown on screen, and text to help assistive technology users\n * for the buttons toggling each section.\n * @property {string} [hideAllSections] - The text content for the 'Hide all\n * sections' button, used when at least one section is expanded.\n * @property {string} [hideSection] - The text content for the 'Hide'\n * button, used when a section is expanded.\n * @property {string} [hideSectionAriaLabel] - The text content appended to the\n * 'Hide' button's accessible name when a section is expanded.\n * @property {string} [showAllSections] - The text content for the 'Show all\n * sections' button, used when all sections are collapsed.\n * @property {string} [showSection] - The text content for the 'Show'\n * button, used when a section is collapsed.\n * @property {string} [showSectionAriaLabel] - The text content appended to the\n * 'Show' button's accessible name when a section is expanded.\n */\n\n/**\n * @typedef {import('../../common/index.mjs').Schema} Schema\n */\n"],"names":["Accordion","GOVUKFrontendComponent","constructor","$module","config","i18n","controlsClass","showAllClass","showAllTextClass","sectionClass","sectionExpandedClass","sectionButtonClass","sectionHeaderClass","sectionHeadingClass","sectionHeadingDividerClass","sectionHeadingTextClass","sectionHeadingTextFocusClass","sectionShowHideToggleClass","sectionShowHideToggleFocusClass","sectionShowHideTextClass","upChevronIconClass","downChevronIconClass","sectionSummaryClass","sectionSummaryFocusClass","sectionContentClass","$sections","$showAllButton","$showAllIcon","$showAllText","HTMLElement","ElementError","componentName","element","identifier","mergeConfigs","defaults","normaliseDataset","dataset","I18n","querySelectorAll","length","initControls","initSectionHeaders","updateShowAllButton","areAllSectionsOpen","document","createElement","setAttribute","classList","add","appendChild","$accordionControls","insertBefore","firstChild","addEventListener","onShowOrHideAllToggle","event","onBeforeMatch","forEach","$section","i","$header","querySelector","constructHeaderMarkup","setExpanded","isExpanded","onSectionToggle","setInitialState","index","$span","$heading","$summary","$button","id","attr","Array","from","attributes","name","value","$headingText","$headingTextFocus","childNodes","$child","$showHideToggle","$showHideToggleFocus","$showHideText","$showHideIcon","getButtonPunctuationEl","$summarySpan","$summarySpanFocus","remove","removeChild","$fragment","target","Element","closest","nowExpanded","storeState","expanded","$content","newButtonText","t","textContent","ariaLabelParts","push","trim","ariaLabelMessage","join","removeAttribute","contains","every","toString","toggle","getIdentifier","getAttribute","rememberExpanded","window","sessionStorage","setItem","exception","state","getItem","$punctuationEl","moduleName","Object","freeze","hideAllSections","hideSection","hideSectionAriaLabel","showAllSections","showSection","showSectionAriaLabel","schema","properties","type"],"mappings":";;;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,SAAS,SAASC,sBAAsB,CAAC;AA2FpD;AACF;AACA;AACA;AACEC,EAAAA,WAAWA,CAACC,OAAO,EAAEC,MAAM,GAAG,EAAE,EAAE;AAChC,IAAA,KAAK,EAAE,CAAA;AAAA,I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src/govuk/components/accordion/accordion.mjs"],"sourcesContent":["import { mergeConfigs } from '../../common/index.mjs'\nimport { normaliseDataset } from '../../common/normalise-dataset.mjs'\nimport { ElementError } from '../../errors/index.mjs'\nimport { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'\nimport { I18n } from '../../i18n.mjs'\n\n/**\n * Accordion component\n *\n * This allows a collection of sections to be collapsed by default, showing only\n * their headers. Sections can be expanded or collapsed individually by clicking\n * their headers. A \"Show all sections\" button is also added to the top of the\n * accordion, which switches to \"Hide all sections\" when all the sections are\n * expanded.\n *\n * The state of each section is saved to the DOM via the `aria-expanded`\n * attribute, which also provides accessibility.\n *\n * @preserve\n */\nexport class Accordion extends GOVUKFrontendComponent {\n /**\n * @private\n * @type {AccordionConfig}\n */\n config\n\n /** @private */\n i18n\n\n /** @private */\n controlsClass = 'govuk-accordion__controls'\n\n /** @private */\n showAllClass = 'govuk-accordion__show-all'\n\n /** @private */\n showAllTextClass = 'govuk-accordion__show-all-text'\n\n /** @private */\n sectionClass = 'govuk-accordion__section'\n\n /** @private */\n sectionExpandedClass = 'govuk-accordion__section--expanded'\n\n /** @private */\n sectionButtonClass = 'govuk-accordion__section-button'\n\n /** @private */\n sectionHeaderClass = 'govuk-accordion__section-header'\n\n /** @private */\n sectionHeadingClass = 'govuk-accordion__section-heading'\n\n /** @private */\n sectionHeadingDividerClass = 'govuk-accordion__section-heading-divider'\n\n /** @private */\n sectionHeadingTextClass = 'govuk-accordion__section-heading-text'\n\n /** @private */\n sectionHeadingTextFocusClass = 'govuk-accordion__section-heading-text-focus'\n\n /** @private */\n sectionShowHideToggleClass = 'govuk-accordion__section-toggle'\n\n /** @private */\n sectionShowHideToggleFocusClass = 'govuk-accordion__section-toggle-focus'\n\n /** @private */\n sectionShowHideTextClass = 'govuk-accordion__section-toggle-text'\n\n /** @private */\n upChevronIconClass = 'govuk-accordion-nav__chevron'\n\n /** @private */\n downChevronIconClass = 'govuk-accordion-nav__chevron--down'\n\n /** @private */\n sectionSummaryClass = 'govuk-accordion__section-summary'\n\n /** @private */\n sectionSummaryFocusClass = 'govuk-accordion__section-summary-focus'\n\n /** @private */\n sectionContentClass = 'govuk-accordion__section-content'\n\n /** @private */\n $sections\n\n /**\n * @private\n * @type {HTMLButtonElement | null}\n */\n $showAllButton = null\n\n /**\n * @private\n * @type {HTMLElement | null}\n */\n $showAllIcon = null\n\n /**\n * @private\n * @type {HTMLElement | null}\n */\n $showAllText = null\n\n /**\n * @param {Element | null} $root - HTML element to use for accordion\n * @param {AccordionConfig} [config] - Accordion config\n */\n constructor($root, config = {}) {\n super($root)\n\n this.config = mergeConfigs(\n Accordion.defaults,\n config,\n normaliseDataset(Accordion, this.$root.dataset)\n )\n\n this.i18n = new I18n(this.config.i18n)\n\n const $sections = this.$root.querySelectorAll(`.${this.sectionClass}`)\n if (!$sections.length) {\n throw new ElementError({\n component: Accordion,\n identifier: `Sections (\\`<div class=\"${this.sectionClass}\">\\`)`\n })\n }\n\n this.$sections = $sections\n\n this.initControls()\n this.initSectionHeaders()\n\n this.updateShowAllButton(this.areAllSectionsOpen())\n }\n\n /**\n * Initialise controls and set attributes\n *\n * @private\n */\n initControls() {\n // Create \"Show all\" button and set attributes\n this.$showAllButton = document.createElement('button')\n this.$showAllButton.setAttribute('type', 'button')\n this.$showAllButton.setAttribute('class', this.showAllClass)\n this.$showAllButton.setAttribute('aria-expanded', 'false')\n\n // Create icon, add to element\n this.$showAllIcon = document.createElement('span')\n this.$showAllIcon.classList.add(this.upChevronIconClass)\n this.$showAllButton.appendChild(this.$showAllIcon)\n\n // Create control wrapper and add controls to it\n const $accordionControls = document.createElement('div')\n $accordionControls.setAttribute('class', this.controlsClass)\n $accordionControls.appendChild(this.$showAllButton)\n this.$root.insertBefore($accordionControls, this.$root.firstChild)\n\n // Build additional wrapper for Show all toggle text and place after icon\n this.$showAllText = document.createElement('span')\n this.$showAllText.classList.add(this.showAllTextClass)\n this.$showAllButton.appendChild(this.$showAllText)\n\n // Handle click events on the show/hide all button\n this.$showAllButton.addEventListener('click', () =>\n this.onShowOrHideAllToggle()\n )\n\n // Handle 'beforematch' events, if the user agent supports them\n if ('onbeforematch' in document) {\n document.addEventListener('beforematch', (event) =>\n this.onBeforeMatch(event)\n )\n }\n }\n\n /**\n * Initialise section headers\n *\n * @private\n */\n initSectionHeaders() {\n this.$sections.forEach(($section, i) => {\n const $header = $section.querySelector(`.${this.sectionHeaderClass}`)\n if (!$header) {\n throw new ElementError({\n component: Accordion,\n identifier: `Section headers (\\`<div class=\"${this.sectionHeaderClass}\">\\`)`\n })\n }\n\n // Set header attributes\n this.constructHeaderMarkup($header, i)\n this.setExpanded(this.isExpanded($section), $section)\n\n // Handle events\n $header.addEventListener('click', () => this.onSectionToggle($section))\n\n // See if there is any state stored in sessionStorage and set the sections\n // to open or closed.\n this.setInitialState($section)\n })\n }\n\n /**\n * Construct section header\n *\n * @private\n * @param {Element} $header - Section header\n * @param {number} index - Section index\n */\n constructHeaderMarkup($header, index) {\n const $span = $header.querySelector(`.${this.sectionButtonClass}`)\n const $heading = $header.querySelector(`.${this.sectionHeadingClass}`)\n const $summary = $header.querySelector(`.${this.sectionSummaryClass}`)\n\n if (!$heading) {\n throw new ElementError({\n component: Accordion,\n identifier: `Section heading (\\`.${this.sectionHeadingClass}\\`)`\n })\n }\n\n if (!$span) {\n throw new ElementError({\n component: Accordion,\n identifier: `Section button placeholder (\\`<span class=\"${this.sectionButtonClass}\">\\`)`\n })\n }\n\n // Create a button element that will replace the\n // '.govuk-accordion__section-button' span\n const $button = document.createElement('button')\n $button.setAttribute('type', 'button')\n $button.setAttribute(\n 'aria-controls',\n `${this.$root.id}-content-${index + 1}`\n )\n\n // Copy all attributes from $span to $button (except `id`, which gets added\n // to the `$headingText` element)\n for (const attr of Array.from($span.attributes)) {\n if (attr.name !== 'id') {\n $button.setAttribute(attr.name, attr.value)\n }\n }\n\n // Create container for heading text so it can be styled\n const $headingText = document.createElement('span')\n $headingText.classList.add(this.sectionHeadingTextClass)\n // Copy the span ID to the heading text to allow it to be referenced by\n // `aria-labelledby` on the hidden content area without \"Show this section\"\n $headingText.id = $span.id\n\n // Create an inner heading text container to limit the width of the focus\n // state\n const $headingTextFocus = document.createElement('span')\n $headingTextFocus.classList.add(this.sectionHeadingTextFocusClass)\n $headingText.appendChild($headingTextFocus)\n // span could contain HTML elements\n // (see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content)\n Array.from($span.childNodes).forEach(($child) =>\n $headingTextFocus.appendChild($child)\n )\n\n // Create container for show / hide icons and text.\n const $showHideToggle = document.createElement('span')\n $showHideToggle.classList.add(this.sectionShowHideToggleClass)\n // Tell Google not to index the 'show' text as part of the heading. Must be\n // set on the element before it's added to the DOM.\n // See https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#data-nosnippet-attr\n $showHideToggle.setAttribute('data-nosnippet', '')\n // Create an inner container to limit the width of the focus state\n const $showHideToggleFocus = document.createElement('span')\n $showHideToggleFocus.classList.add(this.sectionShowHideToggleFocusClass)\n $showHideToggle.appendChild($showHideToggleFocus)\n // Create wrapper for the show / hide text. Append text after the show/hide icon\n const $showHideText = document.createElement('span')\n const $showHideIcon = document.createElement('span')\n $showHideIcon.classList.add(this.upChevronIconClass)\n $showHideToggleFocus.appendChild($showHideIcon)\n $showHideText.classList.add(this.sectionShowHideTextClass)\n $showHideToggleFocus.appendChild($showHideText)\n\n // Append elements to the button:\n // 1. Heading text\n // 2. Punctuation\n // 3. (Optional: Summary line followed by punctuation)\n // 4. Show / hide toggle\n $button.appendChild($headingText)\n $button.appendChild(this.getButtonPunctuationEl())\n\n // If summary content exists add to DOM in correct order\n if ($summary) {\n // Create a new `span` element and copy the summary line content from the\n // original `div` to the new `span`. This is because the summary line text\n // is now inside a button element, which can only contain phrasing\n // content.\n const $summarySpan = document.createElement('span')\n // Create an inner summary container to limit the width of the summary\n // focus state\n const $summarySpanFocus = document.createElement('span')\n $summarySpanFocus.classList.add(this.sectionSummaryFocusClass)\n $summarySpan.appendChild($summarySpanFocus)\n\n // Get original attributes, and pass them to the replacement\n for (const attr of Array.from($summary.attributes)) {\n $summarySpan.setAttribute(attr.name, attr.value)\n }\n\n // Copy original contents of summary to the new summary span\n Array.from($summary.childNodes).forEach(($child) =>\n $summarySpanFocus.appendChild($child)\n )\n\n // Replace the original summary `div` with the new summary `span`\n $summary.remove()\n\n $button.appendChild($summarySpan)\n $button.appendChild(this.getButtonPunctuationEl())\n }\n\n $button.appendChild($showHideToggle)\n\n $heading.removeChild($span)\n $heading.appendChild($button)\n }\n\n /**\n * When a section is opened by the user agent via the 'beforematch' event\n *\n * @private\n * @param {Event} event - Generic event\n */\n onBeforeMatch(event) {\n const $fragment = event.target\n\n // Handle elements with `.closest()` support only\n if (!($fragment instanceof Element)) {\n return\n }\n\n // Handle when fragment is inside section\n const $section = $fragment.closest(`.${this.sectionClass}`)\n if ($section) {\n this.setExpanded(true, $section)\n }\n }\n\n /**\n * When section toggled, set and store state\n *\n * @private\n * @param {Element} $section - Section element\n */\n onSectionToggle($section) {\n const nowExpanded = !this.isExpanded($section)\n this.setExpanded(nowExpanded, $section)\n\n // Store the state in sessionStorage when a change is triggered\n this.storeState($section, nowExpanded)\n }\n\n /**\n * When Open/Close All toggled, set and store state\n *\n * @private\n */\n onShowOrHideAllToggle() {\n const nowExpanded = !this.areAllSectionsOpen()\n\n this.$sections.forEach(($section) => {\n this.setExpanded(nowExpanded, $section)\n this.storeState($section, nowExpanded)\n })\n\n this.updateShowAllButton(nowExpanded)\n }\n\n /**\n * Set section attributes when opened/closed\n *\n * @private\n * @param {boolean} expanded - Section expanded\n * @param {Element} $section - Section element\n */\n setExpanded(expanded, $section) {\n const $showHideIcon = $section.querySelector(`.${this.upChevronIconClass}`)\n const $showHideText = $section.querySelector(\n `.${this.sectionShowHideTextClass}`\n )\n const $button = $section.querySelector(`.${this.sectionButtonClass}`)\n const $content = $section.querySelector(`.${this.sectionContentClass}`)\n\n if (!$content) {\n throw new ElementError({\n component: Accordion,\n identifier: `Section content (\\`<div class=\"${this.sectionContentClass}\">\\`)`\n })\n }\n\n if (!$showHideIcon || !$showHideText || !$button) {\n // Return early for elements we create\n return\n }\n\n const newButtonText = expanded\n ? this.i18n.t('hideSection')\n : this.i18n.t('showSection')\n\n $showHideText.textContent = newButtonText\n $button.setAttribute('aria-expanded', `${expanded}`)\n\n // Update aria-label combining\n const ariaLabelParts = []\n\n const $headingText = $section.querySelector(\n `.${this.sectionHeadingTextClass}`\n )\n if ($headingText) {\n ariaLabelParts.push(`${$headingText.textContent}`.trim())\n }\n\n const $summary = $section.querySelector(`.${this.sectionSummaryClass}`)\n if ($summary) {\n ariaLabelParts.push(`${$summary.textContent}`.trim())\n }\n\n const ariaLabelMessage = expanded\n ? this.i18n.t('hideSectionAriaLabel')\n : this.i18n.t('showSectionAriaLabel')\n ariaLabelParts.push(ariaLabelMessage)\n\n /*\n * Join with a comma to add pause for assistive technology.\n * Example: [heading]Section A ,[pause] Show this section.\n * https://accessibility.blog.gov.uk/2017/12/18/what-working-on-gov-uk-navigation-taught-us-about-accessibility/\n */\n $button.setAttribute('aria-label', ariaLabelParts.join(' , '))\n\n // Swap icon, change class\n if (expanded) {\n $content.removeAttribute('hidden')\n $section.classList.add(this.sectionExpandedClass)\n $showHideIcon.classList.remove(this.downChevronIconClass)\n } else {\n $content.setAttribute('hidden', 'until-found')\n $section.classList.remove(this.sectionExpandedClass)\n $showHideIcon.classList.add(this.downChevronIconClass)\n }\n\n // See if \"Show all sections\" button text should be updated\n this.updateShowAllButton(this.areAllSectionsOpen())\n }\n\n /**\n * Get state of section\n *\n * @private\n * @param {Element} $section - Section element\n * @returns {boolean} True if expanded\n */\n isExpanded($section) {\n return $section.classList.contains(this.sectionExpandedClass)\n }\n\n /**\n * Check if all sections are open\n *\n * @private\n * @returns {boolean} True if all sections are open\n */\n areAllSectionsOpen() {\n return Array.from(this.$sections).every(($section) =>\n this.isExpanded($section)\n )\n }\n\n /**\n * Update \"Show all sections\" button\n *\n * @private\n * @param {boolean} expanded - Section expanded\n */\n updateShowAllButton(expanded) {\n if (!this.$showAllButton || !this.$showAllText || !this.$showAllIcon) {\n return\n }\n\n this.$showAllButton.setAttribute('aria-expanded', expanded.toString())\n this.$showAllText.textContent = expanded\n ? this.i18n.t('hideAllSections')\n : this.i18n.t('showAllSections')\n this.$showAllIcon.classList.toggle(this.downChevronIconClass, !expanded)\n }\n\n /**\n * Get the identifier for a section\n *\n * We need a unique way of identifying each content in the Accordion.\n * Since an `#id` should be unique and an `id` is required for `aria-`\n * attributes `id` can be safely used.\n *\n * @param {Element} $section - Section element\n * @returns {string | undefined | null} Identifier for section\n */\n getIdentifier($section) {\n const $button = $section.querySelector(`.${this.sectionButtonClass}`)\n\n return $button?.getAttribute('aria-controls')\n }\n\n /**\n * Set the state of the accordions in sessionStorage\n *\n * @private\n * @param {Element} $section - Section element\n * @param {boolean} isExpanded - Whether the section is expanded\n */\n storeState($section, isExpanded) {\n if (!this.config.rememberExpanded) {\n return\n }\n\n const id = this.getIdentifier($section)\n\n if (id) {\n try {\n window.sessionStorage.setItem(id, isExpanded.toString())\n } catch (exception) {}\n }\n }\n\n /**\n * Read the state of the accordions from sessionStorage\n *\n * @private\n * @param {Element} $section - Section element\n */\n setInitialState($section) {\n if (!this.config.rememberExpanded) {\n return\n }\n\n const id = this.getIdentifier($section)\n\n if (id) {\n try {\n const state = window.sessionStorage.getItem(id)\n\n if (state !== null) {\n this.setExpanded(state === 'true', $section)\n }\n } catch (exception) {}\n }\n }\n\n /**\n * Create an element to improve semantics of the section button with\n * punctuation\n *\n * Adding punctuation to the button can also improve its general semantics by\n * dividing its contents into thematic chunks. See\n * https://github.com/alphagov/govuk-frontend/issues/2327#issuecomment-922957442\n *\n * @private\n * @returns {Element} DOM element\n */\n getButtonPunctuationEl() {\n const $punctuationEl = document.createElement('span')\n $punctuationEl.classList.add(\n 'govuk-visually-hidden',\n this.sectionHeadingDividerClass\n )\n $punctuationEl.textContent = ', '\n return $punctuationEl\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-accordion'\n\n /**\n * Accordion default config\n *\n * @see {@link AccordionConfig}\n * @constant\n * @type {AccordionConfig}\n */\n static defaults = Object.freeze({\n i18n: {\n hideAllSections: 'Hide all sections',\n hideSection: 'Hide',\n hideSectionAriaLabel: 'Hide this section',\n showAllSections: 'Show all sections',\n showSection: 'Show',\n showSectionAriaLabel: 'Show this section'\n },\n rememberExpanded: true\n })\n\n /**\n * Accordion config schema\n *\n * @constant\n * @satisfies {Schema}\n */\n static schema = Object.freeze({\n properties: {\n i18n: { type: 'object' },\n rememberExpanded: { type: 'boolean' }\n }\n })\n}\n\n/**\n * Accordion config\n *\n * @see {@link Accordion.defaults}\n * @typedef {object} AccordionConfig\n * @property {AccordionTranslations} [i18n=Accordion.defaults.i18n] - Accordion translations\n * @property {boolean} [rememberExpanded] - Whether the expanded and collapsed\n * state of each section is remembered and restored when navigating.\n */\n\n/**\n * Accordion translations\n *\n * @see {@link Accordion.defaults.i18n}\n * @typedef {object} AccordionTranslations\n *\n * Messages used by the component for the labels of its buttons. This includes\n * the visible text shown on screen, and text to help assistive technology users\n * for the buttons toggling each section.\n * @property {string} [hideAllSections] - The text content for the 'Hide all\n * sections' button, used when at least one section is expanded.\n * @property {string} [hideSection] - The text content for the 'Hide'\n * button, used when a section is expanded.\n * @property {string} [hideSectionAriaLabel] - The text content appended to the\n * 'Hide' button's accessible name when a section is expanded.\n * @property {string} [showAllSections] - The text content for the 'Show all\n * sections' button, used when all sections are collapsed.\n * @property {string} [showSection] - The text content for the 'Show'\n * button, used when a section is collapsed.\n * @property {string} [showSectionAriaLabel] - The text content appended to the\n * 'Show' button's accessible name when a section is expanded.\n */\n\n/**\n * @typedef {import('../../common/index.mjs').Schema} Schema\n */\n"],"names":["Accordion","GOVUKFrontendComponent","constructor","$root","config","i18n","controlsClass","showAllClass","showAllTextClass","sectionClass","sectionExpandedClass","sectionButtonClass","sectionHeaderClass","sectionHeadingClass","sectionHeadingDividerClass","sectionHeadingTextClass","sectionHeadingTextFocusClass","sectionShowHideToggleClass","sectionShowHideToggleFocusClass","sectionShowHideTextClass","upChevronIconClass","downChevronIconClass","sectionSummaryClass","sectionSummaryFocusClass","sectionContentClass","$sections","$showAllButton","$showAllIcon","$showAllText","mergeConfigs","defaults","normaliseDataset","dataset","I18n","querySelectorAll","length","ElementError","component","identifier","initControls","initSectionHeaders","updateShowAllButton","areAllSectionsOpen","document","createElement","setAttribute","classList","add","appendChild","$accordionControls","insertBefore","firstChild","addEventListener","onShowOrHideAllToggle","event","onBeforeMatch","forEach","$section","i","$header","querySelector","constructHeaderMarkup","setExpanded","isExpanded","onSectionToggle","setInitialState","index","$span","$heading","$summary","$button","id","attr","Array","from","attributes","name","value","$headingText","$headingTextFocus","childNodes","$child","$showHideToggle","$showHideToggleFocus","$showHideText","$showHideIcon","getButtonPunctuationEl","$summarySpan","$summarySpanFocus","remove","removeChild","$fragment","target","Element","closest","nowExpanded","storeState","expanded","$content","newButtonText","t","textContent","ariaLabelParts","push","trim","ariaLabelMessage","join","removeAttribute","contains","every","toString","toggle","getIdentifier","getAttribute","rememberExpanded","window","sessionStorage","setItem","exception","state","getItem","$punctuationEl","moduleName","Object","freeze","hideAllSections","hideSection","hideSectionAriaLabel","showAllSections","showSection","showSectionAriaLabel","schema","properties","type"],"mappings":";;;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,SAAS,SAASC,sBAAsB,CAAC;AAwFpD;AACF;AACA;AACA;AACEC,EAAAA,WAAWA,CAACC,KAAK,EAAEC,MAAM,GAAG,EAAE,EAAE;IAC9B,KAAK,CAACD,KAAK,CAAC,CAAA;AAAA,IAAA,IAAA,CAxFdC,MAAM,GAAA,KAAA,CAAA,CAAA;AAAA,IAAA,IAAA,CAGNC,IAAI,GAAA,KAAA,CAAA,CAAA;IAAA,IAGJC,CAAAA,aAAa,GAAG,2BAA2B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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AA3nBazH,SAAS,CAqjBb0H,UAAU,GAAG,iBAAiB,CAAA;AArjB1B1H,SAAS,CA8jBb8B,QAAQ,GAAG6F,MAAM,CAACC,MAAM,CAAC;AAC9BvH,EAAAA,IAAI,EAAE;AACJwH,IAAAA,eAAe,EAAE,mBAAmB;AACpCC,IAAAA,WAAW,EAAE,MAAM;AACnBC,IAAAA,oBAAoB,EAAE,mBAAmB;AACzCC,IAAAA,eAAe,EAAE,mBAAmB;AACpCC,IAAAA,WAAW,EAAE,MAAM;AACnBC,IAAAA,oBAAoB,EAAE,mBAAA;GACvB;AACDhB,EAAAA,gBAAgB,EAAE,IAAA;AACpB,CAAC,CAAC,CAAA;AAxkBSlH,SAAS,CAglBbmI,MAAM,GAAGR,MAAM,CAACC,MAAM,CAAC;AAC5BQ,EAAAA,UAAU,EAAE;AACV/H,IAAAA,IAAI,EAAE;AAAEgI,MAAAA,IAAI,EAAE,QAAA;KAAU;AACxBnB,IAAAA,gBAAgB,EAAE;AAAEmB,MAAAA,IAAI,EAAE,SAAA;AAAU,KAAA;AACtC,GAAA;AACF,CAAC,CAAC;;;;"}
|
@@ -74,6 +74,19 @@
|
|
74
74
|
}
|
75
75
|
return newObject[namespace];
|
76
76
|
}
|
77
|
+
function isInitialised($root, moduleName) {
|
78
|
+
return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
|
79
|
+
}
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Checks if GOV.UK Frontend is supported on this page
|
83
|
+
*
|
84
|
+
* Some browsers will load and run our JavaScript but GOV.UK Frontend
|
85
|
+
* won't be supported.
|
86
|
+
*
|
87
|
+
* @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support
|
88
|
+
* @returns {boolean} Whether GOV.UK Frontend is supported on this page
|
89
|
+
*/
|
77
90
|
function isSupported($scope = document.body) {
|
78
91
|
if (!$scope) {
|
79
92
|
return false;
|
@@ -86,6 +99,9 @@
|
|
86
99
|
function isObject(option) {
|
87
100
|
return !!option && typeof option === 'object' && !isArray(option);
|
88
101
|
}
|
102
|
+
function formatErrorMessage(Component, message) {
|
103
|
+
return `${Component.moduleName}: ${message}`;
|
104
|
+
}
|
89
105
|
|
90
106
|
/**
|
91
107
|
* Schema for component config
|
@@ -109,6 +125,10 @@
|
|
109
125
|
* @property {string[]} required - List of required config fields
|
110
126
|
* @property {string} errorMessage - Error message when required config fields not provided
|
111
127
|
*/
|
128
|
+
/**
|
129
|
+
* @typedef ComponentWithModuleName
|
130
|
+
* @property {string} moduleName - Name of the component
|
131
|
+
*/
|
112
132
|
|
113
133
|
function normaliseDataset(Component, dataset) {
|
114
134
|
const out = {};
|
@@ -146,30 +166,85 @@
|
|
146
166
|
let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
|
147
167
|
if (typeof messageOrOptions === 'object') {
|
148
168
|
const {
|
149
|
-
|
169
|
+
component,
|
150
170
|
identifier,
|
151
171
|
element,
|
152
172
|
expectedType
|
153
173
|
} = messageOrOptions;
|
154
|
-
message =
|
174
|
+
message = identifier;
|
155
175
|
message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
|
176
|
+
message = formatErrorMessage(component, message);
|
156
177
|
}
|
157
178
|
super(message);
|
158
179
|
this.name = 'ElementError';
|
159
180
|
}
|
160
181
|
}
|
182
|
+
class InitError extends GOVUKFrontendError {
|
183
|
+
constructor(componentOrMessage) {
|
184
|
+
const message = typeof componentOrMessage === 'string' ? componentOrMessage : formatErrorMessage(componentOrMessage, `Root element (\`$root\`) already initialised`);
|
185
|
+
super(message);
|
186
|
+
this.name = 'InitError';
|
187
|
+
}
|
188
|
+
}
|
189
|
+
/**
|
190
|
+
* @typedef {import('../common/index.mjs').ComponentWithModuleName} ComponentWithModuleName
|
191
|
+
*/
|
161
192
|
|
162
193
|
class GOVUKFrontendComponent {
|
163
|
-
|
164
|
-
|
194
|
+
/**
|
195
|
+
* Returns the root element of the component
|
196
|
+
*
|
197
|
+
* @protected
|
198
|
+
* @returns {RootElementType} - the root element of component
|
199
|
+
*/
|
200
|
+
get $root() {
|
201
|
+
return this._$root;
|
165
202
|
}
|
166
|
-
|
203
|
+
constructor($root) {
|
204
|
+
this._$root = void 0;
|
205
|
+
const childConstructor = this.constructor;
|
206
|
+
if (typeof childConstructor.moduleName !== 'string') {
|
207
|
+
throw new InitError(`\`moduleName\` not defined in component`);
|
208
|
+
}
|
209
|
+
if (!($root instanceof childConstructor.elementType)) {
|
210
|
+
throw new ElementError({
|
211
|
+
element: $root,
|
212
|
+
component: childConstructor,
|
213
|
+
identifier: 'Root element (`$root`)',
|
214
|
+
expectedType: childConstructor.elementType.name
|
215
|
+
});
|
216
|
+
} else {
|
217
|
+
this._$root = $root;
|
218
|
+
}
|
219
|
+
childConstructor.checkSupport();
|
220
|
+
this.checkInitialised();
|
221
|
+
const moduleName = childConstructor.moduleName;
|
222
|
+
this.$root.setAttribute(`data-${moduleName}-init`, '');
|
223
|
+
}
|
224
|
+
checkInitialised() {
|
225
|
+
const constructor = this.constructor;
|
226
|
+
const moduleName = constructor.moduleName;
|
227
|
+
if (moduleName && isInitialised(this.$root, moduleName)) {
|
228
|
+
throw new InitError(constructor);
|
229
|
+
}
|
230
|
+
}
|
231
|
+
static checkSupport() {
|
167
232
|
if (!isSupported()) {
|
168
233
|
throw new SupportError();
|
169
234
|
}
|
170
235
|
}
|
171
236
|
}
|
172
237
|
|
238
|
+
/**
|
239
|
+
* @typedef ChildClass
|
240
|
+
* @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
|
241
|
+
*/
|
242
|
+
|
243
|
+
/**
|
244
|
+
* @typedef {typeof GOVUKFrontendComponent & ChildClass} ChildClassConstructor
|
245
|
+
*/
|
246
|
+
GOVUKFrontendComponent.elementType = HTMLElement;
|
247
|
+
|
173
248
|
const DEBOUNCE_TIMEOUT_IN_SECONDS = 1;
|
174
249
|
|
175
250
|
/**
|
@@ -179,25 +254,16 @@
|
|
179
254
|
*/
|
180
255
|
class Button extends GOVUKFrontendComponent {
|
181
256
|
/**
|
182
|
-
* @param {Element | null} $
|
257
|
+
* @param {Element | null} $root - HTML element to use for button
|
183
258
|
* @param {ButtonConfig} [config] - Button config
|
184
259
|
*/
|
185
|
-
constructor($
|
186
|
-
super();
|
187
|
-
this.$module = void 0;
|
260
|
+
constructor($root, config = {}) {
|
261
|
+
super($root);
|
188
262
|
this.config = void 0;
|
189
263
|
this.debounceFormSubmitTimer = null;
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
element: $module,
|
194
|
-
identifier: 'Root element (`$module`)'
|
195
|
-
});
|
196
|
-
}
|
197
|
-
this.$module = $module;
|
198
|
-
this.config = mergeConfigs(Button.defaults, config, normaliseDataset(Button, $module.dataset));
|
199
|
-
this.$module.addEventListener('keydown', event => this.handleKeyDown(event));
|
200
|
-
this.$module.addEventListener('click', event => this.debounce(event));
|
264
|
+
this.config = mergeConfigs(Button.defaults, config, normaliseDataset(Button, this.$root.dataset));
|
265
|
+
this.$root.addEventListener('keydown', event => this.handleKeyDown(event));
|
266
|
+
this.$root.addEventListener('click', event => this.debounce(event));
|
201
267
|
}
|
202
268
|
handleKeyDown(event) {
|
203
269
|
const $target = event.target;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"button.bundle.js","sources":["../../../../src/govuk/common/normalise-string.mjs","../../../../src/govuk/common/index.mjs","../../../../src/govuk/common/normalise-dataset.mjs","../../../../src/govuk/errors/index.mjs","../../../../src/govuk/govuk-frontend-component.mjs","../../../../src/govuk/components/button/button.mjs"],"sourcesContent":["/**\n * Normalise string\n *\n * 'If it looks like a duck, and it quacks like a duck…' 🦆\n *\n * If the passed value looks like a boolean or a number, convert it to a boolean\n * or number.\n *\n * Designed to be used to convert config passed via data attributes (which are\n * always strings) into something sensible.\n *\n * @internal\n * @param {DOMStringMap[string]} value - The value to normalise\n * @param {SchemaProperty} [property] - Component schema property\n * @returns {string | boolean | number | undefined} Normalised data\n */\nexport function normaliseString(value, property) {\n const trimmedValue = value ? value.trim() : ''\n\n let output\n let outputType = property?.type\n\n // No schema type set? Determine automatically\n if (!outputType) {\n if (['true', 'false'].includes(trimmedValue)) {\n outputType = 'boolean'\n }\n\n // Empty / whitespace-only strings are considered finite so we need to check\n // the length of the trimmed string as well\n if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {\n outputType = 'number'\n }\n }\n\n switch (outputType) {\n case 'boolean':\n output = trimmedValue === 'true'\n break\n\n case 'number':\n output = Number(trimmedValue)\n break\n\n default:\n output = value\n }\n\n return output\n}\n\n/**\n * @typedef {import('./index.mjs').SchemaProperty} SchemaProperty\n */\n","import { normaliseString } from './normalise-string.mjs'\n\n/**\n * Common helpers which do not require polyfill.\n *\n * IMPORTANT: If a helper require a polyfill, please isolate it in its own module\n * so that the polyfill can be properly tree-shaken and does not burden\n * the components that do not need that helper\n */\n\n/**\n * Config merging function\n *\n * Takes any number of objects and combines them together, with\n * greatest priority on the LAST item passed in.\n *\n * @internal\n * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge\n * @returns {{ [key: string]: unknown }} A merged config object\n */\nexport function mergeConfigs(...configObjects) {\n // Start with an empty object as our base\n /** @type {{ [key: string]: unknown }} */\n const formattedConfigObject = {}\n\n // Loop through each of the passed objects\n for (const configObject of configObjects) {\n for (const key of Object.keys(configObject)) {\n const option = formattedConfigObject[key]\n const override = configObject[key]\n\n // Push their keys one-by-one into formattedConfigObject. Any duplicate\n // keys with object values will be merged, otherwise the new value will\n // override the existing value.\n if (isObject(option) && isObject(override)) {\n // @ts-expect-error Index signature for type 'string' is missing\n formattedConfigObject[key] = mergeConfigs(option, override)\n } else {\n // Apply override\n formattedConfigObject[key] = override\n }\n }\n }\n\n return formattedConfigObject\n}\n\n/**\n * Extracts keys starting with a particular namespace from dataset ('data-*')\n * object, removing the namespace in the process, normalising all values\n *\n * @internal\n * @param {{ schema: Schema }} Component - Component class\n * @param {DOMStringMap} dataset - The object to extract key-value pairs from\n * @param {string} namespace - The namespace to filter keys with\n * @returns {ObjectNested | undefined} Nested object with dot-separated key namespace removed\n */\nexport function extractConfigByNamespace(Component, dataset, namespace) {\n const property = Component.schema.properties[namespace]\n\n // Only extract configs for object schema properties\n if (property?.type !== 'object') {\n return\n }\n\n // Add default empty config\n const newObject = {\n [namespace]: /** @type {ObjectNested} */ ({})\n }\n\n for (const [key, value] of Object.entries(dataset)) {\n /** @type {ObjectNested | ObjectNested[NestedKey]} */\n let current = newObject\n\n // Split the key into parts, using . as our namespace separator\n const keyParts = key.split('.')\n\n /**\n * Create new level per part\n *\n * e.g. 'i18n.textareaDescription.other' becomes\n * `{ i18n: { textareaDescription: { other } } }`\n */\n for (const [index, name] of keyParts.entries()) {\n if (typeof current === 'object') {\n // Drop down to nested object until the last part\n if (index < keyParts.length - 1) {\n // New nested object (optionally) replaces existing value\n if (!isObject(current[name])) {\n current[name] = {}\n }\n\n // Drop down into new or existing nested object\n current = current[name]\n } else if (key !== namespace) {\n // Normalised value (optionally) replaces existing value\n current[name] = normaliseString(value)\n }\n }\n }\n }\n\n return newObject[namespace]\n}\n\n/**\n * Get hash fragment from URL\n *\n * Extract the hash fragment (everything after the hash) from a URL,\n * but not including the hash symbol\n *\n * @private\n * @param {string} url - URL\n * @returns {string | undefined} Fragment from URL, without the hash\n */\nexport function getFragmentFromUrl(url) {\n if (!url.includes('#')) {\n return undefined\n }\n\n return url.split('#').pop()\n}\n\n/**\n * Get GOV.UK Frontend breakpoint value from CSS custom property\n *\n * @private\n * @param {string} name - Breakpoint name\n * @returns {{ property: string, value?: string }} Breakpoint object\n */\nexport function getBreakpoint(name) {\n const property = `--govuk-frontend-breakpoint-${name}`\n\n // Get value from `<html>` with breakpoints on CSS :root\n const value = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(property)\n\n return {\n property,\n value: value || undefined\n }\n}\n\n/**\n * Move focus to element\n *\n * Sets tabindex to -1 to make the element programmatically focusable,\n * but removes it on blur as the element doesn't need to be focused again.\n *\n * @private\n * @template {HTMLElement} FocusElement\n * @param {FocusElement} $element - HTML element\n * @param {object} [options] - Handler options\n * @param {function(this: FocusElement): void} [options.onBeforeFocus] - Callback before focus\n * @param {function(this: FocusElement): void} [options.onBlur] - Callback on blur\n */\nexport function setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute('tabindex')\n\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1')\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener('blur', onBlur, { once: true })\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n options.onBlur?.call($element)\n\n if (!isFocusable) {\n $element.removeAttribute('tabindex')\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener('focus', onFocus, { once: true })\n\n // Focus element\n options.onBeforeFocus?.call($element)\n $element.focus()\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @internal\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nexport function isSupported($scope = document.body) {\n if (!$scope) {\n return false\n }\n\n return $scope.classList.contains('govuk-frontend-supported')\n}\n\n/**\n * Validate component config by schema\n *\n * Follows limited examples in JSON schema for wider support in future\n *\n * {@link https://ajv.js.org/json-schema.html#compound-keywords}\n * {@link https://ajv.js.org/packages/ajv-errors.html#single-message}\n *\n * @internal\n * @param {Schema} schema - Config schema\n * @param {{ [key: string]: unknown }} config - Component config\n * @returns {string[]} List of validation errors\n */\nexport function validateConfig(schema, config) {\n const validationErrors = []\n\n // Check errors for each schema\n for (const [name, conditions] of Object.entries(schema)) {\n const errors = []\n\n // Check errors for each schema condition\n if (Array.isArray(conditions)) {\n for (const { required, errorMessage } of conditions) {\n if (!required.every((key) => !!config[key])) {\n errors.push(errorMessage) // Missing config key value\n }\n }\n\n // Check one condition passes or add errors\n if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {\n validationErrors.push(...errors)\n }\n }\n }\n\n return validationErrors\n}\n\n/**\n * Check for an array\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an array\n */\nfunction isArray(option) {\n return Array.isArray(option)\n}\n\n/**\n * Check for an object\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an object\n */\nfunction isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option)\n}\n\n/**\n * Schema for component config\n *\n * @typedef {object} Schema\n * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties\n * @property {SchemaCondition[]} [anyOf] - List of schema conditions\n */\n\n/**\n * Schema property for component config\n *\n * @typedef {object} SchemaProperty\n * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type\n */\n\n/**\n * Schema condition for component config\n *\n * @typedef {object} SchemaCondition\n * @property {string[]} required - List of required config fields\n * @property {string} errorMessage - Error message when required config fields not provided\n */\n\n/**\n * @internal\n * @typedef {keyof ObjectNested} NestedKey\n * @typedef {{ [key: string]: string | boolean | number | ObjectNested | undefined }} ObjectNested\n */\n","import { extractConfigByNamespace } from './index.mjs'\nimport { normaliseString } from './normalise-string.mjs'\n\n/**\n * Normalise dataset\n *\n * Loop over an object and normalise each value using {@link normaliseString},\n * optionally expanding nested `i18n.field`\n *\n * @internal\n * @param {{ schema: Schema }} Component - Component class\n * @param {DOMStringMap} dataset - HTML element dataset\n * @returns {ObjectNested} Normalised dataset\n */\nexport function normaliseDataset(Component, dataset) {\n const out = /** @type {ReturnType<typeof normaliseDataset>} */ ({})\n\n // Normalise top-level dataset ('data-*') values using schema types\n for (const [field, property] of Object.entries(Component.schema.properties)) {\n if (field in dataset) {\n out[field] = normaliseString(dataset[field], property)\n }\n\n /**\n * Extract and normalise nested object values automatically using\n * {@link normaliseString} but only schema object types are allowed\n */\n if (property?.type === 'object') {\n out[field] = extractConfigByNamespace(Component, dataset, field)\n }\n }\n\n return out\n}\n\n/**\n * @internal\n * @typedef {import('./index.mjs').ObjectNested} ObjectNested\n * @typedef {import('./index.mjs').Schema} Schema\n */\n","/**\n * GOV.UK Frontend error\n *\n * A base class for `Error`s thrown by GOV.UK Frontend.\n *\n * It is meant to be extended into specific types of errors\n * to be thrown by our code.\n *\n * @example\n * ```js\n * class MissingRootError extends GOVUKFrontendError {\n * // Setting an explicit name is important as extending the class will not\n * // set a new `name` on the subclass. The `name` property is important\n * // to ensure intelligible error names even if the class name gets\n * // mangled by a minifier\n * name = \"MissingRootError\"\n * }\n * ```\n * @abstract\n */\nexport class GOVUKFrontendError extends Error {\n name = 'GOVUKFrontendError'\n}\n\n/**\n * Indicates that GOV.UK Frontend is not supported\n */\nexport class SupportError extends GOVUKFrontendError {\n name = 'SupportError'\n\n /**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n */\n constructor($scope = document.body) {\n const supportMessage =\n 'noModule' in HTMLScriptElement.prototype\n ? 'GOV.UK Frontend initialised without `<body class=\"govuk-frontend-supported\">` from template `<script>` snippet'\n : 'GOV.UK Frontend is not supported in this browser'\n\n super(\n $scope\n ? supportMessage\n : 'GOV.UK Frontend initialised without `<script type=\"module\">`'\n )\n }\n}\n\n/**\n * Indicates that a component has received an illegal configuration\n */\nexport class ConfigError extends GOVUKFrontendError {\n name = 'ConfigError'\n}\n\n/**\n * Indicates an issue with an element (possibly `null` or `undefined`)\n */\nexport class ElementError extends GOVUKFrontendError {\n name = 'ElementError'\n\n /**\n * @internal\n * @overload\n * @param {string} message - Element error message\n */\n\n /**\n * @internal\n * @overload\n * @param {ElementErrorOptions} options - Element error options\n */\n\n /**\n * @internal\n * @param {string | ElementErrorOptions} messageOrOptions - Element error message or options\n */\n constructor(messageOrOptions) {\n let message = typeof messageOrOptions === 'string' ? messageOrOptions : ''\n\n // Build message from options\n if (typeof messageOrOptions === 'object') {\n const { componentName, identifier, element, expectedType } =\n messageOrOptions\n\n // Add prefix and identifier\n message = `${componentName}: ${identifier}`\n\n // Append reason\n message += element\n ? ` is not of type ${expectedType ?? 'HTMLElement'}`\n : ' not found'\n }\n\n super(message)\n }\n}\n\n/**\n * Element error options\n *\n * @internal\n * @typedef {object} ElementErrorOptions\n * @property {string} componentName - The name of the component throwing the error\n * @property {string} identifier - An identifier that'll let the user understand which element has an error. This is whatever makes the most sense\n * @property {Element | null} [element] - The element in error\n * @property {string} [expectedType] - The type that was expected for the identifier\n */\n","import { isSupported } from './common/index.mjs'\nimport { SupportError } from './errors/index.mjs'\n\n/**\n * Base Component class\n *\n * Centralises the behaviours shared by our components\n *\n * @internal\n * @abstract\n */\nexport class GOVUKFrontendComponent {\n /**\n * Constructs a new component, validating that GOV.UK Frontend is supported\n *\n * @internal\n */\n constructor() {\n this.checkSupport()\n }\n\n /**\n * Validates whether GOV.UK Frontend is supported\n *\n * @private\n * @throws {SupportError} when GOV.UK Frontend is not supported\n */\n checkSupport() {\n if (!isSupported()) {\n throw new SupportError()\n }\n }\n}\n","import { mergeConfigs } from '../../common/index.mjs'\nimport { normaliseDataset } from '../../common/normalise-dataset.mjs'\nimport { ElementError } from '../../errors/index.mjs'\nimport { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'\n\nconst DEBOUNCE_TIMEOUT_IN_SECONDS = 1\n\n/**\n * JavaScript enhancements for the Button component\n *\n * @preserve\n */\nexport class Button extends GOVUKFrontendComponent {\n /** @private */\n $module\n\n /**\n * @private\n * @type {ButtonConfig}\n */\n config\n\n /**\n * @private\n * @type {number | null}\n */\n debounceFormSubmitTimer = null\n\n /**\n * @param {Element | null} $module - HTML element to use for button\n * @param {ButtonConfig} [config] - Button config\n */\n constructor($module, config = {}) {\n super()\n\n if (!($module instanceof HTMLElement)) {\n throw new ElementError({\n componentName: 'Button',\n element: $module,\n identifier: 'Root element (`$module`)'\n })\n }\n\n this.$module = $module\n\n this.config = mergeConfigs(\n Button.defaults,\n config,\n normaliseDataset(Button, $module.dataset)\n )\n\n this.$module.addEventListener('keydown', (event) =>\n this.handleKeyDown(event)\n )\n this.$module.addEventListener('click', (event) => this.debounce(event))\n }\n\n /**\n * Trigger a click event when the space key is pressed\n *\n * Some screen readers tell users they can use the space bar to activate\n * things with the 'button' role, so we need to match the functionality of\n * native HTML buttons.\n *\n * See https://github.com/alphagov/govuk_elements/pull/272#issuecomment-233028270\n *\n * @private\n * @param {KeyboardEvent} event - Keydown event\n */\n handleKeyDown(event) {\n const $target = event.target\n\n // Handle space bar only\n if (event.key !== ' ') {\n return\n }\n\n // Handle elements with [role=\"button\"] only\n if (\n $target instanceof HTMLElement &&\n $target.getAttribute('role') === 'button'\n ) {\n event.preventDefault() // prevent the page from scrolling\n $target.click()\n }\n }\n\n /**\n * Debounce double-clicks\n *\n * If the click quickly succeeds a previous click then nothing will happen.\n * This stops people accidentally causing multiple form submissions by double\n * clicking buttons.\n *\n * @private\n * @param {MouseEvent} event - Mouse click event\n * @returns {undefined | false} Returns undefined, or false when debounced\n */\n debounce(event) {\n // Check the button that was clicked has preventDoubleClick enabled\n if (!this.config.preventDoubleClick) {\n return\n }\n\n // If the timer is still running, prevent the click from submitting the form\n if (this.debounceFormSubmitTimer) {\n event.preventDefault()\n return false\n }\n\n this.debounceFormSubmitTimer = window.setTimeout(() => {\n this.debounceFormSubmitTimer = null\n }, DEBOUNCE_TIMEOUT_IN_SECONDS * 1000)\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-button'\n\n /**\n * Button default config\n *\n * @see {@link ButtonConfig}\n * @constant\n * @type {ButtonConfig}\n */\n static defaults = Object.freeze({\n preventDoubleClick: false\n })\n\n /**\n * Button config schema\n *\n * @constant\n * @satisfies {Schema}\n */\n static schema = Object.freeze({\n properties: {\n preventDoubleClick: { type: 'boolean' }\n }\n })\n}\n\n/**\n * Button config\n *\n * @typedef {object} ButtonConfig\n * @property {boolean} [preventDoubleClick=false] - Prevent accidental double\n * clicks on submit buttons from submitting forms multiple times.\n */\n\n/**\n * @typedef {import('../../common/index.mjs').Schema} Schema\n */\n"],"names":["normaliseString","value","property","trimmedValue","trim","output","outputType","type","includes","length","isFinite","Number","mergeConfigs","configObjects","formattedConfigObject","configObject","key","Object","keys","option","override","isObject","extractConfigByNamespace","Component","dataset","namespace","schema","properties","newObject","entries","current","keyParts","split","index","name","isSupported","$scope","document","body","classList","contains","isArray","Array","normaliseDataset","out","field","GOVUKFrontendError","Error","constructor","args","SupportError","supportMessage","HTMLScriptElement","prototype","ElementError","messageOrOptions","message","componentName","identifier","element","expectedType","GOVUKFrontendComponent","checkSupport","DEBOUNCE_TIMEOUT_IN_SECONDS","Button","$module","config","debounceFormSubmitTimer","HTMLElement","defaults","addEventListener","event","handleKeyDown","debounce","$target","target","getAttribute","preventDefault","click","preventDoubleClick","window","setTimeout","moduleName","freeze"],"mappings":";;;;;;EAgBO,SAASA,eAAeA,CAACC,KAAK,EAAEC,QAAQ,EAAE;IAC/C,MAAMC,YAAY,GAAGF,KAAK,GAAGA,KAAK,CAACG,IAAI,EAAE,GAAG,EAAE,CAAA;EAE9C,EAAA,IAAIC,MAAM,CAAA;EACV,EAAA,IAAIC,UAAU,GAAGJ,QAAQ,IAARA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,QAAQ,CAAEK,IAAI,CAAA;IAG/B,IAAI,CAACD,UAAU,EAAE;MACf,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAACE,QAAQ,CAACL,YAAY,CAAC,EAAE;EAC5CG,MAAAA,UAAU,GAAG,SAAS,CAAA;EACxB,KAAA;EAIA,IAAA,IAAIH,YAAY,CAACM,MAAM,GAAG,CAAC,IAAIC,QAAQ,CAACC,MAAM,CAACR,YAAY,CAAC,CAAC,EAAE;EAC7DG,MAAAA,UAAU,GAAG,QAAQ,CAAA;EACvB,KAAA;EACF,GAAA;EAEA,EAAA,QAAQA,UAAU;EAChB,IAAA,KAAK,SAAS;QACZD,MAAM,GAAGF,YAAY,KAAK,MAAM,CAAA;EA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;EACF,KAAA;EAGA,IAAA,IACE0D,OAAO,YAAYN,WAAW,IAC9BM,OAAO,CAACE,YAAY,CAAC,MAAM,CAAC,KAAK,QAAQ,EACzC;QACAL,KAAK,CAACM,cAAc,EAAE,CAAA;QACtBH,OAAO,CAACI,KAAK,EAAE,CAAA;EACjB,KAAA;EACF,GAAA;IAaAL,QAAQA,CAACF,KAAK,EAAE;EAEd,IAAA,IAAI,CAAC,IAAI,CAACL,MAAM,CAACa,kBAAkB,EAAE;EACnC,MAAA,OAAA;EACF,KAAA;MAGA,IAAI,IAAI,CAACZ,uBAAuB,EAAE;QAChCI,KAAK,CAACM,cAAc,EAAE,CAAA;EACtB,MAAA,OAAO,KAAK,CAAA;EACd,KAAA;EAEA,IAAA,IAAI,CAACV,uBAAuB,GAAGa,MAAM,CAACC,UAAU,CAAC,MAAM;QACrD,IAAI,CAACd,uBAAuB,GAAG,IAAI,CAAA;EACrC,KAAC,EAAEJ,2BAA2B,GAAG,IAAI,CAAC,CAAA;EACxC,GAAA;EA6BF,CAAA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EA9IaC,MAAM,CA0GVkB,UAAU,GAAG,cAAc,CAAA;EA1GvBlB,MAAM,CAmHVK,QAAQ,GAAGpD,MAAM,CAACkE,MAAM,CAAC;EAC9BJ,EAAAA,kBAAkB,EAAE,KAAA;EACtB,CAAC,CAAC,CAAA;EArHSf,MAAM,CA6HVtC,MAAM,GAAGT,MAAM,CAACkE,MAAM,CAAC;EAC5BxD,EAAAA,UAAU,EAAE;EACVoD,IAAAA,kBAAkB,EAAE;EAAExE,MAAAA,IAAI,EAAE,SAAA;EAAU,KAAA;EACxC,GAAA;EACF,CAAC,CAAC;;;;;;;;"}
|
1
|
+
{"version":3,"file":"button.bundle.js","sources":["../../../../src/govuk/common/normalise-string.mjs","../../../../src/govuk/common/index.mjs","../../../../src/govuk/common/normalise-dataset.mjs","../../../../src/govuk/errors/index.mjs","../../../../src/govuk/govuk-frontend-component.mjs","../../../../src/govuk/components/button/button.mjs"],"sourcesContent":["/**\n * Normalise string\n *\n * 'If it looks like a duck, and it quacks like a duck…' 🦆\n *\n * If the passed value looks like a boolean or a number, convert it to a boolean\n * or number.\n *\n * Designed to be used to convert config passed via data attributes (which are\n * always strings) into something sensible.\n *\n * @internal\n * @param {DOMStringMap[string]} value - The value to normalise\n * @param {SchemaProperty} [property] - Component schema property\n * @returns {string | boolean | number | undefined} Normalised data\n */\nexport function normaliseString(value, property) {\n const trimmedValue = value ? value.trim() : ''\n\n let output\n let outputType = property?.type\n\n // No schema type set? Determine automatically\n if (!outputType) {\n if (['true', 'false'].includes(trimmedValue)) {\n outputType = 'boolean'\n }\n\n // Empty / whitespace-only strings are considered finite so we need to check\n // the length of the trimmed string as well\n if (trimmedValue.length > 0 && isFinite(Number(trimmedValue))) {\n outputType = 'number'\n }\n }\n\n switch (outputType) {\n case 'boolean':\n output = trimmedValue === 'true'\n break\n\n case 'number':\n output = Number(trimmedValue)\n break\n\n default:\n output = value\n }\n\n return output\n}\n\n/**\n * @typedef {import('./index.mjs').SchemaProperty} SchemaProperty\n */\n","import { normaliseString } from './normalise-string.mjs'\n\n/**\n * Common helpers which do not require polyfill.\n *\n * IMPORTANT: If a helper require a polyfill, please isolate it in its own module\n * so that the polyfill can be properly tree-shaken and does not burden\n * the components that do not need that helper\n */\n\n/**\n * Config merging function\n *\n * Takes any number of objects and combines them together, with\n * greatest priority on the LAST item passed in.\n *\n * @internal\n * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge\n * @returns {{ [key: string]: unknown }} A merged config object\n */\nexport function mergeConfigs(...configObjects) {\n // Start with an empty object as our base\n /** @type {{ [key: string]: unknown }} */\n const formattedConfigObject = {}\n\n // Loop through each of the passed objects\n for (const configObject of configObjects) {\n for (const key of Object.keys(configObject)) {\n const option = formattedConfigObject[key]\n const override = configObject[key]\n\n // Push their keys one-by-one into formattedConfigObject. Any duplicate\n // keys with object values will be merged, otherwise the new value will\n // override the existing value.\n if (isObject(option) && isObject(override)) {\n // @ts-expect-error Index signature for type 'string' is missing\n formattedConfigObject[key] = mergeConfigs(option, override)\n } else {\n // Apply override\n formattedConfigObject[key] = override\n }\n }\n }\n\n return formattedConfigObject\n}\n\n/**\n * Extracts keys starting with a particular namespace from dataset ('data-*')\n * object, removing the namespace in the process, normalising all values\n *\n * @internal\n * @param {{ schema: Schema }} Component - Component class\n * @param {DOMStringMap} dataset - The object to extract key-value pairs from\n * @param {string} namespace - The namespace to filter keys with\n * @returns {ObjectNested | undefined} Nested object with dot-separated key namespace removed\n */\nexport function extractConfigByNamespace(Component, dataset, namespace) {\n const property = Component.schema.properties[namespace]\n\n // Only extract configs for object schema properties\n if (property?.type !== 'object') {\n return\n }\n\n // Add default empty config\n const newObject = {\n [namespace]: /** @type {ObjectNested} */ ({})\n }\n\n for (const [key, value] of Object.entries(dataset)) {\n /** @type {ObjectNested | ObjectNested[NestedKey]} */\n let current = newObject\n\n // Split the key into parts, using . as our namespace separator\n const keyParts = key.split('.')\n\n /**\n * Create new level per part\n *\n * e.g. 'i18n.textareaDescription.other' becomes\n * `{ i18n: { textareaDescription: { other } } }`\n */\n for (const [index, name] of keyParts.entries()) {\n if (typeof current === 'object') {\n // Drop down to nested object until the last part\n if (index < keyParts.length - 1) {\n // New nested object (optionally) replaces existing value\n if (!isObject(current[name])) {\n current[name] = {}\n }\n\n // Drop down into new or existing nested object\n current = current[name]\n } else if (key !== namespace) {\n // Normalised value (optionally) replaces existing value\n current[name] = normaliseString(value)\n }\n }\n }\n }\n\n return newObject[namespace]\n}\n\n/**\n * Get hash fragment from URL\n *\n * Extract the hash fragment (everything after the hash) from a URL,\n * but not including the hash symbol\n *\n * @private\n * @param {string} url - URL\n * @returns {string | undefined} Fragment from URL, without the hash\n */\nexport function getFragmentFromUrl(url) {\n if (!url.includes('#')) {\n return undefined\n }\n\n return url.split('#').pop()\n}\n\n/**\n * Get GOV.UK Frontend breakpoint value from CSS custom property\n *\n * @private\n * @param {string} name - Breakpoint name\n * @returns {{ property: string, value?: string }} Breakpoint object\n */\nexport function getBreakpoint(name) {\n const property = `--govuk-frontend-breakpoint-${name}`\n\n // Get value from `<html>` with breakpoints on CSS :root\n const value = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(property)\n\n return {\n property,\n value: value || undefined\n }\n}\n\n/**\n * Move focus to element\n *\n * Sets tabindex to -1 to make the element programmatically focusable,\n * but removes it on blur as the element doesn't need to be focused again.\n *\n * @private\n * @template {HTMLElement} FocusElement\n * @param {FocusElement} $element - HTML element\n * @param {object} [options] - Handler options\n * @param {function(this: FocusElement): void} [options.onBeforeFocus] - Callback before focus\n * @param {function(this: FocusElement): void} [options.onBlur] - Callback on blur\n */\nexport function setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute('tabindex')\n\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1')\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener('blur', onBlur, { once: true })\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n options.onBlur?.call($element)\n\n if (!isFocusable) {\n $element.removeAttribute('tabindex')\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener('focus', onFocus, { once: true })\n\n // Focus element\n options.onBeforeFocus?.call($element)\n $element.focus()\n}\n\n/**\n * Checks if component is already initialised\n *\n * @internal\n * @param {Element} $root - HTML element to be checked\n * @param {string} moduleName - name of component module\n * @returns {boolean} Whether component is already initialised\n */\nexport function isInitialised($root, moduleName) {\n return (\n $root instanceof HTMLElement &&\n $root.hasAttribute(`data-${moduleName}-init`)\n )\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nexport function isSupported($scope = document.body) {\n if (!$scope) {\n return false\n }\n\n return $scope.classList.contains('govuk-frontend-supported')\n}\n\n/**\n * Validate component config by schema\n *\n * Follows limited examples in JSON schema for wider support in future\n *\n * {@link https://ajv.js.org/json-schema.html#compound-keywords}\n * {@link https://ajv.js.org/packages/ajv-errors.html#single-message}\n *\n * @internal\n * @param {Schema} schema - Config schema\n * @param {{ [key: string]: unknown }} config - Component config\n * @returns {string[]} List of validation errors\n */\nexport function validateConfig(schema, config) {\n const validationErrors = []\n\n // Check errors for each schema\n for (const [name, conditions] of Object.entries(schema)) {\n const errors = []\n\n // Check errors for each schema condition\n if (Array.isArray(conditions)) {\n for (const { required, errorMessage } of conditions) {\n if (!required.every((key) => !!config[key])) {\n errors.push(errorMessage) // Missing config key value\n }\n }\n\n // Check one condition passes or add errors\n if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {\n validationErrors.push(...errors)\n }\n }\n }\n\n return validationErrors\n}\n\n/**\n * Check for an array\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an array\n */\nfunction isArray(option) {\n return Array.isArray(option)\n}\n\n/**\n * Check for an object\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an object\n */\nfunction isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option)\n}\n\n/**\n * Format error message\n *\n * @internal\n * @param {ComponentWithModuleName} Component - Component that threw the error\n * @param {string} message - Error message\n * @returns {string} - Formatted error message\n */\nexport function formatErrorMessage(Component, message) {\n return `${Component.moduleName}: ${message}`\n}\n\n/**\n * Schema for component config\n *\n * @typedef {object} Schema\n * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties\n * @property {SchemaCondition[]} [anyOf] - List of schema conditions\n */\n\n/**\n * Schema property for component config\n *\n * @typedef {object} SchemaProperty\n * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type\n */\n\n/**\n * Schema condition for component config\n *\n * @typedef {object} SchemaCondition\n * @property {string[]} required - List of required config fields\n * @property {string} errorMessage - Error message when required config fields not provided\n */\n\n/**\n * @internal\n * @typedef {keyof ObjectNested} NestedKey\n * @typedef {{ [key: string]: string | boolean | number | ObjectNested | undefined }} ObjectNested\n */\n\n/* eslint-disable jsdoc/valid-types --\n * `{new(...args: any[] ): object}` is not recognised as valid\n * https://github.com/gajus/eslint-plugin-jsdoc/issues/145#issuecomment-1308722878\n * https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/131\n **/\n\n/**\n * @typedef ComponentWithModuleName\n * @property {string} moduleName - Name of the component\n */\n\n/* eslint-enable jsdoc/valid-types */\n","import { extractConfigByNamespace } from './index.mjs'\nimport { normaliseString } from './normalise-string.mjs'\n\n/**\n * Normalise dataset\n *\n * Loop over an object and normalise each value using {@link normaliseString},\n * optionally expanding nested `i18n.field`\n *\n * @internal\n * @param {{ schema: Schema }} Component - Component class\n * @param {DOMStringMap} dataset - HTML element dataset\n * @returns {ObjectNested} Normalised dataset\n */\nexport function normaliseDataset(Component, dataset) {\n const out = /** @type {ReturnType<typeof normaliseDataset>} */ ({})\n\n // Normalise top-level dataset ('data-*') values using schema types\n for (const [field, property] of Object.entries(Component.schema.properties)) {\n if (field in dataset) {\n out[field] = normaliseString(dataset[field], property)\n }\n\n /**\n * Extract and normalise nested object values automatically using\n * {@link normaliseString} but only schema object types are allowed\n */\n if (property?.type === 'object') {\n out[field] = extractConfigByNamespace(Component, dataset, field)\n }\n }\n\n return out\n}\n\n/**\n * @internal\n * @typedef {import('./index.mjs').ObjectNested} ObjectNested\n * @typedef {import('./index.mjs').Schema} Schema\n */\n","import { formatErrorMessage } from '../common/index.mjs'\n\n/**\n * GOV.UK Frontend error\n *\n * A base class for `Error`s thrown by GOV.UK Frontend.\n *\n * It is meant to be extended into specific types of errors\n * to be thrown by our code.\n *\n * @example\n * ```js\n * class MissingRootError extends GOVUKFrontendError {\n * // Setting an explicit name is important as extending the class will not\n * // set a new `name` on the subclass. The `name` property is important\n * // to ensure intelligible error names even if the class name gets\n * // mangled by a minifier\n * name = \"MissingRootError\"\n * }\n * ```\n * @virtual\n */\nexport class GOVUKFrontendError extends Error {\n name = 'GOVUKFrontendError'\n}\n\n/**\n * Indicates that GOV.UK Frontend is not supported\n */\nexport class SupportError extends GOVUKFrontendError {\n name = 'SupportError'\n\n /**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n */\n constructor($scope = document.body) {\n const supportMessage =\n 'noModule' in HTMLScriptElement.prototype\n ? 'GOV.UK Frontend initialised without `<body class=\"govuk-frontend-supported\">` from template `<script>` snippet'\n : 'GOV.UK Frontend is not supported in this browser'\n\n super(\n $scope\n ? supportMessage\n : 'GOV.UK Frontend initialised without `<script type=\"module\">`'\n )\n }\n}\n\n/**\n * Indicates that a component has received an illegal configuration\n */\nexport class ConfigError extends GOVUKFrontendError {\n name = 'ConfigError'\n}\n\n/**\n * Indicates an issue with an element (possibly `null` or `undefined`)\n */\nexport class ElementError extends GOVUKFrontendError {\n name = 'ElementError'\n\n /**\n * @internal\n * @overload\n * @param {string} message - Element error message\n */\n\n /**\n * @internal\n * @overload\n * @param {ElementErrorOptions} options - Element error options\n */\n\n /**\n * @internal\n * @param {string | ElementErrorOptions} messageOrOptions - Element error message or options\n */\n constructor(messageOrOptions) {\n let message = typeof messageOrOptions === 'string' ? messageOrOptions : ''\n\n // Build message from options\n if (typeof messageOrOptions === 'object') {\n const { component, identifier, element, expectedType } = messageOrOptions\n\n message = identifier\n\n // Append reason\n message += element\n ? ` is not of type ${expectedType ?? 'HTMLElement'}`\n : ' not found'\n\n message = formatErrorMessage(component, message)\n }\n\n super(message)\n }\n}\n\n/**\n * Indicates that a component is already initialised\n */\nexport class InitError extends GOVUKFrontendError {\n name = 'InitError'\n\n /**\n * @internal\n * @param {ComponentWithModuleName | string} componentOrMessage - name of the component module\n */\n constructor(componentOrMessage) {\n const message =\n typeof componentOrMessage === 'string'\n ? componentOrMessage\n : formatErrorMessage(\n componentOrMessage,\n `Root element (\\`$root\\`) already initialised`\n )\n\n super(message)\n }\n}\n\n/**\n * Element error options\n *\n * @internal\n * @typedef {object} ElementErrorOptions\n * @property {string} identifier - An identifier that'll let the user understand which element has an error. This is whatever makes the most sense\n * @property {Element | null} [element] - The element in error\n * @property {string} [expectedType] - The type that was expected for the identifier\n * @property {ComponentWithModuleName} component - Component throwing the error\n */\n\n/**\n * @typedef {import('../common/index.mjs').ComponentWithModuleName} ComponentWithModuleName\n */\n","import { isInitialised, isSupported } from './common/index.mjs'\nimport { ElementError, InitError, SupportError } from './errors/index.mjs'\n\n/**\n * Base Component class\n *\n * Centralises the behaviours shared by our components\n *\n * @virtual\n * @template {Element} [RootElementType=HTMLElement]\n */\nexport class GOVUKFrontendComponent {\n /**\n * @type {typeof Element}\n */\n static elementType = HTMLElement\n\n // allows Typescript user to work around the lack of types\n // in GOVUKFrontend package, Typescript is not aware of $root\n // in components that extend GOVUKFrontendComponent\n /**\n * Returns the root element of the component\n *\n * @protected\n * @returns {RootElementType} - the root element of component\n */\n get $root() {\n return this._$root\n }\n\n /**\n * @protected\n * @type {RootElementType}\n */\n _$root\n\n /**\n * Constructs a new component, validating that GOV.UK Frontend is supported\n *\n * @internal\n * @param {Element | null} [$root] - HTML element to use for component\n */\n constructor($root) {\n const childConstructor = /** @type {ChildClassConstructor} */ (\n this.constructor\n )\n\n // TypeScript does not enforce that inheriting classes will define a `moduleName`\n // (even if we add a `@virtual` `static moduleName` property to this class).\n // While we trust users to do this correctly, we do a little check to provide them\n // a helpful error message.\n //\n // After this, we'll be sure that `childConstructor` has a `moduleName`\n // as expected of the `ChildClassConstructor` we've cast `this.constructor` to.\n if (typeof childConstructor.moduleName !== 'string') {\n throw new InitError(`\\`moduleName\\` not defined in component`)\n }\n\n if (!($root instanceof childConstructor.elementType)) {\n throw new ElementError({\n element: $root,\n component: childConstructor,\n identifier: 'Root element (`$root`)',\n expectedType: childConstructor.elementType.name\n })\n } else {\n this._$root = /** @type {RootElementType} */ ($root)\n }\n\n childConstructor.checkSupport()\n\n this.checkInitialised()\n\n const moduleName = childConstructor.moduleName\n\n this.$root.setAttribute(`data-${moduleName}-init`, '')\n }\n\n /**\n * Validates whether component is already initialised\n *\n * @private\n * @throws {InitError} when component is already initialised\n */\n checkInitialised() {\n const constructor = /** @type {ChildClassConstructor} */ (this.constructor)\n const moduleName = constructor.moduleName\n\n if (moduleName && isInitialised(this.$root, moduleName)) {\n throw new InitError(constructor)\n }\n }\n\n /**\n * Validates whether components are supported\n *\n * @throws {SupportError} when the components are not supported\n */\n static checkSupport() {\n if (!isSupported()) {\n throw new SupportError()\n }\n }\n}\n\n/**\n * @typedef ChildClass\n * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component\n */\n\n/**\n * @typedef {typeof GOVUKFrontendComponent & ChildClass} ChildClassConstructor\n */\n","import { mergeConfigs } from '../../common/index.mjs'\nimport { normaliseDataset } from '../../common/normalise-dataset.mjs'\nimport { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'\n\nconst DEBOUNCE_TIMEOUT_IN_SECONDS = 1\n\n/**\n * JavaScript enhancements for the Button component\n *\n * @preserve\n */\nexport class Button extends GOVUKFrontendComponent {\n /**\n * @private\n * @type {ButtonConfig}\n */\n config\n\n /**\n * @private\n * @type {number | null}\n */\n debounceFormSubmitTimer = null\n\n /**\n * @param {Element | null} $root - HTML element to use for button\n * @param {ButtonConfig} [config] - Button config\n */\n constructor($root, config = {}) {\n super($root)\n\n this.config = mergeConfigs(\n Button.defaults,\n config,\n normaliseDataset(Button, this.$root.dataset)\n )\n\n this.$root.addEventListener('keydown', (event) => this.handleKeyDown(event))\n this.$root.addEventListener('click', (event) => this.debounce(event))\n }\n\n /**\n * Trigger a click event when the space key is pressed\n *\n * Some screen readers tell users they can use the space bar to activate\n * things with the 'button' role, so we need to match the functionality of\n * native HTML buttons.\n *\n * See https://github.com/alphagov/govuk_elements/pull/272#issuecomment-233028270\n *\n * @private\n * @param {KeyboardEvent} event - Keydown event\n */\n handleKeyDown(event) {\n const $target = event.target\n\n // Handle space bar only\n if (event.key !== ' ') {\n return\n }\n\n // Handle elements with [role=\"button\"] only\n if (\n $target instanceof HTMLElement &&\n $target.getAttribute('role') === 'button'\n ) {\n event.preventDefault() // prevent the page from scrolling\n $target.click()\n }\n }\n\n /**\n * Debounce double-clicks\n *\n * If the click quickly succeeds a previous click then nothing will happen.\n * This stops people accidentally causing multiple form submissions by double\n * clicking buttons.\n *\n * @private\n * @param {MouseEvent} event - Mouse click event\n * @returns {undefined | false} Returns undefined, or false when debounced\n */\n debounce(event) {\n // Check the button that was clicked has preventDoubleClick enabled\n if (!this.config.preventDoubleClick) {\n return\n }\n\n // If the timer is still running, prevent the click from submitting the form\n if (this.debounceFormSubmitTimer) {\n event.preventDefault()\n return false\n }\n\n this.debounceFormSubmitTimer = window.setTimeout(() => {\n this.debounceFormSubmitTimer = null\n }, DEBOUNCE_TIMEOUT_IN_SECONDS * 1000)\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-button'\n\n /**\n * Button default config\n *\n * @see {@link ButtonConfig}\n * @constant\n * @type {ButtonConfig}\n */\n static defaults = Object.freeze({\n preventDoubleClick: false\n })\n\n /**\n * Button config schema\n *\n * @constant\n * @satisfies {Schema}\n */\n static schema = Object.freeze({\n properties: {\n preventDoubleClick: { type: 'boolean' }\n }\n })\n}\n\n/**\n * Button config\n *\n * @typedef {object} ButtonConfig\n * @property {boolean} [preventDoubleClick=false] - Prevent accidental double\n * clicks on submit buttons from submitting forms multiple times.\n */\n\n/**\n * @typedef {import('../../common/index.mjs').Schema} Schema\n */\n"],"names":["normaliseString","value","property","trimmedValue","trim","output","outputType","type","includes","length","isFinite","Number","mergeConfigs","configObjects","formattedConfigObject","configObject","key","Object","keys","option","override","isObject","extractConfigByNamespace","Component","dataset","namespace","schema","properties","newObject","entries","current","keyParts","split","index","name","isInitialised","$root","moduleName","HTMLElement","hasAttribute","isSupported","$scope","document","body","classList","contains","isArray","Array","formatErrorMessage","message","normaliseDataset","out","field","GOVUKFrontendError","Error","constructor","args","SupportError","supportMessage","HTMLScriptElement","prototype","ElementError","messageOrOptions","component","identifier","element","expectedType","InitError","componentOrMessage","GOVUKFrontendComponent","_$root","childConstructor","elementType","checkSupport","checkInitialised","setAttribute","DEBOUNCE_TIMEOUT_IN_SECONDS","Button","config","debounceFormSubmitTimer","defaults","addEventListener","event","handleKeyDown","debounce","$target","target","getAttribute","preventDefault","click","preventDoubleClick","window","setTimeout","freeze"],"mappings":";;;;;;EAgBO,SAASA,eAAeA,CAACC,KAAK,EAAEC,QAAQ,EAAE;IAC/C,MAAMC,YAAY,GAAGF,KAAK,GAAGA,KAAK,CAACG,IAAI,EAAE,GAAG,EAAE,CAAA;EAE9C,EAAA,IAAIC,MAAM,CAAA;EACV,EAAA,IAAIC,UAAU,GAAGJ,QAAQ,IAARA,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,QAAQ,CAAEK,IAAI,CAAA;IAG/B,IAAI,CAACD,UAAU,EAAE;MACf,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAACE,QAAQ,CAACL,YAAY,CAAC,EAAE;EAC5CG,MAAAA,UAAU,GAAG,SAAS,CAAA;EACxB,KAAA;EAIA,IAAA,IAAIH,YAAY,CAACM,MAAM,GAAG,CAAC,IAAIC,QAAQ,CAACC,MAAM,CAACR,YAAY,CAAC,CAAC,EAAE;EAC7DG,MAAAA,UAAU,GAAG,QAAQ,CAAA;EACvB,KAAA;EACF,GAAA;EAEA,EAAA,QAAQA,UAAU;EAChB,IAAA,KAAK,SAAS;QACZD,MAAM,GAAGF,YAAY,KAAK,MAAM,CAAA;EAChC,MAAA,MAAA;EAEF,IAAA,KAAK,QAAQ;EACXE,MAAAA,MAAM,GAAGM,MAAM,CAACR,YAAY,CAAC,CAAA;EAC7B,MAAA,MAAA;EAEF,IAAA;EACEE,MAAAA,MAAM,GAAGJ,KAAK,CAAA;EAClB,GAAA;EAEA,EAAA,OAAOI,MAAM,CAAA;EACf,CAAA;;EAEA;EACA;EACA;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