{"version":3,"file":"select-dropdown.js","sources":["../../../src/assets/scripts/select-dropdown.entry.ts"],"sourcesContent":["const selectDropdown = {\n parentElem: document?.querySelector('.saig-m-dropdown'),\n init: function () {\n this.addEvent();\n },\n addEvent: function () {\n const dropdown__headers = document?.querySelectorAll('.saig-m-dropdown__header');\n const dropdown__options = document?.querySelectorAll('.saig-m-dropdown__option');\n\n [].forEach.call(dropdown__headers, (dropdown__header: HTMLElement) => {\n dropdown__header?.addEventListener('click', this.expandDropdown.bind(this));\n });\n\n document?.addEventListener('click', this.documentClickHandler.bind(this));\n [].forEach.call(dropdown__options, (node: HTMLElement) => {\n node?.addEventListener('mouseenter', this.hoverDropDownOptionHandler.bind(this));\n node?.addEventListener('click', this.clickDropDownOptionHandler.bind(this));\n });\n },\n expandDropdown: function (event: any) {\n event.preventDefault();\n event.stopPropagation();\n\n if (event.currentTarget.classList.contains('active')) {\n this.collapseAllDropdowns();\n } else {\n this.collapseAllDropdowns();\n const nodes = [event.currentTarget, event.currentTarget.nextElementSibling, event.currentTarget.querySelector('.saig-m-dropdown__header-icon')];\n [].forEach.call(nodes, (node: HTMLElement) => {\n node.classList.contains('active') ? node.classList.remove('active') : node.classList.add('active');\n });\n }\n },\n documentClickHandler: function (event: any) {\n this.collapseAllDropdowns();\n },\n hoverDropDownOptionHandler: function (event: any) {\n event.preventDefault();\n const nodes = event.currentTarget.parentElement.children;\n [].forEach.call(nodes, (node: HTMLElement) => {\n node.classList.remove('highlight');\n node.classList.remove('chosen');\n });\n event.currentTarget.classList.add('highlight');\n },\n clickDropDownOptionHandler: function (event: any) {\n event.preventDefault();\n const selectedValue = event.currentTarget.dataset.value;\n const parentNode = event.currentTarget.closest('.saig-m-dropdown__dropdown');\n const inputName = parentNode.dataset.name;\n const selectedTextElm = parentNode?.querySelector('.saig-m-dropdown__header-text-content');\n selectedTextElm.innerText = event.currentTarget.innerText;\n const inputHidden = document?.querySelector(\"input[name='\" + inputName + \"']\");\n inputHidden!.value = selectedValue;\n inputHidden!.dataset.attr = event.currentTarget.dataset.attr;\n\n window.dispatchEvent(new CustomEvent('dropdownChange', { detail: { inputName: inputHidden?.name } }));\n },\n collapseAllDropdowns: function () {\n const activeNodes = document?.querySelectorAll('.saig-m-dropdown.dropdown-serverside .active');\n [].forEach.call(activeNodes, (node: HTMLDivElement) => {\n node.classList.contains('active') ? node.classList.remove('active') : '';\n });\n },\n};\n\nselectDropdown.init();\n\nexport { selectDropdown };\n"],"names":["selectDropdown","dropdown__headers","dropdown__options","dropdown__header","node","event","nodes","selectedValue","parentNode","inputName","selectedTextElm","inputHidden","activeNodes"],"mappings":"AAAA,MAAMA,EAAiB,CACrB,WAAY,+BAAU,cAA8B,oBACpD,KAAM,UAAY,CAChB,KAAK,SAAS,CAChB,EACA,SAAU,UAAY,CACd,MAAAC,EAAoB,+BAAU,iBAAiC,4BAC/DC,EAAoB,+BAAU,iBAAiC,4BAErE,CAAA,EAAG,QAAQ,KAAKD,EAAoBE,GAAkC,CACpEA,GAAA,MAAAA,EAAkB,iBAAiB,QAAS,KAAK,eAAe,KAAK,IAAI,EAAC,CAC3E,EAED,yBAAU,iBAAiB,QAAS,KAAK,qBAAqB,KAAK,IAAI,GACvE,CAAA,EAAG,QAAQ,KAAKD,EAAoBE,GAAsB,CACxDA,GAAA,MAAAA,EAAM,iBAAiB,aAAc,KAAK,2BAA2B,KAAK,IAAI,GAC9EA,GAAA,MAAAA,EAAM,iBAAiB,QAAS,KAAK,2BAA2B,KAAK,IAAI,EAAC,CAC3E,CACH,EACA,eAAgB,SAAUC,EAAY,CAIpC,GAHAA,EAAM,eAAe,EACrBA,EAAM,gBAAgB,EAElBA,EAAM,cAAc,UAAU,SAAS,QAAQ,EACjD,KAAK,qBAAqB,MACrB,CACL,KAAK,qBAAqB,EACpB,MAAAC,EAAQ,CAACD,EAAM,cAAeA,EAAM,cAAc,mBAAoBA,EAAM,cAAc,cAAc,+BAA+B,CAAC,EAC9I,CAAA,EAAG,QAAQ,KAAKC,EAAQF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