Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@preline/combobox

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@preline/combobox - npm Package Compare versions

Comparing version 2.1.0 to 2.3.0

10

index.d.ts

@@ -38,2 +38,3 @@

preventSelection?: boolean;
preventAutoPosition?: boolean;
isOpenOnFocus?: boolean;

@@ -64,2 +65,3 @@ }

preventSelection: boolean;
preventAutoPosition: boolean;
isOpenOnFocus: boolean;

@@ -72,2 +74,4 @@ private readonly input;

private readonly toggle;
private readonly toggleClose;
private readonly toggleOpen;
private outputPlaceholder;

@@ -82,3 +86,3 @@ private outputLoader;

private animationInProcess;
constructor(el: HTMLElement, options?: IComboBoxOptions);
constructor(el: HTMLElement, options?: IComboBoxOptions, events?: {});
private init;

@@ -108,2 +112,4 @@ private build;

private buildToggle;
private buildToggleClose;
private buildToggleOpen;
private setSelectedByValue;

@@ -126,2 +132,4 @@ private setValue;

static closeCurrentlyOpened(evtTarget?: HTMLElement | null): void;
private static getPreparedItems;
private static setHighlighted;
static accessibility(evt: KeyboardEvent): void;

@@ -128,0 +136,0 @@ static onEscape(): void;

2

index.js

