@aquera/nile-elements 1.1.6 → 1.1.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 +3 -0
- package/dist/index.js +5 -5
- package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
- package/dist/nile-select/index.cjs.js +1 -1
- package/dist/nile-select/index.esm.js +1 -1
- package/dist/nile-select/nile-select.test.cjs.js +1 -1
- package/dist/nile-select/nile-select.test.esm.js +1 -1
- package/dist/nile-virtual-select/index.cjs.js +1 -1
- package/dist/nile-virtual-select/index.esm.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js +2 -2
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.esm.js +13 -13
- package/dist/nile-virtual-select/portal-manager.cjs.js +1 -1
- package/dist/nile-virtual-select/portal-manager.cjs.js.map +1 -1
- package/dist/nile-virtual-select/portal-manager.esm.js +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.d.ts +1 -0
- package/dist/src/nile-virtual-select/nile-virtual-select.js +3 -0
- package/dist/src/nile-virtual-select/nile-virtual-select.js.map +1 -1
- package/dist/src/nile-virtual-select/portal-manager.d.ts +21 -2
- package/dist/src/nile-virtual-select/portal-manager.js +179 -23
- package/dist/src/nile-virtual-select/portal-manager.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-virtual-select/nile-virtual-select.ts +1 -0
- package/src/nile-virtual-select/portal-manager.ts +256 -25
- package/vscode-html-custom-data.json +1 -1
package/README.md
CHANGED
|
@@ -79,6 +79,9 @@ To run a local development server that serves the basic demo located in `demo/in
|
|
|
79
79
|
|
|
80
80
|
In this section, you can find the updates for each release of `nile-elements`. It's a good practice to maintain detailed release notes to help users and developers understand what changes have been made from one version to another and how these changes might affect their projects.
|
|
81
81
|
|
|
82
|
+
#### Version 1.1.7
|
|
83
|
+
- Nile Virtual Select: Portal feature defect fixes (UIF-986).
|
|
84
|
+
|
|
82
85
|
#### Version 1.1.6
|
|
83
86
|
- Nile Select/Virtual Select: Angular CDK overflow issue fix (UIF-986).
|
|
84
87
|
|
package/dist/index.js
CHANGED
|
@@ -4675,7 +4675,7 @@ class wi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
4675
4675
|
>
|
|
4676
4676
|
${pe(N)}
|
|
4677
4677
|
</nile-option>
|
|
4678
|
-
`}static shouldUseVirtualizer(e){return e.length>=5}}let Wi=class{constructor(e){this.portalContainer=null,this.originalListboxParent=null,this.measuredPopupHeight=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(){if(!this.portalContainer||!this.component.popup)return;this.measurePopupHeight();const{topPosition:e,placementClass:t}=this.calculatePosition();this.applyPositioning(e,t)}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="")}calculatePosition(){const e=this.component.getBoundingClientRect(),t=window.innerHeight,M=this.measuredPopupHeight||100,i=t-e.bottom,n=e.top;return i<M&&n>i?{topPosition:e.top-M-6,placementClass:"top"}:{topPosition:e.bottom+6,placementClass:"bottom"}}applyPositioning(e,t){if(!this.portalContainer)return;const M=this.component.getBoundingClientRect();this.portalContainer.style.left=`${M.left}px`,this.portalContainer.style.top=`${e}px`,this.portalContainer.style.width=`${M.width}px`,this.portalContainer.style.pointerEvents="auto",this.portalContainer.className=`nile-virtual-select-portal-append select__listbox--${t}`}updatePortalAppendPosition(){this.component.portal&&this.portalContainer&&this.positionPortalAppend()}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 M=document.createElement("style");M.id=e,M.textContent=this.extractStylesAsCSS(t),document.head.appendChild(M),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())}))}cleanupPortalAppend(){if(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)}this.portalContainer=null,this.originalListboxParent=null}get portalContainerElement(){return this.portalContainer}resetMeasuredHeight(){this.measuredPopupHeight=null}},Pi=class{constructor(e,{target:t,config:M,callback:i,skipInitial:n}){this.t=new Set,this.o=!1,this.i=!1,this.h=e,null!==t&&this.t.add(t??e),this.l=M,this.o=n??this.o,this.callback=i,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()}},Ri=class extends Re{constructor(){super(...arguments),this.formControlController=new fe(this,{assumeInteractionOn:["nile-blur","nile-input"]}),this.hasSlotController=new Ye(this,"help-text","label"),this.portalManager=new Wi(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.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.showListbox=!1,this.handleDocumentMouseDown=e=>{if(!this.open)return;const t=e.composedPath(),M=t.includes(this),i=this.popup&&t.includes(this.popup),n=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);M||i||n||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 Pi(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.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}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")}handleDocumentFocusIn(e){if(!this.open)return;const t=e.composedPath(),M=t.includes(this),i=this.popup&&t.includes(this.popup),n=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);M||i||n||this.hide()}handleDocumentKeyDown(e){this.shouldIgnoreKeyPress(e)||(this.isEscapeKey(e)&&this.handleEscapeKey(e),this.isEnterOrSpaceKey(e)&&this.handleEnterOrSpaceKey(e))}shouldIgnoreKeyPress(e){const t=e.target,M=null!==t.closest(".select__clear"),i=null!==t.closest("nile-icon-button");return M||i}isEscapeKey(e){return"Escape"===e.key&&this.open}handleEscapeKey(e){e.preventDefault(),e.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})}isEnterOrSpaceKey(e){return"Enter"===e.key||" "===e.key}handleEnterOrSpaceKey(e){e.preventDefault(),e.stopImmediatePropagation(),this.open?this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})):this.show()}handleFooterClick(e){e.stopPropagation(),e.preventDefault()}toggleShowSelected(e){if(e.stopPropagation(),e.preventDefault(),0!==this.selectedOptions?.length){if(this.showSelected=!this.showSelected,this.showSelected){const e=Array.isArray(this.value)?this.value:[this.value];this.data=this.originalOptionItems.filter((t=>{const M=this.getItemValue(t);return e.some((e=>String(e)===String(M)))}))}else this.data=[...this.originalOptionItems];this.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 M=this.value;this.oldValue=M,t&&!t.disabled&&this.handleOptionSelection(t)}shouldBlockValueChange(e){return!(!this.blockValueChange||!e)&&(this.emit("nile-block-change",{value:e?.value,name:this.name}),this.hide(),!0)}handleOptionSelection(e){const t=e.value;this.multiple?this.toggleOptionSelection(t):this.setSelectedOptions(t),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==this.oldValue&&this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name})})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0}))}setSelectedOptions(e){this.value=e,this.selectionChanged()}toggleOptionSelection(e){const t=Array.isArray(this.value)?this.value:[];t.includes(e)?this.value=t.filter((t=>t!==e)):this.value=[...t,e],this.selectionChanged()}handleTagRemove(e,t){e.stopPropagation(),this.disabled||(this.removeTagFromSelection(t),this.emitTagRemovalEvent(t))}removeTagFromSelection(e){let t=this.value;Array.isArray(t)||(t=t?[t]:[]);const M=t.filter((t=>t!==e.value));this.value=M,this.selectionChanged()}emitTagRemovalEvent(e){this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name}),this.emit("nile-tag-remove",{value:this.value,name:this.name,removedtagvalue:e.value})}))}selectionChanged(){const e=this.originalOptionItems.length>0?this.originalOptionItems:this.data;if(this.selectedOptions=ci.createVirtualOptionsFromValues(this.value,e,this.getDisplayText.bind(this),this.renderItemConfig?.getValue),this.multiple)this.placeholder&&0===this.value.length?this.displayLabel="":this.displayLabel=this.selectedOptions.length+" selected";else{const e=Array.isArray(this.value)?this.value[0]:this.value,t=this.selectedOptions[0]?.getTextLabel();this.displayLabel=t||(e??"")}this.updateValidity(),0===this.selectedOptions.length&&(this.showSelected=!1,this.filterVirtualOptions(""),this.repaintOptionsContainer()),this.calculateTotalWidthOfTags()}handleSearchFocus(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleSearchBlur(){document.addEventListener("keydown",this.handleDocumentKeyDown)}handleSearchChange(e){this.searchValue=e.detail.value,this.emit("nile-search",{query:this.searchValue,name:this.name}),this.disableLocalSearch||(this.filterVirtualOptions(this.searchValue),this.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=ji.filterVirtualOptions(e,this.originalOptionItems,this.data,this.getDisplayText.bind(this),this.renderItemConfig?.getSearchText);this.data=t.filteredItems,this.showNoResults=t.showNoResults,this.showSelected=!1,this.requestUpdate()}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e)}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}handleValueChange(){this.selectionChanged(),this.requestUpdate(),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?(await this.handleOpen(),this.showListbox=!0,this.portal&&this.portalManager.setupPortalAppend()):(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 jt(this),this.popup.active=!0;const{keyframes:e,options:t}=ht(this,"select.show",{dir:"ltr"});await Dt(this.popup.popup,e,t),this.initializeOriginalItems(),this.filterVirtualOptions(this.searchValue),this.resetScrollPosition(),this.emit("nile-after-show",{value:this.value,name:this.name})}async handleClose(){this.emit("nile-hide",{value:this.value,name:this.name}),this.removeOpenListeners(),await jt(this);const{keyframes:e,options:t}=ht(this,"select.hide",{dir:"ltr"});await Dt(this.popup.popup,e,t),this.popup.active=!1,this.searchValue="",this.portalManager.resetMeasuredHeight(),this.emit("nile-after-hide",{value:this.value,name:this.name})}initializeOriginalItems(){this.data.length>0&&(this.originalOptionItems=[...this.data])}async show(){if(!this.open&&!this.disabled)return this.open=!0,St(this,"nile-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,St(this,"nile-after-hide");this.open=!1}checkValidity(){return this.valueInput.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.valueInput.reportValidity()}setCustomValidity(e){this.valueInput.setCustomValidity(e),this.formControlController.updateValidity()}focus(e){this.displayInput.focus(e)}blur(){this.displayInput.blur()}onInputChange(e){e.stopPropagation()}render(){const e=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const t=this.hasSlotController.test("label-suffix"),M=this.hasSlotController.test("custom-select"),i=!!this.label||!!e,n=this.clearable&&!this.disabled&&this.value.length>0,o=!!this.placeholder&&0===this.value.length,r=!!this.helpText,s=!!this.errorMessage;return R`
|
|
4678
|
+
`}static shouldUseVirtualizer(e){return e.length>=5}}class Wi{static calculateAvailableSpace(e){const t=e.getBoundingClientRect(),M=window.innerHeight,i=M-t.bottom;return{spaceAbove:t.top,spaceBelow:i,viewportHeight:M}}static getOptimalPlacement(e){const{spaceAbove:t,spaceBelow:M}=this.calculateAvailableSpace(e);return M<200&&t>M?"top":"bottom"}static findBoundaryElements(e){const t=[];let M=e.parentElement;for(;M&&M!==document.body;){const e=window.getComputedStyle(M),i=e.overflow,n=e.overflowY,o=e.overflowX;"auto"!==i&&"scroll"!==i&&"auto"!==n&&"scroll"!==n&&"auto"!==o&&"scroll"!==o||t.push(M),(M.hasAttribute("data-floating-boundary")||M.classList.contains("floating-boundary")||M.classList.contains("scroll-container"))&&t.push(M),M=M.parentElement}return t.length>0?t:void 0}static calculateOptimalHeight(e,t,M){const i=t-(e.y+e.height),n=e.y;return n>i?Math.max(n-20,100):i>n?Math.max(i-20,100):Math.max(Math.min(n,i)-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:M,spaceBelow:i}=this.calculateAvailableSpace(t),n=e.startsWith("top"),o=e.startsWith("bottom");return!(n&&i>M)&&!(o&&M>i)}static applyCollisionData(e,t,M){if(t.flip){const{overflows:i}=t.flip;if(e.setAttribute("data-placement",M),i&&i.length>0){const t=i.map((e=>e.placement)).join(",");e.setAttribute("data-overflow",t)}else e.removeAttribute("data-overflow")}if(t.shift){const{x:M,y:i}=t.shift;void 0===M||void 0===i||0===M&&0===i?e.removeAttribute("data-shift"):e.setAttribute("data-shift",`${M},${i}`)}if(t.size){const{availableWidth:M,availableHeight:i}=t.size;void 0!==M&&e.setAttribute("data-available-width",M.toString()),void 0!==i&&e.setAttribute("data-available-height",i.toString())}}static createFloatingUIMiddleware(e,t){return[]}}class Pi{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 M=document.createElement("div");M.className="select__search",M.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(M)}static addLoadingSection(e,t){if(!t.optionsLoading)return;const M=document.createElement("span");M.className="select__loader",M.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(M)}static addOptionsSection(e,t){const M=document.createElement("div");M.className="select__options "+(t.searchEnabled?"select__options__search-enabled":""),this.addNoResultsMessage(M,t),this.addClonedOptions(M,t),e.appendChild(M)}static addNoResultsMessage(e,t){if(!t.showNoResults)return;const M=document.createElement("div");M.className="select__no-results",M.textContent=t.noResultsMessage,e.appendChild(M)}static addClonedOptions(e,t){Array.from(t.querySelectorAll("nile-option")).forEach((t=>{const M=this.cloneOption(t);e.appendChild(M)}))}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((M=>{void 0!==e[M]&&(t[M]=e[M])}))}static addFooterSection(e,t){if(!t.multiple)return;const M=this.createFooter(t);e.appendChild(M)}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 M=document.createElement("span");M.style.cursor="pointer";const i=document.createElement("nile-checkbox");i.disabled=0===t.selectedOptions.length,i.checked=t.showSelected,i.innerHTML=" Show Selected",M.appendChild(i),e.appendChild(M)}static addClearAllButton(e,t){if(0===t.selectedOptions.length)return;const M=document.createElement("span");M.className="select__clear",M.textContent="Clear All",M.style.cursor="pointer",e.appendChild(M)}static updateClonedOptions(e,t){const M=e.querySelector(".select__options");if(!M)return;const i=Array.from(t.querySelectorAll("nile-option")),n=Array.from(M.querySelectorAll("nile-option"));i.forEach(((e,t)=>{const M=n[t];M&&this.updateClonedOption(e,M)}))}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:M,attr:i})=>{e[M]?t.setAttribute(i,""):t.removeAttribute(i)}))}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}}class Ri{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 M=e.target.closest("nile-option");M&&this.handleOptionClick(M,t)}))}static handleOptionClick(e,t){const M=t.querySelector(`nile-option[value="${e.getAttribute("value")}"]`);if(M){const e=new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,view:window});Object.defineProperty(e,"target",{value:M,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 M=e.querySelector("nile-input");M&&(M.addEventListener("nile-input",(e=>{t.handleSearchChange&&t.handleSearchChange(e)})),M.addEventListener("nile-focus",(e=>{t.handleSearchFocus&&t.handleSearchFocus()})),M.addEventListener("nile-blur",(e=>{t.handleSearchBlur&&t.handleSearchBlur()})))}static setupFooterListeners(e,t){if(!e)return;const M=e.querySelector(".select__footer");M&&(this.setupFooterClickHandlers(M),this.setupShowSelectedToggle(M,t),this.setupClearAllHandler(M,t))}static setupFooterClickHandlers(e){e.addEventListener("click",(e=>{e.stopPropagation(),e.preventDefault()}))}static setupShowSelectedToggle(e,t){const M=e.querySelector('span[style*="cursor: pointer"]');M&&M.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 M=e.querySelector("slot");M&&M.addEventListener("slotchange",(()=>{t.updatePortalContent&&t.updatePortalContent()}))}}let Gi=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:M,y:i,placement:n,middlewareData:o}=await this.calculateFloatingUIPosition(e,t);this.applyFloatingUIPosition(t,e,M,i,n,o)}catch(e){console.warn("Floating UI positioning failed, falling back to simple positioning:",e),this.fallbackPositioning()}}async calculateFloatingUIPosition(e,t){const M=Wi.findBoundaryElements(e),i=Wi.getOptimalPlacement(e),n=this.createFloatingUIMiddleware(M);return await JM(e,t,{placement:i,strategy:"fixed",middleware:n,platform:this.createCustomPlatform()})}createFloatingUIMiddleware(e){return[GM(4),FM({apply:this.handleSizeMiddleware.bind(this),padding:10,boundary:e}),_M({fallbackPlacements:["bottom","top","bottom-start","top-start","bottom-end","top-end"],fallbackStrategy:"bestFit",padding:10,boundary:e}),BM({padding:10,crossAxis:!0,boundary:e})]}handleSizeMiddleware({availableWidth:e,availableHeight:t,elements:M,rects:i}){const n=Wi.calculateOptimalHeight(i.reference,window.innerHeight,this.currentPlacement);M.floating.style.maxWidth=`${e}px`,M.floating.style.maxHeight=`${n}px`,M.floating.style.setProperty("--auto-size-available-width",`${e}px`),M.floating.style.setProperty("--auto-size-available-height",`${n}px`)}createCustomPlatform(){return WM}applyFloatingUIPosition(e,t,M,i,n,o){Object.assign(e.style,{left:`${M}px`,top:`${i}px`,position:"fixed",pointerEvents:"auto"}),this.currentPlacement=n,this.currentMiddlewareData=o,Wi.applyCollisionData(e,o,n);const r=n.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 M=t-e.bottom,i=e.top;let n,o,r;i>M?(r=Math.max(i-20,100),n=Math.max(e.top-r-4,10),o="top"):(r=Math.max(M-20,100),n=e.bottom+4,o="bottom"),this.portalContainer.style.left=`${e.left}px`,this.portalContainer.style.top=`${n}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--${o}`,this.calculateAndSetAutoSizeProperties(e,n,o)}calculateAndSetAutoSizeProperties(e,t,M){if(!this.portalContainer)return;const i=window.innerHeight,n=window.innerWidth;let o;o="top"===M?e.top-10:i-e.bottom-10;const r=Math.min(e.width,n-e.left-10);this.portalContainer.style.setProperty("--auto-size-available-height",`${Math.max(o,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=RM(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 M=document.createElement("style");M.id=e,M.textContent=this.extractStylesAsCSS(t),document.head.appendChild(M),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}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,M=e.top,i=this.currentPlacement.startsWith("top"),n=this.currentPlacement.startsWith("bottom");return!(i&&t>M)&&!(n&&M>t)}},Bi=class{constructor(e,{target:t,config:M,callback:i,skipInitial:n}){this.t=new Set,this.o=!1,this.i=!1,this.h=e,null!==t&&this.t.add(t??e),this.l=M,this.o=n??this.o,this.callback=i,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()}},_i=class extends Re{constructor(){super(...arguments),this.formControlController=new fe(this,{assumeInteractionOn:["nile-blur","nile-input"]}),this.hasSlotController=new Ye(this,"help-text","label"),this.portalManager=new Gi(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.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.showListbox=!1,this.handleDocumentMouseDown=e=>{if(!this.open)return;const t=e.composedPath(),M=t.includes(this),i=this.popup&&t.includes(this.popup),n=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);M||i||n||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 Bi(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.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}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")}handleDocumentFocusIn(e){if(!this.open)return;const t=e.composedPath(),M=t.includes(this),i=this.popup&&t.includes(this.popup),n=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);M||i||n||this.hide()}handleDocumentKeyDown(e){this.shouldIgnoreKeyPress(e)||(this.isEscapeKey(e)&&this.handleEscapeKey(e),this.isEnterOrSpaceKey(e)&&this.handleEnterOrSpaceKey(e))}shouldIgnoreKeyPress(e){const t=e.target,M=null!==t.closest(".select__clear"),i=null!==t.closest("nile-icon-button");return M||i}isEscapeKey(e){return"Escape"===e.key&&this.open}handleEscapeKey(e){e.preventDefault(),e.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})}isEnterOrSpaceKey(e){return"Enter"===e.key||" "===e.key}handleEnterOrSpaceKey(e){e.preventDefault(),e.stopImmediatePropagation(),this.open?this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})):this.show()}handleFooterClick(e){e.stopPropagation(),e.preventDefault()}toggleShowSelected(e){if(e.stopPropagation(),e.preventDefault(),0!==this.selectedOptions?.length){if(this.showSelected=!this.showSelected,this.showSelected){const e=Array.isArray(this.value)?this.value:[this.value];this.data=this.originalOptionItems.filter((t=>{const M=this.getItemValue(t);return e.some((e=>String(e)===String(M)))}))}else this.data=[...this.originalOptionItems];this.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 M=this.value;this.oldValue=M,t&&!t.disabled&&this.handleOptionSelection(t)}shouldBlockValueChange(e){return!(!this.blockValueChange||!e)&&(this.emit("nile-block-change",{value:e?.value,name:this.name}),this.hide(),!0)}handleOptionSelection(e){const t=e.value;this.multiple?this.toggleOptionSelection(t):this.setSelectedOptions(t),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==this.oldValue&&this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name})})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0}))}setSelectedOptions(e){this.value=e,this.selectionChanged()}toggleOptionSelection(e){const t=Array.isArray(this.value)?this.value:[];t.includes(e)?this.value=t.filter((t=>t!==e)):this.value=[...t,e],this.selectionChanged()}handleTagRemove(e,t){e.stopPropagation(),this.disabled||(this.removeTagFromSelection(t),this.emitTagRemovalEvent(t))}removeTagFromSelection(e){let t=this.value;Array.isArray(t)||(t=t?[t]:[]);const M=t.filter((t=>t!==e.value));this.value=M,this.selectionChanged()}emitTagRemovalEvent(e){this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name}),this.emit("nile-tag-remove",{value:this.value,name:this.name,removedtagvalue:e.value})}))}selectionChanged(){const e=this.originalOptionItems.length>0?this.originalOptionItems:this.data;if(this.selectedOptions=ci.createVirtualOptionsFromValues(this.value,e,this.getDisplayText.bind(this),this.renderItemConfig?.getValue),this.multiple)this.placeholder&&0===this.value.length?this.displayLabel="":this.displayLabel=this.selectedOptions.length+" selected";else{const e=Array.isArray(this.value)?this.value[0]:this.value,t=this.selectedOptions[0]?.getTextLabel();this.displayLabel=t||(e??"")}this.updateValidity(),0===this.selectedOptions.length&&(this.showSelected=!1,this.filterVirtualOptions(""),this.repaintOptionsContainer()),this.calculateTotalWidthOfTags()}handleSearchFocus(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleSearchBlur(){document.addEventListener("keydown",this.handleDocumentKeyDown)}handleSearchChange(e){this.searchValue=e.detail.value,this.emit("nile-search",{query:this.searchValue,name:this.name}),this.disableLocalSearch||(this.filterVirtualOptions(this.searchValue),this.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=ji.filterVirtualOptions(e,this.originalOptionItems,this.data,this.getDisplayText.bind(this),this.renderItemConfig?.getSearchText);this.data=t.filteredItems,this.showNoResults=t.showNoResults,this.showSelected=!1,this.requestUpdate()}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e)}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}handleValueChange(){this.selectionChanged(),this.requestUpdate(),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?(await this.handleOpen(),this.showListbox=!0,this.portal&&this.portalManager.setupPortalAppend()):(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 jt(this),this.popup.active=!0;const{keyframes:e,options:t}=ht(this,"select.show",{dir:"ltr"});await Dt(this.popup.popup,e,t),this.initializeOriginalItems(),this.filterVirtualOptions(this.searchValue),this.resetScrollPosition(),this.emit("nile-after-show",{value:this.value,name:this.name})}async handleClose(){this.emit("nile-hide",{value:this.value,name:this.name}),this.removeOpenListeners(),await jt(this);const{keyframes:e,options:t}=ht(this,"select.hide",{dir:"ltr"});await Dt(this.popup.popup,e,t),this.popup.active=!1,this.searchValue="",this.portalManager.resetMeasuredHeight(),this.emit("nile-after-hide",{value:this.value,name:this.name})}initializeOriginalItems(){this.data.length>0&&(this.originalOptionItems=[...this.data])}async show(){if(!this.open&&!this.disabled)return this.open=!0,St(this,"nile-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,St(this,"nile-after-hide");this.open=!1}checkValidity(){return this.valueInput.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.valueInput.reportValidity()}setCustomValidity(e){this.valueInput.setCustomValidity(e),this.formControlController.updateValidity()}focus(e){this.displayInput.focus(e)}blur(){this.displayInput.blur()}onInputChange(e){e.stopPropagation()}render(){const e=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const t=this.hasSlotController.test("label-suffix"),M=this.hasSlotController.test("custom-select"),i=!!this.label||!!e,n=this.clearable&&!this.disabled&&this.value.length>0,o=!!this.placeholder&&0===this.value.length,r=!!this.helpText,s=!!this.errorMessage;return R`
|
|
4679
4679
|
<div
|
|
4680
4680
|
part="form-control"
|
|
4681
4681
|
class=${Le({"form-control":!0,"form-control--small":"small"===this.size,"form-control--medium":"medium"===this.size,"form-control--large":"large"===this.size,"form-control--has-label":i,"form-control--has-help-text":r})}
|
|
@@ -4911,7 +4911,7 @@ class wi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
4911
4911
|
* @license
|
|
4912
4912
|
* Copyright 2021 Google LLC
|
|
4913
4913
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
4914
|
-
*/
|
|
4914
|
+
*/_i.styles=ui,e([Ie(".select")],_i.prototype,"popup",void 0),e([Ie(".select__combobox")],_i.prototype,"combobox",void 0),e([Ie(".select__display-input")],_i.prototype,"displayInput",void 0),e([Ie(".select__value-input")],_i.prototype,"valueInput",void 0),e([Ie(".virtualized")],_i.prototype,"virtualizedContainer",void 0),e([ce()],_i.prototype,"hasFocus",void 0),e([ce()],_i.prototype,"displayLabel",void 0),e([ce()],_i.prototype,"selectedOptions",void 0),e([ce()],_i.prototype,"oldValue",void 0),e([ue()],_i.prototype,"name",void 0),e([ue({type:Array})],_i.prototype,"data",void 0),e([ce()],_i.prototype,"originalOptionItems",void 0),e([ue({converter:{fromAttribute:e=>e.split(" "),toAttribute:e=>e.join(" ")}})],_i.prototype,"value",void 0),e([Je()],_i.prototype,"defaultValue",void 0),e([ue()],_i.prototype,"size",void 0),e([ue()],_i.prototype,"placeholder",void 0),e([ue({type:Boolean})],_i.prototype,"autoResize",void 0),e([ce()],_i.prototype,"searchValue",void 0),e([ue({type:Boolean,reflect:!0})],_i.prototype,"searchEnabled",void 0),e([ue({attribute:"internal-search-placeholder"})],_i.prototype,"internalSearchPlaceHolder",void 0),e([ue({type:Boolean,reflect:!0})],_i.prototype,"disableLocalSearch",void 0),e([ue({type:Boolean,reflect:!0})],_i.prototype,"optionsLoading",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],_i.prototype,"loading",void 0),e([ue({type:Boolean,reflect:!0})],_i.prototype,"multiple",void 0),e([ue({attribute:"help-text",reflect:!0})],_i.prototype,"helpText",void 0),e([ue({attribute:"error-message",reflect:!0})],_i.prototype,"errorMessage",void 0),e([ue({type:Boolean})],_i.prototype,"warning",void 0),e([ue({type:Boolean})],_i.prototype,"error",void 0),e([ue({type:Boolean})],_i.prototype,"success",void 0),e([ue({type:Boolean,reflect:!0})],_i.prototype,"disabled",void 0),e([ue({type:Boolean,reflect:!0})],_i.prototype,"clearable",void 0),e([ue({type:Boolean,reflect:!0})],_i.prototype,"open",void 0),e([ue({type:Boolean})],_i.prototype,"hoist",void 0),e([ue({type:Boolean,reflect:!0})],_i.prototype,"filled",void 0),e([ue({type:Boolean,reflect:!0})],_i.prototype,"pill",void 0),e([ue()],_i.prototype,"label",void 0),e([ue({reflect:!0})],_i.prototype,"placement",void 0),e([ue({reflect:!0})],_i.prototype,"form",void 0),e([ue({type:Boolean,reflect:!0})],_i.prototype,"required",void 0),e([ue({type:Boolean})],_i.prototype,"showNoResults",void 0),e([ue({type:String})],_i.prototype,"noResultsMessage",void 0),e([ue({type:Boolean})],_i.prototype,"showSelected",void 0),e([ue({attribute:!1})],_i.prototype,"renderItemConfig",void 0),e([ue({type:Boolean,reflect:!0})],_i.prototype,"blockValueChange",void 0),e([ue({type:Boolean,reflect:!0})],_i.prototype,"noWidthSync",void 0),e([ue({type:Boolean,reflect:!0})],_i.prototype,"portal",void 0),e([ue({attribute:"max-options-visible",type:Number})],_i.prototype,"maxOptionsVisible",void 0),e([ce()],_i.prototype,"oldMaxOptionsVisible",void 0),e([ce()],_i.prototype,"showListbox",void 0),e([We("disabled",{waitUntilFirstUpdate:!0})],_i.prototype,"handleDisabledChange",null),e([We("value",{waitUntilFirstUpdate:!0})],_i.prototype,"handleValueChange",null),e([We("data",{waitUntilFirstUpdate:!0})],_i.prototype,"handleDataChange",null),e([We("renderItemConfig",{waitUntilFirstUpdate:!0})],_i.prototype,"handleRenderItemConfigChange",null),e([We("optionsLoading",{waitUntilFirstUpdate:!0})],_i.prototype,"handleOptionsLoadingChange",null),e([We("portal",{waitUntilFirstUpdate:!0})],_i.prototype,"handlePortalAppendChange",null),e([We("open",{waitUntilFirstUpdate:!0})],_i.prototype,"handleOpenChange",null),_i=e([le("nile-virtual-select")],_i),yt("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),yt("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});class Fi{constructor(e){this.component=e}renderVirtualizedContent(){const e=this.component;return R`
|
|
4915
4915
|
<div class="virtual-select">
|
|
4916
4916
|
<nile-virtual-select
|
|
4917
4917
|
.name=${e.name}
|
|
@@ -4972,7 +4972,7 @@ class wi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
4972
4972
|
<slot name="prefix" slot="prefix"></slot>
|
|
4973
4973
|
</nile-virtual-select>
|
|
4974
4974
|
</div>
|
|
4975
|
-
`}}class Bi{static calculateAvailableSpace(e){const t=e.getBoundingClientRect(),M=window.innerHeight,i=M-t.bottom;return{spaceAbove:t.top,spaceBelow:i,viewportHeight:M}}static getOptimalPlacement(e){const{spaceAbove:t,spaceBelow:M}=this.calculateAvailableSpace(e);return M<200&&t>M?"top":"bottom"}static findBoundaryElements(e){const t=[];let M=e.parentElement;for(;M&&M!==document.body;){const e=window.getComputedStyle(M),i=e.overflow,n=e.overflowY,o=e.overflowX;"auto"!==i&&"scroll"!==i&&"auto"!==n&&"scroll"!==n&&"auto"!==o&&"scroll"!==o||t.push(M),(M.hasAttribute("data-floating-boundary")||M.classList.contains("floating-boundary")||M.classList.contains("scroll-container"))&&t.push(M),M=M.parentElement}return t.length>0?t:void 0}static calculateOptimalHeight(e,t,M){const i=t-(e.y+e.height),n=e.y;return n>i?Math.max(n-20,100):i>n?Math.max(i-20,100):Math.max(Math.min(n,i)-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:M,spaceBelow:i}=this.calculateAvailableSpace(t),n=e.startsWith("top"),o=e.startsWith("bottom");return!(n&&i>M)&&!(o&&M>i)}static applyCollisionData(e,t,M){if(t.flip){const{overflows:i}=t.flip;if(e.setAttribute("data-placement",M),i&&i.length>0){const t=i.map((e=>e.placement)).join(",");e.setAttribute("data-overflow",t)}else e.removeAttribute("data-overflow")}if(t.shift){const{x:M,y:i}=t.shift;void 0===M||void 0===i||0===M&&0===i?e.removeAttribute("data-shift"):e.setAttribute("data-shift",`${M},${i}`)}if(t.size){const{availableWidth:M,availableHeight:i}=t.size;void 0!==M&&e.setAttribute("data-available-width",M.toString()),void 0!==i&&e.setAttribute("data-available-height",i.toString())}}static createFloatingUIMiddleware(e,t){return[]}}class _i{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 M=document.createElement("div");M.className="select__search",M.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(M)}static addLoadingSection(e,t){if(!t.optionsLoading)return;const M=document.createElement("span");M.className="select__loader",M.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(M)}static addOptionsSection(e,t){const M=document.createElement("div");M.className="select__options "+(t.searchEnabled?"select__options__search-enabled":""),this.addNoResultsMessage(M,t),this.addClonedOptions(M,t),e.appendChild(M)}static addNoResultsMessage(e,t){if(!t.showNoResults)return;const M=document.createElement("div");M.className="select__no-results",M.textContent=t.noResultsMessage,e.appendChild(M)}static addClonedOptions(e,t){Array.from(t.querySelectorAll("nile-option")).forEach((t=>{const M=this.cloneOption(t);e.appendChild(M)}))}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((M=>{void 0!==e[M]&&(t[M]=e[M])}))}static addFooterSection(e,t){if(!t.multiple)return;const M=this.createFooter(t);e.appendChild(M)}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 M=document.createElement("span");M.style.cursor="pointer";const i=document.createElement("nile-checkbox");i.disabled=0===t.selectedOptions.length,i.checked=t.showSelected,i.innerHTML=" Show Selected",M.appendChild(i),e.appendChild(M)}static addClearAllButton(e,t){if(0===t.selectedOptions.length)return;const M=document.createElement("span");M.className="select__clear",M.textContent="Clear All",M.style.cursor="pointer",e.appendChild(M)}static updateClonedOptions(e,t){const M=e.querySelector(".select__options");if(!M)return;const i=Array.from(t.querySelectorAll("nile-option")),n=Array.from(M.querySelectorAll("nile-option"));i.forEach(((e,t)=>{const M=n[t];M&&this.updateClonedOption(e,M)}))}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:M,attr:i})=>{e[M]?t.setAttribute(i,""):t.removeAttribute(i)}))}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}}class Fi{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 M=e.target.closest("nile-option");M&&this.handleOptionClick(M,t)}))}static handleOptionClick(e,t){const M=t.querySelector(`nile-option[value="${e.getAttribute("value")}"]`);if(M){const e=new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,view:window});Object.defineProperty(e,"target",{value:M,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 M=e.querySelector("nile-input");M&&(M.addEventListener("nile-input",(e=>{t.handleSearchChange&&t.handleSearchChange(e)})),M.addEventListener("nile-focus",(e=>{t.handleSearchFocus&&t.handleSearchFocus()})),M.addEventListener("nile-blur",(e=>{t.handleSearchBlur&&t.handleSearchBlur()})))}static setupFooterListeners(e,t){if(!e)return;const M=e.querySelector(".select__footer");M&&(this.setupFooterClickHandlers(M),this.setupShowSelectedToggle(M,t),this.setupClearAllHandler(M,t))}static setupFooterClickHandlers(e){e.addEventListener("click",(e=>{e.stopPropagation(),e.preventDefault()}))}static setupShowSelectedToggle(e,t){const M=e.querySelector('span[style*="cursor: pointer"]');M&&M.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 M=e.querySelector("slot");M&&M.addEventListener("slotchange",(()=>{t.updatePortalContent&&t.updatePortalContent()}))}}class Hi{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:M,y:i,placement:n,middlewareData:o}=await this.calculateFloatingUIPosition(e,t);this.applyFloatingUIPosition(t,e,M,i,n,o)}catch(e){console.warn("Floating UI positioning failed, falling back to simple positioning:",e),this.fallbackPositioning()}}async calculateFloatingUIPosition(e,t){const M=Bi.findBoundaryElements(e),i=Bi.getOptimalPlacement(e),n=this.createFloatingUIMiddleware(M);return await JM(e,t,{placement:i,strategy:"fixed",middleware:n,platform:this.createCustomPlatform()})}createFloatingUIMiddleware(e){return[GM(4),FM({apply:this.handleSizeMiddleware.bind(this),padding:10,boundary:e}),_M({fallbackPlacements:["bottom","top","bottom-start","top-start","bottom-end","top-end"],fallbackStrategy:"bestFit",padding:10,boundary:e}),BM({padding:10,crossAxis:!0,boundary:e})]}handleSizeMiddleware({availableWidth:e,availableHeight:t,elements:M,rects:i}){const n=Bi.calculateOptimalHeight(i.reference,window.innerHeight,this.currentPlacement);M.floating.style.maxWidth=`${e}px`,M.floating.style.maxHeight=`${n}px`,M.floating.style.setProperty("--auto-size-available-width",`${e}px`),M.floating.style.setProperty("--auto-size-available-height",`${n}px`)}createCustomPlatform(){return WM}applyFloatingUIPosition(e,t,M,i,n,o){Object.assign(e.style,{left:`${M}px`,top:`${i}px`,position:"fixed",pointerEvents:"auto"}),this.currentPlacement=n,this.currentMiddlewareData=o,Bi.applyCollisionData(e,o,n);const r=n.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 M=t-e.bottom,i=e.top;let n,o,r;i>M?(r=Math.max(i-20,100),n=Math.max(e.top-r-4,10),o="top"):(r=Math.max(M-20,100),n=e.bottom+4,o="bottom"),this.portalContainer.style.left=`${e.left}px`,this.portalContainer.style.top=`${n}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--${o}`,this.calculateAndSetAutoSizeProperties(e,n,o)}calculateAndSetAutoSizeProperties(e,t,M){if(!this.portalContainer)return;const i=window.innerHeight,n=window.innerWidth;let o;o="top"===M?e.top-10:i-e.bottom-10;const r=Math.min(e.width,n-e.left-10);this.portalContainer.style.setProperty("--auto-size-available-height",`${Math.max(o,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=RM(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=Bi.generateStyleId();if(document.getElementById(e))return;const t=this.component.constructor.styles;if(!t)return;const M=document.createElement("style");M.id=e,M.textContent=Bi.extractStylesAsCSS(t),document.head.appendChild(M),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 _i.createPortalListbox(this.component)}setupPortalEventListeners(){Fi.setupPortalEventListeners(this.clonedListbox,this.component)}updatePortalContent(){this.clonedListbox&&(_i.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 M=e.querySelector(".select__clear");if(0===this.component.selectedOptions.length)M&&M.remove();else if(!M){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,M=e.top,i=this.currentPlacement.startsWith("top"),n=this.currentPlacement.startsWith("bottom");return!(i&&t>M)&&!(n&&M>t)}}let Ji=class extends Re{get validity(){return this.valueInput?.validity}get validationMessage(){return this.valueInput?.validationMessage}constructor(){super(),this.portalManager=new Hi(this),this.hasSlotController=new Ye(this,"help-text","label"),this.typeToSelectString="",this.scrolling=!1,this.options=[],this.hasFocus=!1,this.displayLabel="",this.selectedOptions=[],this.oldValue="",this.name="",this.value="",this.defaultValue="",this.size="medium",this.placeholder="Select...",this.searchValue="",this.searchEnabled=!1,this.internalSearchPlaceHolder="Search...",this.blockValueChange=!1,this.disableLocalSearch=!1,this.optionsLoading=!1,this.noWidthSync=!1,this.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.showNoResults=!1,this.noResultsMessage="No results found",this.data=[],this.enableVirtualScroll=!1,this.enableGroupHeader=!1,this.autoFocusSearch=!1,this.loading=!1,this.handleWindowResize=()=>{this.portalManager.updatePortalAppendPosition()},this.handleWindowScroll=()=>{this.portalManager.updatePortalAppendPosition()}}connectedCallback(){super.connectedCallback(),this.enableVirtualScroll||(this.formControlController=new fe(this,{assumeInteractionOn:["nile-blur","nile-input"]})),this.virtualScrollHelper=new Gi(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.portalManager.cleanupPortalAppend(),this.emit("nile-destroy")}setupResizeObserver(){if(this.autoResize){const e=this.shadowRoot?.querySelector(".select__tags");e&&(this.resizeController=new Pi(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("multiple")&&this.setCheckBoxInOption(this.multiple),e.has("autoResize")&&this.setupResizeObserver()}firstUpdated(e){this.enableGroupHeader&&this.handleGroupSearchChange(),this.setupResizeObserver(),e.has("multiple")&&this.setCheckBoxInOption(this.multiple)}setCheckBoxInOption(e){this.options.length||(this.options=this.getAllOptions()),this.options.forEach((t=>{t.showCheckbox=e}))}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown),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(),M=t.includes(this),i=this.popup&&t.includes(this.popup),n=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);M||i||n||this.hide()}handleFooterClick(e){e.stopPropagation(),e.preventDefault()}toggleShowSelected(e){if(e.stopPropagation(),e.preventDefault(),0===this.selectedOptions?.length)return;this.showSelected=!this.showSelected;this.getAllOptions().forEach((e=>{e.selected||(e.hidden=this.showSelected)})),this.enableGroupHeader&&this.handleGroupShowSelected(),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,M=null!==t.closest(".select__clear"),i=null!==t.closest("nile-icon-button");if(!M&&!i){if("Escape"===e.key&&this.open&&(e.preventDefault(),e.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})),"Enter"===e.key||" "===e.key&&""===this.typeToSelectString)return e.preventDefault(),e.stopImmediatePropagation(),this.open?void(this.currentOption&&!this.currentOption.disabled&&(this.multiple?this.toggleOptionSelection(this.currentOption):this.setSelectedOptions(this.currentOption),this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name})})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))):void this.show();if(1===e.key.length||"Backspace"===e.key){const t=this.getAllOptions();if(e.metaKey||e.ctrlKey||e.altKey)return;if(!this.open){if("Backspace"===e.key)return;this.show()}e.stopPropagation(),e.preventDefault(),clearTimeout(this.typeToSelectTimeout),this.typeToSelectTimeout=window.setTimeout((()=>this.typeToSelectString=""),1e3),"Backspace"===e.key?this.typeToSelectString=this.typeToSelectString.slice(0,-1):this.typeToSelectString+=e.key.toLowerCase();for(const e of t){if(e.getTextLabel().toLowerCase().startsWith(this.typeToSelectString)){this.setCurrentOption(e);break}}}}}handleDocumentMouseDown(e){if(!this.open)return;const t=e.composedPath(),M=t.includes(this),i=this.popup&&t.includes(this.popup),n=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);M||i||n||this.hide()}handleLabelClick(){this.displayInput.focus(),this.hide()}handleComboboxMouseDown(e){const t=e.composedPath().some((e=>e instanceof Element&&"nile-icon-button"===e.tagName.toLowerCase()));this.disabled||t||(e.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open)}handleComboboxKeyDown(e){e.stopPropagation(),this.handleDocumentKeyDown(e)}handleClearClick(e){e.stopPropagation(),""!==this.value&&(this.setSelectedOptions([]),this.showSelected=!1,this.value="",this.displayInput.focus({preventScroll:!0}),this.enableGroupHeader&&this.handleGroupShowSelected(),this.updateComplete.then((()=>{const e={value:this.multiple?this.value:"",name:this.name};this.emit("nile-clear",e),this.nileInput(e),this.nileChange(e)})))}handleClearMouseDown(e){e.stopPropagation(),e.preventDefault()}handleOptionClick(e){const t=e.target.closest("nile-option");if(this.blockValueChange&&t)return this.emit("nile-block-change",{value:t?.value,name:this.name}),void this.hide();const M=this.value;if(this.oldValue=M,t&&!t.disabled&&(this.multiple?this.toggleOptionSelection(t):this.setSelectedOptions(t),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==M&&this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name})})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0}))),this.showSelected){this.getAllOptions().forEach((e=>{e.selected||(e.hidden=this.showSelected)})),this.enableGroupHeader&&this.handleGroupShowSelected(),this.requestUpdate()}this.portal&&this.open&&this.portalManager.updatePortalOptions()}handleDefaultSlotChange(){const e=this.getAllOptions(),t=Array.isArray(this.value)?this.value:[this.value],M=[];customElements.get("nile-option")?(e.forEach((e=>M.push(e.value))),this.setSelectedOptions(e.filter((e=>t.map(String).includes(e.value))))):customElements.whenDefined("nile-option").then((()=>this.handleDefaultSlotChange())),this.portal&&this.open&&this.portalManager.updatePortalOptions()}handleTagRemove(e,t){if(e.stopPropagation(),!this.disabled){this.toggleOptionSelection(t,!1);this.getAllOptions().forEach((e=>{e.selected||(e.hidden=this.showSelected)})),this.enableGroupHeader&&this.handleGroupShowSelected(),this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name}),this.emit("nile-tag-remove",{value:this.value,name:this.name,removedtagvalue:t.value})}))}}getAllOptions(){const e=[...this.querySelectorAll("nile-option")];return this.multiple&&this.oldValue?.length>0&&e.sort(((e,t)=>{let M=this.oldValue.indexOf(e.value),i=this.oldValue.indexOf(t.value);return-1===M&&(M=1/0),-1===i&&(i=1/0),M<i?-1:M>i?1:0})),e}getOptionPrefix(e){const t=e.shadowRoot?.querySelector('slot[name="prefix"]');if(!t)return"";const M=t.assignedNodes(),i=[];return M.forEach((e=>{e instanceof HTMLElement?i.push(e.outerHTML):e.nodeType===Node.TEXT_NODE&&i.push(e.textContent||"")})),i.join("")}getFirstOption(){return this.querySelector("nile-option")}setCurrentOption(e){this.getAllOptions().forEach((e=>{e.current=!1,e.tabIndex=-1})),e&&(this.currentOption=e,e.current=!0,e.tabIndex=0,e.focus())}setSelectedOptions(e){const t=this.getAllOptions(),M=Array.isArray(e)?e:[e];t.forEach((e=>e.selected=!1)),M.length&&M.forEach((e=>e.selected=!0)),this.selectionChanged(),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.handleGroupSearchChange(),!this.disableLocalSearch){0===this.filterOptions(this.searchValue).length?this.showNoResults=!0:this.showNoResults=!1}}handleScroll(e){const t=e.target;this.emit("nile-scroll",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name}),this.scrolling||(this.scrolling=!0,this.emit("nile-scroll-start",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name})),clearTimeout(this.scrollTimeout),this.scrollTimeout=window.setTimeout((()=>{this.scrolling&&(this.scrolling=!1)}),300);Math.ceil(t.scrollTop)>=Math.floor(t.scrollHeight-t.offsetHeight)&&this.emit("nile-scroll-end",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name,isAtBottom:!0})}filterOptions(e){const t=this.getAllOptions(),M=e.toLowerCase();let i=[];return t.forEach((e=>{const t=e.getTextLabel().toLowerCase(),n=(e.value||"").toLowerCase();t.includes(M)||n.includes(M)?(e.hidden=!1,i.push(e)):e.hidden=!0})),this.portal&&this.open&&this.portalManager.updatePortalOptions(),i}handleInvalid(e){this.formControlController?.setValidity(!1),this.formControlController?.emitInvalidEvent(e)}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}handleValueChange(){const e=this.getAllOptions(),t=Array.isArray(this.value)?this.value:[this.value];this.enableVirtualScroll||this.setSelectedOptions(e.filter((e=>t.includes(e.value))))}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.showNoResults=!this.getAllOptions()?.length,await jt(this),this.listbox.hidden=!1,this.popup.active=!0,requestAnimationFrame((()=>{this.setCurrentOption(this.currentOption)}));const{keyframes:e,options:t}=ht(this,"select.show",{dir:"ltr"});await Dt(this.popup.popup,e,t),this.currentOption&&xt(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(),await jt(this);const{keyframes:e,options:t}=ht(this,"select.hide",{dir:"ltr"});await Dt(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:M})=>{M?.classList.toggle("nile-group-hidden",!e.has(t))}))}handleGroupShowSelected(){const e=new Set;this.showSelected&&this.getAllOptions().forEach((t=>{t.hidden||e.add(t.groupName)})),this.getAllGroupAttributes().forEach((({name:t,element:M})=>{M?.classList.toggle("nile-group-hidden",this.showSelected&&!e.has(t))}))}async show(){if(!this.open&&!this.disabled)return this.open=!0,St(this,"nile-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,St(this,"nile-after-hide");this.open=!1}checkValidity(){return this.valueInput.checkValidity()}getForm(){return this.formControlController?.getForm()||null}reportValidity(){return this.valueInput.reportValidity()}setCustomValidity(e){this.valueInput.setCustomValidity(e),this.formControlController?.updateValidity()}focus(e){this.displayInput.focus(e)}blur(){this.displayInput.blur()}onInputChange(e){e.stopPropagation()}calculateWidthOfSelectTagsDiv(){if(this.shadowRoot){const e=this.shadowRoot.querySelector("div.select__tags");if(e instanceof HTMLElement){return e.offsetWidth-70}}}calculateTotalWidthOfTags(){this.maxOptionsVisible!==1/0&&(this.oldMaxOptionsVisible=this.maxOptionsVisible),this.maxOptionsVisible=1/0,setTimeout((()=>{let e=[];if(this.shadowRoot){this.shadowRoot.querySelectorAll("nile-tag").forEach((t=>{t instanceof HTMLElement&&e.push(t.offsetWidth)}))}if(this.value.length!==e.length)return;const t=this.calculateWidthOfSelectTagsDiv();if(!t)return;let M=0,i=0;for(let n=0;n<e.length;n++)if(M+=e[n],M>t){i=n;break}this.maxOptionsVisible=i}),1)}handleInputAfterInit(){this.shadowRoot?.querySelector("nile-input")?.inputFocus()}render(){if(this.enableVirtualScroll)return this.virtualScrollHelper.renderVirtualizedContent();const e=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const t=this.hasSlotController.test("label-suffix"),M=this.hasSlotController.test("custom-select"),i=!!this.label||!!e,n=this.clearable&&!this.disabled&&this.value.length>0,o=this.placeholder&&0===this.value.length,r=!(!this.helpText&&!this.help_text),s=!!this.errorMessage,a=this.selectedOptions[0]?this.getOptionPrefix(this.selectedOptions[0]):"";return R`
|
|
4975
|
+
`}}class Hi{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:M,y:i,placement:n,middlewareData:o}=await this.calculateFloatingUIPosition(e,t);this.applyFloatingUIPosition(t,e,M,i,n,o)}catch(e){console.warn("Floating UI positioning failed, falling back to simple positioning:",e),this.fallbackPositioning()}}async calculateFloatingUIPosition(e,t){const M=Wi.findBoundaryElements(e),i=Wi.getOptimalPlacement(e),n=this.createFloatingUIMiddleware(M);return await JM(e,t,{placement:i,strategy:"fixed",middleware:n,platform:this.createCustomPlatform()})}createFloatingUIMiddleware(e){return[GM(4),FM({apply:this.handleSizeMiddleware.bind(this),padding:10,boundary:e}),_M({fallbackPlacements:["bottom","top","bottom-start","top-start","bottom-end","top-end"],fallbackStrategy:"bestFit",padding:10,boundary:e}),BM({padding:10,crossAxis:!0,boundary:e})]}handleSizeMiddleware({availableWidth:e,availableHeight:t,elements:M,rects:i}){const n=Wi.calculateOptimalHeight(i.reference,window.innerHeight,this.currentPlacement);M.floating.style.maxWidth=`${e}px`,M.floating.style.maxHeight=`${n}px`,M.floating.style.setProperty("--auto-size-available-width",`${e}px`),M.floating.style.setProperty("--auto-size-available-height",`${n}px`)}createCustomPlatform(){return WM}applyFloatingUIPosition(e,t,M,i,n,o){Object.assign(e.style,{left:`${M}px`,top:`${i}px`,position:"fixed",pointerEvents:"auto"}),this.currentPlacement=n,this.currentMiddlewareData=o,Wi.applyCollisionData(e,o,n);const r=n.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 M=t-e.bottom,i=e.top;let n,o,r;i>M?(r=Math.max(i-20,100),n=Math.max(e.top-r-4,10),o="top"):(r=Math.max(M-20,100),n=e.bottom+4,o="bottom"),this.portalContainer.style.left=`${e.left}px`,this.portalContainer.style.top=`${n}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--${o}`,this.calculateAndSetAutoSizeProperties(e,n,o)}calculateAndSetAutoSizeProperties(e,t,M){if(!this.portalContainer)return;const i=window.innerHeight,n=window.innerWidth;let o;o="top"===M?e.top-10:i-e.bottom-10;const r=Math.min(e.width,n-e.left-10);this.portalContainer.style.setProperty("--auto-size-available-height",`${Math.max(o,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=RM(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=Wi.generateStyleId();if(document.getElementById(e))return;const t=this.component.constructor.styles;if(!t)return;const M=document.createElement("style");M.id=e,M.textContent=Wi.extractStylesAsCSS(t),document.head.appendChild(M),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 Pi.createPortalListbox(this.component)}setupPortalEventListeners(){Ri.setupPortalEventListeners(this.clonedListbox,this.component)}updatePortalContent(){this.clonedListbox&&(Pi.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 M=e.querySelector(".select__clear");if(0===this.component.selectedOptions.length)M&&M.remove();else if(!M){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,M=e.top,i=this.currentPlacement.startsWith("top"),n=this.currentPlacement.startsWith("bottom");return!(i&&t>M)&&!(n&&M>t)}}let Ji=class extends Re{get validity(){return this.valueInput?.validity}get validationMessage(){return this.valueInput?.validationMessage}constructor(){super(),this.portalManager=new Hi(this),this.hasSlotController=new Ye(this,"help-text","label"),this.typeToSelectString="",this.scrolling=!1,this.options=[],this.hasFocus=!1,this.displayLabel="",this.selectedOptions=[],this.oldValue="",this.name="",this.value="",this.defaultValue="",this.size="medium",this.placeholder="Select...",this.searchValue="",this.searchEnabled=!1,this.internalSearchPlaceHolder="Search...",this.blockValueChange=!1,this.disableLocalSearch=!1,this.optionsLoading=!1,this.noWidthSync=!1,this.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.showNoResults=!1,this.noResultsMessage="No results found",this.data=[],this.enableVirtualScroll=!1,this.enableGroupHeader=!1,this.autoFocusSearch=!1,this.loading=!1,this.handleWindowResize=()=>{this.portalManager.updatePortalAppendPosition()},this.handleWindowScroll=()=>{this.portalManager.updatePortalAppendPosition()}}connectedCallback(){super.connectedCallback(),this.enableVirtualScroll||(this.formControlController=new fe(this,{assumeInteractionOn:["nile-blur","nile-input"]})),this.virtualScrollHelper=new Fi(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.portalManager.cleanupPortalAppend(),this.emit("nile-destroy")}setupResizeObserver(){if(this.autoResize){const e=this.shadowRoot?.querySelector(".select__tags");e&&(this.resizeController=new Bi(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("multiple")&&this.setCheckBoxInOption(this.multiple),e.has("autoResize")&&this.setupResizeObserver()}firstUpdated(e){this.enableGroupHeader&&this.handleGroupSearchChange(),this.setupResizeObserver(),e.has("multiple")&&this.setCheckBoxInOption(this.multiple)}setCheckBoxInOption(e){this.options.length||(this.options=this.getAllOptions()),this.options.forEach((t=>{t.showCheckbox=e}))}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown),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(),M=t.includes(this),i=this.popup&&t.includes(this.popup),n=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);M||i||n||this.hide()}handleFooterClick(e){e.stopPropagation(),e.preventDefault()}toggleShowSelected(e){if(e.stopPropagation(),e.preventDefault(),0===this.selectedOptions?.length)return;this.showSelected=!this.showSelected;this.getAllOptions().forEach((e=>{e.selected||(e.hidden=this.showSelected)})),this.enableGroupHeader&&this.handleGroupShowSelected(),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,M=null!==t.closest(".select__clear"),i=null!==t.closest("nile-icon-button");if(!M&&!i){if("Escape"===e.key&&this.open&&(e.preventDefault(),e.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})),"Enter"===e.key||" "===e.key&&""===this.typeToSelectString)return e.preventDefault(),e.stopImmediatePropagation(),this.open?void(this.currentOption&&!this.currentOption.disabled&&(this.multiple?this.toggleOptionSelection(this.currentOption):this.setSelectedOptions(this.currentOption),this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name})})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})))):void this.show();if(1===e.key.length||"Backspace"===e.key){const t=this.getAllOptions();if(e.metaKey||e.ctrlKey||e.altKey)return;if(!this.open){if("Backspace"===e.key)return;this.show()}e.stopPropagation(),e.preventDefault(),clearTimeout(this.typeToSelectTimeout),this.typeToSelectTimeout=window.setTimeout((()=>this.typeToSelectString=""),1e3),"Backspace"===e.key?this.typeToSelectString=this.typeToSelectString.slice(0,-1):this.typeToSelectString+=e.key.toLowerCase();for(const e of t){if(e.getTextLabel().toLowerCase().startsWith(this.typeToSelectString)){this.setCurrentOption(e);break}}}}}handleDocumentMouseDown(e){if(!this.open)return;const t=e.composedPath(),M=t.includes(this),i=this.popup&&t.includes(this.popup),n=this.portal&&this.portalManager.portalContainerElement&&t.includes(this.portalManager.portalContainerElement);M||i||n||this.hide()}handleLabelClick(){this.displayInput.focus(),this.hide()}handleComboboxMouseDown(e){const t=e.composedPath().some((e=>e instanceof Element&&"nile-icon-button"===e.tagName.toLowerCase()));this.disabled||t||(e.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open)}handleComboboxKeyDown(e){e.stopPropagation(),this.handleDocumentKeyDown(e)}handleClearClick(e){e.stopPropagation(),""!==this.value&&(this.setSelectedOptions([]),this.showSelected=!1,this.value="",this.displayInput.focus({preventScroll:!0}),this.enableGroupHeader&&this.handleGroupShowSelected(),this.updateComplete.then((()=>{const e={value:this.multiple?this.value:"",name:this.name};this.emit("nile-clear",e),this.nileInput(e),this.nileChange(e)})))}handleClearMouseDown(e){e.stopPropagation(),e.preventDefault()}handleOptionClick(e){const t=e.target.closest("nile-option");if(this.blockValueChange&&t)return this.emit("nile-block-change",{value:t?.value,name:this.name}),void this.hide();const M=this.value;if(this.oldValue=M,t&&!t.disabled&&(this.multiple?this.toggleOptionSelection(t):this.setSelectedOptions(t),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==M&&this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name})})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0}))),this.showSelected){this.getAllOptions().forEach((e=>{e.selected||(e.hidden=this.showSelected)})),this.enableGroupHeader&&this.handleGroupShowSelected(),this.requestUpdate()}this.portal&&this.open&&this.portalManager.updatePortalOptions()}handleDefaultSlotChange(){const e=this.getAllOptions(),t=Array.isArray(this.value)?this.value:[this.value],M=[];customElements.get("nile-option")?(e.forEach((e=>M.push(e.value))),this.setSelectedOptions(e.filter((e=>t.map(String).includes(e.value))))):customElements.whenDefined("nile-option").then((()=>this.handleDefaultSlotChange())),this.portal&&this.open&&this.portalManager.updatePortalOptions()}handleTagRemove(e,t){if(e.stopPropagation(),!this.disabled){this.toggleOptionSelection(t,!1);this.getAllOptions().forEach((e=>{e.selected||(e.hidden=this.showSelected)})),this.enableGroupHeader&&this.handleGroupShowSelected(),this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name}),this.emit("nile-tag-remove",{value:this.value,name:this.name,removedtagvalue:t.value})}))}}getAllOptions(){const e=[...this.querySelectorAll("nile-option")];return this.multiple&&this.oldValue?.length>0&&e.sort(((e,t)=>{let M=this.oldValue.indexOf(e.value),i=this.oldValue.indexOf(t.value);return-1===M&&(M=1/0),-1===i&&(i=1/0),M<i?-1:M>i?1:0})),e}getOptionPrefix(e){const t=e.shadowRoot?.querySelector('slot[name="prefix"]');if(!t)return"";const M=t.assignedNodes(),i=[];return M.forEach((e=>{e instanceof HTMLElement?i.push(e.outerHTML):e.nodeType===Node.TEXT_NODE&&i.push(e.textContent||"")})),i.join("")}getFirstOption(){return this.querySelector("nile-option")}setCurrentOption(e){this.getAllOptions().forEach((e=>{e.current=!1,e.tabIndex=-1})),e&&(this.currentOption=e,e.current=!0,e.tabIndex=0,e.focus())}setSelectedOptions(e){const t=this.getAllOptions(),M=Array.isArray(e)?e:[e];t.forEach((e=>e.selected=!1)),M.length&&M.forEach((e=>e.selected=!0)),this.selectionChanged(),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.handleGroupSearchChange(),!this.disableLocalSearch){0===this.filterOptions(this.searchValue).length?this.showNoResults=!0:this.showNoResults=!1}}handleScroll(e){const t=e.target;this.emit("nile-scroll",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name}),this.scrolling||(this.scrolling=!0,this.emit("nile-scroll-start",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name})),clearTimeout(this.scrollTimeout),this.scrollTimeout=window.setTimeout((()=>{this.scrolling&&(this.scrolling=!1)}),300);Math.ceil(t.scrollTop)>=Math.floor(t.scrollHeight-t.offsetHeight)&&this.emit("nile-scroll-end",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name,isAtBottom:!0})}filterOptions(e){const t=this.getAllOptions(),M=e.toLowerCase();let i=[];return t.forEach((e=>{const t=e.getTextLabel().toLowerCase(),n=(e.value||"").toLowerCase();t.includes(M)||n.includes(M)?(e.hidden=!1,i.push(e)):e.hidden=!0})),this.portal&&this.open&&this.portalManager.updatePortalOptions(),i}handleInvalid(e){this.formControlController?.setValidity(!1),this.formControlController?.emitInvalidEvent(e)}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}handleValueChange(){const e=this.getAllOptions(),t=Array.isArray(this.value)?this.value:[this.value];this.enableVirtualScroll||this.setSelectedOptions(e.filter((e=>t.includes(e.value))))}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.showNoResults=!this.getAllOptions()?.length,await jt(this),this.listbox.hidden=!1,this.popup.active=!0,requestAnimationFrame((()=>{this.setCurrentOption(this.currentOption)}));const{keyframes:e,options:t}=ht(this,"select.show",{dir:"ltr"});await Dt(this.popup.popup,e,t),this.currentOption&&xt(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(),await jt(this);const{keyframes:e,options:t}=ht(this,"select.hide",{dir:"ltr"});await Dt(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:M})=>{M?.classList.toggle("nile-group-hidden",!e.has(t))}))}handleGroupShowSelected(){const e=new Set;this.showSelected&&this.getAllOptions().forEach((t=>{t.hidden||e.add(t.groupName)})),this.getAllGroupAttributes().forEach((({name:t,element:M})=>{M?.classList.toggle("nile-group-hidden",this.showSelected&&!e.has(t))}))}async show(){if(!this.open&&!this.disabled)return this.open=!0,St(this,"nile-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,St(this,"nile-after-hide");this.open=!1}checkValidity(){return this.valueInput.checkValidity()}getForm(){return this.formControlController?.getForm()||null}reportValidity(){return this.valueInput.reportValidity()}setCustomValidity(e){this.valueInput.setCustomValidity(e),this.formControlController?.updateValidity()}focus(e){this.displayInput.focus(e)}blur(){this.displayInput.blur()}onInputChange(e){e.stopPropagation()}calculateWidthOfSelectTagsDiv(){if(this.shadowRoot){const e=this.shadowRoot.querySelector("div.select__tags");if(e instanceof HTMLElement){return e.offsetWidth-70}}}calculateTotalWidthOfTags(){this.maxOptionsVisible!==1/0&&(this.oldMaxOptionsVisible=this.maxOptionsVisible),this.maxOptionsVisible=1/0,setTimeout((()=>{let e=[];if(this.shadowRoot){this.shadowRoot.querySelectorAll("nile-tag").forEach((t=>{t instanceof HTMLElement&&e.push(t.offsetWidth)}))}if(this.value.length!==e.length)return;const t=this.calculateWidthOfSelectTagsDiv();if(!t)return;let M=0,i=0;for(let n=0;n<e.length;n++)if(M+=e[n],M>t){i=n;break}this.maxOptionsVisible=i}),1)}handleInputAfterInit(){this.shadowRoot?.querySelector("nile-input")?.inputFocus()}render(){if(this.enableVirtualScroll)return this.virtualScrollHelper.renderVirtualizedContent();const e=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const t=this.hasSlotController.test("label-suffix"),M=this.hasSlotController.test("custom-select"),i=!!this.label||!!e,n=this.clearable&&!this.disabled&&this.value.length>0,o=this.placeholder&&0===this.value.length,r=!(!this.helpText&&!this.help_text),s=!!this.errorMessage,a=this.selectedOptions[0]?this.getOptionPrefix(this.selectedOptions[0]):"";return R`
|
|
4976
4976
|
<div
|
|
4977
4977
|
part="form-control"
|
|
4978
4978
|
class=${Le({"form-control":!0,"form-control--small":"small"===this.size,"form-control--medium":"medium"===this.size,"form-control--large":"large"===this.size,"form-control--has-label":i,"form-control--has-help-text":r})}
|
|
@@ -14011,7 +14011,7 @@ nile-rte-toolbar-item nile-button[data-active]::part(base):hover {
|
|
|
14011
14011
|
|
|
14012
14012
|
|
|
14013
14013
|
|
|
14014
|
-
`,rS={bold:"format_bold",italic:"format_italic",underline:"format_underline",link:"link_2",left:"format_align_left",center:"format_align_middle",right:"format_align_right",justify:"format_align_justify",ul:"format_list_bulleted",ol:"format_list_numbered",clear:"format_clear"};let sS=class extends ae{constructor(){super(...arguments),this.value="",this.noStyles=!1,this.singleLineEditor=!1,this.mentions={},this.content="",this.previewEl=null,this.toolbarEl=null,this.lastRange=null,this.buttonMap=new Map,this.headingSelect=null,this.fontSelect=null,this.colorInput=null,this.bgColorInput=null,this.colorSwatchEl=null,this.bgSwatchEl=null,this.containerEl=null,this.mentionsEl=null,this.onEditorKeydown=e=>{if(this.singleLineEditor&&"Enter"===e.key&&e.shiftKey)return void e.preventDefault();if(e.ctrlKey&&"i"===e.key.toLowerCase()&&(e.preventDefault(),qp(this.editorEl,"em"),this.updateContent(),this.updateToolbarState()),this.singleLineEditor&&"Enter"===e.key)return void e.preventDefault();if("Tab"!==e.key)return;e.preventDefault(),this.focusAndRestore();const t=window.getSelection();if(!t||0===t.rangeCount)return;const M=t.getRangeAt(0);if(e.shiftKey){if(M.collapsed&&M.startContainer.nodeType===Node.TEXT_NODE){const e=M.startContainer,i=M.startOffset,n=e.data.slice(0,i),o=n.replace(/(\t|[ \u00a0]{2})$/,"");if(o.length!==n.length){e.data=o+e.data.slice(i);const M=document.createRange();M.setStart(e,o.length),M.collapse(!0),t.removeAllRanges(),t.addRange(M),this.updateContent(),this.updateToolbarState()}}return}M.deleteContents();const i=document.createTextNode("\t");M.insertNode(i);const n=document.createRange();n.setStartAfter(i),n.collapse(!0),t.removeAllRanges(),t.addRange(n),this.updateContent(),this.updateToolbarState()},this.onSelectionChange=()=>{if(!this.editorEl)return;const e=document.getSelection();if(!e||0===e.rangeCount)return;const t=e.getRangeAt(0);this.editorEl.contains(t.commonAncestorContainer)&&(this.lastRange=t.cloneRange(),this.updateToolbarState())}}createRenderRoot(){return this}injectCss(e){if(this.querySelector("style[data-rte-style]"))return;const t=document.createElement("style");t.setAttribute("data-rte-style","true"),t.textContent=e,this.insertBefore(t,this.firstChild)}connectedCallback(){super.connectedCallback(),this.injectCss(oS.cssText),this.ensureStructure(),this.value&&!this.editorEl.innerHTML.trim()&&(this.editorEl.innerHTML=this.value),this.content=this.editorEl.innerHTML,this.toolbarEl&&this.wireAuthoredToolbar(this.toolbarEl),this.mentionsEl=this.querySelector("nile-rte-mentions"),this.mentionsEl&&(this.mentionsEl.attach?.(this.editorEl,this),this.mentionsEl.setExternalConfig?.(this.mentions)),this.wireEditor(),document.addEventListener("selectionchange",this.onSelectionChange,{passive:!0}),this.updateToolbarState(),this.syncPreview()}ensureStructure(){this.toolbarEl=this.querySelector("nile-rte-toolbar"),this.previewEl=this.querySelector("nile-rte-preview"),this.containerEl=this.querySelector(".rte-container"),this.containerEl||(this.containerEl=document.createElement("div"),this.containerEl.className="rte-container",this.appendChild(this.containerEl)),this.ensureEditor(),this.toolbarEl&&this.toolbarEl.parentElement!==this.containerEl&&this.containerEl.appendChild(this.toolbarEl),this.editorEl.parentElement!==this.containerEl&&this.containerEl.appendChild(this.editorEl),this.previewEl&&(this.previewEl.parentElement!==this&&this.appendChild(this.previewEl),this.previewEl.previousElementSibling!==this.containerEl&&this.insertBefore(this.previewEl,this.containerEl.nextSibling))}updateContentWithMention(e){this.updateContent(),this.dispatchEvent(new CustomEvent("nile-change",{detail:{content:this.content,mention:e},bubbles:!0,composed:!0}))}disconnectedCallback(){document.removeEventListener("selectionchange",this.onSelectionChange),this.mentionsEl&&this.mentionsEl.detach&&this.mentionsEl.detach(),super.disconnectedCallback()}updated(e){e.has("value")&&this.editorEl&&this.value!==this.editorEl.innerHTML&&(this.editorEl.innerHTML=this.value||"<p><br></p>",this.content=this.editorEl.innerHTML,this.syncPreview()),e.has("singleLineEditor")&&(this.editorEl&&this.editorEl.classList.toggle("single-line",this.singleLineEditor),this.previewEl&&this.previewEl.classList.toggle("single-line",this.singleLineEditor))}ensureEditor(){if(this.editorEl=this.querySelector(".editor"),!this.editorEl){const e=document.createElement("article");e.className="editor",e.setAttribute("contenteditable","true"),this.editorEl=e}this.editorEl.innerHTML.trim()||(this.editorEl.innerHTML="<p><br></p>")}unwrapMention(e,t=!0){const M=e.parentNode;if(!M)return;const i=t?(e.textContent??"").replace(/\u200B/g,""):"",n=document.createTextNode(i);M.insertBefore(n,e),M.removeChild(e);const o=document.createRange();o.setStartAfter(n),o.collapse(!0);const r=window.getSelection();r?.removeAllRanges(),r?.addRange(o)}scrubBrokenMentions(){if(!this.editorEl)return;this.editorEl.querySelectorAll("span.mention").forEach((e=>{const t=e,M=t.getAttribute("data-mention-key"),i=t.getAttribute("data-mention-label"),n=t.getAttribute("data-mention-trigger")||"",o=(t.textContent??"").replace(/\u200B/g,"").trim(),r=!!M&&!!i&&o.length>0&&o.startsWith(n)&&o.includes(i);o&&r||this.unwrapMention(t,!0)}))}wireEditor(){this.editorEl.addEventListener("input",(()=>{this.ensureAtLeastOneParagraph(),this.scrubBrokenMentions(),this.updateContent(),this.updateToolbarState()})),this.editorEl.addEventListener("mouseup",(()=>{this.saveSelection(),this.updateToolbarState()})),this.editorEl.addEventListener("keyup",(e=>{this.saveSelection(),["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.key)&&this.updateToolbarState()})),this.editorEl.addEventListener("keydown",this.onEditorKeydown)}wireAuthoredToolbar(e){this.buttonMap.clear(),this.headingSelect=null,this.fontSelect=null,this.colorInput=null,Array.from(e.children).forEach((e=>{const t=e.tagName.toLowerCase();if("nile-rte-select"!==t||"align"!==e.getAttribute("type")){if("nile-rte-link"===t)return e.editorEl=this.editorEl,void e.addEventListener("link-changed",(()=>{this.updateContent(),this.updateToolbarState()}));if("nile-rte-toolbar-item"===t){let t=e.querySelector(":scope > nile-button");const M=e.getAttribute("name")||"",i=e.getAttribute("label")||M,n=e.getAttribute("icon"),o=e.innerHTML.trim().length>0;if(t||(t=document.createElement("nile-button"),t.variant="tertiary",t.size="small"),n)t.innerHTML=`<nile-icon name="${n}" aria-label="${i}"></nile-icon>`,e.innerHTML="";else if(o)t.innerHTML=e.innerHTML,e.innerHTML="";else{const n=rS[M];n?t.innerHTML=`<nile-icon name="${n}" size="20" color="black" aria-label="${i}"></nile-icon>`:t.textContent=i||M,e.innerHTML=""}if(!t.isConnected){const M=document.createElement("nile-tooltip");M.setAttribute("content",i),M.appendChild(t),e.appendChild(M)}t.setAttribute("aria-label",i),t.addEventListener("mousedown",(e=>e.preventDefault())),t.addEventListener("click",(()=>this.onToolbarCommand(M)));const r=this.buttonMap.get(M)??[];return r.push(t),void this.buttonMap.set(M,r)}if("nile-rte-select"!==t)"nile-rte-color"!==t||e.addEventListener("change",(e=>{this.focusAndRestore();const{mode:t,value:M}=e.detail;"backColor"===t?tS(this.editorEl,"backgroundColor",M,"data-rte-bg"):function(e,t){tS(e,"color",t,"data-rte-color")}(this.editorEl,M),this.updateContent(),this.updateToolbarState()}));else{const t=e.getAttribute("type")||"";e.addEventListener("change",(e=>{this.focusAndRestore();const M=e.detail;"heading"===t?function(e,t){const M=document.getSelection();if(!M||0===M.rangeCount)return;const i=Fp(M.getRangeAt(0).startContainer,e);if(!i)return;if(i.tagName.toLowerCase()===t)return;const n=document.createElement(t);for(;i.firstChild;)n.appendChild(i.firstChild);i.replaceWith(n);const o=document.createRange();o.selectNodeContents(n),o.collapse(!0),M.removeAllRanges(),M.addRange(o)}(this.editorEl,M):"font"===t&&function(e,t){const M=document.getSelection();if(!M||0===M.rangeCount)return;const i=M.getRangeAt(0);if(i.collapsed){const e=document.createElement("span");e.style.fontFamily=t,e.appendChild(document.createTextNode("")),i.insertNode(e);const n=document.createRange();return n.setStart(e.firstChild,1),n.collapse(!0),M.removeAllRanges(),void M.addRange(n)}$p(i,"span",{style:`font-family:${t}`})}(this.editorEl,M),this.updateContent(),this.updateToolbarState()}))}}else e.addEventListener("change",(e=>{this.focusAndRestore();const t=e.detail;Kp(this.editorEl,t),this.updateContent(),this.updateToolbarState()}))}))}saveSelection(){const e=window.getSelection();e&&e.rangeCount&&(this.lastRange=e.getRangeAt(0).cloneRange())}restoreSelection(){if(!this.lastRange)return;const e=document.getSelection();e&&(e.removeAllRanges(),e.addRange(this.lastRange))}focusAndRestore(){this.editorEl?.focus(),this.restoreSelection()}getCleanContent(){const e=this.editorEl.cloneNode(!0);return e.querySelectorAll("*").forEach((e=>{e.removeAttribute("style")})),e.innerHTML}insertList(e){if(this.restoreSelection(),!this.lastRange)return;const t=document.createElement(e),M=this.lastRange.extractContents(),i=document.createElement("div");i.appendChild(M),Array.from(i.childNodes).forEach((e=>{if(e.nodeType===Node.TEXT_NODE&&!e.textContent?.trim())return;const M=document.createElement("li");M.appendChild(e),t.appendChild(M)})),this.lastRange.insertNode(t),this.afterListEdit(t)}afterListEdit(e){const t=document.createRange();t.setStartAfter(e),t.collapse(!0);const M=window.getSelection();M?.removeAllRanges(),M?.addRange(t),this.saveSelection(),this.updateContent(),this.updateToolbarState()}ensureAtLeastOneParagraph(){const e=this.editorEl;if(!e)return;const t=""===(e.textContent??"").replace(/\u200B/g,"").trim();if(0===e.childNodes.length||t)return void(e.innerHTML="<p><br></p>");if(!e.querySelector("p,h1,h2,h3,h4,h5,h6,ul,ol,table,blockquote,pre")){const t=document.createElement("p");for(;e.firstChild;)t.appendChild(e.firstChild);return t.hasChildNodes()||t.appendChild(document.createElement("br")),void e.appendChild(t)}e.querySelectorAll("p").forEach((e=>{""===(e.textContent??"").replace(/\u200B/g,"")&&(e.innerHTML.toLowerCase().includes("<br")||(e.innerHTML="<br>"))}))}onToolbarCommand(e){switch(this.focusAndRestore(),e){case"bold":qp(this.editorEl,"strong");break;case"italic":qp(this.editorEl,"em");break;case"underline":qp(this.editorEl,"u");break;case"left":Kp(this.editorEl,"left");break;case"center":Kp(this.editorEl,"center");break;case"right":Kp(this.editorEl,"right");break;case"justify":Kp(this.editorEl,"justify");break;case"ul":nS(this.editorEl,"ul"),this.updateContent(),this.updateToolbarState();break;case"ol":nS(this.editorEl,"ol"),this.updateContent(),this.updateToolbarState();break;case"link":break;case"clear":const e=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),t=[];for(;e.nextNode();){const M=e.currentNode;M.removeAttribute("style"),["B","STRONG","I","EM","U","SPAN","FONT"].includes(M.tagName)&&t.push(M)}for(const e of t){for(;e.firstChild;)e.parentNode?.insertBefore(e.firstChild,e);e.remove()}this.ensureAtLeastOneParagraph()}this.updateContent(),this.updateToolbarState()}setBtnActive(e,t){const M=this.buttonMap.get(e);if(M)for(const e of M)e.toggleAttribute("data-active",!!t)}updateToolbarState(){if(!this.editorEl)return;const e=document.getSelection();if(!e||0===e.rangeCount)return;const t=e.getRangeAt(0);if(!this.editorEl.contains(t.commonAncestorContainer))return;const M=function(e){for(;e&&!(e instanceof HTMLElement);)e=e.parentNode;return e}(t.startContainer)||this.editorEl,i=getComputedStyle(M),n=Fp(t.startContainer,this.editorEl)||this.editorEl,o=(()=>{let e=M;for(;e&&e!==this.editorEl;){if(e instanceof HTMLElement){const t=e.tagName.toLowerCase();if("strong"===t||"b"===t)return!0;const M=getComputedStyle(e).fontWeight;if(parseInt(M,10)>=600)return!0}e=e.parentNode}return!1})(),r=(()=>{let e=M;for(;e&&e!==this.editorEl;){if(e instanceof HTMLElement){const t=e.tagName.toLowerCase();if("em"===t||"i"===t)return!0;if("italic"===getComputedStyle(e).fontStyle)return!0}e=e.parentNode}return!1})(),s=(()=>{let e=M;for(;e&&e!==this.editorEl;){if(e instanceof HTMLElement){const t=getComputedStyle(e).textDecorationLine;if(t&&t.includes("underline"))return!0;if("u"===e.tagName.toLowerCase())return!0}e=e.parentNode}return!1})(),a=!!M.closest("a"),N=n.style.textAlign||getComputedStyle(n).textAlign||"start",l="start"===N?"left":N,g=!!M.closest("li")&&M.closest("ul,ol")?.tagName.toLowerCase()||"";if(this.setBtnActive("bold",o),this.setBtnActive("italic",r),this.setBtnActive("underline",s),this.setBtnActive("link",a),this.setBtnActive("left","left"===l&&!["center","right","justify"].includes(l)),this.setBtnActive("center","center"===l),this.setBtnActive("right","right"===l),this.setBtnActive("justify","justify"===l),this.setBtnActive("ul","ul"===g),this.setBtnActive("ol","ol"===g),this.headingSelect){const e=n.tagName.toLowerCase(),t=["h1","h2","h3"].includes(e)?e:"p";this.headingSelect.value!==t&&(this.headingSelect.value=t)}if(this.fontSelect){const e=(i.fontFamily||"").replace(/["']/g,"").split(",")[0].trim().toLowerCase();if(e)for(const t of Array.from(this.fontSelect.options))if(t.value.toLowerCase()===e){this.fontSelect.value=t.value;break}}if(this.colorInput){const e=Hp(i.color);e&&this.colorInput.value.toLowerCase()!==e.toLowerCase()&&(this.colorInput.value=e),this.colorSwatchEl&&(this.colorSwatchEl.style.backgroundColor=this.colorInput.value)}if(this.bgColorInput){const e=getComputedStyle(M).backgroundColor;if(e&&!/transparent|rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\)/i.test(e)){const t=Hp(e);t&&this.bgColorInput.value.toLowerCase()!==t.toLowerCase()&&(this.bgColorInput.value=t)}this.bgSwatchEl&&(this.bgSwatchEl.style.backgroundColor=this.bgColorInput.value)}}syncPreview(){this.updateContent()}updateContent(){if(!this.editorEl)return;this.ensureAtLeastOneParagraph();const e=this.editorEl.cloneNode(!0);if(this.noStyles)e.querySelectorAll("[style]").forEach((e=>e.removeAttribute("style")));else{const t=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),M=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),i=["font-weight","font-style","text-decoration","color","background-color","font-size","font-family","text-align","line-height","letter-spacing","white-space","vertical-align","list-style-position","padding-inline-start"];for(;t.nextNode()&&M.nextNode();){const e=t.currentNode,n=M.currentNode,o=window.getComputedStyle(e),r=i.map((e=>`${e}:${o.getPropertyValue(e)}`)).join(";");r.trim()&&n.setAttribute("style",r)}}this.content=e.innerHTML,this.previewEl&&(this.previewEl.innerHTML=this.content),this.dispatchEvent(new CustomEvent("nile-change",{detail:{content:this.content},bubbles:!0,composed:!0}))}};e([ue({type:String,attribute:!0,reflect:!0})],sS.prototype,"value",void 0),e([ue({type:Boolean,attribute:!0,reflect:!0})],sS.prototype,"noStyles",void 0),e([ue({type:Boolean,attribute:"singlelineeditor",reflect:!0})],sS.prototype,"singleLineEditor",void 0),e([ue({attribute:"mentions",reflect:!0,converter:{fromAttribute:e=>{try{const t=JSON.parse(e),M={};for(const e of Object.keys(t)){const i=t[e];Array.isArray(i)&&(M[e]=i.filter((e=>e&&"string"==typeof e.key&&"string"==typeof e.label)).map((e=>({key:e.key,label:e.label}))))}return M}catch{return{}}},toAttribute:e=>JSON.stringify(e)}})],sS.prototype,"mentions",void 0),e([ce()],sS.prototype,"content",void 0),sS=e([le("nile-rich-text-editor")],sS);"undefined"!=typeof window&&(window.nileElementsVersion='"1.1.6"',window.nileVersion="__NILE_VERSION__");const aS=r`
|
|
14014
|
+
`,rS={bold:"format_bold",italic:"format_italic",underline:"format_underline",link:"link_2",left:"format_align_left",center:"format_align_middle",right:"format_align_right",justify:"format_align_justify",ul:"format_list_bulleted",ol:"format_list_numbered",clear:"format_clear"};let sS=class extends ae{constructor(){super(...arguments),this.value="",this.noStyles=!1,this.singleLineEditor=!1,this.mentions={},this.content="",this.previewEl=null,this.toolbarEl=null,this.lastRange=null,this.buttonMap=new Map,this.headingSelect=null,this.fontSelect=null,this.colorInput=null,this.bgColorInput=null,this.colorSwatchEl=null,this.bgSwatchEl=null,this.containerEl=null,this.mentionsEl=null,this.onEditorKeydown=e=>{if(this.singleLineEditor&&"Enter"===e.key&&e.shiftKey)return void e.preventDefault();if(e.ctrlKey&&"i"===e.key.toLowerCase()&&(e.preventDefault(),qp(this.editorEl,"em"),this.updateContent(),this.updateToolbarState()),this.singleLineEditor&&"Enter"===e.key)return void e.preventDefault();if("Tab"!==e.key)return;e.preventDefault(),this.focusAndRestore();const t=window.getSelection();if(!t||0===t.rangeCount)return;const M=t.getRangeAt(0);if(e.shiftKey){if(M.collapsed&&M.startContainer.nodeType===Node.TEXT_NODE){const e=M.startContainer,i=M.startOffset,n=e.data.slice(0,i),o=n.replace(/(\t|[ \u00a0]{2})$/,"");if(o.length!==n.length){e.data=o+e.data.slice(i);const M=document.createRange();M.setStart(e,o.length),M.collapse(!0),t.removeAllRanges(),t.addRange(M),this.updateContent(),this.updateToolbarState()}}return}M.deleteContents();const i=document.createTextNode("\t");M.insertNode(i);const n=document.createRange();n.setStartAfter(i),n.collapse(!0),t.removeAllRanges(),t.addRange(n),this.updateContent(),this.updateToolbarState()},this.onSelectionChange=()=>{if(!this.editorEl)return;const e=document.getSelection();if(!e||0===e.rangeCount)return;const t=e.getRangeAt(0);this.editorEl.contains(t.commonAncestorContainer)&&(this.lastRange=t.cloneRange(),this.updateToolbarState())}}createRenderRoot(){return this}injectCss(e){if(this.querySelector("style[data-rte-style]"))return;const t=document.createElement("style");t.setAttribute("data-rte-style","true"),t.textContent=e,this.insertBefore(t,this.firstChild)}connectedCallback(){super.connectedCallback(),this.injectCss(oS.cssText),this.ensureStructure(),this.value&&!this.editorEl.innerHTML.trim()&&(this.editorEl.innerHTML=this.value),this.content=this.editorEl.innerHTML,this.toolbarEl&&this.wireAuthoredToolbar(this.toolbarEl),this.mentionsEl=this.querySelector("nile-rte-mentions"),this.mentionsEl&&(this.mentionsEl.attach?.(this.editorEl,this),this.mentionsEl.setExternalConfig?.(this.mentions)),this.wireEditor(),document.addEventListener("selectionchange",this.onSelectionChange,{passive:!0}),this.updateToolbarState(),this.syncPreview()}ensureStructure(){this.toolbarEl=this.querySelector("nile-rte-toolbar"),this.previewEl=this.querySelector("nile-rte-preview"),this.containerEl=this.querySelector(".rte-container"),this.containerEl||(this.containerEl=document.createElement("div"),this.containerEl.className="rte-container",this.appendChild(this.containerEl)),this.ensureEditor(),this.toolbarEl&&this.toolbarEl.parentElement!==this.containerEl&&this.containerEl.appendChild(this.toolbarEl),this.editorEl.parentElement!==this.containerEl&&this.containerEl.appendChild(this.editorEl),this.previewEl&&(this.previewEl.parentElement!==this&&this.appendChild(this.previewEl),this.previewEl.previousElementSibling!==this.containerEl&&this.insertBefore(this.previewEl,this.containerEl.nextSibling))}updateContentWithMention(e){this.updateContent(),this.dispatchEvent(new CustomEvent("nile-change",{detail:{content:this.content,mention:e},bubbles:!0,composed:!0}))}disconnectedCallback(){document.removeEventListener("selectionchange",this.onSelectionChange),this.mentionsEl&&this.mentionsEl.detach&&this.mentionsEl.detach(),super.disconnectedCallback()}updated(e){e.has("value")&&this.editorEl&&this.value!==this.editorEl.innerHTML&&(this.editorEl.innerHTML=this.value||"<p><br></p>",this.content=this.editorEl.innerHTML,this.syncPreview()),e.has("singleLineEditor")&&(this.editorEl&&this.editorEl.classList.toggle("single-line",this.singleLineEditor),this.previewEl&&this.previewEl.classList.toggle("single-line",this.singleLineEditor))}ensureEditor(){if(this.editorEl=this.querySelector(".editor"),!this.editorEl){const e=document.createElement("article");e.className="editor",e.setAttribute("contenteditable","true"),this.editorEl=e}this.editorEl.innerHTML.trim()||(this.editorEl.innerHTML="<p><br></p>")}unwrapMention(e,t=!0){const M=e.parentNode;if(!M)return;const i=t?(e.textContent??"").replace(/\u200B/g,""):"",n=document.createTextNode(i);M.insertBefore(n,e),M.removeChild(e);const o=document.createRange();o.setStartAfter(n),o.collapse(!0);const r=window.getSelection();r?.removeAllRanges(),r?.addRange(o)}scrubBrokenMentions(){if(!this.editorEl)return;this.editorEl.querySelectorAll("span.mention").forEach((e=>{const t=e,M=t.getAttribute("data-mention-key"),i=t.getAttribute("data-mention-label"),n=t.getAttribute("data-mention-trigger")||"",o=(t.textContent??"").replace(/\u200B/g,"").trim(),r=!!M&&!!i&&o.length>0&&o.startsWith(n)&&o.includes(i);o&&r||this.unwrapMention(t,!0)}))}wireEditor(){this.editorEl.addEventListener("input",(()=>{this.ensureAtLeastOneParagraph(),this.scrubBrokenMentions(),this.updateContent(),this.updateToolbarState()})),this.editorEl.addEventListener("mouseup",(()=>{this.saveSelection(),this.updateToolbarState()})),this.editorEl.addEventListener("keyup",(e=>{this.saveSelection(),["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e.key)&&this.updateToolbarState()})),this.editorEl.addEventListener("keydown",this.onEditorKeydown)}wireAuthoredToolbar(e){this.buttonMap.clear(),this.headingSelect=null,this.fontSelect=null,this.colorInput=null,Array.from(e.children).forEach((e=>{const t=e.tagName.toLowerCase();if("nile-rte-select"!==t||"align"!==e.getAttribute("type")){if("nile-rte-link"===t)return e.editorEl=this.editorEl,void e.addEventListener("link-changed",(()=>{this.updateContent(),this.updateToolbarState()}));if("nile-rte-toolbar-item"===t){let t=e.querySelector(":scope > nile-button");const M=e.getAttribute("name")||"",i=e.getAttribute("label")||M,n=e.getAttribute("icon"),o=e.innerHTML.trim().length>0;if(t||(t=document.createElement("nile-button"),t.variant="tertiary",t.size="small"),n)t.innerHTML=`<nile-icon name="${n}" aria-label="${i}"></nile-icon>`,e.innerHTML="";else if(o)t.innerHTML=e.innerHTML,e.innerHTML="";else{const n=rS[M];n?t.innerHTML=`<nile-icon name="${n}" size="20" color="black" aria-label="${i}"></nile-icon>`:t.textContent=i||M,e.innerHTML=""}if(!t.isConnected){const M=document.createElement("nile-tooltip");M.setAttribute("content",i),M.appendChild(t),e.appendChild(M)}t.setAttribute("aria-label",i),t.addEventListener("mousedown",(e=>e.preventDefault())),t.addEventListener("click",(()=>this.onToolbarCommand(M)));const r=this.buttonMap.get(M)??[];return r.push(t),void this.buttonMap.set(M,r)}if("nile-rte-select"!==t)"nile-rte-color"!==t||e.addEventListener("change",(e=>{this.focusAndRestore();const{mode:t,value:M}=e.detail;"backColor"===t?tS(this.editorEl,"backgroundColor",M,"data-rte-bg"):function(e,t){tS(e,"color",t,"data-rte-color")}(this.editorEl,M),this.updateContent(),this.updateToolbarState()}));else{const t=e.getAttribute("type")||"";e.addEventListener("change",(e=>{this.focusAndRestore();const M=e.detail;"heading"===t?function(e,t){const M=document.getSelection();if(!M||0===M.rangeCount)return;const i=Fp(M.getRangeAt(0).startContainer,e);if(!i)return;if(i.tagName.toLowerCase()===t)return;const n=document.createElement(t);for(;i.firstChild;)n.appendChild(i.firstChild);i.replaceWith(n);const o=document.createRange();o.selectNodeContents(n),o.collapse(!0),M.removeAllRanges(),M.addRange(o)}(this.editorEl,M):"font"===t&&function(e,t){const M=document.getSelection();if(!M||0===M.rangeCount)return;const i=M.getRangeAt(0);if(i.collapsed){const e=document.createElement("span");e.style.fontFamily=t,e.appendChild(document.createTextNode("")),i.insertNode(e);const n=document.createRange();return n.setStart(e.firstChild,1),n.collapse(!0),M.removeAllRanges(),void M.addRange(n)}$p(i,"span",{style:`font-family:${t}`})}(this.editorEl,M),this.updateContent(),this.updateToolbarState()}))}}else e.addEventListener("change",(e=>{this.focusAndRestore();const t=e.detail;Kp(this.editorEl,t),this.updateContent(),this.updateToolbarState()}))}))}saveSelection(){const e=window.getSelection();e&&e.rangeCount&&(this.lastRange=e.getRangeAt(0).cloneRange())}restoreSelection(){if(!this.lastRange)return;const e=document.getSelection();e&&(e.removeAllRanges(),e.addRange(this.lastRange))}focusAndRestore(){this.editorEl?.focus(),this.restoreSelection()}getCleanContent(){const e=this.editorEl.cloneNode(!0);return e.querySelectorAll("*").forEach((e=>{e.removeAttribute("style")})),e.innerHTML}insertList(e){if(this.restoreSelection(),!this.lastRange)return;const t=document.createElement(e),M=this.lastRange.extractContents(),i=document.createElement("div");i.appendChild(M),Array.from(i.childNodes).forEach((e=>{if(e.nodeType===Node.TEXT_NODE&&!e.textContent?.trim())return;const M=document.createElement("li");M.appendChild(e),t.appendChild(M)})),this.lastRange.insertNode(t),this.afterListEdit(t)}afterListEdit(e){const t=document.createRange();t.setStartAfter(e),t.collapse(!0);const M=window.getSelection();M?.removeAllRanges(),M?.addRange(t),this.saveSelection(),this.updateContent(),this.updateToolbarState()}ensureAtLeastOneParagraph(){const e=this.editorEl;if(!e)return;const t=""===(e.textContent??"").replace(/\u200B/g,"").trim();if(0===e.childNodes.length||t)return void(e.innerHTML="<p><br></p>");if(!e.querySelector("p,h1,h2,h3,h4,h5,h6,ul,ol,table,blockquote,pre")){const t=document.createElement("p");for(;e.firstChild;)t.appendChild(e.firstChild);return t.hasChildNodes()||t.appendChild(document.createElement("br")),void e.appendChild(t)}e.querySelectorAll("p").forEach((e=>{""===(e.textContent??"").replace(/\u200B/g,"")&&(e.innerHTML.toLowerCase().includes("<br")||(e.innerHTML="<br>"))}))}onToolbarCommand(e){switch(this.focusAndRestore(),e){case"bold":qp(this.editorEl,"strong");break;case"italic":qp(this.editorEl,"em");break;case"underline":qp(this.editorEl,"u");break;case"left":Kp(this.editorEl,"left");break;case"center":Kp(this.editorEl,"center");break;case"right":Kp(this.editorEl,"right");break;case"justify":Kp(this.editorEl,"justify");break;case"ul":nS(this.editorEl,"ul"),this.updateContent(),this.updateToolbarState();break;case"ol":nS(this.editorEl,"ol"),this.updateContent(),this.updateToolbarState();break;case"link":break;case"clear":const e=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),t=[];for(;e.nextNode();){const M=e.currentNode;M.removeAttribute("style"),["B","STRONG","I","EM","U","SPAN","FONT"].includes(M.tagName)&&t.push(M)}for(const e of t){for(;e.firstChild;)e.parentNode?.insertBefore(e.firstChild,e);e.remove()}this.ensureAtLeastOneParagraph()}this.updateContent(),this.updateToolbarState()}setBtnActive(e,t){const M=this.buttonMap.get(e);if(M)for(const e of M)e.toggleAttribute("data-active",!!t)}updateToolbarState(){if(!this.editorEl)return;const e=document.getSelection();if(!e||0===e.rangeCount)return;const t=e.getRangeAt(0);if(!this.editorEl.contains(t.commonAncestorContainer))return;const M=function(e){for(;e&&!(e instanceof HTMLElement);)e=e.parentNode;return e}(t.startContainer)||this.editorEl,i=getComputedStyle(M),n=Fp(t.startContainer,this.editorEl)||this.editorEl,o=(()=>{let e=M;for(;e&&e!==this.editorEl;){if(e instanceof HTMLElement){const t=e.tagName.toLowerCase();if("strong"===t||"b"===t)return!0;const M=getComputedStyle(e).fontWeight;if(parseInt(M,10)>=600)return!0}e=e.parentNode}return!1})(),r=(()=>{let e=M;for(;e&&e!==this.editorEl;){if(e instanceof HTMLElement){const t=e.tagName.toLowerCase();if("em"===t||"i"===t)return!0;if("italic"===getComputedStyle(e).fontStyle)return!0}e=e.parentNode}return!1})(),s=(()=>{let e=M;for(;e&&e!==this.editorEl;){if(e instanceof HTMLElement){const t=getComputedStyle(e).textDecorationLine;if(t&&t.includes("underline"))return!0;if("u"===e.tagName.toLowerCase())return!0}e=e.parentNode}return!1})(),a=!!M.closest("a"),N=n.style.textAlign||getComputedStyle(n).textAlign||"start",l="start"===N?"left":N,g=!!M.closest("li")&&M.closest("ul,ol")?.tagName.toLowerCase()||"";if(this.setBtnActive("bold",o),this.setBtnActive("italic",r),this.setBtnActive("underline",s),this.setBtnActive("link",a),this.setBtnActive("left","left"===l&&!["center","right","justify"].includes(l)),this.setBtnActive("center","center"===l),this.setBtnActive("right","right"===l),this.setBtnActive("justify","justify"===l),this.setBtnActive("ul","ul"===g),this.setBtnActive("ol","ol"===g),this.headingSelect){const e=n.tagName.toLowerCase(),t=["h1","h2","h3"].includes(e)?e:"p";this.headingSelect.value!==t&&(this.headingSelect.value=t)}if(this.fontSelect){const e=(i.fontFamily||"").replace(/["']/g,"").split(",")[0].trim().toLowerCase();if(e)for(const t of Array.from(this.fontSelect.options))if(t.value.toLowerCase()===e){this.fontSelect.value=t.value;break}}if(this.colorInput){const e=Hp(i.color);e&&this.colorInput.value.toLowerCase()!==e.toLowerCase()&&(this.colorInput.value=e),this.colorSwatchEl&&(this.colorSwatchEl.style.backgroundColor=this.colorInput.value)}if(this.bgColorInput){const e=getComputedStyle(M).backgroundColor;if(e&&!/transparent|rgba\(\s*0\s*,\s*0\s*,\s*0\s*,\s*0\s*\)/i.test(e)){const t=Hp(e);t&&this.bgColorInput.value.toLowerCase()!==t.toLowerCase()&&(this.bgColorInput.value=t)}this.bgSwatchEl&&(this.bgSwatchEl.style.backgroundColor=this.bgColorInput.value)}}syncPreview(){this.updateContent()}updateContent(){if(!this.editorEl)return;this.ensureAtLeastOneParagraph();const e=this.editorEl.cloneNode(!0);if(this.noStyles)e.querySelectorAll("[style]").forEach((e=>e.removeAttribute("style")));else{const t=document.createTreeWalker(this.editorEl,NodeFilter.SHOW_ELEMENT),M=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),i=["font-weight","font-style","text-decoration","color","background-color","font-size","font-family","text-align","line-height","letter-spacing","white-space","vertical-align","list-style-position","padding-inline-start"];for(;t.nextNode()&&M.nextNode();){const e=t.currentNode,n=M.currentNode,o=window.getComputedStyle(e),r=i.map((e=>`${e}:${o.getPropertyValue(e)}`)).join(";");r.trim()&&n.setAttribute("style",r)}}this.content=e.innerHTML,this.previewEl&&(this.previewEl.innerHTML=this.content),this.dispatchEvent(new CustomEvent("nile-change",{detail:{content:this.content},bubbles:!0,composed:!0}))}};e([ue({type:String,attribute:!0,reflect:!0})],sS.prototype,"value",void 0),e([ue({type:Boolean,attribute:!0,reflect:!0})],sS.prototype,"noStyles",void 0),e([ue({type:Boolean,attribute:"singlelineeditor",reflect:!0})],sS.prototype,"singleLineEditor",void 0),e([ue({attribute:"mentions",reflect:!0,converter:{fromAttribute:e=>{try{const t=JSON.parse(e),M={};for(const e of Object.keys(t)){const i=t[e];Array.isArray(i)&&(M[e]=i.filter((e=>e&&"string"==typeof e.key&&"string"==typeof e.label)).map((e=>({key:e.key,label:e.label}))))}return M}catch{return{}}},toAttribute:e=>JSON.stringify(e)}})],sS.prototype,"mentions",void 0),e([ce()],sS.prototype,"content",void 0),sS=e([le("nile-rich-text-editor")],sS);"undefined"!=typeof window&&(window.nileElementsVersion='"1.1.7"',window.nileVersion="__NILE_VERSION__");const aS=r`
|
|
14015
14015
|
:host {
|
|
14016
14016
|
--sidebar-width: 240px;
|
|
14017
14017
|
--sidebar-collapsed-width: 70px;
|
|
@@ -14958,4 +14958,4 @@ class fS{constructor(e){this._map=new Map,this._roundAverageSize=!1,this.totalSi
|
|
|
14958
14958
|
* @license
|
|
14959
14959
|
* Copyright 2021 Google LLC
|
|
14960
14960
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
14961
|
-
*/function ZS(e){return"horizontal"===e?"marginLeft":"marginTop"}function VS(e){return"horizontal"===e?"marginRight":"marginBottom"}function WS(e){return"horizontal"===e?"xOffset":"yOffset"}function PS(e,t){const M=[e,t].sort();return M[1]<=0?Math.min(...M):M[0]>=0?Math.max(...M):M[0]+M[1]}class RS{constructor(){this._childSizeCache=new fS,this._marginSizeCache=new fS,this._metricsCache=new Map}update(e,t){const M=new Set;Object.keys(e).forEach((i=>{const n=Number(i);this._metricsCache.set(n,e[n]),this._childSizeCache.set(n,e[n][vS(t)]),M.add(n),M.add(n+1)}));for(const e of M){const M=this._metricsCache.get(e)?.[ZS(t)]||0,i=this._metricsCache.get(e-1)?.[VS(t)]||0;this._marginSizeCache.set(e,PS(M,i))}}get averageChildSize(){return this._childSizeCache.averageSize}get totalChildSize(){return this._childSizeCache.totalSize}get averageMarginSize(){return this._marginSizeCache.averageSize}get totalMarginSize(){return this._marginSizeCache.totalSize}getLeadingMarginValue(e,t){return this._metricsCache.get(e)?.[ZS(t)]||0}getChildSize(e){return this._childSizeCache.getSize(e)}getMarginSize(e){return this._marginSizeCache.getSize(e)}clear(){this._childSizeCache.clear(),this._marginSizeCache.clear(),this._metricsCache.clear()}}var GS=Object.freeze({__proto__:null,FlowLayout:class extends YS{constructor(){super(...arguments),this._itemSize={width:100,height:100},this._physicalItems=new Map,this._newPhysicalItems=new Map,this._metricsCache=new RS,this._anchorIdx=null,this._anchorPos=null,this._stable=!0,this._measureChildren=!0,this._estimate=!0}get measureChildren(){return this._measureChildren}updateItemSizes(e){this._metricsCache.update(e,this.direction),this._scheduleReflow()}_getPhysicalItem(e){return this._newPhysicalItems.get(e)??this._physicalItems.get(e)}_getSize(e){return this._getPhysicalItem(e)&&this._metricsCache.getChildSize(e)}_getAverageSize(){return this._metricsCache.averageChildSize||this._itemSize[this._sizeDim]}_estimatePosition(e){const t=this._metricsCache;if(-1===this._first||-1===this._last)return t.averageMarginSize+e*(t.averageMarginSize+this._getAverageSize());if(e<this._first){const M=this._first-e;return this._getPhysicalItem(this._first).pos-(t.getMarginSize(this._first-1)||t.averageMarginSize)-(M*t.averageChildSize+(M-1)*t.averageMarginSize)}{const M=e-this._last;return this._getPhysicalItem(this._last).pos+(t.getChildSize(this._last)||t.averageChildSize)+(t.getMarginSize(this._last)||t.averageMarginSize)+M*(t.averageChildSize+t.averageMarginSize)}}_getPosition(e){const t=this._getPhysicalItem(e),{averageMarginSize:M}=this._metricsCache;return 0===e?this._metricsCache.getMarginSize(0)??M:t?t.pos:this._estimatePosition(e)}_calculateAnchor(e,t){return e<=0?0:t>this._scrollSize-this._viewDim1?this.items.length-1:Math.max(0,Math.min(this.items.length-1,Math.floor((e+t)/2/this._delta)))}_getAnchor(e,t){if(0===this._physicalItems.size)return this._calculateAnchor(e,t);if(this._first<0)return this._calculateAnchor(e,t);if(this._last<0)return this._calculateAnchor(e,t);const M=this._getPhysicalItem(this._first),i=this._getPhysicalItem(this._last),n=M.pos;if(i.pos+this._metricsCache.getChildSize(this._last)<e)return this._calculateAnchor(e,t);if(n>t)return this._calculateAnchor(e,t);let o=this._firstVisible-1,r=-1/0;for(;r<e;){r=this._getPhysicalItem(++o).pos+this._metricsCache.getChildSize(o)}return o}_getActiveItems(){0===this._viewDim1||0===this.items.length?this._clearItems():this._getItems()}_clearItems(){this._first=-1,this._last=-1,this._physicalMin=0,this._physicalMax=0;const e=this._newPhysicalItems;this._newPhysicalItems=this._physicalItems,this._newPhysicalItems.clear(),this._physicalItems=e,this._stable=!0}_getItems(){const e=this._newPhysicalItems;let t,M;if(this._stable=!0,null!==this.pin){const{index:e}=this.pin;this._anchorIdx=e,this._anchorPos=this._getPosition(e)}if(t=this._scrollPosition-this._overhang,M=this._scrollPosition+this._viewDim1+this._overhang,M<0||t>this._scrollSize)return void this._clearItems();null!==this._anchorIdx&&null!==this._anchorPos||(this._anchorIdx=this._getAnchor(t,M),this._anchorPos=this._getPosition(this._anchorIdx));let i=this._getSize(this._anchorIdx);void 0===i&&(this._stable=!1,i=this._getAverageSize());const n=this._metricsCache.getMarginSize(this._anchorIdx)??this._metricsCache.averageMarginSize,o=this._metricsCache.getMarginSize(this._anchorIdx+1)??this._metricsCache.averageMarginSize;0===this._anchorIdx&&(this._anchorPos=n),this._anchorIdx===this.items.length-1&&(this._anchorPos=this._scrollSize-o-i);let r=0;for(this._anchorPos+i+o<t&&(r=t-(this._anchorPos+i+o)),this._anchorPos-n>M&&(r=M-(this._anchorPos-n)),r&&(this._scrollPosition-=r,t-=r,M-=r,this._scrollError+=r),e.set(this._anchorIdx,{pos:this._anchorPos,size:i}),this._first=this._last=this._anchorIdx,this._physicalMin=this._anchorPos-n,this._physicalMax=this._anchorPos+i+o;this._physicalMin>t&&this._first>0;){let t=this._getSize(--this._first);void 0===t&&(this._stable=!1,t=this._getAverageSize());let M=this._metricsCache.getMarginSize(this._first);void 0===M&&(this._stable=!1,M=this._metricsCache.averageMarginSize),this._physicalMin-=t;const i=this._physicalMin;if(e.set(this._first,{pos:i,size:t}),this._physicalMin-=M,!1===this._stable&&!1===this._estimate)break}for(;this._physicalMax<M&&this._last<this.items.length-1;){let t=this._getSize(++this._last);void 0===t&&(this._stable=!1,t=this._getAverageSize());let M=this._metricsCache.getMarginSize(this._last);void 0===M&&(this._stable=!1,M=this._metricsCache.averageMarginSize);const i=this._physicalMax;if(e.set(this._last,{pos:i,size:t}),this._physicalMax+=t+M,!this._stable&&!this._estimate)break}const s=this._calculateError();s&&(this._physicalMin-=s,this._physicalMax-=s,this._anchorPos-=s,this._scrollPosition-=s,e.forEach((e=>e.pos-=s)),this._scrollError+=s),this._stable&&(this._newPhysicalItems=this._physicalItems,this._newPhysicalItems.clear(),this._physicalItems=e)}_calculateError(){return 0===this._first?this._physicalMin:this._physicalMin<=0?this._physicalMin-this._first*this._delta:this._last===this.items.length-1?this._physicalMax-this._scrollSize:this._physicalMax>=this._scrollSize?this._physicalMax-this._scrollSize+(this.items.length-1-this._last)*this._delta:0}_reflow(){const{_first:e,_last:t}=this;super._reflow(),(-1===this._first&&-1==this._last||this._first===e&&this._last===t)&&this._resetReflowState()}_resetReflowState(){this._anchorIdx=null,this._anchorPos=null,this._stable=!0}_updateScrollSize(){const{averageMarginSize:e}=this._metricsCache;this._scrollSize=Math.max(1,this.items.length*(e+this._getAverageSize())+e)}get _delta(){const{averageMarginSize:e}=this._metricsCache;return this._getAverageSize()+e}_getItemPosition(e){return{[this._positionDim]:this._getPosition(e),[this._secondaryPositionDim]:0,[WS(this.direction)]:-(this._metricsCache.getLeadingMarginValue(e,this.direction)??this._metricsCache.averageMarginSize)}}_getItemSize(e){return{[this._sizeDim]:this._getSize(e)||this._getAverageSize(),[this._secondarySizeDim]:this._itemSize[this._secondarySizeDim]}}_viewDim2Changed(){this._metricsCache.clear(),this._scheduleReflow()}}});export{ax as NileAccordion,nn as NileAutoComplete,QL as NileAvatar,gt as NileBadge,tL as NileBreadcrumb,iL as NileBreadcrumbItem,_e as NileButton,gL as NileButtonFilter,Ln as NileButtonToggle,pn as NileButtonToggleGroup,dn as NileCalendar,sL as NileCard,Ut as NileCheckbox,rn as NileChip,uL as NileCircularProgressbar,JO as NileCodeEditor,Un as NileContentEditor,ln as NileDatePicker,vn as NileDialog,lx as NileDivider,Ct as NileDrawer,tn as NileDropdown,CL as NileEmptyState,Dn as NileErrorMessage,Zn as NileErrorNotification,zp as NileFilePreview,qx as NileFileUpload,Ox as NileFilterChip,cn as NileFormErrorMessage,oL as NileFormGroup,In as NileFormHelpText,BL as NileFormatDate,pp as NileGrid,Ep as NileGridBody,bp as NileGridCellItem,fp as NileGridHead,kp as NileGridHeadItem,wp as NileGridRow,Fe as NileHeading,UL as NileHero,WL as NileHeroHeader,me as NileIcon,lt as NileIconButton,dx as NileInlineEdit,ot as NileInput,hn as NileLink,rx as NileList,nx as NileListItem,oi as NileLoader,st as NileMenu,Ki as NileMenuItem,Xi as NileOption,Tp as NileOptionGroup,mL as NilePageHeader,px as NilePagination,NL as NilePopover,KM as NilePopup,si as NileProgressBar,vt as NileRadio,Zt as NileRadioGroup,sS as NileRichTextEditor,cx as NileSectionMessage,Ji as NileSelect,NS as NileSideBar,QS as NileSideBarAction,US as NileSideBarActionMenu,CS as NileSideBarActionMenuItem,jS as NileSideBarExpand,xS as NileSideBarFooter,SS as NileSideBarFooterItem,mS as NileSideBarFooterText,zS as NileSideBarGroup,TS as NileSideBarGroupItem,hS as NileSideBarGroupItemIcon,OS as NileSideBarGroupItemText,gS as NileSideBarHeader,uS as NileSideBarLogo,ii as NileSlideToggle,Cx as NileSlider,Ni as NileSpinner,HL as NileSplitPanel,ZL as NileStepper,vL as NileStepperItem,kn as NileSwitcher,Gn as NileTab,Wn as NileTabGroup,Fn as NileTabPanel,yx as NileTable,xL as NileTableBody,hL as NileTableCellItem,SL as NileTableHeaderItem,OL as NileTableRow,Di as NileTag,an as NileTextarea,Dx as NileTitle,KO as NileToast,Ix as NileToolbar,ti as NileTooltip,Mx as NileTree,KL as NileTreeItem,RL as NileVerticalStepperItem,
|
|
14961
|
+
*/function ZS(e){return"horizontal"===e?"marginLeft":"marginTop"}function VS(e){return"horizontal"===e?"marginRight":"marginBottom"}function WS(e){return"horizontal"===e?"xOffset":"yOffset"}function PS(e,t){const M=[e,t].sort();return M[1]<=0?Math.min(...M):M[0]>=0?Math.max(...M):M[0]+M[1]}class RS{constructor(){this._childSizeCache=new fS,this._marginSizeCache=new fS,this._metricsCache=new Map}update(e,t){const M=new Set;Object.keys(e).forEach((i=>{const n=Number(i);this._metricsCache.set(n,e[n]),this._childSizeCache.set(n,e[n][vS(t)]),M.add(n),M.add(n+1)}));for(const e of M){const M=this._metricsCache.get(e)?.[ZS(t)]||0,i=this._metricsCache.get(e-1)?.[VS(t)]||0;this._marginSizeCache.set(e,PS(M,i))}}get averageChildSize(){return this._childSizeCache.averageSize}get totalChildSize(){return this._childSizeCache.totalSize}get averageMarginSize(){return this._marginSizeCache.averageSize}get totalMarginSize(){return this._marginSizeCache.totalSize}getLeadingMarginValue(e,t){return this._metricsCache.get(e)?.[ZS(t)]||0}getChildSize(e){return this._childSizeCache.getSize(e)}getMarginSize(e){return this._marginSizeCache.getSize(e)}clear(){this._childSizeCache.clear(),this._marginSizeCache.clear(),this._metricsCache.clear()}}var GS=Object.freeze({__proto__:null,FlowLayout:class extends YS{constructor(){super(...arguments),this._itemSize={width:100,height:100},this._physicalItems=new Map,this._newPhysicalItems=new Map,this._metricsCache=new RS,this._anchorIdx=null,this._anchorPos=null,this._stable=!0,this._measureChildren=!0,this._estimate=!0}get measureChildren(){return this._measureChildren}updateItemSizes(e){this._metricsCache.update(e,this.direction),this._scheduleReflow()}_getPhysicalItem(e){return this._newPhysicalItems.get(e)??this._physicalItems.get(e)}_getSize(e){return this._getPhysicalItem(e)&&this._metricsCache.getChildSize(e)}_getAverageSize(){return this._metricsCache.averageChildSize||this._itemSize[this._sizeDim]}_estimatePosition(e){const t=this._metricsCache;if(-1===this._first||-1===this._last)return t.averageMarginSize+e*(t.averageMarginSize+this._getAverageSize());if(e<this._first){const M=this._first-e;return this._getPhysicalItem(this._first).pos-(t.getMarginSize(this._first-1)||t.averageMarginSize)-(M*t.averageChildSize+(M-1)*t.averageMarginSize)}{const M=e-this._last;return this._getPhysicalItem(this._last).pos+(t.getChildSize(this._last)||t.averageChildSize)+(t.getMarginSize(this._last)||t.averageMarginSize)+M*(t.averageChildSize+t.averageMarginSize)}}_getPosition(e){const t=this._getPhysicalItem(e),{averageMarginSize:M}=this._metricsCache;return 0===e?this._metricsCache.getMarginSize(0)??M:t?t.pos:this._estimatePosition(e)}_calculateAnchor(e,t){return e<=0?0:t>this._scrollSize-this._viewDim1?this.items.length-1:Math.max(0,Math.min(this.items.length-1,Math.floor((e+t)/2/this._delta)))}_getAnchor(e,t){if(0===this._physicalItems.size)return this._calculateAnchor(e,t);if(this._first<0)return this._calculateAnchor(e,t);if(this._last<0)return this._calculateAnchor(e,t);const M=this._getPhysicalItem(this._first),i=this._getPhysicalItem(this._last),n=M.pos;if(i.pos+this._metricsCache.getChildSize(this._last)<e)return this._calculateAnchor(e,t);if(n>t)return this._calculateAnchor(e,t);let o=this._firstVisible-1,r=-1/0;for(;r<e;){r=this._getPhysicalItem(++o).pos+this._metricsCache.getChildSize(o)}return o}_getActiveItems(){0===this._viewDim1||0===this.items.length?this._clearItems():this._getItems()}_clearItems(){this._first=-1,this._last=-1,this._physicalMin=0,this._physicalMax=0;const e=this._newPhysicalItems;this._newPhysicalItems=this._physicalItems,this._newPhysicalItems.clear(),this._physicalItems=e,this._stable=!0}_getItems(){const e=this._newPhysicalItems;let t,M;if(this._stable=!0,null!==this.pin){const{index:e}=this.pin;this._anchorIdx=e,this._anchorPos=this._getPosition(e)}if(t=this._scrollPosition-this._overhang,M=this._scrollPosition+this._viewDim1+this._overhang,M<0||t>this._scrollSize)return void this._clearItems();null!==this._anchorIdx&&null!==this._anchorPos||(this._anchorIdx=this._getAnchor(t,M),this._anchorPos=this._getPosition(this._anchorIdx));let i=this._getSize(this._anchorIdx);void 0===i&&(this._stable=!1,i=this._getAverageSize());const n=this._metricsCache.getMarginSize(this._anchorIdx)??this._metricsCache.averageMarginSize,o=this._metricsCache.getMarginSize(this._anchorIdx+1)??this._metricsCache.averageMarginSize;0===this._anchorIdx&&(this._anchorPos=n),this._anchorIdx===this.items.length-1&&(this._anchorPos=this._scrollSize-o-i);let r=0;for(this._anchorPos+i+o<t&&(r=t-(this._anchorPos+i+o)),this._anchorPos-n>M&&(r=M-(this._anchorPos-n)),r&&(this._scrollPosition-=r,t-=r,M-=r,this._scrollError+=r),e.set(this._anchorIdx,{pos:this._anchorPos,size:i}),this._first=this._last=this._anchorIdx,this._physicalMin=this._anchorPos-n,this._physicalMax=this._anchorPos+i+o;this._physicalMin>t&&this._first>0;){let t=this._getSize(--this._first);void 0===t&&(this._stable=!1,t=this._getAverageSize());let M=this._metricsCache.getMarginSize(this._first);void 0===M&&(this._stable=!1,M=this._metricsCache.averageMarginSize),this._physicalMin-=t;const i=this._physicalMin;if(e.set(this._first,{pos:i,size:t}),this._physicalMin-=M,!1===this._stable&&!1===this._estimate)break}for(;this._physicalMax<M&&this._last<this.items.length-1;){let t=this._getSize(++this._last);void 0===t&&(this._stable=!1,t=this._getAverageSize());let M=this._metricsCache.getMarginSize(this._last);void 0===M&&(this._stable=!1,M=this._metricsCache.averageMarginSize);const i=this._physicalMax;if(e.set(this._last,{pos:i,size:t}),this._physicalMax+=t+M,!this._stable&&!this._estimate)break}const s=this._calculateError();s&&(this._physicalMin-=s,this._physicalMax-=s,this._anchorPos-=s,this._scrollPosition-=s,e.forEach((e=>e.pos-=s)),this._scrollError+=s),this._stable&&(this._newPhysicalItems=this._physicalItems,this._newPhysicalItems.clear(),this._physicalItems=e)}_calculateError(){return 0===this._first?this._physicalMin:this._physicalMin<=0?this._physicalMin-this._first*this._delta:this._last===this.items.length-1?this._physicalMax-this._scrollSize:this._physicalMax>=this._scrollSize?this._physicalMax-this._scrollSize+(this.items.length-1-this._last)*this._delta:0}_reflow(){const{_first:e,_last:t}=this;super._reflow(),(-1===this._first&&-1==this._last||this._first===e&&this._last===t)&&this._resetReflowState()}_resetReflowState(){this._anchorIdx=null,this._anchorPos=null,this._stable=!0}_updateScrollSize(){const{averageMarginSize:e}=this._metricsCache;this._scrollSize=Math.max(1,this.items.length*(e+this._getAverageSize())+e)}get _delta(){const{averageMarginSize:e}=this._metricsCache;return this._getAverageSize()+e}_getItemPosition(e){return{[this._positionDim]:this._getPosition(e),[this._secondaryPositionDim]:0,[WS(this.direction)]:-(this._metricsCache.getLeadingMarginValue(e,this.direction)??this._metricsCache.averageMarginSize)}}_getItemSize(e){return{[this._sizeDim]:this._getSize(e)||this._getAverageSize(),[this._secondarySizeDim]:this._itemSize[this._secondarySizeDim]}}_viewDim2Changed(){this._metricsCache.clear(),this._scheduleReflow()}}});export{ax as NileAccordion,nn as NileAutoComplete,QL as NileAvatar,gt as NileBadge,tL as NileBreadcrumb,iL as NileBreadcrumbItem,_e as NileButton,gL as NileButtonFilter,Ln as NileButtonToggle,pn as NileButtonToggleGroup,dn as NileCalendar,sL as NileCard,Ut as NileCheckbox,rn as NileChip,uL as NileCircularProgressbar,JO as NileCodeEditor,Un as NileContentEditor,ln as NileDatePicker,vn as NileDialog,lx as NileDivider,Ct as NileDrawer,tn as NileDropdown,CL as NileEmptyState,Dn as NileErrorMessage,Zn as NileErrorNotification,zp as NileFilePreview,qx as NileFileUpload,Ox as NileFilterChip,cn as NileFormErrorMessage,oL as NileFormGroup,In as NileFormHelpText,BL as NileFormatDate,pp as NileGrid,Ep as NileGridBody,bp as NileGridCellItem,fp as NileGridHead,kp as NileGridHeadItem,wp as NileGridRow,Fe as NileHeading,UL as NileHero,WL as NileHeroHeader,me as NileIcon,lt as NileIconButton,dx as NileInlineEdit,ot as NileInput,hn as NileLink,rx as NileList,nx as NileListItem,oi as NileLoader,st as NileMenu,Ki as NileMenuItem,Xi as NileOption,Tp as NileOptionGroup,mL as NilePageHeader,px as NilePagination,NL as NilePopover,KM as NilePopup,si as NileProgressBar,vt as NileRadio,Zt as NileRadioGroup,sS as NileRichTextEditor,cx as NileSectionMessage,Ji as NileSelect,NS as NileSideBar,QS as NileSideBarAction,US as NileSideBarActionMenu,CS as NileSideBarActionMenuItem,jS as NileSideBarExpand,xS as NileSideBarFooter,SS as NileSideBarFooterItem,mS as NileSideBarFooterText,zS as NileSideBarGroup,TS as NileSideBarGroupItem,hS as NileSideBarGroupItemIcon,OS as NileSideBarGroupItemText,gS as NileSideBarHeader,uS as NileSideBarLogo,ii as NileSlideToggle,Cx as NileSlider,Ni as NileSpinner,HL as NileSplitPanel,ZL as NileStepper,vL as NileStepperItem,kn as NileSwitcher,Gn as NileTab,Wn as NileTabGroup,Fn as NileTabPanel,yx as NileTable,xL as NileTableBody,hL as NileTableCellItem,SL as NileTableHeaderItem,OL as NileTableRow,Di as NileTag,an as NileTextarea,Dx as NileTitle,KO as NileToast,Ix as NileToolbar,ti as NileTooltip,Mx as NileTree,KL as NileTreeItem,RL as NileVerticalStepperItem,_i as NileVirtualSelect};
|