{"version":3,"file":"runtime.js","sources":["../src/components/secondary-nav.ts","../src/components/accordion.ts","../src/components/dropdown.ts","../src/components/validated-form.ts","../src/components/product-module.ts","../src/components/slider.ts","../src/runtime.ts"],"sourcesContent":["export class SecondaryNav {\r\n\troot: HTMLFormElement;\r\n\r\n\tconstructor(root: HTMLFormElement) {\r\n\t\tthis.root = root;\r\n\t\tthis.root.dataset.secondaryNav = '';\r\n\t\tthis.bindEvents();\r\n\t}\r\n\r\n\tbindEvents = () => {\r\n\t\tconst navMenu = this.root.querySelector('ul.nav-menu');\r\n\t\tif (!navMenu) return;\r\n\r\n\t\tconst openMobileMenu = () => {\r\n\t\t\tthis.root.scrollIntoView({\r\n\t\t\t\tbehavior: 'smooth',\r\n\t\t\t\tblock: 'start'\r\n\t\t\t});\r\n\t\t\tthis.root.dataset.mobileMenuActive = 'true';\r\n\t\t\tnavMenu.dataset.menuActive = 'true';\r\n\t\t};\r\n\r\n\t\tconst closeMobileMenu = () => {\r\n\t\t\tdelete this.root.dataset.mobileMenuActive;\r\n\t\t\tdelete navMenu.dataset.menuActive;\r\n\t\t};\r\n\r\n\t\tlet mobileMenuDisabled = false;\r\n\t\tconst updateMobileMenuDisabledState = () => {\r\n\t\t\tmobileMenuDisabled = document.body.clientWidth >= 1280;\r\n\t\t\tif (mobileMenuDisabled && !this.root.hasAttribute('data-accordion-disabled')) {\r\n\t\t\t\tthis.root.dataset.accordionDisabled = '';\r\n\t\t\t} else if (!mobileMenuDisabled && this.root.hasAttribute('data-accordion-disabled')) {\r\n\t\t\t\tdelete this.root.dataset.accordionDisabled;\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\tthis.root.querySelectorAll('.page-container > [data-accordion-toggle]').forEach(toggle => {\r\n\t\t\ttoggle.addEventListener('click', () => {\r\n\t\t\t\tif (mobileMenuDisabled) return;\r\n\t\t\t\tif (navMenu.dataset.menuActive) closeMobileMenu();\r\n\t\t\t\telse openMobileMenu();\r\n\t\t\t});\r\n\t\t});\r\n\r\n\t\twindow.addEventListener('resize', updateMobileMenuDisabledState);\r\n\t\tupdateMobileMenuDisabledState();\r\n\t};\r\n}\r\n\r\nconst _instances: SecondaryNav[] = [];\r\n\r\nexport const init = () => {\r\n\tconst navs = Array.from(document.querySelectorAll('header.secondary-nav'));\r\n\r\n\tfor (const root of navs) {\r\n\t\tif (!('secondaryNav' in root.dataset) && !_instances.find(nav => nav.root === root)) _instances.push(new SecondaryNav(root));\r\n\t}\r\n};\r\n\r\nexport default {\r\n\tinit\r\n};\r\n","import { generateId } from '../helpers/index.js';\r\n\r\nexport class Accordion {\r\n\troot: HTMLElement;\r\n\ttoggles: HTMLElement[];\r\n\tcontent: HTMLElement | null;\r\n\tcontentObserver: ResizeObserver;\r\n\tcontentHeight = 'auto';\r\n\r\n\tid: string;\r\n\tgroup: string | null;\r\n\tisOpen: boolean;\r\n\r\n\tconstructor(root: HTMLElement) {\r\n\t\tthis.root = root;\r\n\t\tthis.content = root.querySelector('[data-accordion-content]');\r\n\t\tif (this.content == null) console.warn('[ui:accordion] No content element found.');\r\n\r\n\t\tthis.id = root.dataset.accordion || generateId('accordion');\r\n\t\tthis.group = root.dataset.accordionGroup || null;\r\n\t\tif (root.dataset.accordion !== this.id) root.dataset.accordion = this.id;\r\n\r\n\t\t// add all id-irrelevant toggles inside this accordion\r\n\t\tthis.toggles = Array.from(root.querySelectorAll('[data-accordion-toggle=\"\"]'));\r\n\r\n\t\t// add all toggles elsewhere in the document that point specifically to this accordion's id\r\n\t\tdocument.querySelectorAll(`[data-accordion-toggle=\"${this.id}\"]`).forEach(toggle => {\r\n\t\t\tthis.toggles.push(toggle);\r\n\t\t});\r\n\r\n\t\tthis.contentObserver = new ResizeObserver(this.updateHeight);\r\n\r\n\t\tthis.isOpen = root.dataset.accordionOpen == 'true' || false;\r\n\t}\r\n\r\n\topen = () => {\r\n\t\tif (this.root.hasAttribute('data-accordion-disabled')) return;\r\n\r\n\t\tthis.root.dataset.accordionOpen = 'true';\r\n\t\tthis.content?.classList.add('accordion-open');\r\n\t\tthis.isOpen = true;\r\n\t\tthis.updateHeight();\r\n\r\n\t\t// close all other accordions from the same group\r\n\t\tif (this.group && window.StandardUI.accordion) {\r\n\t\t\tconst targets = window.StandardUI.accordion.instances.filter(acc => acc.group === this.group && acc.id !== this.id);\r\n\t\t\tfor (const accordion of targets) accordion.close();\r\n\t\t}\r\n\t};\r\n\r\n\tclose = () => {\r\n\t\tif (this.root.hasAttribute('data-accordion-disabled')) return;\r\n\r\n\t\tdelete this.root.dataset.accordionOpen;\r\n\t\tthis.content?.classList.remove('accordion-open');\r\n\t\tthis.isOpen = false;\r\n\t\tif (this.content) this.content.style.maxHeight = this.content.scrollHeight + 'px';\r\n\t\tthis.updateHeight();\r\n\t};\r\n\r\n\ttoggle = (evt?: MouseEvent) => {\r\n\t\tif (this.root.dataset.accordionOpen) this.close();\r\n\t\telse this.open();\r\n\r\n\t\tif (evt) evt.preventDefault();\r\n\t};\r\n\r\n\tinit = () => {\r\n\t\tfor (const t of this.toggles) {\r\n\t\t\tt.addEventListener('click', this.toggle);\r\n\t\t}\r\n\r\n\t\tif (this.content) this.contentObserver.observe(this.content);\r\n\t\twindow.addEventListener('resize', this.updateHeight);\r\n\t\tthis.updateHeight();\r\n\t};\r\n\r\n\tdestroy = () => {\r\n\t\tfor (const t of this.toggles) {\r\n\t\t\tt.removeEventListener('click', this.toggle);\r\n\t\t}\r\n\r\n\t\tif (this.content) this.contentObserver.disconnect();\r\n\r\n\t\twindow.removeEventListener('resize', this.updateHeight);\r\n\t};\r\n\r\n\tupdateHeight = () => {\r\n\t\tif (!this.content) return;\r\n\t\tthis.contentHeight = this.content.scrollHeight + 'px';\r\n\t\tthis.content.dataset.height = this.contentHeight;\r\n\r\n\t\tif (this.isOpen && this.content.clientHeight === this.content.scrollHeight) {\r\n\t\t\t// when the accordion is opening and it has reached its target height, we set the max-height to auto\r\n\t\t\tthis.content.style.maxHeight = 'none';\r\n\t\t} else {\r\n\t\t\t// for all other cases, we wait for the transition to naturally happen\r\n\t\t\tthis.content.style.maxHeight = this.isOpen ? this.contentHeight : '0px';\r\n\t\t}\r\n\t};\r\n}\r\n\r\nexport const init = () => {\r\n\tconst accordions = Array.from(document.querySelectorAll('[data-accordion]'));\r\n\tif (!window.StandardUI.accordion) window.StandardUI.accordion = { init, instances: [] };\r\n\r\n\tfor (const root of accordions) {\r\n\t\tif (!window.StandardUI.accordion.instances.find(x => x.root === root)) {\r\n\t\t\tconst accordion = new Accordion(root);\r\n\t\t\taccordion.init();\r\n\t\t\twindow.StandardUI.accordion.instances.push(accordion);\r\n\t\t}\r\n\t}\r\n};\r\n\r\nexport default {\r\n\tinit,\r\n};\r\n","import { Instance as PopperInstance, createPopper, preventOverflow, flip } from '@popperjs/core';\r\n\r\nexport type DropdownOption = {\r\n\ttext: string;\r\n\tvalue: string;\r\n\tcontent: string;\r\n\tdisabled: boolean;\r\n};\r\n\r\nexport type DropdownOptionGroup = {\r\n\tlabel: string;\r\n\toptions: DropdownOption[];\r\n};\r\n\r\nexport class Dropdown {\r\n\troot: HTMLElement;\r\n\tselect: HTMLSelectElement;\r\n\tmultiple: boolean;\r\n\tsearchInput: HTMLInputElement;\r\n\toptions: (DropdownOption | DropdownOptionGroup)[] = [];\r\n\tdropdown: HTMLElement;\r\n\tdropdownOptions: HTMLElement;\r\n\tpopper: PopperInstance;\r\n\r\n\tkeyboardFocus = -1;\r\n\r\n\tconstructor(root: HTMLElement) {\r\n\t\tthis.root = root;\r\n\r\n\t\tconst select = root.querySelector('select');\r\n\t\tif (!select) throw new Error('[ui:dropdown] Dropdown element has no