@aquera/nile-elements 1.8.6 → 1.8.7
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.
- package/README.md +4 -0
- package/dist/index.js +76 -31
- package/dist/nile-markdown-editor/nile-markdown-editor.cjs.js +1 -1
- package/dist/nile-markdown-editor/nile-markdown-editor.cjs.js.map +1 -1
- package/dist/nile-markdown-editor/nile-markdown-editor.esm.js +1 -1
- package/dist/nile-option/nile-option.cjs.js +1 -1
- package/dist/nile-option/nile-option.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.css.cjs.js +1 -1
- package/dist/nile-option/nile-option.css.cjs.js.map +1 -1
- package/dist/nile-option/nile-option.css.esm.js +22 -1
- package/dist/nile-option/nile-option.esm.js +12 -2
- package/dist/nile-select/nile-select.cjs.js +1 -1
- package/dist/nile-select/nile-select.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.css.cjs.js +1 -1
- package/dist/nile-select/nile-select.css.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.css.esm.js +16 -7
- package/dist/nile-select/nile-select.esm.js +2 -2
- package/dist/nile-select/virtual-scroll-helper.cjs.js +1 -1
- package/dist/nile-select/virtual-scroll-helper.cjs.js.map +1 -1
- package/dist/nile-select/virtual-scroll-helper.esm.js +2 -0
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js +3 -3
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.esm.js +4 -3
- package/dist/nile-virtual-select/nile-virtual-select.esm.js +4 -4
- package/dist/nile-virtual-select/renderer.cjs.js +1 -1
- package/dist/nile-virtual-select/renderer.cjs.js.map +1 -1
- package/dist/nile-virtual-select/renderer.esm.js +14 -12
- package/dist/src/nile-markdown-editor/nile-markdown-editor.js +1 -1
- package/dist/src/nile-markdown-editor/nile-markdown-editor.js.map +1 -1
- package/dist/src/nile-option/nile-option.css.js +22 -1
- package/dist/src/nile-option/nile-option.css.js.map +1 -1
- package/dist/src/nile-option/nile-option.d.ts +3 -0
- package/dist/src/nile-option/nile-option.js +21 -0
- package/dist/src/nile-option/nile-option.js.map +1 -1
- package/dist/src/nile-select/nile-select.css.js +16 -7
- package/dist/src/nile-select/nile-select.css.js.map +1 -1
- package/dist/src/nile-select/nile-select.d.ts +7 -0
- package/dist/src/nile-select/nile-select.js +35 -0
- package/dist/src/nile-select/nile-select.js.map +1 -1
- package/dist/src/nile-select/virtual-scroll-helper.js +2 -0
- package/dist/src/nile-select/virtual-scroll-helper.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js +4 -3
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.d.ts +4 -0
- package/dist/src/nile-virtual-select/nile-virtual-select.js +11 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.js.map +1 -1
- package/dist/src/nile-virtual-select/renderer.d.ts +2 -2
- package/dist/src/nile-virtual-select/renderer.js +6 -4
- package/dist/src/nile-virtual-select/renderer.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-markdown-editor/nile-markdown-editor.ts +1 -1
- package/src/nile-option/nile-option.css.ts +22 -1
- package/src/nile-option/nile-option.ts +18 -0
- package/src/nile-select/nile-select.css.ts +16 -7
- package/src/nile-select/nile-select.ts +32 -0
- package/src/nile-select/virtual-scroll-helper.ts +2 -0
- package/src/nile-virtual-select/nile-virtual-select.css.ts +4 -3
- package/src/nile-virtual-select/nile-virtual-select.ts +9 -1
- package/src/nile-virtual-select/renderer.ts +9 -3
- package/vscode-html-custom-data.json +33 -3
package/dist/index.js
CHANGED
|
@@ -4797,7 +4797,8 @@ ${o?_`
|
|
|
4797
4797
|
display: inline-flex;
|
|
4798
4798
|
align-items: center;
|
|
4799
4799
|
justify-content: center;
|
|
4800
|
-
font-
|
|
4800
|
+
font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
|
|
4801
|
+
font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
|
|
4801
4802
|
color: var(--nile-colors-primary-600, var(--ng-colors-text-brand-secondary-700));
|
|
4802
4803
|
border: none;
|
|
4803
4804
|
background: none;
|
|
@@ -4898,21 +4899,29 @@ ${o?_`
|
|
|
4898
4899
|
}
|
|
4899
4900
|
|
|
4900
4901
|
|
|
4902
|
+
/* Default: visible + centered footer with proper nxtgen fallbacks. */
|
|
4901
4903
|
.select__footer {
|
|
4902
4904
|
position: sticky;
|
|
4903
4905
|
bottom: 0px;
|
|
4904
|
-
background: var(--nile-colors-neutral-100);
|
|
4905
|
-
border-top: 1px solid var(--nile-colors-neutral-400);
|
|
4906
|
-
display: flex;
|
|
4906
|
+
background: var(--nile-colors-neutral-100, var(--ng-colors-bg-secondary));
|
|
4907
|
+
border-top: 1px solid var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));
|
|
4907
4908
|
height: 15px;
|
|
4908
4909
|
/* Auto layout */
|
|
4909
|
-
display:var(--nile-display-flex, var(--ng-display-
|
|
4910
|
+
display: var(--nile-display-flex, var(--ng-display-flex));
|
|
4910
4911
|
flex-direction: row;
|
|
4912
|
+
align-items: center;
|
|
4913
|
+
padding: var(--nile-spacing-md, var(--ng-spacing-md)) var(--nile-spacing-lg, var(--ng-spacing-lg));
|
|
4914
|
+
gap: var(--nile-spacing-lg, var(--ng-spacing-lg));
|
|
4915
|
+
justify-content: space-between;
|
|
4916
|
+
}
|
|
4917
|
+
|
|
4918
|
+
:host([legacy]) .select__footer {
|
|
4919
|
+
background: var(--nile-colors-neutral-100);
|
|
4920
|
+
border-top: 1px solid var(--nile-colors-neutral-400);
|
|
4921
|
+
display: var(--nile-display-flex, var(--ng-display-none));
|
|
4911
4922
|
align-items: flex-start;
|
|
4912
4923
|
padding: var(--nile-spacing-md) var(--nile-spacing-lg)
|
|
4913
4924
|
var(--nile-spacing-xl);
|
|
4914
|
-
gap: var(--nile-spacing-lg, var(--ng-spacing-lg));
|
|
4915
|
-
justify-content: space-between;
|
|
4916
4925
|
}
|
|
4917
4926
|
|
|
4918
4927
|
.tag__prefix[slot='prefix'] {
|
|
@@ -5513,7 +5522,8 @@ ${o?_`
|
|
|
5513
5522
|
display: inline-flex;
|
|
5514
5523
|
align-items: center;
|
|
5515
5524
|
justify-content: center;
|
|
5516
|
-
font-
|
|
5525
|
+
font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
|
|
5526
|
+
font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
|
|
5517
5527
|
color: var(--nile-colors-primary-600, var(--ng-colors-text-brand-secondary-700));
|
|
5518
5528
|
border: none;
|
|
5519
5529
|
background: none;
|
|
@@ -5605,8 +5615,8 @@ ${o?_`
|
|
|
5605
5615
|
/* Auto layout */
|
|
5606
5616
|
display: var(--nile-display-flex, var(--ng-display-flex));
|
|
5607
5617
|
flex-direction: row;
|
|
5608
|
-
align-items:
|
|
5609
|
-
padding: var(--nile-spacing-md, var(--ng-spacing-md)) var(--nile-spacing-lg, var(--ng-spacing-lg))
|
|
5618
|
+
align-items: center;
|
|
5619
|
+
padding: var(--nile-spacing-md, var(--ng-spacing-md)) var(--nile-spacing-lg, var(--ng-spacing-lg));
|
|
5610
5620
|
gap: var(--nile-spacing-lg, var(--ng-spacing-lg));
|
|
5611
5621
|
justify-content: space-between;
|
|
5612
5622
|
box-sizing: unset;
|
|
@@ -5736,7 +5746,7 @@ class no{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
5736
5746
|
* @license
|
|
5737
5747
|
* Copyright 2021 Google LLC
|
|
5738
5748
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5739
|
-
*/(this._hostElement,e),this._scrollerController=new oo(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(`[${so}]`);t||(t=document.createElement("div"),t.setAttribute(so,""),e.appendChild(t)),Object.assign(t.style,{position:"absolute",margin:"-2px 0 0 0",padding:0,visibility:"hidden",fontSize:"2px"}),t.textContent=" ",t.setAttribute(so,""),this._sizer=t}return this._sizer}async updateLayoutConfig(e){await this._layoutInitialized;const t=e.type||ao;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,i;if("function"==typeof e.type){i=e.type;const n={...e};delete n.type,t=n}else t=e;void 0===i&&(ao=i=(await Promise.resolve().then((function(){return sQ}))).FlowLayout),this._layout=new i((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,i=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:i}}return null}_measureChildren(){const e={},t=this._children,i=this._measureChildOverride||this._measureChild;for(let n=0;n<t.length;n++){const o=t[n],M=this._first+n;(this._itemsChanged||this._toBeMeasured.has(o))&&(e[M]=i.call(this,o,this._items[M]))}this._childMeasurements=e,this._schedule(this._updateLayout),this._toBeMeasured.clear()}_measureChild(e){const{width:t,height:i}=e.getBoundingClientRect();return Object.assign({width:t,height:i},function(e){const t=window.getComputedStyle(e);return{marginTop:go(t.marginTop),marginRight:go(t.marginRight),marginBottom:go(t.marginBottom),marginLeft:go(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:i}=this;this._visibilityChanged&&(this._notifyVisibility(),this._visibilityChanged=!1),(t||i)&&(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 io)}get _children(){const e=[];let t=this._hostElement.firstElementChild;for(;t;)t.hasAttribute(so)||e.push(t),t=t.nextElementSibling;return e}_updateView(){const e=this._hostElement,t=this._scrollerController?.element,i=this._layout;if(e&&t&&i){let n,o,M,r;const s=e.getBoundingClientRect();n=0,o=0,M=window.innerHeight,r=window.innerWidth;const a=this._clippingAncestors.map((e=>e.getBoundingClientRect()));a.unshift(s);for(const e of a)n=Math.max(n,e.top),o=Math.max(o,e.left),M=Math.min(M,e.bottom),r=Math.min(r,e.right);const l=t.getBoundingClientRect(),g={left:s.left-l.left,top:s.top-l.top},c={width:t.scrollWidth,height:t.scrollHeight},N=n-s.top+e.scrollTop,u=o-s.left+e.scrollLeft,D=Math.max(0,M-n),d=Math.max(0,r-o);i.viewportSize={width:d,height:D},i.viewportScroll={top:N,left:u},i.totalScrollSize=c,i.offsetWithinScroller=g}}_sizeHostElement(e){const t=82e5,i=e&&null!==e.width?Math.min(t,e.width):0,n=e&&null!==e.height?Math.min(t,e.height):0;if(this._isScroller)this._getSizer().style.transform=`translate(${i}px, ${n}px)`;else{const e=this._hostElement.style;e.minWidth=i?`${i}px`:"100%",e.minHeight=n?`${n}px`:"100%"}}_positionChildren(e){e&&e.forEach((({top:e,left:t,width:i,height:n,xOffset:o,yOffset:M},r)=>{const s=this._children[r-this._first];s&&(s.style.position="absolute",s.style.boxSizing="border-box",s.style.transform=`translate(${t}px, ${e}px)`,void 0!==i&&(s.style.width=i+"px"),void 0!==n&&(s.style.height=n+"px"),s.style.left=void 0===o?null:o+"px",s.style.top=void 0===M?null:M+"px")}))}async _adjustRange(e){const{_first:t,_last:i,_firstVisible:n,_lastVisible:o}=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!==i,this._visibilityChanged=this._visibilityChanged||this._firstVisible!==n||this._lastVisible!==o}_correctScrollError(){if(this._scrollError){const{scrollTop:e,scrollLeft:t}=this._scrollerController,{top:i,left:n}=this._scrollError;this._scrollError=null,this._scrollerController.correctScrollError({top:e-i,left:t-n})}}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:i}=e;this._updateScrollIntoViewCoordinates=this._scrollerController.managedScrollTo(Object.assign(t,{behavior:i}),(()=>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 eo({first:this._first,last:this._last}))}_notifyVisibility(){this._hostElement.dispatchEvent(new to({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 go(e){const t=e?parseFloat(e):NaN;return Number.isNaN(t)?0:t}function co(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 No=Ae(class extends Xn{constructor(e){if(super(e),this._virtualizer=null,this._first=0,this._last=-1,this._renderItem=(e,t)=>((e,t)=>_`${t}: ${JSON.stringify(e,null,2)}`)(e,t+this._first),this._keyFunction=(e,t)=>(e=>e)(e,this._first),this._items=[],e.type!==ye)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 Kn(t,this._keyFunction,this._renderItem)}update(e,[t]){this._setFunctions(t);const i=this._items!==t.items;return this._items=t.items||[],this._virtualizer?this._updateVirtualizerConfig(e,t):this._initialize(e,t),i?R:this.render()}async _updateVirtualizerConfig(e,t){if(!await this._virtualizer.updateLayoutConfig(t.layout||{})){const i=e.parentNode;this._makeVirtualizer(i,t)}this._virtualizer.items=this._items}_setFunctions(e){const{renderItem:t,keyFunction:i}=e;t&&(this._renderItem=(e,i)=>t(e,i+this._first)),i&&(this._keyFunction=(e,t)=>i(e,t+this._first))}_makeVirtualizer(e,t){this._virtualizer&&this._virtualizer.disconnected();const{layout:i,scroller:n,items:o}=t;this._virtualizer=new lo({hostElement:e,layout:i,scroller:n}),this._virtualizer.items=o,this._virtualizer.connected()}_initialize(e,t){const i=e.parentNode;i&&1===i.nodeType&&(i.addEventListener("rangeChanged",(e=>{this._first=e.first,this._last=e.last,this.setValue(this.render())})),this._makeVirtualizer(i,t))}disconnected(){this._virtualizer?.disconnected()}reconnected(){this._virtualizer?.connected()}});class uo{static getVirtualizedContent(e,t,i,n,o,M,r,s,a,l,g,c,N,u,D,d){return _`
|
|
5749
|
+
*/(this._hostElement,e),this._scrollerController=new oo(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(`[${so}]`);t||(t=document.createElement("div"),t.setAttribute(so,""),e.appendChild(t)),Object.assign(t.style,{position:"absolute",margin:"-2px 0 0 0",padding:0,visibility:"hidden",fontSize:"2px"}),t.textContent=" ",t.setAttribute(so,""),this._sizer=t}return this._sizer}async updateLayoutConfig(e){await this._layoutInitialized;const t=e.type||ao;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,i;if("function"==typeof e.type){i=e.type;const n={...e};delete n.type,t=n}else t=e;void 0===i&&(ao=i=(await Promise.resolve().then((function(){return sQ}))).FlowLayout),this._layout=new i((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,i=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:i}}return null}_measureChildren(){const e={},t=this._children,i=this._measureChildOverride||this._measureChild;for(let n=0;n<t.length;n++){const o=t[n],M=this._first+n;(this._itemsChanged||this._toBeMeasured.has(o))&&(e[M]=i.call(this,o,this._items[M]))}this._childMeasurements=e,this._schedule(this._updateLayout),this._toBeMeasured.clear()}_measureChild(e){const{width:t,height:i}=e.getBoundingClientRect();return Object.assign({width:t,height:i},function(e){const t=window.getComputedStyle(e);return{marginTop:go(t.marginTop),marginRight:go(t.marginRight),marginBottom:go(t.marginBottom),marginLeft:go(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:i}=this;this._visibilityChanged&&(this._notifyVisibility(),this._visibilityChanged=!1),(t||i)&&(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 io)}get _children(){const e=[];let t=this._hostElement.firstElementChild;for(;t;)t.hasAttribute(so)||e.push(t),t=t.nextElementSibling;return e}_updateView(){const e=this._hostElement,t=this._scrollerController?.element,i=this._layout;if(e&&t&&i){let n,o,M,r;const s=e.getBoundingClientRect();n=0,o=0,M=window.innerHeight,r=window.innerWidth;const a=this._clippingAncestors.map((e=>e.getBoundingClientRect()));a.unshift(s);for(const e of a)n=Math.max(n,e.top),o=Math.max(o,e.left),M=Math.min(M,e.bottom),r=Math.min(r,e.right);const l=t.getBoundingClientRect(),g={left:s.left-l.left,top:s.top-l.top},c={width:t.scrollWidth,height:t.scrollHeight},N=n-s.top+e.scrollTop,u=o-s.left+e.scrollLeft,D=Math.max(0,M-n),d=Math.max(0,r-o);i.viewportSize={width:d,height:D},i.viewportScroll={top:N,left:u},i.totalScrollSize=c,i.offsetWithinScroller=g}}_sizeHostElement(e){const t=82e5,i=e&&null!==e.width?Math.min(t,e.width):0,n=e&&null!==e.height?Math.min(t,e.height):0;if(this._isScroller)this._getSizer().style.transform=`translate(${i}px, ${n}px)`;else{const e=this._hostElement.style;e.minWidth=i?`${i}px`:"100%",e.minHeight=n?`${n}px`:"100%"}}_positionChildren(e){e&&e.forEach((({top:e,left:t,width:i,height:n,xOffset:o,yOffset:M},r)=>{const s=this._children[r-this._first];s&&(s.style.position="absolute",s.style.boxSizing="border-box",s.style.transform=`translate(${t}px, ${e}px)`,void 0!==i&&(s.style.width=i+"px"),void 0!==n&&(s.style.height=n+"px"),s.style.left=void 0===o?null:o+"px",s.style.top=void 0===M?null:M+"px")}))}async _adjustRange(e){const{_first:t,_last:i,_firstVisible:n,_lastVisible:o}=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!==i,this._visibilityChanged=this._visibilityChanged||this._firstVisible!==n||this._lastVisible!==o}_correctScrollError(){if(this._scrollError){const{scrollTop:e,scrollLeft:t}=this._scrollerController,{top:i,left:n}=this._scrollError;this._scrollError=null,this._scrollerController.correctScrollError({top:e-i,left:t-n})}}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:i}=e;this._updateScrollIntoViewCoordinates=this._scrollerController.managedScrollTo(Object.assign(t,{behavior:i}),(()=>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 eo({first:this._first,last:this._last}))}_notifyVisibility(){this._hostElement.dispatchEvent(new to({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 go(e){const t=e?parseFloat(e):NaN;return Number.isNaN(t)?0:t}function co(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 No=Ae(class extends Xn{constructor(e){if(super(e),this._virtualizer=null,this._first=0,this._last=-1,this._renderItem=(e,t)=>((e,t)=>_`${t}: ${JSON.stringify(e,null,2)}`)(e,t+this._first),this._keyFunction=(e,t)=>(e=>e)(e,this._first),this._items=[],e.type!==ye)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 Kn(t,this._keyFunction,this._renderItem)}update(e,[t]){this._setFunctions(t);const i=this._items!==t.items;return this._items=t.items||[],this._virtualizer?this._updateVirtualizerConfig(e,t):this._initialize(e,t),i?R:this.render()}async _updateVirtualizerConfig(e,t){if(!await this._virtualizer.updateLayoutConfig(t.layout||{})){const i=e.parentNode;this._makeVirtualizer(i,t)}this._virtualizer.items=this._items}_setFunctions(e){const{renderItem:t,keyFunction:i}=e;t&&(this._renderItem=(e,i)=>t(e,i+this._first)),i&&(this._keyFunction=(e,t)=>i(e,t+this._first))}_makeVirtualizer(e,t){this._virtualizer&&this._virtualizer.disconnected();const{layout:i,scroller:n,items:o}=t;this._virtualizer=new lo({hostElement:e,layout:i,scroller:n}),this._virtualizer.items=o,this._virtualizer.connected()}_initialize(e,t){const i=e.parentNode;i&&1===i.nodeType&&(i.addEventListener("rangeChanged",(e=>{this._first=e.first,this._last=e.last,this.setValue(this.render())})),this._makeVirtualizer(i,t))}disconnected(){this._virtualizer?.disconnected()}reconnected(){this._virtualizer?.connected()}});class uo{static getVirtualizedContent(e,t,i,n,o,M,r,s,a,l,g,c,N,u,D,d,h,j){return _`
|
|
5740
5750
|
<div part="select-options" class="select__options ${t?"select__options__search-enabled":""} ${N?"loading":""}">
|
|
5741
5751
|
${g&&!N?_`
|
|
5742
5752
|
<div part="select-no-results" class="select__no-results">
|
|
@@ -5749,27 +5759,29 @@ class no{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
5749
5759
|
@scroll=${u}
|
|
5750
5760
|
>
|
|
5751
5761
|
${uo.shouldUseVirtualizer(e)?_`
|
|
5752
|
-
${No({items:e,renderItem:e=>uo.getItemRenderFunction(e,i,n,o,M,r,s,a,l,D,d),scroller:!0})}
|
|
5762
|
+
${No({items:e,renderItem:e=>uo.getItemRenderFunction(e,i,n,o,M,r,s,a,l,D,d,h,j),scroller:!0})}
|
|
5753
5763
|
`:_`
|
|
5754
|
-
${e.map((e=>uo.getItemRenderFunction(e,i,n,o,M,r,s,a,l,D,d)))}
|
|
5764
|
+
${e.map((e=>uo.getItemRenderFunction(e,i,n,o,M,r,s,a,l,D,d,h,j)))}
|
|
5755
5765
|
`}
|
|
5756
5766
|
</div>
|
|
5757
5767
|
`}
|
|
5758
|
-
</div>`}static getItemRenderFunction(e,t,i,n,o,M,r,s,a,l,g){if(!e)return _``;const
|
|
5768
|
+
</div>`}static getItemRenderFunction(e,t,i,n,o,M,r,s,a,l,g,c,N){if(!e)return _``;const u=o||t,D=M||(e=>e?.value||e),d=D(e),h=u(e),j=e?.disabled||!1,I=e?.className,z=(r?r(e):e?.description)??"",y=(s?s(e):e?.prefix)??"",p=(a?a(e):e?.suffix)??"";let T=!1;return T=n?Array.isArray(i)&&i.some((e=>String(e)===String(d))):(Array.isArray(i)?i[0]:i)===d,_`
|
|
5759
5769
|
<nile-option
|
|
5760
|
-
value=${
|
|
5761
|
-
.selected=${
|
|
5762
|
-
.disabled=${
|
|
5770
|
+
value=${d}
|
|
5771
|
+
.selected=${T}
|
|
5772
|
+
.disabled=${j}
|
|
5763
5773
|
.showCheckbox=${n}
|
|
5764
|
-
|
|
5765
|
-
.
|
|
5774
|
+
.tickOnSelect=${c??!1}
|
|
5775
|
+
.legacy=${N??!1}
|
|
5776
|
+
class=${Oe({option:g??!1,[I??""]:!!I})}
|
|
5777
|
+
.description=${z}
|
|
5766
5778
|
.isDescriptionEnabled=${g}
|
|
5767
5779
|
>
|
|
5768
|
-
${me(
|
|
5769
|
-
${l?me(
|
|
5770
|
-
${me(
|
|
5780
|
+
${me(y)}
|
|
5781
|
+
${l?me(h):h}
|
|
5782
|
+
${me(p)}
|
|
5771
5783
|
</nile-option>
|
|
5772
|
-
`}static shouldUseVirtualizer(e){return e.length>=5}}let Do=class{static calculateAvailableSpace(e){const t=e.getBoundingClientRect(),i=window.innerHeight,n=i-t.bottom;return{spaceAbove:t.top,spaceBelow:n,viewportHeight:i}}static getOptimalPlacement(e){const{spaceAbove:t,spaceBelow:i}=this.calculateAvailableSpace(e);return i<200&&t>i?"top":"bottom"}static findBoundaryElements(e){const t=[];let i=e.parentElement;for(;i&&i!==document.body;){const e=window.getComputedStyle(i),n=e.overflow,o=e.overflowY,M=e.overflowX;"auto"!==n&&"scroll"!==n&&"auto"!==o&&"scroll"!==o&&"auto"!==M&&"scroll"!==M||t.push(i),(i.hasAttribute("data-floating-boundary")||i.classList.contains("floating-boundary")||i.classList.contains("scroll-container"))&&t.push(i),i=i.parentElement}return t.length>0?t:void 0}static calculateOptimalHeight(e,t,i){const n=t-(e.y+e.height),o=e.y;return o>n?Math.max(o-20,100):n>o?Math.max(n-20,100):Math.max(Math.min(o,n)-20,100)}static extractStylesAsCSS(e){return"string"==typeof e?e:Array.isArray(e)?e.map((e=>this.extractStylesAsCSS(e))).join("\n"):e&&"object"==typeof e&&e.cssText?e.cssText:""}static generateStyleId(){return`nile-select-styles-${Math.random().toString(36).substring(2,11)}`}static isPositioningOptimal(e,t){const{spaceAbove:i,spaceBelow:n}=this.calculateAvailableSpace(t),o=e.startsWith("top"),M=e.startsWith("bottom");return!(o&&n>i)&&!(M&&i>n)}static applyCollisionData(e,t,i){if(t.flip){const{overflows:n}=t.flip;if(e.setAttribute("data-placement",i),n&&n.length>0){const t=n.map((e=>e.placement)).join(",");e.setAttribute("data-overflow",t)}else e.removeAttribute("data-overflow")}if(t.shift){const{x:i,y:n}=t.shift;void 0===i||void 0===n||0===i&&0===n?e.removeAttribute("data-shift"):e.setAttribute("data-shift",`${i},${n}`)}if(t.size){const{availableWidth:i,availableHeight:n}=t.size;void 0!==i&&e.setAttribute("data-available-width",i.toString()),void 0!==n&&e.setAttribute("data-available-height",n.toString())}}static createFloatingUIMiddleware(e,t){return[]}},ho=class{static createBaseListbox(e){const t=document.createElement("div");return t.className="select__listbox "+(e.searchEnabled?"select__search-enabled ":""),t.setAttribute("tabindex","-1"),t}static addSearchSection(e,t){if(!t.searchEnabled)return;const i=document.createElement("div");i.className="select__search",i.innerHTML=`\n <nile-input size="small" clearable value="${t.searchValue}" placeholder="${t.internalSearchPlaceHolder}">\n <nile-icon name="var(--nile-icon-search, var(--ng-icon-search-lg))" method="var(--nile-svg-method-fill, var(--ng-svg-method-stroke))" slot="suffix"></nile-icon>\n </nile-input>\n `,e.appendChild(i)}static addLoadingSection(e,t){if(!t.optionsLoading)return;const i=document.createElement("span");i.className="select__loader",i.innerHTML='\n <nile-icon class="select__loader--icon" name="var(--nile-icon-button-loading-blue, var(--ng-icon-button-loading-blue))" method="var(--nile-svg-method-fill, var(--ng-svg-method-stroke))"></nile-icon>\n ',e.appendChild(i)}static addOptionsSection(e,t){const i=document.createElement("div");i.className="select__options "+(t.searchEnabled?"select__options__search-enabled":""),this.addNoResultsMessage(i,t),this.addClonedOptions(i,t),e.appendChild(i)}static addNoResultsMessage(e,t){if(!t.showNoResults)return;const i=document.createElement("div");i.className="select__no-results",i.textContent=t.noResultsMessage,e.appendChild(i)}static addClonedOptions(e,t){Array.from(t.querySelectorAll("nile-option")).forEach((t=>{const i=this.cloneOption(t);e.appendChild(i)}))}static cloneOption(e){const t=e.cloneNode(!0);return Array.from(e.attributes).forEach((e=>{t.setAttribute(e.name,e.value)})),this.copyOptionProperties(e,t),t}static copyOptionProperties(e,t){["selected","disabled","current","hidden"].forEach((i=>{void 0!==e[i]&&(t[i]=e[i])}))}static addFooterSection(e,t){const i=t.querySelectorAll('[slot="pre-footer"]').length>0,n=t.multiple;if(!i&&!n)return;const o=document.createElement("div");if(o.setAttribute("part","footer-area"),o.className="select__footer-area",i&&this.addCustomFooter(o,t),n){const e=this.createFooter(t);o.appendChild(e)}e.appendChild(o)}static addCustomFooter(e,t){const i=Array.from(t.querySelectorAll('[slot="pre-footer"]'));if(0===i.length)return;const n=document.createElement("div");n.className="select__custom-footer",n.setAttribute("part","custom-footer"),i.forEach((e=>{n.appendChild(e.cloneNode(!0))})),n.addEventListener("click",(()=>t.hide())),e.appendChild(n)}static createFooter(e){const t=document.createElement("div");return t.setAttribute("part","footer"),t.className="select__footer",this.addShowSelectedToggle(t,e),this.addClearAllButton(t,e),t}static addShowSelectedToggle(e,t){const i=document.createElement("span");i.style.cursor="pointer";const n=document.createElement("nile-checkbox");n.disabled=0===t.selectedOptions.length,n.checked=t.showSelected,n.innerHTML=" Show Selected",i.appendChild(n),e.appendChild(i)}static addClearAllButton(e,t){if(0===t.selectedOptions.length)return;const i=document.createElement("span");i.className="select__clear",i.textContent="Clear All",i.style.cursor="pointer",e.appendChild(i)}static updateClonedOptions(e,t){const i=e.querySelector(".select__options");if(!i)return;const n=Array.from(t.querySelectorAll("nile-option")),o=Array.from(i.querySelectorAll("nile-option"));n.forEach(((e,t)=>{const i=o[t];i&&this.updateClonedOption(e,i)}))}static updateClonedOption(e,t){t.selected=e.selected,t.disabled=e.disabled,t.current=e.current,t.hidden=e.hidden,this.updateClonedOptionAttributes(e,t)}static updateClonedOptionAttributes(e,t){[{prop:"selected",attr:"selected"},{prop:"disabled",attr:"disabled"},{prop:"current",attr:"current"},{prop:"hidden",attr:"hidden"}].forEach((({prop:i,attr:n})=>{e[i]?t.setAttribute(n,""):t.removeAttribute(n)}))}static createPortalListbox(e){const t=this.createBaseListbox(e);return this.addSearchSection(t,e),this.addLoadingSection(t,e),this.addOptionsSection(t,e),this.addFooterSection(t,e),t}},jo=class{static setupPortalEventListeners(e,t){e&&(this.setupOptionClickListeners(e,t),this.setupScrollListeners(e,t),this.setupSearchListeners(e,t),this.setupFooterListeners(e,t),this.setupSlotListeners(e,t))}static setupOptionClickListeners(e,t){e&&e.addEventListener("mouseup",(e=>{const i=e.target.closest("nile-option");i&&this.handleOptionClick(i,t)}))}static handleOptionClick(e,t){const i=t.querySelector(`nile-option[value="${e.getAttribute("value")}"]`);if(i){const e=new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,view:window});Object.defineProperty(e,"target",{value:i,writable:!1}),t.handleOptionClick&&t.handleOptionClick(e)}}static setupScrollListeners(e,t){e&&e.addEventListener("scroll",(e=>{t.handleScroll&&t.handleScroll(e)}))}static setupSearchListeners(e,t){if(!e)return;const i=e.querySelector("nile-input");i&&(i.addEventListener("nile-input",(e=>{t.handleSearchChange&&t.handleSearchChange(e)})),i.addEventListener("nile-focus",(e=>{t.handleSearchFocus&&t.handleSearchFocus()})),i.addEventListener("nile-blur",(e=>{t.handleSearchBlur&&t.handleSearchBlur()})))}static setupFooterListeners(e,t){if(!e)return;const i=e.querySelector(".select__footer");i&&(this.setupFooterClickHandlers(i),this.setupShowSelectedToggle(i,t),this.setupClearAllHandler(i,t)),this.setupCustomFooterListeners(e,t)}static setupCustomFooterListeners(e,t){const i=e.querySelector(".select__custom-footer");i&&i.addEventListener("click",(e=>{e.stopPropagation()}))}static setupFooterClickHandlers(e){e.addEventListener("click",(e=>{e.stopPropagation(),e.preventDefault()}))}static setupShowSelectedToggle(e,t){const i=e.querySelector('span[style*="cursor: pointer"]');i&&i.addEventListener("click",(e=>{e.stopPropagation(),e.preventDefault(),t.toggleShowSelected&&t.toggleShowSelected(e)}))}static setupClearAllHandler(e,t){e.addEventListener("click",(e=>{e.target.classList.contains("select__clear")&&(e.stopPropagation(),e.preventDefault(),t.unSlectAll&&t.unSlectAll())}))}static setupSlotListeners(e,t){if(!e)return;const i=e.querySelector("slot");i&&i.addEventListener("slotchange",(()=>{t.updatePortalContent&&t.updatePortalContent()}))}},Io=class{constructor(e){this.portalContainer=null,this.originalListboxParent=null,this.measuredPopupHeight=null,this.cleanupAutoUpdate=null,this.currentPlacement="bottom",this.currentMiddlewareData=null,this.component=e}createPortalAppendContainer(){const e=document.createElement("div");return e.style.position="absolute",e.style.zIndex="9999",e.style.pointerEvents="none",e.className="nile-virtual-select-portal-append",e}positionPortalAppend(){this.portalContainer&&this.component.popup&&(this.measurePopupHeight(),this.computeFloatingUIPosition())}measurePopupHeight(){!this.measuredPopupHeight&&this.portalContainer&&(this.portalContainer.style.position="absolute",this.portalContainer.style.visibility="hidden",this.portalContainer.style.top="0px",this.portalContainer.style.left="0px",this.portalContainer.offsetHeight,this.measuredPopupHeight=this.portalContainer.offsetHeight,this.portalContainer.style.visibility="")}async computeFloatingUIPosition(){if(!this.portalContainer)return;const e=this.component.combobox||this.component,t=this.portalContainer;try{const{x:i,y:n,placement:o,middlewareData:M}=await this.calculateFloatingUIPosition(e,t);this.applyFloatingUIPosition(t,e,i,n,o,M)}catch(e){console.warn("Floating UI positioning failed, falling back to simple positioning:",e),this.fallbackPositioning()}}async calculateFloatingUIPosition(e,t){const i=Do.findBoundaryElements(e),n=Do.getOptimalPlacement(e),o=this.createFloatingUIMiddleware(i);return await pn(e,t,{placement:n,strategy:"fixed",middleware:o,platform:this.createCustomPlatform()})}createFloatingUIMiddleware(e){return[hn(4),zn({apply:this.handleSizeMiddleware.bind(this),padding:10,boundary:e}),In({fallbackPlacements:["bottom","top","bottom-start","top-start","bottom-end","top-end"],fallbackStrategy:"bestFit",padding:10,boundary:e}),jn({padding:10,crossAxis:!0,boundary:e})]}handleSizeMiddleware({availableWidth:e,availableHeight:t,elements:i,rects:n}){const o=Do.calculateOptimalHeight(n.reference,window.innerHeight,this.currentPlacement);i.floating.style.maxWidth=`${e}px`,i.floating.style.maxHeight=`${o}px`,i.floating.style.setProperty("--auto-size-available-width",`${e}px`),i.floating.style.setProperty("--auto-size-available-height",`${o}px`)}createCustomPlatform(){return un}applyFloatingUIPosition(e,t,i,n,o,M){Object.assign(e.style,{left:`${i}px`,top:`${n}px`,position:"fixed",pointerEvents:"auto"}),this.currentPlacement=o,this.currentMiddlewareData=M,Do.applyCollisionData(e,M,o);const r=o.split("-")[0];e.className=`nile-virtual-select-portal-append select__listbox--${r}`;const s=t.getBoundingClientRect();e.style.width=`${s.width}px`}fallbackPositioning(){if(!this.portalContainer)return;const e=(this.component.combobox||this.component).getBoundingClientRect(),t=window.innerHeight;this.measuredPopupHeight;const i=t-e.bottom,n=e.top;let o,M,r;n>i?(r=Math.max(n-20,100),o=Math.max(e.top-r-4,10),M="top"):(r=Math.max(i-20,100),o=e.bottom+4,M="bottom"),this.portalContainer.style.left=`${e.left}px`,this.portalContainer.style.top=`${o}px`,this.portalContainer.style.width=`${e.width}px`,this.portalContainer.style.maxHeight=`${r}px`,this.portalContainer.style.pointerEvents="auto",this.portalContainer.className=`nile-virtual-select-portal-append select__listbox--${M}`,this.calculateAndSetAutoSizeProperties(e,o,M)}calculateAndSetAutoSizeProperties(e,t,i){if(!this.portalContainer)return;const n=window.innerHeight,o=window.innerWidth;let M;M="top"===i?e.top-10:n-e.bottom-10;const r=Math.min(e.width,o-e.left-10);this.portalContainer.style.setProperty("--auto-size-available-height",`${Math.max(M,100)}px`),this.portalContainer.style.setProperty("--auto-size-available-width",`${Math.max(r,200)}px`)}updatePortalAppendPosition(){this.component.portal&&this.portalContainer&&this.positionPortalAppend()}handleWindowResize(){this.component.portal&&this.portalContainer&&this.positionPortalAppend()}setupAutoUpdatePositioning(){this.portalContainer&&this.component&&(this.cleanupAutoUpdatePositioning(),this.cleanupAutoUpdate=dn(this.component,this.portalContainer,(()=>{this.computeFloatingUIPosition()}),{ancestorScroll:!0,ancestorResize:!0,elementResize:!0,layoutShift:!0,animationFrame:!0}))}cleanupAutoUpdatePositioning(){this.cleanupAutoUpdate&&(this.cleanupAutoUpdate(),this.cleanupAutoUpdate=null)}extractStylesAsCSS(e){return"string"==typeof e?e:Array.isArray(e)?e.map((e=>this.extractStylesAsCSS(e))).join("\n"):e&&"object"==typeof e&&e.cssText?e.cssText:""}injectStylesToDocument(){if(!this.portalContainer)return;const e=`nile-virtual-select-styles-${Math.random().toString(36).substring(2,11)}`;if(document.getElementById(e))return;const t=this.component.constructor.styles;if(!t)return;const i=document.createElement("style");i.id=e,i.textContent=this.extractStylesAsCSS(t),document.head.appendChild(i),this.portalContainer.__injectedStyleId=e}adoptStylesToPortalAppend(){this.portalContainer&&this.injectStylesToDocument()}setupPortalAppend(){this.component.portal&&this.component.updateComplete.then((()=>{const e=this.component.shadowRoot?.querySelector("#listbox");e&&(this.originalListboxParent=e.parentElement,this.portalContainer=this.createPortalAppendContainer(),this.portalContainer.appendChild(e),document.body.appendChild(this.portalContainer),this.adoptStylesToPortalAppend(),e.style.display="",this.positionPortalAppend(),this.setupAutoUpdatePositioning(),window.addEventListener("resize",this.handleWindowResize.bind(this)))}))}cleanupPortalAppend(){if(this.cleanupAutoUpdatePositioning(),this.portalContainer&&this.portalContainer.parentNode){const e=this.portalContainer.querySelector("#listbox");e&&this.originalListboxParent&&(this.originalListboxParent.appendChild(e),e.style.display=this.component.portal?"none":"");const t=this.portalContainer.__injectedStyleId;if(t){const e=document.getElementById(t);e&&e.remove()}this.portalContainer.parentNode.removeChild(this.portalContainer)}window.removeEventListener("resize",this.handleWindowResize.bind(this)),this.portalContainer=null,this.originalListboxParent=null,this.measuredPopupHeight=null,this.currentPlacement="bottom",this.currentMiddlewareData=null}async resetScrollPosition(){await this.component.updateComplete,requestAnimationFrame((()=>{let e=null;if(e=this.component.portal&&this.portalContainer?this.portalContainer.querySelector("#listbox"):this.component.shadowRoot?.querySelector("#listbox"),!e||!e.isConnected)return;e.scrollTop=0;const t=e.querySelector(".virtualized");if(t&&t.isConnected){this.component.data?.length<5?(t.style.overflowY="hidden",t.style.maxHeight="none",e.style.overflowY="hidden",e.style.maxHeight="fit-content"):(t.style.overflowY="auto",t.style.maxHeight="",e.style.overflowY="auto",e.style.maxHeight=""),t.scrollTop=0}const i=e.querySelector("lit-virtualizer");i&&i.isConnected&&(i.scrollTop=0)}))}get portalContainerElement(){return this.portalContainer}resetMeasuredHeight(){this.measuredPopupHeight=null}forceReposition(){this.portalContainer&&this.computeFloatingUIPosition()}getCurrentPlacement(){return this.currentPlacement}getCurrentMiddlewareData(){return this.currentMiddlewareData}isUsingFloatingUI(){return null!==this.cleanupAutoUpdate}handleViewportChange(){this.portalContainer&&(this.resetMeasuredHeight(),this.forceReposition())}isPositioningOptimal(){if(!this.portalContainer||!this.currentMiddlewareData)return!0;const e=(this.component.combobox||this.component).getBoundingClientRect(),t=window.innerHeight-e.bottom,i=e.top,n=this.currentPlacement.startsWith("top"),o=this.currentPlacement.startsWith("bottom");return!(n&&t>i)&&!(o&&i>t)}},zo=class{constructor(e,{target:t,config:i,callback:n,skipInitial:o}){this.t=new Set,this.o=!1,this.i=!1,this.h=e,null!==t&&this.t.add(t??e),this.l=i,this.o=o??this.o,this.callback=n,window.ResizeObserver?(this.u=new ResizeObserver((e=>{this.handleChanges(e),this.h.requestUpdate()})),e.addController(this)):console.warn("ResizeController error: browser does not support ResizeObserver.")}handleChanges(e){this.value=this.callback?.(e,this.u)}hostConnected(){for(const e of this.t)this.observe(e)}hostDisconnected(){this.disconnect()}async hostUpdated(){!this.o&&this.i&&this.handleChanges([]),this.i=!1}observe(e){this.t.add(e),this.u.observe(e,this.l),this.i=!0,this.h.requestUpdate()}unobserve(e){this.t.delete(e),this.u.unobserve(e)}disconnect(){this.u.disconnect()}target(e){return yo(this,e)}};const yo=Ae(class extends Xn{constructor(){super(...arguments),this.observing=!1}render(e,t){}update(e,[t,i]){this.controller=t,this.part=e,this.observe=i,!1===i?(t.unobserve(e.element),this.observing=!1):!1===this.observing&&(t.observe(e.element),this.observing=!0)}disconnected(){this.controller?.unobserve(this.part.element),this.observing=!1}reconnected(){!1!==this.observe&&!1===this.observing&&(this.controller?.observe(this.part.element),this.observing=!0)}});let po=class extends Fe{constructor(){super(...arguments),this.formControlController=new Ue(this,{assumeInteractionOn:["nile-blur","nile-input"]}),this.hasSlotController=new Ze(this,"help-text","label"),this.portalManager=new Io(this),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.autoResize=!1,this.searchValue="",this.searchEnabled=!1,this.enableVisibilityEffect=!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.portal=!1,this.maxOptionsVisible=3,this.oldMaxOptionsVisible=1,this.enableTabClose=!1,this.descriptionSearchEnabled=!1,this.allowHtmlLabel=!0,this.enableDescription=!1,this.showListbox=!1,this.wasShowSelectedCheckedOnClose=!1,this.handleDocumentMouseDown=e=>{if(!this.open)return;const t=e.composedPath(),i=t.includes(this),n=this.popup&&t.includes(this.popup),o=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);i||n||o||this.hide()},this.handleWindowError=e=>{(e.error?.message||e.message||"").includes("Cannot read properties of null (reading 'insertBefore')")&&e.preventDefault()},this.handleWindowResize=()=>{this.portalManager.updatePortalAppendPosition()},this.handleWindowScroll=()=>{this.portalManager.updatePortalAppendPosition()},this.resizeController=new zo(this,{callback:e=>{for(const t of e)t.target.classList.contains("select__tags")&&this.calculateTotalWidthOfTags()}})}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.visibilityManager?.cleanup(),this.scrollTimeout&&(clearTimeout(this.scrollTimeout),this.scrollTimeout=void 0),this.portalManager.cleanupPortalAppend()}updated(e){if(e.has("value")&&this.selectionChanged(),e.has("autoResize")){const e=this.shadowRoot?.querySelector(".select__tags");this.autoResize&&e?this.resizeController.observe(e):e&&this.resizeController.unobserve(e)}}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}getItemDescription(e){return this.renderItemConfig?.getDescription?this.renderItemConfig.getDescription(e):e?.description||e||""}getItemPrefix(e){return this.renderItemConfig?.getPrefix?this.renderItemConfig.getPrefix(e):e?.prefix||e||""}getItemSuffix(e){return this.renderItemConfig?.getSuffix?this.renderItemConfig.getSuffix(e):e?.suffix||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),this.handleWindowResize=this.handleWindowResize.bind(this),this.handleWindowScroll=this.handleWindowScroll.bind(this)}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown),window.addEventListener("error",this.handleWindowError),this.portal&&(window.addEventListener("resize",this.handleWindowResize),window.addEventListener("scroll",this.handleWindowScroll,!0))}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown),window.removeEventListener("error",this.handleWindowError),window.removeEventListener("resize",this.handleWindowResize),window.removeEventListener("scroll",this.handleWindowScroll,!0)}handleFocus(){this.hasFocus=!0,this.emit("nile-focus")}handleBlur(){this.hasFocus=!1,this.emit("nile-blur")}firstUpdated(e){this.visibilityManager=new mn({host:this,target:this.combobox,enableVisibilityEffect:this.enableVisibilityEffect,enableTabClose:this.enableTabClose,isOpen:()=>this.open,onAnchorOutOfView:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"anchor-out-of-view",name:this.name})},onDocumentHidden:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"document-hidden",name:this.name})},emit:(e,t)=>this.emit(`nile-${e}`,t)})}handleDocumentFocusIn(e){if(!this.open)return;const t=e.composedPath(),i=t.includes(this),n=this.popup&&t.includes(this.popup),o=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);i||n||o||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,i=null!==t.closest(".select__clear"),n=null!==t.closest("nile-icon-button");return i||n}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){this.searchValue="";const e=Array.isArray(this.value)?this.value:[this.value];this.data=this.originalOptionItems.filter((t=>{const i=this.getItemValue(t);return e.some((e=>String(e)===String(i)))}))}else this.data=[...this.originalOptionItems];this.portalManager.resetMeasuredHeight(),this.requestUpdate(),this.repaintOptionsContainer()}}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 i=this.value;this.oldValue=i,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 i=t.filter((t=>t!==e.value));this.value=i,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=_n.createVirtualOptionsFromValues(this.value,e,this.getDisplayText.bind(this),this.renderItemConfig?.getValue,this.allowHtmlLabel),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.originalOptionItems?.length>0&&!this.searchValue&&(this.data=[...this.originalOptionItems]),this.repaintOptionsContainer()),this.calculateTotalWidthOfTags()}handleSearchFocus(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleSearchBlur(){document.addEventListener("keydown",this.handleDocumentKeyDown)}handleSearchChange(e){this.searchValue=e.detail.value,this.portal&&this.portalManager.updatePortalAppendPosition(),this.emit("nile-search",{query:this.searchValue,name:this.name}),this.disableLocalSearch||(this.filterVirtualOptions(this.searchValue),this.repaintOptionsContainer(),this.portalManager.resetMeasuredHeight())}repaintOptionsContainer(){this.resetScrollPosition(),this.updateComplete.then((()=>{const e=this.shadowRoot?.querySelector(".virtualized");e&&(this.data.length<5?e.classList.add("no-scroll"):e.classList.remove("no-scroll"))}))}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.searchValue&&this.emit("nile-scroll-end",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name,isAtBottom:!0})}filterVirtualOptions(e){const t=Rn.filterVirtualOptions(e,this.originalOptionItems,this.data,this.getDisplayText.bind(this),this.getItemDescription.bind(this),this.descriptionSearchEnabled,this.renderItemConfig?.getSearchText);this.portal?(this.portalManager.updatePortalAppendPosition(),this.updateComplete.then((()=>{requestAnimationFrame((()=>{this.resetScrollPosition()}))}))):this.resetScrollPosition(),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(),this.portal&&this.portalManager.portalContainerElement&&this.portalManager.updatePortalAppendPosition()}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(),this.portalManager.resetMeasuredHeight(),this.portal&&this.portalManager.portalContainerElement&&this.portalManager.updatePortalAppendPosition()}handleRenderItemConfigChange(){this.value&&this.data.length>0&&(this.selectionChanged(),this.requestUpdate())}handleOptionsLoadingChange(){this.optionsLoading||0!==this.data.length||(this.showNoResults=!0),this.requestUpdate(),this.portal&&this.portalManager.portalContainerElement&&this.portalManager.updatePortalAppendPosition()}handlePortalAppendChange(){this.open&&(this.portal?this.portalManager.setupPortalAppend():this.portalManager.cleanupPortalAppend())}async handleOpenChange(){this.open&&!this.disabled?(this.visibilityManager?.setup(),this.showListbox=!0,await this.updateComplete,await this.handleOpen(),this.portal&&this.portalManager.setupPortalAppend()):(this.visibilityManager?.cleanup(),await this.handleClose(),this.showListbox=!1,this.portal&&this.portalManager.cleanupPortalAppend())}async handleOpen(){this.emit("nile-show",{value:this.value,name:this.name}),this.addOpenListeners(),this.showNoResults=!this.data?.length,await Yt(this),this.popup?.popup&&(this.popup.popup.style.visibility="hidden"),this.popup.active=!0,await new Promise((e=>requestAnimationFrame(e))),await new Promise((e=>requestAnimationFrame(e))),this.popup?.popup&&(this.popup.popup.style.visibility="");const{keyframes:e,options:t}=Rt(this,"select.show",{dir:"ltr"});await Qt(this.popup.popup,e,t),this.wasShowSelectedCheckedOnClose&&(this.showSelected=!1,this.data=[...this.originalOptionItems],this.wasShowSelectedCheckedOnClose=!1),this.filterVirtualOptions(""),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(),this.wasShowSelectedCheckedOnClose=this.showSelected,await Yt(this);const{keyframes:e,options:t}=Rt(this,"select.hide",{dir:"ltr"});await Qt(this.popup.popup,e,t),this.popup.active=!1,this.popup?.popup&&(this.popup.popup.style.visibility=""),this.searchValue="",this.portalManager.resetMeasuredHeight(),this.emit("nile-after-hide",{value:this.value,name:this.name})}async show(){if(!this.open&&!this.disabled)return this.open=!0,Jt(this,"nile-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,Jt(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"),i=this.hasSlotController.test("custom-select"),n=!!this.label||!!e,o=this.clearable&&!this.disabled&&this.value.length>0,M=!!this.placeholder&&0===this.value.length,r=!!this.helpText,s=!!this.errorMessage;return _`
|
|
5784
|
+
`}static shouldUseVirtualizer(e){return e.length>=5}}let Do=class{static calculateAvailableSpace(e){const t=e.getBoundingClientRect(),i=window.innerHeight,n=i-t.bottom;return{spaceAbove:t.top,spaceBelow:n,viewportHeight:i}}static getOptimalPlacement(e){const{spaceAbove:t,spaceBelow:i}=this.calculateAvailableSpace(e);return i<200&&t>i?"top":"bottom"}static findBoundaryElements(e){const t=[];let i=e.parentElement;for(;i&&i!==document.body;){const e=window.getComputedStyle(i),n=e.overflow,o=e.overflowY,M=e.overflowX;"auto"!==n&&"scroll"!==n&&"auto"!==o&&"scroll"!==o&&"auto"!==M&&"scroll"!==M||t.push(i),(i.hasAttribute("data-floating-boundary")||i.classList.contains("floating-boundary")||i.classList.contains("scroll-container"))&&t.push(i),i=i.parentElement}return t.length>0?t:void 0}static calculateOptimalHeight(e,t,i){const n=t-(e.y+e.height),o=e.y;return o>n?Math.max(o-20,100):n>o?Math.max(n-20,100):Math.max(Math.min(o,n)-20,100)}static extractStylesAsCSS(e){return"string"==typeof e?e:Array.isArray(e)?e.map((e=>this.extractStylesAsCSS(e))).join("\n"):e&&"object"==typeof e&&e.cssText?e.cssText:""}static generateStyleId(){return`nile-select-styles-${Math.random().toString(36).substring(2,11)}`}static isPositioningOptimal(e,t){const{spaceAbove:i,spaceBelow:n}=this.calculateAvailableSpace(t),o=e.startsWith("top"),M=e.startsWith("bottom");return!(o&&n>i)&&!(M&&i>n)}static applyCollisionData(e,t,i){if(t.flip){const{overflows:n}=t.flip;if(e.setAttribute("data-placement",i),n&&n.length>0){const t=n.map((e=>e.placement)).join(",");e.setAttribute("data-overflow",t)}else e.removeAttribute("data-overflow")}if(t.shift){const{x:i,y:n}=t.shift;void 0===i||void 0===n||0===i&&0===n?e.removeAttribute("data-shift"):e.setAttribute("data-shift",`${i},${n}`)}if(t.size){const{availableWidth:i,availableHeight:n}=t.size;void 0!==i&&e.setAttribute("data-available-width",i.toString()),void 0!==n&&e.setAttribute("data-available-height",n.toString())}}static createFloatingUIMiddleware(e,t){return[]}},ho=class{static createBaseListbox(e){const t=document.createElement("div");return t.className="select__listbox "+(e.searchEnabled?"select__search-enabled ":""),t.setAttribute("tabindex","-1"),t}static addSearchSection(e,t){if(!t.searchEnabled)return;const i=document.createElement("div");i.className="select__search",i.innerHTML=`\n <nile-input size="small" clearable value="${t.searchValue}" placeholder="${t.internalSearchPlaceHolder}">\n <nile-icon name="var(--nile-icon-search, var(--ng-icon-search-lg))" method="var(--nile-svg-method-fill, var(--ng-svg-method-stroke))" slot="suffix"></nile-icon>\n </nile-input>\n `,e.appendChild(i)}static addLoadingSection(e,t){if(!t.optionsLoading)return;const i=document.createElement("span");i.className="select__loader",i.innerHTML='\n <nile-icon class="select__loader--icon" name="var(--nile-icon-button-loading-blue, var(--ng-icon-button-loading-blue))" method="var(--nile-svg-method-fill, var(--ng-svg-method-stroke))"></nile-icon>\n ',e.appendChild(i)}static addOptionsSection(e,t){const i=document.createElement("div");i.className="select__options "+(t.searchEnabled?"select__options__search-enabled":""),this.addNoResultsMessage(i,t),this.addClonedOptions(i,t),e.appendChild(i)}static addNoResultsMessage(e,t){if(!t.showNoResults)return;const i=document.createElement("div");i.className="select__no-results",i.textContent=t.noResultsMessage,e.appendChild(i)}static addClonedOptions(e,t){Array.from(t.querySelectorAll("nile-option")).forEach((t=>{const i=this.cloneOption(t);e.appendChild(i)}))}static cloneOption(e){const t=e.cloneNode(!0);return Array.from(e.attributes).forEach((e=>{t.setAttribute(e.name,e.value)})),this.copyOptionProperties(e,t),t}static copyOptionProperties(e,t){["selected","disabled","current","hidden"].forEach((i=>{void 0!==e[i]&&(t[i]=e[i])}))}static addFooterSection(e,t){const i=t.querySelectorAll('[slot="pre-footer"]').length>0,n=t.multiple;if(!i&&!n)return;const o=document.createElement("div");if(o.setAttribute("part","footer-area"),o.className="select__footer-area",i&&this.addCustomFooter(o,t),n){const e=this.createFooter(t);o.appendChild(e)}e.appendChild(o)}static addCustomFooter(e,t){const i=Array.from(t.querySelectorAll('[slot="pre-footer"]'));if(0===i.length)return;const n=document.createElement("div");n.className="select__custom-footer",n.setAttribute("part","custom-footer"),i.forEach((e=>{n.appendChild(e.cloneNode(!0))})),n.addEventListener("click",(()=>t.hide())),e.appendChild(n)}static createFooter(e){const t=document.createElement("div");return t.setAttribute("part","footer"),t.className="select__footer",this.addShowSelectedToggle(t,e),this.addClearAllButton(t,e),t}static addShowSelectedToggle(e,t){const i=document.createElement("span");i.style.cursor="pointer";const n=document.createElement("nile-checkbox");n.disabled=0===t.selectedOptions.length,n.checked=t.showSelected,n.innerHTML=" Show Selected",i.appendChild(n),e.appendChild(i)}static addClearAllButton(e,t){if(0===t.selectedOptions.length)return;const i=document.createElement("span");i.className="select__clear",i.textContent="Clear All",i.style.cursor="pointer",e.appendChild(i)}static updateClonedOptions(e,t){const i=e.querySelector(".select__options");if(!i)return;const n=Array.from(t.querySelectorAll("nile-option")),o=Array.from(i.querySelectorAll("nile-option"));n.forEach(((e,t)=>{const i=o[t];i&&this.updateClonedOption(e,i)}))}static updateClonedOption(e,t){t.selected=e.selected,t.disabled=e.disabled,t.current=e.current,t.hidden=e.hidden,this.updateClonedOptionAttributes(e,t)}static updateClonedOptionAttributes(e,t){[{prop:"selected",attr:"selected"},{prop:"disabled",attr:"disabled"},{prop:"current",attr:"current"},{prop:"hidden",attr:"hidden"}].forEach((({prop:i,attr:n})=>{e[i]?t.setAttribute(n,""):t.removeAttribute(n)}))}static createPortalListbox(e){const t=this.createBaseListbox(e);return this.addSearchSection(t,e),this.addLoadingSection(t,e),this.addOptionsSection(t,e),this.addFooterSection(t,e),t}},jo=class{static setupPortalEventListeners(e,t){e&&(this.setupOptionClickListeners(e,t),this.setupScrollListeners(e,t),this.setupSearchListeners(e,t),this.setupFooterListeners(e,t),this.setupSlotListeners(e,t))}static setupOptionClickListeners(e,t){e&&e.addEventListener("mouseup",(e=>{const i=e.target.closest("nile-option");i&&this.handleOptionClick(i,t)}))}static handleOptionClick(e,t){const i=t.querySelector(`nile-option[value="${e.getAttribute("value")}"]`);if(i){const e=new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,view:window});Object.defineProperty(e,"target",{value:i,writable:!1}),t.handleOptionClick&&t.handleOptionClick(e)}}static setupScrollListeners(e,t){e&&e.addEventListener("scroll",(e=>{t.handleScroll&&t.handleScroll(e)}))}static setupSearchListeners(e,t){if(!e)return;const i=e.querySelector("nile-input");i&&(i.addEventListener("nile-input",(e=>{t.handleSearchChange&&t.handleSearchChange(e)})),i.addEventListener("nile-focus",(e=>{t.handleSearchFocus&&t.handleSearchFocus()})),i.addEventListener("nile-blur",(e=>{t.handleSearchBlur&&t.handleSearchBlur()})))}static setupFooterListeners(e,t){if(!e)return;const i=e.querySelector(".select__footer");i&&(this.setupFooterClickHandlers(i),this.setupShowSelectedToggle(i,t),this.setupClearAllHandler(i,t)),this.setupCustomFooterListeners(e,t)}static setupCustomFooterListeners(e,t){const i=e.querySelector(".select__custom-footer");i&&i.addEventListener("click",(e=>{e.stopPropagation()}))}static setupFooterClickHandlers(e){e.addEventListener("click",(e=>{e.stopPropagation(),e.preventDefault()}))}static setupShowSelectedToggle(e,t){const i=e.querySelector('span[style*="cursor: pointer"]');i&&i.addEventListener("click",(e=>{e.stopPropagation(),e.preventDefault(),t.toggleShowSelected&&t.toggleShowSelected(e)}))}static setupClearAllHandler(e,t){e.addEventListener("click",(e=>{e.target.classList.contains("select__clear")&&(e.stopPropagation(),e.preventDefault(),t.unSlectAll&&t.unSlectAll())}))}static setupSlotListeners(e,t){if(!e)return;const i=e.querySelector("slot");i&&i.addEventListener("slotchange",(()=>{t.updatePortalContent&&t.updatePortalContent()}))}},Io=class{constructor(e){this.portalContainer=null,this.originalListboxParent=null,this.measuredPopupHeight=null,this.cleanupAutoUpdate=null,this.currentPlacement="bottom",this.currentMiddlewareData=null,this.component=e}createPortalAppendContainer(){const e=document.createElement("div");return e.style.position="absolute",e.style.zIndex="9999",e.style.pointerEvents="none",e.className="nile-virtual-select-portal-append",e}positionPortalAppend(){this.portalContainer&&this.component.popup&&(this.measurePopupHeight(),this.computeFloatingUIPosition())}measurePopupHeight(){!this.measuredPopupHeight&&this.portalContainer&&(this.portalContainer.style.position="absolute",this.portalContainer.style.visibility="hidden",this.portalContainer.style.top="0px",this.portalContainer.style.left="0px",this.portalContainer.offsetHeight,this.measuredPopupHeight=this.portalContainer.offsetHeight,this.portalContainer.style.visibility="")}async computeFloatingUIPosition(){if(!this.portalContainer)return;const e=this.component.combobox||this.component,t=this.portalContainer;try{const{x:i,y:n,placement:o,middlewareData:M}=await this.calculateFloatingUIPosition(e,t);this.applyFloatingUIPosition(t,e,i,n,o,M)}catch(e){console.warn("Floating UI positioning failed, falling back to simple positioning:",e),this.fallbackPositioning()}}async calculateFloatingUIPosition(e,t){const i=Do.findBoundaryElements(e),n=Do.getOptimalPlacement(e),o=this.createFloatingUIMiddleware(i);return await pn(e,t,{placement:n,strategy:"fixed",middleware:o,platform:this.createCustomPlatform()})}createFloatingUIMiddleware(e){return[hn(4),zn({apply:this.handleSizeMiddleware.bind(this),padding:10,boundary:e}),In({fallbackPlacements:["bottom","top","bottom-start","top-start","bottom-end","top-end"],fallbackStrategy:"bestFit",padding:10,boundary:e}),jn({padding:10,crossAxis:!0,boundary:e})]}handleSizeMiddleware({availableWidth:e,availableHeight:t,elements:i,rects:n}){const o=Do.calculateOptimalHeight(n.reference,window.innerHeight,this.currentPlacement);i.floating.style.maxWidth=`${e}px`,i.floating.style.maxHeight=`${o}px`,i.floating.style.setProperty("--auto-size-available-width",`${e}px`),i.floating.style.setProperty("--auto-size-available-height",`${o}px`)}createCustomPlatform(){return un}applyFloatingUIPosition(e,t,i,n,o,M){Object.assign(e.style,{left:`${i}px`,top:`${n}px`,position:"fixed",pointerEvents:"auto"}),this.currentPlacement=o,this.currentMiddlewareData=M,Do.applyCollisionData(e,M,o);const r=o.split("-")[0];e.className=`nile-virtual-select-portal-append select__listbox--${r}`;const s=t.getBoundingClientRect();e.style.width=`${s.width}px`}fallbackPositioning(){if(!this.portalContainer)return;const e=(this.component.combobox||this.component).getBoundingClientRect(),t=window.innerHeight;this.measuredPopupHeight;const i=t-e.bottom,n=e.top;let o,M,r;n>i?(r=Math.max(n-20,100),o=Math.max(e.top-r-4,10),M="top"):(r=Math.max(i-20,100),o=e.bottom+4,M="bottom"),this.portalContainer.style.left=`${e.left}px`,this.portalContainer.style.top=`${o}px`,this.portalContainer.style.width=`${e.width}px`,this.portalContainer.style.maxHeight=`${r}px`,this.portalContainer.style.pointerEvents="auto",this.portalContainer.className=`nile-virtual-select-portal-append select__listbox--${M}`,this.calculateAndSetAutoSizeProperties(e,o,M)}calculateAndSetAutoSizeProperties(e,t,i){if(!this.portalContainer)return;const n=window.innerHeight,o=window.innerWidth;let M;M="top"===i?e.top-10:n-e.bottom-10;const r=Math.min(e.width,o-e.left-10);this.portalContainer.style.setProperty("--auto-size-available-height",`${Math.max(M,100)}px`),this.portalContainer.style.setProperty("--auto-size-available-width",`${Math.max(r,200)}px`)}updatePortalAppendPosition(){this.component.portal&&this.portalContainer&&this.positionPortalAppend()}handleWindowResize(){this.component.portal&&this.portalContainer&&this.positionPortalAppend()}setupAutoUpdatePositioning(){this.portalContainer&&this.component&&(this.cleanupAutoUpdatePositioning(),this.cleanupAutoUpdate=dn(this.component,this.portalContainer,(()=>{this.computeFloatingUIPosition()}),{ancestorScroll:!0,ancestorResize:!0,elementResize:!0,layoutShift:!0,animationFrame:!0}))}cleanupAutoUpdatePositioning(){this.cleanupAutoUpdate&&(this.cleanupAutoUpdate(),this.cleanupAutoUpdate=null)}extractStylesAsCSS(e){return"string"==typeof e?e:Array.isArray(e)?e.map((e=>this.extractStylesAsCSS(e))).join("\n"):e&&"object"==typeof e&&e.cssText?e.cssText:""}injectStylesToDocument(){if(!this.portalContainer)return;const e=`nile-virtual-select-styles-${Math.random().toString(36).substring(2,11)}`;if(document.getElementById(e))return;const t=this.component.constructor.styles;if(!t)return;const i=document.createElement("style");i.id=e,i.textContent=this.extractStylesAsCSS(t),document.head.appendChild(i),this.portalContainer.__injectedStyleId=e}adoptStylesToPortalAppend(){this.portalContainer&&this.injectStylesToDocument()}setupPortalAppend(){this.component.portal&&this.component.updateComplete.then((()=>{const e=this.component.shadowRoot?.querySelector("#listbox");e&&(this.originalListboxParent=e.parentElement,this.portalContainer=this.createPortalAppendContainer(),this.portalContainer.appendChild(e),document.body.appendChild(this.portalContainer),this.adoptStylesToPortalAppend(),e.style.display="",this.positionPortalAppend(),this.setupAutoUpdatePositioning(),window.addEventListener("resize",this.handleWindowResize.bind(this)))}))}cleanupPortalAppend(){if(this.cleanupAutoUpdatePositioning(),this.portalContainer&&this.portalContainer.parentNode){const e=this.portalContainer.querySelector("#listbox");e&&this.originalListboxParent&&(this.originalListboxParent.appendChild(e),e.style.display=this.component.portal?"none":"");const t=this.portalContainer.__injectedStyleId;if(t){const e=document.getElementById(t);e&&e.remove()}this.portalContainer.parentNode.removeChild(this.portalContainer)}window.removeEventListener("resize",this.handleWindowResize.bind(this)),this.portalContainer=null,this.originalListboxParent=null,this.measuredPopupHeight=null,this.currentPlacement="bottom",this.currentMiddlewareData=null}async resetScrollPosition(){await this.component.updateComplete,requestAnimationFrame((()=>{let e=null;if(e=this.component.portal&&this.portalContainer?this.portalContainer.querySelector("#listbox"):this.component.shadowRoot?.querySelector("#listbox"),!e||!e.isConnected)return;e.scrollTop=0;const t=e.querySelector(".virtualized");if(t&&t.isConnected){this.component.data?.length<5?(t.style.overflowY="hidden",t.style.maxHeight="none",e.style.overflowY="hidden",e.style.maxHeight="fit-content"):(t.style.overflowY="auto",t.style.maxHeight="",e.style.overflowY="auto",e.style.maxHeight=""),t.scrollTop=0}const i=e.querySelector("lit-virtualizer");i&&i.isConnected&&(i.scrollTop=0)}))}get portalContainerElement(){return this.portalContainer}resetMeasuredHeight(){this.measuredPopupHeight=null}forceReposition(){this.portalContainer&&this.computeFloatingUIPosition()}getCurrentPlacement(){return this.currentPlacement}getCurrentMiddlewareData(){return this.currentMiddlewareData}isUsingFloatingUI(){return null!==this.cleanupAutoUpdate}handleViewportChange(){this.portalContainer&&(this.resetMeasuredHeight(),this.forceReposition())}isPositioningOptimal(){if(!this.portalContainer||!this.currentMiddlewareData)return!0;const e=(this.component.combobox||this.component).getBoundingClientRect(),t=window.innerHeight-e.bottom,i=e.top,n=this.currentPlacement.startsWith("top"),o=this.currentPlacement.startsWith("bottom");return!(n&&t>i)&&!(o&&i>t)}},zo=class{constructor(e,{target:t,config:i,callback:n,skipInitial:o}){this.t=new Set,this.o=!1,this.i=!1,this.h=e,null!==t&&this.t.add(t??e),this.l=i,this.o=o??this.o,this.callback=n,window.ResizeObserver?(this.u=new ResizeObserver((e=>{this.handleChanges(e),this.h.requestUpdate()})),e.addController(this)):console.warn("ResizeController error: browser does not support ResizeObserver.")}handleChanges(e){this.value=this.callback?.(e,this.u)}hostConnected(){for(const e of this.t)this.observe(e)}hostDisconnected(){this.disconnect()}async hostUpdated(){!this.o&&this.i&&this.handleChanges([]),this.i=!1}observe(e){this.t.add(e),this.u.observe(e,this.l),this.i=!0,this.h.requestUpdate()}unobserve(e){this.t.delete(e),this.u.unobserve(e)}disconnect(){this.u.disconnect()}target(e){return yo(this,e)}};const yo=Ae(class extends Xn{constructor(){super(...arguments),this.observing=!1}render(e,t){}update(e,[t,i]){this.controller=t,this.part=e,this.observe=i,!1===i?(t.unobserve(e.element),this.observing=!1):!1===this.observing&&(t.observe(e.element),this.observing=!0)}disconnected(){this.controller?.unobserve(this.part.element),this.observing=!1}reconnected(){!1!==this.observe&&!1===this.observing&&(this.controller?.observe(this.part.element),this.observing=!0)}});let po=class extends Fe{constructor(){super(...arguments),this.formControlController=new Ue(this,{assumeInteractionOn:["nile-blur","nile-input"]}),this.hasSlotController=new Ze(this,"help-text","label"),this.portalManager=new Io(this),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.autoResize=!1,this.searchValue="",this.searchEnabled=!1,this.enableVisibilityEffect=!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.portal=!1,this.maxOptionsVisible=3,this.oldMaxOptionsVisible=1,this.enableTabClose=!1,this.descriptionSearchEnabled=!1,this.allowHtmlLabel=!0,this.enableDescription=!1,this.legacy=!1,this.tickOnSelect=!1,this.showListbox=!1,this.wasShowSelectedCheckedOnClose=!1,this.handleDocumentMouseDown=e=>{if(!this.open)return;const t=e.composedPath(),i=t.includes(this),n=this.popup&&t.includes(this.popup),o=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);i||n||o||this.hide()},this.handleWindowError=e=>{(e.error?.message||e.message||"").includes("Cannot read properties of null (reading 'insertBefore')")&&e.preventDefault()},this.handleWindowResize=()=>{this.portalManager.updatePortalAppendPosition()},this.handleWindowScroll=()=>{this.portalManager.updatePortalAppendPosition()},this.resizeController=new zo(this,{callback:e=>{for(const t of e)t.target.classList.contains("select__tags")&&this.calculateTotalWidthOfTags()}})}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.visibilityManager?.cleanup(),this.scrollTimeout&&(clearTimeout(this.scrollTimeout),this.scrollTimeout=void 0),this.portalManager.cleanupPortalAppend()}updated(e){if(e.has("value")&&this.selectionChanged(),e.has("autoResize")){const e=this.shadowRoot?.querySelector(".select__tags");this.autoResize&&e?this.resizeController.observe(e):e&&this.resizeController.unobserve(e)}}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}getItemDescription(e){return this.renderItemConfig?.getDescription?this.renderItemConfig.getDescription(e):e?.description||e||""}getItemPrefix(e){return this.renderItemConfig?.getPrefix?this.renderItemConfig.getPrefix(e):e?.prefix||e||""}getItemSuffix(e){return this.renderItemConfig?.getSuffix?this.renderItemConfig.getSuffix(e):e?.suffix||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),this.handleWindowResize=this.handleWindowResize.bind(this),this.handleWindowScroll=this.handleWindowScroll.bind(this)}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown),window.addEventListener("error",this.handleWindowError),this.portal&&(window.addEventListener("resize",this.handleWindowResize),window.addEventListener("scroll",this.handleWindowScroll,!0))}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown),window.removeEventListener("error",this.handleWindowError),window.removeEventListener("resize",this.handleWindowResize),window.removeEventListener("scroll",this.handleWindowScroll,!0)}handleFocus(){this.hasFocus=!0,this.emit("nile-focus")}handleBlur(){this.hasFocus=!1,this.emit("nile-blur")}firstUpdated(e){this.visibilityManager=new mn({host:this,target:this.combobox,enableVisibilityEffect:this.enableVisibilityEffect,enableTabClose:this.enableTabClose,isOpen:()=>this.open,onAnchorOutOfView:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"anchor-out-of-view",name:this.name})},onDocumentHidden:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"document-hidden",name:this.name})},emit:(e,t)=>this.emit(`nile-${e}`,t)})}handleDocumentFocusIn(e){if(!this.open)return;const t=e.composedPath(),i=t.includes(this),n=this.popup&&t.includes(this.popup),o=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);i||n||o||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,i=null!==t.closest(".select__clear"),n=null!==t.closest("nile-icon-button");return i||n}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){this.searchValue="";const e=Array.isArray(this.value)?this.value:[this.value];this.data=this.originalOptionItems.filter((t=>{const i=this.getItemValue(t);return e.some((e=>String(e)===String(i)))}))}else this.data=[...this.originalOptionItems];this.portalManager.resetMeasuredHeight(),this.requestUpdate(),this.repaintOptionsContainer()}}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 i=this.value;this.oldValue=i,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 i=t.filter((t=>t!==e.value));this.value=i,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=_n.createVirtualOptionsFromValues(this.value,e,this.getDisplayText.bind(this),this.renderItemConfig?.getValue,this.allowHtmlLabel),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.originalOptionItems?.length>0&&!this.searchValue&&(this.data=[...this.originalOptionItems]),this.repaintOptionsContainer()),this.calculateTotalWidthOfTags()}handleSearchFocus(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleSearchBlur(){document.addEventListener("keydown",this.handleDocumentKeyDown)}handleSearchChange(e){this.searchValue=e.detail.value,this.portal&&this.portalManager.updatePortalAppendPosition(),this.emit("nile-search",{query:this.searchValue,name:this.name}),this.disableLocalSearch||(this.filterVirtualOptions(this.searchValue),this.repaintOptionsContainer(),this.portalManager.resetMeasuredHeight())}repaintOptionsContainer(){this.resetScrollPosition(),this.updateComplete.then((()=>{const e=this.shadowRoot?.querySelector(".virtualized");e&&(this.data.length<5?e.classList.add("no-scroll"):e.classList.remove("no-scroll"))}))}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.searchValue&&this.emit("nile-scroll-end",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name,isAtBottom:!0})}filterVirtualOptions(e){const t=Rn.filterVirtualOptions(e,this.originalOptionItems,this.data,this.getDisplayText.bind(this),this.getItemDescription.bind(this),this.descriptionSearchEnabled,this.renderItemConfig?.getSearchText);this.portal?(this.portalManager.updatePortalAppendPosition(),this.updateComplete.then((()=>{requestAnimationFrame((()=>{this.resetScrollPosition()}))}))):this.resetScrollPosition(),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(),this.portal&&this.portalManager.portalContainerElement&&this.portalManager.updatePortalAppendPosition()}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(),this.portalManager.resetMeasuredHeight(),this.portal&&this.portalManager.portalContainerElement&&this.portalManager.updatePortalAppendPosition()}handleRenderItemConfigChange(){this.value&&this.data.length>0&&(this.selectionChanged(),this.requestUpdate())}handleOptionsLoadingChange(){this.optionsLoading||0!==this.data.length||(this.showNoResults=!0),this.requestUpdate(),this.portal&&this.portalManager.portalContainerElement&&this.portalManager.updatePortalAppendPosition()}handlePortalAppendChange(){this.open&&(this.portal?this.portalManager.setupPortalAppend():this.portalManager.cleanupPortalAppend())}async handleOpenChange(){this.open&&!this.disabled?(this.visibilityManager?.setup(),this.showListbox=!0,await this.updateComplete,await this.handleOpen(),this.portal&&this.portalManager.setupPortalAppend()):(this.visibilityManager?.cleanup(),await this.handleClose(),this.showListbox=!1,this.portal&&this.portalManager.cleanupPortalAppend())}async handleOpen(){this.emit("nile-show",{value:this.value,name:this.name}),this.addOpenListeners(),this.showNoResults=!this.data?.length,await Yt(this),this.popup?.popup&&(this.popup.popup.style.visibility="hidden"),this.popup.active=!0,await new Promise((e=>requestAnimationFrame(e))),await new Promise((e=>requestAnimationFrame(e))),this.popup?.popup&&(this.popup.popup.style.visibility="");const{keyframes:e,options:t}=Rt(this,"select.show",{dir:"ltr"});await Qt(this.popup.popup,e,t),this.wasShowSelectedCheckedOnClose&&(this.showSelected=!1,this.data=[...this.originalOptionItems],this.wasShowSelectedCheckedOnClose=!1),this.filterVirtualOptions(""),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(),this.wasShowSelectedCheckedOnClose=this.showSelected,await Yt(this);const{keyframes:e,options:t}=Rt(this,"select.hide",{dir:"ltr"});await Qt(this.popup.popup,e,t),this.popup.active=!1,this.popup?.popup&&(this.popup.popup.style.visibility=""),this.searchValue="",this.portalManager.resetMeasuredHeight(),this.emit("nile-after-hide",{value:this.value,name:this.name})}async show(){if(!this.open&&!this.disabled)return this.open=!0,Jt(this,"nile-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,Jt(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"),i=this.hasSlotController.test("custom-select"),n=!!this.label||!!e,o=this.clearable&&!this.disabled&&this.value.length>0,M=!!this.placeholder&&0===this.value.length,r=!!this.helpText,s=!!this.errorMessage;return _`
|
|
5773
5785
|
<div
|
|
5774
5786
|
part="form-control"
|
|
5775
5787
|
class=${Oe({"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":n,"form-control--has-help-text":r})}
|
|
@@ -6001,7 +6013,7 @@ class no{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
6001
6013
|
>${this.errorMessage}</nile-form-error-message
|
|
6002
6014
|
>
|
|
6003
6015
|
`:""}
|
|
6004
|
-
`}getVirtualizedContent(){return uo.getVirtualizedContent(this.data,this.searchEnabled,this.getDisplayText.bind(this),this.value,this.multiple,this.renderItemConfig?.getDisplayText,this.renderItemConfig?.getValue,this.renderItemConfig?.getDescription,this.renderItemConfig?.getPrefix,this.renderItemConfig?.getSuffix,this.showNoResults,this.noResultsMessage,this.optionsLoading||this.loading,this.handleScroll.bind(this),this.allowHtmlLabel,this.enableDescription)}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 i=0,n=0;for(let o=0;o<e.length;o++)if(i+=e[o],i>t){n=o;break}this.maxOptionsVisible=n}),1)}async resetScrollPosition(){await this.portalManager.resetScrollPosition()}};po.styles=Wn,e([he(".select")],po.prototype,"popup",void 0),e([he(".select__combobox")],po.prototype,"combobox",void 0),e([he(".select__display-input")],po.prototype,"displayInput",void 0),e([he(".select__value-input")],po.prototype,"valueInput",void 0),e([he(".virtualized")],po.prototype,"virtualizedContainer",void 0),e([De()],po.prototype,"hasFocus",void 0),e([De()],po.prototype,"displayLabel",void 0),e([De()],po.prototype,"selectedOptions",void 0),e([De()],po.prototype,"oldValue",void 0),e([ue()],po.prototype,"name",void 0),e([ue({type:Array})],po.prototype,"data",void 0),e([De()],po.prototype,"originalOptionItems",void 0),e([ue({converter:{fromAttribute:e=>e.split(" "),toAttribute:e=>e.join(" ")}})],po.prototype,"value",void 0),e([et()],po.prototype,"defaultValue",void 0),e([ue()],po.prototype,"size",void 0),e([ue()],po.prototype,"placeholder",void 0),e([ue({type:Boolean})],po.prototype,"autoResize",void 0),e([De()],po.prototype,"searchValue",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"searchEnabled",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],po.prototype,"enableVisibilityEffect",void 0),e([ue({attribute:"internal-search-placeholder"})],po.prototype,"internalSearchPlaceHolder",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"disableLocalSearch",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"optionsLoading",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],po.prototype,"loading",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"multiple",void 0),e([ue({attribute:"help-text",reflect:!0})],po.prototype,"helpText",void 0),e([ue({attribute:"error-message",reflect:!0})],po.prototype,"errorMessage",void 0),e([ue({type:Boolean})],po.prototype,"warning",void 0),e([ue({type:Boolean})],po.prototype,"error",void 0),e([ue({type:Boolean})],po.prototype,"success",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"disabled",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"clearable",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"open",void 0),e([ue({type:Boolean})],po.prototype,"hoist",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"filled",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"pill",void 0),e([ue()],po.prototype,"label",void 0),e([ue({reflect:!0})],po.prototype,"placement",void 0),e([ue({reflect:!0})],po.prototype,"form",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"required",void 0),e([ue({type:Boolean})],po.prototype,"showNoResults",void 0),e([ue({type:String})],po.prototype,"noResultsMessage",void 0),e([ue({type:Boolean})],po.prototype,"showSelected",void 0),e([ue({attribute:!1})],po.prototype,"renderItemConfig",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"blockValueChange",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"noWidthSync",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"portal",void 0),e([ue({attribute:"max-options-visible",type:Number})],po.prototype,"maxOptionsVisible",void 0),e([De()],po.prototype,"oldMaxOptionsVisible",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],po.prototype,"enableTabClose",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],po.prototype,"descriptionSearchEnabled",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0,converter:{fromAttribute:e=>"true"===e,toAttribute:e=>String(e)}})],po.prototype,"allowHtmlLabel",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],po.prototype,"enableDescription",void 0),e([De()],po.prototype,"showListbox",void 0),e([De()],po.prototype,"wasShowSelectedCheckedOnClose",void 0),e([We("disabled",{waitUntilFirstUpdate:!0})],po.prototype,"handleDisabledChange",null),e([We("value",{waitUntilFirstUpdate:!0})],po.prototype,"handleValueChange",null),e([We("data",{waitUntilFirstUpdate:!0})],po.prototype,"handleDataChange",null),e([We("renderItemConfig",{waitUntilFirstUpdate:!0})],po.prototype,"handleRenderItemConfigChange",null),e([We("optionsLoading",{waitUntilFirstUpdate:!0})],po.prototype,"handleOptionsLoadingChange",null),e([We("portal",{waitUntilFirstUpdate:!0})],po.prototype,"handlePortalAppendChange",null),e([We("open",{waitUntilFirstUpdate:!0})],po.prototype,"handleOpenChange",null),po=e([ge("nile-virtual-select")],po),_t("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),_t("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});class To{constructor(e){this.component=e}renderVirtualizedContent(){const e=this.component;return _`
|
|
6016
|
+
`}getVirtualizedContent(){return uo.getVirtualizedContent(this.data,this.searchEnabled,this.getDisplayText.bind(this),this.value,this.multiple,this.renderItemConfig?.getDisplayText,this.renderItemConfig?.getValue,this.renderItemConfig?.getDescription,this.renderItemConfig?.getPrefix,this.renderItemConfig?.getSuffix,this.showNoResults,this.noResultsMessage,this.optionsLoading||this.loading,this.handleScroll.bind(this),this.allowHtmlLabel,this.enableDescription,this.tickOnSelect,this.legacy)}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 i=0,n=0;for(let o=0;o<e.length;o++)if(i+=e[o],i>t){n=o;break}this.maxOptionsVisible=n}),1)}async resetScrollPosition(){await this.portalManager.resetScrollPosition()}};po.styles=Wn,e([he(".select")],po.prototype,"popup",void 0),e([he(".select__combobox")],po.prototype,"combobox",void 0),e([he(".select__display-input")],po.prototype,"displayInput",void 0),e([he(".select__value-input")],po.prototype,"valueInput",void 0),e([he(".virtualized")],po.prototype,"virtualizedContainer",void 0),e([De()],po.prototype,"hasFocus",void 0),e([De()],po.prototype,"displayLabel",void 0),e([De()],po.prototype,"selectedOptions",void 0),e([De()],po.prototype,"oldValue",void 0),e([ue()],po.prototype,"name",void 0),e([ue({type:Array})],po.prototype,"data",void 0),e([De()],po.prototype,"originalOptionItems",void 0),e([ue({converter:{fromAttribute:e=>e.split(" "),toAttribute:e=>e.join(" ")}})],po.prototype,"value",void 0),e([et()],po.prototype,"defaultValue",void 0),e([ue()],po.prototype,"size",void 0),e([ue()],po.prototype,"placeholder",void 0),e([ue({type:Boolean})],po.prototype,"autoResize",void 0),e([De()],po.prototype,"searchValue",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"searchEnabled",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],po.prototype,"enableVisibilityEffect",void 0),e([ue({attribute:"internal-search-placeholder"})],po.prototype,"internalSearchPlaceHolder",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"disableLocalSearch",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"optionsLoading",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],po.prototype,"loading",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"multiple",void 0),e([ue({attribute:"help-text",reflect:!0})],po.prototype,"helpText",void 0),e([ue({attribute:"error-message",reflect:!0})],po.prototype,"errorMessage",void 0),e([ue({type:Boolean})],po.prototype,"warning",void 0),e([ue({type:Boolean})],po.prototype,"error",void 0),e([ue({type:Boolean})],po.prototype,"success",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"disabled",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"clearable",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"open",void 0),e([ue({type:Boolean})],po.prototype,"hoist",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"filled",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"pill",void 0),e([ue()],po.prototype,"label",void 0),e([ue({reflect:!0})],po.prototype,"placement",void 0),e([ue({reflect:!0})],po.prototype,"form",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"required",void 0),e([ue({type:Boolean})],po.prototype,"showNoResults",void 0),e([ue({type:String})],po.prototype,"noResultsMessage",void 0),e([ue({type:Boolean})],po.prototype,"showSelected",void 0),e([ue({attribute:!1})],po.prototype,"renderItemConfig",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"blockValueChange",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"noWidthSync",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"portal",void 0),e([ue({attribute:"max-options-visible",type:Number})],po.prototype,"maxOptionsVisible",void 0),e([De()],po.prototype,"oldMaxOptionsVisible",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],po.prototype,"enableTabClose",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],po.prototype,"descriptionSearchEnabled",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0,converter:{fromAttribute:e=>"true"===e,toAttribute:e=>String(e)}})],po.prototype,"allowHtmlLabel",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],po.prototype,"enableDescription",void 0),e([ue({type:Boolean,reflect:!0})],po.prototype,"legacy",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],po.prototype,"tickOnSelect",void 0),e([De()],po.prototype,"showListbox",void 0),e([De()],po.prototype,"wasShowSelectedCheckedOnClose",void 0),e([We("disabled",{waitUntilFirstUpdate:!0})],po.prototype,"handleDisabledChange",null),e([We("value",{waitUntilFirstUpdate:!0})],po.prototype,"handleValueChange",null),e([We("data",{waitUntilFirstUpdate:!0})],po.prototype,"handleDataChange",null),e([We("renderItemConfig",{waitUntilFirstUpdate:!0})],po.prototype,"handleRenderItemConfigChange",null),e([We("optionsLoading",{waitUntilFirstUpdate:!0})],po.prototype,"handleOptionsLoadingChange",null),e([We("portal",{waitUntilFirstUpdate:!0})],po.prototype,"handlePortalAppendChange",null),e([We("open",{waitUntilFirstUpdate:!0})],po.prototype,"handleOpenChange",null),po=e([ge("nile-virtual-select")],po),_t("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),_t("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});class To{constructor(e){this.component=e}renderVirtualizedContent(){const e=this.component;return _`
|
|
6005
6017
|
<div class="virtual-select">
|
|
6006
6018
|
<nile-virtual-select
|
|
6007
6019
|
.name=${e.name}
|
|
@@ -6043,6 +6055,8 @@ class no{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
6043
6055
|
.descriptionSearchEnabled=${e.descriptionSearchEnabled}
|
|
6044
6056
|
.allowHtmlLabel=${e.allowHtmlLabel}
|
|
6045
6057
|
.enableDescription=${e.enableDescription}
|
|
6058
|
+
.tickOnSelect=${e.tickOnSelect}
|
|
6059
|
+
.legacy=${e.legacy}
|
|
6046
6060
|
exportparts="
|
|
6047
6061
|
select-options,
|
|
6048
6062
|
select-no-results,
|
|
@@ -6068,7 +6082,7 @@ class no{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
6068
6082
|
<slot name="prefix" slot="prefix"></slot>
|
|
6069
6083
|
</nile-virtual-select>
|
|
6070
6084
|
</div>
|
|
6071
|
-
`}}class Ao{constructor(e){this.portalContainer=null,this.originalListboxParent=null,this.measuredPopupHeight=null,this.clonedListbox=null,this.cleanupAutoUpdate=null,this.currentPlacement="bottom",this.currentMiddlewareData=null,this.component=e}createPortalAppendContainer(){const e=document.createElement("div");return e.style.position="absolute",e.style.zIndex="9999",e.style.pointerEvents="none",e.className="nile-select-portal-append",e}positionPortalAppend(){this.portalContainer&&this.component.popup&&(this.measurePopupHeight(),this.computeFloatingUIPosition())}measurePopupHeight(){!this.measuredPopupHeight&&this.portalContainer&&(this.portalContainer.style.position="absolute",this.portalContainer.style.visibility="hidden",this.portalContainer.style.top="0px",this.portalContainer.style.left="0px",this.portalContainer.offsetHeight,this.measuredPopupHeight=this.portalContainer.offsetHeight,this.portalContainer.style.visibility="")}async computeFloatingUIPosition(){if(!this.portalContainer)return;const e=this.component.combobox||this.component,t=this.portalContainer;try{const{x:i,y:n,placement:o,middlewareData:M}=await this.calculateFloatingUIPosition(e,t);this.applyFloatingUIPosition(t,e,i,n,o,M)}catch(e){console.warn("Floating UI positioning failed, falling back to simple positioning:",e),this.fallbackPositioning()}}async calculateFloatingUIPosition(e,t){const i=Do.findBoundaryElements(e),n=Do.getOptimalPlacement(e),o=this.createFloatingUIMiddleware(i);return await pn(e,t,{placement:n,strategy:"fixed",middleware:o,platform:this.createCustomPlatform()})}createFloatingUIMiddleware(e){return[hn(4),zn({apply:this.handleSizeMiddleware.bind(this),padding:10,boundary:e}),In({fallbackPlacements:["bottom","top","bottom-start","top-start","bottom-end","top-end"],fallbackStrategy:"bestFit",padding:10,boundary:e}),jn({padding:10,crossAxis:!0,boundary:e})]}handleSizeMiddleware({availableWidth:e,availableHeight:t,elements:i,rects:n}){const o=Do.calculateOptimalHeight(n.reference,window.innerHeight,this.currentPlacement);i.floating.style.maxWidth=`${e}px`,i.floating.style.maxHeight=`${o}px`,i.floating.style.setProperty("--auto-size-available-width",`${e}px`),i.floating.style.setProperty("--auto-size-available-height",`${o}px`)}createCustomPlatform(){return un}applyFloatingUIPosition(e,t,i,n,o,M){Object.assign(e.style,{left:`${i}px`,top:`${n}px`,position:"fixed",pointerEvents:"auto"}),this.currentPlacement=o,this.currentMiddlewareData=M,Do.applyCollisionData(e,M,o);const r=o.split("-")[0];e.className=`nile-select-portal-append select__listbox--${r}`;const s=t.getBoundingClientRect();e.style.width=`${s.width}px`}fallbackPositioning(){if(!this.portalContainer)return;const e=(this.component.combobox||this.component).getBoundingClientRect(),t=window.innerHeight;this.measuredPopupHeight;const i=t-e.bottom,n=e.top;let o,M,r;n>i?(r=Math.max(n-20,100),o=Math.max(e.top-r-4,10),M="top"):(r=Math.max(i-20,100),o=e.bottom+4,M="bottom"),this.portalContainer.style.left=`${e.left}px`,this.portalContainer.style.top=`${o}px`,this.portalContainer.style.width=`${e.width}px`,this.portalContainer.style.maxHeight=`${r}px`,this.portalContainer.style.pointerEvents="auto",this.portalContainer.className=`nile-select-portal-append select__listbox--${M}`,this.calculateAndSetAutoSizeProperties(e,o,M)}calculateAndSetAutoSizeProperties(e,t,i){if(!this.portalContainer)return;const n=window.innerHeight,o=window.innerWidth;let M;M="top"===i?e.top-10:n-e.bottom-10;const r=Math.min(e.width,o-e.left-10);this.portalContainer.style.setProperty("--auto-size-available-height",`${Math.max(M,100)}px`),this.portalContainer.style.setProperty("--auto-size-available-width",`${Math.max(r,200)}px`)}updatePortalAppendPosition(){this.component.portal&&this.portalContainer&&this.positionPortalAppend()}handleWindowResize(){this.component.portal&&this.portalContainer&&this.positionPortalAppend()}setupAutoUpdatePositioning(){this.portalContainer&&this.component&&(this.cleanupAutoUpdatePositioning(),this.cleanupAutoUpdate=dn(this.component,this.portalContainer,(()=>{this.computeFloatingUIPosition()}),{ancestorScroll:!0,ancestorResize:!0,elementResize:!0,layoutShift:!0,animationFrame:!0}))}cleanupAutoUpdatePositioning(){this.cleanupAutoUpdate&&(this.cleanupAutoUpdate(),this.cleanupAutoUpdate=null)}injectStylesToDocument(){if(!this.portalContainer)return;const e=Do.generateStyleId();if(document.getElementById(e))return;const t=this.component.constructor.styles;if(!t)return;const i=document.createElement("style");i.id=e,i.textContent=Do.extractStylesAsCSS(t),document.head.appendChild(i),this.portalContainer.__injectedStyleId=e}adoptStylesToPortalAppend(){this.portalContainer&&this.injectStylesToDocument()}setupPortalAppend(){this.component.portal&&this.component.updateComplete.then((()=>{setTimeout((()=>{const e=this.component.shadowRoot?.querySelector("#listbox");e&&(this.originalListboxParent=e.parentElement,this.clonedListbox=this.createPortalListbox(),this.portalContainer=this.createPortalAppendContainer(),this.portalContainer.appendChild(this.clonedListbox),document.body.appendChild(this.portalContainer),this.adoptStylesToPortalAppend(),this.clonedListbox.style.display="",this.positionPortalAppend(),this.setupPortalEventListeners(),this.updatePortalContent(),setTimeout((()=>{this.updateFooterState()}),50),this.setupAutoUpdatePositioning(),window.addEventListener("resize",this.handleWindowResize.bind(this)))}),10)}))}createPortalListbox(){return ho.createPortalListbox(this.component)}setupPortalEventListeners(){jo.setupPortalEventListeners(this.clonedListbox,this.component)}updatePortalContent(){this.clonedListbox&&(ho.updateClonedOptions(this.clonedListbox,this.component),this.updateFooterState())}updateFooterState(){const e=this.clonedListbox?.querySelector(".select__footer");if(!e||!this.component.multiple)return;const t=e.querySelector("nile-checkbox");t&&(t.disabled=0===this.component.selectedOptions.length,t.checked=this.component.showSelected);const i=e.querySelector(".select__clear");if(0===this.component.selectedOptions.length)i&&i.remove();else if(!i){const t=document.createElement("span");t.className="select__clear",t.textContent="Clear All",t.style.cursor="pointer",e.appendChild(t)}}cleanupPortalAppend(){if(this.cleanupAutoUpdatePositioning(),this.portalContainer&&this.portalContainer.parentNode){const e=this.portalContainer.__injectedStyleId;if(e){const t=document.getElementById(e);t&&t.remove()}this.portalContainer.parentNode.removeChild(this.portalContainer)}window.removeEventListener("resize",this.handleWindowResize.bind(this)),this.portalContainer=null,this.originalListboxParent=null,this.clonedListbox=null,this.measuredPopupHeight=null,this.currentPlacement="bottom",this.currentMiddlewareData=null}get portalContainerElement(){return this.portalContainer}resetMeasuredHeight(){this.measuredPopupHeight=null}updatePortalOptions(){this.portalContainer&&this.clonedListbox&&(this.updatePortalContent(),this.forceReposition())}forceReposition(){this.portalContainer&&this.computeFloatingUIPosition()}getCurrentPlacement(){return this.currentPlacement}getCurrentMiddlewareData(){return this.currentMiddlewareData}isUsingFloatingUI(){return null!==this.cleanupAutoUpdate}updatePositioningConfig(e){this.forceReposition()}handleViewportChange(){this.portalContainer&&(this.resetMeasuredHeight(),this.forceReposition())}isPositioningOptimal(){if(!this.portalContainer||!this.currentMiddlewareData)return!0;const e=(this.component.combobox||this.component).getBoundingClientRect(),t=window.innerHeight-e.bottom,i=e.top,n=this.currentPlacement.startsWith("top"),o=this.currentPlacement.startsWith("bottom");return!(n&&t>i)&&!(o&&i>t)}}let xo=class extends Fe{get validity(){return this.valueInput?.validity}get validationMessage(){return this.valueInput?.validationMessage}constructor(){super(),this.portalManager=new Ao(this),this.hasSlotController=new Ze(this,"help-text","label","pre-footer"),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.enableVisibilityEffect=!1,this.blockValueChange=!1,this.disableLocalSearch=!1,this.optionsLoading=!1,this.noWidthSync=!1,this.portal=!1,this.multiple=!1,this.helpText="",this.help_text="",this.autoResize=!1,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.enableTabClose=!1,this.showNoResults=!1,this.noResultsMessage="No results found",this.data=[],this.enableVirtualScroll=!1,this.enableGroupHeader=!1,this.autoFocusSearch=!1,this.loading=!1,this.stickyHeader=!1,this.descriptionSearchEnabled=!1,this.enableDescription=!1,this.allowHtmlLabel=!0,this.handleWindowResize=()=>{this.portalManager.updatePortalAppendPosition()},this.handleWindowScroll=()=>{this.portalManager.updatePortalAppendPosition()}}connectedCallback(){super.connectedCallback(),this.enableVirtualScroll||(this.formControlController=new Ue(this,{assumeInteractionOn:["nile-blur","nile-input"]})),this.virtualScrollHelper=new To(this),this.handleDocumentFocusIn=this.handleDocumentFocusIn.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.handleWindowResize=this.handleWindowResize.bind(this),this.handleWindowScroll=this.handleWindowScroll.bind(this),this.open=!1,this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.scrollTimeout&&(clearTimeout(this.scrollTimeout),this.scrollTimeout=void 0),this.visibilityManager?.cleanup(),this.portalManager.cleanupPortalAppend(),this.emit("nile-destroy")}setupResizeObserver(){if(this.autoResize){const e=this.shadowRoot?.querySelector(".select__tags");e&&(this.resizeController=new zo(this,{callback:()=>this.calculateTotalWidthOfTags()}),this.resizeController.observe(e))}else this.resizeController?.unobserve?.(this.shadowRoot?.querySelector(".select__tags")),this.resizeController=void 0}updated(e){e.has("searchEnabled")&&this.updateGroupStickyOffsets(),e.has("multiple")&&this.setCheckBoxInOption(this.multiple),e.has("autoResize")&&this.setupResizeObserver(),e.has("enableDescription")&&this.setEnableDescriptionInOptions()}firstUpdated(e){this.enableGroupHeader&&(this.disableLocalSearch||this.handleGroupSearchChange(),this.applyStickyToGroups()),this.setupResizeObserver(),e.has("multiple")&&this.setCheckBoxInOption(this.multiple),e.has("enableDescription")&&this.setEnableDescriptionInOptions(),this.visibilityManager=new mn({host:this,target:this.combobox,enableVisibilityEffect:this.enableVisibilityEffect,enableTabClose:this.enableTabClose,isOpen:()=>this.open,onAnchorOutOfView:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"anchor-out-of-view",name:this.name})},onDocumentHidden:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"document-hidden",name:this.name})},emit:(e,t)=>this.emit(`nile-${e}`,t)})}setCheckBoxInOption(e){this.options.length||(this.options=this.getAllOptions()),this.options.forEach((t=>{t.showCheckbox=e}))}setEnableDescriptionInOptions(){this.options=this.getAllOptions(),this.options.forEach((e=>{(e?.updateComplete??Promise.resolve()).then((()=>{e.isDescriptionEnabled=this.enableDescription})).catch((()=>{}))}))}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown),this.portal&&(window.addEventListener("resize",this.handleWindowResize),window.addEventListener("scroll",this.handleWindowScroll,!0))}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown),window.removeEventListener("resize",this.handleWindowResize),window.removeEventListener("scroll",this.handleWindowScroll,!0)}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){if(!this.open)return;const t=e.composedPath(),i=t.includes(this),n=this.popup&&t.includes(this.popup),o=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);i||n||o||this.hide()}updateGroupStickyOffsets(){this.querySelectorAll("nile-option-group").forEach((e=>{this.searchEnabled?e.setAttribute("search-enabled",""):e.removeAttribute("search-enabled")}))}handleFooterClick(e){e.stopPropagation(),e.preventDefault()}handlePreFooterClick(){this.hide()}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(),this.portal&&this.open&&this.portalManager.updatePortalOptions()}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}),this.portal&&this.open&&this.portalManager.updatePortalOptions()}handleDocumentKeyDown(e){const t=e.target,i=null!==t.closest(".select__clear"),n=null!==t.closest("nile-icon-button");if(!i&&!n){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){if(!this.open)return;const t=e.composedPath(),i=t.includes(this),n=this.popup&&t.includes(this.popup),o=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);i||n||o||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 i=this.value;if(this.oldValue=i,t&&!t.disabled&&(this.multiple?this.toggleOptionSelection(t):this.setSelectedOptions(t),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==i&&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()}this.portal&&this.open&&this.portalManager.updatePortalOptions()}applyStickyToGroups(){this.querySelectorAll("nile-option-group").forEach((e=>{this.stickyHeader?e.setAttribute("sticky",""):e.removeAttribute("sticky")}))}handleDefaultSlotChange(){const e=this.getAllOptions(),t=Array.isArray(this.value)?this.value:[this.value],i=[];this.updateGroupStickyOffsets(),this.applyStickyToGroups(),customElements.get("nile-option")?(e.forEach((e=>i.push(e.value))),this.setSelectedOptions(e.filter((e=>t.map(String).includes(e.value))))):customElements.whenDefined("nile-option").then((()=>this.handleDefaultSlotChange())),this.portal&&this.open&&this.portalManager.updatePortalOptions(),this.setEnableDescriptionInOptions()}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 i=this.oldValue.indexOf(e.value),n=this.oldValue.indexOf(t.value);return-1===i&&(i=1/0),-1===n&&(n=1/0),i<n?-1:i>n?1:0})),e}getOptionPrefix(e){const t=e.shadowRoot?.querySelector('slot[name="prefix"]');if(!t)return"";const i=t.assignedNodes(),n=[];return i.forEach((e=>{e instanceof HTMLElement?n.push(e.outerHTML):e.nodeType===Node.TEXT_NODE&&n.push(e.textContent||"")})),n.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(),i=Array.isArray(e)?e:[e];t.forEach((e=>e.selected=!1)),i.length&&i.forEach((e=>e.selected=!0)),this.selectionChanged(),this.portal&&this.open&&this.portalManager.updatePortalOptions()}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.disableLocalSearch&&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(),i=e.toLowerCase();let n=[];return t.forEach((e=>{const t=e.getTextLabel().toLowerCase(),o=(e.value||"").toLowerCase(),M=(e.description||"").toLowerCase(),r=t.includes(i)||o.includes(i)||this.descriptionSearchEnabled&&M.includes(i);e.hidden=!r,r&&n.push(e)})),this.portal&&this.open&&this.portalManager.updatePortalOptions(),n}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))))}handlePortalAppendChange(){this.open&&(this.portal?this.portalManager.setupPortalAppend():this.portalManager.cleanupPortalAppend())}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.visibilityManager?.setup(),this.showNoResults=!this.getAllOptions()?.length,await Yt(this),this.listbox.hidden=!1,this.popup.active=!0,requestAnimationFrame((()=>{this.setCurrentOption(this.currentOption)}));const{keyframes:e,options:t}=Rt(this,"select.show",{dir:"ltr"});await Qt(this.popup.popup,e,t),this.currentOption&&Ht(this.currentOption,this.listbox,"vertical","auto"),this.searchValue="",this.filterOptions(this.searchValue),this.portal&&this.portalManager.setupPortalAppend(),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(),this.visibilityManager?.cleanup(),await Yt(this);const{keyframes:e,options:t}=Rt(this,"select.hide",{dir:"ltr"});await Qt(this.popup.popup,e,t),this.listbox.hidden=!0,this.popup.active=!1,this.portal&&this.portalManager.cleanupPortalAppend(),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:i})=>{i?.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:i})=>{i?.classList.toggle("nile-group-hidden",this.showSelected&&!e.has(t))}))}async show(){if(!this.open&&!this.disabled)return this.open=!0,Jt(this,"nile-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,Jt(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 i=0,n=0;for(let o=0;o<e.length;o++)if(i+=e[o],i>t){n=o;break}this.maxOptionsVisible=n}),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"),i=this.hasSlotController.test("custom-select"),n=!!this.label||!!e,o=this.clearable&&!this.disabled&&this.value.length>0,M=this.placeholder&&0===this.value.length,r=!(!this.helpText&&!this.help_text),s=!!this.errorMessage,a=this.selectedOptions[0]?this.getOptionPrefix(this.selectedOptions[0]):"";return _`
|
|
6085
|
+
`}}class Ao{constructor(e){this.portalContainer=null,this.originalListboxParent=null,this.measuredPopupHeight=null,this.clonedListbox=null,this.cleanupAutoUpdate=null,this.currentPlacement="bottom",this.currentMiddlewareData=null,this.component=e}createPortalAppendContainer(){const e=document.createElement("div");return e.style.position="absolute",e.style.zIndex="9999",e.style.pointerEvents="none",e.className="nile-select-portal-append",e}positionPortalAppend(){this.portalContainer&&this.component.popup&&(this.measurePopupHeight(),this.computeFloatingUIPosition())}measurePopupHeight(){!this.measuredPopupHeight&&this.portalContainer&&(this.portalContainer.style.position="absolute",this.portalContainer.style.visibility="hidden",this.portalContainer.style.top="0px",this.portalContainer.style.left="0px",this.portalContainer.offsetHeight,this.measuredPopupHeight=this.portalContainer.offsetHeight,this.portalContainer.style.visibility="")}async computeFloatingUIPosition(){if(!this.portalContainer)return;const e=this.component.combobox||this.component,t=this.portalContainer;try{const{x:i,y:n,placement:o,middlewareData:M}=await this.calculateFloatingUIPosition(e,t);this.applyFloatingUIPosition(t,e,i,n,o,M)}catch(e){console.warn("Floating UI positioning failed, falling back to simple positioning:",e),this.fallbackPositioning()}}async calculateFloatingUIPosition(e,t){const i=Do.findBoundaryElements(e),n=Do.getOptimalPlacement(e),o=this.createFloatingUIMiddleware(i);return await pn(e,t,{placement:n,strategy:"fixed",middleware:o,platform:this.createCustomPlatform()})}createFloatingUIMiddleware(e){return[hn(4),zn({apply:this.handleSizeMiddleware.bind(this),padding:10,boundary:e}),In({fallbackPlacements:["bottom","top","bottom-start","top-start","bottom-end","top-end"],fallbackStrategy:"bestFit",padding:10,boundary:e}),jn({padding:10,crossAxis:!0,boundary:e})]}handleSizeMiddleware({availableWidth:e,availableHeight:t,elements:i,rects:n}){const o=Do.calculateOptimalHeight(n.reference,window.innerHeight,this.currentPlacement);i.floating.style.maxWidth=`${e}px`,i.floating.style.maxHeight=`${o}px`,i.floating.style.setProperty("--auto-size-available-width",`${e}px`),i.floating.style.setProperty("--auto-size-available-height",`${o}px`)}createCustomPlatform(){return un}applyFloatingUIPosition(e,t,i,n,o,M){Object.assign(e.style,{left:`${i}px`,top:`${n}px`,position:"fixed",pointerEvents:"auto"}),this.currentPlacement=o,this.currentMiddlewareData=M,Do.applyCollisionData(e,M,o);const r=o.split("-")[0];e.className=`nile-select-portal-append select__listbox--${r}`;const s=t.getBoundingClientRect();e.style.width=`${s.width}px`}fallbackPositioning(){if(!this.portalContainer)return;const e=(this.component.combobox||this.component).getBoundingClientRect(),t=window.innerHeight;this.measuredPopupHeight;const i=t-e.bottom,n=e.top;let o,M,r;n>i?(r=Math.max(n-20,100),o=Math.max(e.top-r-4,10),M="top"):(r=Math.max(i-20,100),o=e.bottom+4,M="bottom"),this.portalContainer.style.left=`${e.left}px`,this.portalContainer.style.top=`${o}px`,this.portalContainer.style.width=`${e.width}px`,this.portalContainer.style.maxHeight=`${r}px`,this.portalContainer.style.pointerEvents="auto",this.portalContainer.className=`nile-select-portal-append select__listbox--${M}`,this.calculateAndSetAutoSizeProperties(e,o,M)}calculateAndSetAutoSizeProperties(e,t,i){if(!this.portalContainer)return;const n=window.innerHeight,o=window.innerWidth;let M;M="top"===i?e.top-10:n-e.bottom-10;const r=Math.min(e.width,o-e.left-10);this.portalContainer.style.setProperty("--auto-size-available-height",`${Math.max(M,100)}px`),this.portalContainer.style.setProperty("--auto-size-available-width",`${Math.max(r,200)}px`)}updatePortalAppendPosition(){this.component.portal&&this.portalContainer&&this.positionPortalAppend()}handleWindowResize(){this.component.portal&&this.portalContainer&&this.positionPortalAppend()}setupAutoUpdatePositioning(){this.portalContainer&&this.component&&(this.cleanupAutoUpdatePositioning(),this.cleanupAutoUpdate=dn(this.component,this.portalContainer,(()=>{this.computeFloatingUIPosition()}),{ancestorScroll:!0,ancestorResize:!0,elementResize:!0,layoutShift:!0,animationFrame:!0}))}cleanupAutoUpdatePositioning(){this.cleanupAutoUpdate&&(this.cleanupAutoUpdate(),this.cleanupAutoUpdate=null)}injectStylesToDocument(){if(!this.portalContainer)return;const e=Do.generateStyleId();if(document.getElementById(e))return;const t=this.component.constructor.styles;if(!t)return;const i=document.createElement("style");i.id=e,i.textContent=Do.extractStylesAsCSS(t),document.head.appendChild(i),this.portalContainer.__injectedStyleId=e}adoptStylesToPortalAppend(){this.portalContainer&&this.injectStylesToDocument()}setupPortalAppend(){this.component.portal&&this.component.updateComplete.then((()=>{setTimeout((()=>{const e=this.component.shadowRoot?.querySelector("#listbox");e&&(this.originalListboxParent=e.parentElement,this.clonedListbox=this.createPortalListbox(),this.portalContainer=this.createPortalAppendContainer(),this.portalContainer.appendChild(this.clonedListbox),document.body.appendChild(this.portalContainer),this.adoptStylesToPortalAppend(),this.clonedListbox.style.display="",this.positionPortalAppend(),this.setupPortalEventListeners(),this.updatePortalContent(),setTimeout((()=>{this.updateFooterState()}),50),this.setupAutoUpdatePositioning(),window.addEventListener("resize",this.handleWindowResize.bind(this)))}),10)}))}createPortalListbox(){return ho.createPortalListbox(this.component)}setupPortalEventListeners(){jo.setupPortalEventListeners(this.clonedListbox,this.component)}updatePortalContent(){this.clonedListbox&&(ho.updateClonedOptions(this.clonedListbox,this.component),this.updateFooterState())}updateFooterState(){const e=this.clonedListbox?.querySelector(".select__footer");if(!e||!this.component.multiple)return;const t=e.querySelector("nile-checkbox");t&&(t.disabled=0===this.component.selectedOptions.length,t.checked=this.component.showSelected);const i=e.querySelector(".select__clear");if(0===this.component.selectedOptions.length)i&&i.remove();else if(!i){const t=document.createElement("span");t.className="select__clear",t.textContent="Clear All",t.style.cursor="pointer",e.appendChild(t)}}cleanupPortalAppend(){if(this.cleanupAutoUpdatePositioning(),this.portalContainer&&this.portalContainer.parentNode){const e=this.portalContainer.__injectedStyleId;if(e){const t=document.getElementById(e);t&&t.remove()}this.portalContainer.parentNode.removeChild(this.portalContainer)}window.removeEventListener("resize",this.handleWindowResize.bind(this)),this.portalContainer=null,this.originalListboxParent=null,this.clonedListbox=null,this.measuredPopupHeight=null,this.currentPlacement="bottom",this.currentMiddlewareData=null}get portalContainerElement(){return this.portalContainer}resetMeasuredHeight(){this.measuredPopupHeight=null}updatePortalOptions(){this.portalContainer&&this.clonedListbox&&(this.updatePortalContent(),this.forceReposition())}forceReposition(){this.portalContainer&&this.computeFloatingUIPosition()}getCurrentPlacement(){return this.currentPlacement}getCurrentMiddlewareData(){return this.currentMiddlewareData}isUsingFloatingUI(){return null!==this.cleanupAutoUpdate}updatePositioningConfig(e){this.forceReposition()}handleViewportChange(){this.portalContainer&&(this.resetMeasuredHeight(),this.forceReposition())}isPositioningOptimal(){if(!this.portalContainer||!this.currentMiddlewareData)return!0;const e=(this.component.combobox||this.component).getBoundingClientRect(),t=window.innerHeight-e.bottom,i=e.top,n=this.currentPlacement.startsWith("top"),o=this.currentPlacement.startsWith("bottom");return!(n&&t>i)&&!(o&&i>t)}}let xo=class extends Fe{get validity(){return this.valueInput?.validity}get validationMessage(){return this.valueInput?.validationMessage}constructor(){super(),this.portalManager=new Ao(this),this.hasSlotController=new Ze(this,"help-text","label","pre-footer"),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.legacy=!1,this.tickOnSelect=!1,this.internalSearchPlaceHolder="Search...",this.enableVisibilityEffect=!1,this.blockValueChange=!1,this.disableLocalSearch=!1,this.optionsLoading=!1,this.noWidthSync=!1,this.portal=!1,this.multiple=!1,this.helpText="",this.help_text="",this.autoResize=!1,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.enableTabClose=!1,this.showNoResults=!1,this.noResultsMessage="No results found",this.data=[],this.enableVirtualScroll=!1,this.enableGroupHeader=!1,this.autoFocusSearch=!1,this.loading=!1,this.stickyHeader=!1,this.descriptionSearchEnabled=!1,this.enableDescription=!1,this.allowHtmlLabel=!0,this.handleWindowResize=()=>{this.portalManager.updatePortalAppendPosition()},this.handleWindowScroll=()=>{this.portalManager.updatePortalAppendPosition()}}connectedCallback(){super.connectedCallback(),this.enableVirtualScroll||(this.formControlController=new Ue(this,{assumeInteractionOn:["nile-blur","nile-input"]})),this.virtualScrollHelper=new To(this),this.handleDocumentFocusIn=this.handleDocumentFocusIn.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.handleWindowResize=this.handleWindowResize.bind(this),this.handleWindowScroll=this.handleWindowScroll.bind(this),this.open=!1,this.emit("nile-init")}disconnectedCallback(){super.disconnectedCallback(),this.scrollTimeout&&(clearTimeout(this.scrollTimeout),this.scrollTimeout=void 0),this.visibilityManager?.cleanup(),this.portalManager.cleanupPortalAppend(),this.emit("nile-destroy")}setupResizeObserver(){if(this.autoResize){const e=this.shadowRoot?.querySelector(".select__tags");e&&(this.resizeController=new zo(this,{callback:()=>this.calculateTotalWidthOfTags()}),this.resizeController.observe(e))}else this.resizeController?.unobserve?.(this.shadowRoot?.querySelector(".select__tags")),this.resizeController=void 0}updated(e){e.has("searchEnabled")&&this.updateGroupStickyOffsets(),e.has("multiple")&&this.setCheckBoxInOption(this.multiple),e.has("legacy")&&this.setLegacyInOptions(this.legacy),e.has("tickOnSelect")&&this.setTickOnSelectInOptions(this.tickOnSelect),e.has("autoResize")&&this.setupResizeObserver(),e.has("enableDescription")&&this.setEnableDescriptionInOptions()}firstUpdated(e){this.enableGroupHeader&&(this.disableLocalSearch||this.handleGroupSearchChange(),this.applyStickyToGroups()),this.setupResizeObserver(),e.has("multiple")&&this.setCheckBoxInOption(this.multiple),this.setLegacyInOptions(this.legacy),this.setTickOnSelectInOptions(this.tickOnSelect),e.has("enableDescription")&&this.setEnableDescriptionInOptions(),this.visibilityManager=new mn({host:this,target:this.combobox,enableVisibilityEffect:this.enableVisibilityEffect,enableTabClose:this.enableTabClose,isOpen:()=>this.open,onAnchorOutOfView:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"anchor-out-of-view",name:this.name})},onDocumentHidden:()=>{this.hide(),this.emit("nile-visibility-change",{visible:!1,reason:"document-hidden",name:this.name})},emit:(e,t)=>this.emit(`nile-${e}`,t)})}setCheckBoxInOption(e){this.options.length||(this.options=this.getAllOptions()),this.options.forEach((t=>{t.showCheckbox=e}))}setLegacyInOptions(e){this.options.length||(this.options=this.getAllOptions()),this.options.forEach((t=>{t.legacy=e}))}setTickOnSelectInOptions(e){this.options.length||(this.options=this.getAllOptions()),this.options.forEach((t=>{t.tickOnSelect=e}))}setEnableDescriptionInOptions(){this.options=this.getAllOptions(),this.options.forEach((e=>{(e?.updateComplete??Promise.resolve()).then((()=>{e.isDescriptionEnabled=this.enableDescription})).catch((()=>{}))}))}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown),this.portal&&(window.addEventListener("resize",this.handleWindowResize),window.addEventListener("scroll",this.handleWindowScroll,!0))}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown),window.removeEventListener("resize",this.handleWindowResize),window.removeEventListener("scroll",this.handleWindowScroll,!0)}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){if(!this.open)return;const t=e.composedPath(),i=t.includes(this),n=this.popup&&t.includes(this.popup),o=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);i||n||o||this.hide()}updateGroupStickyOffsets(){this.querySelectorAll("nile-option-group").forEach((e=>{this.searchEnabled?e.setAttribute("search-enabled",""):e.removeAttribute("search-enabled")}))}handleFooterClick(e){e.stopPropagation(),e.preventDefault()}handlePreFooterClick(){this.hide()}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(),this.portal&&this.open&&this.portalManager.updatePortalOptions()}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}),this.portal&&this.open&&this.portalManager.updatePortalOptions()}handleDocumentKeyDown(e){const t=e.target,i=null!==t.closest(".select__clear"),n=null!==t.closest("nile-icon-button");if(!i&&!n){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){if(!this.open)return;const t=e.composedPath(),i=t.includes(this),n=this.popup&&t.includes(this.popup),o=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);i||n||o||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 i=this.value;if(this.oldValue=i,t&&!t.disabled&&(this.multiple?this.toggleOptionSelection(t):this.setSelectedOptions(t),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==i&&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()}this.portal&&this.open&&this.portalManager.updatePortalOptions()}applyStickyToGroups(){this.querySelectorAll("nile-option-group").forEach((e=>{this.stickyHeader?e.setAttribute("sticky",""):e.removeAttribute("sticky")}))}handleDefaultSlotChange(){const e=this.getAllOptions(),t=Array.isArray(this.value)?this.value:[this.value],i=[];this.updateGroupStickyOffsets(),this.applyStickyToGroups(),customElements.get("nile-option")?(e.forEach((e=>i.push(e.value))),this.setSelectedOptions(e.filter((e=>t.map(String).includes(e.value))))):customElements.whenDefined("nile-option").then((()=>this.handleDefaultSlotChange())),this.portal&&this.open&&this.portalManager.updatePortalOptions(),this.setEnableDescriptionInOptions()}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 i=this.oldValue.indexOf(e.value),n=this.oldValue.indexOf(t.value);return-1===i&&(i=1/0),-1===n&&(n=1/0),i<n?-1:i>n?1:0})),e}getOptionPrefix(e){const t=e.shadowRoot?.querySelector('slot[name="prefix"]');if(!t)return"";const i=t.assignedNodes(),n=[];return i.forEach((e=>{e instanceof HTMLElement?n.push(e.outerHTML):e.nodeType===Node.TEXT_NODE&&n.push(e.textContent||"")})),n.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(),i=Array.isArray(e)?e:[e];t.forEach((e=>e.selected=!1)),i.length&&i.forEach((e=>e.selected=!0)),this.selectionChanged(),this.portal&&this.open&&this.portalManager.updatePortalOptions()}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.disableLocalSearch&&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(),i=e.toLowerCase();let n=[];return t.forEach((e=>{const t=e.getTextLabel().toLowerCase(),o=(e.value||"").toLowerCase(),M=(e.description||"").toLowerCase(),r=t.includes(i)||o.includes(i)||this.descriptionSearchEnabled&&M.includes(i);e.hidden=!r,r&&n.push(e)})),this.portal&&this.open&&this.portalManager.updatePortalOptions(),n}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))))}handlePortalAppendChange(){this.open&&(this.portal?this.portalManager.setupPortalAppend():this.portalManager.cleanupPortalAppend())}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.visibilityManager?.setup(),this.showNoResults=!this.getAllOptions()?.length,await Yt(this),this.listbox.hidden=!1,this.popup.active=!0,requestAnimationFrame((()=>{this.setCurrentOption(this.currentOption)}));const{keyframes:e,options:t}=Rt(this,"select.show",{dir:"ltr"});await Qt(this.popup.popup,e,t),this.currentOption&&Ht(this.currentOption,this.listbox,"vertical","auto"),this.searchValue="",this.filterOptions(this.searchValue),this.portal&&this.portalManager.setupPortalAppend(),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(),this.visibilityManager?.cleanup(),await Yt(this);const{keyframes:e,options:t}=Rt(this,"select.hide",{dir:"ltr"});await Qt(this.popup.popup,e,t),this.listbox.hidden=!0,this.popup.active=!1,this.portal&&this.portalManager.cleanupPortalAppend(),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:i})=>{i?.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:i})=>{i?.classList.toggle("nile-group-hidden",this.showSelected&&!e.has(t))}))}async show(){if(!this.open&&!this.disabled)return this.open=!0,Jt(this,"nile-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,Jt(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 i=0,n=0;for(let o=0;o<e.length;o++)if(i+=e[o],i>t){n=o;break}this.maxOptionsVisible=n}),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"),i=this.hasSlotController.test("custom-select"),n=!!this.label||!!e,o=this.clearable&&!this.disabled&&this.value.length>0,M=this.placeholder&&0===this.value.length,r=!(!this.helpText&&!this.help_text),s=!!this.errorMessage,a=this.selectedOptions[0]?this.getOptionPrefix(this.selectedOptions[0]):"";return _`
|
|
6072
6086
|
<div
|
|
6073
6087
|
part="form-control"
|
|
6074
6088
|
class=${Oe({"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":n,"form-control--has-help-text":r})}
|
|
@@ -6307,7 +6321,7 @@ class no{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
6307
6321
|
>
|
|
6308
6322
|
`:""}
|
|
6309
6323
|
</div>
|
|
6310
|
-
`}nileInput(e){this.emit("nile-input",e)}nileChange(e){this.emit("nile-change",e)}};xo.styles=Zn,e([he(".select")],xo.prototype,"popup",void 0),e([he(".select__combobox")],xo.prototype,"combobox",void 0),e([he(".select__display-input")],xo.prototype,"displayInput",void 0),e([he(".select__value-input")],xo.prototype,"valueInput",void 0),e([he(".select__listbox")],xo.prototype,"listbox",void 0),e([De()],xo.prototype,"hasFocus",void 0),e([De()],xo.prototype,"displayLabel",void 0),e([De()],xo.prototype,"currentOption",void 0),e([De()],xo.prototype,"selectedOptions",void 0),e([De()],xo.prototype,"oldValue",void 0),e([ue()],xo.prototype,"name",void 0),e([ue({converter:{fromAttribute:e=>e.split(" "),toAttribute:e=>e.join(" ")}})],xo.prototype,"value",void 0),e([et()],xo.prototype,"defaultValue",void 0),e([ue()],xo.prototype,"size",void 0),e([ue()],xo.prototype,"placeholder",void 0),e([De()],xo.prototype,"searchValue",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"searchEnabled",void 0),e([ue({attribute:"internal-search-placeholder"})],xo.prototype,"internalSearchPlaceHolder",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"enableVisibilityEffect",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"blockValueChange",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"disableLocalSearch",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"optionsLoading",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"noWidthSync",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"portal",void 0),e([ue({reflect:!0,converter:{fromAttribute:e=>""===e||"true"===e||"false"!==e&&e,toAttribute:e=>"boolean"==typeof e?String(e):e}})],xo.prototype,"multiple",void 0),e([ue({attribute:!0,reflect:!0})],xo.prototype,"helpText",void 0),e([ue({attribute:"help-text",reflect:!0})],xo.prototype,"help_text",void 0),e([ue({type:Boolean,attribute:!0,reflect:!0})],xo.prototype,"autoResize",void 0),e([ue({attribute:"error-message",reflect:!0})],xo.prototype,"errorMessage",void 0),e([ue({type:Boolean})],xo.prototype,"warning",void 0),e([ue({type:Boolean})],xo.prototype,"error",void 0),e([ue({type:Boolean})],xo.prototype,"success",void 0),e([ue({attribute:"max-options-visible",type:Number})],xo.prototype,"maxOptionsVisible",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"disabled",void 0),e([ue({type:Boolean})],xo.prototype,"clearable",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"open",void 0),e([ue({type:Boolean})],xo.prototype,"hoist",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"filled",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"pill",void 0),e([ue()],xo.prototype,"label",void 0),e([ue({reflect:!0})],xo.prototype,"placement",void 0),e([ue({reflect:!0})],xo.prototype,"form",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"required",void 0),e([ue({type:Boolean})],xo.prototype,"showSelected",void 0),e([De()],xo.prototype,"oldMaxOptionsVisible",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"enableTabClose",void 0),e([ue({type:Boolean})],xo.prototype,"showNoResults",void 0),e([ue({type:String})],xo.prototype,"noResultsMessage",void 0),e([ue({attribute:!1})],xo.prototype,"renderItemConfig",void 0),e([ue({type:Array})],xo.prototype,"data",void 0),e([ue({type:Boolean})],xo.prototype,"enableVirtualScroll",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"enableGroupHeader",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"autoFocusSearch",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"loading",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"stickyHeader",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"descriptionSearchEnabled",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"enableDescription",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0,converter:{fromAttribute:e=>"true"===e||""===e,toAttribute:e=>String(e)}})],xo.prototype,"allowHtmlLabel",void 0),e([We("disabled",{waitUntilFirstUpdate:!0})],xo.prototype,"handleDisabledChange",null),e([We("value",{waitUntilFirstUpdate:!0})],xo.prototype,"handleValueChange",null),e([We("portal",{waitUntilFirstUpdate:!0})],xo.prototype,"handlePortalAppendChange",null),e([We("open",{waitUntilFirstUpdate:!0})],xo.prototype,"handleOpenChange",null),xo=e([ge("nile-select")],xo),_t("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),_t("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});const Oo=r`
|
|
6324
|
+
`}nileInput(e){this.emit("nile-input",e)}nileChange(e){this.emit("nile-change",e)}};xo.styles=Zn,e([he(".select")],xo.prototype,"popup",void 0),e([he(".select__combobox")],xo.prototype,"combobox",void 0),e([he(".select__display-input")],xo.prototype,"displayInput",void 0),e([he(".select__value-input")],xo.prototype,"valueInput",void 0),e([he(".select__listbox")],xo.prototype,"listbox",void 0),e([De()],xo.prototype,"hasFocus",void 0),e([De()],xo.prototype,"displayLabel",void 0),e([De()],xo.prototype,"currentOption",void 0),e([De()],xo.prototype,"selectedOptions",void 0),e([De()],xo.prototype,"oldValue",void 0),e([ue()],xo.prototype,"name",void 0),e([ue({converter:{fromAttribute:e=>e.split(" "),toAttribute:e=>e.join(" ")}})],xo.prototype,"value",void 0),e([et()],xo.prototype,"defaultValue",void 0),e([ue()],xo.prototype,"size",void 0),e([ue()],xo.prototype,"placeholder",void 0),e([De()],xo.prototype,"searchValue",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"searchEnabled",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"legacy",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"tickOnSelect",void 0),e([ue({attribute:"internal-search-placeholder"})],xo.prototype,"internalSearchPlaceHolder",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"enableVisibilityEffect",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"blockValueChange",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"disableLocalSearch",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"optionsLoading",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"noWidthSync",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"portal",void 0),e([ue({reflect:!0,converter:{fromAttribute:e=>""===e||"true"===e||"false"!==e&&e,toAttribute:e=>"boolean"==typeof e?String(e):e}})],xo.prototype,"multiple",void 0),e([ue({attribute:!0,reflect:!0})],xo.prototype,"helpText",void 0),e([ue({attribute:"help-text",reflect:!0})],xo.prototype,"help_text",void 0),e([ue({type:Boolean,attribute:!0,reflect:!0})],xo.prototype,"autoResize",void 0),e([ue({attribute:"error-message",reflect:!0})],xo.prototype,"errorMessage",void 0),e([ue({type:Boolean})],xo.prototype,"warning",void 0),e([ue({type:Boolean})],xo.prototype,"error",void 0),e([ue({type:Boolean})],xo.prototype,"success",void 0),e([ue({attribute:"max-options-visible",type:Number})],xo.prototype,"maxOptionsVisible",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"disabled",void 0),e([ue({type:Boolean})],xo.prototype,"clearable",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"open",void 0),e([ue({type:Boolean})],xo.prototype,"hoist",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"filled",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"pill",void 0),e([ue()],xo.prototype,"label",void 0),e([ue({reflect:!0})],xo.prototype,"placement",void 0),e([ue({reflect:!0})],xo.prototype,"form",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"required",void 0),e([ue({type:Boolean})],xo.prototype,"showSelected",void 0),e([De()],xo.prototype,"oldMaxOptionsVisible",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"enableTabClose",void 0),e([ue({type:Boolean})],xo.prototype,"showNoResults",void 0),e([ue({type:String})],xo.prototype,"noResultsMessage",void 0),e([ue({attribute:!1})],xo.prototype,"renderItemConfig",void 0),e([ue({type:Array})],xo.prototype,"data",void 0),e([ue({type:Boolean})],xo.prototype,"enableVirtualScroll",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"enableGroupHeader",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"autoFocusSearch",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"loading",void 0),e([ue({type:Boolean,reflect:!0})],xo.prototype,"stickyHeader",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"descriptionSearchEnabled",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],xo.prototype,"enableDescription",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0,converter:{fromAttribute:e=>"true"===e||""===e,toAttribute:e=>String(e)}})],xo.prototype,"allowHtmlLabel",void 0),e([We("disabled",{waitUntilFirstUpdate:!0})],xo.prototype,"handleDisabledChange",null),e([We("value",{waitUntilFirstUpdate:!0})],xo.prototype,"handleValueChange",null),e([We("portal",{waitUntilFirstUpdate:!0})],xo.prototype,"handlePortalAppendChange",null),e([We("open",{waitUntilFirstUpdate:!0})],xo.prototype,"handleOpenChange",null),xo=e([ge("nile-select")],xo),_t("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),_t("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});const Oo=r`
|
|
6311
6325
|
:host {
|
|
6312
6326
|
display: block;
|
|
6313
6327
|
user-select: none;
|
|
@@ -6329,12 +6343,15 @@ class no{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
6329
6343
|
line-height: var(--nile-line-height-1-8, var(--ng-line-height-text-md));
|
|
6330
6344
|
letter-spacing: normal;
|
|
6331
6345
|
color: var(--nile-color-dark-1, var(--ng-colors-text-primary-900));
|
|
6332
|
-
padding: var(--nile-spacing-sm, var(--ng-spacing-md)) var(--nile-spacing-none, var(--ng-spacing-
|
|
6346
|
+
padding: var(--nile-spacing-sm, var(--ng-spacing-md)) var(--nile-spacing-none, var(--ng-spacing-none));
|
|
6333
6347
|
transition: 150ms fill;
|
|
6334
6348
|
font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
|
|
6335
6349
|
cursor: pointer;
|
|
6336
6350
|
margin-bottom: var(--nile-spacing-none, var(--ng-spacing-xxs) )
|
|
6337
6351
|
}
|
|
6352
|
+
:host([legacy]) .option {
|
|
6353
|
+
padding: var(--nile-spacing-sm, var(--ng-spacing-md)) var(--nile-spacing-none, var(--ng-spacing-md));
|
|
6354
|
+
}
|
|
6338
6355
|
|
|
6339
6356
|
.option--single-select {
|
|
6340
6357
|
padding: var(--nile-spacing-9px, var(--ng-spacing-md)) var(--nile-spacing-lg, var(--ng-spacing-md));
|
|
@@ -6374,12 +6391,17 @@ class no{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
6374
6391
|
justify-content: center;
|
|
6375
6392
|
visibility: hidden;
|
|
6376
6393
|
padding-inline-end: var(--nile-spacing-xs);
|
|
6394
|
+
color: var(--nile-colors-primary-600, var(--ng-colors-fg-brand-primary-600));
|
|
6377
6395
|
}
|
|
6378
6396
|
|
|
6379
6397
|
.option--selected .option__check {
|
|
6380
6398
|
visibility: visible;
|
|
6381
6399
|
}
|
|
6382
6400
|
|
|
6401
|
+
:host([tickonselect][selected]) .option__check {
|
|
6402
|
+
visibility: visible;
|
|
6403
|
+
}
|
|
6404
|
+
|
|
6383
6405
|
.option__prefix,
|
|
6384
6406
|
.option__suffix {
|
|
6385
6407
|
flex: 0 0 auto;
|
|
@@ -6404,9 +6426,22 @@ class no{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
6404
6426
|
margin-left: var(--nile-spacing-lg, var(--ng-spacing-lg));
|
|
6405
6427
|
margin-right: var(--nile-spacing-lg, var(--ng-spacing-lg));
|
|
6406
6428
|
width:auto;
|
|
6429
|
+
display:var(--nile-display-inline-block, var(--ng-display-inline-block));
|
|
6430
|
+
}
|
|
6431
|
+
:host([legacy]) .option--checkbox{
|
|
6407
6432
|
display:var(--nile-display-inline-block, var(--ng-display-none));
|
|
6408
6433
|
}
|
|
6409
6434
|
|
|
6435
|
+
|
|
6436
|
+
:host([tickonselect]) .option--checkbox{
|
|
6437
|
+
display: none;
|
|
6438
|
+
}
|
|
6439
|
+
|
|
6440
|
+
:host([tickonselect]) .option{
|
|
6441
|
+
padding-left: var(--nile-spacing-lg, var(--ng-spacing-lg));
|
|
6442
|
+
padding-right: var(--nile-spacing-lg, var(--ng-spacing-lg));
|
|
6443
|
+
}
|
|
6444
|
+
|
|
6410
6445
|
|
|
6411
6446
|
@media (forced-colors: active) {
|
|
6412
6447
|
:host(:hover:not([aria-disabled='true'])) .option {
|
|
@@ -6440,7 +6475,7 @@ class no{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
6440
6475
|
display: inline-block;
|
|
6441
6476
|
width: 99%;
|
|
6442
6477
|
}
|
|
6443
|
-
`;let Lo=class extends Fe{constructor(){super(...arguments),this.current=!1,this.hasHover=!1,this.hidden=!1,this.isMultipleSelect=!1,this.value="",this.showCheckbox=!1,this.disabled=!1,this.selected=!1,this.groupName="",this.description="",this.isParentVirtualSelect=!1,this.isDescriptionEnabled=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","option"),this.setAttribute("aria-selected","false"),this.checkIfMultipleSelect()}firstUpdated(){"NILE-SELECT"!==this.parentElement?.tagName&&(this.isParentVirtualSelect=!0,this.applyWidthToLabelContainer())}applyWidthToLabelContainer(){let e=0;(this.prefixSlot?.assignedNodes({flatten:!0})??[]).length>0&&(e+=30),(this.suffixSlot?.assignedNodes({flatten:!0})??[]).length>0&&(e+=30),this.showCheckbox&&(e+=50),this.labelContainer&&(this.labelContainer.style.width=`calc(100% - ${e}px)`)}checkIfMultipleSelect(){const e=this.closest("nile-select");e&&e.hasAttribute("multiple")?e.hasAttribute("multiple")&&""===e.getAttribute("multiple")||"true"===e.getAttribute("multiple")?this.isMultipleSelect=!0:this.isMultipleSelect=!1:this.isMultipleSelect=this.showCheckbox}updated(e){this.checkIfMultipleSelect()}handleDefaultSlotChange(){const e=this.getTextLabel();void 0!==this.cachedTextLabel?e!==this.cachedTextLabel&&(this.cachedTextLabel=e,this.emit("slotchange")):this.cachedTextLabel=e}handleMouseEnter(){this.hasHover=!0}handleMouseLeave(){this.hasHover=!1}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false")}handleSelectedChange(){this.setAttribute("aria-selected",this.selected?"true":"false")}handleValueChange(){"string"!=typeof this.value&&(this.value=String(this.value))}getTextLabel(){const e=this.querySelector("label");return e?e.textContent?.trim()??"":(this.textContent??"").trim()}render(){return _`
|
|
6478
|
+
`;let Lo=class extends Fe{constructor(){super(...arguments),this.current=!1,this.hasHover=!1,this.hidden=!1,this.isMultipleSelect=!1,this.value="",this.showCheckbox=!1,this.legacy=!1,this.tickOnSelect=!1,this.disabled=!1,this.selected=!1,this.groupName="",this.description="",this.isParentVirtualSelect=!1,this.isDescriptionEnabled=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","option"),this.setAttribute("aria-selected","false"),this.checkIfMultipleSelect()}firstUpdated(){"NILE-SELECT"!==this.parentElement?.tagName&&(this.isParentVirtualSelect=!0,this.applyWidthToLabelContainer())}applyWidthToLabelContainer(){let e=0;(this.prefixSlot?.assignedNodes({flatten:!0})??[]).length>0&&(e+=30),(this.suffixSlot?.assignedNodes({flatten:!0})??[]).length>0&&(e+=30),this.showCheckbox&&(e+=50),this.labelContainer&&(this.labelContainer.style.width=`calc(100% - ${e}px)`)}checkIfMultipleSelect(){const e=this.closest("nile-select");e&&e.hasAttribute("multiple")?e.hasAttribute("multiple")&&""===e.getAttribute("multiple")||"true"===e.getAttribute("multiple")?this.isMultipleSelect=!0:this.isMultipleSelect=!1:this.isMultipleSelect=this.showCheckbox}updated(e){this.checkIfMultipleSelect()}handleDefaultSlotChange(){const e=this.getTextLabel();void 0!==this.cachedTextLabel?e!==this.cachedTextLabel&&(this.cachedTextLabel=e,this.emit("slotchange")):this.cachedTextLabel=e}handleMouseEnter(){this.hasHover=!0}handleMouseLeave(){this.hasHover=!1}handleDisabledChange(){this.setAttribute("aria-disabled",this.disabled?"true":"false")}handleSelectedChange(){this.setAttribute("aria-selected",this.selected?"true":"false")}handleValueChange(){"string"!=typeof this.value&&(this.value=String(this.value))}getTextLabel(){const e=this.querySelector("label");return e?e.textContent?.trim()??"":(this.textContent??"").trim()}render(){return _`
|
|
6444
6479
|
${this.hidden?"":_` <div
|
|
6445
6480
|
part="base"
|
|
6446
6481
|
class=${Oe({option:!0,"option--single-select":!this.isMultipleSelect,"option--current":this.selected&&!this.isMultipleSelect,"option--disabled":this.disabled,"option--selected":this.selected&&!this.isMultipleSelect,"option--hover":this.hasHover})}
|
|
@@ -6480,8 +6515,18 @@ class no{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
6480
6515
|
`}
|
|
6481
6516
|
|
|
6482
6517
|
<slot part="suffix" name="suffix" class="option__suffix"></slot>
|
|
6518
|
+
|
|
6519
|
+
${this.tickOnSelect?_`<span part="checked-icon" class="option__check">
|
|
6520
|
+
<nile-icon
|
|
6521
|
+
name="var(--nile-icon-tick, var(--ng-icon-check))"
|
|
6522
|
+
method="var(--nile-svg-method-fill, var(--ng-svg-method-stroke))"
|
|
6523
|
+
color="currentColor"
|
|
6524
|
+
library="system"
|
|
6525
|
+
aria-hidden="true"
|
|
6526
|
+
></nile-icon>
|
|
6527
|
+
</span>`:""}
|
|
6483
6528
|
</div>`}
|
|
6484
|
-
`}};Lo.styles=Oo,e([he(".option__label")],Lo.prototype,"defaultSlot",void 0),e([De()],Lo.prototype,"current",void 0),e([De()],Lo.prototype,"hasHover",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],Lo.prototype,"hidden",void 0),e([De()],Lo.prototype,"isMultipleSelect",void 0),e([ue({reflect:!0})],Lo.prototype,"value",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],Lo.prototype,"showCheckbox",void 0),e([ue({type:Boolean,reflect:!0})],Lo.prototype,"disabled",void 0),e([ue({type:Boolean,reflect:!0})],Lo.prototype,"selected",void 0),e([ue({type:String,reflect:!0,attribute:!0})],Lo.prototype,"groupName",void 0),e([ue({type:String,reflect:!0,attribute:!0})],Lo.prototype,"description",void 0),e([he('slot[name="prefix"]')],Lo.prototype,"prefixSlot",void 0),e([he('slot[name="suffix"]')],Lo.prototype,"suffixSlot",void 0),e([he(".option__label-container")],Lo.prototype,"labelContainer",void 0),e([De()],Lo.prototype,"isParentVirtualSelect",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],Lo.prototype,"isDescriptionEnabled",void 0),e([We("disabled")],Lo.prototype,"handleDisabledChange",null),e([We("selected")],Lo.prototype,"handleSelectedChange",null),e([We("value")],Lo.prototype,"handleValueChange",null),Lo=e([ge("nile-option")],Lo);const mo=r`
|
|
6529
|
+
`}};Lo.styles=Oo,e([he(".option__label")],Lo.prototype,"defaultSlot",void 0),e([De()],Lo.prototype,"current",void 0),e([De()],Lo.prototype,"hasHover",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],Lo.prototype,"hidden",void 0),e([De()],Lo.prototype,"isMultipleSelect",void 0),e([ue({reflect:!0})],Lo.prototype,"value",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],Lo.prototype,"showCheckbox",void 0),e([ue({type:Boolean,reflect:!0})],Lo.prototype,"legacy",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],Lo.prototype,"tickOnSelect",void 0),e([ue({type:Boolean,reflect:!0})],Lo.prototype,"disabled",void 0),e([ue({type:Boolean,reflect:!0})],Lo.prototype,"selected",void 0),e([ue({type:String,reflect:!0,attribute:!0})],Lo.prototype,"groupName",void 0),e([ue({type:String,reflect:!0,attribute:!0})],Lo.prototype,"description",void 0),e([he('slot[name="prefix"]')],Lo.prototype,"prefixSlot",void 0),e([he('slot[name="suffix"]')],Lo.prototype,"suffixSlot",void 0),e([he(".option__label-container")],Lo.prototype,"labelContainer",void 0),e([De()],Lo.prototype,"isParentVirtualSelect",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],Lo.prototype,"isDescriptionEnabled",void 0),e([We("disabled")],Lo.prototype,"handleDisabledChange",null),e([We("selected")],Lo.prototype,"handleSelectedChange",null),e([We("value")],Lo.prototype,"handleValueChange",null),Lo=e([ge("nile-option")],Lo);const mo=r`
|
|
6485
6530
|
:host {
|
|
6486
6531
|
box-sizing: border-box;
|
|
6487
6532
|
-webkit-font-smoothing: var(--nile-webkit-font-smoothing, var(--ng-webkit-font-smoothing));
|
|
@@ -17840,7 +17885,7 @@ nile-rich-text-editor[disabled] .editor a {
|
|
|
17840
17885
|
</span>
|
|
17841
17886
|
`:B}
|
|
17842
17887
|
</button>
|
|
17843
|
-
`}};e([ue({type:String,reflect:!0})],qS.prototype,"color",void 0),e([ue({type:Boolean,reflect:!0})],qS.prototype,"active",void 0),qS=e([ge("nile-color-swatch")],qS);"undefined"!=typeof window&&(window.nileElementsVersion='"1.8.
|
|
17888
|
+
`}};e([ue({type:String,reflect:!0})],qS.prototype,"color",void 0),e([ue({type:Boolean,reflect:!0})],qS.prototype,"active",void 0),qS=e([ge("nile-color-swatch")],qS);"undefined"!=typeof window&&(window.nileElementsVersion='"1.8.7"',window.nileVersion="__NILE_VERSION__",window.process=window.process||{env:{NODE_ENV:"production"}});const KS=r`
|
|
17844
17889
|
:host {
|
|
17845
17890
|
|
|
17846
17891
|
top: 0;
|
|
@@ -21888,6 +21933,7 @@ const Kk="important",ev=" !"+Kk,tv=Ae(class extends xe{constructor(e){if(super(e
|
|
|
21888
21933
|
part="base"
|
|
21889
21934
|
>
|
|
21890
21935
|
<div class="header" part="header">
|
|
21936
|
+
${this.renderToolbar()}
|
|
21891
21937
|
<nile-button-toggle-group
|
|
21892
21938
|
class="tabs"
|
|
21893
21939
|
aria-label="Editor view"
|
|
@@ -21910,7 +21956,6 @@ const Kk="important",ev=" !"+Kk,tv=Ae(class extends xe{constructor(e){if(super(e
|
|
|
21910
21956
|
</nile-button-toggle>
|
|
21911
21957
|
`))}
|
|
21912
21958
|
</nile-button-toggle-group>
|
|
21913
|
-
${this.renderToolbar()}
|
|
21914
21959
|
</div>
|
|
21915
21960
|
<div
|
|
21916
21961
|
class=${Oe({body:!0,"body--dragging":this.splitDragging})}
|