import { getBreakpoint, getFragmentFromUrl } from '../../common/index.mjs'; import { ElementError } from '../../errors/index.mjs'; import { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'; /** * Tabs component * * @preserve */ class Tabs extends GOVUKFrontendComponent { /** * @param {Element | null} $module - HTML element to use for tabs */ constructor($module) { super(); this.$module = void 0; this.$tabs = void 0; this.$tabList = void 0; this.$tabListItems = void 0; this.jsHiddenClass = 'govuk-tabs__panel--hidden'; this.changingHash = false; this.boundTabClick = void 0; this.boundTabKeydown = void 0; this.boundOnHashChange = void 0; this.mql = null; if (!$module) { throw new ElementError({ componentName: 'Tabs', element: $module, identifier: 'Root element (`$module`)' }); } const $tabs = $module.querySelectorAll('a.govuk-tabs__tab'); if (!$tabs.length) { throw new ElementError({ componentName: 'Tabs', identifier: 'Links (``)' }); } this.$module = $module; this.$tabs = $tabs; this.boundTabClick = this.onTabClick.bind(this); this.boundTabKeydown = this.onTabKeydown.bind(this); this.boundOnHashChange = this.onHashChange.bind(this); const $tabList = this.$module.querySelector('.govuk-tabs__list'); const $tabListItems = this.$module.querySelectorAll('li.govuk-tabs__list-item'); if (!$tabList) { throw new ElementError({ componentName: 'Tabs', identifier: 'List (`