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} $root - HTML element to use for tabs */ constructor($root) { super($root); 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; const $tabs = this.$root.querySelectorAll('a.govuk-tabs__tab'); if (!$tabs.length) { throw new ElementError({ component: Tabs, identifier: 'Links (``)' }); } this.$tabs = $tabs; this.boundTabClick = this.onTabClick.bind(this); this.boundTabKeydown = this.onTabKeydown.bind(this); this.boundOnHashChange = this.onHashChange.bind(this); const $tabList = this.$root.querySelector('.govuk-tabs__list'); const $tabListItems = this.$root.querySelectorAll('li.govuk-tabs__list-item'); if (!$tabList) { throw new ElementError({ component: Tabs, identifier: 'List (`