@@ -17,2 +17,2 @@ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o=e();for(var i in o)("object"==typeof exports?exports:t)[i]=o[i]}}(self,(()=>(()=>{"use strict";var t={190:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BREAKPOINTS=e.COMBO_BOX_ACCESSIBILITY_KEY_SET=e.SELECT_ACCESSIBILITY_KEY_SET=e.TABS_ACCESSIBILITY_KEY_SET=e.OVERLAY_ACCESSIBILITY_KEY_SET=e.DROPDOWN_ACCESSIBILITY_KEY_SET=e.POSITIONS=void 0,e.POSITIONS={auto:"auto","auto-start":"auto-start","auto-end":"auto-end",top:"top","top-left":"top-start","top-right":"top-end",bottom:"bottom","bottom-left":"bottom-start","bottom-right":"bottom-end",right:"right","right-start":"right-start","right-end":"right-end",left:"left","left-start":"left-start","left-end":"left-end"},e.DROPDOWN_ACCESSIBILITY_KEY_SET=["Escape","ArrowUp","ArrowDown","Home","End","Enter"],e.OVERLAY_ACCESSIBILITY_KEY_SET=["Escape","Tab"],e.TABS_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End"],e.SELECT_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter","Tab"],e.COMBO_BOX_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter"],e.BREAKPOINTS={sm:640,md:768,lg:1024,xl:1280,"2xl":1536}},737:(t,e)=>{

*/
var i,n=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}),r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,o=1,i=arguments.length;o<i;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},r.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,o,i){return new(o||(o=Promise))((function(n,r){function s(t){try{a(i.next(t))}catch(t){r(t)}}function l(t){try{a(i.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,l)}a((i=i.apply(t,e||[])).next())}))},l=this&&this.__generator||function(t,e){var o,i,n,r,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function l(l){return function(a){return function(l){if(o)throw new TypeError("Generator is already executing.");for(;r&&(r=0,l[0]&&(s=0)),s;)try{if(o=1,i&&(n=2&l[0]?i.return:l[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,l[1])).done)return n;switch(i=0,n&&(l=[2&l[0],n.value]),l[0]){case 0:case 1:n=l;break;case 4:return s.label++,{value:l[1],done:!1};case 5:s.label++,i=l[1],l=[0];continue;case 7:l=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==l[0]&&2!==l[0])){s=0;continue}if(3===l[0]&&(!n||l[1]>n[0]&&l[1]<n[3])){s.label=l[1];break}if(6===l[0]&&s.label<n[1]){s.label=n[1],n=l;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(l);break}n[2]&&s.ops.pop(),s.trys.pop();continue}l=e.call(t,s)}catch(t){l=[6,t],i=0}finally{o=n=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,a])}}},a=this&&this.__spreadArray||function(t,e,o){if(o||2===arguments.length)for(var i,n=0,r=e.length;n<r;n++)!i&&n in e||(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0});var u=o(969),c=o(737),p=o(190),d=function(t){function e(e,o){var i,n,s,l,a,u,c,p,d,h,m,f,b,v,y,g,x,E,T,w,S,A,C=t.call(this,e,o)||this,I=e.getAttribute("data-hs-combo-box"),L=I?JSON.parse(I):{},O=r(r({},L),o);return C.gap=5,C.viewport=null!==(i="string"==typeof(null==O?void 0:O.viewport)?document.querySelector(null==O?void 0:O.viewport):null==O?void 0:O.viewport)&&void 0!==i?i:null,C.preventVisibility=null!==(n=null==O?void 0:O.preventVisibility)&&void 0!==n&&n,C.apiUrl=null!==(s=null==O?void 0:O.apiUrl)&&void 0!==s?s:null,C.apiDataPart=null!==(l=null==O?void 0:O.apiDataPart)&&void 0!==l?l:null,C.apiQuery=null!==(a=null==O?void 0:O.apiQuery)&&void 0!==a?a:null,C.apiSearchQuery=null!==(u=null==O?void 0:O.apiSearchQuery)&&void 0!==u?u:null,C.apiHeaders=null!==(c=null==O?void 0:O.apiHeaders)&&void 0!==c?c:{},C.apiGroupField=null!==(p=null==O?void 0:O.apiGroupField)&&void 0!==p?p:null,C.outputItemTemplate=null!==(d=null==O?void 0:O.outputItemTemplate)&&void 0!==d?d:'<div class="cursor-pointer py-2 px-4 w-full text-sm text-gray-800 hover:bg-gray-100 rounded-lg focus:outline-none focus:bg-gray-100 dark:bg-slate-900 dark:hover:bg-slate-800 dark:text-gray-200 dark:focus:bg-slate-800" data-hs-combo-box-output-item>\n\t\t\t<div class="flex justify-between items-center w-full">\n\t\t\t\t<span data-hs-combo-box-search-text></span>\n\t\t\t\t<span class="hidden hs-combo-box-selected:block">\n\t\t\t\t\t<svg class="flex-shrink-0 size-3.5 text-blue-600 dark:text-blue-500" xmlns="http:.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n\t\t\t\t\t\t<polyline points="20 6 9 17 4 12"></polyline>\n\t\t\t\t\t</svg>\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t</div>',C.outputEmptyTemplate=null!==(h=null==O?void 0:O.outputEmptyTemplate)&&void 0!==h?h:'<div class="py-2 px-4 w-full text-sm text-gray-800 rounded-lg dark:bg-slate-900 dark:text-gray-200">Nothing found...</div>',C.outputLoaderTemplate=null!==(m=null==O?void 0:O.outputLoaderTemplate)&&void 0!==m?m:'<div class="flex justify-center items-center py-2 px-4 text-sm text-gray-800 rounded-lg bg-white dark:bg-slate-900 dark:text-gray-200">\n\t\t\t\t<div class="animate-spin inline-block size-6 border-[3px] border-current border-t-transparent text-blue-600 rounded-full dark:text-blue-500" role="status" aria-label="loading">\n\t\t\t\t\t<span class="sr-only">Loading...</span>\n\t\t\t\t</div>\n\t\t\t</div>',C.groupingType=null!==(f=null==O?void 0:O.groupingType)&&void 0!==f?f:null,C.groupingTitleTemplate=null!==(b=null==O?void 0:O.groupingTitleTemplate)&&void 0!==b?b:"default"===C.groupingType?'<div class="block mb-1 text-xs font-semibold uppercase text-blue-600 dark:text-blue-500"></div>':'<button type="button" class="py-2 px-3 inline-flex items-center gap-x-2 text-sm font-semibold whitespace-nowrap rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 disabled:pointer-events-none"></button>',C.tabsWrapperTemplate=null!==(v=null==O?void 0:O.tabsWrapperTemplate)&&void 0!==v?v:'<div class="overflow-x-auto p-4"></div>',C.preventSelection=null!==(y=null==O?void 0:O.preventSelection)&&void 0!==y&&y,C.isOpenOnFocus=null!==(g=null==O?void 0:O.isOpenOnFocus)&&void 0!==g&&g,C.input=null!==(x=C.el.querySelector("[data-hs-combo-box-input]"))&&void 0!==x?x:null,C.output=null!==(E=C.el.querySelector("[data-hs-combo-box-output]"))&&void 0!==E?E:null,C.itemsWrapper=null!==(T=C.el.querySelector("[data-hs-combo-box-output-items-wrapper]"))&&void 0!==T?T:null,C.items=null!==(w=Array.from(C.el.querySelectorAll("[data-hs-combo-box-output-item]")))&&void 0!==w?w:[],C.tabs=[],C.toggle=null!==(S=C.el.querySelector("[data-hs-combo-box-toggle]"))&&void 0!==S?S:null,C.outputPlaceholder=null,C.selected=C.value=null!==(A=C.el.querySelector("[data-hs-combo-box-input]").value)&&void 0!==A?A:"",C.isOpened=!1,C.isCurrent=!1,C.animationInProcess=!1,C.selectedGroup="all",C.init(),C}return n(e,t),e.prototype.init=function(){this.createCollection(window.$hsComboBoxCollection,this),this.build()},e.prototype.build=function(){this.buildInput(),this.groupingType&&this.setGroups(),this.buildItems(),this.preventVisibility&&(this.isOpened=!0,this.recalculateDirection()),this.toggle&&this.buildToggle()},e.prototype.setResultAndRender=function(t){void 0===t&&(t=""),this.setResults(t),this.apiSearchQuery&&this.itemsFromJson()},e.prototype.buildInput=function(){var t=this;this.isOpenOnFocus&&this.input.addEventListener("focus",(function(){t.isOpened||(t.setResultAndRender(),t.open())})),this.input.addEventListener("input",(0,u.debounce)((function(e){t.setResultAndRender(e.target.value),t.isOpened||t.open()})))},e.prototype.buildItems=function(){this.apiUrl?this.itemsFromJson():(this.itemsWrapper?this.itemsWrapper.innerHTML="":this.output.innerHTML="",this.itemsFromHtml())},e.prototype.setResults=function(t){this.value=t,this.resultItems(),this.hasVisibleItems()?this.destroyOutputPlaceholder():this.buildOutputPlaceholder()},e.prototype.isItemExists=function(t){return this.items.some((function(e){return Array.from(e.querySelectorAll("[data-hs-combo-box-search-text]")).some((function(e){return e.getAttribute("data-hs-combo-box-search-text")===t[e.getAttribute("data-hs-combo-box-output-item-field")]}))}))},e.prototype.isTextExists=function(t,e){var o=e.map((function(t){return t.toLowerCase()}));return Array.from(t.querySelectorAll("[data-hs-combo-box-search-text]")).some((function(t){return o.includes(t.getAttribute("data-hs-combo-box-search-text").toLowerCase())}))},e.prototype.isTextExistsAny=function(t,e){return Array.from(t.querySelectorAll("[data-hs-combo-box-search-text]")).some((function(t){return t.getAttribute("data-hs-combo-box-search-text").toLowerCase().includes(e.toLowerCase())}))},e.prototype.valuesBySelector=function(t){return Array.from(t.querySelectorAll("[data-hs-combo-box-search-text]")).reduce((function(t,e){return a(a([],t,!0),[e.getAttribute("data-hs-combo-box-search-text")],!1)}),[])},e.prototype.buildOutputLoader=function(){if(this.outputLoader)return!1;this.outputLoader=(0,u.htmlToElement)(this.outputLoaderTemplate),this.items.length||this.outputPlaceholder?(this.outputLoader.style.position="absolute",this.outputLoader.style.top="0",this.outputLoader.style.bottom="0",this.outputLoader.style.left="0",this.outputLoader.style.right="0",this.outputLoader.style.zIndex="2"):(this.outputLoader.style.position="",this.outputLoader.style.top="",this.outputLoader.style.bottom="",this.outputLoader.style.left="",this.outputLoader.style.right="",this.outputLoader.style.zIndex="",this.outputLoader.style.height="30px"),this.output.append(this.outputLoader)},e.prototype.destroyOutputLoader=function(){this.outputLoader&&this.outputLoader.remove(),this.outputLoader=null},e.prototype.itemsFromJson=function(){return s(this,void 0,void 0,(function(){var t,e,o,i,n,r=this;return l(this,(function(s){switch(s.label){case 0:this.buildOutputLoader(),s.label=1;case 1:return s.trys.push([1,4,,5]),t="".concat(this.apiQuery),e="".concat(this.apiSearchQuery,"=").concat(this.value.toLowerCase()),o=this.apiUrl,this.apiQuery&&this.apiSearchQuery?o+="?".concat(e,"&").concat(t):this.apiQuery?o+="?".concat(t):this.apiSearchQuery&&(o+="?".concat(e)),[4,fetch(o,this.apiHeaders)];case 2:return[4,s.sent().json()];case 3:return i=s.sent(),this.apiDataPart&&(i=i[this.apiDataPart]),this.apiSearchQuery&&(this.items=[]),this.itemsWrapper?this.itemsWrapper.innerHTML="":this.output.innerHTML="","tabs"===this.groupingType?(this.setApiGroups(i),this.groupTabsRender(),this.jsonItemsRender(i)):"default"===this.groupingType?(this.setApiGroups(i),this.groups.forEach((function(t){var e=(0,u.htmlToElement)(r.groupingTitleTemplate);e.setAttribute("data-hs-combo-box-group-title",t.name),e.classList.add("--exclude-accessibility"),e.innerText=t.title;var o=i.filter((function(e){return e[r.apiGroupField]===t.name}));r.itemsWrapper?r.itemsWrapper.append(e):r.output.append(e),r.jsonItemsRender(o)}))):this.jsonItemsRender(i),this.setResults(this.input.value),[3,5];case 4:return n=s.sent(),console.error(n),[3,5];case 5:return this.destroyOutputLoader(),[2]}}))}))},e.prototype.jsonItemsRender=function(t){var e=this;t.forEach((function(t,o){if(e.isItemExists(t))return!1;var i=(0,u.htmlToElement)(e.outputItemTemplate);i.querySelectorAll("[data-hs-combo-box-search-text]").forEach((function(e){var o,i;e.textContent=null!==(o=t[e.getAttribute("data-hs-combo-box-output-item-field")])&&void 0!==o?o:"",e.setAttribute("data-hs-combo-box-search-text",null!==(i=t[e.getAttribute("data-hs-combo-box-output-item-field")])&&void 0!==i?i:"")})),i.querySelectorAll("[data-hs-combo-box-output-item-attr]").forEach((function(e){JSON.parse(e.getAttribute("data-hs-combo-box-output-item-attr")).forEach((function(o){e.setAttribute(o.attr,t[o.valueFrom])}))})),i.setAttribute("tabIndex","".concat(o)),"tabs"!==e.groupingType&&"default"!==e.groupingType||i.setAttribute("data-hs-combo-box-output-item",'{"group": {"name": "'.concat(t[e.apiGroupField],'", "title": "').concat(t[e.apiGroupField],'"}}')),e.items=a(a([],e.items,!0),[i],!1),e.preventSelection||i.addEventListener("click",(function(){e.close(i.querySelector("[data-hs-combo-box-value]").getAttribute("data-hs-combo-box-search-text")),e.setSelectedByValue(e.valuesBySelector(i))})),e.appendItemsToWrapper(i)}))},e.prototype.setGroups=function(){var t=[];this.items.forEach((function(e){var o=JSON.parse(e.getAttribute("data-hs-combo-box-output-item")).group;t.some((function(t){return(null==t?void 0:t.name)===o.name}))||t.push(o)})),this.groups=t},e.prototype.setCurrent=function(){window.$hsComboBoxCollection.length&&(window.$hsComboBoxCollection.map((function(t){return t.element.isCurrent=!1})),this.isCurrent=!0)},e.prototype.setApiGroups=function(t){var e=this,o=[];t.forEach((function(t){var i=t[e.apiGroupField];o.some((function(t){return t.name===i}))||o.push({name:i,title:i})})),this.groups=o},e.prototype.sortItems=function(){return this.items.sort((function(t,e){var o=t.querySelector("[data-hs-combo-box-value]").getAttribute("data-hs-combo-box-search-text"),i=e.querySelector("[data-hs-combo-box-value]").getAttribute("data-hs-combo-box-search-text");return o<i?-1:o>i?1:0}))},e.prototype.itemRender=function(t){var e=this,o=t.querySelector("[data-hs-combo-box-value]").getAttribute("data-hs-combo-box-search-text");this.itemsWrapper?this.itemsWrapper.append(t):this.output.append(t),this.preventSelection||t.addEventListener("click",(function(){e.close(o),e.setSelectedByValue(e.valuesBySelector(t))}))},e.prototype.plainRender=function(t){var e=this;t.forEach((function(t){e.itemRender(t)}))},e.prototype.groupTabsRender=function(){var t=this,e=(0,u.htmlToElement)(this.tabsWrapperTemplate),o=(0,u.htmlToElement)('<div class="flex flex-nowrap gap-x-2"></div>');e.append(o),this.output.insertBefore(e,this.output.firstChild);var i=(0,u.htmlToElement)(this.groupingTitleTemplate);i.setAttribute("data-hs-combo-box-group-title","all"),i.classList.add("--exclude-accessibility","active"),i.innerText="All",this.tabs=a(a([],this.tabs,!0),[i],!1),o.append(i),i.addEventListener("click",(function(){t.selectedGroup="all";var e=t.tabs.find((function(e){return e.getAttribute("data-hs-combo-box-group-title")===t.selectedGroup}));t.tabs.forEach((function(t){return t.classList.remove("active")})),e.classList.add("active"),t.setItemsVisibility()})),this.groups.forEach((function(e){var i=(0,u.htmlToElement)(t.groupingTitleTemplate);i.setAttribute("data-hs-combo-box-group-title",e.name),i.classList.add("--exclude-accessibility"),i.innerText=e.title,t.tabs=a(a([],t.tabs,!0),[i],!1),o.append(i),i.addEventListener("click",(function(){t.selectedGroup=e.name;var o=t.tabs.find((function(e){return e.getAttribute("data-hs-combo-box-group-title")===t.selectedGroup}));t.tabs.forEach((function(t){return t.classList.remove("active")})),o.classList.add("active"),t.setItemsVisibility()}))}))},e.prototype.groupDefaultRender=function(){var t=this;this.groups.forEach((function(e){var o=(0,u.htmlToElement)(t.groupingTitleTemplate);o.setAttribute("data-hs-combo-box-group-title",e.name),o.classList.add("--exclude-accessibility"),o.innerText=e.title,t.itemsWrapper?t.itemsWrapper.append(o):t.output.append(o);var i=t.sortItems().filter((function(t){return JSON.parse(t.getAttribute("data-hs-combo-box-output-item")).group.name===e.name}));t.plainRender(i)}))},e.prototype.itemsFromHtml=function(){if("default"===this.groupingType)this.groupDefaultRender();else if("tabs"===this.groupingType){var t=this.sortItems();this.groupTabsRender(),this.plainRender(t)}else{t=this.sortItems();this.plainRender(t)}this.setResults(this.input.value)},e.prototype.buildToggle=function(){var t=this;this.toggle.addEventListener("click",(function(){t.isOpened?t.close():t.open(t.toggle.getAttribute("data-hs-combo-box-toggle"))}))},e.prototype.setSelectedByValue=function(t){var e=this;this.items.forEach((function(o){e.isTextExists(o,t)?o.classList.add("selected"):o.classList.remove("selected")}))},e.prototype.setValue=function(t){this.selected=t,this.value=t,this.input.value=t},e.prototype.setItemsVisibility=function(){var t=this;"tabs"===this.groupingType&&"all"!==this.selectedGroup&&this.items.forEach((function(t){t.style.display="none"}));var e="tabs"===this.groupingType?"all"===this.selectedGroup?this.items:this.items.filter((function(e){return JSON.parse(e.getAttribute("data-hs-combo-box-output-item")).group.name===t.selectedGroup})):this.items;"tabs"===this.groupingType&&"all"!==this.selectedGroup&&e.forEach((function(t){t.style.display="block"})),e.forEach((function(e){t.isTextExistsAny(e,t.value)?e.style.display="block":e.style.display="none"})),"default"===this.groupingType&&this.output.querySelectorAll("[data-hs-combo-box-group-title]").forEach((function(e){var o=e.getAttribute("data-hs-combo-box-group-title");t.items.filter((function(t){return JSON.parse(t.getAttribute("data-hs-combo-box-output-item")).group.name===o&&"block"===t.style.display})).length?e.style.display="block":e.style.display="none"}))},e.prototype.hasVisibleItems=function(){return!!this.items.length&&this.items.some((function(t){return"block"===t.style.display}))},e.prototype.appendItemsToWrapper=function(t){this.itemsWrapper?this.itemsWrapper.append(t):this.output.append(t)},e.prototype.buildOutputPlaceholder=function(){this.outputPlaceholder||(this.outputPlaceholder=(0,u.htmlToElement)(this.outputEmptyTemplate)),this.appendItemsToWrapper(this.outputPlaceholder)},e.prototype.destroyOutputPlaceholder=function(){this.outputPlaceholder&&this.outputPlaceholder.remove(),this.outputPlaceholder=null},e.prototype.resultItems=function(){if(!this.items.length)return!1;this.setItemsVisibility(),this.setSelectedByValue([this.selected])},e.prototype.setValueAndOpen=function(t){this.value=t,this.items.length&&this.setItemsVisibility()},e.prototype.open=function(t){var e=this;return!this.animationInProcess&&(void 0!==t&&this.setValueAndOpen(t),!this.preventVisibility&&(this.animationInProcess=!0,this.output.style.display="block",this.recalculateDirection(),setTimeout((function(){e.el.classList.add("active"),e.animationInProcess=!1})),void(this.isOpened=!0)))},e.prototype.setValueAndClear=function(t){t?this.setValue(t):this.setValue(this.selected),this.outputPlaceholder&&this.destroyOutputPlaceholder()},e.prototype.close=function(t){var e=this;return!this.animationInProcess&&(this.preventVisibility?(this.setValueAndClear(t),!1):(this.animationInProcess=!0,this.el.classList.remove("active"),this.output.classList.remove("bottom-full","top-full"),this.output.style.marginTop="",this.output.style.marginBottom="",(0,u.afterTransition)(this.output,(function(){e.output.style.display="none",e.setValueAndClear(t),e.animationInProcess=!1})),void(this.isOpened=!1)))},e.prototype.recalculateDirection=function(){(0,u.isEnoughSpace)(this.output,this.input,"bottom",this.gap,this.viewport)?(this.output.classList.remove("bottom-full"),this.output.style.marginBottom="",this.output.classList.add("top-full"),this.output.style.marginTop="".concat(this.gap,"px")):(this.output.classList.remove("top-full"),this.output.style.marginTop="",this.output.classList.add("bottom-full"),this.output.style.marginBottom="".concat(this.gap,"px"))},e.getInstance=function(t,e){var o=window.$hsComboBoxCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));return o?e?o:o.element:null},e.autoInit=function(){window.$hsComboBoxCollection||(window.$hsComboBoxCollection=[]),document.querySelectorAll("[data-hs-combo-box]:not(.--prevent-on-load-init)").forEach((function(t){if(!window.$hsComboBoxCollection.find((function(e){var o;return(null===(o=null==e?void 0:e.element)||void 0===o?void 0:o.el)===t}))){var o=t.getAttribute("data-hs-combo-box"),i=o?JSON.parse(o):{};new e(t,i)}})),window.$hsComboBoxCollection&&(window.addEventListener("click",(function(t){var o=t.target;e.closeCurrentlyOpened(o)})),document.addEventListener("keydown",(function(t){return e.accessibility(t)})))},e.close=function(t){var e=window.$hsComboBoxCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));e&&e.element.isOpened&&e.element.close()},e.closeCurrentlyOpened=function(t){if(void 0===t&&(t=null),!t.closest("[data-hs-combo-box].active")){var e=window.$hsComboBoxCollection.filter((function(t){return t.element.isOpened}))||null;e&&e.forEach((function(t){t.element.close()}))}},e.getPreparedItems=function(t,e){return void 0===t&&(t=!1),e?(t?Array.from(e.querySelectorAll(":scope > *:not(.--exclude-accessibility)")).filter((function(t){return"none"!==t.style.display})).reverse():Array.from(e.querySelectorAll(":scope > *:not(.--exclude-accessibility)")).filter((function(t){return"none"!==t.style.display}))).filter((function(t){return!t.classList.contains("disabled")})):null},e.setHighlighted=function(t,e,o){e.focus(),o.value=e.querySelector("[data-hs-combo-box-value]").getAttribute("data-hs-combo-box-search-text"),t&&t.classList.remove("hs-combo-box-output-item-highlighted"),e.classList.add("hs-combo-box-output-item-highlighted")},e.accessibility=function(t){if(window.$hsComboBoxCollection.find((function(t){return t.element.isOpened}))&&p.COMBO_BOX_ACCESSIBILITY_KEY_SET.includes(t.code)&&!t.metaKey)switch(t.code){case"Escape":t.preventDefault(),this.onEscape();break;case"ArrowUp":t.preventDefault(),this.onArrow();break;case"ArrowDown":t.preventDefault(),this.onArrow(!1);break;case"Home":t.preventDefault(),this.onStartEnd();break;case"End":t.preventDefault(),this.onStartEnd(!1);break;case"Enter":t.preventDefault(),this.onEnter(t)}},e.onEscape=function(){var t=window.$hsComboBoxCollection.find((function(t){return!t.element.preventVisibility&&t.element.isOpened}));t&&(t.element.close(),t.element.input.blur())},e.onArrow=function(t){var o;void 0===t&&(t=!0);var i=window.$hsComboBoxCollection.find((function(t){return t.element.preventVisibility?t.element.isCurrent:t.element.isOpened}));if(i){var n=null!==(o=i.element.itemsWrapper)&&void 0!==o?o:i.element.output;if(!n)return!1;var r,s=e.getPreparedItems(t,n),l=n.querySelector(".hs-combo-box-output-item-highlighted");l||s[0].classList.add("hs-combo-box-output-item-highlighted");var a=s.findIndex((function(t){return t===l}));a+1<s.length&&a++,r=s[a],e.setHighlighted(l,r,i.element.input)}},e.onStartEnd=function(t){var o;void 0===t&&(t=!0);var i=window.$hsComboBoxCollection.find((function(t){return t.element.preventVisibility?t.element.isCurrent:t.element.isOpened}));if(i){var n=null!==(o=i.element.itemsWrapper)&&void 0!==o?o:i.element.output;if(!n)return!1;var r=e.getPreparedItems(t,n),s=n.querySelector(".hs-combo-box-output-item-highlighted");r.length&&e.setHighlighted(s,r[0],i.element.input)}},e.onEnter=function(t){var e=t.target,o=window.$hsComboBoxCollection.find((function(t){return!(0,u.isParentOrElementHidden)(t.element.el)&&t.element.isOpened})),i=o.element.el.querySelector("a");e.hasAttribute("data-hs-combo-box-input")?(o.element.close(),e.blur()):(o.element.preventSelection||o.element.setSelectedByValue(o.element.valuesBySelector(t.target)),o.element.preventSelection&&i&&window.location.assign(i.getAttribute("href")),o.element.close(o.element.preventSelection?null:t.target.querySelector("[data-hs-combo-box-value]").getAttribute("data-hs-combo-box-search-text")))},e}(c.default);window.addEventListener("load",(function(){d.autoInit()})),document.addEventListener("scroll",(function(){if(!window.$hsComboBoxCollection)return!1;var t=window.$hsComboBoxCollection.find((function(t){return t.element.isOpened}));t&&t.element.recalculateDirection()})),"undefined"!=typeof window&&(window.HSComboBox=d),e.default=d},969:function(t,e){var o=this;Object.defineProperty(e,"__esModule",{value:!0}),e.menuSearchHistory=e.classToClassList=e.htmlToElement=e.afterTransition=e.dispatch=e.debounce=e.isFormElement=e.isParentOrElementHidden=e.isEnoughSpace=e.isIpadOS=e.isIOS=e.getClassPropertyAlt=e.getClassProperty=e.stringToBoolean=void 0;e.stringToBoolean=function(t){return"true"===t};e.getClassProperty=function(t,e,o){return void 0===o&&(o=""),(window.getComputedStyle(t).getPropertyValue(e)||o).replace(" ","")};e.getClassPropertyAlt=function(t,e,o){void 0===o&&(o="");var i="";return t.classList.forEach((function(t){t.includes(e)&&(i=t)})),i.match(/:(.*)]/)?i.match(/:(.*)]/)[1]:o};e.isIOS=function(){return!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};e.isIpadOS=function(){return navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};e.isEnoughSpace=function(t,e,o,i,n){void 0===o&&(o="auto"),void 0===i&&(i=10),void 0===n&&(n=null);var r=e.getBoundingClientRect(),s=n?n.getBoundingClientRect():null,l=window.innerHeight,a=s?r.top-s.top:r.top,u=(n?s.bottom:l)-r.bottom,c=t.clientHeight+i;return"bottom"===o?u>=c:"top"===o?a>=c:a>=c||u>=c};e.isFormElement=function(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement};var i=function(t){return!!t&&("none"===window.getComputedStyle(t).display||i(t.parentElement))};e.isParentOrElementHidden=i;e.debounce=function(t,e){var i;return void 0===e&&(e=200),function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];clearTimeout(i),i=setTimeout((function(){t.apply(o,n)}),e)}};e.dispatch=function(t,e,o){void 0===o&&(o=null);var i=new CustomEvent(t,{detail:{payload:o},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(i)};e.afterTransition=function(t,e){var o=function(){e(),t.removeEventListener("transitionend",o,!0)};window.getComputedStyle(t,null).getPropertyValue("transition")!==(navigator.userAgent.includes("Firefox")?"all":"all 0s ease 0s")?t.addEventListener("transitionend",o,!0):e()};e.htmlToElement=function(t){var e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild};e.classToClassList=function(t,e,o,i){void 0===o&&(o=" "),void 0===i&&(i="add"),t.split(o).forEach((function(t){return"add"===i?e.classList.add(t):e.classList.remove(t)}))};e.menuSearchHistory={historyIndex:-1,addHistory:function(t){this.historyIndex=t},existsInHistory:function(t){return t>this.historyIndex},clearHistory:function(){this.historyIndex=-1}}}},e={};var o=function o(i){var n=e[i];if(void 0!==n)return n.exports;var r=e[i]={exports:{}};return t[i].call(r.exports,r,r.exports,o),r.exports}(23);return o})()));
var i,n=this&&this.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},i(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}),r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,o=1,i=arguments.length;o<i;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},r.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,o,i){return new(o||(o=Promise))((function(n,r){function s(t){try{u(i.next(t))}catch(t){r(t)}}function l(t){try{u(i.throw(t))}catch(t){r(t)}}function u(t){var e;t.done?n(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(s,l)}u((i=i.apply(t,e||[])).next())}))},l=this&&this.__generator||function(t,e){var o,i,n,r,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function l(l){return function(u){return function(l){if(o)throw new TypeError("Generator is already executing.");for(;r&&(r=0,l[0]&&(s=0)),s;)try{if(o=1,i&&(n=2&l[0]?i.return:l[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,l[1])).done)return n;switch(i=0,n&&(l=[2&l[0],n.value]),l[0]){case 0:case 1:n=l;break;case 4:return s.label++,{value:l[1],done:!1};case 5:s.label++,i=l[1],l=[0];continue;case 7:l=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==l[0]&&2!==l[0])){s=0;continue}if(3===l[0]&&(!n||l[1]>n[0]&&l[1]<n[3])){s.label=l[1];break}if(6===l[0]&&s.label<n[1]){s.label=n[1],n=l;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(l);break}n[2]&&s.ops.pop(),s.trys.pop();continue}l=e.call(t,s)}catch(t){l=[6,t],i=0}finally{o=n=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,u])}}},u=this&&this.__spreadArray||function(t,e,o){if(o||2===arguments.length)for(var i,n=0,r=e.length;n<r;n++)!i&&n in e||(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var c=o(969),p=a(o(737)),d=o(190),h=function(t){function e(e,o,i){var n,s,l,u,a,c,p,d,h,m,f,b,v,y,g,x,E,T,w,S,A,C,L,I,O,_=t.call(this,e,o,i)||this,P=e.getAttribute("data-hs-combo-box"),B=P?JSON.parse(P):{},k=r(r({},B),o);return _.gap=5,_.viewport=null!==(n="string"==typeof(null==k?void 0:k.viewport)?document.querySelector(null==k?void 0:k.viewport):null==k?void 0:k.viewport)&&void 0!==n?n:null,_.preventVisibility=null!==(s=null==k?void 0:k.preventVisibility)&&void 0!==s&&s,_.apiUrl=null!==(l=null==k?void 0:k.apiUrl)&&void 0!==l?l:null,_.apiDataPart=null!==(u=null==k?void 0:k.apiDataPart)&&void 0!==u?u:null,_.apiQuery=null!==(a=null==k?void 0:k.apiQuery)&&void 0!==a?a:null,_.apiSearchQuery=null!==(c=null==k?void 0:k.apiSearchQuery)&&void 0!==c?c:null,_.apiHeaders=null!==(p=null==k?void 0:k.apiHeaders)&&void 0!==p?p:{},_.apiGroupField=null!==(d=null==k?void 0:k.apiGroupField)&&void 0!==d?d:null,_.outputItemTemplate=null!==(h=null==k?void 0:k.outputItemTemplate)&&void 0!==h?h:'<div class="cursor-pointer py-2 px-4 w-full text-sm text-gray-800 hover:bg-gray-100 rounded-lg focus:outline-none focus:bg-gray-100 dark:bg-neutral-900 dark:hover:bg-neutral-800 dark:text-neutral-200 dark:focus:bg-neutral-800" data-hs-combo-box-output-item>\n\t\t\t\t<div class="flex justify-between items-center w-full">\n\t\t\t\t\t<span data-hs-combo-box-search-text></span>\n\t\t\t\t\t<span class="hidden hs-combo-box-selected:block">\n\t\t\t\t\t\t<svg class="flex-shrink-0 size-3.5 text-blue-600 dark:text-blue-500" xmlns="http:.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n\t\t\t\t\t\t\t<polyline points="20 6 9 17 4 12"></polyline>\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t</span>\n\t\t\t\t</div>\n\t\t\t</div>',_.outputEmptyTemplate=null!==(m=null==k?void 0:k.outputEmptyTemplate)&&void 0!==m?m:'<div class="py-2 px-4 w-full text-sm text-gray-800 rounded-lg dark:bg-neutral-900 dark:text-neutral-200">Nothing found...</div>',_.outputLoaderTemplate=null!==(f=null==k?void 0:k.outputLoaderTemplate)&&void 0!==f?f:'<div class="flex justify-center items-center py-2 px-4 text-sm text-gray-800 rounded-lg bg-white dark:bg-neutral-900 dark:text-neutral-200">\n\t\t\t\t<div class="animate-spin inline-block size-6 border-[3px] border-current border-t-transparent text-blue-600 rounded-full dark:text-blue-500" role="status" aria-label="loading">\n\t\t\t\t\t<span class="sr-only">Loading...</span>\n\t\t\t\t</div>\n\t\t\t</div>',_.groupingType=null!==(b=null==k?void 0:k.groupingType)&&void 0!==b?b:null,_.groupingTitleTemplate=null!==(v=null==k?void 0:k.groupingTitleTemplate)&&void 0!==v?v:"default"===_.groupingType?'<div class="block mb-1 text-xs font-semibold uppercase text-blue-600 dark:text-blue-500"></div>':'<button type="button" class="py-2 px-3 inline-flex items-center gap-x-2 text-sm font-semibold whitespace-nowrap rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 disabled:pointer-events-none"></button>',_.tabsWrapperTemplate=null!==(y=null==k?void 0:k.tabsWrapperTemplate)&&void 0!==y?y:'<div class="overflow-x-auto p-4"></div>',_.preventSelection=null!==(g=null==k?void 0:k.preventSelection)&&void 0!==g&&g,_.preventAutoPosition=null!==(x=null==k?void 0:k.preventAutoPosition)&&void 0!==x&&x,_.isOpenOnFocus=null!==(E=null==k?void 0:k.isOpenOnFocus)&&void 0!==E&&E,_.input=null!==(T=_.el.querySelector("[data-hs-combo-box-input]"))&&void 0!==T?T:null,_.output=null!==(w=_.el.querySelector("[data-hs-combo-box-output]"))&&void 0!==w?w:null,_.itemsWrapper=null!==(S=_.el.querySelector("[data-hs-combo-box-output-items-wrapper]"))&&void 0!==S?S:null,_.items=null!==(A=Array.from(_.el.querySelectorAll("[data-hs-combo-box-output-item]")))&&void 0!==A?A:[],_.tabs=[],_.toggle=null!==(C=_.el.querySelector("[data-hs-combo-box-toggle]"))&&void 0!==C?C:null,_.toggleClose=null!==(L=_.el.querySelector("[data-hs-combo-box-close]"))&&void 0!==L?L:null,_.toggleOpen=null!==(I=_.el.querySelector("[data-hs-combo-box-open]"))&&void 0!==I?I:null,_.outputPlaceholder=null,_.selected=_.value=null!==(O=_.el.querySelector("[data-hs-combo-box-input]").value)&&void 0!==O?O:"",_.isOpened=!1,_.isCurrent=!1,_.animationInProcess=!1,_.selectedGroup="all",_.init(),_}return n(e,t),e.prototype.init=function(){this.createCollection(window.$hsComboBoxCollection,this),this.build()},e.prototype.build=function(){this.buildInput(),this.groupingType&&this.setGroups(),this.buildItems(),this.preventVisibility&&(this.isOpened=!0,this.preventAutoPosition||this.recalculateDirection()),this.toggle&&this.buildToggle(),this.toggleClose&&this.buildToggleClose(),this.toggleOpen&&this.buildToggleOpen()},e.prototype.setResultAndRender=function(t){void 0===t&&(t=""),this.setResults(t),this.apiSearchQuery&&this.itemsFromJson()},e.prototype.buildInput=function(){var t=this;this.isOpenOnFocus&&this.input.addEventListener("focus",(function(){t.isOpened||(t.setResultAndRender(),t.open())})),this.input.addEventListener("input",(0,c.debounce)((function(e){t.setResultAndRender(e.target.value),t.isOpened||t.open()})))},e.prototype.buildItems=function(){this.apiUrl?this.itemsFromJson():(this.itemsWrapper?this.itemsWrapper.innerHTML="":this.output.innerHTML="",this.itemsFromHtml())},e.prototype.setResults=function(t){this.value=t,this.resultItems(),this.hasVisibleItems()?this.destroyOutputPlaceholder():this.buildOutputPlaceholder()},e.prototype.isItemExists=function(t){return this.items.some((function(e){return Array.from(e.querySelectorAll("[data-hs-combo-box-search-text]")).some((function(e){return e.getAttribute("data-hs-combo-box-search-text")===t[e.getAttribute("data-hs-combo-box-output-item-field")]}))}))},e.prototype.isTextExists=function(t,e){var o=e.map((function(t){return t.toLowerCase()}));return Array.from(t.querySelectorAll("[data-hs-combo-box-search-text]")).some((function(t){return o.includes(t.getAttribute("data-hs-combo-box-search-text").toLowerCase())}))},e.prototype.isTextExistsAny=function(t,e){return Array.from(t.querySelectorAll("[data-hs-combo-box-search-text]")).some((function(t){return t.getAttribute("data-hs-combo-box-search-text").toLowerCase().includes(e.toLowerCase())}))},e.prototype.valuesBySelector=function(t){return Array.from(t.querySelectorAll("[data-hs-combo-box-search-text]")).reduce((function(t,e){return u(u([],t,!0),[e.getAttribute("data-hs-combo-box-search-text")],!1)}),[])},e.prototype.buildOutputLoader=function(){if(this.outputLoader)return!1;this.outputLoader=(0,c.htmlToElement)(this.outputLoaderTemplate),this.items.length||this.outputPlaceholder?(this.outputLoader.style.position="absolute",this.outputLoader.style.top="0",this.outputLoader.style.bottom="0",this.outputLoader.style.left="0",this.outputLoader.style.right="0",this.outputLoader.style.zIndex="2"):(this.outputLoader.style.position="",this.outputLoader.style.top="",this.outputLoader.style.bottom="",this.outputLoader.style.left="",this.outputLoader.style.right="",this.outputLoader.style.zIndex="",this.outputLoader.style.height="30px"),this.output.append(this.outputLoader)},e.prototype.destroyOutputLoader=function(){this.outputLoader&&this.outputLoader.remove(),this.outputLoader=null},e.prototype.itemsFromJson=function(){return s(this,void 0,void 0,(function(){var t,e,o,i,n,r=this;return l(this,(function(s){switch(s.label){case 0:this.buildOutputLoader(),s.label=1;case 1:return s.trys.push([1,4,,5]),t="".concat(this.apiQuery),e="".concat(this.apiSearchQuery,"=").concat(this.value.toLowerCase()),o=this.apiUrl,this.apiQuery&&this.apiSearchQuery?o+="?".concat(e,"&").concat(t):this.apiQuery?o+="?".concat(t):this.apiSearchQuery&&(o+="?".concat(e)),[4,fetch(o,this.apiHeaders)];case 2:return[4,s.sent().json()];case 3:return i=s.sent(),this.apiDataPart&&(i=i[this.apiDataPart]),this.apiSearchQuery&&(this.items=[]),this.itemsWrapper?this.itemsWrapper.innerHTML="":this.output.innerHTML="","tabs"===this.groupingType?(this.setApiGroups(i),this.groupTabsRender(),this.jsonItemsRender(i)):"default"===this.groupingType?(this.setApiGroups(i),this.groups.forEach((function(t){var e=(0,c.htmlToElement)(r.groupingTitleTemplate);e.setAttribute("data-hs-combo-box-group-title",t.name),e.classList.add("--exclude-accessibility"),e.innerText=t.title;var o=i.filter((function(e){return e[r.apiGroupField]===t.name}));r.itemsWrapper?r.itemsWrapper.append(e):r.output.append(e),r.jsonItemsRender(o)}))):this.jsonItemsRender(i),this.setResults(this.input.value),[3,5];case 4:return n=s.sent(),console.error(n),[3,5];case 5:return this.destroyOutputLoader(),[2]}}))}))},e.prototype.jsonItemsRender=function(t){var e=this;t.forEach((function(t,o){if(e.isItemExists(t))return!1;var i=(0,c.htmlToElement)(e.outputItemTemplate);i.querySelectorAll("[data-hs-combo-box-search-text]").forEach((function(e){var o,i;e.textContent=null!==(o=t[e.getAttribute("data-hs-combo-box-output-item-field")])&&void 0!==o?o:"",e.setAttribute("data-hs-combo-box-search-text",null!==(i=t[e.getAttribute("data-hs-combo-box-output-item-field")])&&void 0!==i?i:"")})),i.querySelectorAll("[data-hs-combo-box-output-item-attr]").forEach((function(e){JSON.parse(e.getAttribute("data-hs-combo-box-output-item-attr")).forEach((function(o){e.setAttribute(o.attr,t[o.valueFrom])}))})),i.setAttribute("tabIndex","".concat(o)),"tabs"!==e.groupingType&&"default"!==e.groupingType||i.setAttribute("data-hs-combo-box-output-item",'{"group": {"name": "'.concat(t[e.apiGroupField],'", "title": "').concat(t[e.apiGroupField],'"}}')),e.items=u(u([],e.items,!0),[i],!1),e.preventSelection||i.addEventListener("click",(function(){e.close(i.querySelector("[data-hs-combo-box-value]").getAttribute("data-hs-combo-box-search-text")),e.setSelectedByValue(e.valuesBySelector(i))})),e.appendItemsToWrapper(i)}))},e.prototype.setGroups=function(){var t=[];this.items.forEach((function(e){var o=JSON.parse(e.getAttribute("data-hs-combo-box-output-item")).group;t.some((function(t){return(null==t?void 0:t.name)===o.name}))||t.push(o)})),this.groups=t},e.prototype.setCurrent=function(){window.$hsComboBoxCollection.length&&(window.$hsComboBoxCollection.map((function(t){return t.element.isCurrent=!1})),this.isCurrent=!0)},e.prototype.setApiGroups=function(t){var e=this,o=[];t.forEach((function(t){var i=t[e.apiGroupField];o.some((function(t){return t.name===i}))||o.push({name:i,title:i})})),this.groups=o},e.prototype.sortItems=function(){return this.items.sort((function(t,e){var o=t.querySelector("[data-hs-combo-box-value]").getAttribute("data-hs-combo-box-search-text"),i=e.querySelector("[data-hs-combo-box-value]").getAttribute("data-hs-combo-box-search-text");return o<i?-1:o>i?1:0}))},e.prototype.itemRender=function(t){var e=this,o=t.querySelector("[data-hs-combo-box-value]").getAttribute("data-hs-combo-box-search-text");this.itemsWrapper?this.itemsWrapper.append(t):this.output.append(t),this.preventSelection||t.addEventListener("click",(function(){e.close(o),e.setSelectedByValue(e.valuesBySelector(t))}))},e.prototype.plainRender=function(t){var e=this;t.forEach((function(t){e.itemRender(t)}))},e.prototype.groupTabsRender=function(){var t=this,e=(0,c.htmlToElement)(this.tabsWrapperTemplate),o=(0,c.htmlToElement)('<div class="flex flex-nowrap gap-x-2"></div>');e.append(o),this.output.insertBefore(e,this.output.firstChild);var i=(0,c.htmlToElement)(this.groupingTitleTemplate);i.setAttribute("data-hs-combo-box-group-title","all"),i.classList.add("--exclude-accessibility","active"),i.innerText="All",this.tabs=u(u([],this.tabs,!0),[i],!1),o.append(i),i.addEventListener("click",(function(){t.selectedGroup="all";var e=t.tabs.find((function(e){return e.getAttribute("data-hs-combo-box-group-title")===t.selectedGroup}));t.tabs.forEach((function(t){return t.classList.remove("active")})),e.classList.add("active"),t.setItemsVisibility()})),this.groups.forEach((function(e){var i=(0,c.htmlToElement)(t.groupingTitleTemplate);i.setAttribute("data-hs-combo-box-group-title",e.name),i.classList.add("--exclude-accessibility"),i.innerText=e.title,t.tabs=u(u([],t.tabs,!0),[i],!1),o.append(i),i.addEventListener("click",(function(){t.selectedGroup=e.name;var o=t.tabs.find((function(e){return e.getAttribute("data-hs-combo-box-group-title")===t.selectedGroup}));t.tabs.forEach((function(t){return t.classList.remove("active")})),o.classList.add("active"),t.setItemsVisibility()}))}))},e.prototype.groupDefaultRender=function(){var t=this;this.groups.forEach((function(e){var o=(0,c.htmlToElement)(t.groupingTitleTemplate);o.setAttribute("data-hs-combo-box-group-title",e.name),o.classList.add("--exclude-accessibility"),o.innerText=e.title,t.itemsWrapper?t.itemsWrapper.append(o):t.output.append(o);var i=t.sortItems().filter((function(t){return JSON.parse(t.getAttribute("data-hs-combo-box-output-item")).group.name===e.name}));t.plainRender(i)}))},e.prototype.itemsFromHtml=function(){if("default"===this.groupingType)this.groupDefaultRender();else if("tabs"===this.groupingType){var t=this.sortItems();this.groupTabsRender(),this.plainRender(t)}else{t=this.sortItems();this.plainRender(t)}this.setResults(this.input.value)},e.prototype.buildToggle=function(){var t=this;this.toggle.addEventListener("click",(function(){t.isOpened?t.close():t.open(t.toggle.getAttribute("data-hs-combo-box-toggle"))}))},e.prototype.buildToggleClose=function(){var t=this;this.toggleClose.addEventListener("click",(function(){return t.close()}))},e.prototype.buildToggleOpen=function(){var t=this;this.toggleOpen.addEventListener("click",(function(){return t.open()}))},e.prototype.setSelectedByValue=function(t){var e=this;this.items.forEach((function(o){e.isTextExists(o,t)?o.classList.add("selected"):o.classList.remove("selected")}))},e.prototype.setValue=function(t){this.selected=t,this.value=t,this.input.value=t,this.fireEvent("select",this.el),(0,c.dispatch)("select.hs.combobox",this.el,this.value)},e.prototype.setItemsVisibility=function(){var t=this;"tabs"===this.groupingType&&"all"!==this.selectedGroup&&this.items.forEach((function(t){t.style.display="none"}));var e="tabs"===this.groupingType?"all"===this.selectedGroup?this.items:this.items.filter((function(e){return JSON.parse(e.getAttribute("data-hs-combo-box-output-item")).group.name===t.selectedGroup})):this.items;"tabs"===this.groupingType&&"all"!==this.selectedGroup&&e.forEach((function(t){t.style.display="block"})),e.forEach((function(e){t.isTextExistsAny(e,t.value)?e.style.display="block":e.style.display="none"})),"default"===this.groupingType&&this.output.querySelectorAll("[data-hs-combo-box-group-title]").forEach((function(e){var o=e.getAttribute("data-hs-combo-box-group-title");t.items.filter((function(t){return JSON.parse(t.getAttribute("data-hs-combo-box-output-item")).group.name===o&&"block"===t.style.display})).length?e.style.display="block":e.style.display="none"}))},e.prototype.hasVisibleItems=function(){return!!this.items.length&&this.items.some((function(t){return"block"===t.style.display}))},e.prototype.appendItemsToWrapper=function(t){this.itemsWrapper?this.itemsWrapper.append(t):this.output.append(t)},e.prototype.buildOutputPlaceholder=function(){this.outputPlaceholder||(this.outputPlaceholder=(0,c.htmlToElement)(this.outputEmptyTemplate)),this.appendItemsToWrapper(this.outputPlaceholder)},e.prototype.destroyOutputPlaceholder=function(){this.outputPlaceholder&&this.outputPlaceholder.remove(),this.outputPlaceholder=null},e.prototype.resultItems=function(){if(!this.items.length)return!1;this.setItemsVisibility(),this.setSelectedByValue([this.selected])},e.prototype.setValueAndOpen=function(t){this.value=t,this.items.length&&this.setItemsVisibility()},e.prototype.open=function(t){var e=this;return!this.animationInProcess&&(void 0!==t&&this.setValueAndOpen(t),!this.preventVisibility&&(this.animationInProcess=!0,this.output.style.display="block",this.preventAutoPosition||this.recalculateDirection(),setTimeout((function(){e.el.classList.add("active"),e.animationInProcess=!1})),void(this.isOpened=!0)))},e.prototype.setValueAndClear=function(t){t?this.setValue(t):this.setValue(this.selected),this.outputPlaceholder&&this.destroyOutputPlaceholder()},e.prototype.close=function(t){var e=this;return!this.animationInProcess&&(this.preventVisibility?(this.setValueAndClear(t),!1):(this.animationInProcess=!0,this.el.classList.remove("active"),this.preventAutoPosition||(this.output.classList.remove("bottom-full","top-full"),this.output.style.marginTop="",this.output.style.marginBottom=""),(0,c.afterTransition)(this.output,(function(){e.output.style.display="none",e.setValueAndClear(t),e.animationInProcess=!1})),void(this.isOpened=!1)))},e.prototype.recalculateDirection=function(){(0,c.isEnoughSpace)(this.output,this.input,"bottom",this.gap,this.viewport)?(this.output.classList.remove("bottom-full"),this.output.style.marginBottom="",this.output.classList.add("top-full"),this.output.style.marginTop="".concat(this.gap,"px")):(this.output.classList.remove("top-full"),this.output.style.marginTop="",this.output.classList.add("bottom-full"),this.output.style.marginBottom="".concat(this.gap,"px"))},e.getInstance=function(t,e){var o=window.$hsComboBoxCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));return o?e?o:o.element:null},e.autoInit=function(){window.$hsComboBoxCollection||(window.$hsComboBoxCollection=[]),document.querySelectorAll("[data-hs-combo-box]:not(.--prevent-on-load-init)").forEach((function(t){if(!window.$hsComboBoxCollection.find((function(e){var o;return(null===(o=null==e?void 0:e.element)||void 0===o?void 0:o.el)===t}))){var o=t.getAttribute("data-hs-combo-box"),i=o?JSON.parse(o):{};new e(t,i)}})),window.$hsComboBoxCollection&&(window.addEventListener("click",(function(t){var o=t.target;e.closeCurrentlyOpened(o)})),document.addEventListener("keydown",(function(t){return e.accessibility(t)})))},e.close=function(t){var e=window.$hsComboBoxCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));e&&e.element.isOpened&&e.element.close()},e.closeCurrentlyOpened=function(t){if(void 0===t&&(t=null),!t.closest("[data-hs-combo-box].active")){var e=window.$hsComboBoxCollection.filter((function(t){return t.element.isOpened}))||null;e&&e.forEach((function(t){t.element.close()}))}},e.getPreparedItems=function(t,e){return void 0===t&&(t=!1),e?(t?Array.from(e.querySelectorAll(":scope > *:not(.--exclude-accessibility)")).filter((function(t){return"none"!==t.style.display})).reverse():Array.from(e.querySelectorAll(":scope > *:not(.--exclude-accessibility)")).filter((function(t){return"none"!==t.style.display}))).filter((function(t){return!t.classList.contains("disabled")})):null},e.setHighlighted=function(t,e,o){e.focus(),o.value=e.querySelector("[data-hs-combo-box-value]").getAttribute("data-hs-combo-box-search-text"),t&&t.classList.remove("hs-combo-box-output-item-highlighted"),e.classList.add("hs-combo-box-output-item-highlighted")},e.accessibility=function(t){if(window.$hsComboBoxCollection.find((function(t){return t.element.isOpened}))&&d.COMBO_BOX_ACCESSIBILITY_KEY_SET.includes(t.code)&&!t.metaKey)switch(t.code){case"Escape":t.preventDefault(),this.onEscape();break;case"ArrowUp":t.preventDefault(),this.onArrow();break;case"ArrowDown":t.preventDefault(),this.onArrow(!1);break;case"Home":t.preventDefault(),this.onStartEnd();break;case"End":t.preventDefault(),this.onStartEnd(!1);break;case"Enter":t.preventDefault(),this.onEnter(t)}},e.onEscape=function(){var t=window.$hsComboBoxCollection.find((function(t){return!t.element.preventVisibility&&t.element.isOpened}));t&&(t.element.close(),t.element.input.blur())},e.onArrow=function(t){var o;void 0===t&&(t=!0);var i=window.$hsComboBoxCollection.find((function(t){return t.element.preventVisibility?t.element.isCurrent:t.element.isOpened}));if(i){var n=null!==(o=i.element.itemsWrapper)&&void 0!==o?o:i.element.output;if(!n)return!1;var r,s=e.getPreparedItems(t,n),l=n.querySelector(".hs-combo-box-output-item-highlighted");l||s[0].classList.add("hs-combo-box-output-item-highlighted");var u=s.findIndex((function(t){return t===l}));u+1<s.length&&u++,r=s[u],e.setHighlighted(l,r,i.element.input)}},e.onStartEnd=function(t){var o;void 0===t&&(t=!0);var i=window.$hsComboBoxCollection.find((function(t){return t.element.preventVisibility?t.element.isCurrent:t.element.isOpened}));if(i){var n=null!==(o=i.element.itemsWrapper)&&void 0!==o?o:i.element.output;if(!n)return!1;var r=e.getPreparedItems(t,n),s=n.querySelector(".hs-combo-box-output-item-highlighted");r.length&&e.setHighlighted(s,r[0],i.element.input)}},e.onEnter=function(t){var e=t.target,o=window.$hsComboBoxCollection.find((function(e){return!(0,c.isParentOrElementHidden)(e.element.el)&&t.target.closest("[data-hs-combo-box]")===e.element.el})),i=o.element.el.querySelector(".hs-combo-box-output-item-highlighted a");e.hasAttribute("data-hs-combo-box-input")?(o.element.close(),e.blur()):(o.element.preventSelection||o.element.setSelectedByValue(o.element.valuesBySelector(t.target)),o.element.preventSelection&&i&&window.location.assign(i.getAttribute("href")),o.element.close(o.element.preventSelection?null:t.target.querySelector("[data-hs-combo-box-value]").getAttribute("data-hs-combo-box-search-text")))},e}(p.default);window.addEventListener("load",(function(){h.autoInit()})),document.addEventListener("scroll",(function(){if(!window.$hsComboBoxCollection)return!1;var t=window.$hsComboBoxCollection.find((function(t){return t.element.isOpened}));t&&!t.element.preventAutoPosition&&t.element.recalculateDirection()})),"undefined"!=typeof window&&(window.HSComboBox=h),e.default=h},969:function(t,e){var o=this;Object.defineProperty(e,"__esModule",{value:!0}),e.menuSearchHistory=e.classToClassList=e.htmlToElement=e.afterTransition=e.dispatch=e.debounce=e.isFormElement=e.isParentOrElementHidden=e.isEnoughSpace=e.isIpadOS=e.isIOS=e.getClassPropertyAlt=e.getClassProperty=e.stringToBoolean=void 0;e.stringToBoolean=function(t){return"true"===t};e.getClassProperty=function(t,e,o){return void 0===o&&(o=""),(window.getComputedStyle(t).getPropertyValue(e)||o).replace(" ","")};e.getClassPropertyAlt=function(t,e,o){void 0===o&&(o="");var i="";return t.classList.forEach((function(t){t.includes(e)&&(i=t)})),i.match(/:(.*)]/)?i.match(/:(.*)]/)[1]:o};e.isIOS=function(){return!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};e.isIpadOS=function(){return navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};e.isEnoughSpace=function(t,e,o,i,n){void 0===o&&(o="auto"),void 0===i&&(i=10),void 0===n&&(n=null);var r=e.getBoundingClientRect(),s=n?n.getBoundingClientRect():null,l=window.innerHeight,u=s?r.top-s.top:r.top,a=(n?s.bottom:l)-r.bottom,c=t.clientHeight+i;return"bottom"===o?a>=c:"top"===o?u>=c:u>=c||a>=c};e.isFormElement=function(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement};var i=function(t){return!!t&&("none"===window.getComputedStyle(t).display||i(t.parentElement))};e.isParentOrElementHidden=i;e.debounce=function(t,e){var i;return void 0===e&&(e=200),function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];clearTimeout(i),i=setTimeout((function(){t.apply(o,n)}),e)}};e.dispatch=function(t,e,o){void 0===o&&(o=null);var i=new CustomEvent(t,{detail:{payload:o},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(i)};e.afterTransition=function(t,e){var o=function(){e(),t.removeEventListener("transitionend",o,!0)};window.getComputedStyle(t,null).getPropertyValue("transition")!==(navigator.userAgent.includes("Firefox")?"all":"all 0s ease 0s")?t.addEventListener("transitionend",o,!0):e()};e.htmlToElement=function(t){var e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild};e.classToClassList=function(t,e,o,i){void 0===o&&(o=" "),void 0===i&&(i="add"),t.split(o).forEach((function(t){return"add"===i?e.classList.add(t):e.classList.remove(t)}))};e.menuSearchHistory={historyIndex:-1,addHistory:function(t){this.historyIndex=t},existsInHistory:function(t){return t>this.historyIndex},clearHistory:function(){this.historyIndex=-1}}}},e={};var o=function o(i){var n=e[i];if(void 0!==n)return n.exports;var r=e[i]={exports:{}};return t[i].call(r.exports,r,r.exports,o),r.exports}(23);return o})()));
{
"name": "@preline/combobox",
"version": "2.1.0",
"version": "2.3.0",
"description": "Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc