govuk_publishing_components 44.0.0 → 44.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/images/govuk_publishing_components/crests/dbt_crest_18px_x2.png +0 -0
- data/app/assets/images/govuk_publishing_components/crests/ho_crest_18px_x2.png +0 -0
- data/app/assets/images/govuk_publishing_components/crests/mod_crest_18px_x2.png +0 -0
- data/app/assets/images/govuk_publishing_components/crests/org_crest_18px_x2.png +0 -0
- data/app/assets/images/govuk_publishing_components/crests/portcullis_18px_x2.png +0 -0
- data/app/assets/images/govuk_publishing_components/crests/so_crest_18px_x2.png +0 -0
- data/app/assets/images/govuk_publishing_components/crests/wales_crest_18px_x2.png +0 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +336 -225
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +334 -226
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.mjs +3 -0
- data/node_modules/govuk-frontend/dist/govuk/all.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest.svg +1 -0
- data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +1 -1
- data/node_modules/govuk-frontend/dist/govuk/common/index.mjs +21 -1
- data/node_modules/govuk-frontend/dist/govuk/common/index.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/_index.scss +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +92 -26
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +92 -26
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs +12 -21
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs +6 -16
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +89 -23
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +89 -23
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +10 -19
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js +113 -47
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs +113 -47
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs +7 -16
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss +7 -2
- data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs +6 -16
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +87 -21
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +87 -21
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs +7 -16
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss +8 -10
- data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss +8 -0
- data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/fixtures.json +12 -0
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js +87 -21
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs +87 -21
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs +7 -16
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-full-width-border.html +24 -0
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs +6 -16
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +89 -23
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +89 -23
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs +9 -18
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js +113 -47
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs +113 -47
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs +7 -16
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/README.md +15 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss +168 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_service-navigation.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_service-navigation.scss.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/fixtures.json +464 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/macro-options.json +138 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/macro.njk +3 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +249 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs +241 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs +85 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-default.html +57 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-html-navigation-items.html +49 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-large-navigation.html +153 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-long-service-name.html +20 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-navigation-with-a-current-item.html +58 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-navigation-with-an-active-item.html +58 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-non-link-navigation-items.html +49 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-link.html +20 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-name-and-navigation.html +63 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-name.html +18 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template.njk +102 -0
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js +93 -26
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs +93 -26
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs +13 -21
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js +93 -27
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs +93 -27
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs +13 -22
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss +4 -3
- data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs +16 -3
- data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend-component.mjs +49 -5
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend-component.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css +2 -2
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/init.mjs +72 -10
- data/node_modules/govuk-frontend/dist/govuk/init.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +3 -0
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss.map +1 -1
- data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +5 -1
- data/node_modules/govuk-frontend/package.json +8 -8
- metadata +29 -4
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest-2x.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest.png +0 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tabs.bundle.mjs","sources":["../../../../src/govuk/common/index.mjs","../../../../src/govuk/errors/index.mjs","../../../../src/govuk/govuk-frontend-component.mjs","../../../../src/govuk/components/tabs/tabs.mjs"],"sourcesContent":["import { normaliseString } from './normalise-string.mjs'\n\n/**\n * Common helpers which do not require polyfill.\n *\n * IMPORTANT: If a helper require a polyfill, please isolate it in its own module\n * so that the polyfill can be properly tree-shaken and does not burden\n * the components that do not need that helper\n */\n\n/**\n * Config merging function\n *\n * Takes any number of objects and combines them together, with\n * greatest priority on the LAST item passed in.\n *\n * @internal\n * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge\n * @returns {{ [key: string]: unknown }} A merged config object\n */\nexport function mergeConfigs(...configObjects) {\n // Start with an empty object as our base\n /** @type {{ [key: string]: unknown }} */\n const formattedConfigObject = {}\n\n // Loop through each of the passed objects\n for (const configObject of configObjects) {\n for (const key of Object.keys(configObject)) {\n const option = formattedConfigObject[key]\n const override = configObject[key]\n\n // Push their keys one-by-one into formattedConfigObject. Any duplicate\n // keys with object values will be merged, otherwise the new value will\n // override the existing value.\n if (isObject(option) && isObject(override)) {\n // @ts-expect-error Index signature for type 'string' is missing\n formattedConfigObject[key] = mergeConfigs(option, override)\n } else {\n // Apply override\n formattedConfigObject[key] = override\n }\n }\n }\n\n return formattedConfigObject\n}\n\n/**\n * Extracts keys starting with a particular namespace from dataset ('data-*')\n * object, removing the namespace in the process, normalising all values\n *\n * @internal\n * @param {{ schema: Schema }} Component - Component class\n * @param {DOMStringMap} dataset - The object to extract key-value pairs from\n * @param {string} namespace - The namespace to filter keys with\n * @returns {ObjectNested | undefined} Nested object with dot-separated key namespace removed\n */\nexport function extractConfigByNamespace(Component, dataset, namespace) {\n const property = Component.schema.properties[namespace]\n\n // Only extract configs for object schema properties\n if (property?.type !== 'object') {\n return\n }\n\n // Add default empty config\n const newObject = {\n [namespace]: /** @type {ObjectNested} */ ({})\n }\n\n for (const [key, value] of Object.entries(dataset)) {\n /** @type {ObjectNested | ObjectNested[NestedKey]} */\n let current = newObject\n\n // Split the key into parts, using . as our namespace separator\n const keyParts = key.split('.')\n\n /**\n * Create new level per part\n *\n * e.g. 'i18n.textareaDescription.other' becomes\n * `{ i18n: { textareaDescription: { other } } }`\n */\n for (const [index, name] of keyParts.entries()) {\n if (typeof current === 'object') {\n // Drop down to nested object until the last part\n if (index < keyParts.length - 1) {\n // New nested object (optionally) replaces existing value\n if (!isObject(current[name])) {\n current[name] = {}\n }\n\n // Drop down into new or existing nested object\n current = current[name]\n } else if (key !== namespace) {\n // Normalised value (optionally) replaces existing value\n current[name] = normaliseString(value)\n }\n }\n }\n }\n\n return newObject[namespace]\n}\n\n/**\n * Get hash fragment from URL\n *\n * Extract the hash fragment (everything after the hash) from a URL,\n * but not including the hash symbol\n *\n * @private\n * @param {string} url - URL\n * @returns {string | undefined} Fragment from URL, without the hash\n */\nexport function getFragmentFromUrl(url) {\n if (!url.includes('#')) {\n return undefined\n }\n\n return url.split('#').pop()\n}\n\n/**\n * Get GOV.UK Frontend breakpoint value from CSS custom property\n *\n * @private\n * @param {string} name - Breakpoint name\n * @returns {{ property: string, value?: string }} Breakpoint object\n */\nexport function getBreakpoint(name) {\n const property = `--govuk-frontend-breakpoint-${name}`\n\n // Get value from `<html>` with breakpoints on CSS :root\n const value = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(property)\n\n return {\n property,\n value: value || undefined\n }\n}\n\n/**\n * Move focus to element\n *\n * Sets tabindex to -1 to make the element programmatically focusable,\n * but removes it on blur as the element doesn't need to be focused again.\n *\n * @private\n * @template {HTMLElement} FocusElement\n * @param {FocusElement} $element - HTML element\n * @param {object} [options] - Handler options\n * @param {function(this: FocusElement): void} [options.onBeforeFocus] - Callback before focus\n * @param {function(this: FocusElement): void} [options.onBlur] - Callback on blur\n */\nexport function setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute('tabindex')\n\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1')\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener('blur', onBlur, { once: true })\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n options.onBlur?.call($element)\n\n if (!isFocusable) {\n $element.removeAttribute('tabindex')\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener('focus', onFocus, { once: true })\n\n // Focus element\n options.onBeforeFocus?.call($element)\n $element.focus()\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @internal\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nexport function isSupported($scope = document.body) {\n if (!$scope) {\n return false\n }\n\n return $scope.classList.contains('govuk-frontend-supported')\n}\n\n/**\n * Validate component config by schema\n *\n * Follows limited examples in JSON schema for wider support in future\n *\n * {@link https://ajv.js.org/json-schema.html#compound-keywords}\n * {@link https://ajv.js.org/packages/ajv-errors.html#single-message}\n *\n * @internal\n * @param {Schema} schema - Config schema\n * @param {{ [key: string]: unknown }} config - Component config\n * @returns {string[]} List of validation errors\n */\nexport function validateConfig(schema, config) {\n const validationErrors = []\n\n // Check errors for each schema\n for (const [name, conditions] of Object.entries(schema)) {\n const errors = []\n\n // Check errors for each schema condition\n if (Array.isArray(conditions)) {\n for (const { required, errorMessage } of conditions) {\n if (!required.every((key) => !!config[key])) {\n errors.push(errorMessage) // Missing config key value\n }\n }\n\n // Check one condition passes or add errors\n if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {\n validationErrors.push(...errors)\n }\n }\n }\n\n return validationErrors\n}\n\n/**\n * Check for an array\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an array\n */\nfunction isArray(option) {\n return Array.isArray(option)\n}\n\n/**\n * Check for an object\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an object\n */\nfunction isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option)\n}\n\n/**\n * Schema for component config\n *\n * @typedef {object} Schema\n * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties\n * @property {SchemaCondition[]} [anyOf] - List of schema conditions\n */\n\n/**\n * Schema property for component config\n *\n * @typedef {object} SchemaProperty\n * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type\n */\n\n/**\n * Schema condition for component config\n *\n * @typedef {object} SchemaCondition\n * @property {string[]} required - List of required config fields\n * @property {string} errorMessage - Error message when required config fields not provided\n */\n\n/**\n * @internal\n * @typedef {keyof ObjectNested} NestedKey\n * @typedef {{ [key: string]: string | boolean | number | ObjectNested | undefined }} ObjectNested\n */\n","/**\n * GOV.UK Frontend error\n *\n * A base class for `Error`s thrown by GOV.UK Frontend.\n *\n * It is meant to be extended into specific types of errors\n * to be thrown by our code.\n *\n * @example\n * ```js\n * class MissingRootError extends GOVUKFrontendError {\n * // Setting an explicit name is important as extending the class will not\n * // set a new `name` on the subclass. The `name` property is important\n * // to ensure intelligible error names even if the class name gets\n * // mangled by a minifier\n * name = \"MissingRootError\"\n * }\n * ```\n * @abstract\n */\nexport class GOVUKFrontendError extends Error {\n name = 'GOVUKFrontendError'\n}\n\n/**\n * Indicates that GOV.UK Frontend is not supported\n */\nexport class SupportError extends GOVUKFrontendError {\n name = 'SupportError'\n\n /**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n */\n constructor($scope = document.body) {\n const supportMessage =\n 'noModule' in HTMLScriptElement.prototype\n ? 'GOV.UK Frontend initialised without `<body class=\"govuk-frontend-supported\">` from template `<script>` snippet'\n : 'GOV.UK Frontend is not supported in this browser'\n\n super(\n $scope\n ? supportMessage\n : 'GOV.UK Frontend initialised without `<script type=\"module\">`'\n )\n }\n}\n\n/**\n * Indicates that a component has received an illegal configuration\n */\nexport class ConfigError extends GOVUKFrontendError {\n name = 'ConfigError'\n}\n\n/**\n * Indicates an issue with an element (possibly `null` or `undefined`)\n */\nexport class ElementError extends GOVUKFrontendError {\n name = 'ElementError'\n\n /**\n * @internal\n * @overload\n * @param {string} message - Element error message\n */\n\n /**\n * @internal\n * @overload\n * @param {ElementErrorOptions} options - Element error options\n */\n\n /**\n * @internal\n * @param {string | ElementErrorOptions} messageOrOptions - Element error message or options\n */\n constructor(messageOrOptions) {\n let message = typeof messageOrOptions === 'string' ? messageOrOptions : ''\n\n // Build message from options\n if (typeof messageOrOptions === 'object') {\n const { componentName, identifier, element, expectedType } =\n messageOrOptions\n\n // Add prefix and identifier\n message = `${componentName}: ${identifier}`\n\n // Append reason\n message += element\n ? ` is not of type ${expectedType ?? 'HTMLElement'}`\n : ' not found'\n }\n\n super(message)\n }\n}\n\n/**\n * Element error options\n *\n * @internal\n * @typedef {object} ElementErrorOptions\n * @property {string} componentName - The name of the component throwing the error\n * @property {string} identifier - An identifier that'll let the user understand which element has an error. This is whatever makes the most sense\n * @property {Element | null} [element] - The element in error\n * @property {string} [expectedType] - The type that was expected for the identifier\n */\n","import { isSupported } from './common/index.mjs'\nimport { SupportError } from './errors/index.mjs'\n\n/**\n * Base Component class\n *\n * Centralises the behaviours shared by our components\n *\n * @internal\n * @abstract\n */\nexport class GOVUKFrontendComponent {\n /**\n * Constructs a new component, validating that GOV.UK Frontend is supported\n *\n * @internal\n */\n constructor() {\n this.checkSupport()\n }\n\n /**\n * Validates whether GOV.UK Frontend is supported\n *\n * @private\n * @throws {SupportError} when GOV.UK Frontend is not supported\n */\n checkSupport() {\n if (!isSupported()) {\n throw new SupportError()\n }\n }\n}\n","import { getBreakpoint, getFragmentFromUrl } from '../../common/index.mjs'\nimport { ElementError } from '../../errors/index.mjs'\nimport { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'\n\n/**\n * Tabs component\n *\n * @preserve\n */\nexport class Tabs extends GOVUKFrontendComponent {\n /** @private */\n $module\n\n /** @private */\n $tabs\n\n /** @private */\n $tabList\n\n /** @private */\n $tabListItems\n\n /** @private */\n jsHiddenClass = 'govuk-tabs__panel--hidden'\n\n /** @private */\n changingHash = false\n\n /** @private */\n boundTabClick\n\n /** @private */\n boundTabKeydown\n\n /** @private */\n boundOnHashChange\n\n /**\n * @private\n * @type {MediaQueryList | null}\n */\n mql = null\n\n /**\n * @param {Element | null} $module - HTML element to use for tabs\n */\n constructor($module) {\n super()\n\n if (!$module) {\n throw new ElementError({\n componentName: 'Tabs',\n element: $module,\n identifier: 'Root element (`$module`)'\n })\n }\n\n const $tabs = $module.querySelectorAll('a.govuk-tabs__tab')\n if (!$tabs.length) {\n throw new ElementError({\n componentName: 'Tabs',\n identifier: 'Links (`<a class=\"govuk-tabs__tab\">`)'\n })\n }\n\n this.$module = $module\n this.$tabs = $tabs\n\n // Save bound functions so we can remove event listeners during teardown\n this.boundTabClick = this.onTabClick.bind(this)\n this.boundTabKeydown = this.onTabKeydown.bind(this)\n this.boundOnHashChange = this.onHashChange.bind(this)\n\n const $tabList = this.$module.querySelector('.govuk-tabs__list')\n const $tabListItems = this.$module.querySelectorAll(\n 'li.govuk-tabs__list-item'\n )\n\n if (!$tabList) {\n throw new ElementError({\n componentName: 'Tabs',\n identifier: 'List (`<ul class=\"govuk-tabs__list\">`)'\n })\n }\n\n if (!$tabListItems.length) {\n throw new ElementError({\n componentName: 'Tabs',\n identifier: 'List items (`<li class=\"govuk-tabs__list-item\">`)'\n })\n }\n\n this.$tabList = $tabList\n this.$tabListItems = $tabListItems\n\n this.setupResponsiveChecks()\n }\n\n /**\n * Setup viewport resize check\n *\n * @private\n */\n setupResponsiveChecks() {\n const breakpoint = getBreakpoint('tablet')\n\n if (!breakpoint.value) {\n throw new ElementError({\n componentName: 'Tabs',\n identifier: `CSS custom property (\\`${breakpoint.property}\\`) on pseudo-class \\`:root\\``\n })\n }\n\n // Media query list for GOV.UK Frontend tablet breakpoint\n this.mql = window.matchMedia(`(min-width: ${breakpoint.value})`)\n\n // MediaQueryList.addEventListener isn't supported by Safari < 14 so we need\n // to be able to fall back to the deprecated MediaQueryList.addListener\n if ('addEventListener' in this.mql) {\n this.mql.addEventListener('change', () => this.checkMode())\n } else {\n // @ts-expect-error Property 'addListener' does not exist\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n this.mql.addListener(() => this.checkMode())\n }\n\n this.checkMode()\n }\n\n /**\n * Setup or teardown handler for viewport resize check\n *\n * @private\n */\n checkMode() {\n if (this.mql?.matches) {\n this.setup()\n } else {\n this.teardown()\n }\n }\n\n /**\n * Setup tab component\n *\n * @private\n */\n setup() {\n this.$tabList.setAttribute('role', 'tablist')\n\n this.$tabListItems.forEach(($item) => {\n $item.setAttribute('role', 'presentation')\n })\n\n this.$tabs.forEach(($tab) => {\n // Set HTML attributes\n this.setAttributes($tab)\n\n // Handle events\n $tab.addEventListener('click', this.boundTabClick, true)\n $tab.addEventListener('keydown', this.boundTabKeydown, true)\n\n // Remove old active panels\n this.hideTab($tab)\n })\n\n // Show either the active tab according to the URL's hash or the first tab\n const $activeTab = this.getTab(window.location.hash) ?? this.$tabs[0]\n\n this.showTab($activeTab)\n\n // Handle hashchange events\n window.addEventListener('hashchange', this.boundOnHashChange, true)\n }\n\n /**\n * Teardown tab component\n *\n * @private\n */\n teardown() {\n this.$tabList.removeAttribute('role')\n\n this.$tabListItems.forEach(($item) => {\n $item.removeAttribute('role')\n })\n\n this.$tabs.forEach(($tab) => {\n // Remove events\n $tab.removeEventListener('click', this.boundTabClick, true)\n $tab.removeEventListener('keydown', this.boundTabKeydown, true)\n\n // Unset HTML attributes\n this.unsetAttributes($tab)\n })\n\n // Remove hashchange event handler\n window.removeEventListener('hashchange', this.boundOnHashChange, true)\n }\n\n /**\n * Handle hashchange event\n *\n * @private\n * @returns {void | undefined} Returns void, or undefined when prevented\n */\n onHashChange() {\n const hash = window.location.hash\n const $tabWithHash = this.getTab(hash)\n if (!$tabWithHash) {\n return\n }\n\n // Prevent changing the hash\n if (this.changingHash) {\n this.changingHash = false\n return\n }\n\n // Show either the active tab according to the URL's hash or the first tab\n const $previousTab = this.getCurrentTab()\n if (!$previousTab) {\n return\n }\n\n this.hideTab($previousTab)\n this.showTab($tabWithHash)\n $tabWithHash.focus()\n }\n\n /**\n * Hide panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n hideTab($tab) {\n this.unhighlightTab($tab)\n this.hidePanel($tab)\n }\n\n /**\n * Show panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n showTab($tab) {\n this.highlightTab($tab)\n this.showPanel($tab)\n }\n\n /**\n * Get tab link by hash\n *\n * @private\n * @param {string} hash - Hash fragment including #\n * @returns {HTMLAnchorElement | null} Tab link\n */\n getTab(hash) {\n return this.$module.querySelector(`a.govuk-tabs__tab[href=\"${hash}\"]`)\n }\n\n /**\n * Set tab link and panel attributes\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n setAttributes($tab) {\n const panelId = getFragmentFromUrl($tab.href)\n if (!panelId) {\n return\n }\n\n // Set tab attributes\n $tab.setAttribute('id', `tab_${panelId}`)\n $tab.setAttribute('role', 'tab')\n $tab.setAttribute('aria-controls', panelId)\n $tab.setAttribute('aria-selected', 'false')\n $tab.setAttribute('tabindex', '-1')\n\n // Set panel attributes\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.setAttribute('role', 'tabpanel')\n $panel.setAttribute('aria-labelledby', $tab.id)\n $panel.classList.add(this.jsHiddenClass)\n }\n\n /**\n * Unset tab link and panel attributes\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n unsetAttributes($tab) {\n // unset tab attributes\n $tab.removeAttribute('id')\n $tab.removeAttribute('role')\n $tab.removeAttribute('aria-controls')\n $tab.removeAttribute('aria-selected')\n $tab.removeAttribute('tabindex')\n\n // unset panel attributes\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.removeAttribute('role')\n $panel.removeAttribute('aria-labelledby')\n $panel.classList.remove(this.jsHiddenClass)\n }\n\n /**\n * Handle tab link clicks\n *\n * @private\n * @param {MouseEvent} event - Mouse click event\n * @returns {void} Returns void\n */\n onTabClick(event) {\n const $currentTab = this.getCurrentTab()\n const $nextTab = event.currentTarget\n\n if (!$currentTab || !($nextTab instanceof HTMLAnchorElement)) {\n return\n }\n\n event.preventDefault()\n\n this.hideTab($currentTab)\n this.showTab($nextTab)\n this.createHistoryEntry($nextTab)\n }\n\n /**\n * Update browser URL hash fragment for tab\n *\n * - Allows back/forward to navigate tabs\n * - Avoids page jump when hash changes\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n createHistoryEntry($tab) {\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n // Save and restore the id so the page doesn't jump when a user clicks a tab\n // (which changes the hash)\n const panelId = $panel.id\n $panel.id = ''\n this.changingHash = true\n window.location.hash = panelId\n $panel.id = panelId\n }\n\n /**\n * Handle tab keydown event\n *\n * - Press right arrow for next tab\n * - Press left arrow for previous tab\n *\n * @private\n * @param {KeyboardEvent} event - Keydown event\n */\n onTabKeydown(event) {\n switch (event.key) {\n // 'Left' and 'Right' required for Edge 16 support.\n case 'ArrowLeft':\n case 'Left':\n this.activatePreviousTab()\n event.preventDefault()\n break\n case 'ArrowRight':\n case 'Right':\n this.activateNextTab()\n event.preventDefault()\n break\n }\n }\n\n /**\n * Activate next tab\n *\n * @private\n */\n activateNextTab() {\n const $currentTab = this.getCurrentTab()\n if (!$currentTab?.parentElement) {\n return\n }\n\n const $nextTabListItem = $currentTab.parentElement.nextElementSibling\n if (!$nextTabListItem) {\n return\n }\n\n const $nextTab = $nextTabListItem.querySelector('a.govuk-tabs__tab')\n if (!$nextTab) {\n return\n }\n\n this.hideTab($currentTab)\n this.showTab($nextTab)\n $nextTab.focus()\n this.createHistoryEntry($nextTab)\n }\n\n /**\n * Activate previous tab\n *\n * @private\n */\n activatePreviousTab() {\n const $currentTab = this.getCurrentTab()\n if (!$currentTab?.parentElement) {\n return\n }\n\n const $previousTabListItem =\n $currentTab.parentElement.previousElementSibling\n if (!$previousTabListItem) {\n return\n }\n\n const $previousTab = $previousTabListItem.querySelector('a.govuk-tabs__tab')\n if (!$previousTab) {\n return\n }\n\n this.hideTab($currentTab)\n this.showTab($previousTab)\n $previousTab.focus()\n this.createHistoryEntry($previousTab)\n }\n\n /**\n * Get tab panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n * @returns {Element | null} Tab panel\n */\n getPanel($tab) {\n const panelId = getFragmentFromUrl($tab.href)\n if (!panelId) {\n return null\n }\n\n return this.$module.querySelector(`#${panelId}`)\n }\n\n /**\n * Show tab panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n showPanel($tab) {\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.classList.remove(this.jsHiddenClass)\n }\n\n /**\n * Hide tab panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n hidePanel($tab) {\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.classList.add(this.jsHiddenClass)\n }\n\n /**\n * Unset 'selected' state for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n unhighlightTab($tab) {\n if (!$tab.parentElement) {\n return\n }\n\n $tab.setAttribute('aria-selected', 'false')\n $tab.parentElement.classList.remove('govuk-tabs__list-item--selected')\n $tab.setAttribute('tabindex', '-1')\n }\n\n /**\n * Set 'selected' state for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n highlightTab($tab) {\n if (!$tab.parentElement) {\n return\n }\n\n $tab.setAttribute('aria-selected', 'true')\n $tab.parentElement.classList.add('govuk-tabs__list-item--selected')\n $tab.setAttribute('tabindex', '0')\n }\n\n /**\n * Get current tab link\n *\n * @private\n * @returns {HTMLAnchorElement | null} Tab link\n */\n getCurrentTab() {\n return this.$module.querySelector(\n '.govuk-tabs__list-item--selected a.govuk-tabs__tab'\n )\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-tabs'\n}\n"],"names":["getFragmentFromUrl","url","includes","undefined","split","pop","getBreakpoint","name","property","value","window","getComputedStyle","document","documentElement","getPropertyValue","isSupported","$scope","body","classList","contains","GOVUKFrontendError","Error","constructor","args","SupportError","supportMessage","HTMLScriptElement","prototype","ElementError","messageOrOptions","message","componentName","identifier","element","expectedType","GOVUKFrontendComponent","checkSupport","Tabs","$module","$tabs","$tabList","$tabListItems","jsHiddenClass","changingHash","boundTabClick","boundTabKeydown","boundOnHashChange","mql","querySelectorAll","length","onTabClick","bind","onTabKeydown","onHashChange","querySelector","setupResponsiveChecks","breakpoint","matchMedia","addEventListener","checkMode","addListener","_this$mql","matches","setup","teardown","_this$getTab","setAttribute","forEach","$item","$tab","setAttributes","hideTab","$activeTab","getTab","location","hash","showTab","removeAttribute","removeEventListener","unsetAttributes","$tabWithHash","$previousTab","getCurrentTab","focus","unhighlightTab","hidePanel","highlightTab","showPanel","panelId","href","$panel","getPanel","id","add","remove","event","$currentTab","$nextTab","currentTarget","HTMLAnchorElement","preventDefault","createHistoryEntry","key","activatePreviousTab","activateNextTab","parentElement","$nextTabListItem","nextElementSibling","$previousTabListItem","previousElementSibling","moduleName"],"mappings":"AAmHO,SAASA,kBAAkBA,CAACC,GAAG,EAAE;AACtC,EAAA,IAAI,CAACA,GAAG,CAACC,QAAQ,CAAC,GAAG,CAAC,EAAE;AACtB,IAAA,OAAOC,SAAS,CAAA;AAClB,G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AAa,CAACvF,SAAS,CAAC4E,MAAM,CAAC,iCAAiC,CAAC,CAAA;AACtEzB,IAAAA,IAAI,CAACH,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACrC,GAAA;EAQAoB,YAAYA,CAACjB,IAAI,EAAE;AACjB,IAAA,IAAI,CAACA,IAAI,CAACoC,aAAa,EAAE;AACvB,MAAA,OAAA;AACF,KAAA;AAEApC,IAAAA,IAAI,CAACH,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAA;IAC1CG,IAAI,CAACoC,aAAa,CAACvF,SAAS,CAAC2E,GAAG,CAAC,iCAAiC,CAAC,CAAA;AACnExB,IAAAA,IAAI,CAACH,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;AACpC,GAAA;AAQAgB,EAAAA,aAAaA,GAAG;AACd,IAAA,OAAO,IAAI,CAAC5C,OAAO,CAACgB,aAAa,CAC/B,oDACF,CAAC,CAAA;AACH,GAAA;AAMF,CAAA;AAjhBajB,IAAI,CAghBRyE,UAAU,GAAG,YAAY;;;;"}
|
1
|
+
{"version":3,"file":"tabs.bundle.mjs","sources":["../../../../src/govuk/common/index.mjs","../../../../src/govuk/errors/index.mjs","../../../../src/govuk/govuk-frontend-component.mjs","../../../../src/govuk/components/tabs/tabs.mjs"],"sourcesContent":["import { normaliseString } from './normalise-string.mjs'\n\n/**\n * Common helpers which do not require polyfill.\n *\n * IMPORTANT: If a helper require a polyfill, please isolate it in its own module\n * so that the polyfill can be properly tree-shaken and does not burden\n * the components that do not need that helper\n */\n\n/**\n * Config merging function\n *\n * Takes any number of objects and combines them together, with\n * greatest priority on the LAST item passed in.\n *\n * @internal\n * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge\n * @returns {{ [key: string]: unknown }} A merged config object\n */\nexport function mergeConfigs(...configObjects) {\n // Start with an empty object as our base\n /** @type {{ [key: string]: unknown }} */\n const formattedConfigObject = {}\n\n // Loop through each of the passed objects\n for (const configObject of configObjects) {\n for (const key of Object.keys(configObject)) {\n const option = formattedConfigObject[key]\n const override = configObject[key]\n\n // Push their keys one-by-one into formattedConfigObject. Any duplicate\n // keys with object values will be merged, otherwise the new value will\n // override the existing value.\n if (isObject(option) && isObject(override)) {\n // @ts-expect-error Index signature for type 'string' is missing\n formattedConfigObject[key] = mergeConfigs(option, override)\n } else {\n // Apply override\n formattedConfigObject[key] = override\n }\n }\n }\n\n return formattedConfigObject\n}\n\n/**\n * Extracts keys starting with a particular namespace from dataset ('data-*')\n * object, removing the namespace in the process, normalising all values\n *\n * @internal\n * @param {{ schema: Schema }} Component - Component class\n * @param {DOMStringMap} dataset - The object to extract key-value pairs from\n * @param {string} namespace - The namespace to filter keys with\n * @returns {ObjectNested | undefined} Nested object with dot-separated key namespace removed\n */\nexport function extractConfigByNamespace(Component, dataset, namespace) {\n const property = Component.schema.properties[namespace]\n\n // Only extract configs for object schema properties\n if (property?.type !== 'object') {\n return\n }\n\n // Add default empty config\n const newObject = {\n [namespace]: /** @type {ObjectNested} */ ({})\n }\n\n for (const [key, value] of Object.entries(dataset)) {\n /** @type {ObjectNested | ObjectNested[NestedKey]} */\n let current = newObject\n\n // Split the key into parts, using . as our namespace separator\n const keyParts = key.split('.')\n\n /**\n * Create new level per part\n *\n * e.g. 'i18n.textareaDescription.other' becomes\n * `{ i18n: { textareaDescription: { other } } }`\n */\n for (const [index, name] of keyParts.entries()) {\n if (typeof current === 'object') {\n // Drop down to nested object until the last part\n if (index < keyParts.length - 1) {\n // New nested object (optionally) replaces existing value\n if (!isObject(current[name])) {\n current[name] = {}\n }\n\n // Drop down into new or existing nested object\n current = current[name]\n } else if (key !== namespace) {\n // Normalised value (optionally) replaces existing value\n current[name] = normaliseString(value)\n }\n }\n }\n }\n\n return newObject[namespace]\n}\n\n/**\n * Get hash fragment from URL\n *\n * Extract the hash fragment (everything after the hash) from a URL,\n * but not including the hash symbol\n *\n * @private\n * @param {string} url - URL\n * @returns {string | undefined} Fragment from URL, without the hash\n */\nexport function getFragmentFromUrl(url) {\n if (!url.includes('#')) {\n return undefined\n }\n\n return url.split('#').pop()\n}\n\n/**\n * Get GOV.UK Frontend breakpoint value from CSS custom property\n *\n * @private\n * @param {string} name - Breakpoint name\n * @returns {{ property: string, value?: string }} Breakpoint object\n */\nexport function getBreakpoint(name) {\n const property = `--govuk-frontend-breakpoint-${name}`\n\n // Get value from `<html>` with breakpoints on CSS :root\n const value = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(property)\n\n return {\n property,\n value: value || undefined\n }\n}\n\n/**\n * Move focus to element\n *\n * Sets tabindex to -1 to make the element programmatically focusable,\n * but removes it on blur as the element doesn't need to be focused again.\n *\n * @private\n * @template {HTMLElement} FocusElement\n * @param {FocusElement} $element - HTML element\n * @param {object} [options] - Handler options\n * @param {function(this: FocusElement): void} [options.onBeforeFocus] - Callback before focus\n * @param {function(this: FocusElement): void} [options.onBlur] - Callback on blur\n */\nexport function setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute('tabindex')\n\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1')\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener('blur', onBlur, { once: true })\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n options.onBlur?.call($element)\n\n if (!isFocusable) {\n $element.removeAttribute('tabindex')\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener('focus', onFocus, { once: true })\n\n // Focus element\n options.onBeforeFocus?.call($element)\n $element.focus()\n}\n\n/**\n * Checks if component is already initialised\n *\n * @internal\n * @param {Element} $root - HTML element to be checked\n * @param {string} moduleName - name of component module\n * @returns {boolean} Whether component is already initialised\n */\nexport function isInitialised($root, moduleName) {\n return (\n $root instanceof HTMLElement &&\n $root.hasAttribute(`data-${moduleName}-init`)\n )\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nexport function isSupported($scope = document.body) {\n if (!$scope) {\n return false\n }\n\n return $scope.classList.contains('govuk-frontend-supported')\n}\n\n/**\n * Validate component config by schema\n *\n * Follows limited examples in JSON schema for wider support in future\n *\n * {@link https://ajv.js.org/json-schema.html#compound-keywords}\n * {@link https://ajv.js.org/packages/ajv-errors.html#single-message}\n *\n * @internal\n * @param {Schema} schema - Config schema\n * @param {{ [key: string]: unknown }} config - Component config\n * @returns {string[]} List of validation errors\n */\nexport function validateConfig(schema, config) {\n const validationErrors = []\n\n // Check errors for each schema\n for (const [name, conditions] of Object.entries(schema)) {\n const errors = []\n\n // Check errors for each schema condition\n if (Array.isArray(conditions)) {\n for (const { required, errorMessage } of conditions) {\n if (!required.every((key) => !!config[key])) {\n errors.push(errorMessage) // Missing config key value\n }\n }\n\n // Check one condition passes or add errors\n if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {\n validationErrors.push(...errors)\n }\n }\n }\n\n return validationErrors\n}\n\n/**\n * Check for an array\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an array\n */\nfunction isArray(option) {\n return Array.isArray(option)\n}\n\n/**\n * Check for an object\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an object\n */\nfunction isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option)\n}\n\n/**\n * Format error message\n *\n * @internal\n * @param {ComponentWithModuleName} Component - Component that threw the error\n * @param {string} message - Error message\n * @returns {string} - Formatted error message\n */\nexport function formatErrorMessage(Component, message) {\n return `${Component.moduleName}: ${message}`\n}\n\n/**\n * Schema for component config\n *\n * @typedef {object} Schema\n * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties\n * @property {SchemaCondition[]} [anyOf] - List of schema conditions\n */\n\n/**\n * Schema property for component config\n *\n * @typedef {object} SchemaProperty\n * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type\n */\n\n/**\n * Schema condition for component config\n *\n * @typedef {object} SchemaCondition\n * @property {string[]} required - List of required config fields\n * @property {string} errorMessage - Error message when required config fields not provided\n */\n\n/**\n * @internal\n * @typedef {keyof ObjectNested} NestedKey\n * @typedef {{ [key: string]: string | boolean | number | ObjectNested | undefined }} ObjectNested\n */\n\n/* eslint-disable jsdoc/valid-types --\n * `{new(...args: any[] ): object}` is not recognised as valid\n * https://github.com/gajus/eslint-plugin-jsdoc/issues/145#issuecomment-1308722878\n * https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/131\n **/\n\n/**\n * @typedef ComponentWithModuleName\n * @property {string} moduleName - Name of the component\n */\n\n/* eslint-enable jsdoc/valid-types */\n","import { formatErrorMessage } from '../common/index.mjs'\n\n/**\n * GOV.UK Frontend error\n *\n * A base class for `Error`s thrown by GOV.UK Frontend.\n *\n * It is meant to be extended into specific types of errors\n * to be thrown by our code.\n *\n * @example\n * ```js\n * class MissingRootError extends GOVUKFrontendError {\n * // Setting an explicit name is important as extending the class will not\n * // set a new `name` on the subclass. The `name` property is important\n * // to ensure intelligible error names even if the class name gets\n * // mangled by a minifier\n * name = \"MissingRootError\"\n * }\n * ```\n * @virtual\n */\nexport class GOVUKFrontendError extends Error {\n name = 'GOVUKFrontendError'\n}\n\n/**\n * Indicates that GOV.UK Frontend is not supported\n */\nexport class SupportError extends GOVUKFrontendError {\n name = 'SupportError'\n\n /**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n */\n constructor($scope = document.body) {\n const supportMessage =\n 'noModule' in HTMLScriptElement.prototype\n ? 'GOV.UK Frontend initialised without `<body class=\"govuk-frontend-supported\">` from template `<script>` snippet'\n : 'GOV.UK Frontend is not supported in this browser'\n\n super(\n $scope\n ? supportMessage\n : 'GOV.UK Frontend initialised without `<script type=\"module\">`'\n )\n }\n}\n\n/**\n * Indicates that a component has received an illegal configuration\n */\nexport class ConfigError extends GOVUKFrontendError {\n name = 'ConfigError'\n}\n\n/**\n * Indicates an issue with an element (possibly `null` or `undefined`)\n */\nexport class ElementError extends GOVUKFrontendError {\n name = 'ElementError'\n\n /**\n * @internal\n * @overload\n * @param {string} message - Element error message\n */\n\n /**\n * @internal\n * @overload\n * @param {ElementErrorOptions} options - Element error options\n */\n\n /**\n * @internal\n * @param {string | ElementErrorOptions} messageOrOptions - Element error message or options\n */\n constructor(messageOrOptions) {\n let message = typeof messageOrOptions === 'string' ? messageOrOptions : ''\n\n // Build message from options\n if (typeof messageOrOptions === 'object') {\n const { component, identifier, element, expectedType } = messageOrOptions\n\n message = identifier\n\n // Append reason\n message += element\n ? ` is not of type ${expectedType ?? 'HTMLElement'}`\n : ' not found'\n\n message = formatErrorMessage(component, message)\n }\n\n super(message)\n }\n}\n\n/**\n * Indicates that a component is already initialised\n */\nexport class InitError extends GOVUKFrontendError {\n name = 'InitError'\n\n /**\n * @internal\n * @param {ComponentWithModuleName | string} componentOrMessage - name of the component module\n */\n constructor(componentOrMessage) {\n const message =\n typeof componentOrMessage === 'string'\n ? componentOrMessage\n : formatErrorMessage(\n componentOrMessage,\n `Root element (\\`$root\\`) already initialised`\n )\n\n super(message)\n }\n}\n\n/**\n * Element error options\n *\n * @internal\n * @typedef {object} ElementErrorOptions\n * @property {string} identifier - An identifier that'll let the user understand which element has an error. This is whatever makes the most sense\n * @property {Element | null} [element] - The element in error\n * @property {string} [expectedType] - The type that was expected for the identifier\n * @property {ComponentWithModuleName} component - Component throwing the error\n */\n\n/**\n * @typedef {import('../common/index.mjs').ComponentWithModuleName} ComponentWithModuleName\n */\n","import { isInitialised, isSupported } from './common/index.mjs'\nimport { ElementError, InitError, SupportError } from './errors/index.mjs'\n\n/**\n * Base Component class\n *\n * Centralises the behaviours shared by our components\n *\n * @virtual\n * @template {Element} [RootElementType=HTMLElement]\n */\nexport class GOVUKFrontendComponent {\n /**\n * @type {typeof Element}\n */\n static elementType = HTMLElement\n\n // allows Typescript user to work around the lack of types\n // in GOVUKFrontend package, Typescript is not aware of $root\n // in components that extend GOVUKFrontendComponent\n /**\n * Returns the root element of the component\n *\n * @protected\n * @returns {RootElementType} - the root element of component\n */\n get $root() {\n return this._$root\n }\n\n /**\n * @protected\n * @type {RootElementType}\n */\n _$root\n\n /**\n * Constructs a new component, validating that GOV.UK Frontend is supported\n *\n * @internal\n * @param {Element | null} [$root] - HTML element to use for component\n */\n constructor($root) {\n const childConstructor = /** @type {ChildClassConstructor} */ (\n this.constructor\n )\n\n // TypeScript does not enforce that inheriting classes will define a `moduleName`\n // (even if we add a `@virtual` `static moduleName` property to this class).\n // While we trust users to do this correctly, we do a little check to provide them\n // a helpful error message.\n //\n // After this, we'll be sure that `childConstructor` has a `moduleName`\n // as expected of the `ChildClassConstructor` we've cast `this.constructor` to.\n if (typeof childConstructor.moduleName !== 'string') {\n throw new InitError(`\\`moduleName\\` not defined in component`)\n }\n\n if (!($root instanceof childConstructor.elementType)) {\n throw new ElementError({\n element: $root,\n component: childConstructor,\n identifier: 'Root element (`$root`)',\n expectedType: childConstructor.elementType.name\n })\n } else {\n this._$root = /** @type {RootElementType} */ ($root)\n }\n\n childConstructor.checkSupport()\n\n this.checkInitialised()\n\n const moduleName = childConstructor.moduleName\n\n this.$root.setAttribute(`data-${moduleName}-init`, '')\n }\n\n /**\n * Validates whether component is already initialised\n *\n * @private\n * @throws {InitError} when component is already initialised\n */\n checkInitialised() {\n const constructor = /** @type {ChildClassConstructor} */ (this.constructor)\n const moduleName = constructor.moduleName\n\n if (moduleName && isInitialised(this.$root, moduleName)) {\n throw new InitError(constructor)\n }\n }\n\n /**\n * Validates whether components are supported\n *\n * @throws {SupportError} when the components are not supported\n */\n static checkSupport() {\n if (!isSupported()) {\n throw new SupportError()\n }\n }\n}\n\n/**\n * @typedef ChildClass\n * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component\n */\n\n/**\n * @typedef {typeof GOVUKFrontendComponent & ChildClass} ChildClassConstructor\n */\n","import { getBreakpoint, getFragmentFromUrl } from '../../common/index.mjs'\nimport { ElementError } from '../../errors/index.mjs'\nimport { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'\n\n/**\n * Tabs component\n *\n * @preserve\n */\nexport class Tabs extends GOVUKFrontendComponent {\n /** @private */\n $tabs\n\n /** @private */\n $tabList\n\n /** @private */\n $tabListItems\n\n /** @private */\n jsHiddenClass = 'govuk-tabs__panel--hidden'\n\n /** @private */\n changingHash = false\n\n /** @private */\n boundTabClick\n\n /** @private */\n boundTabKeydown\n\n /** @private */\n boundOnHashChange\n\n /**\n * @private\n * @type {MediaQueryList | null}\n */\n mql = null\n\n /**\n * @param {Element | null} $root - HTML element to use for tabs\n */\n constructor($root) {\n super($root)\n\n const $tabs = this.$root.querySelectorAll('a.govuk-tabs__tab')\n if (!$tabs.length) {\n throw new ElementError({\n component: Tabs,\n identifier: 'Links (`<a class=\"govuk-tabs__tab\">`)'\n })\n }\n\n this.$tabs = $tabs\n\n // Save bound functions so we can remove event listeners during teardown\n this.boundTabClick = this.onTabClick.bind(this)\n this.boundTabKeydown = this.onTabKeydown.bind(this)\n this.boundOnHashChange = this.onHashChange.bind(this)\n\n const $tabList = this.$root.querySelector('.govuk-tabs__list')\n const $tabListItems = this.$root.querySelectorAll(\n 'li.govuk-tabs__list-item'\n )\n\n if (!$tabList) {\n throw new ElementError({\n component: Tabs,\n identifier: 'List (`<ul class=\"govuk-tabs__list\">`)'\n })\n }\n\n if (!$tabListItems.length) {\n throw new ElementError({\n component: Tabs,\n identifier: 'List items (`<li class=\"govuk-tabs__list-item\">`)'\n })\n }\n\n this.$tabList = $tabList\n this.$tabListItems = $tabListItems\n\n this.setupResponsiveChecks()\n }\n\n /**\n * Setup viewport resize check\n *\n * @private\n */\n setupResponsiveChecks() {\n const breakpoint = getBreakpoint('tablet')\n\n if (!breakpoint.value) {\n throw new ElementError({\n component: Tabs,\n identifier: `CSS custom property (\\`${breakpoint.property}\\`) on pseudo-class \\`:root\\``\n })\n }\n\n // Media query list for GOV.UK Frontend tablet breakpoint\n this.mql = window.matchMedia(`(min-width: ${breakpoint.value})`)\n\n // MediaQueryList.addEventListener isn't supported by Safari < 14 so we need\n // to be able to fall back to the deprecated MediaQueryList.addListener\n if ('addEventListener' in this.mql) {\n this.mql.addEventListener('change', () => this.checkMode())\n } else {\n // @ts-expect-error Property 'addListener' does not exist\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n this.mql.addListener(() => this.checkMode())\n }\n\n this.checkMode()\n }\n\n /**\n * Setup or teardown handler for viewport resize check\n *\n * @private\n */\n checkMode() {\n if (this.mql?.matches) {\n this.setup()\n } else {\n this.teardown()\n }\n }\n\n /**\n * Setup tab component\n *\n * @private\n */\n setup() {\n this.$tabList.setAttribute('role', 'tablist')\n\n this.$tabListItems.forEach(($item) => {\n $item.setAttribute('role', 'presentation')\n })\n\n this.$tabs.forEach(($tab) => {\n // Set HTML attributes\n this.setAttributes($tab)\n\n // Handle events\n $tab.addEventListener('click', this.boundTabClick, true)\n $tab.addEventListener('keydown', this.boundTabKeydown, true)\n\n // Remove old active panels\n this.hideTab($tab)\n })\n\n // Show either the active tab according to the URL's hash or the first tab\n const $activeTab = this.getTab(window.location.hash) ?? this.$tabs[0]\n\n this.showTab($activeTab)\n\n // Handle hashchange events\n window.addEventListener('hashchange', this.boundOnHashChange, true)\n }\n\n /**\n * Teardown tab component\n *\n * @private\n */\n teardown() {\n this.$tabList.removeAttribute('role')\n\n this.$tabListItems.forEach(($item) => {\n $item.removeAttribute('role')\n })\n\n this.$tabs.forEach(($tab) => {\n // Remove events\n $tab.removeEventListener('click', this.boundTabClick, true)\n $tab.removeEventListener('keydown', this.boundTabKeydown, true)\n\n // Unset HTML attributes\n this.unsetAttributes($tab)\n })\n\n // Remove hashchange event handler\n window.removeEventListener('hashchange', this.boundOnHashChange, true)\n }\n\n /**\n * Handle hashchange event\n *\n * @private\n * @returns {void | undefined} Returns void, or undefined when prevented\n */\n onHashChange() {\n const hash = window.location.hash\n const $tabWithHash = this.getTab(hash)\n if (!$tabWithHash) {\n return\n }\n\n // Prevent changing the hash\n if (this.changingHash) {\n this.changingHash = false\n return\n }\n\n // Show either the active tab according to the URL's hash or the first tab\n const $previousTab = this.getCurrentTab()\n if (!$previousTab) {\n return\n }\n\n this.hideTab($previousTab)\n this.showTab($tabWithHash)\n $tabWithHash.focus()\n }\n\n /**\n * Hide panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n hideTab($tab) {\n this.unhighlightTab($tab)\n this.hidePanel($tab)\n }\n\n /**\n * Show panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n showTab($tab) {\n this.highlightTab($tab)\n this.showPanel($tab)\n }\n\n /**\n * Get tab link by hash\n *\n * @private\n * @param {string} hash - Hash fragment including #\n * @returns {HTMLAnchorElement | null} Tab link\n */\n getTab(hash) {\n return this.$root.querySelector(`a.govuk-tabs__tab[href=\"${hash}\"]`)\n }\n\n /**\n * Set tab link and panel attributes\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n setAttributes($tab) {\n const panelId = getFragmentFromUrl($tab.href)\n if (!panelId) {\n return\n }\n\n // Set tab attributes\n $tab.setAttribute('id', `tab_${panelId}`)\n $tab.setAttribute('role', 'tab')\n $tab.setAttribute('aria-controls', panelId)\n $tab.setAttribute('aria-selected', 'false')\n $tab.setAttribute('tabindex', '-1')\n\n // Set panel attributes\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.setAttribute('role', 'tabpanel')\n $panel.setAttribute('aria-labelledby', $tab.id)\n $panel.classList.add(this.jsHiddenClass)\n }\n\n /**\n * Unset tab link and panel attributes\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n unsetAttributes($tab) {\n // unset tab attributes\n $tab.removeAttribute('id')\n $tab.removeAttribute('role')\n $tab.removeAttribute('aria-controls')\n $tab.removeAttribute('aria-selected')\n $tab.removeAttribute('tabindex')\n\n // unset panel attributes\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.removeAttribute('role')\n $panel.removeAttribute('aria-labelledby')\n $panel.classList.remove(this.jsHiddenClass)\n }\n\n /**\n * Handle tab link clicks\n *\n * @private\n * @param {MouseEvent} event - Mouse click event\n * @returns {void} Returns void\n */\n onTabClick(event) {\n const $currentTab = this.getCurrentTab()\n const $nextTab = event.currentTarget\n\n if (!$currentTab || !($nextTab instanceof HTMLAnchorElement)) {\n return\n }\n\n event.preventDefault()\n\n this.hideTab($currentTab)\n this.showTab($nextTab)\n this.createHistoryEntry($nextTab)\n }\n\n /**\n * Update browser URL hash fragment for tab\n *\n * - Allows back/forward to navigate tabs\n * - Avoids page jump when hash changes\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n createHistoryEntry($tab) {\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n // Save and restore the id so the page doesn't jump when a user clicks a tab\n // (which changes the hash)\n const panelId = $panel.id\n $panel.id = ''\n this.changingHash = true\n window.location.hash = panelId\n $panel.id = panelId\n }\n\n /**\n * Handle tab keydown event\n *\n * - Press right arrow for next tab\n * - Press left arrow for previous tab\n *\n * @private\n * @param {KeyboardEvent} event - Keydown event\n */\n onTabKeydown(event) {\n switch (event.key) {\n // 'Left' and 'Right' required for Edge 16 support.\n case 'ArrowLeft':\n case 'Left':\n this.activatePreviousTab()\n event.preventDefault()\n break\n case 'ArrowRight':\n case 'Right':\n this.activateNextTab()\n event.preventDefault()\n break\n }\n }\n\n /**\n * Activate next tab\n *\n * @private\n */\n activateNextTab() {\n const $currentTab = this.getCurrentTab()\n if (!$currentTab?.parentElement) {\n return\n }\n\n const $nextTabListItem = $currentTab.parentElement.nextElementSibling\n if (!$nextTabListItem) {\n return\n }\n\n const $nextTab = $nextTabListItem.querySelector('a.govuk-tabs__tab')\n if (!$nextTab) {\n return\n }\n\n this.hideTab($currentTab)\n this.showTab($nextTab)\n $nextTab.focus()\n this.createHistoryEntry($nextTab)\n }\n\n /**\n * Activate previous tab\n *\n * @private\n */\n activatePreviousTab() {\n const $currentTab = this.getCurrentTab()\n if (!$currentTab?.parentElement) {\n return\n }\n\n const $previousTabListItem =\n $currentTab.parentElement.previousElementSibling\n if (!$previousTabListItem) {\n return\n }\n\n const $previousTab = $previousTabListItem.querySelector('a.govuk-tabs__tab')\n if (!$previousTab) {\n return\n }\n\n this.hideTab($currentTab)\n this.showTab($previousTab)\n $previousTab.focus()\n this.createHistoryEntry($previousTab)\n }\n\n /**\n * Get tab panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n * @returns {Element | null} Tab panel\n */\n getPanel($tab) {\n const panelId = getFragmentFromUrl($tab.href)\n if (!panelId) {\n return null\n }\n\n return this.$root.querySelector(`#${panelId}`)\n }\n\n /**\n * Show tab panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n showPanel($tab) {\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.classList.remove(this.jsHiddenClass)\n }\n\n /**\n * Hide tab panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n hidePanel($tab) {\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.classList.add(this.jsHiddenClass)\n }\n\n /**\n * Unset 'selected' state for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n unhighlightTab($tab) {\n if (!$tab.parentElement) {\n return\n }\n\n $tab.setAttribute('aria-selected', 'false')\n $tab.parentElement.classList.remove('govuk-tabs__list-item--selected')\n $tab.setAttribute('tabindex', '-1')\n }\n\n /**\n * Set 'selected' state for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n highlightTab($tab) {\n if (!$tab.parentElement) {\n return\n }\n\n $tab.setAttribute('aria-selected', 'true')\n $tab.parentElement.classList.add('govuk-tabs__list-item--selected')\n $tab.setAttribute('tabindex', '0')\n }\n\n /**\n * Get current tab link\n *\n * @private\n * @returns {HTMLAnchorElement | null} Tab link\n */\n getCurrentTab() {\n return this.$root.querySelector(\n '.govuk-tabs__list-item--selected a.govuk-tabs__tab'\n )\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-tabs'\n}\n"],"names":["getFragmentFromUrl","url","includes","undefined","split","pop","getBreakpoint","name","property","value","window","getComputedStyle","document","documentElement","getPropertyValue","isInitialised","$root","moduleName","HTMLElement","hasAttribute","isSupported","$scope","body","classList","contains","formatErrorMessage","Component","message","GOVUKFrontendError","Error","constructor","args","SupportError","supportMessage","HTMLScriptElement","prototype","ElementError","messageOrOptions","component","identifier","element","expectedType","InitError","componentOrMessage","GOVUKFrontendComponent","_$root","childConstructor","elementType","checkSupport","checkInitialised","setAttribute","Tabs","$tabs","$tabList","$tabListItems","jsHiddenClass","changingHash","boundTabClick","boundTabKeydown","boundOnHashChange","mql","querySelectorAll","length","onTabClick","bind","onTabKeydown","onHashChange","querySelector","setupResponsiveChecks","breakpoint","matchMedia","addEventListener","checkMode","addListener","_this$mql","matches","setup","teardown","_this$getTab","forEach","$item","$tab","setAttributes","hideTab","$activeTab","getTab","location","hash","showTab","removeAttribute","removeEventListener","unsetAttributes","$tabWithHash","$previousTab","getCurrentTab","focus","unhighlightTab","hidePanel","highlightTab","showPanel","panelId","href","$panel","getPanel","id","add","remove","event","$currentTab","$nextTab","currentTarget","HTMLAnchorElement","preventDefault","createHistoryEntry","key","activatePreviousTab","activateNextTab","parentElement","$nextTabListItem","nextElementSibling","$previousTabListItem","previousElementSibling"],"mappings":"AAmHO,SAASA,kBAAkBA,CAACC,GAAG,EAAE;AACtC,EAAA,IAAI,CAACA,GAAG,CAACC,QAAQ,CAAC,GAAG,CAAC,EAAE;AACtB,IAAA,OAAOC,SAAS,CAAA;AAClB,GAAA;EAEA,OAAOF,GAAG,CAACG,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,EAAE,CAAA;AAC7B,CAAA;AASO,SAASC,aAAaA,CAACC,I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VUKFrontendComponent } from '../../govuk-frontend-component.mjs';
|
|
9
9
|
*/
|
10
10
|
class Tabs extends GOVUKFrontendComponent {
|
11
11
|
/**
|
12
|
-
* @param {Element | null} $
|
12
|
+
* @param {Element | null} $root - HTML element to use for tabs
|
13
13
|
*/
|
14
|
-
constructor($
|
15
|
-
super();
|
16
|
-
this.$module = void 0;
|
14
|
+
constructor($root) {
|
15
|
+
super($root);
|
17
16
|
this.$tabs = void 0;
|
18
17
|
this.$tabList = void 0;
|
19
18
|
this.$tabListItems = void 0;
|
@@ -23,36 +22,28 @@ class Tabs extends GOVUKFrontendComponent {
|
|
23
22
|
this.boundTabKeydown = void 0;
|
24
23
|
this.boundOnHashChange = void 0;
|
25
24
|
this.mql = null;
|
26
|
-
|
27
|
-
throw new ElementError({
|
28
|
-
componentName: 'Tabs',
|
29
|
-
element: $module,
|
30
|
-
identifier: 'Root element (`$module`)'
|
31
|
-
});
|
32
|
-
}
|
33
|
-
const $tabs = $module.querySelectorAll('a.govuk-tabs__tab');
|
25
|
+
const $tabs = this.$root.querySelectorAll('a.govuk-tabs__tab');
|
34
26
|
if (!$tabs.length) {
|
35
27
|
throw new ElementError({
|
36
|
-
|
28
|
+
component: Tabs,
|
37
29
|
identifier: 'Links (`<a class="govuk-tabs__tab">`)'
|
38
30
|
});
|
39
31
|
}
|
40
|
-
this.$module = $module;
|
41
32
|
this.$tabs = $tabs;
|
42
33
|
this.boundTabClick = this.onTabClick.bind(this);
|
43
34
|
this.boundTabKeydown = this.onTabKeydown.bind(this);
|
44
35
|
this.boundOnHashChange = this.onHashChange.bind(this);
|
45
|
-
const $tabList = this.$
|
46
|
-
const $tabListItems = this.$
|
36
|
+
const $tabList = this.$root.querySelector('.govuk-tabs__list');
|
37
|
+
const $tabListItems = this.$root.querySelectorAll('li.govuk-tabs__list-item');
|
47
38
|
if (!$tabList) {
|
48
39
|
throw new ElementError({
|
49
|
-
|
40
|
+
component: Tabs,
|
50
41
|
identifier: 'List (`<ul class="govuk-tabs__list">`)'
|
51
42
|
});
|
52
43
|
}
|
53
44
|
if (!$tabListItems.length) {
|
54
45
|
throw new ElementError({
|
55
|
-
|
46
|
+
component: Tabs,
|
56
47
|
identifier: 'List items (`<li class="govuk-tabs__list-item">`)'
|
57
48
|
});
|
58
49
|
}
|
@@ -64,7 +55,7 @@ class Tabs extends GOVUKFrontendComponent {
|
|
64
55
|
const breakpoint = getBreakpoint('tablet');
|
65
56
|
if (!breakpoint.value) {
|
66
57
|
throw new ElementError({
|
67
|
-
|
58
|
+
component: Tabs,
|
68
59
|
identifier: `CSS custom property (\`${breakpoint.property}\`) on pseudo-class \`:root\``
|
69
60
|
});
|
70
61
|
}
|
@@ -139,7 +130,7 @@ class Tabs extends GOVUKFrontendComponent {
|
|
139
130
|
this.showPanel($tab);
|
140
131
|
}
|
141
132
|
getTab(hash) {
|
142
|
-
return this.$
|
133
|
+
return this.$root.querySelector(`a.govuk-tabs__tab[href="${hash}"]`);
|
143
134
|
}
|
144
135
|
setAttributes($tab) {
|
145
136
|
const panelId = getFragmentFromUrl($tab.href);
|
@@ -250,7 +241,7 @@ class Tabs extends GOVUKFrontendComponent {
|
|
250
241
|
if (!panelId) {
|
251
242
|
return null;
|
252
243
|
}
|
253
|
-
return this.$
|
244
|
+
return this.$root.querySelector(`#${panelId}`);
|
254
245
|
}
|
255
246
|
showPanel($tab) {
|
256
247
|
const $panel = this.getPanel($tab);
|
@@ -283,7 +274,7 @@ class Tabs extends GOVUKFrontendComponent {
|
|
283
274
|
$tab.setAttribute('tabindex', '0');
|
284
275
|
}
|
285
276
|
getCurrentTab() {
|
286
|
-
return this.$
|
277
|
+
return this.$root.querySelector('.govuk-tabs__list-item--selected a.govuk-tabs__tab');
|
287
278
|
}
|
288
279
|
}
|
289
280
|
Tabs.moduleName = 'govuk-tabs';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"tabs.mjs","sources":["../../../../src/govuk/components/tabs/tabs.mjs"],"sourcesContent":["import { getBreakpoint, getFragmentFromUrl } from '../../common/index.mjs'\nimport { ElementError } from '../../errors/index.mjs'\nimport { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'\n\n/**\n * Tabs component\n *\n * @preserve\n */\nexport class Tabs extends GOVUKFrontendComponent {\n /** @private */\n $module\n\n /** @private */\n $tabs\n\n /** @private */\n $tabList\n\n /** @private */\n $tabListItems\n\n /** @private */\n jsHiddenClass = 'govuk-tabs__panel--hidden'\n\n /** @private */\n changingHash = false\n\n /** @private */\n boundTabClick\n\n /** @private */\n boundTabKeydown\n\n /** @private */\n boundOnHashChange\n\n /**\n * @private\n * @type {MediaQueryList | null}\n */\n mql = null\n\n /**\n * @param {Element | null} $module - HTML element to use for tabs\n */\n constructor($module) {\n super()\n\n if (!$module) {\n throw new ElementError({\n componentName: 'Tabs',\n element: $module,\n identifier: 'Root element (`$module`)'\n })\n }\n\n const $tabs = $module.querySelectorAll('a.govuk-tabs__tab')\n if (!$tabs.length) {\n throw new ElementError({\n componentName: 'Tabs',\n identifier: 'Links (`<a class=\"govuk-tabs__tab\">`)'\n })\n }\n\n this.$module = $module\n this.$tabs = $tabs\n\n // Save bound functions so we can remove event listeners during teardown\n this.boundTabClick = this.onTabClick.bind(this)\n this.boundTabKeydown = this.onTabKeydown.bind(this)\n this.boundOnHashChange = this.onHashChange.bind(this)\n\n const $tabList = this.$module.querySelector('.govuk-tabs__list')\n const $tabListItems = this.$module.querySelectorAll(\n 'li.govuk-tabs__list-item'\n )\n\n if (!$tabList) {\n throw new ElementError({\n componentName: 'Tabs',\n identifier: 'List (`<ul class=\"govuk-tabs__list\">`)'\n })\n }\n\n if (!$tabListItems.length) {\n throw new ElementError({\n componentName: 'Tabs',\n identifier: 'List items (`<li class=\"govuk-tabs__list-item\">`)'\n })\n }\n\n this.$tabList = $tabList\n this.$tabListItems = $tabListItems\n\n this.setupResponsiveChecks()\n }\n\n /**\n * Setup viewport resize check\n *\n * @private\n */\n setupResponsiveChecks() {\n const breakpoint = getBreakpoint('tablet')\n\n if (!breakpoint.value) {\n throw new ElementError({\n componentName: 'Tabs',\n identifier: `CSS custom property (\\`${breakpoint.property}\\`) on pseudo-class \\`:root\\``\n })\n }\n\n // Media query list for GOV.UK Frontend tablet breakpoint\n this.mql = window.matchMedia(`(min-width: ${breakpoint.value})`)\n\n // MediaQueryList.addEventListener isn't supported by Safari < 14 so we need\n // to be able to fall back to the deprecated MediaQueryList.addListener\n if ('addEventListener' in this.mql) {\n this.mql.addEventListener('change', () => this.checkMode())\n } else {\n // @ts-expect-error Property 'addListener' does not exist\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n this.mql.addListener(() => this.checkMode())\n }\n\n this.checkMode()\n }\n\n /**\n * Setup or teardown handler for viewport resize check\n *\n * @private\n */\n checkMode() {\n if (this.mql?.matches) {\n this.setup()\n } else {\n this.teardown()\n }\n }\n\n /**\n * Setup tab component\n *\n * @private\n */\n setup() {\n this.$tabList.setAttribute('role', 'tablist')\n\n this.$tabListItems.forEach(($item) => {\n $item.setAttribute('role', 'presentation')\n })\n\n this.$tabs.forEach(($tab) => {\n // Set HTML attributes\n this.setAttributes($tab)\n\n // Handle events\n $tab.addEventListener('click', this.boundTabClick, true)\n $tab.addEventListener('keydown', this.boundTabKeydown, true)\n\n // Remove old active panels\n this.hideTab($tab)\n })\n\n // Show either the active tab according to the URL's hash or the first tab\n const $activeTab = this.getTab(window.location.hash) ?? this.$tabs[0]\n\n this.showTab($activeTab)\n\n // Handle hashchange events\n window.addEventListener('hashchange', this.boundOnHashChange, true)\n }\n\n /**\n * Teardown tab component\n *\n * @private\n */\n teardown() {\n this.$tabList.removeAttribute('role')\n\n this.$tabListItems.forEach(($item) => {\n $item.removeAttribute('role')\n })\n\n this.$tabs.forEach(($tab) => {\n // Remove events\n $tab.removeEventListener('click', this.boundTabClick, true)\n $tab.removeEventListener('keydown', this.boundTabKeydown, true)\n\n // Unset HTML attributes\n this.unsetAttributes($tab)\n })\n\n // Remove hashchange event handler\n window.removeEventListener('hashchange', this.boundOnHashChange, true)\n }\n\n /**\n * Handle hashchange event\n *\n * @private\n * @returns {void | undefined} Returns void, or undefined when prevented\n */\n onHashChange() {\n const hash = window.location.hash\n const $tabWithHash = this.getTab(hash)\n if (!$tabWithHash) {\n return\n }\n\n // Prevent changing the hash\n if (this.changingHash) {\n this.changingHash = false\n return\n }\n\n // Show either the active tab according to the URL's hash or the first tab\n const $previousTab = this.getCurrentTab()\n if (!$previousTab) {\n return\n }\n\n this.hideTab($previousTab)\n this.showTab($tabWithHash)\n $tabWithHash.focus()\n }\n\n /**\n * Hide panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n hideTab($tab) {\n this.unhighlightTab($tab)\n this.hidePanel($tab)\n }\n\n /**\n * Show panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n showTab($tab) {\n this.highlightTab($tab)\n this.showPanel($tab)\n }\n\n /**\n * Get tab link by hash\n *\n * @private\n * @param {string} hash - Hash fragment including #\n * @returns {HTMLAnchorElement | null} Tab link\n */\n getTab(hash) {\n return this.$module.querySelector(`a.govuk-tabs__tab[href=\"${hash}\"]`)\n }\n\n /**\n * Set tab link and panel attributes\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n setAttributes($tab) {\n const panelId = getFragmentFromUrl($tab.href)\n if (!panelId) {\n return\n }\n\n // Set tab attributes\n $tab.setAttribute('id', `tab_${panelId}`)\n $tab.setAttribute('role', 'tab')\n $tab.setAttribute('aria-controls', panelId)\n $tab.setAttribute('aria-selected', 'false')\n $tab.setAttribute('tabindex', '-1')\n\n // Set panel attributes\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.setAttribute('role', 'tabpanel')\n $panel.setAttribute('aria-labelledby', $tab.id)\n $panel.classList.add(this.jsHiddenClass)\n }\n\n /**\n * Unset tab link and panel attributes\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n unsetAttributes($tab) {\n // unset tab attributes\n $tab.removeAttribute('id')\n $tab.removeAttribute('role')\n $tab.removeAttribute('aria-controls')\n $tab.removeAttribute('aria-selected')\n $tab.removeAttribute('tabindex')\n\n // unset panel attributes\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.removeAttribute('role')\n $panel.removeAttribute('aria-labelledby')\n $panel.classList.remove(this.jsHiddenClass)\n }\n\n /**\n * Handle tab link clicks\n *\n * @private\n * @param {MouseEvent} event - Mouse click event\n * @returns {void} Returns void\n */\n onTabClick(event) {\n const $currentTab = this.getCurrentTab()\n const $nextTab = event.currentTarget\n\n if (!$currentTab || !($nextTab instanceof HTMLAnchorElement)) {\n return\n }\n\n event.preventDefault()\n\n this.hideTab($currentTab)\n this.showTab($nextTab)\n this.createHistoryEntry($nextTab)\n }\n\n /**\n * Update browser URL hash fragment for tab\n *\n * - Allows back/forward to navigate tabs\n * - Avoids page jump when hash changes\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n createHistoryEntry($tab) {\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n // Save and restore the id so the page doesn't jump when a user clicks a tab\n // (which changes the hash)\n const panelId = $panel.id\n $panel.id = ''\n this.changingHash = true\n window.location.hash = panelId\n $panel.id = panelId\n }\n\n /**\n * Handle tab keydown event\n *\n * - Press right arrow for next tab\n * - Press left arrow for previous tab\n *\n * @private\n * @param {KeyboardEvent} event - Keydown event\n */\n onTabKeydown(event) {\n switch (event.key) {\n // 'Left' and 'Right' required for Edge 16 support.\n case 'ArrowLeft':\n case 'Left':\n this.activatePreviousTab()\n event.preventDefault()\n break\n case 'ArrowRight':\n case 'Right':\n this.activateNextTab()\n event.preventDefault()\n break\n }\n }\n\n /**\n * Activate next tab\n *\n * @private\n */\n activateNextTab() {\n const $currentTab = this.getCurrentTab()\n if (!$currentTab?.parentElement) {\n return\n }\n\n const $nextTabListItem = $currentTab.parentElement.nextElementSibling\n if (!$nextTabListItem) {\n return\n }\n\n const $nextTab = $nextTabListItem.querySelector('a.govuk-tabs__tab')\n if (!$nextTab) {\n return\n }\n\n this.hideTab($currentTab)\n this.showTab($nextTab)\n $nextTab.focus()\n this.createHistoryEntry($nextTab)\n }\n\n /**\n * Activate previous tab\n *\n * @private\n */\n activatePreviousTab() {\n const $currentTab = this.getCurrentTab()\n if (!$currentTab?.parentElement) {\n return\n }\n\n const $previousTabListItem =\n $currentTab.parentElement.previousElementSibling\n if (!$previousTabListItem) {\n return\n }\n\n const $previousTab = $previousTabListItem.querySelector('a.govuk-tabs__tab')\n if (!$previousTab) {\n return\n }\n\n this.hideTab($currentTab)\n this.showTab($previousTab)\n $previousTab.focus()\n this.createHistoryEntry($previousTab)\n }\n\n /**\n * Get tab panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n * @returns {Element | null} Tab panel\n */\n getPanel($tab) {\n const panelId = getFragmentFromUrl($tab.href)\n if (!panelId) {\n return null\n }\n\n return this.$module.querySelector(`#${panelId}`)\n }\n\n /**\n * Show tab panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n showPanel($tab) {\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.classList.remove(this.jsHiddenClass)\n }\n\n /**\n * Hide tab panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n hidePanel($tab) {\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.classList.add(this.jsHiddenClass)\n }\n\n /**\n * Unset 'selected' state for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n unhighlightTab($tab) {\n if (!$tab.parentElement) {\n return\n }\n\n $tab.setAttribute('aria-selected', 'false')\n $tab.parentElement.classList.remove('govuk-tabs__list-item--selected')\n $tab.setAttribute('tabindex', '-1')\n }\n\n /**\n * Set 'selected' state for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n highlightTab($tab) {\n if (!$tab.parentElement) {\n return\n }\n\n $tab.setAttribute('aria-selected', 'true')\n $tab.parentElement.classList.add('govuk-tabs__list-item--selected')\n $tab.setAttribute('tabindex', '0')\n }\n\n /**\n * Get current tab link\n *\n * @private\n * @returns {HTMLAnchorElement | null} Tab link\n */\n getCurrentTab() {\n return this.$module.querySelector(\n '.govuk-tabs__list-item--selected a.govuk-tabs__tab'\n )\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-tabs'\n}\n"],"names":["Tabs","GOVUKFrontendComponent","constructor","$module","$tabs","$tabList","$tabListItems","jsHiddenClass","changingHash","boundTabClick","boundTabKeydown","boundOnHashChange","mql","ElementError","componentName","element","identifier","querySelectorAll","length","onTabClick","bind","onTabKeydown","onHashChange","querySelector","setupResponsiveChecks","breakpoint","getBreakpoint","value","property","window","matchMedia","addEventListener","checkMode","addListener","_this$mql","matches","setup","teardown","_this$getTab","setAttribute","forEach","$item","$tab","setAttributes","hideTab","$activeTab","getTab","location","hash","showTab","removeAttribute","removeEventListener","unsetAttributes","$tabWithHash","$previousTab","getCurrentTab","focus","unhighlightTab","hidePanel","highlightTab","showPanel","panelId","getFragmentFromUrl","href","$panel","getPanel","id","classList","add","remove","event","$currentTab","$nextTab","currentTarget","HTMLAnchorElement","preventDefault","createHistoryEntry","key","activatePreviousTab","activateNextTab","parentElement","$nextTabListItem","nextElementSibling","$previousTabListItem","previousElementSibling","moduleName"],"mappings":";;;;AAIA;AACA;AACA;AACA;AACA;AACO,MAAMA,IAAI,SAASC,sBAAsB,CAAC;AAkC/C;AACF;AACA;EACEC,WAAWA,CAACC,OAAO,EAAE;AACnB,IAAA,KAAK,EAAE,CAAA;AAAA,IAAA,IAAA,CApCTA,OAAO,GAAA,KAAA,CAAA,CAAA;AAAA,IAAA,IAAA,CAGPC,KAAK,GAAA,KAAA,CAAA,CAAA;AAAA,IAAA,IAAA,CAGLC,QAAQ,GAAA,KAAA,CAAA,CAAA;AAAA,IAAA,IAAA,CAGRC,aAAa,GAAA,KA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,YAAYA,CAACjB,IAAI,EAAE;AACjB,IAAA,IAAI,CAACA,IAAI,CAACsC,aAAa,EAAE;AACvB,MAAA,OAAA;AACF,KAAA;AAEAtC,IAAAA,IAAI,CAACH,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAA;IAC1CG,IAAI,CAACsC,aAAa,CAACb,SAAS,CAACC,GAAG,CAAC,iCAAiC,CAAC,CAAA;AACnE1B,IAAAA,IAAI,CAACH,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;AACpC,GAAA;AAQAgB,EAAAA,aAAaA,GAAG;AACd,IAAA,OAAO,IAAI,CAACpD,OAAO,CAACoB,aAAa,CAC/B,oDACF,CAAC,CAAA;AACH,GAAA;AAMF,CAAA;AAjhBavB,IAAI,CAghBRqF,UAAU,GAAG,YAAY;;;;"}
|
1
|
+
{"version":3,"file":"tabs.mjs","sources":["../../../../src/govuk/components/tabs/tabs.mjs"],"sourcesContent":["import { getBreakpoint, getFragmentFromUrl } from '../../common/index.mjs'\nimport { ElementError } from '../../errors/index.mjs'\nimport { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'\n\n/**\n * Tabs component\n *\n * @preserve\n */\nexport class Tabs extends GOVUKFrontendComponent {\n /** @private */\n $tabs\n\n /** @private */\n $tabList\n\n /** @private */\n $tabListItems\n\n /** @private */\n jsHiddenClass = 'govuk-tabs__panel--hidden'\n\n /** @private */\n changingHash = false\n\n /** @private */\n boundTabClick\n\n /** @private */\n boundTabKeydown\n\n /** @private */\n boundOnHashChange\n\n /**\n * @private\n * @type {MediaQueryList | null}\n */\n mql = null\n\n /**\n * @param {Element | null} $root - HTML element to use for tabs\n */\n constructor($root) {\n super($root)\n\n const $tabs = this.$root.querySelectorAll('a.govuk-tabs__tab')\n if (!$tabs.length) {\n throw new ElementError({\n component: Tabs,\n identifier: 'Links (`<a class=\"govuk-tabs__tab\">`)'\n })\n }\n\n this.$tabs = $tabs\n\n // Save bound functions so we can remove event listeners during teardown\n this.boundTabClick = this.onTabClick.bind(this)\n this.boundTabKeydown = this.onTabKeydown.bind(this)\n this.boundOnHashChange = this.onHashChange.bind(this)\n\n const $tabList = this.$root.querySelector('.govuk-tabs__list')\n const $tabListItems = this.$root.querySelectorAll(\n 'li.govuk-tabs__list-item'\n )\n\n if (!$tabList) {\n throw new ElementError({\n component: Tabs,\n identifier: 'List (`<ul class=\"govuk-tabs__list\">`)'\n })\n }\n\n if (!$tabListItems.length) {\n throw new ElementError({\n component: Tabs,\n identifier: 'List items (`<li class=\"govuk-tabs__list-item\">`)'\n })\n }\n\n this.$tabList = $tabList\n this.$tabListItems = $tabListItems\n\n this.setupResponsiveChecks()\n }\n\n /**\n * Setup viewport resize check\n *\n * @private\n */\n setupResponsiveChecks() {\n const breakpoint = getBreakpoint('tablet')\n\n if (!breakpoint.value) {\n throw new ElementError({\n component: Tabs,\n identifier: `CSS custom property (\\`${breakpoint.property}\\`) on pseudo-class \\`:root\\``\n })\n }\n\n // Media query list for GOV.UK Frontend tablet breakpoint\n this.mql = window.matchMedia(`(min-width: ${breakpoint.value})`)\n\n // MediaQueryList.addEventListener isn't supported by Safari < 14 so we need\n // to be able to fall back to the deprecated MediaQueryList.addListener\n if ('addEventListener' in this.mql) {\n this.mql.addEventListener('change', () => this.checkMode())\n } else {\n // @ts-expect-error Property 'addListener' does not exist\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n this.mql.addListener(() => this.checkMode())\n }\n\n this.checkMode()\n }\n\n /**\n * Setup or teardown handler for viewport resize check\n *\n * @private\n */\n checkMode() {\n if (this.mql?.matches) {\n this.setup()\n } else {\n this.teardown()\n }\n }\n\n /**\n * Setup tab component\n *\n * @private\n */\n setup() {\n this.$tabList.setAttribute('role', 'tablist')\n\n this.$tabListItems.forEach(($item) => {\n $item.setAttribute('role', 'presentation')\n })\n\n this.$tabs.forEach(($tab) => {\n // Set HTML attributes\n this.setAttributes($tab)\n\n // Handle events\n $tab.addEventListener('click', this.boundTabClick, true)\n $tab.addEventListener('keydown', this.boundTabKeydown, true)\n\n // Remove old active panels\n this.hideTab($tab)\n })\n\n // Show either the active tab according to the URL's hash or the first tab\n const $activeTab = this.getTab(window.location.hash) ?? this.$tabs[0]\n\n this.showTab($activeTab)\n\n // Handle hashchange events\n window.addEventListener('hashchange', this.boundOnHashChange, true)\n }\n\n /**\n * Teardown tab component\n *\n * @private\n */\n teardown() {\n this.$tabList.removeAttribute('role')\n\n this.$tabListItems.forEach(($item) => {\n $item.removeAttribute('role')\n })\n\n this.$tabs.forEach(($tab) => {\n // Remove events\n $tab.removeEventListener('click', this.boundTabClick, true)\n $tab.removeEventListener('keydown', this.boundTabKeydown, true)\n\n // Unset HTML attributes\n this.unsetAttributes($tab)\n })\n\n // Remove hashchange event handler\n window.removeEventListener('hashchange', this.boundOnHashChange, true)\n }\n\n /**\n * Handle hashchange event\n *\n * @private\n * @returns {void | undefined} Returns void, or undefined when prevented\n */\n onHashChange() {\n const hash = window.location.hash\n const $tabWithHash = this.getTab(hash)\n if (!$tabWithHash) {\n return\n }\n\n // Prevent changing the hash\n if (this.changingHash) {\n this.changingHash = false\n return\n }\n\n // Show either the active tab according to the URL's hash or the first tab\n const $previousTab = this.getCurrentTab()\n if (!$previousTab) {\n return\n }\n\n this.hideTab($previousTab)\n this.showTab($tabWithHash)\n $tabWithHash.focus()\n }\n\n /**\n * Hide panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n hideTab($tab) {\n this.unhighlightTab($tab)\n this.hidePanel($tab)\n }\n\n /**\n * Show panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n showTab($tab) {\n this.highlightTab($tab)\n this.showPanel($tab)\n }\n\n /**\n * Get tab link by hash\n *\n * @private\n * @param {string} hash - Hash fragment including #\n * @returns {HTMLAnchorElement | null} Tab link\n */\n getTab(hash) {\n return this.$root.querySelector(`a.govuk-tabs__tab[href=\"${hash}\"]`)\n }\n\n /**\n * Set tab link and panel attributes\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n setAttributes($tab) {\n const panelId = getFragmentFromUrl($tab.href)\n if (!panelId) {\n return\n }\n\n // Set tab attributes\n $tab.setAttribute('id', `tab_${panelId}`)\n $tab.setAttribute('role', 'tab')\n $tab.setAttribute('aria-controls', panelId)\n $tab.setAttribute('aria-selected', 'false')\n $tab.setAttribute('tabindex', '-1')\n\n // Set panel attributes\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.setAttribute('role', 'tabpanel')\n $panel.setAttribute('aria-labelledby', $tab.id)\n $panel.classList.add(this.jsHiddenClass)\n }\n\n /**\n * Unset tab link and panel attributes\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n unsetAttributes($tab) {\n // unset tab attributes\n $tab.removeAttribute('id')\n $tab.removeAttribute('role')\n $tab.removeAttribute('aria-controls')\n $tab.removeAttribute('aria-selected')\n $tab.removeAttribute('tabindex')\n\n // unset panel attributes\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.removeAttribute('role')\n $panel.removeAttribute('aria-labelledby')\n $panel.classList.remove(this.jsHiddenClass)\n }\n\n /**\n * Handle tab link clicks\n *\n * @private\n * @param {MouseEvent} event - Mouse click event\n * @returns {void} Returns void\n */\n onTabClick(event) {\n const $currentTab = this.getCurrentTab()\n const $nextTab = event.currentTarget\n\n if (!$currentTab || !($nextTab instanceof HTMLAnchorElement)) {\n return\n }\n\n event.preventDefault()\n\n this.hideTab($currentTab)\n this.showTab($nextTab)\n this.createHistoryEntry($nextTab)\n }\n\n /**\n * Update browser URL hash fragment for tab\n *\n * - Allows back/forward to navigate tabs\n * - Avoids page jump when hash changes\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n createHistoryEntry($tab) {\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n // Save and restore the id so the page doesn't jump when a user clicks a tab\n // (which changes the hash)\n const panelId = $panel.id\n $panel.id = ''\n this.changingHash = true\n window.location.hash = panelId\n $panel.id = panelId\n }\n\n /**\n * Handle tab keydown event\n *\n * - Press right arrow for next tab\n * - Press left arrow for previous tab\n *\n * @private\n * @param {KeyboardEvent} event - Keydown event\n */\n onTabKeydown(event) {\n switch (event.key) {\n // 'Left' and 'Right' required for Edge 16 support.\n case 'ArrowLeft':\n case 'Left':\n this.activatePreviousTab()\n event.preventDefault()\n break\n case 'ArrowRight':\n case 'Right':\n this.activateNextTab()\n event.preventDefault()\n break\n }\n }\n\n /**\n * Activate next tab\n *\n * @private\n */\n activateNextTab() {\n const $currentTab = this.getCurrentTab()\n if (!$currentTab?.parentElement) {\n return\n }\n\n const $nextTabListItem = $currentTab.parentElement.nextElementSibling\n if (!$nextTabListItem) {\n return\n }\n\n const $nextTab = $nextTabListItem.querySelector('a.govuk-tabs__tab')\n if (!$nextTab) {\n return\n }\n\n this.hideTab($currentTab)\n this.showTab($nextTab)\n $nextTab.focus()\n this.createHistoryEntry($nextTab)\n }\n\n /**\n * Activate previous tab\n *\n * @private\n */\n activatePreviousTab() {\n const $currentTab = this.getCurrentTab()\n if (!$currentTab?.parentElement) {\n return\n }\n\n const $previousTabListItem =\n $currentTab.parentElement.previousElementSibling\n if (!$previousTabListItem) {\n return\n }\n\n const $previousTab = $previousTabListItem.querySelector('a.govuk-tabs__tab')\n if (!$previousTab) {\n return\n }\n\n this.hideTab($currentTab)\n this.showTab($previousTab)\n $previousTab.focus()\n this.createHistoryEntry($previousTab)\n }\n\n /**\n * Get tab panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n * @returns {Element | null} Tab panel\n */\n getPanel($tab) {\n const panelId = getFragmentFromUrl($tab.href)\n if (!panelId) {\n return null\n }\n\n return this.$root.querySelector(`#${panelId}`)\n }\n\n /**\n * Show tab panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n showPanel($tab) {\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.classList.remove(this.jsHiddenClass)\n }\n\n /**\n * Hide tab panel for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n hidePanel($tab) {\n const $panel = this.getPanel($tab)\n if (!$panel) {\n return\n }\n\n $panel.classList.add(this.jsHiddenClass)\n }\n\n /**\n * Unset 'selected' state for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n unhighlightTab($tab) {\n if (!$tab.parentElement) {\n return\n }\n\n $tab.setAttribute('aria-selected', 'false')\n $tab.parentElement.classList.remove('govuk-tabs__list-item--selected')\n $tab.setAttribute('tabindex', '-1')\n }\n\n /**\n * Set 'selected' state for tab link\n *\n * @private\n * @param {HTMLAnchorElement} $tab - Tab link\n */\n highlightTab($tab) {\n if (!$tab.parentElement) {\n return\n }\n\n $tab.setAttribute('aria-selected', 'true')\n $tab.parentElement.classList.add('govuk-tabs__list-item--selected')\n $tab.setAttribute('tabindex', '0')\n }\n\n /**\n * Get current tab link\n *\n * @private\n * @returns {HTMLAnchorElement | null} Tab link\n */\n getCurrentTab() {\n return this.$root.querySelector(\n '.govuk-tabs__list-item--selected a.govuk-tabs__tab'\n )\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-tabs'\n}\n"],"names":["Tabs","GOVUKFrontendComponent","constructor","$root","$tabs","$tabList","$tabListItems","jsHiddenClass","changingHash","boundTabClick","boundTabKeydown","boundOnHashChange","mql","querySelectorAll","length","ElementError","component","identifier","onTabClick","bind","onTabKeydown","onHashChange","querySelector","setupResponsiveChecks","breakpoint","getBreakpoint","value","property","window","matchMedia","addEventListener","checkMode","addListener","_this$mql","matches","setup","teardown","_this$getTab","setAttribute","forEach","$item","$tab","setAttributes","hideTab","$activeTab","getTab","location","hash","showTab","removeAttribute","removeEventListener","unsetAttributes","$tabWithHash","$previousTab","getCurrentTab","focus","unhighlightTab","hidePanel","highlightTab","showPanel","panelId","getFragmentFromUrl","href","$panel","getPanel","id","classList","add","remove","event","$currentTab","$nextTab","currentTarget","HTMLAnchorElement","preventDefault","createHistoryEntry","key","activatePreviousTab","activateNextTab","parentElement","$nextTabListItem","nextElementSibling","$previousTabListItem","previousElementSibling","moduleName"],"mappings":";;;;AAIA;AACA;AACA;AACA;AACA;AACO,MAAMA,IAAI,SAASC,sBAAsB,CAAC;AA+B/C;AACF;AACA;EACEC,WAAWA,CAACC,KAAK,EAAE;IACjB,KAAK,CAACA,KAAK,CAAC,CAAA;AAAA,IAAA,IAAA,CAjCdC,KAAK,GAAA,KAAA,CAAA,CAAA;AAAA,IAAA,IAAA,CAGLC,QAAQ,GAAA,KAAA,CAAA,CAAA;AAAA,IAAA,IAAA,CAGRC,aAAa,GAAA,KAAA,CAAA,CAAA;IAAA,IAGbC,CAAAA,aAAa,GAAG,2BAA2B,CAAA;IAAA,IAG3CC,CAAAA,YAAY,GAAG,KAAK,CAAA;AAAA,IAAA,IAAA,CAGpBC,aAAa,GAAA,KAAA,CAAA,CAAA;AAAA,IAAA,IAAA,CAGbC,eAAe,GAAA,KAAA,CAAA,CAAA;AAAA,IAAA,IAAA,CAGfC,iBAAiB,GAAA,KAAA,CAAA,CAAA;IAAA,IAMjBC,CAAAA,GAAG,GAAG,IAAI,CAAA;IAQR,MAAMR,KAAK,GAAG,IAAI,CAACD,KAAK,CAACU,gBAAgB,CAAC,mBAAmB,CAAC,CAAA;AAC9D,IAAA,IAAI,CAACT,KAAK,CAACU,MAAM,EAAE;MACjB,MAAM,IAAIC,YAAY,CAAC;AACrBC,QAAAA,SAAS,EAAEhB,IAAI;AACfiB,QAAAA,UAAU,EAAE,uCAAA;AACd,OAAC,CAAC,CAAA;AACJ,KAAA;IAEA,IAAI,CAACb,KAAK,GAAGA,KAAK,CAAA;IAGlB,IAAI,CAACK,aAAa,GAAG,IAAI,CAACS,UAAU,CAACC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC/C,IAAI,CAACT,eAAe,GAAG,IAAI,CAACU,YAAY,CAACD,IAAI,CAAC,IAAI,CAAC,C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AAC,eAAe,EAAE,OAAO,CAAC,CAAA;IAC3CG,IAAI,CAACsC,aAAa,CAACb,SAAS,CAACE,MAAM,CAAC,iCAAiC,CAAC,CAAA;AACtE3B,IAAAA,IAAI,CAACH,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACrC,GAAA;EAQAoB,YAAYA,CAACjB,IAAI,EAAE;AACjB,IAAA,IAAI,CAACA,IAAI,CAACsC,aAAa,EAAE;AACvB,MAAA,OAAA;AACF,KAAA;AAEAtC,IAAAA,IAAI,CAACH,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAA;IAC1CG,IAAI,CAACsC,aAAa,CAACb,SAAS,CAACC,GAAG,CAAC,iCAAiC,CAAC,CAAA;AACnE1B,IAAAA,IAAI,CAACH,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;AACpC,GAAA;AAQAgB,EAAAA,aAAaA,GAAG;AACd,IAAA,OAAO,IAAI,CAACnD,KAAK,CAACmB,aAAa,CAC7B,oDACF,CAAC,CAAA;AACH,GAAA;AAMF,CAAA;AArgBatB,IAAI,CAogBRoF,UAAU,GAAG,YAAY;;;;"}
|
@@ -2,14 +2,12 @@
|
|
2
2
|
.govuk-warning-text {
|
3
3
|
@include govuk-font($size: 19);
|
4
4
|
@include govuk-responsive-margin(6, "bottom");
|
5
|
+
@include govuk-typography-weight-bold;
|
5
6
|
position: relative;
|
6
7
|
padding: govuk-spacing(2) 0;
|
7
8
|
}
|
8
9
|
|
9
10
|
.govuk-warning-text__icon {
|
10
|
-
// We apply this here and not at the parent level because the actual text is
|
11
|
-
// a <strong> and so will always be bold
|
12
|
-
@include govuk-typography-weight-bold;
|
13
11
|
box-sizing: border-box;
|
14
12
|
|
15
13
|
display: inline-block;
|
@@ -59,6 +57,9 @@
|
|
59
57
|
@include govuk-text-colour;
|
60
58
|
display: block;
|
61
59
|
padding-left: 45px;
|
60
|
+
// While `<strong>` is styled `bold` or `bolder` by user-agents
|
61
|
+
// this can be reset by the app's stylesheet
|
62
|
+
font-weight: inherit;
|
62
63
|
}
|
63
64
|
}
|
64
65
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/govuk/components/warning-text/_index.scss"],"names":[],"mappings":"AAAA;EACE;IACE,8BAA8B;IAC9B,6CAA6C;IAC7C,kBAAkB;IAClB,2BAA2B;EAC7B;;EAEA;IACE,
|
1
|
+
{"version":3,"sources":["../../../../src/govuk/components/warning-text/_index.scss"],"names":[],"mappings":"AAAA;EACE;IACE,8BAA8B;IAC9B,6CAA6C;IAC7C,qCAAqC;IACrC,kBAAkB;IAClB,2BAA2B;EAC7B;;EAEA;IACE,sBAAsB;;IAEtB,qBAAqB;;IAErB,kBAAkB;IAClB,OAAO;;IAEP,eAAe;IACf,gBAAgB;IAChB,gBAAgB;;IAEhB;MACE,gBAAgB;IAClB;;IAEA,0EAA0E;IAC1E,yEAAyE;IACzE,oCAAoC;IACpC,kBAAkB;;IAElB,oCAAoC;IACpC,8BAA8B;;IAE9B,eAAe;IACf,iBAAiB;;IAEjB,kBAAkB;;IAElB,wEAAwE;IACxE,yBAAyB;IACzB,yBAAiB;QAAjB,qBAAiB;YAAjB,iBAAiB;;IAEjB,iEAAiE;IACjE,uEAAuE;IACvE,yBAAyB;;IAEzB;MACE,wBAAwB;MACxB,iBAAiB;MACjB,uBAAuB;IACzB;EACF;;EAEA;IACE,0BAA0B;IAC1B,cAAc;IACd,kBAAkB;IAClB,8DAA8D;IAC9D,2CAA2C;IAC3C,oBAAoB;EACtB;AACF","file":"_index.scss","sourcesContent":["@include govuk-exports(\"govuk/component/warning-text\") {\n .govuk-warning-text {\n @include govuk-font($size: 19);\n @include govuk-responsive-margin(6, \"bottom\");\n @include govuk-typography-weight-bold;\n position: relative;\n padding: govuk-spacing(2) 0;\n }\n\n .govuk-warning-text__icon {\n box-sizing: border-box;\n\n display: inline-block;\n\n position: absolute;\n left: 0;\n\n min-width: 35px;\n min-height: 35px;\n margin-top: -7px;\n\n @include govuk-media-query($from: tablet) {\n margin-top: -5px;\n }\n\n // When a user customises their colours the background colour will often be\n // removed. Adding a border to the component keeps it's shape as a circle.\n border: 3px solid $govuk-text-colour;\n border-radius: 50%;\n\n color: $govuk-body-background-colour;\n background: $govuk-text-colour;\n\n font-size: 30px;\n line-height: 29px;\n\n text-align: center;\n\n // Prevent the exclamation mark from being included when the warning text\n // is copied, for example.\n user-select: none;\n\n // Improve rendering in Windows High Contrast Mode (Edge), where a\n // readability backplate behind the exclamation mark obscures the circle\n forced-color-adjust: none;\n\n @media screen and (forced-colors: active) {\n border-color: windowText;\n color: windowText;\n background: transparent;\n }\n }\n\n .govuk-warning-text__text {\n @include govuk-text-colour;\n display: block;\n padding-left: 45px;\n // While `<strong>` is styled `bold` or `bolder` by user-agents\n // this can be reset by the app's stylesheet\n font-weight: inherit;\n }\n}\n"]}
|
@@ -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
|
-
--govuk-frontend-version: "5.
|
4
|
+
--govuk-frontend-version: "5.7.0";
|
5
5
|
|
6
6
|
// CSS custom property for each breakpoint
|
7
7
|
@each $name, $value in $govuk-breakpoints {
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import { formatErrorMessage } from '../common/index.mjs';
|
2
|
+
|
1
3
|
class GOVUKFrontendError extends Error {
|
2
4
|
constructor(...args) {
|
3
5
|
super(...args);
|
@@ -27,18 +29,29 @@ class ElementError extends GOVUKFrontendError {
|
|
27
29
|
let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
|
28
30
|
if (typeof messageOrOptions === 'object') {
|
29
31
|
const {
|
30
|
-
|
32
|
+
component,
|
31
33
|
identifier,
|
32
34
|
element,
|
33
35
|
expectedType
|
34
36
|
} = messageOrOptions;
|
35
|
-
message =
|
37
|
+
message = identifier;
|
36
38
|
message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
|
39
|
+
message = formatErrorMessage(component, message);
|
37
40
|
}
|
38
41
|
super(message);
|
39
42
|
this.name = 'ElementError';
|
40
43
|
}
|
41
44
|
}
|
45
|
+
class InitError extends GOVUKFrontendError {
|
46
|
+
constructor(componentOrMessage) {
|
47
|
+
const message = typeof componentOrMessage === 'string' ? componentOrMessage : formatErrorMessage(componentOrMessage, `Root element (\`$root\`) already initialised`);
|
48
|
+
super(message);
|
49
|
+
this.name = 'InitError';
|
50
|
+
}
|
51
|
+
}
|
52
|
+
/**
|
53
|
+
* @typedef {import('../common/index.mjs').ComponentWithModuleName} ComponentWithModuleName
|
54
|
+
*/
|
42
55
|
|
43
|
-
export { ConfigError, ElementError, GOVUKFrontendError, SupportError };
|
56
|
+
export { ConfigError, ElementError, GOVUKFrontendError, InitError, SupportError };
|
44
57
|
//# sourceMappingURL=index.mjs.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../src/govuk/errors/index.mjs"],"sourcesContent":["/**\n * GOV.UK Frontend error\n *\n * A base class for `Error`s thrown by GOV.UK Frontend.\n *\n * It is meant to be extended into specific types of errors\n * to be thrown by our code.\n *\n * @example\n * ```js\n * class MissingRootError extends GOVUKFrontendError {\n * // Setting an explicit name is important as extending the class will not\n * // set a new `name` on the subclass. The `name` property is important\n * // to ensure intelligible error names even if the class name gets\n * // mangled by a minifier\n * name = \"MissingRootError\"\n * }\n * ```\n * @
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/govuk/errors/index.mjs"],"sourcesContent":["import { formatErrorMessage } from '../common/index.mjs'\n\n/**\n * GOV.UK Frontend error\n *\n * A base class for `Error`s thrown by GOV.UK Frontend.\n *\n * It is meant to be extended into specific types of errors\n * to be thrown by our code.\n *\n * @example\n * ```js\n * class MissingRootError extends GOVUKFrontendError {\n * // Setting an explicit name is important as extending the class will not\n * // set a new `name` on the subclass. The `name` property is important\n * // to ensure intelligible error names even if the class name gets\n * // mangled by a minifier\n * name = \"MissingRootError\"\n * }\n * ```\n * @virtual\n */\nexport class GOVUKFrontendError extends Error {\n name = 'GOVUKFrontendError'\n}\n\n/**\n * Indicates that GOV.UK Frontend is not supported\n */\nexport class SupportError extends GOVUKFrontendError {\n name = 'SupportError'\n\n /**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n */\n constructor($scope = document.body) {\n const supportMessage =\n 'noModule' in HTMLScriptElement.prototype\n ? 'GOV.UK Frontend initialised without `<body class=\"govuk-frontend-supported\">` from template `<script>` snippet'\n : 'GOV.UK Frontend is not supported in this browser'\n\n super(\n $scope\n ? supportMessage\n : 'GOV.UK Frontend initialised without `<script type=\"module\">`'\n )\n }\n}\n\n/**\n * Indicates that a component has received an illegal configuration\n */\nexport class ConfigError extends GOVUKFrontendError {\n name = 'ConfigError'\n}\n\n/**\n * Indicates an issue with an element (possibly `null` or `undefined`)\n */\nexport class ElementError extends GOVUKFrontendError {\n name = 'ElementError'\n\n /**\n * @internal\n * @overload\n * @param {string} message - Element error message\n */\n\n /**\n * @internal\n * @overload\n * @param {ElementErrorOptions} options - Element error options\n */\n\n /**\n * @internal\n * @param {string | ElementErrorOptions} messageOrOptions - Element error message or options\n */\n constructor(messageOrOptions) {\n let message = typeof messageOrOptions === 'string' ? messageOrOptions : ''\n\n // Build message from options\n if (typeof messageOrOptions === 'object') {\n const { component, identifier, element, expectedType } = messageOrOptions\n\n message = identifier\n\n // Append reason\n message += element\n ? ` is not of type ${expectedType ?? 'HTMLElement'}`\n : ' not found'\n\n message = formatErrorMessage(component, message)\n }\n\n super(message)\n }\n}\n\n/**\n * Indicates that a component is already initialised\n */\nexport class InitError extends GOVUKFrontendError {\n name = 'InitError'\n\n /**\n * @internal\n * @param {ComponentWithModuleName | string} componentOrMessage - name of the component module\n */\n constructor(componentOrMessage) {\n const message =\n typeof componentOrMessage === 'string'\n ? componentOrMessage\n : formatErrorMessage(\n componentOrMessage,\n `Root element (\\`$root\\`) already initialised`\n )\n\n super(message)\n }\n}\n\n/**\n * Element error options\n *\n * @internal\n * @typedef {object} ElementErrorOptions\n * @property {string} identifier - An identifier that'll let the user understand which element has an error. This is whatever makes the most sense\n * @property {Element | null} [element] - The element in error\n * @property {string} [expectedType] - The type that was expected for the identifier\n * @property {ComponentWithModuleName} component - Component throwing the error\n */\n\n/**\n * @typedef {import('../common/index.mjs').ComponentWithModuleName} ComponentWithModuleName\n */\n"],"names":["GOVUKFrontendError","Error","constructor","args","name","SupportError","$scope","document","body","supportMessage","HTMLScriptElement","prototype","ConfigError","ElementError","messageOrOptions","message","component","identifier","element","expectedType","formatErrorMessage","InitError","componentOrMessage"],"mappings":";;AAsBO,MAAMA,kBAAkB,SAASC,KAAK,CAAC;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA,CAAA;IAAA,IAC5CC,CAAAA,IAAI,GAAG,oBAAoB,CAAA;AAAA,GAAA;AAC7B,CAAA;AAKO,MAAMC,YAAY,SAASL,kBAAkB,CAAC;AAGnD;AACF;AACA;AACA;AACA;AACEE,EAAAA,WAAWA,CAACI,MAAM,GAAGC,QAAQ,CAACC,IAAI,EAAE;IAClC,MAAMC,cAAc,GAClB,UAAU,IAAIC,iBAAiB,CAACC,SAAS,GACrC,gHAAgH,GAChH,kDAAkD,CAAA;AAExD,IAAA,KAAK,CACHL,MAAM,GACFG,cAAc,GACd,8DACN,CAAC,CAAA;IAAA,IAjBHL,CAAAA,IAAI,GAAG,cAAc,CAAA;AAkBrB,GAAA;AACF,CAAA;AAKO,MAAMQ,WAAW,SAASZ,kBAAkB,CAAC;AAAAE,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA,CAAA;IAAA,IAClDC,CAAAA,IAAI,GAAG,aAAa,CAAA;AAAA,GAAA;AACtB,CAAA;AAKO,MAAMS,YAAY,SAASb,kBAAkB,CAAC;EAmBnDE,WAAWA,CAACY,gBAAgB,EAAE;IAC5B,IAAIC,OAAO,GAAG,OAAOD,gBAAgB,KAAK,QAAQ,GAAGA,gBAAgB,GAAG,EAAE,CAAA;AAG1E,IAAA,IAAI,OAAOA,gBAAgB,KAAK,QAAQ,EAAE;MACxC,MAAM;QAAEE,SAAS;QAAEC,UAAU;QAAEC,OAAO;AAAEC,QAAAA,YAAAA;AAAa,OAAC,GAAGL,gBAAgB,CAAA;AAEzEC,MAAAA,OAAO,GAAGE,UAAU,CAAA;MAGpBF,OAAO,IAAIG,OAAO,GACd,CAAmBC,gBAAAA,EAAAA,YAAY,IAAZA,IAAAA,GAAAA,YAAY,GAAI,aAAa,CAAE,CAAA,GAClD,YAAY,CAAA;AAEhBJ,MAAAA,OAAO,GAAGK,kBAAkB,CAACJ,SAAS,EAAED,OAAO,CAAC,CAAA;AAClD,KAAA;IAEA,KAAK,CAACA,OAAO,CAAC,CAAA;IAAA,IAnChBX,CAAAA,IAAI,GAAG,cAAc,CAAA;AAoCrB,GAAA;AACF,CAAA;AAKO,MAAMiB,SAAS,SAASrB,kBAAkB,CAAC;EAOhDE,WAAWA,CAACoB,kBAAkB,EAAE;AAC9B,IAAA,MAAMP,OAAO,GACX,OAAOO,kBAAkB,KAAK,QAAQ,GAClCA,kBAAkB,GAClBF,kBAAkB,CAChBE,kBAAkB,EAClB,8CACF,CAAC,CAAA;IAEP,KAAK,CAACP,OAAO,CAAC,CAAA;IAAA,IAfhBX,CAAAA,IAAI,GAAG,WAAW,CAAA;AAgBlB,GAAA;AACF,CAAA;AAaA;AACA;AACA;;;;"}
|
@@ -1,16 +1,60 @@
|
|
1
|
-
import { isSupported } from './common/index.mjs';
|
2
|
-
import { SupportError } from './errors/index.mjs';
|
1
|
+
import { isInitialised, isSupported } from './common/index.mjs';
|
2
|
+
import { InitError, ElementError, SupportError } from './errors/index.mjs';
|
3
3
|
|
4
4
|
class GOVUKFrontendComponent {
|
5
|
-
|
6
|
-
|
5
|
+
/**
|
6
|
+
* Returns the root element of the component
|
7
|
+
*
|
8
|
+
* @protected
|
9
|
+
* @returns {RootElementType} - the root element of component
|
10
|
+
*/
|
11
|
+
get $root() {
|
12
|
+
return this._$root;
|
7
13
|
}
|
8
|
-
|
14
|
+
constructor($root) {
|
15
|
+
this._$root = void 0;
|
16
|
+
const childConstructor = this.constructor;
|
17
|
+
if (typeof childConstructor.moduleName !== 'string') {
|
18
|
+
throw new InitError(`\`moduleName\` not defined in component`);
|
19
|
+
}
|
20
|
+
if (!($root instanceof childConstructor.elementType)) {
|
21
|
+
throw new ElementError({
|
22
|
+
element: $root,
|
23
|
+
component: childConstructor,
|
24
|
+
identifier: 'Root element (`$root`)',
|
25
|
+
expectedType: childConstructor.elementType.name
|
26
|
+
});
|
27
|
+
} else {
|
28
|
+
this._$root = $root;
|
29
|
+
}
|
30
|
+
childConstructor.checkSupport();
|
31
|
+
this.checkInitialised();
|
32
|
+
const moduleName = childConstructor.moduleName;
|
33
|
+
this.$root.setAttribute(`data-${moduleName}-init`, '');
|
34
|
+
}
|
35
|
+
checkInitialised() {
|
36
|
+
const constructor = this.constructor;
|
37
|
+
const moduleName = constructor.moduleName;
|
38
|
+
if (moduleName && isInitialised(this.$root, moduleName)) {
|
39
|
+
throw new InitError(constructor);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
static checkSupport() {
|
9
43
|
if (!isSupported()) {
|
10
44
|
throw new SupportError();
|
11
45
|
}
|
12
46
|
}
|
13
47
|
}
|
14
48
|
|
49
|
+
/**
|
50
|
+
* @typedef ChildClass
|
51
|
+
* @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
|
52
|
+
*/
|
53
|
+
|
54
|
+
/**
|
55
|
+
* @typedef {typeof GOVUKFrontendComponent & ChildClass} ChildClassConstructor
|
56
|
+
*/
|
57
|
+
GOVUKFrontendComponent.elementType = HTMLElement;
|
58
|
+
|
15
59
|
export { GOVUKFrontendComponent };
|
16
60
|
//# sourceMappingURL=govuk-frontend-component.mjs.map
|