@aquera/nile-elements 0.1.75-beta-1.2 → 0.1.75-beta-1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/demo/index.html +5 -17
  2. package/dist/index.js +35 -16
  3. package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
  4. package/dist/nile-calendar/nile-calendar.test.cjs.js.map +1 -1
  5. package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
  6. package/dist/nile-select/index.cjs.js +1 -1
  7. package/dist/nile-select/index.esm.js +1 -1
  8. package/dist/nile-select/nile-select.cjs.js +1 -1
  9. package/dist/nile-select/nile-select.cjs.js.map +1 -1
  10. package/dist/nile-select/nile-select.esm.js +2 -2
  11. package/dist/nile-select/nile-select.test.cjs.js +1 -1
  12. package/dist/nile-select/nile-select.test.cjs.js.map +1 -1
  13. package/dist/nile-select/nile-select.test.esm.js +1 -1
  14. package/dist/nile-select/virtual-scroll-helper.cjs.js +1 -1
  15. package/dist/nile-select/virtual-scroll-helper.cjs.js.map +1 -1
  16. package/dist/nile-select/virtual-scroll-helper.esm.js +1 -0
  17. package/dist/nile-virtual-select/index.cjs.js +1 -1
  18. package/dist/nile-virtual-select/index.esm.js +1 -1
  19. package/dist/nile-virtual-select/nile-virtual-select.cjs.js +1 -1
  20. package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +1 -1
  21. package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js +1 -1
  22. package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js.map +1 -1
  23. package/dist/nile-virtual-select/nile-virtual-select.css.esm.js +14 -0
  24. package/dist/nile-virtual-select/nile-virtual-select.esm.js +15 -11
  25. package/dist/nile-virtual-select/renderer.cjs.js +1 -1
  26. package/dist/nile-virtual-select/renderer.cjs.js.map +1 -1
  27. package/dist/nile-virtual-select/renderer.esm.js +10 -10
  28. package/dist/nile-virtual-select/selection-manager.cjs.js +1 -1
  29. package/dist/nile-virtual-select/selection-manager.cjs.js.map +1 -1
  30. package/dist/nile-virtual-select/selection-manager.esm.js +1 -1
  31. package/dist/src/nile-select/nile-select.d.ts +2 -0
  32. package/dist/src/nile-select/nile-select.js +5 -0
  33. package/dist/src/nile-select/nile-select.js.map +1 -1
  34. package/dist/src/nile-select/virtual-scroll-helper.js +1 -0
  35. package/dist/src/nile-select/virtual-scroll-helper.js.map +1 -1
  36. package/dist/src/nile-virtual-select/nile-virtual-select.css.js +14 -0
  37. package/dist/src/nile-virtual-select/nile-virtual-select.css.js.map +1 -1
  38. package/dist/src/nile-virtual-select/nile-virtual-select.d.ts +8 -0
  39. package/dist/src/nile-virtual-select/nile-virtual-select.js +38 -15
  40. package/dist/src/nile-virtual-select/nile-virtual-select.js.map +1 -1
  41. package/dist/src/nile-virtual-select/renderer.d.ts +1 -1
  42. package/dist/src/nile-virtual-select/renderer.js +4 -4
  43. package/dist/src/nile-virtual-select/renderer.js.map +1 -1
  44. package/dist/src/nile-virtual-select/selection-manager.js +1 -1
  45. package/dist/src/nile-virtual-select/selection-manager.js.map +1 -1
  46. package/dist/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +1 -1
  48. package/src/nile-select/nile-select.ts +3 -0
  49. package/src/nile-select/virtual-scroll-helper.ts +1 -0
  50. package/src/nile-virtual-select/nile-virtual-select.css.ts +14 -0
  51. package/src/nile-virtual-select/nile-virtual-select.ts +38 -17
  52. package/src/nile-virtual-select/renderer.ts +4 -4
  53. package/src/nile-virtual-select/selection-manager.ts +1 -1
  54. package/vscode-html-custom-data.json +7 -226
  55. package/src/nile-virtual-select/temp_nile-virtual-select copy.ts +0 -1398
package/demo/index.html CHANGED
@@ -22,22 +22,12 @@
22
22
  flex: 0 0 auto;
23
23
  height: 38px;
24
24
  }
25
- /*
26
- nile-virtual-select.select-loader::part(loader) {
27
- position: absolute;
28
- height: 100%;
29
- }
30
-
31
- nile-virtual-select.select-loader::part(select-options) {
32
- opacity: 0.2;
33
- pointer-events: none;
34
- } */
35
25
 
36
26
  </style>
37
27
 
38
28
  <body>
39
29
  <div>
40
- <nile-virtual-select id="vselect" placeholder="Please Select" searchEnabled disableLocalSearch enableVirtualScroll multiple >
30
+ <nile-virtual-select id="vselect" placeholder="Please Select" searchEnabled multiple >
41
31
  </nile-virtual-select>
42
32
  </div>
43
33
 
@@ -92,7 +82,7 @@
92
82
  currentSearchQuery = searchQuery;
93
83
  currentPage = 1;
94
84
 
95
- // nileVirtualSelect.optionsLoading = true;
85
+ nileVirtualSelect.loading = true;
96
86
 
97
87
  try {
98
88
  const searchData = await fetchUsers(currentPage, searchQuery);
@@ -102,7 +92,7 @@
102
92
  } catch (error) {
103
93
  console.error('Error searching users:', error);
104
94
  } finally {
105
- // nileVirtualSelect.optionsLoading = false;
95
+ nileVirtualSelect.loading = false;
106
96
  }
107
97
  });
108
98
 
@@ -112,8 +102,7 @@
112
102
  return; // No more users to load
113
103
  }
114
104
 
115
- // nileVirtualSelect.optionsLoading = true;
116
- // nileVirtualSelect.classList.add('select-loader');
105
+ nileVirtualSelect.loading = true;
117
106
 
118
107
  try {
119
108
  currentPage++;
@@ -125,8 +114,7 @@
125
114
  } catch (error) {
126
115
  console.error('Error loading more users:', error);
127
116
  } finally {
128
- // nileVirtualSelect.optionsLoading = false;
129
- // nileVirtualSelect.classList.remove('select-loader');
117
+ nileVirtualSelect.loading = false;
130
118
  }
131
119
  });
132
120
  });
