@ministryofjustice/frontend 7.0.0 → 8.0.0-beta.1
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.
- package/moj/all.bundle.js +15 -7
- package/moj/all.bundle.js.map +1 -1
- package/moj/all.bundle.mjs +15 -7
- package/moj/all.bundle.mjs.map +1 -1
- package/moj/common/moj-frontend-version.mjs +1 -1
- package/moj/components/date-picker/date-picker.bundle.js +2 -4
- package/moj/components/date-picker/date-picker.bundle.js.map +1 -1
- package/moj/components/date-picker/date-picker.bundle.mjs +2 -4
- package/moj/components/date-picker/date-picker.bundle.mjs.map +1 -1
- package/moj/components/date-picker/date-picker.mjs +2 -4
- package/moj/components/date-picker/date-picker.mjs.map +1 -1
- package/moj/components/domain-specific/probation/header/README.md +20 -1
- package/moj/components/domain-specific/probation/header/_header.scss +2 -1
- package/moj/components/domain-specific/probation/header/_header.scss.map +1 -1
- package/moj/components/domain-specific/probation/header/header.bundle.js +12 -2
- package/moj/components/domain-specific/probation/header/header.bundle.js.map +1 -1
- package/moj/components/domain-specific/probation/header/header.bundle.mjs +12 -2
- package/moj/components/domain-specific/probation/header/header.bundle.mjs.map +1 -1
- package/moj/components/domain-specific/probation/header/header.mjs +12 -2
- package/moj/components/domain-specific/probation/header/header.mjs.map +1 -1
- package/moj/components/domain-specific/probation/header/template.njk +37 -0
- package/moj/core/_moj-frontend-properties.scss +1 -1
- package/moj/core/_moj-frontend-properties.scss.map +1 -1
- package/moj/moj-frontend.min.css +1 -1
- package/moj/moj-frontend.min.css.map +1 -1
- package/moj/moj-frontend.min.js +1 -1
- package/moj/moj-frontend.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header.bundle.mjs","sources":["../../../../../../node_modules/govuk-frontend/dist/govuk/common/index.mjs","../../../../../../node_modules/govuk-frontend/dist/govuk/errors/index.mjs","../../../../../../node_modules/govuk-frontend/dist/govuk/component.mjs","../../../../../../src/moj/components/domain-specific/probation/header/header.mjs"],"sourcesContent":["function getBreakpoint(name) {\n const property = `--govuk-breakpoint-${name}`;\n const value = window.getComputedStyle(document.documentElement).getPropertyValue(property);\n return {\n property,\n value: value || undefined\n };\n}\nfunction setFocus($element, options = {}) {\n var _options$onBeforeFocu;\n const isFocusable = $element.getAttribute('tabindex');\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1');\n }\n function onFocus() {\n $element.addEventListener('blur', onBlur, {\n once: true\n });\n }\n function onBlur() {\n var _options$onBlur;\n (_options$onBlur = options.onBlur) == null || _options$onBlur.call($element);\n if (!isFocusable) {\n $element.removeAttribute('tabindex');\n }\n }\n $element.addEventListener('focus', onFocus, {\n once: true\n });\n (_options$onBeforeFocu = options.onBeforeFocus) == null || _options$onBeforeFocu.call($element);\n $element.focus();\n}\nfunction isInitialised($root, moduleName) {\n return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nfunction isSupported($scope = document.body) {\n if (!$scope) {\n return false;\n }\n return $scope.classList.contains('govuk-frontend-supported');\n}\nfunction isArray(option) {\n return Array.isArray(option);\n}\nfunction isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option);\n}\nfunction isScope($scope) {\n return !!$scope && ($scope instanceof Element || $scope instanceof Document);\n}\nfunction formatErrorMessage(Component, message) {\n return `${Component.moduleName}: ${message}`;\n}\n/**\n * @typedef ComponentWithModuleName\n * @property {string} moduleName - Name of the component\n */\n\nexport { formatErrorMessage, getBreakpoint, isInitialised, isObject, isScope, isSupported, setFocus };\n//# sourceMappingURL=index.mjs.map\n","import { isObject, formatErrorMessage } from '../common/index.mjs';\n\nclass GOVUKFrontendError extends Error {\n constructor(...args) {\n super(...args);\n this.name = 'GOVUKFrontendError';\n }\n}\nclass SupportError extends GOVUKFrontendError {\n /**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n */\n constructor($scope = document.body) {\n const supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class=\"govuk-frontend-supported\">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';\n super($scope ? supportMessage : 'GOV.UK Frontend initialised without `<script type=\"module\">`');\n this.name = 'SupportError';\n }\n}\nclass ConfigError extends GOVUKFrontendError {\n constructor(...args) {\n super(...args);\n this.name = 'ConfigError';\n }\n}\nclass ElementError extends GOVUKFrontendError {\n constructor(messageOrOptions) {\n let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';\n if (isObject(messageOrOptions)) {\n const {\n component,\n identifier,\n element,\n expectedType\n } = messageOrOptions;\n message = identifier;\n message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';\n if (component) {\n message = formatErrorMessage(component, message);\n }\n }\n super(message);\n this.name = 'ElementError';\n }\n}\nclass InitError extends GOVUKFrontendError {\n constructor(componentOrMessage) {\n const message = typeof componentOrMessage === 'string' ? componentOrMessage : formatErrorMessage(componentOrMessage, `Root element (\\`$root\\`) already initialised`);\n super(message);\n this.name = 'InitError';\n }\n}\n/**\n * @import { ComponentWithModuleName } from '../common/index.mjs'\n */\n\nexport { ConfigError, ElementError, GOVUKFrontendError, InitError, SupportError };\n//# sourceMappingURL=index.mjs.map\n","import { isInitialised, isSupported } from './common/index.mjs';\nimport { InitError, ElementError, SupportError } from './errors/index.mjs';\n\nclass Component {\n /**\n * Returns the root element of the component\n *\n * @protected\n * @returns {RootElementType} - the root element of component\n */\n get $root() {\n return this._$root;\n }\n constructor($root) {\n this._$root = void 0;\n const childConstructor = this.constructor;\n if (typeof childConstructor.moduleName !== 'string') {\n throw new InitError(`\\`moduleName\\` not defined in component`);\n }\n if (!($root instanceof childConstructor.elementType)) {\n throw new ElementError({\n element: $root,\n component: childConstructor,\n identifier: 'Root element (`$root`)',\n expectedType: childConstructor.elementType.name\n });\n } else {\n this._$root = $root;\n }\n childConstructor.checkSupport();\n this.checkInitialised();\n const moduleName = childConstructor.moduleName;\n this.$root.setAttribute(`data-${moduleName}-init`, '');\n }\n checkInitialised() {\n const constructor = this.constructor;\n const moduleName = constructor.moduleName;\n if (moduleName && isInitialised(this.$root, moduleName)) {\n throw new InitError(constructor);\n }\n }\n static checkSupport() {\n if (!isSupported()) {\n throw new SupportError();\n }\n }\n}\n\n/**\n * @typedef ChildClass\n * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component\n */\n\n/**\n * @typedef {typeof Component & ChildClass} ChildClassConstructor\n */\nComponent.elementType = HTMLElement;\n\nexport { Component };\n//# sourceMappingURL=component.mjs.map\n","import { Component } from 'govuk-frontend'\n\nexport class PdsHeader extends Component {\n /**\n * @param {Element | null} $root - HTML element to use for PDS header\n */\n constructor($root) {\n super($root)\n this.initHeader()\n }\n\n initHeader() {\n this.$tabOpenClass = 'probation-common-header__toggle-open'\n const $userToggle = this.$root.querySelector(\n '.probation-common-header__user-menu-toggle'\n )\n const $userMenu = this.$root.querySelector(\n '#probation-common-header-user-menu'\n )\n\n if (\n !$userToggle ||\n !$userMenu ||\n !($userToggle instanceof HTMLElement) ||\n !($userMenu instanceof HTMLElement)\n ) {\n return 0\n }\n\n this.hideFallbackLinks()\n $userToggle.removeAttribute('hidden')\n\n this.closeTabs([[$userToggle, $userMenu]])\n\n $userToggle.addEventListener('click', (_event) => {\n this.toggleMenu($userToggle, $userMenu)\n })\n }\n\n /**\n * @param {[any, any][]} tabTuples\n */\n closeTabs(tabTuples) {\n tabTuples.forEach(([toggle, menu]) => {\n if (menu && toggle) {\n menu.setAttribute('hidden', 'hidden')\n toggle.classList.remove(this.$tabOpenClass)\n toggle.parentElement.classList.remove('item-open')\n toggle.setAttribute('aria-expanded', 'false')\n if (toggle.dataset.textForShow)\n toggle.setAttribute('aria-label', toggle.dataset.textForShow)\n }\n })\n }\n\n /**\n * @param {HTMLElement} toggle\n * @param {HTMLElement} menu\n */\n toggleMenu(toggle, menu) {\n const isOpen = !menu.getAttribute('hidden')\n\n if (isOpen) {\n this.closeTabs([[toggle, menu]])\n } else if (menu && toggle) {\n menu.removeAttribute('hidden')\n toggle.classList.add(this.$tabOpenClass)\n toggle.parentElement.classList.add('item-open')\n toggle.setAttribute('aria-expanded', 'true')\n if (toggle.dataset.textForHide)\n toggle.setAttribute('aria-label', toggle.dataset.textForHide)\n }\n }\n\n hideFallbackLinks() {\n const $userLink = this.$root.querySelector(\n '.probation-common-header__user-menu-link'\n )\n if ($userLink) $userLink.setAttribute('hidden', 'hidden')\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'pds-header'\n}\n"],"names":["isInitialised","$root","moduleName","HTMLElement","hasAttribute","isSupported","$scope","document","body","classList","contains","isArray","option","Array","isObject","formatErrorMessage","Component","message","GOVUKFrontendError","Error","constructor","args","name","SupportError","supportMessage","HTMLScriptElement","prototype","ElementError","messageOrOptions","component","identifier","element","expectedType","InitError","componentOrMessage","_$root","childConstructor","elementType","checkSupport","checkInitialised","setAttribute","PdsHeader","initHeader","$tabOpenClass","$userToggle","querySelector","$userMenu","hideFallbackLinks","removeAttribute","closeTabs","addEventListener","_event","toggleMenu","tabTuples","forEach","toggle","menu","remove","parentElement","dataset","textForShow","isOpen","getAttribute","add","textForHide","$userLink"],"mappings":"AAmFO,SAASA,aAAaA,CAACC,KAAK,EAAEC,UAAU,EAAE;EAC/C,OACED,KAAK,YAAYE,WAAW,IAC5BF,KAAK,CAACG,YAAY,CAAC,CAAA,KAAA,EAAQF,UAAU,CAAA,KAAA,CAAO,CAAC;AAEjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,WAAWA,CAACC,MAAM,GAAGC,QAAQ,CAACC,IAAI,EAAE;EAClD,IA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AM,CAACI,OAAO,CAACC,WAAW,CAAC;AACjE,MAAA;AACF,IAAA,CAAC,CAAC;AACJ,EAAA;;AAEA;AACF;AACA;AACA;AACER,EAAAA,UAAUA,CAACG,MAAM,EAAEC,IAAI,EAAE;IACvB,MAAMK,MAAM,GAAG,CAACL,IAAI,CAACM,YAAY,CAAC,QAAQ,CAAC;AAE3C,IAAA,IAAID,MAAM,EAAE;MACV,IAAI,CAACZ,SAAS,CAAC,CAAC,CAACM,MAAM,EAAEC,IAAI,CAAC,CAAC,CAAC;AAClC,IAAA,CAAC,MAAM,IAAIA,IAAI,IAAID,MAAM,EAAE;AACzBC,MAAAA,IAAI,CAACR,eAAe,CAAC,QAAQ,CAAC;MAC9BO,MAAM,CAAC9C,SAAS,CAACsD,GAAG,CAAC,IAAI,CAACpB,aAAa,CAAC;MACxCY,MAAM,CAACG,aAAa,CAACjD,SAAS,CAACsD,GAAG,CAAC,WAAW,CAAC;AAC/CR,MAAAA,MAAM,CAACf,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC;AAC5C,MAAA,IAAIe,MAAM,CAACI,OAAO,CAACK,WAAW,EAC5BT,MAAM,CAACf,YAAY,CAAC,YAAY,EAAEe,MAAM,CAACI,OAAO,CAACK,WAAW,CAAC;AACjE,IAAA;AACF,EAAA;AAEAjB,EAAAA,iBAAiBA,GAAG;IAClB,MAAMkB,SAAS,GAAG,IAAI,CAAChE,KAAK,CAAC4C,aAAa,CACxC,0CACF,CAAC;IACD,IAAIoB,SAAS,EAAEA,SAAS,CAACzB,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC;AAC3D,EAAA;;AAEA;AACF;AACA;AAEA;AAnFaC,SAAS,CAkFbvC,UAAU,GAAG,YAAY;;;;","x_google_ignoreList":[0,1,2]}
|
|
1
|
+
{"version":3,"file":"header.bundle.mjs","sources":["../../../../../../node_modules/govuk-frontend/dist/govuk/common/index.mjs","../../../../../../node_modules/govuk-frontend/dist/govuk/errors/index.mjs","../../../../../../node_modules/govuk-frontend/dist/govuk/component.mjs","../../../../../../src/moj/components/domain-specific/probation/header/header.mjs"],"sourcesContent":["function getBreakpoint(name) {\n const property = `--govuk-breakpoint-${name}`;\n const value = window.getComputedStyle(document.documentElement).getPropertyValue(property);\n return {\n property,\n value: value || undefined\n };\n}\nfunction setFocus($element, options = {}) {\n var _options$onBeforeFocu;\n const isFocusable = $element.getAttribute('tabindex');\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1');\n }\n function onFocus() {\n $element.addEventListener('blur', onBlur, {\n once: true\n });\n }\n function onBlur() {\n var _options$onBlur;\n (_options$onBlur = options.onBlur) == null || _options$onBlur.call($element);\n if (!isFocusable) {\n $element.removeAttribute('tabindex');\n }\n }\n $element.addEventListener('focus', onFocus, {\n once: true\n });\n (_options$onBeforeFocu = options.onBeforeFocus) == null || _options$onBeforeFocu.call($element);\n $element.focus();\n}\nfunction isInitialised($root, moduleName) {\n return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nfunction isSupported($scope = document.body) {\n if (!$scope) {\n return false;\n }\n return $scope.classList.contains('govuk-frontend-supported');\n}\nfunction isArray(option) {\n return Array.isArray(option);\n}\nfunction isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option);\n}\nfunction isScope($scope) {\n return !!$scope && ($scope instanceof Element || $scope instanceof Document);\n}\nfunction formatErrorMessage(Component, message) {\n return `${Component.moduleName}: ${message}`;\n}\n/**\n * @typedef ComponentWithModuleName\n * @property {string} moduleName - Name of the component\n */\n\nexport { formatErrorMessage, getBreakpoint, isInitialised, isObject, isScope, isSupported, setFocus };\n//# sourceMappingURL=index.mjs.map\n","import { isObject, formatErrorMessage } from '../common/index.mjs';\n\nclass GOVUKFrontendError extends Error {\n constructor(...args) {\n super(...args);\n this.name = 'GOVUKFrontendError';\n }\n}\nclass SupportError extends GOVUKFrontendError {\n /**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n */\n constructor($scope = document.body) {\n const supportMessage = 'noModule' in HTMLScriptElement.prototype ? 'GOV.UK Frontend initialised without `<body class=\"govuk-frontend-supported\">` from template `<script>` snippet' : 'GOV.UK Frontend is not supported in this browser';\n super($scope ? supportMessage : 'GOV.UK Frontend initialised without `<script type=\"module\">`');\n this.name = 'SupportError';\n }\n}\nclass ConfigError extends GOVUKFrontendError {\n constructor(...args) {\n super(...args);\n this.name = 'ConfigError';\n }\n}\nclass ElementError extends GOVUKFrontendError {\n constructor(messageOrOptions) {\n let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';\n if (isObject(messageOrOptions)) {\n const {\n component,\n identifier,\n element,\n expectedType\n } = messageOrOptions;\n message = identifier;\n message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';\n if (component) {\n message = formatErrorMessage(component, message);\n }\n }\n super(message);\n this.name = 'ElementError';\n }\n}\nclass InitError extends GOVUKFrontendError {\n constructor(componentOrMessage) {\n const message = typeof componentOrMessage === 'string' ? componentOrMessage : formatErrorMessage(componentOrMessage, `Root element (\\`$root\\`) already initialised`);\n super(message);\n this.name = 'InitError';\n }\n}\n/**\n * @import { ComponentWithModuleName } from '../common/index.mjs'\n */\n\nexport { ConfigError, ElementError, GOVUKFrontendError, InitError, SupportError };\n//# sourceMappingURL=index.mjs.map\n","import { isInitialised, isSupported } from './common/index.mjs';\nimport { InitError, ElementError, SupportError } from './errors/index.mjs';\n\nclass Component {\n /**\n * Returns the root element of the component\n *\n * @protected\n * @returns {RootElementType} - the root element of component\n */\n get $root() {\n return this._$root;\n }\n constructor($root) {\n this._$root = void 0;\n const childConstructor = this.constructor;\n if (typeof childConstructor.moduleName !== 'string') {\n throw new InitError(`\\`moduleName\\` not defined in component`);\n }\n if (!($root instanceof childConstructor.elementType)) {\n throw new ElementError({\n element: $root,\n component: childConstructor,\n identifier: 'Root element (`$root`)',\n expectedType: childConstructor.elementType.name\n });\n } else {\n this._$root = $root;\n }\n childConstructor.checkSupport();\n this.checkInitialised();\n const moduleName = childConstructor.moduleName;\n this.$root.setAttribute(`data-${moduleName}-init`, '');\n }\n checkInitialised() {\n const constructor = this.constructor;\n const moduleName = constructor.moduleName;\n if (moduleName && isInitialised(this.$root, moduleName)) {\n throw new InitError(constructor);\n }\n }\n static checkSupport() {\n if (!isSupported()) {\n throw new SupportError();\n }\n }\n}\n\n/**\n * @typedef ChildClass\n * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component\n */\n\n/**\n * @typedef {typeof Component & ChildClass} ChildClassConstructor\n */\nComponent.elementType = HTMLElement;\n\nexport { Component };\n//# sourceMappingURL=component.mjs.map\n","import { Component } from 'govuk-frontend'\n\nexport class PdsHeader extends Component {\n /**\n * @param {Element | null} $root - HTML element to use for PDS header\n */\n constructor($root) {\n super($root)\n this.initHeader()\n }\n\n initHeader() {\n this.$tabOpenClass = 'probation-common-header__toggle-open'\n const $userToggle = this.$root.querySelector(\n '.probation-common-header__user-menu-toggle'\n )\n const $userMenu = this.$root.querySelector(\n '#probation-common-header-user-menu'\n )\n\n const $servicesToggle = this.$root.querySelector(\n '.probation-common-header__services-menu-toggle'\n )\n\n const $servicesMenu = this.$root.querySelector(\n '#probation-common-header-services-menu'\n )\n\n if (\n !$userToggle ||\n !$userMenu ||\n !$servicesToggle ||\n !$servicesMenu ||\n !($userToggle instanceof HTMLElement) ||\n !($userMenu instanceof HTMLElement) ||\n !($servicesToggle instanceof HTMLElement) ||\n !($servicesMenu instanceof HTMLElement)\n ) {\n return 0\n }\n\n this.hideFallbackLinks()\n $userToggle.removeAttribute('hidden')\n $servicesToggle.removeAttribute('hidden')\n\n this.closeTabs([\n [$userToggle, $userMenu],\n [$servicesToggle, $servicesMenu]\n ])\n\n $userToggle.addEventListener('click', (_event) => {\n this.closeTabs([[$servicesToggle, $servicesMenu]])\n this.toggleMenu($userToggle, $userMenu)\n })\n\n $servicesToggle.addEventListener('click', (_event) => {\n this.closeTabs([[$userToggle, $userMenu]])\n this.toggleMenu($servicesToggle, $servicesMenu)\n })\n }\n\n /**\n * @param {[any, any][]} tabTuples\n */\n closeTabs(tabTuples) {\n tabTuples.forEach(([toggle, menu]) => {\n if (menu && toggle) {\n menu.setAttribute('hidden', 'hidden')\n toggle.classList.remove(this.$tabOpenClass)\n toggle.parentElement.classList.remove('item-open')\n toggle.setAttribute('aria-expanded', 'false')\n if (toggle.dataset.textForShow)\n toggle.setAttribute('aria-label', toggle.dataset.textForShow)\n }\n })\n }\n\n /**\n * @param {HTMLElement} toggle\n * @param {HTMLElement} menu\n */\n toggleMenu(toggle, menu) {\n const isOpen = !menu.getAttribute('hidden')\n\n if (isOpen) {\n this.closeTabs([[toggle, menu]])\n } else if (menu && toggle) {\n menu.removeAttribute('hidden')\n toggle.classList.add(this.$tabOpenClass)\n toggle.parentElement.classList.add('item-open')\n toggle.setAttribute('aria-expanded', 'true')\n if (toggle.dataset.textForHide)\n toggle.setAttribute('aria-label', toggle.dataset.textForHide)\n }\n }\n\n hideFallbackLinks() {\n const $userLink = this.$root.querySelector(\n '.probation-common-header__user-menu-link'\n )\n const $servicesLink = this.$root.querySelector(\n '.probation-common-header__services-menu-link'\n )\n if ($userLink) $userLink.setAttribute('hidden', 'hidden')\n if ($servicesLink) $servicesLink.setAttribute('hidden', 'hidden')\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'pds-header'\n}\n"],"names":["isInitialised","$root","moduleName","HTMLElement","hasAttribute","isSupported","$scope","document","body","classList","contains","isArray","option","Array","isObject","formatErrorMessage","Component","message","GOVUKFrontendError","Error","constructor","args","name","SupportError","supportMessage","HTMLScriptElement","prototype","ElementError","messageOrOptions","component","identifier","element","expectedType","InitError","componentOrMessage","_$root","childConstructor","elementType","checkSupport","checkInitialised","setAttribute","PdsHeader","initHeader","$tabOpenClass","$userToggle","querySelector","$userMenu","$servicesToggle","$servicesMenu","hideFallbackLinks","removeAttribute","closeTabs","addEventListener","_event","toggleMenu","tabTuples","forEach","toggle","menu","remove","parentElement","dataset","textForShow","isOpen","getAttribute","add","textForHide","$userLink","$servicesLink"],"mappings":"AAmFO,SAASA,aAAaA,CAACC,KAAK,EAAEC,UAAU,EAAE;EAC/C,OACED,KAAK,YAAYE,WAAW,IAC5BF,KAAK,CAACG,YAAY,CAAC,CAAA,KAAA,EAAQF,UAAU,CAAA,KAAA,CAAO,CAAC;AAEjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,WAAWA,CAACC,MAAM,GAAGC,QAAQ,CAACC,IAAI,EAAE;EAClD,IAAI,CAACF,MAAM,EAAE;AACX,IAAA,OAAO,KAAK;AACd,EAAA;AAEA,EAAA,OAAOA,MAAM,CAACG,SAAS,CAACC,QAAQ,CAAC,0BAA0B,CAAC;AAC9D;AASA,SAASC,OAAOA,CAACC,MAAM,EAAE;AACvB,EAAA,OAAOC,KAAK,CAACF,OAAO,CAACC,MAAM,CAAC;AAC9B;AAUO,SAASE,QAAQA,CAACF,MAAM,EAAE;AAC/B,EAAA,OAAO,CAAC,CAACA,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,IAAI,CAACD,OAAO,CAACC,MAAM,CAAC;AACnE;AAsBO,SAASG,kBAAkBA,CAACC,SAAS,EAAEC,OAAO,EAAE;AACrD,EAAA,OAAO,GAAGD,SAAS,CAACd,UAAU,CAAA,EAAA,EAAKe,OAAO,CAAA,CAAE;AAC9C;;AClIO,MAAMC,kBAAkB,SAASC,KAAK,CAAC;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;IAAA,IAAA,CAC5CC,IAAI,GAAG,oBAAoB;AAAA,EAAA;AA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,2]}
|
|
@@ -12,15 +12,23 @@ class PdsHeader extends Component {
|
|
|
12
12
|
this.$tabOpenClass = 'probation-common-header__toggle-open';
|
|
13
13
|
const $userToggle = this.$root.querySelector('.probation-common-header__user-menu-toggle');
|
|
14
14
|
const $userMenu = this.$root.querySelector('#probation-common-header-user-menu');
|
|
15
|
-
|
|
15
|
+
const $servicesToggle = this.$root.querySelector('.probation-common-header__services-menu-toggle');
|
|
16
|
+
const $servicesMenu = this.$root.querySelector('#probation-common-header-services-menu');
|
|
17
|
+
if (!$userToggle || !$userMenu || !$servicesToggle || !$servicesMenu || !($userToggle instanceof HTMLElement) || !($userMenu instanceof HTMLElement) || !($servicesToggle instanceof HTMLElement) || !($servicesMenu instanceof HTMLElement)) {
|
|
16
18
|
return 0;
|
|
17
19
|
}
|
|
18
20
|
this.hideFallbackLinks();
|
|
19
21
|
$userToggle.removeAttribute('hidden');
|
|
20
|
-
|
|
22
|
+
$servicesToggle.removeAttribute('hidden');
|
|
23
|
+
this.closeTabs([[$userToggle, $userMenu], [$servicesToggle, $servicesMenu]]);
|
|
21
24
|
$userToggle.addEventListener('click', _event => {
|
|
25
|
+
this.closeTabs([[$servicesToggle, $servicesMenu]]);
|
|
22
26
|
this.toggleMenu($userToggle, $userMenu);
|
|
23
27
|
});
|
|
28
|
+
$servicesToggle.addEventListener('click', _event => {
|
|
29
|
+
this.closeTabs([[$userToggle, $userMenu]]);
|
|
30
|
+
this.toggleMenu($servicesToggle, $servicesMenu);
|
|
31
|
+
});
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
/**
|
|
@@ -56,7 +64,9 @@ class PdsHeader extends Component {
|
|
|
56
64
|
}
|
|
57
65
|
hideFallbackLinks() {
|
|
58
66
|
const $userLink = this.$root.querySelector('.probation-common-header__user-menu-link');
|
|
67
|
+
const $servicesLink = this.$root.querySelector('.probation-common-header__services-menu-link');
|
|
59
68
|
if ($userLink) $userLink.setAttribute('hidden', 'hidden');
|
|
69
|
+
if ($servicesLink) $servicesLink.setAttribute('hidden', 'hidden');
|
|
60
70
|
}
|
|
61
71
|
|
|
62
72
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header.mjs","sources":["../../../../../../src/moj/components/domain-specific/probation/header/header.mjs"],"sourcesContent":["import { Component } from 'govuk-frontend'\n\nexport class PdsHeader extends Component {\n /**\n * @param {Element | null} $root - HTML element to use for PDS header\n */\n constructor($root) {\n super($root)\n this.initHeader()\n }\n\n initHeader() {\n this.$tabOpenClass = 'probation-common-header__toggle-open'\n const $userToggle = this.$root.querySelector(\n '.probation-common-header__user-menu-toggle'\n )\n const $userMenu = this.$root.querySelector(\n '#probation-common-header-user-menu'\n )\n\n if (\n !$userToggle ||\n !$userMenu ||\n !($userToggle instanceof HTMLElement) ||\n !($userMenu instanceof HTMLElement)\n ) {\n return 0\n }\n\n this.hideFallbackLinks()\n $userToggle.removeAttribute('hidden')\n\n this.closeTabs([[$userToggle, $userMenu]])\n\n $userToggle.addEventListener('click', (_event) => {\n this.toggleMenu($userToggle, $userMenu)\n })\n }\n\n /**\n * @param {[any, any][]} tabTuples\n */\n closeTabs(tabTuples) {\n tabTuples.forEach(([toggle, menu]) => {\n if (menu && toggle) {\n menu.setAttribute('hidden', 'hidden')\n toggle.classList.remove(this.$tabOpenClass)\n toggle.parentElement.classList.remove('item-open')\n toggle.setAttribute('aria-expanded', 'false')\n if (toggle.dataset.textForShow)\n toggle.setAttribute('aria-label', toggle.dataset.textForShow)\n }\n })\n }\n\n /**\n * @param {HTMLElement} toggle\n * @param {HTMLElement} menu\n */\n toggleMenu(toggle, menu) {\n const isOpen = !menu.getAttribute('hidden')\n\n if (isOpen) {\n this.closeTabs([[toggle, menu]])\n } else if (menu && toggle) {\n menu.removeAttribute('hidden')\n toggle.classList.add(this.$tabOpenClass)\n toggle.parentElement.classList.add('item-open')\n toggle.setAttribute('aria-expanded', 'true')\n if (toggle.dataset.textForHide)\n toggle.setAttribute('aria-label', toggle.dataset.textForHide)\n }\n }\n\n hideFallbackLinks() {\n const $userLink = this.$root.querySelector(\n '.probation-common-header__user-menu-link'\n )\n if ($userLink) $userLink.setAttribute('hidden', 'hidden')\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'pds-header'\n}\n"],"names":["PdsHeader","Component","constructor","$root","initHeader","$tabOpenClass","$userToggle","querySelector","$userMenu","HTMLElement","hideFallbackLinks","removeAttribute","closeTabs","addEventListener","_event","toggleMenu","tabTuples","forEach","toggle","menu","setAttribute","classList","remove","parentElement","dataset","textForShow","isOpen","getAttribute","add","textForHide","$userLink","moduleName"],"mappings":";;AAEO,MAAMA,SAAS,SAASC,SAAS,CAAC;AACvC;AACF;AACA;EACEC,WAAWA,CAACC,KAAK,EAAE;IACjB,KAAK,CAACA,KAAK,CAAC;IACZ,IAAI,CAACC,UAAU,EAAE;AACnB,EAAA;AAEAA,EAAAA,UAAUA,GAAG;IACX,IAAI,CAACC,aAAa,GAAG,sCAAsC;IAC3D,MAAMC,WAAW,GAAG,IAAI,CAACH,KAAK,CAACI,aAAa,CAC1C,4CACF,CAAC;IACD,MAAMC,SAAS,GAAG,IAAI,CAACL,KAAK,CAACI,aAAa,CACxC,oCACF,CAAC;AAED,IAAA,IACE,CAACD,WAAW,IACZ,CAACE,SAAS,IACV,
|
|
1
|
+
{"version":3,"file":"header.mjs","sources":["../../../../../../src/moj/components/domain-specific/probation/header/header.mjs"],"sourcesContent":["import { Component } from 'govuk-frontend'\n\nexport class PdsHeader extends Component {\n /**\n * @param {Element | null} $root - HTML element to use for PDS header\n */\n constructor($root) {\n super($root)\n this.initHeader()\n }\n\n initHeader() {\n this.$tabOpenClass = 'probation-common-header__toggle-open'\n const $userToggle = this.$root.querySelector(\n '.probation-common-header__user-menu-toggle'\n )\n const $userMenu = this.$root.querySelector(\n '#probation-common-header-user-menu'\n )\n\n const $servicesToggle = this.$root.querySelector(\n '.probation-common-header__services-menu-toggle'\n )\n\n const $servicesMenu = this.$root.querySelector(\n '#probation-common-header-services-menu'\n )\n\n if (\n !$userToggle ||\n !$userMenu ||\n !$servicesToggle ||\n !$servicesMenu ||\n !($userToggle instanceof HTMLElement) ||\n !($userMenu instanceof HTMLElement) ||\n !($servicesToggle instanceof HTMLElement) ||\n !($servicesMenu instanceof HTMLElement)\n ) {\n return 0\n }\n\n this.hideFallbackLinks()\n $userToggle.removeAttribute('hidden')\n $servicesToggle.removeAttribute('hidden')\n\n this.closeTabs([\n [$userToggle, $userMenu],\n [$servicesToggle, $servicesMenu]\n ])\n\n $userToggle.addEventListener('click', (_event) => {\n this.closeTabs([[$servicesToggle, $servicesMenu]])\n this.toggleMenu($userToggle, $userMenu)\n })\n\n $servicesToggle.addEventListener('click', (_event) => {\n this.closeTabs([[$userToggle, $userMenu]])\n this.toggleMenu($servicesToggle, $servicesMenu)\n })\n }\n\n /**\n * @param {[any, any][]} tabTuples\n */\n closeTabs(tabTuples) {\n tabTuples.forEach(([toggle, menu]) => {\n if (menu && toggle) {\n menu.setAttribute('hidden', 'hidden')\n toggle.classList.remove(this.$tabOpenClass)\n toggle.parentElement.classList.remove('item-open')\n toggle.setAttribute('aria-expanded', 'false')\n if (toggle.dataset.textForShow)\n toggle.setAttribute('aria-label', toggle.dataset.textForShow)\n }\n })\n }\n\n /**\n * @param {HTMLElement} toggle\n * @param {HTMLElement} menu\n */\n toggleMenu(toggle, menu) {\n const isOpen = !menu.getAttribute('hidden')\n\n if (isOpen) {\n this.closeTabs([[toggle, menu]])\n } else if (menu && toggle) {\n menu.removeAttribute('hidden')\n toggle.classList.add(this.$tabOpenClass)\n toggle.parentElement.classList.add('item-open')\n toggle.setAttribute('aria-expanded', 'true')\n if (toggle.dataset.textForHide)\n toggle.setAttribute('aria-label', toggle.dataset.textForHide)\n }\n }\n\n hideFallbackLinks() {\n const $userLink = this.$root.querySelector(\n '.probation-common-header__user-menu-link'\n )\n const $servicesLink = this.$root.querySelector(\n '.probation-common-header__services-menu-link'\n )\n if ($userLink) $userLink.setAttribute('hidden', 'hidden')\n if ($servicesLink) $servicesLink.setAttribute('hidden', 'hidden')\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'pds-header'\n}\n"],"names":["PdsHeader","Component","constructor","$root","initHeader","$tabOpenClass","$userToggle","querySelector","$userMenu","$servicesToggle","$servicesMenu","HTMLElement","hideFallbackLinks","removeAttribute","closeTabs","addEventListener","_event","toggleMenu","tabTuples","forEach","toggle","menu","setAttribute","classList","remove","parentElement","dataset","textForShow","isOpen","getAttribute","add","textForHide","$userLink","$servicesLink","moduleName"],"mappings":";;AAEO,MAAMA,SAAS,SAASC,SAAS,CAAC;AACvC;AACF;AACA;EACEC,WAAWA,CAACC,KAAK,EAAE;IACjB,KAAK,CAACA,KAAK,CAAC;IACZ,IAAI,CAACC,UAAU,EAAE;AACnB,EAAA;AAEAA,EAAAA,UAAUA,GAAG;IACX,IAAI,CAACC,aAAa,GAAG,sCAAsC;IAC3D,MAAMC,WAAW,GAAG,IAAI,CAACH,KAAK,CAACI,aAAa,CAC1C,4CACF,CAAC;IACD,MAAMC,SAAS,GAAG,IAAI,CAACL,KAAK,CAACI,aAAa,CACxC,oCACF,CAAC;IAED,MAAME,eAAe,GAAG,IAAI,CAACN,KAAK,CAACI,aAAa,CAC9C,gDACF,CAAC;IAED,MAAMG,aAAa,GAAG,IAAI,CAACP,KAAK,CAACI,aAAa,CAC5C,wCACF,CAAC;AAED,IAAA,IACE,CAACD,WAAW,IACZ,CAACE,SAAS,IACV,CAACC,eAAe,IAChB,CAACC,aAAa,IACd,EAAEJ,WAAW,YAAYK,WAAW,CAAC,IACrC,EAAEH,SAAS,YAAYG,WAAW,CAAC,IACnC,EAAEF,eAAe,YAAYE,WAAW,CAAC,IACzC,EAAED,aAAa,YAAYC,WAAW,CAAC,EACvC;AACA,MAAA,OAAO,CAAC;AACV,IAAA;IAEA,IAAI,CAACC,iBAAiB,EAAE;AACxBN,IAAAA,WAAW,CAACO,eAAe,CAAC,QAAQ,CAAC;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
|
|
102
102
|
|
|
103
|
+
{# SERVICES MENU #}
|
|
104
|
+
<div class="probation-common-header__navigation__item">
|
|
105
|
+
<button data-qa="probation-common-header__menu-toggle" class="probation-common-header__menu-toggle probation-common-header__services-menu-toggle" aria-controls="probation-common-header-services-menu" aria-expanded="false" data-text-for-show="Show services menu" data-text-for-hide="Hide services menu" type="button" hidden='hidden'>
|
|
106
|
+
<span>
|
|
107
|
+
<span class='govuk-!-font-size-19 govuk-!-font-weight-bold'>Menu</span>
|
|
108
|
+
</span>
|
|
109
|
+
</button>
|
|
110
|
+
|
|
111
|
+
<div class="probation-common-header__icon-link-wrapper probation-common-header__services-menu-link">
|
|
112
|
+
<a class="probation-common-header__link" href="{{ params.servicesLink }}">
|
|
113
|
+
<span>
|
|
114
|
+
<span class="govuk-visually-hidden"> Services</span>
|
|
115
|
+
<span>Menu</span>
|
|
116
|
+
</span>
|
|
117
|
+
</a>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
{# END SERVICES MENU #}
|
|
121
|
+
|
|
103
122
|
</div>
|
|
104
123
|
</div>
|
|
105
124
|
</div>
|
|
106
125
|
{# END MENU #}
|
|
126
|
+
{# SERVICES MENU #}
|
|
127
|
+
<div id="probation-common-header-services-menu" class="probation-common-header__pushdown-menu probation-common-header__services-menu" hidden="hidden">
|
|
128
|
+
<div class="govuk-width-container">
|
|
129
|
+
<div class="govuk-grid-row">
|
|
130
|
+
<div class="govuk-grid-column-full">
|
|
131
|
+
<h3 class="govuk-heading-m">
|
|
132
|
+
Services
|
|
133
|
+
</h3>
|
|
134
|
+
<ul class='govuk-list'>
|
|
135
|
+
{% for service in params.services %}
|
|
136
|
+
<li><a href='{{ service.href }}' class='probation-common-header__submenu-link' target="{{ service.target | default('_self') }}" {% if service.target == '_blank' %}rel="noopener noreferrer"{% endif %}>{{ service.heading }}</a></li>
|
|
137
|
+
{% endfor %}
|
|
138
|
+
</ul>
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
{# END SERVICES MENU #}
|
|
107
144
|
</nav>
|
|
108
145
|
</div>
|
|
109
146
|
</header>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
// This variable is automatically overwritten during builds and releases.
|
|
3
3
|
// It doesn't need to be updated manually.
|
|
4
|
-
--moj-frontend-version: "
|
|
4
|
+
--moj-frontend-version: "8.0.0-beta.1";
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
/*# sourceMappingURL=_moj-frontend-properties.scss.map */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/moj/core/_moj-frontend-properties.scss"],"names":[],"mappings":"AAAA;EACE,wEAAwE;EACxE,yCAAyC;EACzC
|
|
1
|
+
{"version":3,"sources":["../../../src/moj/core/_moj-frontend-properties.scss"],"names":[],"mappings":"AAAA;EACE,wEAAwE;EACxE,yCAAyC;EACzC,sCAAqC;AACvC","file":"_moj-frontend-properties.scss","sourcesContent":[":root {\n // This variable is automatically overwritten during builds and releases.\n // It doesn't need to be updated manually.\n --moj-frontend-version: \"development\";\n}\n"]}
|