nhsuk-frontend 8.0.1 → 8.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (()=>{var n={405:()=>{NodeList.prototype.forEach||(NodeList.prototype.forEach=Array.prototype.forEach),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{enumerable:!1,value:function(t){return 0<this.filter(function(e){return e===t}).length}}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;do{if(Element.prototype.matches.call(t,e))return t}while(null!==(t=t.parentElement||t.parentNode)&&1===t.nodeType);return null}),"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:null};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n})}},i={};function k(e){var t=i[e];return void 0!==t||(t=i[e]={exports:{}},n[e](t,t.exports,k)),t.exports}(()=>{"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t,n){(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}function r(e){e=function(e){if("object"!==n(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==n(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(e);return"symbol"===n(e)?e:String(e)}var u=function(){function t(e){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function");s(this,"KEY_SPACE",32),s(this,"DEBOUNCE_TIMEOUT_IN_SECONDS",1),this.$module=e,this.debounceFormSubmitTimer=null}for(var e=t,n=e.prototype,i=[{key:"handleKeyDown",value:function(e){var t=e.target;"button"===t.getAttribute("role")&&e.keyCode===this.KEY_SPACE&&(e.preventDefault(),t.click())}},{key:"debounce",value:function(e){var t=this;if("true"===e.target.getAttribute("data-prevent-double-click"))return this.debounceFormSubmitTimer?(e.preventDefault(),!1):void(this.debounceFormSubmitTimer=setTimeout(function(){t.debounceFormSubmitTimer=null},1e3*this.DEBOUNCE_TIMEOUT_IN_SECONDS))}},{key:"init",value:function(){this.$module.addEventListener("keydown",this.handleKeyDown.bind(this)),this.$module.addEventListener("click",this.debounce.bind(this))}}],o=0;o<i.length;o++){var a=i[o];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(n,r(a.key),a)}return Object.defineProperty(e,"prototype",{writable:!1}),t}();function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function e(e,t){for(var n,i=0;i<t.length;i++){var o=t[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(n=function(e){if("object"!==a(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==a(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(o.key),"symbol"===a(n)?n:String(n)),o)}}p=[{key:"getDataset",value:function(e){var t={},n=e.attributes;if(n)for(var i=0;i<n.length;i++){var o=n[i],a=o.name.match(/^data-(.+)/);a&&(t[a[1]]=o.value)}return t}}],e((i=o).prototype,[{key:"init",value:function(){var e,t,n,i;this.$textarea&&(e=this.$module,t=this.$textarea,n=document.getElementById("".concat(t.id,"-info")),t.insertAdjacentElement("afterend",n),(i=document.createElement("div")).className="nhsuk-character-count__sr-status nhsuk-u-visually-hidden",i.setAttribute("aria-live","polite"),this.$screenReaderCountMessage=i,n.insertAdjacentElement("afterend",i),(i=document.createElement("div")).className=n.className,i.classList.add("nhsuk-character-count__status"),i.setAttribute("aria-hidden","true"),this.$visibleCountMessage=i,n.insertAdjacentElement("afterend",i),n.classList.add("nhsuk-u-visually-hidden"),this.options=o.getDataset(e),i=this.defaults.characterCountAttribute,this.options.maxwords&&(i=this.defaults.wordCountAttribute),this.maxLength=e.getAttribute(i),this.maxLength)&&(t.removeAttribute("maxlength"),this.bindChangeEvents(),"onpageshow"in window?window.addEventListener("pageshow",this.updateCountMessage.bind(this)):window.addEventListener("DOMContentLoaded",this.updateCountMessage.bind(this)),this.updateCountMessage())}},{key:"count",value:function(e){return(this.options.maxwords?e.match(/\S+/g)||[]:e).length}},{key:"bindChangeEvents",value:function(){var e=this.$textarea;e.addEventListener("keyup",this.handleKeyUp.bind(this)),e.addEventListener("focus",this.handleFocus.bind(this)),e.addEventListener("blur",this.handleBlur.bind(this))}},{key:"checkIfValueChanged",value:function(){this.$textarea.oldValue||(this.$textarea.oldValue=""),this.$textarea.value!==this.$textarea.oldValue&&(this.$textarea.oldValue=this.$textarea.value,this.updateCountMessage())}},{key:"updateCountMessage",value:function(){this.updateVisibleCountMessage(),this.updateScreenReaderCountMessage()}},{key:"updateVisibleCountMessage",value:function(){var e=this.$textarea,t=this.$visibleCountMessage,n=this.maxLength-this.count(e.value);this.isOverThreshold()?t.classList.remove("nhsuk-character-count__message--disabled"):t.classList.add("nhsuk-character-count__message--disabled"),n<0?(e.classList.add("nhsuk-textarea--error"),t.classList.remove("nhsuk-hint"),t.classList.add("nhsuk-error-message")):(e.classList.remove("nhsuk-textarea--error"),t.classList.remove("nhsuk-error-message"),t.classList.add("nhsuk-hint")),t.innerHTML=this.formattedUpdateMessage()}},{key:"updateScreenReaderCountMessage",value:function(){var e=this.$screenReaderCountMessage;this.isOverThreshold()?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",!0),e.innerHTML=this.formattedUpdateMessage()}},{key:"formattedUpdateMessage",value:function(){var e=this.$textarea,t=this.options,e=this.maxLength-this.count(e.value),n="character";return t.maxwords&&(n="word"),n+=-1==e||1==e?"":"s",t=e<0?"too many":"remaining",e=Math.abs(e),"You have ".concat(e," ").concat(n," ").concat(t)}},{key:"isOverThreshold",value:function(){var e=this.$textarea,t=this.options,e=this.count(e.value);return this.maxLength*(t.threshold||0)/100<=e}},{key:"handleKeyUp",value:function(){this.updateVisibleCountMessage(),this.lastInputTimestamp=Date.now()}},{key:"handleFocus",value:function(){var e=this;this.valueChecker=setInterval(function(){(!e.lastInputTimestamp||Date.now()-500>=e.lastInputTimestamp)&&e.checkIfValueChanged()},1e3)}},{key:"handleBlur",value:function(){clearInterval(this.valueChecker)}}]),e(i,p),Object.defineProperty(i,"prototype",{writable:!1});var l=o;function o(e){if(!(this instanceof o))throw new TypeError("Cannot call a class as a function");this.$module=e,this.$textarea=e.querySelector(".nhsuk-js-character-count"),this.$visibleCountMessage=null,this.$screenReaderCountMessage=null,this.lastInputTimestamp=null}l.prototype.defaults={characterCountAttribute:"data-maxlength",wordCountAttribute:"data-maxwords"};function c(e,t){var n;e&&t&&(n="true"===e.getAttribute(t)?"false":"true",e.setAttribute(t,n))}function h(e,t){var n;e&&t&&(n=e.getAttribute("aria-controls"))&&(n=document.getElementById(n))&&(e.checked?(n.classList.remove(t),e.setAttribute("aria-expanded",!0)):(n.classList.add(t),e.setAttribute("aria-expanded",!1)))}function d(e){e.form.querySelectorAll('input[type="checkbox"]').forEach(function(e){return h(e,"nhsuk-checkboxes__conditional--hidden")})}function b(e){!function(e){if("A"===e.tagName&&!1!==e.href){var t,e=document.querySelector(e.hash);if(e)return(t=function(e){var t=e.closest("fieldset");if(t){t=t.getElementsByTagName("legend");if(t.length){t=t[0];if("checkbox"===e.type||"radio"===e.type)return t;var n=t.getBoundingClientRect().top,i=e.getBoundingClientRect();if(i.height&&window.innerHeight&&i.top+i.height-n<window.innerHeight/2)return t}}return document.querySelector("label[for='".concat(e.getAttribute("id"),"']"))||e.closest("label")}(e))&&(t.scrollIntoView(),e.focus({preventScroll:!0}),1)}}(e.target)||e.preventDefault()}function m(e){return(m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var f=function(){function e(){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.menuIsOpen=!1,this.navigation=document.querySelector(".nhsuk-navigation"),this.navigationList=document.querySelector(".nhsuk-header__navigation-list"),this.mobileMenu=document.createElement("ul"),this.mobileMenuToggleButton=document.querySelector(".nhsuk-header__menu-toggle"),this.mobileMenuCloseButton=document.createElement("button"),this.mobileMenuContainer=document.querySelector(".nhsuk-mobile-menu-container"),this.breakpoints=[],this.width=document.body.offsetWidth}for(var t,n=e,i=[{key:"init",value:function(){var e=this;this.navigation&&this.navigationList&&this.mobileMenuToggleButton&&this.mobileMenuContainer&&(this.setupMobileMenu(),this.calculateBreakpoints(),this.updateNavigation(),this.doOnOrientationChange(),this.handleResize=this.debounce(function(){e.calculateBreakpoints(),e.updateNavigation()}),this.mobileMenuToggleButton.addEventListener("click",this.toggleMobileMenu.bind(this)),window.addEventListener("resize",this.handleResize),window.addEventListener("orientationchange",this.doOnOrientationChange()))}},{key:"debounce",value:function(i){var o,a=this,s=1<arguments.length&&void 0!==arguments[1]?arguments[1]:100;return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];clearTimeout(o),o=setTimeout(function(){i.apply(a,t)},s)}}},{key:"calculateBreakpoints",value:function(){for(var e=0,t=0;t<this.navigationList.children.length;t++)e+=this.navigationList.children[t].offsetWidth,this.breakpoints[t]=e}},{key:"setupMobileMenu",value:function(){this.mobileMenuContainer.appendChild(this.mobileMenu),this.mobileMenu.classList.add("nhsuk-header__drop-down","nhsuk-header__drop-down--hidden")}},{key:"closeMobileMenu",value:function(){this.menuIsOpen=!1,this.mobileMenu.classList.add("nhsuk-header__drop-down--hidden"),this.navigation.style.marginBottom=0,this.mobileMenuToggleButton.setAttribute("aria-expanded","false"),this.mobileMenuToggleButton.focus(),this.mobileMenuCloseButton.removeEventListener("click",this.closeMobileMenu.bind(this)),document.removeEventListener("keydown",this.handleEscapeKey.bind(this))}},{key:"handleEscapeKey",value:function(e){"Escape"===e.key&&this.closeMobileMenu()}},{key:"openMobileMenu",value:function(){var e=this.mobileMenu.offsetHeight;this.menuIsOpen=!0,this.mobileMenu.classList.remove("nhsuk-header__drop-down--hidden"),this.navigation.style.marginBottom="".concat(e,"px"),this.mobileMenuToggleButton.setAttribute("aria-expanded","true"),document.addEventListener("keydown",this.handleEscapeKey.bind(this)),this.mobileMenuCloseButton.addEventListener("click",this.closeMobileMenu.bind(this))}},{key:"toggleMobileMenu",value:function(){this.menuIsOpen?this.closeMobileMenu():this.openMobileMenu()}},{key:"updateNavigation",value:function(){var e=this.navigation.offsetWidth,t=this.navigationList.children.length;if(e<this.breakpoints[t-1]){if(this.mobileMenuToggleButton.classList.add("nhsuk-header__menu-toggle--visible"),this.mobileMenuContainer.classList.add("nhsuk-mobile-menu-container--visible"),2===t)return;for(;e<this.breakpoints[t-1];)this.mobileMenu.insertBefore(this.navigationList.children[t-2],this.mobileMenu.firstChild),--t}else if(e>this.breakpoints[t])for(;e>this.breakpoints[t];)this.navigationList.insertBefore(this.mobileMenu.removeChild(this.mobileMenu.firstChild),this.mobileMenuContainer),t+=1;this.mobileMenu.children.length||(this.mobileMenuToggleButton.classList.remove("nhsuk-header__menu-toggle--visible"),this.mobileMenuContainer.classList.remove("nhsuk-mobile-menu-container--visible")),document.body.offsetWidth!==this.width&&this.menuIsOpen&&this.closeMobileMenu()}},{key:"doOnOrientationChange",value:function(){var e=this;90===window.orientation&&setTimeout(function(){e.calculateBreakpoints(),e.updateNavigation()},200)}}],o=n.prototype,a=i,s=0;s<a.length;s++){var r=a[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(o,(t=function(e){if("object"!==m(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==m(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(r.key),"symbol"===m(t)?t:String(t)),r)}return Object.defineProperty(n,"prototype",{writable:!1}),e}();function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t(e,t){for(var n,i=0;i<t.length;i++){var o=t[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(n=function(e){if("object"!==v(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==v(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(o.key),"symbol"===v(n)?n:String(n)),o)}}p=[{key:"getHref",value:function(e){e=e.getAttribute("href");return e.slice(e.indexOf("#"),e.length)}}],t((i=g).prototype,[{key:"init",value:function(){"function"==typeof window.matchMedia&&this.responsive?this.setupResponsiveChecks():this.setup()}},{key:"setupResponsiveChecks",value:function(){this.mql=window.matchMedia("(min-width: 641px)"),this.mql.addEventListener("change",this.checkMode.bind(this)),this.checkMode()}},{key:"checkMode",value:function(){this.mql.matches?this.setup():this.teardown()}},{key:"setup",value:function(){var t=this,e=this.$module,n=this.$tabs,i=e.querySelector(".".concat(this.namespace,"__list")),o=e.querySelectorAll(".".concat(this.namespace,"__list-item"));n&&i&&o&&(i.setAttribute("role","tablist"),o.forEach(function(e){e.setAttribute("role","presentation")}),n.forEach(function(e){t.setAttributes(e),e.boundTabClick=t.onTabClick.bind(t),e.boundTabKeydown=t.onTabKeydown.bind(t),e.addEventListener("click",e.boundTabClick,!0),e.addEventListener("keydown",e.boundTabKeydown,!0),t.hideTab(e)}),i=this.getTab(window.location.hash)||this.$tabs[0],this.showTab(i),this.historyEnabled)&&(e.boundOnHashChange=this.onHashChange.bind(this),window.addEventListener("hashchange",e.boundOnHashChange,!0))}},{key:"teardown",value:function(){var t=this,e=this.$module,n=this.$tabs,i=e.querySelector(".".concat(this.namespace,"__list")),o=e.querySelectorAll(".".concat(this.namespace,"__list-item"));n&&i&&o&&(i.removeAttribute("role"),o.forEach(function(e){e.removeAttribute("role","presentation")}),n.forEach(function(e){e.removeEventListener("click",e.boundTabClick,!0),e.removeEventListener("keydown",e.boundTabKeydown,!0),t.unsetAttributes(e)}),this.historyEnabled)&&window.removeEventListener("hashchange",e.boundOnHashChange,!0)}},{key:"onHashChange",value:function(){var e,t=window.location.hash,t=this.getTab(t);t&&(this.changingHash?this.changingHash=!1:(e=this.getCurrentTab(),this.hideTab(e),this.showTab(t),t.focus()))}},{key:"hideTab",value:function(e){this.unhighlightTab(e),this.hidePanel(e)}},{key:"showTab",value:function(e){this.highlightTab(e),this.showPanel(e)}},{key:"getTab",value:function(e){return this.$module.querySelector(".".concat(this.namespace,'__tab[href="').concat(e,'"]'))}},{key:"setAttributes",value:function(e){var t=g.getHref(e).slice(1),t=(e.setAttribute("id","tab_".concat(t)),e.setAttribute("role","tab"),e.setAttribute("aria-controls",t),e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),this.getPanel(e));t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",e.id),t.classList.add(this.jsHiddenClass)}},{key:"unsetAttributes",value:function(e){e.removeAttribute("id"),e.removeAttribute("role"),e.removeAttribute("aria-controls"),e.removeAttribute("aria-selected"),e.removeAttribute("tabindex");e=this.getPanel(e);e.removeAttribute("role"),e.removeAttribute("aria-labelledby"),e.removeAttribute("tabindex"),e.classList.remove(this.jsHiddenClass)}},{key:"onTabClick",value:function(e){e.target.classList.contains("".concat(this.namespace,"__tab"))||(e.stopPropagation(),e.preventDefault()),e.preventDefault();var e=e.target,t=this.getCurrentTab();this.hideTab(t),this.showTab(e),this.createHistoryEntry(e)}},{key:"createHistoryEntry",value:function(e){var t,n;this.historyEnabled&&(n=(t=this.getPanel(e)).id,t.id="",this.changingHash=!0,window.location.hash=g.getHref(e).slice(1),t.id=n)}},{key:"onTabKeydown",value:function(e){switch(e.keyCode){case this.keys.left:case this.keys.up:this.activatePreviousTab(),e.preventDefault();break;case this.keys.right:case this.keys.down:this.activateNextTab(),e.preventDefault()}}},{key:"activateNextTab",value:function(){var e,t=this.getCurrentTab(),n=t.parentNode.nextElementSibling;(e=n?n.querySelector(".".concat(this.namespace,"__tab")):e)&&(this.hideTab(t),this.showTab(e),e.focus(),this.createHistoryEntry(e))}},{key:"activatePreviousTab",value:function(){var e,t=this.getCurrentTab(),n=t.parentNode.previousElementSibling;(e=n?n.querySelector(".".concat(this.namespace,"__tab")):e)&&(this.hideTab(t),this.showTab(e),e.focus(),this.createHistoryEntry(e))}},{key:"getPanel",value:function(e){return this.$module.querySelector(g.getHref(e))}},{key:"showPanel",value:function(e){e=this.getPanel(e);e.classList.remove(this.jsHiddenClass),e.dispatchEvent(this.showEvent)}},{key:"hidePanel",value:function(e){e=this.getPanel(e);e.classList.add(this.jsHiddenClass),e.dispatchEvent(this.hideEvent)}},{key:"unhighlightTab",value:function(e){e.setAttribute("aria-selected","false"),e.parentNode.classList.remove("".concat(this.namespace,"__list-item--selected")),e.setAttribute("tabindex","-1")}},{key:"highlightTab",value:function(e){e.setAttribute("aria-selected","true"),e.parentNode.classList.add("".concat(this.namespace,"__list-item--selected")),e.setAttribute("tabindex","0")}},{key:"getCurrentTab",value:function(){return this.$module.querySelector(".".concat(this.namespace,"__list-item--selected .").concat(this.namespace,"__tab"))}}]),t(i,p),Object.defineProperty(i,"prototype",{writable:!1});var i,p,y=g;function g(e,t,n,i){if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");this.$module=e,this.namespace=t,this.responsive=n,this.historyEnabled=i,this.$tabs=e.querySelectorAll(".".concat(this.namespace,"__tab")),this.keys={down:40,left:37,right:39,up:38},this.jsHiddenClass="".concat(this.namespace,"__panel--hidden"),this.showEvent=new CustomEvent("tab.show"),this.hideEvent=new CustomEvent("tab.hide")}k(405),document.addEventListener("DOMContentLoaded",function(){var t,e,n,i;function o(){e.forEach(function(e){return h(e,"nhsuk-radios__conditional--hidden")})}function a(e){var t,n;h(e.target,"nhsuk-checkboxes__conditional--hidden"),e.target.checked&&(e.target.hasAttribute("data-checkbox-exclusive")?((t=e.target).form.querySelectorAll('input[type="checkbox"][data-checkbox-exclusive-group="'.concat(t.getAttribute("data-checkbox-exclusive-group"),'"]')).forEach(function(e){t.form===e.form&&e!==t&&(e.checked=!1)}),d(t)):((n=e.target).form.querySelectorAll('input[type="checkbox"][data-checkbox-exclusive][data-checkbox-exclusive-group="'.concat(n.getAttribute("data-checkbox-exclusive-group"),'"]')).forEach(function(e){n.form===e.form&&(e.checked=!1)}),d(n)))}document.querySelectorAll('[data-module="nhsuk-character-count"]').forEach(function(e){new l(e).init()}),document.querySelectorAll('[data-module="nhsuk-button"]').forEach(function(e){new u(e).init()}),i=document.querySelectorAll(".nhsuk-checkboxes .nhsuk-checkboxes__input"),"onpageshow"in window?window.addEventListener("pageshow",function(){return i.forEach(d)}):window.addEventListener("DOMContentLoaded",function(){return i.forEach(d)}),i.forEach(d),i.forEach(function(e){e.addEventListener("change",a)}),"boolean"!=typeof document.createElement("details").open&&(n=document.querySelectorAll("details")).length&&n.forEach(function(e,t){var n,i,o;e.hasAttribute("nhsuk-polyfilled")||(t=t,(n=e).setAttribute("nhsuk-polyfilled","true"),n.id||n.setAttribute("id","nhsuk-details".concat(t)),(i=document.querySelector("#".concat(n.id," .nhsuk-details__text"))).id||i.setAttribute("id","nhsuk-details__text".concat(t)),(o=document.querySelector("#".concat(n.id," .nhsuk-details__summary"))).setAttribute("role","button"),o.setAttribute("aria-controls",i.id),o.setAttribute("tabIndex","0"),1==(null!==n.getAttribute("open"))?(o.setAttribute("aria-expanded","true"),i.setAttribute("aria-hidden","false")):(o.setAttribute("aria-expanded","false"),i.setAttribute("aria-hidden","true"),i.style.display="none"),o.addEventListener("click",function(){c(o,"aria-expanded"),c(i,"aria-hidden"),i.style.display="true"===i.getAttribute("aria-hidden")?"none":"",n.hasAttribute("open")?n.removeAttribute("open"):n.setAttribute("open","open")}),o.addEventListener("keydown",function(e){13!==e.keyCode&&32!==e.keyCode||(e.preventDefault(),o.click())}))}),function(e){var e=(0<arguments.length&&void 0!==e?e:{}).focusOnPageLoad,e=void 0===e||e,t=document.querySelector(".nhsuk-error-summary");t&&(e&&t.focus(),t.addEventListener("click",b))}(),(new f).init(),e=document.querySelectorAll(".nhsuk-radios--conditional .nhsuk-radios__input"),"onpageshow"in window?window.addEventListener("pageshow",o):window.addEventListener("DOMContentLoaded",o),o(),e.forEach(function(e){e.addEventListener("change",o)}),t=document.querySelector("h1"),n=document.querySelector(".nhsuk-skip-link"),t&&n&&(n.addEventListener("click",function(e){e.preventDefault(),t.setAttribute("tabIndex","-1"),t.focus()}),t.addEventListener("blur",function(e){e.preventDefault(),t.removeAttribute("tabIndex")})),function(e){var e=0<arguments.length&&void 0!==e?e:{},t=e.namespace,n=void 0===t?"nhsuk-tabs":t,t=e.responsive,i=void 0===t||t,t=e.historyEnabled,o=void 0===t||t;document.querySelectorAll('[data-module="'.concat(n,'"]')).forEach(function(e){new y(e,n,i,o).init()})}()})})()})();
1
+ (()=>{var n={405:()=>{NodeList.prototype.forEach||(NodeList.prototype.forEach=Array.prototype.forEach),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{enumerable:!1,value:function(t){return 0<this.filter(function(e){return e===t}).length}}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;do{if(Element.prototype.matches.call(t,e))return t}while(null!==(t=t.parentElement||t.parentNode)&&1===t.nodeType);return null}),"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:null};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n})}},i={};function k(e){var t=i[e];return void 0!==t||(t=i[e]={exports:{}},n[e](t,t.exports,k)),t.exports}(()=>{"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t,n){(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}function r(e){e=function(e){if("object"!==n(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==n(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(e);return"symbol"===n(e)?e:String(e)}var u=function(){function t(e){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function");s(this,"KEY_SPACE",32),s(this,"DEBOUNCE_TIMEOUT_IN_SECONDS",1),this.$module=e,this.debounceFormSubmitTimer=null}for(var e=t,n=e.prototype,i=[{key:"handleKeyDown",value:function(e){var t=e.target;"button"===t.getAttribute("role")&&e.keyCode===this.KEY_SPACE&&(e.preventDefault(),t.click())}},{key:"debounce",value:function(e){var t=this;if("true"===e.target.getAttribute("data-prevent-double-click"))return this.debounceFormSubmitTimer?(e.preventDefault(),!1):void(this.debounceFormSubmitTimer=setTimeout(function(){t.debounceFormSubmitTimer=null},1e3*this.DEBOUNCE_TIMEOUT_IN_SECONDS))}},{key:"init",value:function(){this.$module.addEventListener("keydown",this.handleKeyDown.bind(this)),this.$module.addEventListener("click",this.debounce.bind(this))}}],o=0;o<i.length;o++){var a=i[o];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(n,r(a.key),a)}return Object.defineProperty(e,"prototype",{writable:!1}),t}();function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function e(e,t){for(var n,i=0;i<t.length;i++){var o=t[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(n=function(e){if("object"!==a(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==a(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(o.key),"symbol"===a(n)?n:String(n)),o)}}p=[{key:"getDataset",value:function(e){var t={},n=e.attributes;if(n)for(var i=0;i<n.length;i++){var o=n[i],a=o.name.match(/^data-(.+)/);a&&(t[a[1]]=o.value)}return t}}],e((i=o).prototype,[{key:"init",value:function(){var e,t,n,i;this.$textarea&&(e=this.$module,t=this.$textarea,n=document.getElementById("".concat(t.id,"-info")),t.insertAdjacentElement("afterend",n),(i=document.createElement("div")).className="nhsuk-character-count__sr-status nhsuk-u-visually-hidden",i.setAttribute("aria-live","polite"),this.$screenReaderCountMessage=i,n.insertAdjacentElement("afterend",i),(i=document.createElement("div")).className=n.className,i.classList.add("nhsuk-character-count__status"),i.setAttribute("aria-hidden","true"),this.$visibleCountMessage=i,n.insertAdjacentElement("afterend",i),n.classList.add("nhsuk-u-visually-hidden"),this.options=o.getDataset(e),i=this.defaults.characterCountAttribute,this.options.maxwords&&(i=this.defaults.wordCountAttribute),this.maxLength=e.getAttribute(i),this.maxLength)&&(t.removeAttribute("maxlength"),this.bindChangeEvents(),"onpageshow"in window?window.addEventListener("pageshow",this.updateCountMessage.bind(this)):window.addEventListener("DOMContentLoaded",this.updateCountMessage.bind(this)),this.updateCountMessage())}},{key:"count",value:function(e){return(this.options.maxwords?e.match(/\S+/g)||[]:e).length}},{key:"bindChangeEvents",value:function(){var e=this.$textarea;e.addEventListener("keyup",this.handleKeyUp.bind(this)),e.addEventListener("focus",this.handleFocus.bind(this)),e.addEventListener("blur",this.handleBlur.bind(this))}},{key:"checkIfValueChanged",value:function(){this.$textarea.oldValue||(this.$textarea.oldValue=""),this.$textarea.value!==this.$textarea.oldValue&&(this.$textarea.oldValue=this.$textarea.value,this.updateCountMessage())}},{key:"updateCountMessage",value:function(){this.updateVisibleCountMessage(),this.updateScreenReaderCountMessage()}},{key:"updateVisibleCountMessage",value:function(){var e=this.$textarea,t=this.$visibleCountMessage,n=this.maxLength-this.count(e.value);this.isOverThreshold()?t.classList.remove("nhsuk-character-count__message--disabled"):t.classList.add("nhsuk-character-count__message--disabled"),n<0?(e.classList.add("nhsuk-textarea--error"),t.classList.remove("nhsuk-hint"),t.classList.add("nhsuk-error-message")):(e.classList.remove("nhsuk-textarea--error"),t.classList.remove("nhsuk-error-message"),t.classList.add("nhsuk-hint")),t.innerHTML=this.formattedUpdateMessage()}},{key:"updateScreenReaderCountMessage",value:function(){var e=this.$screenReaderCountMessage;this.isOverThreshold()?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",!0),e.innerHTML=this.formattedUpdateMessage()}},{key:"formattedUpdateMessage",value:function(){var e=this.$textarea,t=this.options,e=this.maxLength-this.count(e.value),n="character";return t.maxwords&&(n="word"),n+=-1==e||1==e?"":"s",t=e<0?"too many":"remaining",e=Math.abs(e),"You have ".concat(e," ").concat(n," ").concat(t)}},{key:"isOverThreshold",value:function(){var e=this.$textarea,t=this.options,e=this.count(e.value);return this.maxLength*(t.threshold||0)/100<=e}},{key:"handleKeyUp",value:function(){this.updateVisibleCountMessage(),this.lastInputTimestamp=Date.now()}},{key:"handleFocus",value:function(){var e=this;this.valueChecker=setInterval(function(){(!e.lastInputTimestamp||Date.now()-500>=e.lastInputTimestamp)&&e.checkIfValueChanged()},1e3)}},{key:"handleBlur",value:function(){clearInterval(this.valueChecker)}}]),e(i,p),Object.defineProperty(i,"prototype",{writable:!1});var l=o;function o(e){if(!(this instanceof o))throw new TypeError("Cannot call a class as a function");this.$module=e,this.$textarea=e.querySelector(".nhsuk-js-character-count"),this.$visibleCountMessage=null,this.$screenReaderCountMessage=null,this.lastInputTimestamp=null}l.prototype.defaults={characterCountAttribute:"data-maxlength",wordCountAttribute:"data-maxwords"};function c(e,t){var n;e&&t&&(n="true"===e.getAttribute(t)?"false":"true",e.setAttribute(t,n))}function h(e,t){var n;e&&t&&(n=e.getAttribute("aria-controls"))&&(n=document.getElementById(n))&&(e.checked?(n.classList.remove(t),e.setAttribute("aria-expanded",!0)):(n.classList.add(t),e.setAttribute("aria-expanded",!1)))}function d(e){e.form.querySelectorAll('input[type="checkbox"]').forEach(function(e){return h(e,"nhsuk-checkboxes__conditional--hidden")})}function b(e){!function(e){if("A"===e.tagName&&!1!==e.href){var t,e=document.querySelector(e.hash);if(e)return(t=function(e){var t=e.closest("fieldset");if(t){t=t.getElementsByTagName("legend");if(t.length){t=t[0];if("checkbox"===e.type||"radio"===e.type)return t;var n=t.getBoundingClientRect().top,i=e.getBoundingClientRect();if(i.height&&window.innerHeight&&i.top+i.height-n<window.innerHeight/2)return t}}return document.querySelector("label[for='".concat(e.getAttribute("id"),"']"))||e.closest("label")}(e))&&(t.scrollIntoView(),e.focus({preventScroll:!0}),1)}}(e.target)||e.preventDefault()}function m(e){return(m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var f=function(){function e(){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.menuIsOpen=!1,this.navigation=document.querySelector(".nhsuk-navigation"),this.navigationList=document.querySelector(".nhsuk-header__navigation-list"),this.mobileMenu=document.createElement("ul"),this.mobileMenuToggleButton=document.querySelector(".nhsuk-header__menu-toggle"),this.mobileMenuCloseButton=document.createElement("button"),this.mobileMenuContainer=document.querySelector(".nhsuk-mobile-menu-container"),this.breakpoints=[],this.width=document.body.offsetWidth}for(var t,n=e,i=[{key:"init",value:function(){var e=this;this.navigation&&this.navigationList&&this.mobileMenuToggleButton&&this.mobileMenuContainer&&(this.setupMobileMenu(),this.calculateBreakpoints(),this.updateNavigation(),this.doOnOrientationChange(),this.handleResize=this.debounce(function(){e.calculateBreakpoints(),e.updateNavigation()}),this.mobileMenuToggleButton.addEventListener("click",this.toggleMobileMenu.bind(this)),window.addEventListener("resize",this.handleResize),window.addEventListener("orientationchange",this.doOnOrientationChange()))}},{key:"debounce",value:function(i){var o,a=this,s=1<arguments.length&&void 0!==arguments[1]?arguments[1]:100;return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];clearTimeout(o),o=setTimeout(function(){i.apply(a,t)},s)}}},{key:"calculateBreakpoints",value:function(){for(var e=0,t=0;t<this.navigationList.children.length;t++)e+=this.navigationList.children[t].offsetWidth,this.breakpoints[t]=e}},{key:"setupMobileMenu",value:function(){this.mobileMenuContainer.appendChild(this.mobileMenu),this.mobileMenu.classList.add("nhsuk-header__drop-down","nhsuk-header__drop-down--hidden")}},{key:"closeMobileMenu",value:function(){this.menuIsOpen=!1,this.mobileMenu.classList.add("nhsuk-header__drop-down--hidden"),this.navigation.style.marginBottom=0,this.mobileMenuToggleButton.setAttribute("aria-expanded","false"),this.mobileMenuToggleButton.focus(),this.mobileMenuCloseButton.removeEventListener("click",this.closeMobileMenu.bind(this)),document.removeEventListener("keydown",this.handleEscapeKey.bind(this))}},{key:"handleEscapeKey",value:function(e){"Escape"===e.key&&this.closeMobileMenu()}},{key:"openMobileMenu",value:function(){this.menuIsOpen=!0,this.mobileMenu.classList.remove("nhsuk-header__drop-down--hidden");var e=this.mobileMenu.offsetHeight;this.navigation.style.marginBottom="".concat(e,"px"),this.mobileMenuToggleButton.setAttribute("aria-expanded","true"),document.addEventListener("keydown",this.handleEscapeKey.bind(this)),this.mobileMenuCloseButton.addEventListener("click",this.closeMobileMenu.bind(this))}},{key:"toggleMobileMenu",value:function(){this.menuIsOpen?this.closeMobileMenu():this.openMobileMenu()}},{key:"updateNavigation",value:function(){var e=this.navigation.offsetWidth,t=this.navigationList.children.length;if(e<this.breakpoints[t-1]){if(this.mobileMenuToggleButton.classList.add("nhsuk-header__menu-toggle--visible"),this.mobileMenuContainer.classList.add("nhsuk-mobile-menu-container--visible"),2===t)return;for(;e<this.breakpoints[t-1];)this.mobileMenu.insertBefore(this.navigationList.children[t-2],this.mobileMenu.firstChild),--t}else if(e>this.breakpoints[t])for(;e>this.breakpoints[t];)this.navigationList.insertBefore(this.mobileMenu.removeChild(this.mobileMenu.firstChild),this.mobileMenuContainer),t+=1;this.mobileMenu.children.length||(this.mobileMenuToggleButton.classList.remove("nhsuk-header__menu-toggle--visible"),this.mobileMenuContainer.classList.remove("nhsuk-mobile-menu-container--visible")),document.body.offsetWidth!==this.width&&this.menuIsOpen&&this.closeMobileMenu()}},{key:"doOnOrientationChange",value:function(){var e=this;90===window.orientation&&setTimeout(function(){e.calculateBreakpoints(),e.updateNavigation()},200)}}],o=n.prototype,a=i,s=0;s<a.length;s++){var r=a[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(o,(t=function(e){if("object"!==m(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==m(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(r.key),"symbol"===m(t)?t:String(t)),r)}return Object.defineProperty(n,"prototype",{writable:!1}),e}();function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t(e,t){for(var n,i=0;i<t.length;i++){var o=t[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(n=function(e){if("object"!==v(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==v(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(o.key),"symbol"===v(n)?n:String(n)),o)}}p=[{key:"getHref",value:function(e){e=e.getAttribute("href");return e.slice(e.indexOf("#"),e.length)}}],t((i=g).prototype,[{key:"init",value:function(){"function"==typeof window.matchMedia&&this.responsive?this.setupResponsiveChecks():this.setup()}},{key:"setupResponsiveChecks",value:function(){this.mql=window.matchMedia("(min-width: 641px)"),this.mql.addEventListener("change",this.checkMode.bind(this)),this.checkMode()}},{key:"checkMode",value:function(){this.mql.matches?this.setup():this.teardown()}},{key:"setup",value:function(){var t=this,e=this.$module,n=this.$tabs,i=e.querySelector(".".concat(this.namespace,"__list")),o=e.querySelectorAll(".".concat(this.namespace,"__list-item"));n&&i&&o&&(i.setAttribute("role","tablist"),o.forEach(function(e){e.setAttribute("role","presentation")}),n.forEach(function(e){t.setAttributes(e),e.boundTabClick=t.onTabClick.bind(t),e.boundTabKeydown=t.onTabKeydown.bind(t),e.addEventListener("click",e.boundTabClick,!0),e.addEventListener("keydown",e.boundTabKeydown,!0),t.hideTab(e)}),i=this.getTab(window.location.hash)||this.$tabs[0],this.showTab(i),this.historyEnabled)&&(e.boundOnHashChange=this.onHashChange.bind(this),window.addEventListener("hashchange",e.boundOnHashChange,!0))}},{key:"teardown",value:function(){var t=this,e=this.$module,n=this.$tabs,i=e.querySelector(".".concat(this.namespace,"__list")),o=e.querySelectorAll(".".concat(this.namespace,"__list-item"));n&&i&&o&&(i.removeAttribute("role"),o.forEach(function(e){e.removeAttribute("role","presentation")}),n.forEach(function(e){e.removeEventListener("click",e.boundTabClick,!0),e.removeEventListener("keydown",e.boundTabKeydown,!0),t.unsetAttributes(e)}),this.historyEnabled)&&window.removeEventListener("hashchange",e.boundOnHashChange,!0)}},{key:"onHashChange",value:function(){var e,t=window.location.hash,t=this.getTab(t);t&&(this.changingHash?this.changingHash=!1:(e=this.getCurrentTab(),this.hideTab(e),this.showTab(t),t.focus()))}},{key:"hideTab",value:function(e){this.unhighlightTab(e),this.hidePanel(e)}},{key:"showTab",value:function(e){this.highlightTab(e),this.showPanel(e)}},{key:"getTab",value:function(e){return this.$module.querySelector(".".concat(this.namespace,'__tab[href="').concat(e,'"]'))}},{key:"setAttributes",value:function(e){var t=g.getHref(e).slice(1),t=(e.setAttribute("id","tab_".concat(t)),e.setAttribute("role","tab"),e.setAttribute("aria-controls",t),e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),this.getPanel(e));t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",e.id),t.classList.add(this.jsHiddenClass)}},{key:"unsetAttributes",value:function(e){e.removeAttribute("id"),e.removeAttribute("role"),e.removeAttribute("aria-controls"),e.removeAttribute("aria-selected"),e.removeAttribute("tabindex");e=this.getPanel(e);e.removeAttribute("role"),e.removeAttribute("aria-labelledby"),e.removeAttribute("tabindex"),e.classList.remove(this.jsHiddenClass)}},{key:"onTabClick",value:function(e){e.target.classList.contains("".concat(this.namespace,"__tab"))||(e.stopPropagation(),e.preventDefault()),e.preventDefault();var e=e.target,t=this.getCurrentTab();this.hideTab(t),this.showTab(e),this.createHistoryEntry(e)}},{key:"createHistoryEntry",value:function(e){var t,n;this.historyEnabled&&(n=(t=this.getPanel(e)).id,t.id="",this.changingHash=!0,window.location.hash=g.getHref(e).slice(1),t.id=n)}},{key:"onTabKeydown",value:function(e){switch(e.keyCode){case this.keys.left:case this.keys.up:this.activatePreviousTab(),e.preventDefault();break;case this.keys.right:case this.keys.down:this.activateNextTab(),e.preventDefault()}}},{key:"activateNextTab",value:function(){var e,t=this.getCurrentTab(),n=t.parentNode.nextElementSibling;(e=n?n.querySelector(".".concat(this.namespace,"__tab")):e)&&(this.hideTab(t),this.showTab(e),e.focus(),this.createHistoryEntry(e))}},{key:"activatePreviousTab",value:function(){var e,t=this.getCurrentTab(),n=t.parentNode.previousElementSibling;(e=n?n.querySelector(".".concat(this.namespace,"__tab")):e)&&(this.hideTab(t),this.showTab(e),e.focus(),this.createHistoryEntry(e))}},{key:"getPanel",value:function(e){return this.$module.querySelector(g.getHref(e))}},{key:"showPanel",value:function(e){e=this.getPanel(e);e.classList.remove(this.jsHiddenClass),e.dispatchEvent(this.showEvent)}},{key:"hidePanel",value:function(e){e=this.getPanel(e);e.classList.add(this.jsHiddenClass),e.dispatchEvent(this.hideEvent)}},{key:"unhighlightTab",value:function(e){e.setAttribute("aria-selected","false"),e.parentNode.classList.remove("".concat(this.namespace,"__list-item--selected")),e.setAttribute("tabindex","-1")}},{key:"highlightTab",value:function(e){e.setAttribute("aria-selected","true"),e.parentNode.classList.add("".concat(this.namespace,"__list-item--selected")),e.setAttribute("tabindex","0")}},{key:"getCurrentTab",value:function(){return this.$module.querySelector(".".concat(this.namespace,"__list-item--selected .").concat(this.namespace,"__tab"))}}]),t(i,p),Object.defineProperty(i,"prototype",{writable:!1});var i,p,y=g;function g(e,t,n,i){if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");this.$module=e,this.namespace=t,this.responsive=n,this.historyEnabled=i,this.$tabs=e.querySelectorAll(".".concat(this.namespace,"__tab")),this.keys={down:40,left:37,right:39,up:38},this.jsHiddenClass="".concat(this.namespace,"__panel--hidden"),this.showEvent=new CustomEvent("tab.show"),this.hideEvent=new CustomEvent("tab.hide")}k(405),document.addEventListener("DOMContentLoaded",function(){var t,e,n,i;function o(){e.forEach(function(e){return h(e,"nhsuk-radios__conditional--hidden")})}function a(e){var t,n;h(e.target,"nhsuk-checkboxes__conditional--hidden"),e.target.checked&&(e.target.hasAttribute("data-checkbox-exclusive")?((t=e.target).form.querySelectorAll('input[type="checkbox"][data-checkbox-exclusive-group="'.concat(t.getAttribute("data-checkbox-exclusive-group"),'"]')).forEach(function(e){t.form===e.form&&e!==t&&(e.checked=!1)}),d(t)):((n=e.target).form.querySelectorAll('input[type="checkbox"][data-checkbox-exclusive][data-checkbox-exclusive-group="'.concat(n.getAttribute("data-checkbox-exclusive-group"),'"]')).forEach(function(e){n.form===e.form&&(e.checked=!1)}),d(n)))}document.querySelectorAll('[data-module="nhsuk-character-count"]').forEach(function(e){new l(e).init()}),document.querySelectorAll('[data-module="nhsuk-button"]').forEach(function(e){new u(e).init()}),i=document.querySelectorAll(".nhsuk-checkboxes .nhsuk-checkboxes__input"),"onpageshow"in window?window.addEventListener("pageshow",function(){return i.forEach(d)}):window.addEventListener("DOMContentLoaded",function(){return i.forEach(d)}),i.forEach(d),i.forEach(function(e){e.addEventListener("change",a)}),"boolean"!=typeof document.createElement("details").open&&(n=document.querySelectorAll("details")).length&&n.forEach(function(e,t){var n,i,o;e.hasAttribute("nhsuk-polyfilled")||(t=t,(n=e).setAttribute("nhsuk-polyfilled","true"),n.id||n.setAttribute("id","nhsuk-details".concat(t)),(i=document.querySelector("#".concat(n.id," .nhsuk-details__text"))).id||i.setAttribute("id","nhsuk-details__text".concat(t)),(o=document.querySelector("#".concat(n.id," .nhsuk-details__summary"))).setAttribute("role","button"),o.setAttribute("aria-controls",i.id),o.setAttribute("tabIndex","0"),1==(null!==n.getAttribute("open"))?(o.setAttribute("aria-expanded","true"),i.setAttribute("aria-hidden","false")):(o.setAttribute("aria-expanded","false"),i.setAttribute("aria-hidden","true"),i.style.display="none"),o.addEventListener("click",function(){c(o,"aria-expanded"),c(i,"aria-hidden"),i.style.display="true"===i.getAttribute("aria-hidden")?"none":"",n.hasAttribute("open")?n.removeAttribute("open"):n.setAttribute("open","open")}),o.addEventListener("keydown",function(e){13!==e.keyCode&&32!==e.keyCode||(e.preventDefault(),o.click())}))}),function(e){var e=(0<arguments.length&&void 0!==e?e:{}).focusOnPageLoad,e=void 0===e||e,t=document.querySelector(".nhsuk-error-summary");t&&(e&&t.focus(),t.addEventListener("click",b))}(),(new f).init(),e=document.querySelectorAll(".nhsuk-radios--conditional .nhsuk-radios__input"),"onpageshow"in window?window.addEventListener("pageshow",o):window.addEventListener("DOMContentLoaded",o),o(),e.forEach(function(e){e.addEventListener("change",o)}),t=document.querySelector("h1"),n=document.querySelector(".nhsuk-skip-link"),t&&n&&(n.addEventListener("click",function(e){e.preventDefault(),t.setAttribute("tabIndex","-1"),t.focus()}),t.addEventListener("blur",function(e){e.preventDefault(),t.removeAttribute("tabIndex")})),function(e){var e=0<arguments.length&&void 0!==e?e:{},t=e.namespace,n=void 0===t?"nhsuk-tabs":t,t=e.responsive,i=void 0===t||t,t=e.historyEnabled,o=void 0===t||t;document.querySelectorAll('[data-module="'.concat(n,'"]')).forEach(function(e){new y(e,n,i,o).init()})}()})})()})();
package/dist/nhsuk.js CHANGED
@@ -1 +1 @@
1
- (()=>{var e={405:()=>{NodeList.prototype.forEach||(NodeList.prototype.forEach=Array.prototype.forEach),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{enumerable:!1,value:function(e){return this.filter((function(t){return t===e})).length>0}}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;do{if(Element.prototype.matches.call(t,e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null}),"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:null};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n})}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var a=t[i]={exports:{}};return e[i](a,a.exports,n),a.exports}(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,o(i.key),i)}}function i(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(t){var n=function(t,n){if("object"!==e(t)||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,"string");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===e(n)?n:String(n)}var a=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i(this,"KEY_SPACE",32),i(this,"DEBOUNCE_TIMEOUT_IN_SECONDS",1),this.$module=t,this.debounceFormSubmitTimer=null}var n,o;return n=e,(o=[{key:"handleKeyDown",value:function(e){var t=e.target;"button"===t.getAttribute("role")&&e.keyCode===this.KEY_SPACE&&(e.preventDefault(),t.click())}},{key:"debounce",value:function(e){var t=this;if("true"===e.target.getAttribute("data-prevent-double-click"))return this.debounceFormSubmitTimer?(e.preventDefault(),!1):void(this.debounceFormSubmitTimer=setTimeout((function(){t.debounceFormSubmitTimer=null}),1e3*this.DEBOUNCE_TIMEOUT_IN_SECONDS))}},{key:"init",value:function(){this.$module.addEventListener("keydown",this.handleKeyDown.bind(this)),this.$module.addEventListener("click",this.debounce.bind(this))}}])&&t(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),e}();function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function s(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(void 0,o=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(i.key),"symbol"===r(o)?o:String(o)),i)}var o}var u=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.$module=t,this.$textarea=t.querySelector(".nhsuk-js-character-count"),this.$visibleCountMessage=null,this.$screenReaderCountMessage=null,this.lastInputTimestamp=null}var t,n,i;return t=e,i=[{key:"getDataset",value:function(e){var t={},n=e.attributes;if(n)for(var i=0;i<n.length;i++){var o=n[i],a=o.name.match(/^data-(.+)/);a&&(t[a[1]]=o.value)}return t}}],(n=[{key:"init",value:function(){if(this.$textarea){var t=this.$module,n=this.$textarea,i=document.getElementById("".concat(n.id,"-info"));n.insertAdjacentElement("afterend",i);var o=document.createElement("div");o.className="nhsuk-character-count__sr-status nhsuk-u-visually-hidden",o.setAttribute("aria-live","polite"),this.$screenReaderCountMessage=o,i.insertAdjacentElement("afterend",o);var a=document.createElement("div");a.className=i.className,a.classList.add("nhsuk-character-count__status"),a.setAttribute("aria-hidden","true"),this.$visibleCountMessage=a,i.insertAdjacentElement("afterend",a),i.classList.add("nhsuk-u-visually-hidden"),this.options=e.getDataset(t);var r=this.defaults.characterCountAttribute;this.options.maxwords&&(r=this.defaults.wordCountAttribute),this.maxLength=t.getAttribute(r),this.maxLength&&(n.removeAttribute("maxlength"),this.bindChangeEvents(),"onpageshow"in window?window.addEventListener("pageshow",this.updateCountMessage.bind(this)):window.addEventListener("DOMContentLoaded",this.updateCountMessage.bind(this)),this.updateCountMessage())}}},{key:"count",value:function(e){return this.options.maxwords?(e.match(/\S+/g)||[]).length:e.length}},{key:"bindChangeEvents",value:function(){var e=this.$textarea;e.addEventListener("keyup",this.handleKeyUp.bind(this)),e.addEventListener("focus",this.handleFocus.bind(this)),e.addEventListener("blur",this.handleBlur.bind(this))}},{key:"checkIfValueChanged",value:function(){this.$textarea.oldValue||(this.$textarea.oldValue=""),this.$textarea.value!==this.$textarea.oldValue&&(this.$textarea.oldValue=this.$textarea.value,this.updateCountMessage())}},{key:"updateCountMessage",value:function(){this.updateVisibleCountMessage(),this.updateScreenReaderCountMessage()}},{key:"updateVisibleCountMessage",value:function(){var e=this.$textarea,t=this.$visibleCountMessage,n=this.maxLength-this.count(e.value);this.isOverThreshold()?t.classList.remove("nhsuk-character-count__message--disabled"):t.classList.add("nhsuk-character-count__message--disabled"),n<0?(e.classList.add("nhsuk-textarea--error"),t.classList.remove("nhsuk-hint"),t.classList.add("nhsuk-error-message")):(e.classList.remove("nhsuk-textarea--error"),t.classList.remove("nhsuk-error-message"),t.classList.add("nhsuk-hint")),t.innerHTML=this.formattedUpdateMessage()}},{key:"updateScreenReaderCountMessage",value:function(){var e=this.$screenReaderCountMessage;this.isOverThreshold()?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",!0),e.innerHTML=this.formattedUpdateMessage()}},{key:"formattedUpdateMessage",value:function(){var e,t,n=this.$textarea,i=this.options,o=this.maxLength-this.count(n.value),a="character";return i.maxwords&&(a="word"),a+=-1===o||1===o?"":"s",e=o<0?"too many":"remaining",t=Math.abs(o),"You have ".concat(t," ").concat(a," ").concat(e)}},{key:"isOverThreshold",value:function(){var e=this.$textarea,t=this.options,n=this.count(e.value);return this.maxLength*(t.threshold?t.threshold:0)/100<=n}},{key:"handleKeyUp",value:function(){this.updateVisibleCountMessage(),this.lastInputTimestamp=Date.now()}},{key:"handleFocus",value:function(){var e=this;this.valueChecker=setInterval((function(){(!e.lastInputTimestamp||Date.now()-500>=e.lastInputTimestamp)&&e.checkIfValueChanged()}),1e3)}},{key:"handleBlur",value:function(){clearInterval(this.valueChecker)}}])&&s(t.prototype,n),i&&s(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();u.prototype.defaults={characterCountAttribute:"data-maxlength",wordCountAttribute:"data-maxwords"};var l=function(e,t){if(e&&t){var n="true"===e.getAttribute(t)?"false":"true";e.setAttribute(t,n)}},c=function(e,t){if(e&&t){var n=e.getAttribute("aria-controls");if(n){var i=document.getElementById(n);i&&(e.checked?(i.classList.remove(t),e.setAttribute("aria-expanded",!0)):(i.classList.add(t),e.setAttribute("aria-expanded",!1)))}}},h=function(e){e.form.querySelectorAll('input[type="checkbox"]').forEach((function(e){return c(e,"nhsuk-checkboxes__conditional--hidden")}))};function d(e){(function(e){if("A"!==e.tagName||!1===e.href)return!1;var t=document.querySelector(e.hash);if(!t)return!1;var n=function(e){var t=e.closest("fieldset");if(t){var n=t.getElementsByTagName("legend");if(n.length){var i=n[0];if("checkbox"===e.type||"radio"===e.type)return i;var o=i.getBoundingClientRect().top,a=e.getBoundingClientRect();if(a.height&&window.innerHeight&&a.top+a.height-o<window.innerHeight/2)return i}}return document.querySelector("label[for='".concat(e.getAttribute("id"),"']"))||e.closest("label")}(t);return!!n&&(n.scrollIntoView(),t.focus({preventScroll:!0}),!0)})(e.target)&&e.preventDefault()}function b(e){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},b(e)}function f(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(void 0,o=function(e,t){if("object"!==b(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!==b(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(i.key),"symbol"===b(o)?o:String(o)),i)}var o}var v=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.menuIsOpen=!1,this.navigation=document.querySelector(".nhsuk-navigation"),this.navigationList=document.querySelector(".nhsuk-header__navigation-list"),this.mobileMenu=document.createElement("ul"),this.mobileMenuToggleButton=document.querySelector(".nhsuk-header__menu-toggle"),this.mobileMenuCloseButton=document.createElement("button"),this.mobileMenuContainer=document.querySelector(".nhsuk-mobile-menu-container"),this.breakpoints=[],this.width=document.body.offsetWidth}var t,n;return t=e,n=[{key:"init",value:function(){var e=this;this.navigation&&this.navigationList&&this.mobileMenuToggleButton&&this.mobileMenuContainer&&(this.setupMobileMenu(),this.calculateBreakpoints(),this.updateNavigation(),this.doOnOrientationChange(),this.handleResize=this.debounce((function(){e.calculateBreakpoints(),e.updateNavigation()})),this.mobileMenuToggleButton.addEventListener("click",this.toggleMobileMenu.bind(this)),window.addEventListener("resize",this.handleResize),window.addEventListener("orientationchange",this.doOnOrientationChange()))}},{key:"debounce",value:function(e){var t,n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return function(){for(var o=arguments.length,a=new Array(o),r=0;r<o;r++)a[r]=arguments[r];clearTimeout(t),t=setTimeout((function(){e.apply(n,a)}),i)}}},{key:"calculateBreakpoints",value:function(){for(var e=0,t=0;t<this.navigationList.children.length;t++)e+=this.navigationList.children[t].offsetWidth,this.breakpoints[t]=e}},{key:"setupMobileMenu",value:function(){this.mobileMenuContainer.appendChild(this.mobileMenu),this.mobileMenu.classList.add("nhsuk-header__drop-down","nhsuk-header__drop-down--hidden")}},{key:"closeMobileMenu",value:function(){this.menuIsOpen=!1,this.mobileMenu.classList.add("nhsuk-header__drop-down--hidden"),this.navigation.style.marginBottom=0,this.mobileMenuToggleButton.setAttribute("aria-expanded","false"),this.mobileMenuToggleButton.focus(),this.mobileMenuCloseButton.removeEventListener("click",this.closeMobileMenu.bind(this)),document.removeEventListener("keydown",this.handleEscapeKey.bind(this))}},{key:"handleEscapeKey",value:function(e){"Escape"===e.key&&this.closeMobileMenu()}},{key:"openMobileMenu",value:function(){var e=this.mobileMenu.offsetHeight;this.menuIsOpen=!0,this.mobileMenu.classList.remove("nhsuk-header__drop-down--hidden"),this.navigation.style.marginBottom="".concat(e,"px"),this.mobileMenuToggleButton.setAttribute("aria-expanded","true"),document.addEventListener("keydown",this.handleEscapeKey.bind(this)),this.mobileMenuCloseButton.addEventListener("click",this.closeMobileMenu.bind(this))}},{key:"toggleMobileMenu",value:function(){this.menuIsOpen?this.closeMobileMenu():this.openMobileMenu()}},{key:"updateNavigation",value:function(){var e=this.navigation.offsetWidth,t=this.navigationList.children.length;if(e<this.breakpoints[t-1]){if(this.mobileMenuToggleButton.classList.add("nhsuk-header__menu-toggle--visible"),this.mobileMenuContainer.classList.add("nhsuk-mobile-menu-container--visible"),2===t)return;for(;e<this.breakpoints[t-1];)this.mobileMenu.insertBefore(this.navigationList.children[t-2],this.mobileMenu.firstChild),t-=1}else if(e>this.breakpoints[t])for(;e>this.breakpoints[t];)this.navigationList.insertBefore(this.mobileMenu.removeChild(this.mobileMenu.firstChild),this.mobileMenuContainer),t+=1;this.mobileMenu.children.length||(this.mobileMenuToggleButton.classList.remove("nhsuk-header__menu-toggle--visible"),this.mobileMenuContainer.classList.remove("nhsuk-mobile-menu-container--visible")),document.body.offsetWidth!==this.width&&this.menuIsOpen&&this.closeMobileMenu()}},{key:"doOnOrientationChange",value:function(){var e=this;90===window.orientation&&setTimeout((function(){e.calculateBreakpoints(),e.updateNavigation()}),200)}}],n&&f(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function p(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(void 0,o=function(e,t){if("object"!==m(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!==m(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(i.key),"symbol"===m(o)?o:String(o)),i)}var o}var y=function(){function e(t,n,i,o){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.$module=t,this.namespace=n,this.responsive=i,this.historyEnabled=o,this.$tabs=t.querySelectorAll(".".concat(this.namespace,"__tab")),this.keys={down:40,left:37,right:39,up:38},this.jsHiddenClass="".concat(this.namespace,"__panel--hidden"),this.showEvent=new CustomEvent("tab.show"),this.hideEvent=new CustomEvent("tab.hide")}var t,n,i;return t=e,i=[{key:"getHref",value:function(e){var t=e.getAttribute("href");return t.slice(t.indexOf("#"),t.length)}}],(n=[{key:"init",value:function(){"function"==typeof window.matchMedia&&this.responsive?this.setupResponsiveChecks():this.setup()}},{key:"setupResponsiveChecks",value:function(){this.mql=window.matchMedia("(min-width: 641px)"),this.mql.addEventListener("change",this.checkMode.bind(this)),this.checkMode()}},{key:"checkMode",value:function(){this.mql.matches?this.setup():this.teardown()}},{key:"setup",value:function(){var e=this,t=this.$module,n=this.$tabs,i=t.querySelector(".".concat(this.namespace,"__list")),o=t.querySelectorAll(".".concat(this.namespace,"__list-item"));if(n&&i&&o){i.setAttribute("role","tablist"),o.forEach((function(e){e.setAttribute("role","presentation")})),n.forEach((function(t){e.setAttributes(t),t.boundTabClick=e.onTabClick.bind(e),t.boundTabKeydown=e.onTabKeydown.bind(e),t.addEventListener("click",t.boundTabClick,!0),t.addEventListener("keydown",t.boundTabKeydown,!0),e.hideTab(t)}));var a=this.getTab(window.location.hash)||this.$tabs[0];this.showTab(a),this.historyEnabled&&(t.boundOnHashChange=this.onHashChange.bind(this),window.addEventListener("hashchange",t.boundOnHashChange,!0))}}},{key:"teardown",value:function(){var e=this,t=this.$module,n=this.$tabs,i=t.querySelector(".".concat(this.namespace,"__list")),o=t.querySelectorAll(".".concat(this.namespace,"__list-item"));n&&i&&o&&(i.removeAttribute("role"),o.forEach((function(e){e.removeAttribute("role","presentation")})),n.forEach((function(t){t.removeEventListener("click",t.boundTabClick,!0),t.removeEventListener("keydown",t.boundTabKeydown,!0),e.unsetAttributes(t)})),this.historyEnabled&&window.removeEventListener("hashchange",t.boundOnHashChange,!0))}},{key:"onHashChange",value:function(){var e=window.location.hash,t=this.getTab(e);if(t)if(this.changingHash)this.changingHash=!1;else{var n=this.getCurrentTab();this.hideTab(n),this.showTab(t),t.focus()}}},{key:"hideTab",value:function(e){this.unhighlightTab(e),this.hidePanel(e)}},{key:"showTab",value:function(e){this.highlightTab(e),this.showPanel(e)}},{key:"getTab",value:function(e){return this.$module.querySelector(".".concat(this.namespace,'__tab[href="').concat(e,'"]'))}},{key:"setAttributes",value:function(t){var n=e.getHref(t).slice(1);t.setAttribute("id","tab_".concat(n)),t.setAttribute("role","tab"),t.setAttribute("aria-controls",n),t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1");var i=this.getPanel(t);i.setAttribute("role","tabpanel"),i.setAttribute("aria-labelledby",t.id),i.classList.add(this.jsHiddenClass)}},{key:"unsetAttributes",value:function(e){e.removeAttribute("id"),e.removeAttribute("role"),e.removeAttribute("aria-controls"),e.removeAttribute("aria-selected"),e.removeAttribute("tabindex");var t=this.getPanel(e);t.removeAttribute("role"),t.removeAttribute("aria-labelledby"),t.removeAttribute("tabindex"),t.classList.remove(this.jsHiddenClass)}},{key:"onTabClick",value:function(e){e.target.classList.contains("".concat(this.namespace,"__tab"))||(e.stopPropagation(),e.preventDefault()),e.preventDefault();var t=e.target,n=this.getCurrentTab();this.hideTab(n),this.showTab(t),this.createHistoryEntry(t)}},{key:"createHistoryEntry",value:function(t){if(this.historyEnabled){var n=this.getPanel(t),i=n.id;n.id="",this.changingHash=!0,window.location.hash=e.getHref(t).slice(1),n.id=i}}},{key:"onTabKeydown",value:function(e){switch(e.keyCode){case this.keys.left:case this.keys.up:this.activatePreviousTab(),e.preventDefault();break;case this.keys.right:case this.keys.down:this.activateNextTab(),e.preventDefault()}}},{key:"activateNextTab",value:function(){var e,t=this.getCurrentTab(),n=t.parentNode.nextElementSibling;n&&(e=n.querySelector(".".concat(this.namespace,"__tab"))),e&&(this.hideTab(t),this.showTab(e),e.focus(),this.createHistoryEntry(e))}},{key:"activatePreviousTab",value:function(){var e,t=this.getCurrentTab(),n=t.parentNode.previousElementSibling;n&&(e=n.querySelector(".".concat(this.namespace,"__tab"))),e&&(this.hideTab(t),this.showTab(e),e.focus(),this.createHistoryEntry(e))}},{key:"getPanel",value:function(t){return this.$module.querySelector(e.getHref(t))}},{key:"showPanel",value:function(e){var t=this.getPanel(e);t.classList.remove(this.jsHiddenClass),t.dispatchEvent(this.showEvent)}},{key:"hidePanel",value:function(e){var t=this.getPanel(e);t.classList.add(this.jsHiddenClass),t.dispatchEvent(this.hideEvent)}},{key:"unhighlightTab",value:function(e){e.setAttribute("aria-selected","false"),e.parentNode.classList.remove("".concat(this.namespace,"__list-item--selected")),e.setAttribute("tabindex","-1")}},{key:"highlightTab",value:function(e){e.setAttribute("aria-selected","true"),e.parentNode.classList.add("".concat(this.namespace,"__list-item--selected")),e.setAttribute("tabindex","0")}},{key:"getCurrentTab",value:function(){return this.$module.querySelector(".".concat(this.namespace,"__list-item--selected .").concat(this.namespace,"__tab"))}}])&&p(t.prototype,n),i&&p(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();n(405),document.addEventListener("DOMContentLoaded",(function(){var e,t;document.querySelectorAll('[data-module="nhsuk-character-count"]').forEach((function(e){new u(e).init()})),document.querySelectorAll('[data-module="nhsuk-button"]').forEach((function(e){new a(e).init()})),function(){var e=document.querySelectorAll(".nhsuk-checkboxes .nhsuk-checkboxes__input"),t=function(e){var t;c(e.target,"nhsuk-checkboxes__conditional--hidden"),e.target.checked&&(e.target.hasAttribute("data-checkbox-exclusive")?((t=e.target).form.querySelectorAll('input[type="checkbox"][data-checkbox-exclusive-group="'.concat(t.getAttribute("data-checkbox-exclusive-group"),'"]')).forEach((function(e){t.form===e.form&&e!==t&&(e.checked=!1)})),h(t)):function(e){e.form.querySelectorAll('input[type="checkbox"][data-checkbox-exclusive][data-checkbox-exclusive-group="'.concat(e.getAttribute("data-checkbox-exclusive-group"),'"]')).forEach((function(t){e.form===t.form&&(t.checked=!1)})),h(e)}(e.target))};"onpageshow"in window?window.addEventListener("pageshow",(function(){return e.forEach((function(e){return h(e)}))})):window.addEventListener("DOMContentLoaded",(function(){return e.forEach((function(e){return h(e)}))})),e.forEach((function(e){return h(e)})),e.forEach((function(e){e.addEventListener("change",t)}))}(),function(){if("boolean"!=typeof document.createElement("details").open){var e=document.querySelectorAll("details");e.length&&e.forEach((function(e,t){e.hasAttribute("nhsuk-polyfilled")||function(e,t){e.setAttribute("nhsuk-polyfilled","true"),e.id||e.setAttribute("id","nhsuk-details".concat(t));var n=document.querySelector("#".concat(e.id," .nhsuk-details__text"));n.id||n.setAttribute("id","nhsuk-details__text".concat(t));var i=document.querySelector("#".concat(e.id," .nhsuk-details__summary"));i.setAttribute("role","button"),i.setAttribute("aria-controls",n.id),i.setAttribute("tabIndex","0"),1==(null!==e.getAttribute("open"))?(i.setAttribute("aria-expanded","true"),n.setAttribute("aria-hidden","false")):(i.setAttribute("aria-expanded","false"),n.setAttribute("aria-hidden","true"),n.style.display="none"),i.addEventListener("click",(function(){l(i,"aria-expanded"),l(n,"aria-hidden"),n.style.display="true"===n.getAttribute("aria-hidden")?"none":"",e.hasAttribute("open")?e.removeAttribute("open"):e.setAttribute("open","open")})),i.addEventListener("keydown",(function(e){13!==e.keyCode&&32!==e.keyCode||(e.preventDefault(),i.click())}))}(e,t)}))}}(),function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).focusOnPageLoad,t=void 0===e||e,n=document.querySelector(".nhsuk-error-summary");n&&(t&&n.focus(),n.addEventListener("click",d))}(),(new v).init(),function(){var e=document.querySelectorAll(".nhsuk-radios--conditional .nhsuk-radios__input"),t=function(){e.forEach((function(e){return c(e,"nhsuk-radios__conditional--hidden")}))};"onpageshow"in window?window.addEventListener("pageshow",t):window.addEventListener("DOMContentLoaded",t),t(),e.forEach((function(e){e.addEventListener("change",t)}))}(),e=document.querySelector("h1"),t=document.querySelector(".nhsuk-skip-link"),e&&t&&(t.addEventListener("click",(function(t){t.preventDefault(),e.setAttribute("tabIndex","-1"),e.focus()})),e.addEventListener("blur",(function(t){t.preventDefault(),e.removeAttribute("tabIndex")}))),function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.namespace,n=void 0===t?"nhsuk-tabs":t,i=e.responsive,o=void 0===i||i,a=e.historyEnabled,r=void 0===a||a;document.querySelectorAll('[data-module="'.concat(n,'"]')).forEach((function(e){new y(e,n,o,r).init()}))}()}))})()})();
1
+ (()=>{var e={405:()=>{NodeList.prototype.forEach||(NodeList.prototype.forEach=Array.prototype.forEach),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{enumerable:!1,value:function(e){return this.filter((function(t){return t===e})).length>0}}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;do{if(Element.prototype.matches.call(t,e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null}),"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:null};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n})}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var a=t[i]={exports:{}};return e[i](a,a.exports,n),a.exports}(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,o(i.key),i)}}function i(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(t){var n=function(t,n){if("object"!==e(t)||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,"string");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===e(n)?n:String(n)}var a=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),i(this,"KEY_SPACE",32),i(this,"DEBOUNCE_TIMEOUT_IN_SECONDS",1),this.$module=t,this.debounceFormSubmitTimer=null}var n,o;return n=e,(o=[{key:"handleKeyDown",value:function(e){var t=e.target;"button"===t.getAttribute("role")&&e.keyCode===this.KEY_SPACE&&(e.preventDefault(),t.click())}},{key:"debounce",value:function(e){var t=this;if("true"===e.target.getAttribute("data-prevent-double-click"))return this.debounceFormSubmitTimer?(e.preventDefault(),!1):void(this.debounceFormSubmitTimer=setTimeout((function(){t.debounceFormSubmitTimer=null}),1e3*this.DEBOUNCE_TIMEOUT_IN_SECONDS))}},{key:"init",value:function(){this.$module.addEventListener("keydown",this.handleKeyDown.bind(this)),this.$module.addEventListener("click",this.debounce.bind(this))}}])&&t(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),e}();function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function s(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(void 0,o=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(i.key),"symbol"===r(o)?o:String(o)),i)}var o}var u=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.$module=t,this.$textarea=t.querySelector(".nhsuk-js-character-count"),this.$visibleCountMessage=null,this.$screenReaderCountMessage=null,this.lastInputTimestamp=null}var t,n,i;return t=e,i=[{key:"getDataset",value:function(e){var t={},n=e.attributes;if(n)for(var i=0;i<n.length;i++){var o=n[i],a=o.name.match(/^data-(.+)/);a&&(t[a[1]]=o.value)}return t}}],(n=[{key:"init",value:function(){if(this.$textarea){var t=this.$module,n=this.$textarea,i=document.getElementById("".concat(n.id,"-info"));n.insertAdjacentElement("afterend",i);var o=document.createElement("div");o.className="nhsuk-character-count__sr-status nhsuk-u-visually-hidden",o.setAttribute("aria-live","polite"),this.$screenReaderCountMessage=o,i.insertAdjacentElement("afterend",o);var a=document.createElement("div");a.className=i.className,a.classList.add("nhsuk-character-count__status"),a.setAttribute("aria-hidden","true"),this.$visibleCountMessage=a,i.insertAdjacentElement("afterend",a),i.classList.add("nhsuk-u-visually-hidden"),this.options=e.getDataset(t);var r=this.defaults.characterCountAttribute;this.options.maxwords&&(r=this.defaults.wordCountAttribute),this.maxLength=t.getAttribute(r),this.maxLength&&(n.removeAttribute("maxlength"),this.bindChangeEvents(),"onpageshow"in window?window.addEventListener("pageshow",this.updateCountMessage.bind(this)):window.addEventListener("DOMContentLoaded",this.updateCountMessage.bind(this)),this.updateCountMessage())}}},{key:"count",value:function(e){return this.options.maxwords?(e.match(/\S+/g)||[]).length:e.length}},{key:"bindChangeEvents",value:function(){var e=this.$textarea;e.addEventListener("keyup",this.handleKeyUp.bind(this)),e.addEventListener("focus",this.handleFocus.bind(this)),e.addEventListener("blur",this.handleBlur.bind(this))}},{key:"checkIfValueChanged",value:function(){this.$textarea.oldValue||(this.$textarea.oldValue=""),this.$textarea.value!==this.$textarea.oldValue&&(this.$textarea.oldValue=this.$textarea.value,this.updateCountMessage())}},{key:"updateCountMessage",value:function(){this.updateVisibleCountMessage(),this.updateScreenReaderCountMessage()}},{key:"updateVisibleCountMessage",value:function(){var e=this.$textarea,t=this.$visibleCountMessage,n=this.maxLength-this.count(e.value);this.isOverThreshold()?t.classList.remove("nhsuk-character-count__message--disabled"):t.classList.add("nhsuk-character-count__message--disabled"),n<0?(e.classList.add("nhsuk-textarea--error"),t.classList.remove("nhsuk-hint"),t.classList.add("nhsuk-error-message")):(e.classList.remove("nhsuk-textarea--error"),t.classList.remove("nhsuk-error-message"),t.classList.add("nhsuk-hint")),t.innerHTML=this.formattedUpdateMessage()}},{key:"updateScreenReaderCountMessage",value:function(){var e=this.$screenReaderCountMessage;this.isOverThreshold()?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",!0),e.innerHTML=this.formattedUpdateMessage()}},{key:"formattedUpdateMessage",value:function(){var e,t,n=this.$textarea,i=this.options,o=this.maxLength-this.count(n.value),a="character";return i.maxwords&&(a="word"),a+=-1===o||1===o?"":"s",e=o<0?"too many":"remaining",t=Math.abs(o),"You have ".concat(t," ").concat(a," ").concat(e)}},{key:"isOverThreshold",value:function(){var e=this.$textarea,t=this.options,n=this.count(e.value);return this.maxLength*(t.threshold?t.threshold:0)/100<=n}},{key:"handleKeyUp",value:function(){this.updateVisibleCountMessage(),this.lastInputTimestamp=Date.now()}},{key:"handleFocus",value:function(){var e=this;this.valueChecker=setInterval((function(){(!e.lastInputTimestamp||Date.now()-500>=e.lastInputTimestamp)&&e.checkIfValueChanged()}),1e3)}},{key:"handleBlur",value:function(){clearInterval(this.valueChecker)}}])&&s(t.prototype,n),i&&s(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();u.prototype.defaults={characterCountAttribute:"data-maxlength",wordCountAttribute:"data-maxwords"};var l=function(e,t){if(e&&t){var n="true"===e.getAttribute(t)?"false":"true";e.setAttribute(t,n)}},c=function(e,t){if(e&&t){var n=e.getAttribute("aria-controls");if(n){var i=document.getElementById(n);i&&(e.checked?(i.classList.remove(t),e.setAttribute("aria-expanded",!0)):(i.classList.add(t),e.setAttribute("aria-expanded",!1)))}}},h=function(e){e.form.querySelectorAll('input[type="checkbox"]').forEach((function(e){return c(e,"nhsuk-checkboxes__conditional--hidden")}))};function d(e){(function(e){if("A"!==e.tagName||!1===e.href)return!1;var t=document.querySelector(e.hash);if(!t)return!1;var n=function(e){var t=e.closest("fieldset");if(t){var n=t.getElementsByTagName("legend");if(n.length){var i=n[0];if("checkbox"===e.type||"radio"===e.type)return i;var o=i.getBoundingClientRect().top,a=e.getBoundingClientRect();if(a.height&&window.innerHeight&&a.top+a.height-o<window.innerHeight/2)return i}}return document.querySelector("label[for='".concat(e.getAttribute("id"),"']"))||e.closest("label")}(t);return!!n&&(n.scrollIntoView(),t.focus({preventScroll:!0}),!0)})(e.target)&&e.preventDefault()}function b(e){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},b(e)}function f(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(void 0,o=function(e,t){if("object"!==b(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!==b(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(i.key),"symbol"===b(o)?o:String(o)),i)}var o}var v=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.menuIsOpen=!1,this.navigation=document.querySelector(".nhsuk-navigation"),this.navigationList=document.querySelector(".nhsuk-header__navigation-list"),this.mobileMenu=document.createElement("ul"),this.mobileMenuToggleButton=document.querySelector(".nhsuk-header__menu-toggle"),this.mobileMenuCloseButton=document.createElement("button"),this.mobileMenuContainer=document.querySelector(".nhsuk-mobile-menu-container"),this.breakpoints=[],this.width=document.body.offsetWidth}var t,n;return t=e,n=[{key:"init",value:function(){var e=this;this.navigation&&this.navigationList&&this.mobileMenuToggleButton&&this.mobileMenuContainer&&(this.setupMobileMenu(),this.calculateBreakpoints(),this.updateNavigation(),this.doOnOrientationChange(),this.handleResize=this.debounce((function(){e.calculateBreakpoints(),e.updateNavigation()})),this.mobileMenuToggleButton.addEventListener("click",this.toggleMobileMenu.bind(this)),window.addEventListener("resize",this.handleResize),window.addEventListener("orientationchange",this.doOnOrientationChange()))}},{key:"debounce",value:function(e){var t,n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return function(){for(var o=arguments.length,a=new Array(o),r=0;r<o;r++)a[r]=arguments[r];clearTimeout(t),t=setTimeout((function(){e.apply(n,a)}),i)}}},{key:"calculateBreakpoints",value:function(){for(var e=0,t=0;t<this.navigationList.children.length;t++)e+=this.navigationList.children[t].offsetWidth,this.breakpoints[t]=e}},{key:"setupMobileMenu",value:function(){this.mobileMenuContainer.appendChild(this.mobileMenu),this.mobileMenu.classList.add("nhsuk-header__drop-down","nhsuk-header__drop-down--hidden")}},{key:"closeMobileMenu",value:function(){this.menuIsOpen=!1,this.mobileMenu.classList.add("nhsuk-header__drop-down--hidden"),this.navigation.style.marginBottom=0,this.mobileMenuToggleButton.setAttribute("aria-expanded","false"),this.mobileMenuToggleButton.focus(),this.mobileMenuCloseButton.removeEventListener("click",this.closeMobileMenu.bind(this)),document.removeEventListener("keydown",this.handleEscapeKey.bind(this))}},{key:"handleEscapeKey",value:function(e){"Escape"===e.key&&this.closeMobileMenu()}},{key:"openMobileMenu",value:function(){this.menuIsOpen=!0,this.mobileMenu.classList.remove("nhsuk-header__drop-down--hidden");var e=this.mobileMenu.offsetHeight;this.navigation.style.marginBottom="".concat(e,"px"),this.mobileMenuToggleButton.setAttribute("aria-expanded","true"),document.addEventListener("keydown",this.handleEscapeKey.bind(this)),this.mobileMenuCloseButton.addEventListener("click",this.closeMobileMenu.bind(this))}},{key:"toggleMobileMenu",value:function(){this.menuIsOpen?this.closeMobileMenu():this.openMobileMenu()}},{key:"updateNavigation",value:function(){var e=this.navigation.offsetWidth,t=this.navigationList.children.length;if(e<this.breakpoints[t-1]){if(this.mobileMenuToggleButton.classList.add("nhsuk-header__menu-toggle--visible"),this.mobileMenuContainer.classList.add("nhsuk-mobile-menu-container--visible"),2===t)return;for(;e<this.breakpoints[t-1];)this.mobileMenu.insertBefore(this.navigationList.children[t-2],this.mobileMenu.firstChild),t-=1}else if(e>this.breakpoints[t])for(;e>this.breakpoints[t];)this.navigationList.insertBefore(this.mobileMenu.removeChild(this.mobileMenu.firstChild),this.mobileMenuContainer),t+=1;this.mobileMenu.children.length||(this.mobileMenuToggleButton.classList.remove("nhsuk-header__menu-toggle--visible"),this.mobileMenuContainer.classList.remove("nhsuk-mobile-menu-container--visible")),document.body.offsetWidth!==this.width&&this.menuIsOpen&&this.closeMobileMenu()}},{key:"doOnOrientationChange",value:function(){var e=this;90===window.orientation&&setTimeout((function(){e.calculateBreakpoints(),e.updateNavigation()}),200)}}],n&&f(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}();function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function p(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(void 0,o=function(e,t){if("object"!==m(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!==m(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(i.key),"symbol"===m(o)?o:String(o)),i)}var o}var y=function(){function e(t,n,i,o){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.$module=t,this.namespace=n,this.responsive=i,this.historyEnabled=o,this.$tabs=t.querySelectorAll(".".concat(this.namespace,"__tab")),this.keys={down:40,left:37,right:39,up:38},this.jsHiddenClass="".concat(this.namespace,"__panel--hidden"),this.showEvent=new CustomEvent("tab.show"),this.hideEvent=new CustomEvent("tab.hide")}var t,n,i;return t=e,i=[{key:"getHref",value:function(e){var t=e.getAttribute("href");return t.slice(t.indexOf("#"),t.length)}}],(n=[{key:"init",value:function(){"function"==typeof window.matchMedia&&this.responsive?this.setupResponsiveChecks():this.setup()}},{key:"setupResponsiveChecks",value:function(){this.mql=window.matchMedia("(min-width: 641px)"),this.mql.addEventListener("change",this.checkMode.bind(this)),this.checkMode()}},{key:"checkMode",value:function(){this.mql.matches?this.setup():this.teardown()}},{key:"setup",value:function(){var e=this,t=this.$module,n=this.$tabs,i=t.querySelector(".".concat(this.namespace,"__list")),o=t.querySelectorAll(".".concat(this.namespace,"__list-item"));if(n&&i&&o){i.setAttribute("role","tablist"),o.forEach((function(e){e.setAttribute("role","presentation")})),n.forEach((function(t){e.setAttributes(t),t.boundTabClick=e.onTabClick.bind(e),t.boundTabKeydown=e.onTabKeydown.bind(e),t.addEventListener("click",t.boundTabClick,!0),t.addEventListener("keydown",t.boundTabKeydown,!0),e.hideTab(t)}));var a=this.getTab(window.location.hash)||this.$tabs[0];this.showTab(a),this.historyEnabled&&(t.boundOnHashChange=this.onHashChange.bind(this),window.addEventListener("hashchange",t.boundOnHashChange,!0))}}},{key:"teardown",value:function(){var e=this,t=this.$module,n=this.$tabs,i=t.querySelector(".".concat(this.namespace,"__list")),o=t.querySelectorAll(".".concat(this.namespace,"__list-item"));n&&i&&o&&(i.removeAttribute("role"),o.forEach((function(e){e.removeAttribute("role","presentation")})),n.forEach((function(t){t.removeEventListener("click",t.boundTabClick,!0),t.removeEventListener("keydown",t.boundTabKeydown,!0),e.unsetAttributes(t)})),this.historyEnabled&&window.removeEventListener("hashchange",t.boundOnHashChange,!0))}},{key:"onHashChange",value:function(){var e=window.location.hash,t=this.getTab(e);if(t)if(this.changingHash)this.changingHash=!1;else{var n=this.getCurrentTab();this.hideTab(n),this.showTab(t),t.focus()}}},{key:"hideTab",value:function(e){this.unhighlightTab(e),this.hidePanel(e)}},{key:"showTab",value:function(e){this.highlightTab(e),this.showPanel(e)}},{key:"getTab",value:function(e){return this.$module.querySelector(".".concat(this.namespace,'__tab[href="').concat(e,'"]'))}},{key:"setAttributes",value:function(t){var n=e.getHref(t).slice(1);t.setAttribute("id","tab_".concat(n)),t.setAttribute("role","tab"),t.setAttribute("aria-controls",n),t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1");var i=this.getPanel(t);i.setAttribute("role","tabpanel"),i.setAttribute("aria-labelledby",t.id),i.classList.add(this.jsHiddenClass)}},{key:"unsetAttributes",value:function(e){e.removeAttribute("id"),e.removeAttribute("role"),e.removeAttribute("aria-controls"),e.removeAttribute("aria-selected"),e.removeAttribute("tabindex");var t=this.getPanel(e);t.removeAttribute("role"),t.removeAttribute("aria-labelledby"),t.removeAttribute("tabindex"),t.classList.remove(this.jsHiddenClass)}},{key:"onTabClick",value:function(e){e.target.classList.contains("".concat(this.namespace,"__tab"))||(e.stopPropagation(),e.preventDefault()),e.preventDefault();var t=e.target,n=this.getCurrentTab();this.hideTab(n),this.showTab(t),this.createHistoryEntry(t)}},{key:"createHistoryEntry",value:function(t){if(this.historyEnabled){var n=this.getPanel(t),i=n.id;n.id="",this.changingHash=!0,window.location.hash=e.getHref(t).slice(1),n.id=i}}},{key:"onTabKeydown",value:function(e){switch(e.keyCode){case this.keys.left:case this.keys.up:this.activatePreviousTab(),e.preventDefault();break;case this.keys.right:case this.keys.down:this.activateNextTab(),e.preventDefault()}}},{key:"activateNextTab",value:function(){var e,t=this.getCurrentTab(),n=t.parentNode.nextElementSibling;n&&(e=n.querySelector(".".concat(this.namespace,"__tab"))),e&&(this.hideTab(t),this.showTab(e),e.focus(),this.createHistoryEntry(e))}},{key:"activatePreviousTab",value:function(){var e,t=this.getCurrentTab(),n=t.parentNode.previousElementSibling;n&&(e=n.querySelector(".".concat(this.namespace,"__tab"))),e&&(this.hideTab(t),this.showTab(e),e.focus(),this.createHistoryEntry(e))}},{key:"getPanel",value:function(t){return this.$module.querySelector(e.getHref(t))}},{key:"showPanel",value:function(e){var t=this.getPanel(e);t.classList.remove(this.jsHiddenClass),t.dispatchEvent(this.showEvent)}},{key:"hidePanel",value:function(e){var t=this.getPanel(e);t.classList.add(this.jsHiddenClass),t.dispatchEvent(this.hideEvent)}},{key:"unhighlightTab",value:function(e){e.setAttribute("aria-selected","false"),e.parentNode.classList.remove("".concat(this.namespace,"__list-item--selected")),e.setAttribute("tabindex","-1")}},{key:"highlightTab",value:function(e){e.setAttribute("aria-selected","true"),e.parentNode.classList.add("".concat(this.namespace,"__list-item--selected")),e.setAttribute("tabindex","0")}},{key:"getCurrentTab",value:function(){return this.$module.querySelector(".".concat(this.namespace,"__list-item--selected .").concat(this.namespace,"__tab"))}}])&&p(t.prototype,n),i&&p(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();n(405),document.addEventListener("DOMContentLoaded",(function(){var e,t;document.querySelectorAll('[data-module="nhsuk-character-count"]').forEach((function(e){new u(e).init()})),document.querySelectorAll('[data-module="nhsuk-button"]').forEach((function(e){new a(e).init()})),function(){var e=document.querySelectorAll(".nhsuk-checkboxes .nhsuk-checkboxes__input"),t=function(e){var t;c(e.target,"nhsuk-checkboxes__conditional--hidden"),e.target.checked&&(e.target.hasAttribute("data-checkbox-exclusive")?((t=e.target).form.querySelectorAll('input[type="checkbox"][data-checkbox-exclusive-group="'.concat(t.getAttribute("data-checkbox-exclusive-group"),'"]')).forEach((function(e){t.form===e.form&&e!==t&&(e.checked=!1)})),h(t)):function(e){e.form.querySelectorAll('input[type="checkbox"][data-checkbox-exclusive][data-checkbox-exclusive-group="'.concat(e.getAttribute("data-checkbox-exclusive-group"),'"]')).forEach((function(t){e.form===t.form&&(t.checked=!1)})),h(e)}(e.target))};"onpageshow"in window?window.addEventListener("pageshow",(function(){return e.forEach((function(e){return h(e)}))})):window.addEventListener("DOMContentLoaded",(function(){return e.forEach((function(e){return h(e)}))})),e.forEach((function(e){return h(e)})),e.forEach((function(e){e.addEventListener("change",t)}))}(),function(){if("boolean"!=typeof document.createElement("details").open){var e=document.querySelectorAll("details");e.length&&e.forEach((function(e,t){e.hasAttribute("nhsuk-polyfilled")||function(e,t){e.setAttribute("nhsuk-polyfilled","true"),e.id||e.setAttribute("id","nhsuk-details".concat(t));var n=document.querySelector("#".concat(e.id," .nhsuk-details__text"));n.id||n.setAttribute("id","nhsuk-details__text".concat(t));var i=document.querySelector("#".concat(e.id," .nhsuk-details__summary"));i.setAttribute("role","button"),i.setAttribute("aria-controls",n.id),i.setAttribute("tabIndex","0"),1==(null!==e.getAttribute("open"))?(i.setAttribute("aria-expanded","true"),n.setAttribute("aria-hidden","false")):(i.setAttribute("aria-expanded","false"),n.setAttribute("aria-hidden","true"),n.style.display="none"),i.addEventListener("click",(function(){l(i,"aria-expanded"),l(n,"aria-hidden"),n.style.display="true"===n.getAttribute("aria-hidden")?"none":"",e.hasAttribute("open")?e.removeAttribute("open"):e.setAttribute("open","open")})),i.addEventListener("keydown",(function(e){13!==e.keyCode&&32!==e.keyCode||(e.preventDefault(),i.click())}))}(e,t)}))}}(),function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).focusOnPageLoad,t=void 0===e||e,n=document.querySelector(".nhsuk-error-summary");n&&(t&&n.focus(),n.addEventListener("click",d))}(),(new v).init(),function(){var e=document.querySelectorAll(".nhsuk-radios--conditional .nhsuk-radios__input"),t=function(){e.forEach((function(e){return c(e,"nhsuk-radios__conditional--hidden")}))};"onpageshow"in window?window.addEventListener("pageshow",t):window.addEventListener("DOMContentLoaded",t),t(),e.forEach((function(e){e.addEventListener("change",t)}))}(),e=document.querySelector("h1"),t=document.querySelector(".nhsuk-skip-link"),e&&t&&(t.addEventListener("click",(function(t){t.preventDefault(),e.setAttribute("tabIndex","-1"),e.focus()})),e.addEventListener("blur",(function(t){t.preventDefault(),e.removeAttribute("tabIndex")}))),function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.namespace,n=void 0===t?"nhsuk-tabs":t,i=e.responsive,o=void 0===i||i,a=e.historyEnabled,r=void 0===a||a;document.querySelectorAll('[data-module="'.concat(n,'"]')).forEach((function(e){new y(e,n,o,r).init()}))}()}))})()})();
package/dist/nhsuk.min.js CHANGED
@@ -1 +1 @@
1
- (()=>{var n={405:()=>{NodeList.prototype.forEach||(NodeList.prototype.forEach=Array.prototype.forEach),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{enumerable:!1,value:function(t){return 0<this.filter(function(e){return e===t}).length}}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;do{if(Element.prototype.matches.call(t,e))return t}while(null!==(t=t.parentElement||t.parentNode)&&1===t.nodeType);return null}),"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:null};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n})}},i={};function k(e){var t=i[e];return void 0!==t||(t=i[e]={exports:{}},n[e](t,t.exports,k)),t.exports}(()=>{"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t,n){(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}function r(e){e=function(e){if("object"!==n(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==n(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(e);return"symbol"===n(e)?e:String(e)}var u=function(){function t(e){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function");s(this,"KEY_SPACE",32),s(this,"DEBOUNCE_TIMEOUT_IN_SECONDS",1),this.$module=e,this.debounceFormSubmitTimer=null}for(var e=t,n=e.prototype,i=[{key:"handleKeyDown",value:function(e){var t=e.target;"button"===t.getAttribute("role")&&e.keyCode===this.KEY_SPACE&&(e.preventDefault(),t.click())}},{key:"debounce",value:function(e){var t=this;if("true"===e.target.getAttribute("data-prevent-double-click"))return this.debounceFormSubmitTimer?(e.preventDefault(),!1):void(this.debounceFormSubmitTimer=setTimeout(function(){t.debounceFormSubmitTimer=null},1e3*this.DEBOUNCE_TIMEOUT_IN_SECONDS))}},{key:"init",value:function(){this.$module.addEventListener("keydown",this.handleKeyDown.bind(this)),this.$module.addEventListener("click",this.debounce.bind(this))}}],o=0;o<i.length;o++){var a=i[o];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(n,r(a.key),a)}return Object.defineProperty(e,"prototype",{writable:!1}),t}();function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function e(e,t){for(var n,i=0;i<t.length;i++){var o=t[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(n=function(e){if("object"!==a(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==a(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(o.key),"symbol"===a(n)?n:String(n)),o)}}p=[{key:"getDataset",value:function(e){var t={},n=e.attributes;if(n)for(var i=0;i<n.length;i++){var o=n[i],a=o.name.match(/^data-(.+)/);a&&(t[a[1]]=o.value)}return t}}],e((i=o).prototype,[{key:"init",value:function(){var e,t,n,i;this.$textarea&&(e=this.$module,t=this.$textarea,n=document.getElementById("".concat(t.id,"-info")),t.insertAdjacentElement("afterend",n),(i=document.createElement("div")).className="nhsuk-character-count__sr-status nhsuk-u-visually-hidden",i.setAttribute("aria-live","polite"),this.$screenReaderCountMessage=i,n.insertAdjacentElement("afterend",i),(i=document.createElement("div")).className=n.className,i.classList.add("nhsuk-character-count__status"),i.setAttribute("aria-hidden","true"),this.$visibleCountMessage=i,n.insertAdjacentElement("afterend",i),n.classList.add("nhsuk-u-visually-hidden"),this.options=o.getDataset(e),i=this.defaults.characterCountAttribute,this.options.maxwords&&(i=this.defaults.wordCountAttribute),this.maxLength=e.getAttribute(i),this.maxLength)&&(t.removeAttribute("maxlength"),this.bindChangeEvents(),"onpageshow"in window?window.addEventListener("pageshow",this.updateCountMessage.bind(this)):window.addEventListener("DOMContentLoaded",this.updateCountMessage.bind(this)),this.updateCountMessage())}},{key:"count",value:function(e){return(this.options.maxwords?e.match(/\S+/g)||[]:e).length}},{key:"bindChangeEvents",value:function(){var e=this.$textarea;e.addEventListener("keyup",this.handleKeyUp.bind(this)),e.addEventListener("focus",this.handleFocus.bind(this)),e.addEventListener("blur",this.handleBlur.bind(this))}},{key:"checkIfValueChanged",value:function(){this.$textarea.oldValue||(this.$textarea.oldValue=""),this.$textarea.value!==this.$textarea.oldValue&&(this.$textarea.oldValue=this.$textarea.value,this.updateCountMessage())}},{key:"updateCountMessage",value:function(){this.updateVisibleCountMessage(),this.updateScreenReaderCountMessage()}},{key:"updateVisibleCountMessage",value:function(){var e=this.$textarea,t=this.$visibleCountMessage,n=this.maxLength-this.count(e.value);this.isOverThreshold()?t.classList.remove("nhsuk-character-count__message--disabled"):t.classList.add("nhsuk-character-count__message--disabled"),n<0?(e.classList.add("nhsuk-textarea--error"),t.classList.remove("nhsuk-hint"),t.classList.add("nhsuk-error-message")):(e.classList.remove("nhsuk-textarea--error"),t.classList.remove("nhsuk-error-message"),t.classList.add("nhsuk-hint")),t.innerHTML=this.formattedUpdateMessage()}},{key:"updateScreenReaderCountMessage",value:function(){var e=this.$screenReaderCountMessage;this.isOverThreshold()?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",!0),e.innerHTML=this.formattedUpdateMessage()}},{key:"formattedUpdateMessage",value:function(){var e=this.$textarea,t=this.options,e=this.maxLength-this.count(e.value),n="character";return t.maxwords&&(n="word"),n+=-1==e||1==e?"":"s",t=e<0?"too many":"remaining",e=Math.abs(e),"You have ".concat(e," ").concat(n," ").concat(t)}},{key:"isOverThreshold",value:function(){var e=this.$textarea,t=this.options,e=this.count(e.value);return this.maxLength*(t.threshold||0)/100<=e}},{key:"handleKeyUp",value:function(){this.updateVisibleCountMessage(),this.lastInputTimestamp=Date.now()}},{key:"handleFocus",value:function(){var e=this;this.valueChecker=setInterval(function(){(!e.lastInputTimestamp||Date.now()-500>=e.lastInputTimestamp)&&e.checkIfValueChanged()},1e3)}},{key:"handleBlur",value:function(){clearInterval(this.valueChecker)}}]),e(i,p),Object.defineProperty(i,"prototype",{writable:!1});var l=o;function o(e){if(!(this instanceof o))throw new TypeError("Cannot call a class as a function");this.$module=e,this.$textarea=e.querySelector(".nhsuk-js-character-count"),this.$visibleCountMessage=null,this.$screenReaderCountMessage=null,this.lastInputTimestamp=null}l.prototype.defaults={characterCountAttribute:"data-maxlength",wordCountAttribute:"data-maxwords"};function c(e,t){var n;e&&t&&(n="true"===e.getAttribute(t)?"false":"true",e.setAttribute(t,n))}function h(e,t){var n;e&&t&&(n=e.getAttribute("aria-controls"))&&(n=document.getElementById(n))&&(e.checked?(n.classList.remove(t),e.setAttribute("aria-expanded",!0)):(n.classList.add(t),e.setAttribute("aria-expanded",!1)))}function d(e){e.form.querySelectorAll('input[type="checkbox"]').forEach(function(e){return h(e,"nhsuk-checkboxes__conditional--hidden")})}function b(e){!function(e){if("A"===e.tagName&&!1!==e.href){var t,e=document.querySelector(e.hash);if(e)return(t=function(e){var t=e.closest("fieldset");if(t){t=t.getElementsByTagName("legend");if(t.length){t=t[0];if("checkbox"===e.type||"radio"===e.type)return t;var n=t.getBoundingClientRect().top,i=e.getBoundingClientRect();if(i.height&&window.innerHeight&&i.top+i.height-n<window.innerHeight/2)return t}}return document.querySelector("label[for='".concat(e.getAttribute("id"),"']"))||e.closest("label")}(e))&&(t.scrollIntoView(),e.focus({preventScroll:!0}),1)}}(e.target)||e.preventDefault()}function m(e){return(m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var f=function(){function e(){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.menuIsOpen=!1,this.navigation=document.querySelector(".nhsuk-navigation"),this.navigationList=document.querySelector(".nhsuk-header__navigation-list"),this.mobileMenu=document.createElement("ul"),this.mobileMenuToggleButton=document.querySelector(".nhsuk-header__menu-toggle"),this.mobileMenuCloseButton=document.createElement("button"),this.mobileMenuContainer=document.querySelector(".nhsuk-mobile-menu-container"),this.breakpoints=[],this.width=document.body.offsetWidth}for(var t,n=e,i=[{key:"init",value:function(){var e=this;this.navigation&&this.navigationList&&this.mobileMenuToggleButton&&this.mobileMenuContainer&&(this.setupMobileMenu(),this.calculateBreakpoints(),this.updateNavigation(),this.doOnOrientationChange(),this.handleResize=this.debounce(function(){e.calculateBreakpoints(),e.updateNavigation()}),this.mobileMenuToggleButton.addEventListener("click",this.toggleMobileMenu.bind(this)),window.addEventListener("resize",this.handleResize),window.addEventListener("orientationchange",this.doOnOrientationChange()))}},{key:"debounce",value:function(i){var o,a=this,s=1<arguments.length&&void 0!==arguments[1]?arguments[1]:100;return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];clearTimeout(o),o=setTimeout(function(){i.apply(a,t)},s)}}},{key:"calculateBreakpoints",value:function(){for(var e=0,t=0;t<this.navigationList.children.length;t++)e+=this.navigationList.children[t].offsetWidth,this.breakpoints[t]=e}},{key:"setupMobileMenu",value:function(){this.mobileMenuContainer.appendChild(this.mobileMenu),this.mobileMenu.classList.add("nhsuk-header__drop-down","nhsuk-header__drop-down--hidden")}},{key:"closeMobileMenu",value:function(){this.menuIsOpen=!1,this.mobileMenu.classList.add("nhsuk-header__drop-down--hidden"),this.navigation.style.marginBottom=0,this.mobileMenuToggleButton.setAttribute("aria-expanded","false"),this.mobileMenuToggleButton.focus(),this.mobileMenuCloseButton.removeEventListener("click",this.closeMobileMenu.bind(this)),document.removeEventListener("keydown",this.handleEscapeKey.bind(this))}},{key:"handleEscapeKey",value:function(e){"Escape"===e.key&&this.closeMobileMenu()}},{key:"openMobileMenu",value:function(){var e=this.mobileMenu.offsetHeight;this.menuIsOpen=!0,this.mobileMenu.classList.remove("nhsuk-header__drop-down--hidden"),this.navigation.style.marginBottom="".concat(e,"px"),this.mobileMenuToggleButton.setAttribute("aria-expanded","true"),document.addEventListener("keydown",this.handleEscapeKey.bind(this)),this.mobileMenuCloseButton.addEventListener("click",this.closeMobileMenu.bind(this))}},{key:"toggleMobileMenu",value:function(){this.menuIsOpen?this.closeMobileMenu():this.openMobileMenu()}},{key:"updateNavigation",value:function(){var e=this.navigation.offsetWidth,t=this.navigationList.children.length;if(e<this.breakpoints[t-1]){if(this.mobileMenuToggleButton.classList.add("nhsuk-header__menu-toggle--visible"),this.mobileMenuContainer.classList.add("nhsuk-mobile-menu-container--visible"),2===t)return;for(;e<this.breakpoints[t-1];)this.mobileMenu.insertBefore(this.navigationList.children[t-2],this.mobileMenu.firstChild),--t}else if(e>this.breakpoints[t])for(;e>this.breakpoints[t];)this.navigationList.insertBefore(this.mobileMenu.removeChild(this.mobileMenu.firstChild),this.mobileMenuContainer),t+=1;this.mobileMenu.children.length||(this.mobileMenuToggleButton.classList.remove("nhsuk-header__menu-toggle--visible"),this.mobileMenuContainer.classList.remove("nhsuk-mobile-menu-container--visible")),document.body.offsetWidth!==this.width&&this.menuIsOpen&&this.closeMobileMenu()}},{key:"doOnOrientationChange",value:function(){var e=this;90===window.orientation&&setTimeout(function(){e.calculateBreakpoints(),e.updateNavigation()},200)}}],o=n.prototype,a=i,s=0;s<a.length;s++){var r=a[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(o,(t=function(e){if("object"!==m(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==m(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(r.key),"symbol"===m(t)?t:String(t)),r)}return Object.defineProperty(n,"prototype",{writable:!1}),e}();function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t(e,t){for(var n,i=0;i<t.length;i++){var o=t[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(n=function(e){if("object"!==v(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==v(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(o.key),"symbol"===v(n)?n:String(n)),o)}}p=[{key:"getHref",value:function(e){e=e.getAttribute("href");return e.slice(e.indexOf("#"),e.length)}}],t((i=g).prototype,[{key:"init",value:function(){"function"==typeof window.matchMedia&&this.responsive?this.setupResponsiveChecks():this.setup()}},{key:"setupResponsiveChecks",value:function(){this.mql=window.matchMedia("(min-width: 641px)"),this.mql.addEventListener("change",this.checkMode.bind(this)),this.checkMode()}},{key:"checkMode",value:function(){this.mql.matches?this.setup():this.teardown()}},{key:"setup",value:function(){var t=this,e=this.$module,n=this.$tabs,i=e.querySelector(".".concat(this.namespace,"__list")),o=e.querySelectorAll(".".concat(this.namespace,"__list-item"));n&&i&&o&&(i.setAttribute("role","tablist"),o.forEach(function(e){e.setAttribute("role","presentation")}),n.forEach(function(e){t.setAttributes(e),e.boundTabClick=t.onTabClick.bind(t),e.boundTabKeydown=t.onTabKeydown.bind(t),e.addEventListener("click",e.boundTabClick,!0),e.addEventListener("keydown",e.boundTabKeydown,!0),t.hideTab(e)}),i=this.getTab(window.location.hash)||this.$tabs[0],this.showTab(i),this.historyEnabled)&&(e.boundOnHashChange=this.onHashChange.bind(this),window.addEventListener("hashchange",e.boundOnHashChange,!0))}},{key:"teardown",value:function(){var t=this,e=this.$module,n=this.$tabs,i=e.querySelector(".".concat(this.namespace,"__list")),o=e.querySelectorAll(".".concat(this.namespace,"__list-item"));n&&i&&o&&(i.removeAttribute("role"),o.forEach(function(e){e.removeAttribute("role","presentation")}),n.forEach(function(e){e.removeEventListener("click",e.boundTabClick,!0),e.removeEventListener("keydown",e.boundTabKeydown,!0),t.unsetAttributes(e)}),this.historyEnabled)&&window.removeEventListener("hashchange",e.boundOnHashChange,!0)}},{key:"onHashChange",value:function(){var e,t=window.location.hash,t=this.getTab(t);t&&(this.changingHash?this.changingHash=!1:(e=this.getCurrentTab(),this.hideTab(e),this.showTab(t),t.focus()))}},{key:"hideTab",value:function(e){this.unhighlightTab(e),this.hidePanel(e)}},{key:"showTab",value:function(e){this.highlightTab(e),this.showPanel(e)}},{key:"getTab",value:function(e){return this.$module.querySelector(".".concat(this.namespace,'__tab[href="').concat(e,'"]'))}},{key:"setAttributes",value:function(e){var t=g.getHref(e).slice(1),t=(e.setAttribute("id","tab_".concat(t)),e.setAttribute("role","tab"),e.setAttribute("aria-controls",t),e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),this.getPanel(e));t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",e.id),t.classList.add(this.jsHiddenClass)}},{key:"unsetAttributes",value:function(e){e.removeAttribute("id"),e.removeAttribute("role"),e.removeAttribute("aria-controls"),e.removeAttribute("aria-selected"),e.removeAttribute("tabindex");e=this.getPanel(e);e.removeAttribute("role"),e.removeAttribute("aria-labelledby"),e.removeAttribute("tabindex"),e.classList.remove(this.jsHiddenClass)}},{key:"onTabClick",value:function(e){e.target.classList.contains("".concat(this.namespace,"__tab"))||(e.stopPropagation(),e.preventDefault()),e.preventDefault();var e=e.target,t=this.getCurrentTab();this.hideTab(t),this.showTab(e),this.createHistoryEntry(e)}},{key:"createHistoryEntry",value:function(e){var t,n;this.historyEnabled&&(n=(t=this.getPanel(e)).id,t.id="",this.changingHash=!0,window.location.hash=g.getHref(e).slice(1),t.id=n)}},{key:"onTabKeydown",value:function(e){switch(e.keyCode){case this.keys.left:case this.keys.up:this.activatePreviousTab(),e.preventDefault();break;case this.keys.right:case this.keys.down:this.activateNextTab(),e.preventDefault()}}},{key:"activateNextTab",value:function(){var e,t=this.getCurrentTab(),n=t.parentNode.nextElementSibling;(e=n?n.querySelector(".".concat(this.namespace,"__tab")):e)&&(this.hideTab(t),this.showTab(e),e.focus(),this.createHistoryEntry(e))}},{key:"activatePreviousTab",value:function(){var e,t=this.getCurrentTab(),n=t.parentNode.previousElementSibling;(e=n?n.querySelector(".".concat(this.namespace,"__tab")):e)&&(this.hideTab(t),this.showTab(e),e.focus(),this.createHistoryEntry(e))}},{key:"getPanel",value:function(e){return this.$module.querySelector(g.getHref(e))}},{key:"showPanel",value:function(e){e=this.getPanel(e);e.classList.remove(this.jsHiddenClass),e.dispatchEvent(this.showEvent)}},{key:"hidePanel",value:function(e){e=this.getPanel(e);e.classList.add(this.jsHiddenClass),e.dispatchEvent(this.hideEvent)}},{key:"unhighlightTab",value:function(e){e.setAttribute("aria-selected","false"),e.parentNode.classList.remove("".concat(this.namespace,"__list-item--selected")),e.setAttribute("tabindex","-1")}},{key:"highlightTab",value:function(e){e.setAttribute("aria-selected","true"),e.parentNode.classList.add("".concat(this.namespace,"__list-item--selected")),e.setAttribute("tabindex","0")}},{key:"getCurrentTab",value:function(){return this.$module.querySelector(".".concat(this.namespace,"__list-item--selected .").concat(this.namespace,"__tab"))}}]),t(i,p),Object.defineProperty(i,"prototype",{writable:!1});var i,p,y=g;function g(e,t,n,i){if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");this.$module=e,this.namespace=t,this.responsive=n,this.historyEnabled=i,this.$tabs=e.querySelectorAll(".".concat(this.namespace,"__tab")),this.keys={down:40,left:37,right:39,up:38},this.jsHiddenClass="".concat(this.namespace,"__panel--hidden"),this.showEvent=new CustomEvent("tab.show"),this.hideEvent=new CustomEvent("tab.hide")}k(405),document.addEventListener("DOMContentLoaded",function(){var t,e,n,i;function o(){e.forEach(function(e){return h(e,"nhsuk-radios__conditional--hidden")})}function a(e){var t,n;h(e.target,"nhsuk-checkboxes__conditional--hidden"),e.target.checked&&(e.target.hasAttribute("data-checkbox-exclusive")?((t=e.target).form.querySelectorAll('input[type="checkbox"][data-checkbox-exclusive-group="'.concat(t.getAttribute("data-checkbox-exclusive-group"),'"]')).forEach(function(e){t.form===e.form&&e!==t&&(e.checked=!1)}),d(t)):((n=e.target).form.querySelectorAll('input[type="checkbox"][data-checkbox-exclusive][data-checkbox-exclusive-group="'.concat(n.getAttribute("data-checkbox-exclusive-group"),'"]')).forEach(function(e){n.form===e.form&&(e.checked=!1)}),d(n)))}document.querySelectorAll('[data-module="nhsuk-character-count"]').forEach(function(e){new l(e).init()}),document.querySelectorAll('[data-module="nhsuk-button"]').forEach(function(e){new u(e).init()}),i=document.querySelectorAll(".nhsuk-checkboxes .nhsuk-checkboxes__input"),"onpageshow"in window?window.addEventListener("pageshow",function(){return i.forEach(d)}):window.addEventListener("DOMContentLoaded",function(){return i.forEach(d)}),i.forEach(d),i.forEach(function(e){e.addEventListener("change",a)}),"boolean"!=typeof document.createElement("details").open&&(n=document.querySelectorAll("details")).length&&n.forEach(function(e,t){var n,i,o;e.hasAttribute("nhsuk-polyfilled")||(t=t,(n=e).setAttribute("nhsuk-polyfilled","true"),n.id||n.setAttribute("id","nhsuk-details".concat(t)),(i=document.querySelector("#".concat(n.id," .nhsuk-details__text"))).id||i.setAttribute("id","nhsuk-details__text".concat(t)),(o=document.querySelector("#".concat(n.id," .nhsuk-details__summary"))).setAttribute("role","button"),o.setAttribute("aria-controls",i.id),o.setAttribute("tabIndex","0"),1==(null!==n.getAttribute("open"))?(o.setAttribute("aria-expanded","true"),i.setAttribute("aria-hidden","false")):(o.setAttribute("aria-expanded","false"),i.setAttribute("aria-hidden","true"),i.style.display="none"),o.addEventListener("click",function(){c(o,"aria-expanded"),c(i,"aria-hidden"),i.style.display="true"===i.getAttribute("aria-hidden")?"none":"",n.hasAttribute("open")?n.removeAttribute("open"):n.setAttribute("open","open")}),o.addEventListener("keydown",function(e){13!==e.keyCode&&32!==e.keyCode||(e.preventDefault(),o.click())}))}),function(e){var e=(0<arguments.length&&void 0!==e?e:{}).focusOnPageLoad,e=void 0===e||e,t=document.querySelector(".nhsuk-error-summary");t&&(e&&t.focus(),t.addEventListener("click",b))}(),(new f).init(),e=document.querySelectorAll(".nhsuk-radios--conditional .nhsuk-radios__input"),"onpageshow"in window?window.addEventListener("pageshow",o):window.addEventListener("DOMContentLoaded",o),o(),e.forEach(function(e){e.addEventListener("change",o)}),t=document.querySelector("h1"),n=document.querySelector(".nhsuk-skip-link"),t&&n&&(n.addEventListener("click",function(e){e.preventDefault(),t.setAttribute("tabIndex","-1"),t.focus()}),t.addEventListener("blur",function(e){e.preventDefault(),t.removeAttribute("tabIndex")})),function(e){var e=0<arguments.length&&void 0!==e?e:{},t=e.namespace,n=void 0===t?"nhsuk-tabs":t,t=e.responsive,i=void 0===t||t,t=e.historyEnabled,o=void 0===t||t;document.querySelectorAll('[data-module="'.concat(n,'"]')).forEach(function(e){new y(e,n,i,o).init()})}()})})()})();
1
+ (()=>{var n={405:()=>{NodeList.prototype.forEach||(NodeList.prototype.forEach=Array.prototype.forEach),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{enumerable:!1,value:function(t){return 0<this.filter(function(e){return e===t}).length}}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;do{if(Element.prototype.matches.call(t,e))return t}while(null!==(t=t.parentElement||t.parentNode)&&1===t.nodeType);return null}),"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:null};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n})}},i={};function k(e){var t=i[e];return void 0!==t||(t=i[e]={exports:{}},n[e](t,t.exports,k)),t.exports}(()=>{"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t,n){(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}function r(e){e=function(e){if("object"!==n(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==n(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(e);return"symbol"===n(e)?e:String(e)}var u=function(){function t(e){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function");s(this,"KEY_SPACE",32),s(this,"DEBOUNCE_TIMEOUT_IN_SECONDS",1),this.$module=e,this.debounceFormSubmitTimer=null}for(var e=t,n=e.prototype,i=[{key:"handleKeyDown",value:function(e){var t=e.target;"button"===t.getAttribute("role")&&e.keyCode===this.KEY_SPACE&&(e.preventDefault(),t.click())}},{key:"debounce",value:function(e){var t=this;if("true"===e.target.getAttribute("data-prevent-double-click"))return this.debounceFormSubmitTimer?(e.preventDefault(),!1):void(this.debounceFormSubmitTimer=setTimeout(function(){t.debounceFormSubmitTimer=null},1e3*this.DEBOUNCE_TIMEOUT_IN_SECONDS))}},{key:"init",value:function(){this.$module.addEventListener("keydown",this.handleKeyDown.bind(this)),this.$module.addEventListener("click",this.debounce.bind(this))}}],o=0;o<i.length;o++){var a=i[o];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(n,r(a.key),a)}return Object.defineProperty(e,"prototype",{writable:!1}),t}();function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function e(e,t){for(var n,i=0;i<t.length;i++){var o=t[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(n=function(e){if("object"!==a(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==a(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(o.key),"symbol"===a(n)?n:String(n)),o)}}p=[{key:"getDataset",value:function(e){var t={},n=e.attributes;if(n)for(var i=0;i<n.length;i++){var o=n[i],a=o.name.match(/^data-(.+)/);a&&(t[a[1]]=o.value)}return t}}],e((i=o).prototype,[{key:"init",value:function(){var e,t,n,i;this.$textarea&&(e=this.$module,t=this.$textarea,n=document.getElementById("".concat(t.id,"-info")),t.insertAdjacentElement("afterend",n),(i=document.createElement("div")).className="nhsuk-character-count__sr-status nhsuk-u-visually-hidden",i.setAttribute("aria-live","polite"),this.$screenReaderCountMessage=i,n.insertAdjacentElement("afterend",i),(i=document.createElement("div")).className=n.className,i.classList.add("nhsuk-character-count__status"),i.setAttribute("aria-hidden","true"),this.$visibleCountMessage=i,n.insertAdjacentElement("afterend",i),n.classList.add("nhsuk-u-visually-hidden"),this.options=o.getDataset(e),i=this.defaults.characterCountAttribute,this.options.maxwords&&(i=this.defaults.wordCountAttribute),this.maxLength=e.getAttribute(i),this.maxLength)&&(t.removeAttribute("maxlength"),this.bindChangeEvents(),"onpageshow"in window?window.addEventListener("pageshow",this.updateCountMessage.bind(this)):window.addEventListener("DOMContentLoaded",this.updateCountMessage.bind(this)),this.updateCountMessage())}},{key:"count",value:function(e){return(this.options.maxwords?e.match(/\S+/g)||[]:e).length}},{key:"bindChangeEvents",value:function(){var e=this.$textarea;e.addEventListener("keyup",this.handleKeyUp.bind(this)),e.addEventListener("focus",this.handleFocus.bind(this)),e.addEventListener("blur",this.handleBlur.bind(this))}},{key:"checkIfValueChanged",value:function(){this.$textarea.oldValue||(this.$textarea.oldValue=""),this.$textarea.value!==this.$textarea.oldValue&&(this.$textarea.oldValue=this.$textarea.value,this.updateCountMessage())}},{key:"updateCountMessage",value:function(){this.updateVisibleCountMessage(),this.updateScreenReaderCountMessage()}},{key:"updateVisibleCountMessage",value:function(){var e=this.$textarea,t=this.$visibleCountMessage,n=this.maxLength-this.count(e.value);this.isOverThreshold()?t.classList.remove("nhsuk-character-count__message--disabled"):t.classList.add("nhsuk-character-count__message--disabled"),n<0?(e.classList.add("nhsuk-textarea--error"),t.classList.remove("nhsuk-hint"),t.classList.add("nhsuk-error-message")):(e.classList.remove("nhsuk-textarea--error"),t.classList.remove("nhsuk-error-message"),t.classList.add("nhsuk-hint")),t.innerHTML=this.formattedUpdateMessage()}},{key:"updateScreenReaderCountMessage",value:function(){var e=this.$screenReaderCountMessage;this.isOverThreshold()?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",!0),e.innerHTML=this.formattedUpdateMessage()}},{key:"formattedUpdateMessage",value:function(){var e=this.$textarea,t=this.options,e=this.maxLength-this.count(e.value),n="character";return t.maxwords&&(n="word"),n+=-1==e||1==e?"":"s",t=e<0?"too many":"remaining",e=Math.abs(e),"You have ".concat(e," ").concat(n," ").concat(t)}},{key:"isOverThreshold",value:function(){var e=this.$textarea,t=this.options,e=this.count(e.value);return this.maxLength*(t.threshold||0)/100<=e}},{key:"handleKeyUp",value:function(){this.updateVisibleCountMessage(),this.lastInputTimestamp=Date.now()}},{key:"handleFocus",value:function(){var e=this;this.valueChecker=setInterval(function(){(!e.lastInputTimestamp||Date.now()-500>=e.lastInputTimestamp)&&e.checkIfValueChanged()},1e3)}},{key:"handleBlur",value:function(){clearInterval(this.valueChecker)}}]),e(i,p),Object.defineProperty(i,"prototype",{writable:!1});var l=o;function o(e){if(!(this instanceof o))throw new TypeError("Cannot call a class as a function");this.$module=e,this.$textarea=e.querySelector(".nhsuk-js-character-count"),this.$visibleCountMessage=null,this.$screenReaderCountMessage=null,this.lastInputTimestamp=null}l.prototype.defaults={characterCountAttribute:"data-maxlength",wordCountAttribute:"data-maxwords"};function c(e,t){var n;e&&t&&(n="true"===e.getAttribute(t)?"false":"true",e.setAttribute(t,n))}function h(e,t){var n;e&&t&&(n=e.getAttribute("aria-controls"))&&(n=document.getElementById(n))&&(e.checked?(n.classList.remove(t),e.setAttribute("aria-expanded",!0)):(n.classList.add(t),e.setAttribute("aria-expanded",!1)))}function d(e){e.form.querySelectorAll('input[type="checkbox"]').forEach(function(e){return h(e,"nhsuk-checkboxes__conditional--hidden")})}function b(e){!function(e){if("A"===e.tagName&&!1!==e.href){var t,e=document.querySelector(e.hash);if(e)return(t=function(e){var t=e.closest("fieldset");if(t){t=t.getElementsByTagName("legend");if(t.length){t=t[0];if("checkbox"===e.type||"radio"===e.type)return t;var n=t.getBoundingClientRect().top,i=e.getBoundingClientRect();if(i.height&&window.innerHeight&&i.top+i.height-n<window.innerHeight/2)return t}}return document.querySelector("label[for='".concat(e.getAttribute("id"),"']"))||e.closest("label")}(e))&&(t.scrollIntoView(),e.focus({preventScroll:!0}),1)}}(e.target)||e.preventDefault()}function m(e){return(m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var f=function(){function e(){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function");this.menuIsOpen=!1,this.navigation=document.querySelector(".nhsuk-navigation"),this.navigationList=document.querySelector(".nhsuk-header__navigation-list"),this.mobileMenu=document.createElement("ul"),this.mobileMenuToggleButton=document.querySelector(".nhsuk-header__menu-toggle"),this.mobileMenuCloseButton=document.createElement("button"),this.mobileMenuContainer=document.querySelector(".nhsuk-mobile-menu-container"),this.breakpoints=[],this.width=document.body.offsetWidth}for(var t,n=e,i=[{key:"init",value:function(){var e=this;this.navigation&&this.navigationList&&this.mobileMenuToggleButton&&this.mobileMenuContainer&&(this.setupMobileMenu(),this.calculateBreakpoints(),this.updateNavigation(),this.doOnOrientationChange(),this.handleResize=this.debounce(function(){e.calculateBreakpoints(),e.updateNavigation()}),this.mobileMenuToggleButton.addEventListener("click",this.toggleMobileMenu.bind(this)),window.addEventListener("resize",this.handleResize),window.addEventListener("orientationchange",this.doOnOrientationChange()))}},{key:"debounce",value:function(i){var o,a=this,s=1<arguments.length&&void 0!==arguments[1]?arguments[1]:100;return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];clearTimeout(o),o=setTimeout(function(){i.apply(a,t)},s)}}},{key:"calculateBreakpoints",value:function(){for(var e=0,t=0;t<this.navigationList.children.length;t++)e+=this.navigationList.children[t].offsetWidth,this.breakpoints[t]=e}},{key:"setupMobileMenu",value:function(){this.mobileMenuContainer.appendChild(this.mobileMenu),this.mobileMenu.classList.add("nhsuk-header__drop-down","nhsuk-header__drop-down--hidden")}},{key:"closeMobileMenu",value:function(){this.menuIsOpen=!1,this.mobileMenu.classList.add("nhsuk-header__drop-down--hidden"),this.navigation.style.marginBottom=0,this.mobileMenuToggleButton.setAttribute("aria-expanded","false"),this.mobileMenuToggleButton.focus(),this.mobileMenuCloseButton.removeEventListener("click",this.closeMobileMenu.bind(this)),document.removeEventListener("keydown",this.handleEscapeKey.bind(this))}},{key:"handleEscapeKey",value:function(e){"Escape"===e.key&&this.closeMobileMenu()}},{key:"openMobileMenu",value:function(){this.menuIsOpen=!0,this.mobileMenu.classList.remove("nhsuk-header__drop-down--hidden");var e=this.mobileMenu.offsetHeight;this.navigation.style.marginBottom="".concat(e,"px"),this.mobileMenuToggleButton.setAttribute("aria-expanded","true"),document.addEventListener("keydown",this.handleEscapeKey.bind(this)),this.mobileMenuCloseButton.addEventListener("click",this.closeMobileMenu.bind(this))}},{key:"toggleMobileMenu",value:function(){this.menuIsOpen?this.closeMobileMenu():this.openMobileMenu()}},{key:"updateNavigation",value:function(){var e=this.navigation.offsetWidth,t=this.navigationList.children.length;if(e<this.breakpoints[t-1]){if(this.mobileMenuToggleButton.classList.add("nhsuk-header__menu-toggle--visible"),this.mobileMenuContainer.classList.add("nhsuk-mobile-menu-container--visible"),2===t)return;for(;e<this.breakpoints[t-1];)this.mobileMenu.insertBefore(this.navigationList.children[t-2],this.mobileMenu.firstChild),--t}else if(e>this.breakpoints[t])for(;e>this.breakpoints[t];)this.navigationList.insertBefore(this.mobileMenu.removeChild(this.mobileMenu.firstChild),this.mobileMenuContainer),t+=1;this.mobileMenu.children.length||(this.mobileMenuToggleButton.classList.remove("nhsuk-header__menu-toggle--visible"),this.mobileMenuContainer.classList.remove("nhsuk-mobile-menu-container--visible")),document.body.offsetWidth!==this.width&&this.menuIsOpen&&this.closeMobileMenu()}},{key:"doOnOrientationChange",value:function(){var e=this;90===window.orientation&&setTimeout(function(){e.calculateBreakpoints(),e.updateNavigation()},200)}}],o=n.prototype,a=i,s=0;s<a.length;s++){var r=a[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(o,(t=function(e){if("object"!==m(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==m(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(r.key),"symbol"===m(t)?t:String(t)),r)}return Object.defineProperty(n,"prototype",{writable:!1}),e}();function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function t(e,t){for(var n,i=0;i<t.length;i++){var o=t[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,(n=function(e){if("object"!==v(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0===t)return String(e);t=t.call(e,"string");if("object"!==v(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(o.key),"symbol"===v(n)?n:String(n)),o)}}p=[{key:"getHref",value:function(e){e=e.getAttribute("href");return e.slice(e.indexOf("#"),e.length)}}],t((i=g).prototype,[{key:"init",value:function(){"function"==typeof window.matchMedia&&this.responsive?this.setupResponsiveChecks():this.setup()}},{key:"setupResponsiveChecks",value:function(){this.mql=window.matchMedia("(min-width: 641px)"),this.mql.addEventListener("change",this.checkMode.bind(this)),this.checkMode()}},{key:"checkMode",value:function(){this.mql.matches?this.setup():this.teardown()}},{key:"setup",value:function(){var t=this,e=this.$module,n=this.$tabs,i=e.querySelector(".".concat(this.namespace,"__list")),o=e.querySelectorAll(".".concat(this.namespace,"__list-item"));n&&i&&o&&(i.setAttribute("role","tablist"),o.forEach(function(e){e.setAttribute("role","presentation")}),n.forEach(function(e){t.setAttributes(e),e.boundTabClick=t.onTabClick.bind(t),e.boundTabKeydown=t.onTabKeydown.bind(t),e.addEventListener("click",e.boundTabClick,!0),e.addEventListener("keydown",e.boundTabKeydown,!0),t.hideTab(e)}),i=this.getTab(window.location.hash)||this.$tabs[0],this.showTab(i),this.historyEnabled)&&(e.boundOnHashChange=this.onHashChange.bind(this),window.addEventListener("hashchange",e.boundOnHashChange,!0))}},{key:"teardown",value:function(){var t=this,e=this.$module,n=this.$tabs,i=e.querySelector(".".concat(this.namespace,"__list")),o=e.querySelectorAll(".".concat(this.namespace,"__list-item"));n&&i&&o&&(i.removeAttribute("role"),o.forEach(function(e){e.removeAttribute("role","presentation")}),n.forEach(function(e){e.removeEventListener("click",e.boundTabClick,!0),e.removeEventListener("keydown",e.boundTabKeydown,!0),t.unsetAttributes(e)}),this.historyEnabled)&&window.removeEventListener("hashchange",e.boundOnHashChange,!0)}},{key:"onHashChange",value:function(){var e,t=window.location.hash,t=this.getTab(t);t&&(this.changingHash?this.changingHash=!1:(e=this.getCurrentTab(),this.hideTab(e),this.showTab(t),t.focus()))}},{key:"hideTab",value:function(e){this.unhighlightTab(e),this.hidePanel(e)}},{key:"showTab",value:function(e){this.highlightTab(e),this.showPanel(e)}},{key:"getTab",value:function(e){return this.$module.querySelector(".".concat(this.namespace,'__tab[href="').concat(e,'"]'))}},{key:"setAttributes",value:function(e){var t=g.getHref(e).slice(1),t=(e.setAttribute("id","tab_".concat(t)),e.setAttribute("role","tab"),e.setAttribute("aria-controls",t),e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1"),this.getPanel(e));t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",e.id),t.classList.add(this.jsHiddenClass)}},{key:"unsetAttributes",value:function(e){e.removeAttribute("id"),e.removeAttribute("role"),e.removeAttribute("aria-controls"),e.removeAttribute("aria-selected"),e.removeAttribute("tabindex");e=this.getPanel(e);e.removeAttribute("role"),e.removeAttribute("aria-labelledby"),e.removeAttribute("tabindex"),e.classList.remove(this.jsHiddenClass)}},{key:"onTabClick",value:function(e){e.target.classList.contains("".concat(this.namespace,"__tab"))||(e.stopPropagation(),e.preventDefault()),e.preventDefault();var e=e.target,t=this.getCurrentTab();this.hideTab(t),this.showTab(e),this.createHistoryEntry(e)}},{key:"createHistoryEntry",value:function(e){var t,n;this.historyEnabled&&(n=(t=this.getPanel(e)).id,t.id="",this.changingHash=!0,window.location.hash=g.getHref(e).slice(1),t.id=n)}},{key:"onTabKeydown",value:function(e){switch(e.keyCode){case this.keys.left:case this.keys.up:this.activatePreviousTab(),e.preventDefault();break;case this.keys.right:case this.keys.down:this.activateNextTab(),e.preventDefault()}}},{key:"activateNextTab",value:function(){var e,t=this.getCurrentTab(),n=t.parentNode.nextElementSibling;(e=n?n.querySelector(".".concat(this.namespace,"__tab")):e)&&(this.hideTab(t),this.showTab(e),e.focus(),this.createHistoryEntry(e))}},{key:"activatePreviousTab",value:function(){var e,t=this.getCurrentTab(),n=t.parentNode.previousElementSibling;(e=n?n.querySelector(".".concat(this.namespace,"__tab")):e)&&(this.hideTab(t),this.showTab(e),e.focus(),this.createHistoryEntry(e))}},{key:"getPanel",value:function(e){return this.$module.querySelector(g.getHref(e))}},{key:"showPanel",value:function(e){e=this.getPanel(e);e.classList.remove(this.jsHiddenClass),e.dispatchEvent(this.showEvent)}},{key:"hidePanel",value:function(e){e=this.getPanel(e);e.classList.add(this.jsHiddenClass),e.dispatchEvent(this.hideEvent)}},{key:"unhighlightTab",value:function(e){e.setAttribute("aria-selected","false"),e.parentNode.classList.remove("".concat(this.namespace,"__list-item--selected")),e.setAttribute("tabindex","-1")}},{key:"highlightTab",value:function(e){e.setAttribute("aria-selected","true"),e.parentNode.classList.add("".concat(this.namespace,"__list-item--selected")),e.setAttribute("tabindex","0")}},{key:"getCurrentTab",value:function(){return this.$module.querySelector(".".concat(this.namespace,"__list-item--selected .").concat(this.namespace,"__tab"))}}]),t(i,p),Object.defineProperty(i,"prototype",{writable:!1});var i,p,y=g;function g(e,t,n,i){if(!(this instanceof g))throw new TypeError("Cannot call a class as a function");this.$module=e,this.namespace=t,this.responsive=n,this.historyEnabled=i,this.$tabs=e.querySelectorAll(".".concat(this.namespace,"__tab")),this.keys={down:40,left:37,right:39,up:38},this.jsHiddenClass="".concat(this.namespace,"__panel--hidden"),this.showEvent=new CustomEvent("tab.show"),this.hideEvent=new CustomEvent("tab.hide")}k(405),document.addEventListener("DOMContentLoaded",function(){var t,e,n,i;function o(){e.forEach(function(e){return h(e,"nhsuk-radios__conditional--hidden")})}function a(e){var t,n;h(e.target,"nhsuk-checkboxes__conditional--hidden"),e.target.checked&&(e.target.hasAttribute("data-checkbox-exclusive")?((t=e.target).form.querySelectorAll('input[type="checkbox"][data-checkbox-exclusive-group="'.concat(t.getAttribute("data-checkbox-exclusive-group"),'"]')).forEach(function(e){t.form===e.form&&e!==t&&(e.checked=!1)}),d(t)):((n=e.target).form.querySelectorAll('input[type="checkbox"][data-checkbox-exclusive][data-checkbox-exclusive-group="'.concat(n.getAttribute("data-checkbox-exclusive-group"),'"]')).forEach(function(e){n.form===e.form&&(e.checked=!1)}),d(n)))}document.querySelectorAll('[data-module="nhsuk-character-count"]').forEach(function(e){new l(e).init()}),document.querySelectorAll('[data-module="nhsuk-button"]').forEach(function(e){new u(e).init()}),i=document.querySelectorAll(".nhsuk-checkboxes .nhsuk-checkboxes__input"),"onpageshow"in window?window.addEventListener("pageshow",function(){return i.forEach(d)}):window.addEventListener("DOMContentLoaded",function(){return i.forEach(d)}),i.forEach(d),i.forEach(function(e){e.addEventListener("change",a)}),"boolean"!=typeof document.createElement("details").open&&(n=document.querySelectorAll("details")).length&&n.forEach(function(e,t){var n,i,o;e.hasAttribute("nhsuk-polyfilled")||(t=t,(n=e).setAttribute("nhsuk-polyfilled","true"),n.id||n.setAttribute("id","nhsuk-details".concat(t)),(i=document.querySelector("#".concat(n.id," .nhsuk-details__text"))).id||i.setAttribute("id","nhsuk-details__text".concat(t)),(o=document.querySelector("#".concat(n.id," .nhsuk-details__summary"))).setAttribute("role","button"),o.setAttribute("aria-controls",i.id),o.setAttribute("tabIndex","0"),1==(null!==n.getAttribute("open"))?(o.setAttribute("aria-expanded","true"),i.setAttribute("aria-hidden","false")):(o.setAttribute("aria-expanded","false"),i.setAttribute("aria-hidden","true"),i.style.display="none"),o.addEventListener("click",function(){c(o,"aria-expanded"),c(i,"aria-hidden"),i.style.display="true"===i.getAttribute("aria-hidden")?"none":"",n.hasAttribute("open")?n.removeAttribute("open"):n.setAttribute("open","open")}),o.addEventListener("keydown",function(e){13!==e.keyCode&&32!==e.keyCode||(e.preventDefault(),o.click())}))}),function(e){var e=(0<arguments.length&&void 0!==e?e:{}).focusOnPageLoad,e=void 0===e||e,t=document.querySelector(".nhsuk-error-summary");t&&(e&&t.focus(),t.addEventListener("click",b))}(),(new f).init(),e=document.querySelectorAll(".nhsuk-radios--conditional .nhsuk-radios__input"),"onpageshow"in window?window.addEventListener("pageshow",o):window.addEventListener("DOMContentLoaded",o),o(),e.forEach(function(e){e.addEventListener("change",o)}),t=document.querySelector("h1"),n=document.querySelector(".nhsuk-skip-link"),t&&n&&(n.addEventListener("click",function(e){e.preventDefault(),t.setAttribute("tabIndex","-1"),t.focus()}),t.addEventListener("blur",function(e){e.preventDefault(),t.removeAttribute("tabIndex")})),function(e){var e=0<arguments.length&&void 0!==e?e:{},t=e.namespace,n=void 0===t?"nhsuk-tabs":t,t=e.responsive,i=void 0===t||t,t=e.historyEnabled,o=void 0===t||t;document.querySelectorAll('[data-module="'.concat(n,'"]')).forEach(function(e){new y(e,n,i,o).init()})}()})})()})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nhsuk-frontend",
3
- "version": "8.0.1",
3
+ "version": "8.0.2",
4
4
  "description": "NHS.UK frontend contains the code you need to start building user interfaces for NHS websites and services.",
5
5
  "scripts": {
6
6
  "prepare": "gulp bundle",
@@ -109,9 +109,9 @@ class Header {
109
109
  */
110
110
 
111
111
  openMobileMenu() {
112
- const marginBody = this.mobileMenu.offsetHeight
113
112
  this.menuIsOpen = true
114
113
  this.mobileMenu.classList.remove('nhsuk-header__drop-down--hidden')
114
+ const marginBody = this.mobileMenu.offsetHeight
115
115
  this.navigation.style.marginBottom = `${marginBody}px`
116
116
  this.mobileMenuToggleButton.setAttribute('aria-expanded', 'true')
117
117
 
@@ -104,6 +104,7 @@
104
104
  </nav>
105
105
  </div>
106
106
 
107
+
107
108
  {% endif -%}
108
109
 
109
110
  {% if showSearch == "true" and showNav == "false" %}
@@ -132,32 +133,34 @@
132
133
  {% if showNav == "true" and params.primaryLinks and showSearch == "false" %}
133
134
 
134
135
  </div>{# close nhsuk-header__container #}
135
-
136
- <nav class="nhsuk-navigation" id="header-navigation" role="navigation" aria-label="Primary navigation">
137
- <ul class="nhsuk-header__navigation-list">
138
- {%- for item in params.primaryLinks %}
139
- <li class="nhsuk-header__navigation-item">
140
- <a class="nhsuk-header__navigation-link" href="{{item.url}}">
141
- {{item.label}}
142
- </a>
143
- </li>
144
- {%- endfor %}
145
- <li class="nhsuk-header__navigation-item nhsuk-header__navigation-item--home">
146
- <a class="nhsuk-header__navigation-link" href="/">
147
- Home
148
- </a>
149
- </li>
150
- <li class="nhsuk-mobile-menu-container">
151
- <button class="nhsuk-header__menu-toggle nhsuk-header__navigation-link" id="toggle-menu" aria-expanded="false">
152
- <span class="nhsuk-u-visually-hidden">Browse</span>
153
- More
154
- <svg class="nhsuk-icon nhsuk-icon__chevron-down" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
155
- <path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
156
- </svg>
157
- </button>
158
- </li>
159
- </ul>
160
- </nav>
136
+
137
+ <div class="nhsuk-navigation-container">
138
+ <nav class="nhsuk-navigation" id="header-navigation" role="navigation" aria-label="Primary navigation">
139
+ <ul class="nhsuk-header__navigation-list">
140
+ {%- for item in params.primaryLinks %}
141
+ <li class="nhsuk-header__navigation-item">
142
+ <a class="nhsuk-header__navigation-link" href="{{item.url}}">
143
+ {{item.label}}
144
+ </a>
145
+ </li>
146
+ {%- endfor %}
147
+ <li class="nhsuk-header__navigation-item nhsuk-header__navigation-item--home">
148
+ <a class="nhsuk-header__navigation-link" href="/">
149
+ Home
150
+ </a>
151
+ </li>
152
+ <li class="nhsuk-mobile-menu-container">
153
+ <button class="nhsuk-header__menu-toggle nhsuk-header__navigation-link" id="toggle-menu" aria-expanded="false">
154
+ <span class="nhsuk-u-visually-hidden">Browse</span>
155
+ More
156
+ <svg class="nhsuk-icon nhsuk-icon__chevron-down" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
157
+ <path d="M15.5 12a1 1 0 0 1-.29.71l-5 5a1 1 0 0 1-1.42-1.42l4.3-4.29-4.3-4.29a1 1 0 0 1 1.42-1.42l5 5a1 1 0 0 1 .29.71z"></path>
158
+ </svg>
159
+ </button>
160
+ </li>
161
+ </ul>
162
+ </nav>
163
+ </div>
161
164
 
162
165
  {% endif -%}
163
166