You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
1.9 KiB
1 lines
1.9 KiB
import"./common-DqchIN4G.js";function e(){document.querySelectorAll(`.c-field__select`).forEach(e=>{if(e.dataset.customized)return;e.dataset.customized=`true`,e.classList.add(`c-custom-select__native`),e.tabIndex=-1;let t=document.createElement(`div`);e.parentNode.insertBefore(t,e),t.appendChild(e),t.className=`c-custom-select`;let n=document.createElement(`button`);n.type=`button`,n.className=`c-custom-select__trigger`,n.setAttribute(`aria-haspopup`,`listbox`),n.setAttribute(`aria-expanded`,`false`),t.appendChild(n);let r=document.createElement(`div`);r.className=`c-custom-select__dropdown`,r.setAttribute(`role`,`listbox`),t.appendChild(r);function i(){r.innerHTML=``,Array.from(e.options).forEach((e,t)=>{if(e.disabled)return;let n=document.createElement(`button`);n.type=`button`,n.className=`c-custom-select__option`,n.setAttribute(`role`,`option`),n.dataset.value=e.value,n.textContent=e.textContent,e.selected&&e.value&&n.classList.add(`is-active`),n.addEventListener(`click`,()=>o(t)),r.appendChild(n)})}function a(){let t=e.selectedIndex,i=e.options[t];n.textContent=i?i.textContent:``,n.classList.toggle(`is-placeholder`,!i||i.disabled),r.querySelectorAll(`.c-custom-select__option`).forEach(t=>{t.classList.toggle(`is-active`,t.dataset.value===e.value)})}function o(t){e.selectedIndex=t,e.dispatchEvent(new Event(`change`,{bubbles:!0})),a(),c()}function s(){i(),r.classList.add(`is-visible`),n.classList.add(`is-open`),n.setAttribute(`aria-expanded`,`true`)}function c(){r.classList.remove(`is-visible`),n.classList.remove(`is-open`),n.setAttribute(`aria-expanded`,`false`)}function l(){r.classList.contains(`is-visible`)?c():s()}n.addEventListener(`click`,l),document.addEventListener(`click`,e=>{t.contains(e.target)||c()}),t.addEventListener(`keydown`,e=>{e.key===`Escape`&&(c(),n.focus()),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l())}),a()})}$(function(){e()});
|