package/dist/index.js CHANGED
@@ -4277,7 +4277,21 @@ const Ze=e=>e??_;function Ve(e,t){const M={waitUntilFirstUpdate:!1,...t};return(
4277
4277
  .virtualized nile-option[selected]::part(base) {
4278
4278
  color: var(--nile-colors-primary-600);
4279
4279
  }
4280
- `;class ji{static createVirtualOptionsFromValues(e,t,M,i){if(!e||Array.isArray(e)&&0===e.length)return[];return(Array.isArray(e)?e:[e]).map((e=>{const N=M,o=i||(e=>e?.value||e),s=t.find((t=>{const M=o(t),i=N(t);return M===e||i===e})),n=s?N(s):e;return{value:e,selected:!0,getTextLabel:()=>{if("string"==typeof n&&/<[^>]+>/.test(n)){const e=document.createElement("div");return e.innerHTML=n,e.textContent||e.innerText||""}return n},getOptionPrefix:()=>""}}))}static updateDisplayLabel(e,t,M,i){if(M)return t&&0===e.length?"":e.length+" selected";{const t=Array.isArray(i)?i[0]:i;return e[0]?.getTextLabel()?e[0].getTextLabel():t??""}}static updateValue(e,t){return t?e.map((e=>e.value)):e[0]?.value??""}}class ci{static filterVirtualOptions(e,t,M,i,N){if(0===t.length&&M.length>0)return{filteredItems:[...M],showNoResults:!1};if(!t||0===t.length)return{filteredItems:[],showNoResults:!0};if(!e||""===e.trim())return{filteredItems:[...t],showNoResults:!1};const o=e.toLowerCase(),s=N||i,n=t.filter((e=>s(e).toLowerCase().includes(o)));return{filteredItems:n,showNoResults:0===n.length}}}
4280
+
4281
+ .virtual-select-loader {
4282
+ position: absolute;
4283
+ display: flex;
4284
+ justify-content: center;
4285
+ align-items: center;
4286
+ width: 100%;
4287
+ height: 75%;
4288
+ }
4289
+
4290
+ .select__footer.loading, .select__options.loading {
4291
+ opacity: 0.5;
4292
+ pointer-events: none;
4293
+ }
4294
+ `;class ji{static createVirtualOptionsFromValues(e,t,M,i){if(!e||Array.isArray(e)&&0===e.length)return[];return(Array.isArray(e)?e:[e]).map((e=>{const N=M,o=i||(e=>e?.value||e),s=t.find((t=>{const M=o(t),i=N(t);return String(M)===String(e)||String(i)===String(e)})),n=s?N(s):e;return{value:e,selected:!0,getTextLabel:()=>{if("string"==typeof n&&/<[^>]+>/.test(n)){const e=document.createElement("div");return e.innerHTML=n,e.textContent||e.innerText||""}return n},getOptionPrefix:()=>""}}))}static updateDisplayLabel(e,t,M,i){if(M)return t&&0===e.length?"":e.length+" selected";{const t=Array.isArray(i)?i[0]:i;return e[0]?.getTextLabel()?e[0].getTextLabel():t??""}}static updateValue(e,t){return t?e.map((e=>e.value)):e[0]?.value??""}}class ci{static filterVirtualOptions(e,t,M,i,N){if(0===t.length&&M.length>0)return{filteredItems:[...M],showNoResults:!1};if(!t||0===t.length)return{filteredItems:[],showNoResults:!0};if(!e||""===e.trim())return{filteredItems:[...t],showNoResults:!1};const o=e.toLowerCase(),s=N||i,n=t.filter((e=>s(e).toLowerCase().includes(o)));return{filteredItems:n,showNoResults:0===n.length}}}
4281
4295
  /**
4282
4296
  * @license
4283
4297
  * Copyright 2019 Google LLC
@@ -4326,7 +4340,7 @@ class Hi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
4326
4340
  * Copyright 2021 Google LLC
4327
4341
  * SPDX-License-Identifier: BSD-3-Clause
4328
4342
  */(this._hostElement,e),this._scrollerController=new qi(this,this._clippingAncestors[0]),this._schedule(this._updateLayout),this._observeAndListen(),this._connected=!0}_observeAndListen(){this._mutationObserver.observe(this._hostElement,{childList:!0}),this._hostElementRO.observe(this._hostElement),this._scrollEventListeners.push(window),window.addEventListener("scroll",this,this._scrollEventListenerOptions),this._clippingAncestors.forEach((e=>{e.addEventListener("scroll",this,this._scrollEventListenerOptions),this._scrollEventListeners.push(e),this._hostElementRO.observe(e)})),this._hostElementRO.observe(this._scrollerController.element),this._children.forEach((e=>this._childrenRO.observe(e))),this._scrollEventListeners.forEach((e=>e.addEventListener("scroll",this,this._scrollEventListenerOptions)))}disconnected(){this._scrollEventListeners.forEach((e=>e.removeEventListener("scroll",this,this._scrollEventListenerOptions))),this._scrollEventListeners=[],this._clippingAncestors=[],this._scrollerController?.detach(this),this._scrollerController=null,this._mutationObserver?.disconnect(),this._mutationObserver=null,this._hostElementRO?.disconnect(),this._hostElementRO=null,this._childrenRO?.disconnect(),this._childrenRO=null,this._rejectLayoutCompletePromise("disconnected"),this._connected=!1}_applyVirtualizerStyles(){const e=this._hostElement.style;e.display=e.display||"block",e.position=e.position||"relative",e.contain=e.contain||"size layout",this._isScroller&&(e.overflow=e.overflow||"auto",e.minHeight=e.minHeight||"150px")}_getSizer(){const e=this._hostElement;if(!this._sizer){let t=e.querySelector(`[${tN}]`);t||(t=document.createElement("div"),t.setAttribute(tN,""),e.appendChild(t)),Object.assign(t.style,{position:"absolute",margin:"-2px 0 0 0",padding:0,visibility:"hidden",fontSize:"2px"}),t.textContent="&nbsp;",t.setAttribute(tN,""),this._sizer=t}return this._sizer}async updateLayoutConfig(e){await this._layoutInitialized;const t=e.type||MN;if("function"==typeof t&&this._layout instanceof t){const t={...e};return delete t.type,this._layout.config=t,!0}return!1}async _initLayout(e){let t,M;if("function"==typeof e.type){M=e.type;const i={...e};delete i.type,t=i}else t=e;void 0===M&&(MN=M=(await Promise.resolve().then((function(){return $p}))).FlowLayout),this._layout=new M((e=>this._handleLayoutMessage(e)),t),this._layout.measureChildren&&"function"==typeof this._layout.updateItemSizes&&("function"==typeof this._layout.measureChildren&&(this._measureChildOverride=this._layout.measureChildren),this._measureCallback=this._layout.updateItemSizes.bind(this._layout)),this._layout.listenForChildLoadEvents&&this._hostElement.addEventListener("load",this._loadListener,!0),this._schedule(this._updateLayout)}startBenchmarking(){null===this._benchmarkStart&&(this._benchmarkStart=window.performance.now())}stopBenchmarking(){if(null!==this._benchmarkStart){const e=window.performance.now(),t=e-this._benchmarkStart,M=performance.getEntriesByName("uv-virtualizing","measure").filter((t=>t.startTime>=this._benchmarkStart&&t.startTime<e)).reduce(((e,t)=>e+t.duration),0);return this._benchmarkStart=null,{timeElapsed:t,virtualizationTime:M}}return null}_measureChildren(){const e={},t=this._children,M=this._measureChildOverride||this._measureChild;for(let i=0;i<t.length;i++){const N=t[i],o=this._first+i;(this._itemsChanged||this._toBeMeasured.has(N))&&(e[o]=M.call(this,N,this._items[o]))}this._childMeasurements=e,this._schedule(this._updateLayout),this._toBeMeasured.clear()}_measureChild(e){const{width:t,height:M}=e.getBoundingClientRect();return Object.assign({width:t,height:M},function(e){const t=window.getComputedStyle(e);return{marginTop:NN(t.marginTop),marginRight:NN(t.marginRight),marginBottom:NN(t.marginBottom),marginLeft:NN(t.marginLeft)}}(e))}async _schedule(e){this._scheduled.has(e)||(this._scheduled.add(e),await Promise.resolve(),this._scheduled.delete(e),e.call(this))}async _updateDOM(e){this._scrollSize=e.scrollSize,this._adjustRange(e.range),this._childrenPos=e.childPositions,this._scrollError=e.scrollError||null;const{_rangeChanged:t,_itemsChanged:M}=this;this._visibilityChanged&&(this._notifyVisibility(),this._visibilityChanged=!1),(t||M)&&(this._notifyRange(),this._rangeChanged=!1),this._finishDOMUpdate()}_finishDOMUpdate(){this._connected&&(this._children.forEach((e=>this._childrenRO.observe(e))),this._checkScrollIntoViewTarget(this._childrenPos),this._positionChildren(this._childrenPos),this._sizeHostElement(this._scrollSize),this._correctScrollError(),this._benchmarkStart&&"mark"in window.performance&&window.performance.mark("uv-end"))}_updateLayout(){this._layout&&this._connected&&(this._layout.items=this._items,this._updateView(),null!==this._childMeasurements&&(this._measureCallback&&this._measureCallback(this._childMeasurements),this._childMeasurements=null),this._layout.reflowIfNeeded(),this._benchmarkStart&&"mark"in window.performance&&window.performance.mark("uv-end"))}_handleScrollEvent(){if(this._benchmarkStart&&"mark"in window.performance){try{window.performance.measure("uv-virtualizing","uv-start","uv-end")}catch(e){console.warn("Error measuring performance data: ",e)}window.performance.mark("uv-start")}!1===this._scrollerController.correctingScrollError&&this._layout?.unpin(),this._schedule(this._updateLayout)}handleEvent(e){if("scroll"===e.type)(e.currentTarget===window||this._clippingAncestors.includes(e.currentTarget))&&this._handleScrollEvent();else console.warn("event not handled",e)}_handleLayoutMessage(e){"stateChanged"===e.type?this._updateDOM(e):"visibilityChanged"===e.type?(this._firstVisible=e.firstVisible,this._lastVisible=e.lastVisible,this._notifyVisibility()):"unpinned"===e.type&&this._hostElement.dispatchEvent(new Xi)}get _children(){const e=[];let t=this._hostElement.firstElementChild;for(;t;)t.hasAttribute(tN)||e.push(t),t=t.nextElementSibling;return e}_updateView(){const e=this._hostElement,t=this._scrollerController?.element,M=this._layout;if(e&&t&&M){let i,N,o,s;const n=e.getBoundingClientRect();i=0,N=0,o=window.innerHeight,s=window.innerWidth;const r=this._clippingAncestors.map((e=>e.getBoundingClientRect()));r.unshift(n);for(const e of r)i=Math.max(i,e.top),N=Math.max(N,e.left),o=Math.min(o,e.bottom),s=Math.min(s,e.right);const a=t.getBoundingClientRect(),l={left:n.left-a.left,top:n.top-a.top},D={width:t.scrollWidth,height:t.scrollHeight},u=i-n.top+e.scrollTop,g=N-n.left+e.scrollLeft,j=Math.max(0,o-i),c=Math.max(0,s-N);M.viewportSize={width:c,height:j},M.viewportScroll={top:u,left:g},M.totalScrollSize=D,M.offsetWithinScroller=l}}_sizeHostElement(e){const t=82e5,M=e&&null!==e.width?Math.min(t,e.width):0,i=e&&null!==e.height?Math.min(t,e.height):0;if(this._isScroller)this._getSizer().style.transform=`translate(${M}px, ${i}px)`;else{const e=this._hostElement.style;e.minWidth=M?`${M}px`:"100%",e.minHeight=i?`${i}px`:"100%"}}_positionChildren(e){e&&e.forEach((({top:e,left:t,width:M,height:i,xOffset:N,yOffset:o},s)=>{const n=this._children[s-this._first];n&&(n.style.position="absolute",n.style.boxSizing="border-box",n.style.transform=`translate(${t}px, ${e}px)`,void 0!==M&&(n.style.width=M+"px"),void 0!==i&&(n.style.height=i+"px"),n.style.left=void 0===N?null:N+"px",n.style.top=void 0===o?null:o+"px")}))}async _adjustRange(e){const{_first:t,_last:M,_firstVisible:i,_lastVisible:N}=this;this._first=e.first,this._last=e.last,this._firstVisible=e.firstVisible,this._lastVisible=e.lastVisible,this._rangeChanged=this._rangeChanged||this._first!==t||this._last!==M,this._visibilityChanged=this._visibilityChanged||this._firstVisible!==i||this._lastVisible!==N}_correctScrollError(){if(this._scrollError){const{scrollTop:e,scrollLeft:t}=this._scrollerController,{top:M,left:i}=this._scrollError;this._scrollError=null,this._scrollerController.correctScrollError({top:e-M,left:t-i})}}element(e){return e===1/0&&(e=this._items.length-1),void 0===this._items?.[e]?void 0:{scrollIntoView:(t={})=>this._scrollElementIntoView({...t,index:e})}}_scrollElementIntoView(e){if(e.index>=this._first&&e.index<=this._last)this._children[e.index-this._first].scrollIntoView(e);else if(e.index=Math.min(e.index,this._items.length-1),"smooth"===e.behavior){const t=this._layout.getScrollIntoViewCoordinates(e),{behavior:M}=e;this._updateScrollIntoViewCoordinates=this._scrollerController.managedScrollTo(Object.assign(t,{behavior:M}),(()=>this._layout.getScrollIntoViewCoordinates(e)),(()=>this._scrollIntoViewTarget=null)),this._scrollIntoViewTarget=e}else this._layout.pin=e}_checkScrollIntoViewTarget(e){const{index:t}=this._scrollIntoViewTarget||{};t&&e?.has(t)&&this._updateScrollIntoViewCoordinates(this._layout.getScrollIntoViewCoordinates(this._scrollIntoViewTarget))}_notifyRange(){this._hostElement.dispatchEvent(new $i({first:this._first,last:this._last}))}_notifyVisibility(){this._hostElement.dispatchEvent(new Ji({first:this._firstVisible,last:this._lastVisible}))}get layoutComplete(){return this._layoutCompletePromise||(this._layoutCompletePromise=new Promise(((e,t)=>{this._layoutCompleteResolver=e,this._layoutCompleteRejecter=t}))),this._layoutCompletePromise}_rejectLayoutCompletePromise(e){null!==this._layoutCompleteRejecter&&this._layoutCompleteRejecter(e),this._resetLayoutCompleteState()}_scheduleLayoutComplete(){this._layoutCompletePromise&&null===this._pendingLayoutComplete&&(this._pendingLayoutComplete=requestAnimationFrame((()=>requestAnimationFrame((()=>this._resolveLayoutCompletePromise())))))}_resolveLayoutCompletePromise(){null!==this._layoutCompleteResolver&&this._layoutCompleteResolver(),this._resetLayoutCompleteState()}_resetLayoutCompleteState(){this._layoutCompletePromise=null,this._layoutCompleteResolver=null,this._layoutCompleteRejecter=null,this._pendingLayoutComplete=null}_hostElementSizeChanged(){this._schedule(this._updateLayout)}_childLoaded(){}_childrenSizeChanged(e){if(this._layout?.measureChildren){for(const t of e)this._toBeMeasured.set(t.target,t.contentRect);this._measureChildren()}this._scheduleLayoutComplete(),this._itemsChanged=!1,this._rangeChanged=!1}}function NN(e){const t=e?parseFloat(e):NaN;return Number.isNaN(t)?0:t}function oN(e){if(null!==e.assignedSlot)return e.assignedSlot;if(null!==e.parentElement)return e.parentElement;const t=e.parentNode;return t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&t.host||null}const sN=he(class extends _i{constructor(e){if(super(e),this._virtualizer=null,this._first=0,this._last=-1,this._renderItem=(e,t)=>((e,t)=>R`${t}: ${JSON.stringify(e,null,2)}`)(e,t+this._first),this._keyFunction=(e,t)=>(e=>e)(e,this._first),this._items=[],e.type!==de)throw new Error("The virtualize directive can only be used in child expressions")}render(e){e&&this._setFunctions(e);const t=[];if(this._first>=0&&this._last>=this._first)for(let e=this._first;e<=this._last;e++)t.push(this._items[e]);return Fi(t,this._keyFunction,this._renderItem)}update(e,[t]){this._setFunctions(t);const M=this._items!==t.items;return this._items=t.items||[],this._virtualizer?this._updateVirtualizerConfig(e,t):this._initialize(e,t),M?G:this.render()}async _updateVirtualizerConfig(e,t){if(!await this._virtualizer.updateLayoutConfig(t.layout||{})){const M=e.parentNode;this._makeVirtualizer(M,t)}this._virtualizer.items=this._items}_setFunctions(e){const{renderItem:t,keyFunction:M}=e;t&&(this._renderItem=(e,M)=>t(e,M+this._first)),M&&(this._keyFunction=(e,t)=>M(e,t+this._first))}_makeVirtualizer(e,t){this._virtualizer&&this._virtualizer.disconnected();const{layout:M,scroller:i,items:N}=t;this._virtualizer=new iN({hostElement:e,layout:M,scroller:i}),this._virtualizer.items=N,this._virtualizer.connected()}_initialize(e,t){const M=e.parentNode;M&&1===M.nodeType&&(M.addEventListener("rangeChanged",(e=>{this._first=e.first,this._last=e.last,this.setValue(this.render())})),this._makeVirtualizer(M,t))}disconnected(){this._virtualizer?.disconnected()}reconnected(){this._virtualizer?.connected()}});class nN{static getVirtualizedContent(e,t,M,i,N,o,s,n,r,a,l){return R`
4329
- <div part="select-options" class="select__options ${t?"select__options__search-enabled":""}">
4343
+ <div part="select-options" class="select__options ${t?"select__options__search-enabled":""} ${a?"loading":""}">
4330
4344
  ${n&&!a?R`
4331
4345
  <div part="select-no-results" class="select__no-results">
4332
4346
  ${r||"No results found"}
@@ -4344,7 +4358,7 @@ class Hi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
4344
4358
  `}
4345
4359
  </div>
4346
4360
  `}
4347
- </div>`}static getItemRenderFunction(e,t,M,i,N,o){const s=N||t,n=o||(e=>e?.value||e),r=n(e),a=s(e),l=e?.disabled||!1,D=e?.className;let u=!1;return u=i?Array.isArray(M)&&M.includes(r):(Array.isArray(M)?M[0]:M)===r,R`
4361
+ </div>`}static getItemRenderFunction(e,t,M,i,N,o){const s=N||t,n=o||(e=>e?.value||e),r=n(e),a=s(e),l=e?.disabled||!1,D=e?.className;let u=!1;return u=i?Array.isArray(M)&&M.some((e=>String(e)===String(r))):(Array.isArray(M)?M[0]:M)===r,R`
4348
4362
  <nile-option
4349
4363
  value=${r}
4350
4364
  .selected=${u}
@@ -4354,7 +4368,7 @@ class Hi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
4354
4368
  >
4355
4369
  ${pe(a)}
4356
4370
  </nile-option>
4357
- `}static shouldUseVirtualizer(e){return e.length>=5}}let rN=class extends Pe{constructor(){super(...arguments),this.formControlController=new be(this,{assumeInteractionOn:["nile-blur","nile-input"]}),this.hasSlotController=new ve(this,"help-text","label"),this.hasFocus=!1,this.displayLabel="",this.selectedOptions=[],this.oldValue="",this.scrolling=!1,this.name="",this.data=[],this.originalOptionItems=[],this.value="",this.defaultValue="",this.size="medium",this.placeholder="Select...",this.searchValue="",this.searchEnabled=!1,this.internalSearchPlaceHolder="Search...",this.disableLocalSearch=!1,this.optionsLoading=!1,this.multiple=!1,this.helpText="",this.errorMessage="",this.warning=!1,this.error=!1,this.success=!1,this.disabled=!1,this.clearable=!1,this.open=!1,this.hoist=!1,this.filled=!1,this.pill=!1,this.label="",this.placement="bottom",this.form="",this.required=!1,this.showNoResults=!1,this.noResultsMessage="No results found",this.showSelected=!1,this.blockValueChange=!1,this.noWidthSync=!1,this.maxOptionsVisible=3,this.oldMaxOptionsVisible=1,this.handleDocumentMouseDown=e=>{if(!this.open)return;const t=e.composedPath(),M=t.includes(this),i=this.popup&&t.includes(this.popup);M||i||this.hide()},this.handleWindowError=e=>{(e.error?.message||e.message||"").includes("Cannot read properties of null (reading 'insertBefore')")&&e.preventDefault()}}get validity(){return this.valueInput?.validity}get validationMessage(){return this.valueInput?.validationMessage??""}connectedCallback(){super.connectedCallback(),this.initializeComponent(),this.setupEventListeners(),this.updateComplete.then((()=>{this.value&&this.data.length>0&&this.selectionChanged()}))}disconnectedCallback(){this.removeOpenListeners(),this.scrollTimeout&&(clearTimeout(this.scrollTimeout),this.scrollTimeout=void 0)}updated(e){e.has("value")&&this.selectionChanged()}initializeComponent(){this.open=!1,this.emit("nile-init")}getDisplayText(e){return this.renderItemConfig?.getDisplayText?this.renderItemConfig.getDisplayText(e):e?.label||e?.name||e?.toString()||""}getItemValue(e){return this.renderItemConfig?.getValue?this.renderItemConfig.getValue(e):e?.value||e}getSearchText(e){return this.renderItemConfig?.getSearchText?this.renderItemConfig.getSearchText(e):this.getDisplayText(e)}setupEventListeners(){this.handleDocumentFocusIn=this.handleDocumentFocusIn.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.handleWindowError=this.handleWindowError.bind(this)}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown),window.addEventListener("error",this.handleWindowError)}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown),window.removeEventListener("error",this.handleWindowError)}handleFocus(){this.hasFocus=!0,this.emit("nile-focus")}handleBlur(){this.hasFocus=!1,this.emit("nile-blur")}handleDocumentFocusIn(e){if(!this.open)return;const t=e.composedPath(),M=t.includes(this),i=this.popup&&t.includes(this.popup);M||i||this.hide()}handleDocumentKeyDown(e){this.shouldIgnoreKeyPress(e)||(this.isEscapeKey(e)&&this.handleEscapeKey(e),this.isEnterOrSpaceKey(e)&&this.handleEnterOrSpaceKey(e))}shouldIgnoreKeyPress(e){const t=e.target,M=null!==t.closest(".select__clear"),i=null!==t.closest("nile-icon-button");return M||i}isEscapeKey(e){return"Escape"===e.key&&this.open}handleEscapeKey(e){e.preventDefault(),e.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})}isEnterOrSpaceKey(e){return"Enter"===e.key||" "===e.key}handleEnterOrSpaceKey(e){e.preventDefault(),e.stopImmediatePropagation(),this.open?this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})):this.show()}handleFooterClick(e){e.stopPropagation(),e.preventDefault()}toggleShowSelected(e){if(e.stopPropagation(),e.preventDefault(),0!==this.selectedOptions?.length){if(this.showSelected=!this.showSelected,this.showSelected){const e=Array.isArray(this.value)?this.value:[this.value];this.data=this.originalOptionItems.filter((t=>e.includes(t.value)))}else this.data=[...this.originalOptionItems];this.requestUpdate(),this.resetScrollPosition()}}unSelectAll(){this.showSelected=!1,this.value=this.multiple?[]:"",this.data=[...this.originalOptionItems],this.selectionChanged(),this.emit("nile-change",{value:this.value,name:this.name}),this.emit("nile-clear",{value:this.multiple?this.value:"",name:this.name}),this.resetScrollPosition()}handleLabelClick(){this.displayInput.focus(),this.hide()}handleComboboxMouseDown(e){this.shouldIgnoreComboboxClick(e)||(e.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open)}shouldIgnoreComboboxClick(e){const t=e.composedPath().some((e=>e instanceof Element&&"nile-icon-button"===e.tagName.toLowerCase()));return this.disabled||t}handleComboboxKeyDown(e){this.isEnterOrSpaceKey(e)&&(e.preventDefault(),this.open=!this.open)}handleClearClick(e){e.stopPropagation(),this.clearSelection()}clearSelection(){this.value,this.value=this.multiple?[]:"",this.selectionChanged(),this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name}),this.emit("nile-clear")}))}handleClearMouseDown(e){e.stopPropagation()}handleOptionClick(e){const t=e.target.closest("nile-option");if(this.shouldBlockValueChange(t))return;const M=this.value;this.oldValue=M,t&&!t.disabled&&this.handleOptionSelection(t)}shouldBlockValueChange(e){return!(!this.blockValueChange||!e)&&(this.emit("nile-block-change",{value:e?.value,name:this.name}),this.hide(),!0)}handleOptionSelection(e){const t=e.value;this.multiple?this.toggleOptionSelection(t):this.setSelectedOptions(t),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==this.oldValue&&this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name})})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0}))}setSelectedOptions(e){this.value=e,this.selectionChanged()}toggleOptionSelection(e){const t=Array.isArray(this.value)?this.value:[];t.includes(e)?this.value=t.filter((t=>t!==e)):this.value=[...t,e],this.selectionChanged()}handleTagRemove(e,t){e.stopPropagation(),this.disabled||(this.removeTagFromSelection(t),this.emitTagRemovalEvent(t))}removeTagFromSelection(e){let t=this.value;Array.isArray(t)||(t=t?[t]:[]);const M=t.filter((t=>t!==e.value));this.value=M,this.selectionChanged()}emitTagRemovalEvent(e){this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name}),this.emit("nile-tag-remove",{value:this.value,name:this.name,removedtagvalue:e.value})}))}selectionChanged(){const e=this.originalOptionItems.length>0?this.originalOptionItems:this.data;if(this.selectedOptions=ji.createVirtualOptionsFromValues(this.value,e,this.getDisplayText.bind(this),this.renderItemConfig?.getValue),this.multiple)this.placeholder&&0===this.value.length?this.displayLabel="":this.displayLabel=this.selectedOptions.length+" selected";else{const e=Array.isArray(this.value)?this.value[0]:this.value,t=this.selectedOptions[0]?.getTextLabel();this.displayLabel=t||(e??"")}this.updateValidity(),0===this.selectedOptions.length&&(this.showSelected=!1),this.calculateTotalWidthOfTags()}handleSearchFocus(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleSearchBlur(){document.addEventListener("keydown",this.handleDocumentKeyDown)}handleSearchChange(e){this.searchValue=e.detail.value,this.emit("nile-search",{query:this.searchValue,name:this.name}),this.disableLocalSearch||(this.filterVirtualOptions(this.searchValue),this.resetScrollPosition())}handleScroll(e){if(this.showSelected)return;const t=e.target;this.emit("nile-scroll",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name}),this.scrolling||(this.scrolling=!0,this.emit("nile-scroll-start",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name})),clearTimeout(this.scrollTimeout),this.scrollTimeout=window.setTimeout((()=>{this.scrolling&&(this.scrolling=!1)}),300);Math.ceil(t.scrollTop)>=Math.floor(t.scrollHeight-t.offsetHeight)&&this.emit("nile-scroll-end",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name,isAtBottom:!0})}filterVirtualOptions(e){const t=ci.filterVirtualOptions(e,this.originalOptionItems,this.data,this.getDisplayText.bind(this),this.renderItemConfig?.getSearchText);this.data=t.filteredItems,this.showNoResults=t.showNoResults,this.showSelected=!1,this.requestUpdate()}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e)}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}handleValueChange(){this.selectionChanged(),this.requestUpdate()}handleDataChange(){this.data.length>0&&this.open&&!this.showSelected&&(this.originalOptionItems=[...this.data]),this.selectionChanged(),this.optionsLoading||0!==this.data.length?this.data.length>0&&(this.showNoResults=!1):this.showNoResults=!0,this.requestUpdate()}handleRenderItemConfigChange(){this.value&&this.data.length>0&&(this.selectionChanged(),this.requestUpdate())}handleOptionsLoadingChange(){this.optionsLoading||0!==this.data.length||(this.showNoResults=!0),this.requestUpdate()}async handleOpenChange(){this.open&&!this.disabled?await this.handleOpen():await this.handleClose()}async handleOpen(){this.emit("nile-show",{value:this.value,name:this.name}),this.addOpenListeners(),this.showNoResults=!this.data?.length,await ct(this),this.popup.active=!0;const{keyframes:e,options:t}=yt(this,"select.show",{dir:"ltr"});await ut(this.popup.popup,e,t),this.initializeOriginalItems(),this.filterVirtualOptions(this.searchValue),this.resetScrollPosition(),this.emit("nile-after-show",{value:this.value,name:this.name})}async handleClose(){this.emit("nile-hide",{value:this.value,name:this.name}),this.removeOpenListeners(),await ct(this);const{keyframes:e,options:t}=yt(this,"select.hide",{dir:"ltr"});await ut(this.popup.popup,e,t),this.popup.active=!1,this.searchValue="",this.emit("nile-after-hide",{value:this.value,name:this.name})}initializeOriginalItems(){this.data.length>0&&(this.originalOptionItems=[...this.data])}async show(){if(!this.open&&!this.disabled)return this.open=!0,St(this,"nile-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,St(this,"nile-after-hide");this.open=!1}checkValidity(){return this.valueInput.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.valueInput.reportValidity()}setCustomValidity(e){this.valueInput.setCustomValidity(e),this.formControlController.updateValidity()}focus(e){this.displayInput.focus(e)}blur(){this.displayInput.blur()}onInputChange(e){e.stopPropagation()}render(){const e=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const t=this.hasSlotController.test("label-suffix"),M=this.hasSlotController.test("custom-select"),i=!!this.label||!!e,N=this.clearable&&!this.disabled&&this.value.length>0,o=!!this.placeholder&&0===this.value.length,s=!!this.helpText,n=!!this.errorMessage;return R`
4371
+ `}static shouldUseVirtualizer(e){return e.length>=5}}let rN=class extends Pe{constructor(){super(...arguments),this.formControlController=new be(this,{assumeInteractionOn:["nile-blur","nile-input"]}),this.hasSlotController=new ve(this,"help-text","label"),this.hasFocus=!1,this.displayLabel="",this.selectedOptions=[],this.oldValue="",this.scrolling=!1,this.name="",this.data=[],this.originalOptionItems=[],this.value="",this.defaultValue="",this.size="medium",this.placeholder="Select...",this.searchValue="",this.searchEnabled=!1,this.internalSearchPlaceHolder="Search...",this.disableLocalSearch=!1,this.optionsLoading=!1,this.loading=!1,this.multiple=!1,this.helpText="",this.errorMessage="",this.warning=!1,this.error=!1,this.success=!1,this.disabled=!1,this.clearable=!1,this.open=!1,this.hoist=!1,this.filled=!1,this.pill=!1,this.label="",this.placement="bottom",this.form="",this.required=!1,this.showNoResults=!1,this.noResultsMessage="No results found",this.showSelected=!1,this.blockValueChange=!1,this.noWidthSync=!1,this.maxOptionsVisible=3,this.oldMaxOptionsVisible=1,this.handleDocumentMouseDown=e=>{if(!this.open)return;const t=e.composedPath(),M=t.includes(this),i=this.popup&&t.includes(this.popup);M||i||this.hide()},this.handleWindowError=e=>{(e.error?.message||e.message||"").includes("Cannot read properties of null (reading 'insertBefore')")&&e.preventDefault()}}get validity(){return this.valueInput?.validity}get validationMessage(){return this.valueInput?.validationMessage??""}connectedCallback(){super.connectedCallback(),this.initializeComponent(),this.setupEventListeners(),this.updateComplete.then((()=>{this.value&&this.data.length>0&&this.selectionChanged()}))}disconnectedCallback(){this.removeOpenListeners(),this.scrollTimeout&&(clearTimeout(this.scrollTimeout),this.scrollTimeout=void 0)}updated(e){e.has("value")&&this.selectionChanged()}initializeComponent(){this.open=!1,this.emit("nile-init")}getDisplayText(e){return this.renderItemConfig?.getDisplayText?this.renderItemConfig.getDisplayText(e):e?.label||e?.name||e?.toString()||""}getItemValue(e){return this.renderItemConfig?.getValue?this.renderItemConfig.getValue(e):e?.value||e}getSearchText(e){return this.renderItemConfig?.getSearchText?this.renderItemConfig.getSearchText(e):this.getDisplayText(e)}setupEventListeners(){this.handleDocumentFocusIn=this.handleDocumentFocusIn.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.handleWindowError=this.handleWindowError.bind(this)}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown),window.addEventListener("error",this.handleWindowError)}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown),window.removeEventListener("error",this.handleWindowError)}handleFocus(){this.hasFocus=!0,this.emit("nile-focus")}handleBlur(){this.hasFocus=!1,this.emit("nile-blur")}handleDocumentFocusIn(e){if(!this.open)return;const t=e.composedPath(),M=t.includes(this),i=this.popup&&t.includes(this.popup);M||i||this.hide()}handleDocumentKeyDown(e){this.shouldIgnoreKeyPress(e)||(this.isEscapeKey(e)&&this.handleEscapeKey(e),this.isEnterOrSpaceKey(e)&&this.handleEnterOrSpaceKey(e))}shouldIgnoreKeyPress(e){const t=e.target,M=null!==t.closest(".select__clear"),i=null!==t.closest("nile-icon-button");return M||i}isEscapeKey(e){return"Escape"===e.key&&this.open}handleEscapeKey(e){e.preventDefault(),e.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})}isEnterOrSpaceKey(e){return"Enter"===e.key||" "===e.key}handleEnterOrSpaceKey(e){e.preventDefault(),e.stopImmediatePropagation(),this.open?this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})):this.show()}handleFooterClick(e){e.stopPropagation(),e.preventDefault()}toggleShowSelected(e){if(e.stopPropagation(),e.preventDefault(),0!==this.selectedOptions?.length){if(this.showSelected=!this.showSelected,this.showSelected){const e=Array.isArray(this.value)?this.value:[this.value];this.data=this.originalOptionItems.filter((t=>{const M=this.getItemValue(t);return e.some((e=>String(e)===String(M)))}))}else this.data=[...this.originalOptionItems];this.requestUpdate(),this.resetScrollPosition()}}unSelectAll(){this.showSelected=!1,this.value=this.multiple?[]:"",this.data=[...this.originalOptionItems],this.selectionChanged(),this.emit("nile-change",{value:this.value,name:this.name}),this.emit("nile-clear",{value:this.multiple?this.value:"",name:this.name}),this.resetScrollPosition()}handleLabelClick(){this.displayInput.focus(),this.hide()}handleComboboxMouseDown(e){this.shouldIgnoreComboboxClick(e)||(e.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open)}shouldIgnoreComboboxClick(e){const t=e.composedPath().some((e=>e instanceof Element&&"nile-icon-button"===e.tagName.toLowerCase()));return this.disabled||t}handleComboboxKeyDown(e){this.isEnterOrSpaceKey(e)&&(e.preventDefault(),this.open=!this.open)}handleClearClick(e){e.stopPropagation(),this.clearSelection()}clearSelection(){this.value,this.value=this.multiple?[]:"",this.selectionChanged(),this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name}),this.emit("nile-clear")}))}handleClearMouseDown(e){e.stopPropagation()}handleOptionClick(e){const t=e.target.closest("nile-option");if(this.shouldBlockValueChange(t))return;const M=this.value;this.oldValue=M,t&&!t.disabled&&this.handleOptionSelection(t)}shouldBlockValueChange(e){return!(!this.blockValueChange||!e)&&(this.emit("nile-block-change",{value:e?.value,name:this.name}),this.hide(),!0)}handleOptionSelection(e){const t=e.value;this.multiple?this.toggleOptionSelection(t):this.setSelectedOptions(t),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==this.oldValue&&this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name})})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0}))}setSelectedOptions(e){this.value=e,this.selectionChanged()}toggleOptionSelection(e){const t=Array.isArray(this.value)?this.value:[];t.includes(e)?this.value=t.filter((t=>t!==e)):this.value=[...t,e],this.selectionChanged()}handleTagRemove(e,t){e.stopPropagation(),this.disabled||(this.removeTagFromSelection(t),this.emitTagRemovalEvent(t))}removeTagFromSelection(e){let t=this.value;Array.isArray(t)||(t=t?[t]:[]);const M=t.filter((t=>t!==e.value));this.value=M,this.selectionChanged()}emitTagRemovalEvent(e){this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name}),this.emit("nile-tag-remove",{value:this.value,name:this.name,removedtagvalue:e.value})}))}selectionChanged(){const e=this.originalOptionItems.length>0?this.originalOptionItems:this.data;if(this.selectedOptions=ji.createVirtualOptionsFromValues(this.value,e,this.getDisplayText.bind(this),this.renderItemConfig?.getValue),this.multiple)this.placeholder&&0===this.value.length?this.displayLabel="":this.displayLabel=this.selectedOptions.length+" selected";else{const e=Array.isArray(this.value)?this.value[0]:this.value,t=this.selectedOptions[0]?.getTextLabel();this.displayLabel=t||(e??"")}this.updateValidity(),0===this.selectedOptions.length&&(this.showSelected=!1),this.calculateTotalWidthOfTags()}handleSearchFocus(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleSearchBlur(){document.addEventListener("keydown",this.handleDocumentKeyDown)}handleSearchChange(e){this.searchValue=e.detail.value,this.emit("nile-search",{query:this.searchValue,name:this.name}),this.disableLocalSearch||(this.filterVirtualOptions(this.searchValue),this.resetScrollPosition())}handleScroll(e){if(this.showSelected)return;const t=e.target;this.emit("nile-scroll",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name}),this.scrolling||(this.scrolling=!0,this.emit("nile-scroll-start",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name})),clearTimeout(this.scrollTimeout),this.scrollTimeout=window.setTimeout((()=>{this.scrolling&&(this.scrolling=!1)}),300);Math.ceil(t.scrollTop)>=Math.floor(t.scrollHeight-t.offsetHeight)&&this.emit("nile-scroll-end",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name,isAtBottom:!0})}filterVirtualOptions(e){const t=ci.filterVirtualOptions(e,this.originalOptionItems,this.data,this.getDisplayText.bind(this),this.renderItemConfig?.getSearchText);this.data=t.filteredItems,this.showNoResults=t.showNoResults,this.showSelected=!1,this.requestUpdate()}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e)}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}handleValueChange(){this.selectionChanged(),this.requestUpdate()}handleDataChange(){this.data.length>0&&this.open&&!this.showSelected&&!this.searchValue&&(this.originalOptionItems=[...this.data]),this.selectionChanged(),this.optionsLoading||this.loading||0!==this.data.length?this.data.length>0&&(this.showNoResults=!1):this.showNoResults=!0,this.requestUpdate()}handleRenderItemConfigChange(){this.value&&this.data.length>0&&(this.selectionChanged(),this.requestUpdate())}handleOptionsLoadingChange(){this.optionsLoading||0!==this.data.length||(this.showNoResults=!0),this.requestUpdate()}async handleOpenChange(){this.open&&!this.disabled?await this.handleOpen():await this.handleClose()}async handleOpen(){this.emit("nile-show",{value:this.value,name:this.name}),this.addOpenListeners(),this.showNoResults=!this.data?.length,await ct(this),this.popup.active=!0;const{keyframes:e,options:t}=yt(this,"select.show",{dir:"ltr"});await ut(this.popup.popup,e,t),this.initializeOriginalItems(),this.filterVirtualOptions(this.searchValue),this.resetScrollPosition(),this.emit("nile-after-show",{value:this.value,name:this.name})}async handleClose(){this.emit("nile-hide",{value:this.value,name:this.name}),this.removeOpenListeners(),await ct(this);const{keyframes:e,options:t}=yt(this,"select.hide",{dir:"ltr"});await ut(this.popup.popup,e,t),this.popup.active=!1,this.searchValue="",this.emit("nile-after-hide",{value:this.value,name:this.name})}initializeOriginalItems(){this.data.length>0&&(this.originalOptionItems=[...this.data])}async show(){if(!this.open&&!this.disabled)return this.open=!0,St(this,"nile-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,St(this,"nile-after-hide");this.open=!1}checkValidity(){return this.valueInput.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.valueInput.reportValidity()}setCustomValidity(e){this.valueInput.setCustomValidity(e),this.formControlController.updateValidity()}focus(e){this.displayInput.focus(e)}blur(){this.displayInput.blur()}onInputChange(e){e.stopPropagation()}render(){const e=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const t=this.hasSlotController.test("label-suffix"),M=this.hasSlotController.test("custom-select"),i=!!this.label||!!e,N=this.clearable&&!this.disabled&&this.value.length>0,o=!!this.placeholder&&0===this.value.length,s=!!this.helpText,n=!!this.errorMessage;return R`
4358
4372
  <div
4359
4373
  part="form-control"
4360
4374
  class=${Le({"form-control":!0,"form-control--small":"small"===this.size,"form-control--medium":"medium"===this.size,"form-control--large":"large"===this.size,"form-control--has-label":i,"form-control--has-help-text":s})}
@@ -4540,17 +4554,21 @@ class Hi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
4540
4554
  <nile-icon name="search" slot="suffix"> </nile-icon>
4541
4555
  </nile-input>
4542
4556
  </div>
4543
- `:R``}renderLoader(){return this.optionsLoading?R`
4544
- <span part="loader" class="select__loader">
4545
- <nile-icon
4546
- class="select__loader--icon"
4547
- name="button-loading-blue"
4548
- ></nile-icon>
4549
- </span>
4550
- `:R``}renderFooter(){return this.multiple?R`
4557
+ `:R``}renderLoader(){return this.loading?R`
4558
+ <span part="loader" class="virtual-select-loader">
4559
+ <nile-loader size="sm"></nile-loader>
4560
+ </span>
4561
+ `:this.optionsLoading?R`
4562
+ <span part="loader" class="select__loader">
4563
+ <nile-icon
4564
+ class="select__loader--icon"
4565
+ name="button-loading-blue"
4566
+ ></nile-icon>
4567
+ </span>
4568
+ `:R``}renderFooter(){return this.multiple?R`
4551
4569
  <div
4552
4570
  part="footer"
4553
- class="select__footer"
4571
+ class="select__footer ${this.loading?"loading":""}"
4554
4572
  @click="${this.handleFooterClick}"
4555
4573
  >
4556
4574
  <span
@@ -4580,7 +4598,7 @@ class Hi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
4580
4598
  >${this.errorMessage}</nile-form-error-message
4581
4599
  >
4582
4600
  `:""}
4583
- `}getVirtualizedContent(){return nN.getVirtualizedContent(this.data,this.searchEnabled,this.getDisplayText.bind(this),this.value,this.multiple,this.renderItemConfig?.getDisplayText,this.renderItemConfig?.getValue,this.showNoResults,this.noResultsMessage,this.optionsLoading,this.handleScroll.bind(this))}nileInput(e){this.emit("nile-input",e)}nileChange(e){this.emit("nile-change",e)}updateValidity(){this.updateComplete.then((()=>{this.formControlController.updateValidity()}))}calculateWidthOfSelectTagsDiv(){if(this.shadowRoot){const e=this.shadowRoot.querySelector(".select__tags");if(e){return e.offsetWidth-70}}return null}calculateTotalWidthOfTags(){this.maxOptionsVisible!==1/0&&(this.oldMaxOptionsVisible=this.maxOptionsVisible),this.maxOptionsVisible=1/0,setTimeout((()=>{let e=[];if(this.shadowRoot){this.shadowRoot.querySelectorAll("nile-tag").forEach((t=>{t instanceof HTMLElement&&e.push(t.offsetWidth)}))}if(this.value.length!==e.length)return;const t=this.calculateWidthOfSelectTagsDiv();if(!t)return;let M=0,i=0;for(let N=0;N<e.length;N++)if(M+=e[N],M>t){i=N;break}this.maxOptionsVisible=i}),1)}resetScrollPosition(){this.updateComplete.then((()=>{if(this.virtualizedContainer&&this.virtualizedContainer.isConnected){this.virtualizedContainer.scrollTop=0;const e=this.shadowRoot?.querySelector(".select__listbox");e&&e.isConnected&&(e.scrollTop=0);const t=this.virtualizedContainer.querySelector("lit-virtualizer");t&&t.isConnected&&(t.scrollTop=0)}}))}};rN.styles=gi,e([ze(".select")],rN.prototype,"popup",void 0),e([ze(".select__display-input")],rN.prototype,"displayInput",void 0),e([ze(".select__value-input")],rN.prototype,"valueInput",void 0),e([ze(".virtualized")],rN.prototype,"virtualizedContainer",void 0),e([je()],rN.prototype,"hasFocus",void 0),e([je()],rN.prototype,"displayLabel",void 0),e([je()],rN.prototype,"selectedOptions",void 0),e([je()],rN.prototype,"oldValue",void 0),e([ge()],rN.prototype,"name",void 0),e([ge({type:Array})],rN.prototype,"data",void 0),e([je()],rN.prototype,"originalOptionItems",void 0),e([ge({converter:{fromAttribute:e=>e.split(" "),toAttribute:e=>e.join(" ")}})],rN.prototype,"value",void 0),e([$e()],rN.prototype,"defaultValue",void 0),e([ge()],rN.prototype,"size",void 0),e([ge()],rN.prototype,"placeholder",void 0),e([je()],rN.prototype,"searchValue",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"searchEnabled",void 0),e([ge({attribute:"internal-search-placeholder"})],rN.prototype,"internalSearchPlaceHolder",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"disableLocalSearch",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"optionsLoading",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"multiple",void 0),e([ge({attribute:"help-text",reflect:!0})],rN.prototype,"helpText",void 0),e([ge({attribute:"error-message",reflect:!0})],rN.prototype,"errorMessage",void 0),e([ge({type:Boolean})],rN.prototype,"warning",void 0),e([ge({type:Boolean})],rN.prototype,"error",void 0),e([ge({type:Boolean})],rN.prototype,"success",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"disabled",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"clearable",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"open",void 0),e([ge({type:Boolean})],rN.prototype,"hoist",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"filled",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"pill",void 0),e([ge()],rN.prototype,"label",void 0),e([ge({reflect:!0})],rN.prototype,"placement",void 0),e([ge({reflect:!0})],rN.prototype,"form",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"required",void 0),e([ge({type:Boolean})],rN.prototype,"showNoResults",void 0),e([ge({type:String})],rN.prototype,"noResultsMessage",void 0),e([ge({type:Boolean})],rN.prototype,"showSelected",void 0),e([ge({attribute:!1})],rN.prototype,"renderItemConfig",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"blockValueChange",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"noWidthSync",void 0),e([ge({attribute:"max-options-visible",type:Number})],rN.prototype,"maxOptionsVisible",void 0),e([je()],rN.prototype,"oldMaxOptionsVisible",void 0),e([Ve("disabled",{waitUntilFirstUpdate:!0})],rN.prototype,"handleDisabledChange",null),e([Ve("value",{waitUntilFirstUpdate:!0})],rN.prototype,"handleValueChange",null),e([Ve("data",{waitUntilFirstUpdate:!0})],rN.prototype,"handleDataChange",null),e([Ve("renderItemConfig",{waitUntilFirstUpdate:!0})],rN.prototype,"handleRenderItemConfigChange",null),e([Ve("optionsLoading",{waitUntilFirstUpdate:!0})],rN.prototype,"handleOptionsLoadingChange",null),e([Ve("open",{waitUntilFirstUpdate:!0})],rN.prototype,"handleOpenChange",null),rN=e([le("nile-virtual-select")],rN),Ot("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),Ot("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});class aN{constructor(e){this.component=e}renderVirtualizedContent(){const e=this.component;return R`
4601
+ `}getVirtualizedContent(){return nN.getVirtualizedContent(this.data,this.searchEnabled,this.getDisplayText.bind(this),this.value,this.multiple,this.renderItemConfig?.getDisplayText,this.renderItemConfig?.getValue,this.showNoResults,this.noResultsMessage,this.optionsLoading||this.loading,this.handleScroll.bind(this))}nileInput(e){this.emit("nile-input",e)}nileChange(e){this.emit("nile-change",e)}updateValidity(){this.updateComplete.then((()=>{this.formControlController.updateValidity()}))}calculateWidthOfSelectTagsDiv(){if(this.shadowRoot){const e=this.shadowRoot.querySelector(".select__tags");if(e){return e.offsetWidth-70}}return null}calculateTotalWidthOfTags(){this.maxOptionsVisible!==1/0&&(this.oldMaxOptionsVisible=this.maxOptionsVisible),this.maxOptionsVisible=1/0,setTimeout((()=>{let e=[];if(this.shadowRoot){this.shadowRoot.querySelectorAll("nile-tag").forEach((t=>{t instanceof HTMLElement&&e.push(t.offsetWidth)}))}if(this.value.length!==e.length)return;const t=this.calculateWidthOfSelectTagsDiv();if(!t)return;let M=0,i=0;for(let N=0;N<e.length;N++)if(M+=e[N],M>t){i=N;break}this.maxOptionsVisible=i}),1)}resetScrollPosition(){this.updateComplete.then((()=>{if(this.virtualizedContainer&&this.virtualizedContainer.isConnected){this.virtualizedContainer.scrollTop=0;const e=this.shadowRoot?.querySelector(".select__listbox");e&&e.isConnected&&(e.scrollTop=0);const t=this.virtualizedContainer.querySelector("lit-virtualizer");t&&t.isConnected&&(t.scrollTop=0)}}))}};rN.styles=gi,e([ze(".select")],rN.prototype,"popup",void 0),e([ze(".select__display-input")],rN.prototype,"displayInput",void 0),e([ze(".select__value-input")],rN.prototype,"valueInput",void 0),e([ze(".virtualized")],rN.prototype,"virtualizedContainer",void 0),e([je()],rN.prototype,"hasFocus",void 0),e([je()],rN.prototype,"displayLabel",void 0),e([je()],rN.prototype,"selectedOptions",void 0),e([je()],rN.prototype,"oldValue",void 0),e([ge()],rN.prototype,"name",void 0),e([ge({type:Array})],rN.prototype,"data",void 0),e([je()],rN.prototype,"originalOptionItems",void 0),e([ge({converter:{fromAttribute:e=>e.split(" "),toAttribute:e=>e.join(" ")}})],rN.prototype,"value",void 0),e([$e()],rN.prototype,"defaultValue",void 0),e([ge()],rN.prototype,"size",void 0),e([ge()],rN.prototype,"placeholder",void 0),e([je()],rN.prototype,"searchValue",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"searchEnabled",void 0),e([ge({attribute:"internal-search-placeholder"})],rN.prototype,"internalSearchPlaceHolder",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"disableLocalSearch",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"optionsLoading",void 0),e([ge({type:Boolean,reflect:!0,attribute:!0})],rN.prototype,"loading",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"multiple",void 0),e([ge({attribute:"help-text",reflect:!0})],rN.prototype,"helpText",void 0),e([ge({attribute:"error-message",reflect:!0})],rN.prototype,"errorMessage",void 0),e([ge({type:Boolean})],rN.prototype,"warning",void 0),e([ge({type:Boolean})],rN.prototype,"error",void 0),e([ge({type:Boolean})],rN.prototype,"success",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"disabled",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"clearable",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"open",void 0),e([ge({type:Boolean})],rN.prototype,"hoist",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"filled",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"pill",void 0),e([ge()],rN.prototype,"label",void 0),e([ge({reflect:!0})],rN.prototype,"placement",void 0),e([ge({reflect:!0})],rN.prototype,"form",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"required",void 0),e([ge({type:Boolean})],rN.prototype,"showNoResults",void 0),e([ge({type:String})],rN.prototype,"noResultsMessage",void 0),e([ge({type:Boolean})],rN.prototype,"showSelected",void 0),e([ge({attribute:!1})],rN.prototype,"renderItemConfig",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"blockValueChange",void 0),e([ge({type:Boolean,reflect:!0})],rN.prototype,"noWidthSync",void 0),e([ge({attribute:"max-options-visible",type:Number})],rN.prototype,"maxOptionsVisible",void 0),e([je()],rN.prototype,"oldMaxOptionsVisible",void 0),e([Ve("disabled",{waitUntilFirstUpdate:!0})],rN.prototype,"handleDisabledChange",null),e([Ve("value",{waitUntilFirstUpdate:!0})],rN.prototype,"handleValueChange",null),e([Ve("data",{waitUntilFirstUpdate:!0})],rN.prototype,"handleDataChange",null),e([Ve("renderItemConfig",{waitUntilFirstUpdate:!0})],rN.prototype,"handleRenderItemConfigChange",null),e([Ve("optionsLoading",{waitUntilFirstUpdate:!0})],rN.prototype,"handleOptionsLoadingChange",null),e([Ve("open",{waitUntilFirstUpdate:!0})],rN.prototype,"handleOpenChange",null),rN=e([le("nile-virtual-select")],rN),Ot("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),Ot("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});class aN{constructor(e){this.component=e}renderVirtualizedContent(){const e=this.component;return R`
4584
4602
  <div class="virtual-select">
4585
4603
  <nile-virtual-select
4586
4604
  .name=${e.name}
@@ -4614,6 +4632,7 @@ class Hi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
4614
4632
  .maxOptionsVisible=${e.maxOptionsVisible}
4615
4633
  .data=${e.data}
4616
4634
  .open=${e.open}
4635
+ .loading=${e.loading}
4617
4636
  exportparts="
4618
4637
  select-options,
4619
4638
  select-no-results,
@@ -4638,7 +4657,7 @@ class Hi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
4638
4657
  <slot name="prefix" slot="prefix"></slot>
4639
4658
  </nile-virtual-select>
4640
4659
  </div>
4641
- `}}let lN=class extends Pe{get validity(){return this.valueInput?.validity}get validationMessage(){return this.valueInput?.validationMessage}constructor(){super(),this.hasSlotController=new ve(this,"help-text","label"),this.typeToSelectString="",this.scrolling=!1,this.options=[],this.hasFocus=!1,this.displayLabel="",this.selectedOptions=[],this.oldValue="",this.name="",this.value="",this.defaultValue="",this.size="medium",this.placeholder="Select...",this.searchValue="",this.searchEnabled=!1,this.internalSearchPlaceHolder="Search...",this.blockValueChange=!1,this.disableLocalSearch=!1,this.optionsLoading=!1,this.noWidthSync=!1,this.multiple=!1,this.helpText="",this.errorMessage="",this.warning=!1,this.error=!1,this.success=!1,this.maxOptionsVisible=3,this.disabled=!1,this.clearable=!1,this.open=!1,this.hoist=!1,this.filled=!1,this.pill=!1,this.label="",this.placement="bottom",this.form="",this.required=!1,this.showSelected=!1,this.oldMaxOptionsVisible=1,this.showNoResults=!1,this.noResultsMessage="No results found",this.data=[],this.enableVirtualScroll=!1,this.enableGroupHeader=!1,this.autoFocusSearch=!1}connectedCallback(){super.connectedCallback(),this.enableVirtualScroll||(this.formControlController=new be(this,{assumeInteractionOn:["nile-blur","nile-input"]})),this.virtualScrollHelper=new aN(this),this.handleDocumentFocusIn=this.handleDocumentFocusIn.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.open=!1,this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.scrollTimeout&&(clearTimeout(this.scrollTimeout),this.scrollTimeout=void 0),this.emit("nile-destroy")}updated(e){e.has("multiple")&&this.setCheckBoxInOption(this.multiple)}firstUpdated(e){this.enableGroupHeader&&this.handleGroupSearchChange(),e.has("multiple")&&this.setCheckBoxInOption(this.multiple)}setCheckBoxInOption(e){this.options.length||(this.options=this.getAllOptions()),this.options.forEach((t=>{t.showCheckbox=e}))}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}handleFocus(){this.hasFocus=!0,this.displayInput.setSelectionRange(0,0),this.emit("nile-focus",{value:this.value,name:this.name})}handleBlur(){this.hasFocus=!1,this.emit("nile-blur",{value:this.value,name:this.name})}handleDocumentFocusIn(e){const t=e.composedPath();this&&!t.includes(this)&&this.hide()}handleFooterClick(e){e.stopPropagation(),e.preventDefault()}toggleShowSelected(e){if(e.stopPropagation(),e.preventDefault(),0===this.selectedOptions?.length)return;this.showSelected=!this.showSelected;this.getAllOptions().forEach((e=>{e.selected||(e.hidden=this.showSelected)})),this.enableGroupHeader&&this.handleGroupShowSelected()}unSlectAll(){this.showSelected=!1;this.getAllOptions().forEach((e=>{e.selected=!1,e.hidden=!1})),this.enableGroupHeader&&this.handleGroupShowSelected(),this.value="",this.selectionChanged(),this.emit("nile-change",{value:this.value,name:this.name}),this.emit("nile-clear",{value:this.multiple?this.value:"",name:this.name})}handleDocumentKeyDown(e){const t=e.target,M=null!==t.closest(".select__clear"),i=null!==t.closest("nile-icon-button");if(!M&&!i){if("Escape"===e.key&&this.open&&(e.preventDefault(),e.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})),"Enter"===e.key||" "===e.key&&""===this.typeToSelectString)return e.preventDefault(),e.stopImmediatePropagation(),this.open?void(this.currentOption&&!this.currentOption.disabled&&(this.multiple?this.toggleOptionSelection(this.currentOption):this.setSelectedOptions(this.currentOption),this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name})})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))):void this.show();if(1===e.key.length||"Backspace"===e.key){const t=this.getAllOptions();if(e.metaKey||e.ctrlKey||e.altKey)return;if(!this.open){if("Backspace"===e.key)return;this.show()}e.stopPropagation(),e.preventDefault(),clearTimeout(this.typeToSelectTimeout),this.typeToSelectTimeout=window.setTimeout((()=>this.typeToSelectString=""),1e3),"Backspace"===e.key?this.typeToSelectString=this.typeToSelectString.slice(0,-1):this.typeToSelectString+=e.key.toLowerCase();for(const e of t){if(e.getTextLabel().toLowerCase().startsWith(this.typeToSelectString)){this.setCurrentOption(e);break}}}}}handleDocumentMouseDown(e){const t=e.composedPath();this&&!t.includes(this)&&this.hide()}handleLabelClick(){this.displayInput.focus(),this.hide()}handleComboboxMouseDown(e){const t=e.composedPath().some((e=>e instanceof Element&&"nile-icon-button"===e.tagName.toLowerCase()));this.disabled||t||(e.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open)}handleComboboxKeyDown(e){e.stopPropagation(),this.handleDocumentKeyDown(e)}handleClearClick(e){e.stopPropagation(),""!==this.value&&(this.setSelectedOptions([]),this.showSelected=!1,this.value="",this.displayInput.focus({preventScroll:!0}),this.enableGroupHeader&&this.handleGroupShowSelected(),this.updateComplete.then((()=>{const e={value:this.multiple?this.value:"",name:this.name};this.emit("nile-clear",e),this.nileInput(e),this.nileChange(e)})))}handleClearMouseDown(e){e.stopPropagation(),e.preventDefault()}handleOptionClick(e){const t=e.target.closest("nile-option");if(this.blockValueChange&&t)return this.emit("nile-block-change",{value:t?.value,name:this.name}),void this.hide();const M=this.value;if(this.oldValue=M,t&&!t.disabled&&(this.multiple?this.toggleOptionSelection(t):this.setSelectedOptions(t),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==M&&this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name})})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0}))),this.showSelected){this.getAllOptions().forEach((e=>{e.selected||(e.hidden=this.showSelected)})),this.enableGroupHeader&&this.handleGroupShowSelected(),this.requestUpdate()}}handleDefaultSlotChange(){const e=this.getAllOptions(),t=Array.isArray(this.value)?this.value:[this.value],M=[];customElements.get("nile-option")?(e.forEach((e=>M.push(e.value))),this.setSelectedOptions(e.filter((e=>t.map(String).includes(e.value))))):customElements.whenDefined("nile-option").then((()=>this.handleDefaultSlotChange()))}handleTagRemove(e,t){if(e.stopPropagation(),!this.disabled){this.toggleOptionSelection(t,!1);this.getAllOptions().forEach((e=>{e.selected||(e.hidden=this.showSelected)})),this.enableGroupHeader&&this.handleGroupShowSelected(),this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name}),this.emit("nile-tag-remove",{value:this.value,name:this.name,removedtagvalue:t.value})}))}}getAllOptions(){const e=[...this.querySelectorAll("nile-option")];return this.multiple&&this.oldValue?.length>0&&e.sort(((e,t)=>{let M=this.oldValue.indexOf(e.value),i=this.oldValue.indexOf(t.value);return-1===M&&(M=1/0),-1===i&&(i=1/0),M<i?-1:M>i?1:0})),e}getOptionPrefix(e){const t=e.shadowRoot?.querySelector('slot[name="prefix"]');if(!t)return"";const M=t.assignedNodes(),i=[];return M.forEach((e=>{e instanceof HTMLElement?i.push(e.outerHTML):e.nodeType===Node.TEXT_NODE&&i.push(e.textContent||"")})),i.join("")}getFirstOption(){return this.querySelector("nile-option")}setCurrentOption(e){this.getAllOptions().forEach((e=>{e.current=!1,e.tabIndex=-1})),e&&(this.currentOption=e,e.current=!0,e.tabIndex=0,e.focus())}setSelectedOptions(e){const t=this.getAllOptions(),M=Array.isArray(e)?e:[e];t.forEach((e=>e.selected=!1)),M.length&&M.forEach((e=>e.selected=!0)),this.selectionChanged()}toggleOptionSelection(e,t){e.selected=!0===t||!1===t?t:!e.selected,this.selectionChanged()}selectionChanged(){if(this.selectedOptions=this.getAllOptions().filter((e=>e.selected)),this.multiple){if(this.value=this.selectedOptions.map((e=>e.value)),this.placeholder&&0===this.value.length?this.displayLabel="":this.displayLabel=this.selectedOptions.length+" selected",0===this.selectedOptions.length){this.showSelected=!1;this.getAllOptions().forEach((e=>{e.selected||(e.hidden=this.showSelected)})),this.requestUpdate()}}else this.value=this.selectedOptions[0]?.value??this.value,this.displayLabel=this.selectedOptions[0]?.getTextLabel()?this.selectedOptions[0].getTextLabel():this.value??"";this.updateComplete.then((()=>{this.formControlController?.updateValidity()})),this.calculateTotalWidthOfTags()}handleSearchFocus(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleSearchBlur(){document.addEventListener("keydown",this.handleDocumentKeyDown)}handleSearchChange(e){if(this.searchValue=e.detail.value,this.emit("nile-search",{query:this.searchValue,name:this.name}),this.enableGroupHeader&&this.handleGroupSearchChange(),!this.disableLocalSearch){0===this.filterOptions(this.searchValue).length?this.showNoResults=!0:this.showNoResults=!1}}handleScroll(e){const t=e.target;this.emit("nile-scroll",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name}),this.scrolling||(this.scrolling=!0,this.emit("nile-scroll-start",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name})),clearTimeout(this.scrollTimeout),this.scrollTimeout=window.setTimeout((()=>{this.scrolling&&(this.scrolling=!1)}),300);Math.ceil(t.scrollTop)>=Math.floor(t.scrollHeight-t.offsetHeight)&&this.emit("nile-scroll-end",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name,isAtBottom:!0})}filterOptions(e){const t=this.getAllOptions(),M=e.toLowerCase();let i=[];return t.forEach((e=>{const t=e.getTextLabel().toLowerCase(),N=(e.value||"").toLowerCase();t.includes(M)||N.includes(M)?(e.hidden=!1,i.push(e)):e.hidden=!0})),i}handleInvalid(e){this.formControlController?.setValidity(!1),this.formControlController?.emitInvalidEvent(e)}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}handleValueChange(){const e=this.getAllOptions(),t=Array.isArray(this.value)?this.value:[this.value];this.enableVirtualScroll||this.setSelectedOptions(e.filter((e=>t.includes(e.value))))}async handleOpenChange(){if(this.open&&!this.disabled){this.setCurrentOption(this.selectedOptions[0]||this.getFirstOption()),this.emit("nile-show",{value:this.value,name:this.name}),this.enableGroupHeader&&this.getAllGroupAttributes().forEach((e=>{e.element.classList.remove("nile-group-hidden")})),this.addOpenListeners(),this.showNoResults=!this.getAllOptions()?.length,await ct(this),this.listbox.hidden=!1,this.popup.active=!0,requestAnimationFrame((()=>{this.setCurrentOption(this.currentOption)}));const{keyframes:e,options:t}=yt(this,"select.show",{dir:"ltr"});await ut(this.popup.popup,e,t),this.currentOption&&xt(this.currentOption,this.listbox,"vertical","auto"),this.searchValue="",this.filterOptions(this.searchValue),this.emit("nile-after-show",{value:this.value,name:this.name}),this.autoFocusSearch&&this.handleInputAfterInit()}else{this.emit("nile-hide",{value:this.value,name:this.name}),this.showSelected=!1,this.removeOpenListeners(),await ct(this);const{keyframes:e,options:t}=yt(this,"select.hide",{dir:"ltr"});await ut(this.popup.popup,e,t),this.listbox.hidden=!0,this.popup.active=!1,this.searchValue="",this.emit("nile-after-hide",{value:this.value,name:this.name})}}getAllGroupAttributes(){return Array.from(this.querySelectorAll("nile-option-group[name]")).map((e=>({name:e?.getAttribute("name")||"",data:e?.getAttribute("data"),element:e})))}getUniqueGroupNames(e){return Array.from(new Set(e.map((e=>e?.groupName))))}handleGroupSearchChange(){const e=new Set(this.getUniqueGroupNames(this.filterOptions(this.searchValue)));this.getAllGroupAttributes().forEach((({name:t,element:M})=>{M?.classList.toggle("nile-group-hidden",!e.has(t))}))}handleGroupShowSelected(){const e=new Set;this.showSelected&&this.getAllOptions().forEach((t=>{t.hidden||e.add(t.groupName)})),this.getAllGroupAttributes().forEach((({name:t,element:M})=>{M?.classList.toggle("nile-group-hidden",this.showSelected&&!e.has(t))}))}async show(){if(!this.open&&!this.disabled)return this.open=!0,St(this,"nile-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,St(this,"nile-after-hide");this.open=!1}checkValidity(){return this.valueInput.checkValidity()}getForm(){return this.formControlController?.getForm()||null}reportValidity(){return this.valueInput.reportValidity()}setCustomValidity(e){this.valueInput.setCustomValidity(e),this.formControlController?.updateValidity()}focus(e){this.displayInput.focus(e)}blur(){this.displayInput.blur()}onInputChange(e){e.stopPropagation()}calculateWidthOfSelectTagsDiv(){if(this.shadowRoot){const e=this.shadowRoot.querySelector("div.select__tags");if(e instanceof HTMLElement){return e.offsetWidth-70}}}calculateTotalWidthOfTags(){this.maxOptionsVisible!==1/0&&(this.oldMaxOptionsVisible=this.maxOptionsVisible),this.maxOptionsVisible=1/0,setTimeout((()=>{let e=[];if(this.shadowRoot){this.shadowRoot.querySelectorAll("nile-tag").forEach((t=>{t instanceof HTMLElement&&e.push(t.offsetWidth)}))}if(this.value.length!==e.length)return;const t=this.calculateWidthOfSelectTagsDiv();if(!t)return;let M=0,i=0;for(let N=0;N<e.length;N++)if(M+=e[N],M>t){i=N;break}this.maxOptionsVisible=i}),1)}handleInputAfterInit(){this.shadowRoot?.querySelector("nile-input")?.inputFocus()}render(){if(this.enableVirtualScroll)return this.virtualScrollHelper.renderVirtualizedContent();const e=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const t=this.hasSlotController.test("label-suffix"),M=this.hasSlotController.test("custom-select"),i=!!this.label||!!e,N=this.clearable&&!this.disabled&&this.value.length>0,o=this.placeholder&&0===this.value.length,s=!!this.helpText,n=!!this.errorMessage,r=this.selectedOptions[0]?this.getOptionPrefix(this.selectedOptions[0]):"";return R`
4660
+ `}}let lN=class extends Pe{get validity(){return this.valueInput?.validity}get validationMessage(){return this.valueInput?.validationMessage}constructor(){super(),this.hasSlotController=new ve(this,"help-text","label"),this.typeToSelectString="",this.scrolling=!1,this.options=[],this.hasFocus=!1,this.displayLabel="",this.selectedOptions=[],this.oldValue="",this.name="",this.value="",this.defaultValue="",this.size="medium",this.placeholder="Select...",this.searchValue="",this.searchEnabled=!1,this.internalSearchPlaceHolder="Search...",this.blockValueChange=!1,this.disableLocalSearch=!1,this.optionsLoading=!1,this.noWidthSync=!1,this.multiple=!1,this.helpText="",this.errorMessage="",this.warning=!1,this.error=!1,this.success=!1,this.maxOptionsVisible=3,this.disabled=!1,this.clearable=!1,this.open=!1,this.hoist=!1,this.filled=!1,this.pill=!1,this.label="",this.placement="bottom",this.form="",this.required=!1,this.showSelected=!1,this.oldMaxOptionsVisible=1,this.showNoResults=!1,this.noResultsMessage="No results found",this.data=[],this.enableVirtualScroll=!1,this.enableGroupHeader=!1,this.autoFocusSearch=!1,this.loading=!1}connectedCallback(){super.connectedCallback(),this.enableVirtualScroll||(this.formControlController=new be(this,{assumeInteractionOn:["nile-blur","nile-input"]})),this.virtualScrollHelper=new aN(this),this.handleDocumentFocusIn=this.handleDocumentFocusIn.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.open=!1,this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.scrollTimeout&&(clearTimeout(this.scrollTimeout),this.scrollTimeout=void 0),this.emit("nile-destroy")}updated(e){e.has("multiple")&&this.setCheckBoxInOption(this.multiple)}firstUpdated(e){this.enableGroupHeader&&this.handleGroupSearchChange(),e.has("multiple")&&this.setCheckBoxInOption(this.multiple)}setCheckBoxInOption(e){this.options.length||(this.options=this.getAllOptions()),this.options.forEach((t=>{t.showCheckbox=e}))}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}handleFocus(){this.hasFocus=!0,this.displayInput.setSelectionRange(0,0),this.emit("nile-focus",{value:this.value,name:this.name})}handleBlur(){this.hasFocus=!1,this.emit("nile-blur",{value:this.value,name:this.name})}handleDocumentFocusIn(e){const t=e.composedPath();this&&!t.includes(this)&&this.hide()}handleFooterClick(e){e.stopPropagation(),e.preventDefault()}toggleShowSelected(e){if(e.stopPropagation(),e.preventDefault(),0===this.selectedOptions?.length)return;this.showSelected=!this.showSelected;this.getAllOptions().forEach((e=>{e.selected||(e.hidden=this.showSelected)})),this.enableGroupHeader&&this.handleGroupShowSelected()}unSlectAll(){this.showSelected=!1;this.getAllOptions().forEach((e=>{e.selected=!1,e.hidden=!1})),this.enableGroupHeader&&this.handleGroupShowSelected(),this.value="",this.selectionChanged(),this.emit("nile-change",{value:this.value,name:this.name}),this.emit("nile-clear",{value:this.multiple?this.value:"",name:this.name})}handleDocumentKeyDown(e){const t=e.target,M=null!==t.closest(".select__clear"),i=null!==t.closest("nile-icon-button");if(!M&&!i){if("Escape"===e.key&&this.open&&(e.preventDefault(),e.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})),"Enter"===e.key||" "===e.key&&""===this.typeToSelectString)return e.preventDefault(),e.stopImmediatePropagation(),this.open?void(this.currentOption&&!this.currentOption.disabled&&(this.multiple?this.toggleOptionSelection(this.currentOption):this.setSelectedOptions(this.currentOption),this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name})})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))):void this.show();if(1===e.key.length||"Backspace"===e.key){const t=this.getAllOptions();if(e.metaKey||e.ctrlKey||e.altKey)return;if(!this.open){if("Backspace"===e.key)return;this.show()}e.stopPropagation(),e.preventDefault(),clearTimeout(this.typeToSelectTimeout),this.typeToSelectTimeout=window.setTimeout((()=>this.typeToSelectString=""),1e3),"Backspace"===e.key?this.typeToSelectString=this.typeToSelectString.slice(0,-1):this.typeToSelectString+=e.key.toLowerCase();for(const e of t){if(e.getTextLabel().toLowerCase().startsWith(this.typeToSelectString)){this.setCurrentOption(e);break}}}}}handleDocumentMouseDown(e){const t=e.composedPath();this&&!t.includes(this)&&this.hide()}handleLabelClick(){this.displayInput.focus(),this.hide()}handleComboboxMouseDown(e){const t=e.composedPath().some((e=>e instanceof Element&&"nile-icon-button"===e.tagName.toLowerCase()));this.disabled||t||(e.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open)}handleComboboxKeyDown(e){e.stopPropagation(),this.handleDocumentKeyDown(e)}handleClearClick(e){e.stopPropagation(),""!==this.value&&(this.setSelectedOptions([]),this.showSelected=!1,this.value="",this.displayInput.focus({preventScroll:!0}),this.enableGroupHeader&&this.handleGroupShowSelected(),this.updateComplete.then((()=>{const e={value:this.multiple?this.value:"",name:this.name};this.emit("nile-clear",e),this.nileInput(e),this.nileChange(e)})))}handleClearMouseDown(e){e.stopPropagation(),e.preventDefault()}handleOptionClick(e){const t=e.target.closest("nile-option");if(this.blockValueChange&&t)return this.emit("nile-block-change",{value:t?.value,name:this.name}),void this.hide();const M=this.value;if(this.oldValue=M,t&&!t.disabled&&(this.multiple?this.toggleOptionSelection(t):this.setSelectedOptions(t),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==M&&this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name})})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0}))),this.showSelected){this.getAllOptions().forEach((e=>{e.selected||(e.hidden=this.showSelected)})),this.enableGroupHeader&&this.handleGroupShowSelected(),this.requestUpdate()}}handleDefaultSlotChange(){const e=this.getAllOptions(),t=Array.isArray(this.value)?this.value:[this.value],M=[];customElements.get("nile-option")?(e.forEach((e=>M.push(e.value))),this.setSelectedOptions(e.filter((e=>t.map(String).includes(e.value))))):customElements.whenDefined("nile-option").then((()=>this.handleDefaultSlotChange()))}handleTagRemove(e,t){if(e.stopPropagation(),!this.disabled){this.toggleOptionSelection(t,!1);this.getAllOptions().forEach((e=>{e.selected||(e.hidden=this.showSelected)})),this.enableGroupHeader&&this.handleGroupShowSelected(),this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name}),this.emit("nile-tag-remove",{value:this.value,name:this.name,removedtagvalue:t.value})}))}}getAllOptions(){const e=[...this.querySelectorAll("nile-option")];return this.multiple&&this.oldValue?.length>0&&e.sort(((e,t)=>{let M=this.oldValue.indexOf(e.value),i=this.oldValue.indexOf(t.value);return-1===M&&(M=1/0),-1===i&&(i=1/0),M<i?-1:M>i?1:0})),e}getOptionPrefix(e){const t=e.shadowRoot?.querySelector('slot[name="prefix"]');if(!t)return"";const M=t.assignedNodes(),i=[];return M.forEach((e=>{e instanceof HTMLElement?i.push(e.outerHTML):e.nodeType===Node.TEXT_NODE&&i.push(e.textContent||"")})),i.join("")}getFirstOption(){return this.querySelector("nile-option")}setCurrentOption(e){this.getAllOptions().forEach((e=>{e.current=!1,e.tabIndex=-1})),e&&(this.currentOption=e,e.current=!0,e.tabIndex=0,e.focus())}setSelectedOptions(e){const t=this.getAllOptions(),M=Array.isArray(e)?e:[e];t.forEach((e=>e.selected=!1)),M.length&&M.forEach((e=>e.selected=!0)),this.selectionChanged()}toggleOptionSelection(e,t){e.selected=!0===t||!1===t?t:!e.selected,this.selectionChanged()}selectionChanged(){if(this.selectedOptions=this.getAllOptions().filter((e=>e.selected)),this.multiple){if(this.value=this.selectedOptions.map((e=>e.value)),this.placeholder&&0===this.value.length?this.displayLabel="":this.displayLabel=this.selectedOptions.length+" selected",0===this.selectedOptions.length){this.showSelected=!1;this.getAllOptions().forEach((e=>{e.selected||(e.hidden=this.showSelected)})),this.requestUpdate()}}else this.value=this.selectedOptions[0]?.value??this.value,this.displayLabel=this.selectedOptions[0]?.getTextLabel()?this.selectedOptions[0].getTextLabel():this.value??"";this.updateComplete.then((()=>{this.formControlController?.updateValidity()})),this.calculateTotalWidthOfTags()}handleSearchFocus(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleSearchBlur(){document.addEventListener("keydown",this.handleDocumentKeyDown)}handleSearchChange(e){if(this.searchValue=e.detail.value,this.emit("nile-search",{query:this.searchValue,name:this.name}),this.enableGroupHeader&&this.handleGroupSearchChange(),!this.disableLocalSearch){0===this.filterOptions(this.searchValue).length?this.showNoResults=!0:this.showNoResults=!1}}handleScroll(e){const t=e.target;this.emit("nile-scroll",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name}),this.scrolling||(this.scrolling=!0,this.emit("nile-scroll-start",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name})),clearTimeout(this.scrollTimeout),this.scrollTimeout=window.setTimeout((()=>{this.scrolling&&(this.scrolling=!1)}),300);Math.ceil(t.scrollTop)>=Math.floor(t.scrollHeight-t.offsetHeight)&&this.emit("nile-scroll-end",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name,isAtBottom:!0})}filterOptions(e){const t=this.getAllOptions(),M=e.toLowerCase();let i=[];return t.forEach((e=>{const t=e.getTextLabel().toLowerCase(),N=(e.value||"").toLowerCase();t.includes(M)||N.includes(M)?(e.hidden=!1,i.push(e)):e.hidden=!0})),i}handleInvalid(e){this.formControlController?.setValidity(!1),this.formControlController?.emitInvalidEvent(e)}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}handleValueChange(){const e=this.getAllOptions(),t=Array.isArray(this.value)?this.value:[this.value];this.enableVirtualScroll||this.setSelectedOptions(e.filter((e=>t.includes(e.value))))}async handleOpenChange(){if(this.open&&!this.disabled){this.setCurrentOption(this.selectedOptions[0]||this.getFirstOption()),this.emit("nile-show",{value:this.value,name:this.name}),this.enableGroupHeader&&this.getAllGroupAttributes().forEach((e=>{e.element.classList.remove("nile-group-hidden")})),this.addOpenListeners(),this.showNoResults=!this.getAllOptions()?.length,await ct(this),this.listbox.hidden=!1,this.popup.active=!0,requestAnimationFrame((()=>{this.setCurrentOption(this.currentOption)}));const{keyframes:e,options:t}=yt(this,"select.show",{dir:"ltr"});await ut(this.popup.popup,e,t),this.currentOption&&xt(this.currentOption,this.listbox,"vertical","auto"),this.searchValue="",this.filterOptions(this.searchValue),this.emit("nile-after-show",{value:this.value,name:this.name}),this.autoFocusSearch&&this.handleInputAfterInit()}else{this.emit("nile-hide",{value:this.value,name:this.name}),this.showSelected=!1,this.removeOpenListeners(),await ct(this);const{keyframes:e,options:t}=yt(this,"select.hide",{dir:"ltr"});await ut(this.popup.popup,e,t),this.listbox.hidden=!0,this.popup.active=!1,this.searchValue="",this.emit("nile-after-hide",{value:this.value,name:this.name})}}getAllGroupAttributes(){return Array.from(this.querySelectorAll("nile-option-group[name]")).map((e=>({name:e?.getAttribute("name")||"",data:e?.getAttribute("data"),element:e})))}getUniqueGroupNames(e){return Array.from(new Set(e.map((e=>e?.groupName))))}handleGroupSearchChange(){const e=new Set(this.getUniqueGroupNames(this.filterOptions(this.searchValue)));this.getAllGroupAttributes().forEach((({name:t,element:M})=>{M?.classList.toggle("nile-group-hidden",!e.has(t))}))}handleGroupShowSelected(){const e=new Set;this.showSelected&&this.getAllOptions().forEach((t=>{t.hidden||e.add(t.groupName)})),this.getAllGroupAttributes().forEach((({name:t,element:M})=>{M?.classList.toggle("nile-group-hidden",this.showSelected&&!e.has(t))}))}async show(){if(!this.open&&!this.disabled)return this.open=!0,St(this,"nile-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,St(this,"nile-after-hide");this.open=!1}checkValidity(){return this.valueInput.checkValidity()}getForm(){return this.formControlController?.getForm()||null}reportValidity(){return this.valueInput.reportValidity()}setCustomValidity(e){this.valueInput.setCustomValidity(e),this.formControlController?.updateValidity()}focus(e){this.displayInput.focus(e)}blur(){this.displayInput.blur()}onInputChange(e){e.stopPropagation()}calculateWidthOfSelectTagsDiv(){if(this.shadowRoot){const e=this.shadowRoot.querySelector("div.select__tags");if(e instanceof HTMLElement){return e.offsetWidth-70}}}calculateTotalWidthOfTags(){this.maxOptionsVisible!==1/0&&(this.oldMaxOptionsVisible=this.maxOptionsVisible),this.maxOptionsVisible=1/0,setTimeout((()=>{let e=[];if(this.shadowRoot){this.shadowRoot.querySelectorAll("nile-tag").forEach((t=>{t instanceof HTMLElement&&e.push(t.offsetWidth)}))}if(this.value.length!==e.length)return;const t=this.calculateWidthOfSelectTagsDiv();if(!t)return;let M=0,i=0;for(let N=0;N<e.length;N++)if(M+=e[N],M>t){i=N;break}this.maxOptionsVisible=i}),1)}handleInputAfterInit(){this.shadowRoot?.querySelector("nile-input")?.inputFocus()}render(){if(this.enableVirtualScroll)return this.virtualScrollHelper.renderVirtualizedContent();const e=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const t=this.hasSlotController.test("label-suffix"),M=this.hasSlotController.test("custom-select"),i=!!this.label||!!e,N=this.clearable&&!this.disabled&&this.value.length>0,o=this.placeholder&&0===this.value.length,s=!!this.helpText,n=!!this.errorMessage,r=this.selectedOptions[0]?this.getOptionPrefix(this.selectedOptions[0]):"";return R`
4642
4661
  <div
4643
4662
  part="form-control"
4644
4663
  class=${Le({"form-control":!0,"form-control--small":"small"===this.size,"form-control--medium":"medium"===this.size,"form-control--large":"large"===this.size,"form-control--has-label":i,"form-control--has-help-text":s})}
@@ -4865,7 +4884,7 @@ class Hi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
4865
4884
  >
4866
4885
  `:""}
4867
4886
  </div>
4868
- `}nileInput(e){this.emit("nile-input",e)}nileChange(e){this.emit("nile-change",e)}};lN.styles=li,e([ze(".select")],lN.prototype,"popup",void 0),e([ze(".select__combobox")],lN.prototype,"combobox",void 0),e([ze(".select__display-input")],lN.prototype,"displayInput",void 0),e([ze(".select__value-input")],lN.prototype,"valueInput",void 0),e([ze(".select__listbox")],lN.prototype,"listbox",void 0),e([je()],lN.prototype,"hasFocus",void 0),e([je()],lN.prototype,"displayLabel",void 0),e([je()],lN.prototype,"currentOption",void 0),e([je()],lN.prototype,"selectedOptions",void 0),e([je()],lN.prototype,"oldValue",void 0),e([ge()],lN.prototype,"name",void 0),e([ge({converter:{fromAttribute:e=>e.split(" "),toAttribute:e=>e.join(" ")}})],lN.prototype,"value",void 0),e([$e()],lN.prototype,"defaultValue",void 0),e([ge()],lN.prototype,"size",void 0),e([ge()],lN.prototype,"placeholder",void 0),e([je()],lN.prototype,"searchValue",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"searchEnabled",void 0),e([ge({attribute:"internal-search-placeholder"})],lN.prototype,"internalSearchPlaceHolder",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"blockValueChange",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"disableLocalSearch",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"optionsLoading",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"noWidthSync",void 0),e([ge({reflect:!0,converter:{fromAttribute:e=>""===e||"true"===e||"false"!==e&&e,toAttribute:e=>"boolean"==typeof e?String(e):e}})],lN.prototype,"multiple",void 0),e([ge({attribute:"help-text",reflect:!0})],lN.prototype,"helpText",void 0),e([ge({attribute:"error-message",reflect:!0})],lN.prototype,"errorMessage",void 0),e([ge({type:Boolean})],lN.prototype,"warning",void 0),e([ge({type:Boolean})],lN.prototype,"error",void 0),e([ge({type:Boolean})],lN.prototype,"success",void 0),e([ge({attribute:"max-options-visible",type:Number})],lN.prototype,"maxOptionsVisible",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"disabled",void 0),e([ge({type:Boolean})],lN.prototype,"clearable",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"open",void 0),e([ge({type:Boolean})],lN.prototype,"hoist",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"filled",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"pill",void 0),e([ge()],lN.prototype,"label",void 0),e([ge({reflect:!0})],lN.prototype,"placement",void 0),e([ge({reflect:!0})],lN.prototype,"form",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"required",void 0),e([ge({type:Boolean})],lN.prototype,"showSelected",void 0),e([je()],lN.prototype,"oldMaxOptionsVisible",void 0),e([ge({type:Boolean})],lN.prototype,"showNoResults",void 0),e([ge({type:String})],lN.prototype,"noResultsMessage",void 0),e([ge({attribute:!1})],lN.prototype,"renderItemConfig",void 0),e([ge({type:Array})],lN.prototype,"data",void 0),e([ge({type:Boolean})],lN.prototype,"enableVirtualScroll",void 0),e([ge({type:Boolean,reflect:!0,attribute:!0})],lN.prototype,"enableGroupHeader",void 0),e([ge({type:Boolean,reflect:!0,attribute:!0})],lN.prototype,"autoFocusSearch",void 0),e([Ve("disabled",{waitUntilFirstUpdate:!0})],lN.prototype,"handleDisabledChange",null),e([Ve("value",{waitUntilFirstUpdate:!0})],lN.prototype,"handleValueChange",null),e([Ve("open",{waitUntilFirstUpdate:!0})],lN.prototype,"handleOpenChange",null),lN=e([le("nile-select")],lN),Ot("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),Ot("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});const DN=s`
4887
+ `}nileInput(e){this.emit("nile-input",e)}nileChange(e){this.emit("nile-change",e)}};lN.styles=li,e([ze(".select")],lN.prototype,"popup",void 0),e([ze(".select__combobox")],lN.prototype,"combobox",void 0),e([ze(".select__display-input")],lN.prototype,"displayInput",void 0),e([ze(".select__value-input")],lN.prototype,"valueInput",void 0),e([ze(".select__listbox")],lN.prototype,"listbox",void 0),e([je()],lN.prototype,"hasFocus",void 0),e([je()],lN.prototype,"displayLabel",void 0),e([je()],lN.prototype,"currentOption",void 0),e([je()],lN.prototype,"selectedOptions",void 0),e([je()],lN.prototype,"oldValue",void 0),e([ge()],lN.prototype,"name",void 0),e([ge({converter:{fromAttribute:e=>e.split(" "),toAttribute:e=>e.join(" ")}})],lN.prototype,"value",void 0),e([$e()],lN.prototype,"defaultValue",void 0),e([ge()],lN.prototype,"size",void 0),e([ge()],lN.prototype,"placeholder",void 0),e([je()],lN.prototype,"searchValue",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"searchEnabled",void 0),e([ge({attribute:"internal-search-placeholder"})],lN.prototype,"internalSearchPlaceHolder",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"blockValueChange",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"disableLocalSearch",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"optionsLoading",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"noWidthSync",void 0),e([ge({reflect:!0,converter:{fromAttribute:e=>""===e||"true"===e||"false"!==e&&e,toAttribute:e=>"boolean"==typeof e?String(e):e}})],lN.prototype,"multiple",void 0),e([ge({attribute:"help-text",reflect:!0})],lN.prototype,"helpText",void 0),e([ge({attribute:"error-message",reflect:!0})],lN.prototype,"errorMessage",void 0),e([ge({type:Boolean})],lN.prototype,"warning",void 0),e([ge({type:Boolean})],lN.prototype,"error",void 0),e([ge({type:Boolean})],lN.prototype,"success",void 0),e([ge({attribute:"max-options-visible",type:Number})],lN.prototype,"maxOptionsVisible",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"disabled",void 0),e([ge({type:Boolean})],lN.prototype,"clearable",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"open",void 0),e([ge({type:Boolean})],lN.prototype,"hoist",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"filled",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"pill",void 0),e([ge()],lN.prototype,"label",void 0),e([ge({reflect:!0})],lN.prototype,"placement",void 0),e([ge({reflect:!0})],lN.prototype,"form",void 0),e([ge({type:Boolean,reflect:!0})],lN.prototype,"required",void 0),e([ge({type:Boolean})],lN.prototype,"showSelected",void 0),e([je()],lN.prototype,"oldMaxOptionsVisible",void 0),e([ge({type:Boolean})],lN.prototype,"showNoResults",void 0),e([ge({type:String})],lN.prototype,"noResultsMessage",void 0),e([ge({attribute:!1})],lN.prototype,"renderItemConfig",void 0),e([ge({type:Array})],lN.prototype,"data",void 0),e([ge({type:Boolean})],lN.prototype,"enableVirtualScroll",void 0),e([ge({type:Boolean,reflect:!0,attribute:!0})],lN.prototype,"enableGroupHeader",void 0),e([ge({type:Boolean,reflect:!0,attribute:!0})],lN.prototype,"autoFocusSearch",void 0),e([ge({type:Boolean,reflect:!0,attribute:!0})],lN.prototype,"loading",void 0),e([Ve("disabled",{waitUntilFirstUpdate:!0})],lN.prototype,"handleDisabledChange",null),e([Ve("value",{waitUntilFirstUpdate:!0})],lN.prototype,"handleValueChange",null),e([Ve("open",{waitUntilFirstUpdate:!0})],lN.prototype,"handleOpenChange",null),lN=e([le("nile-select")],lN),Ot("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),Ot("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});const DN=s`
4869
4888
  :host {
4870
4889
  display: block;
4871
4890
  user-select: none;