{"version":3,"sources":["webpack://loftware/./src/js/modules/TabbedBlock.js"],"names":[],"mappings":"+HAEA,eAA0B,KAAU,CAClC,eAAgB,CACd,KAAK,IAAM,CACT,KAAM,KAAK,GAAG,iBAAiB,sBAC/B,UAAW,KAAK,GAAG,iBAAiB,6BAEtC,KAAK,gBAAgB,KAAK,IAAI,KAAK,GAAG,aAAa,kBAGrD,cAAe,CACb,KAAK,IAAI,KAAK,QAAQ,GAAO,CAC3B,EAAI,iBAAiB,QAAS,KAAK,eAAe,KAAK,OACvD,EAAI,iBAAiB,UAAW,GAAK,CACnC,EAAM,OAAS,SACb,KAAK,eAAe,OAM5B,eAAgB,CACd,KAAK,IAAI,UAAU,QAAQ,GAAS,CAClC,EAAM,OAAS,KAEjB,KAAK,IAAI,KAAK,QAAQ,GAAO,CAC3B,EAAI,UAAU,OAAO,+BAIzB,gBAAgB,EAAO,CACrB,KAAK,IAAI,UAAU,QAAQ,GAAS,CAClC,EAAU,KAAO,GAAO,GAAM,OAAS,MAEzC,KAAK,IAAI,KAAK,QAAQ,GAAO,CAC3B,EAAQ,aAAa,mBAAqB,GACxC,EAAI,UAAU,IAAI,+BAIxB,eAAe,EAAG,CAEhB,KAAM,GAAQ,EADA,cACI,aAAa,iBAC/B,KAAK,gBACL,KAAK,gBAAgB,IAIzB,UAAe","file":"scripts/36.47e63ea11018ce2d882f.js","sourcesContent":["import { Component } from '@verndale/core';\r\n\r\nclass TabbedBlock extends Component {\r\n setupDefaults() {\r\n this.dom = {\r\n tabs: this.el.querySelectorAll('.tabbed-block__tab'),\r\n tabPanels: this.el.querySelectorAll('.tabbed-block__tab-panel')\r\n };\r\n this.showActivePanel(this.dom.tabs[0].getAttribute('aria-controls'));\r\n }\r\n\r\n addListeners() {\r\n this.dom.tabs.forEach(tab => {\r\n tab.addEventListener('click', this.handleTabClick.bind(this));\r\n tab.addEventListener('keydown', e => {\r\n if (e.code === 'Enter') {\r\n this.handleTabClick(e);\r\n }\r\n });\r\n });\r\n }\r\n\r\n hideAllPanels() {\r\n this.dom.tabPanels.forEach(panel => {\r\n panel.hidden = true;\r\n });\r\n this.dom.tabs.forEach(tab => {\r\n tab.classList.remove('tabbed-block__tab--active');\r\n });\r\n }\r\n\r\n showActivePanel(tabId) {\r\n this.dom.tabPanels.forEach(panel => {\r\n if (panel.id === tabId) panel.hidden = false;\r\n });\r\n this.dom.tabs.forEach(tab => {\r\n if (tab.getAttribute('aria-controls') === tabId)\r\n tab.classList.add('tabbed-block__tab--active');\r\n });\r\n }\r\n\r\n handleTabClick(e) {\r\n const tab = e.currentTarget;\r\n const tabId = tab.getAttribute('aria-controls');\r\n this.hideAllPanels();\r\n this.showActivePanel(tabId);\r\n }\r\n}\r\n\r\nexport default TabbedBlock;\r\n"],"sourceRoot":""}