@aquera/nile-elements 1.2.5-beta-1.0 → 1.2.5-beta-1.1
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/demo/index.html +28 -8
- package/dist/index.js +2 -2
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.esm.js +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.js +10 -4
- package/dist/src/nile-virtual-select/nile-virtual-select.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 +10 -4
package/demo/index.html
CHANGED
|
@@ -12,16 +12,36 @@
|
|
|
12
12
|
<script type="module" src="index.js"></script>
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
<div style="width: 300px;">
|
|
16
|
+
|
|
17
|
+
<nile-select placeholder="Please Select multiple options" searchEnabled enableVirtualScroll multiple portal>
|
|
18
|
+
</nile-select>
|
|
19
|
+
</div>
|
|
18
20
|
|
|
19
21
|
<script>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
let programmingLanguages = [
|
|
23
|
+
"JavaScript", "TypeScript", "Python", "Java", "C#", "Go", "Rust",
|
|
24
|
+
"Docker", "Kubernetes", "AWS", "Azure", "GCP",
|
|
25
|
+
"React", "Angular", "Vue", "Node.js", "Express",
|
|
26
|
+
"Git", "Jenkins", "Terraform", "Ansible",
|
|
27
|
+
"Agile", "Scrum", "Kanban", "CI/CD",
|
|
28
|
+
"Linux", "Windows", "macOS",
|
|
29
|
+
"SQL", "NoSQL", "GraphQL",
|
|
30
|
+
"Machine Learning", "AI", "Data Science",
|
|
31
|
+
"Security", "Networking", "DevOps"
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
let multiSelectOptions = Array.from({ length: 100000 }, (_, i) => {
|
|
35
|
+
const option = programmingLanguages[i % programmingLanguages.length];
|
|
36
|
+
return {
|
|
37
|
+
value: `multi-${i + 1}`,
|
|
38
|
+
label: `${option} ${i+ 1}`
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
setTimeout(()=> {
|
|
43
|
+
document.querySelector('nile-select').data = multiSelectOptions;
|
|
44
|
+
})
|
|
25
45
|
</script>
|
|
26
46
|
|
|
27
47
|
</body>
|
package/dist/index.js
CHANGED
|
@@ -4679,7 +4679,7 @@ class mi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
|
|
|
4679
4679
|
>
|
|
4680
4680
|
${pe(N)}
|
|
4681
4681
|
</nile-option>
|
|
4682
|
-
`}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 HM(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.wasShowSelectedCheckedOnClose=!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){this.searchValue="";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.originalOptionItems?.length>0&&!this.searchValue&&(this.data=[...this.originalOptionItems]),this.repaintOptionsContainer()),this.calculateTotalWidthOfTags()}handleSearchFocus(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleSearchBlur(){document.addEventListener("keydown",this.handleDocumentKeyDown)}handleSearchChange(e){this.searchValue=e.detail.value,this.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.wasShowSelectedCheckedOnClose&&(this.showSelected=!1,this.data=[...this.originalOptionItems],this.wasShowSelectedCheckedOnClose=!1),this.filterVirtualOptions(""),this.resetScrollPosition(),this.emit("nile-after-show",{value:this.value,name:this.name})}async handleClose(){this.emit("nile-hide",{value:this.value,name:this.name}),this.removeOpenListeners(),this.wasShowSelectedCheckedOnClose=this.showSelected,await 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})}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`
|
|
4682
|
+
`}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 HM(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.wasShowSelectedCheckedOnClose=!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){this.searchValue="";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];try{this.portalManager.resetMeasuredHeight(),this.requestUpdate(),this.repaintOptionsContainer()}catch(e){console.warn("Error in toggleShowSelected",e),console.log("Error in toggleShowSelected",e)}}}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.originalOptionItems?.length>0&&!this.searchValue&&(this.data=[...this.originalOptionItems]),this.repaintOptionsContainer()),this.calculateTotalWidthOfTags()}handleSearchFocus(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleSearchBlur(){document.addEventListener("keydown",this.handleDocumentKeyDown)}handleSearchChange(e){this.searchValue=e.detail.value,this.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.wasShowSelectedCheckedOnClose&&(this.showSelected=!1,this.data=[...this.originalOptionItems],this.wasShowSelectedCheckedOnClose=!1),this.filterVirtualOptions(""),this.resetScrollPosition(),this.emit("nile-after-show",{value:this.value,name:this.name})}async handleClose(){this.emit("nile-hide",{value:this.value,name:this.name}),this.removeOpenListeners(),this.wasShowSelectedCheckedOnClose=this.showSelected,await 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})}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`
|
|
4683
4683
|
<div
|
|
4684
4684
|
part="form-control"
|
|
4685
4685
|
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})}
|
|
@@ -14090,7 +14090,7 @@ nile-rte-toolbar-item nile-button[data-active]::part(base):hover {
|
|
|
14090
14090
|
|
|
14091
14091
|
|
|
14092
14092
|
|
|
14093
|
-
`,IS={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 zS=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(),sS(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(jS.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=IS[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?gS(this.editorEl,"backgroundColor",M,"data-rte-bg"):function(e,t){gS(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=oS(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&&NS(this.editorEl,M),this.updateContent(),this.updateToolbarState()}))}}else e.addEventListener("change",(e=>{this.focusAndRestore();const t=e.detail;rS(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":sS(this.editorEl,"strong");break;case"italic":sS(this.editorEl,"em");break;case"underline":sS(this.editorEl,"u");break;case"left":rS(this.editorEl,"left");break;case"center":rS(this.editorEl,"center");break;case"right":rS(this.editorEl,"right");break;case"justify":rS(this.editorEl,"justify");break;case"ul":cS(this.editorEl,"ul"),this.updateContent(),this.updateToolbarState();break;case"ol":cS(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=oS(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=aS(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=aS(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})],zS.prototype,"value",void 0),e([ue({type:Boolean,attribute:!0,reflect:!0})],zS.prototype,"noStyles",void 0),e([ue({type:Boolean,attribute:"singlelineeditor",reflect:!0})],zS.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)}})],zS.prototype,"mentions",void 0),e([ce()],zS.prototype,"content",void 0),zS=e([le("nile-rich-text-editor")],zS);"undefined"!=typeof window&&(window.nileElementsVersion='"1.2.5-beta-1.0"',window.nileVersion="__NILE_VERSION__");const dS=r`
|
|
14093
|
+
`,IS={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 zS=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(),sS(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(jS.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=IS[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?gS(this.editorEl,"backgroundColor",M,"data-rte-bg"):function(e,t){gS(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=oS(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&&NS(this.editorEl,M),this.updateContent(),this.updateToolbarState()}))}}else e.addEventListener("change",(e=>{this.focusAndRestore();const t=e.detail;rS(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":sS(this.editorEl,"strong");break;case"italic":sS(this.editorEl,"em");break;case"underline":sS(this.editorEl,"u");break;case"left":rS(this.editorEl,"left");break;case"center":rS(this.editorEl,"center");break;case"right":rS(this.editorEl,"right");break;case"justify":rS(this.editorEl,"justify");break;case"ul":cS(this.editorEl,"ul"),this.updateContent(),this.updateToolbarState();break;case"ol":cS(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=oS(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=aS(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=aS(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})],zS.prototype,"value",void 0),e([ue({type:Boolean,attribute:!0,reflect:!0})],zS.prototype,"noStyles",void 0),e([ue({type:Boolean,attribute:"singlelineeditor",reflect:!0})],zS.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)}})],zS.prototype,"mentions",void 0),e([ce()],zS.prototype,"content",void 0),zS=e([le("nile-rich-text-editor")],zS);"undefined"!=typeof window&&(window.nileElementsVersion='"1.2.5-beta-1.1"',window.nileVersion="__NILE_VERSION__");const dS=r`
|
|
14094
14094
|
:host {
|
|
14095
14095
|
--sidebar-width: 240px;
|
|
14096
14096
|
--sidebar-collapsed-width: 70px;
|
|
@@ -2,5 +2,5 @@ System.register(["tslib","lit","lit/decorators.js","./nile-virtual-select.css.cj
|
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2021 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/_export("t",x=/*#__PURE__*/function(){function x(i,_ref){var _this=this;var s=_ref.target,o=_ref.config,n=_ref.callback,c=_ref.skipInitial;_classCallCheck(this,x);this.t=new Set(),this.o=!1,this.i=!1,this.h=i,null!==s&&this.t.add(s!==null&&s!==void 0?s:i),this.l=o,this.o=c!==null&&c!==void 0?c:this.o,this.callback=n,window.ResizeObserver?(this.u=new ResizeObserver(function(i){_this.handleChanges(i),_this.h.requestUpdate();}),i.addController(this)):console.warn("ResizeController error: browser does not support ResizeObserver.");}return _createClass(x,[{key:"handleChanges",value:function handleChanges(i){var _this$callback;this.value=(_this$callback=this.callback)===null||_this$callback===void 0?void 0:_this$callback.call(this,i,this.u);}},{key:"hostConnected",value:function hostConnected(){var _iterator=_createForOfIteratorHelper(this.t),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var _i=_step.value;this.observe(_i);}}catch(err){_iterator.e(err);}finally{_iterator.f();}}},{key:"hostDisconnected",value:function hostDisconnected(){this.disconnect();}},{key:"hostUpdated",value:function(){var _hostUpdated=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){return _regeneratorRuntime().wrap(function _callee$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:!this.o&&this.i&&this.handleChanges([]),this.i=!1;case 1:case"end":return _context2.stop();}},_callee,this);}));function hostUpdated(){return _hostUpdated.apply(this,arguments);}return hostUpdated;}()},{key:"observe",value:function observe(i){this.t.add(i),this.u.observe(i,this.l),this.i=!0,this.h.requestUpdate();}},{key:"unobserve",value:function unobserve(i){this.t["delete"](i),this.u.unobserve(i);}},{key:"disconnect",value:function disconnect(){this.u.disconnect();}}]);}());_export("N",k=/*#__PURE__*/function(_u){function k(){var _this2;_classCallCheck(this,k);_this2=_callSuper(this,k,arguments),_this2.formControlController=new p(_assertThisInitialized(_this2),{assumeInteractionOn:["nile-blur","nile-input"]}),_this2.hasSlotController=new h(_assertThisInitialized(_this2),"help-text","label"),_this2.portalManager=new _(_assertThisInitialized(_this2)),_this2.hasFocus=!1,_this2.displayLabel="",_this2.selectedOptions=[],_this2.oldValue="",_this2.scrolling=!1,_this2.name="",_this2.data=[],_this2.originalOptionItems=[],_this2.value="",_this2.defaultValue="",_this2.size="medium",_this2.placeholder="Select...",_this2.autoResize=!1,_this2.searchValue="",_this2.searchEnabled=!1,_this2.internalSearchPlaceHolder="Search...",_this2.disableLocalSearch=!1,_this2.optionsLoading=!1,_this2.loading=!1,_this2.multiple=!1,_this2.helpText="",_this2.errorMessage="",_this2.warning=!1,_this2.error=!1,_this2.success=!1,_this2.disabled=!1,_this2.clearable=!1,_this2.open=!1,_this2.hoist=!1,_this2.filled=!1,_this2.pill=!1,_this2.label="",_this2.placement="bottom",_this2.form="",_this2.required=!1,_this2.showNoResults=!1,_this2.noResultsMessage="No results found",_this2.showSelected=!1,_this2.blockValueChange=!1,_this2.noWidthSync=!1,_this2.portal=!1,_this2.maxOptionsVisible=3,_this2.oldMaxOptionsVisible=1,_this2.showListbox=!1,_this2.wasShowSelectedCheckedOnClose=!1,_this2.handleDocumentMouseDown=function(i){if(!_this2.open)return;var s=i.composedPath(),o=s.includes(_assertThisInitialized(_this2)),n=_this2.popup&&s.includes(_this2.popup),c=_this2.portal&&_this2.portalManager.portalContainerElement&&s.includes(_this2.portalManager.portalContainerElement);o||n||c||_this2.hide();},_this2.handleWindowError=function(i){var _i$error;(((_i$error=i.error)===null||_i$error===void 0?void 0:_i$error.message)||i.message||"").includes("Cannot read properties of null (reading 'insertBefore')")&&i.preventDefault();},_this2.handleWindowResize=function(){_this2.portalManager.updatePortalAppendPosition();},_this2.handleWindowScroll=function(){_this2.portalManager.updatePortalAppendPosition();},_this2.resizeController=new x(_assertThisInitialized(_this2),{callback:function callback(i){var _iterator2=_createForOfIteratorHelper(i),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var _s=_step2.value;_s.target.classList.contains("select__tags")&&_this2.calculateTotalWidthOfTags();}}catch(err){_iterator2.e(err);}finally{_iterator2.f();}}});return _this2;}_inherits(k,_u);return _createClass(k,[{key:"validity",get:function get(){var _this$valueInput;return(_this$valueInput=this.valueInput)===null||_this$valueInput===void 0?void 0:_this$valueInput.validity;}},{key:"validationMessage",get:function get(){var _this$valueInput$vali,_this$valueInput2;return(_this$valueInput$vali=(_this$valueInput2=this.valueInput)===null||_this$valueInput2===void 0?void 0:_this$valueInput2.validationMessage)!==null&&_this$valueInput$vali!==void 0?_this$valueInput$vali:"";}},{key:"connectedCallback",value:function connectedCallback(){var _this3=this;_superPropGet(k,"connectedCallback",this,3)([]),this.initializeComponent(),this.setupEventListeners(),this.updateComplete.then(function(){_this3.value&&_this3.data.length>0&&_this3.selectionChanged();});}},{key:"disconnectedCallback",value:function disconnectedCallback(){this.removeOpenListeners(),this.scrollTimeout&&(clearTimeout(this.scrollTimeout),this.scrollTimeout=void 0),this.portalManager.cleanupPortalAppend();}},{key:"updated",value:function updated(i){if(i.has("value")&&this.selectionChanged(),i.has("autoResize")){var _this$shadowRoot;var _i2=(_this$shadowRoot=this.shadowRoot)===null||_this$shadowRoot===void 0?void 0:_this$shadowRoot.querySelector(".select__tags");this.autoResize&&_i2?this.resizeController.observe(_i2):_i2&&this.resizeController.unobserve(_i2);}}},{key:"initializeComponent",value:function initializeComponent(){this.open=!1,this.emit("nile-init");}},{key:"getDisplayText",value:function getDisplayText(i){var _this$renderItemConfi;return(_this$renderItemConfi=this.renderItemConfig)!==null&&_this$renderItemConfi!==void 0&&_this$renderItemConfi.getDisplayText?this.renderItemConfig.getDisplayText(i):(i===null||i===void 0?void 0:i.label)||(i===null||i===void 0?void 0:i.name)||(i===null||i===void 0?void 0:i.toString())||"";}},{key:"getItemValue",value:function getItemValue(i){var _this$renderItemConfi2;return(_this$renderItemConfi2=this.renderItemConfig)!==null&&_this$renderItemConfi2!==void 0&&_this$renderItemConfi2.getValue?this.renderItemConfig.getValue(i):(i===null||i===void 0?void 0:i.value)||i;}},{key:"getSearchText",value:function getSearchText(i){var _this$renderItemConfi3;return(_this$renderItemConfi3=this.renderItemConfig)!==null&&_this$renderItemConfi3!==void 0&&_this$renderItemConfi3.getSearchText?this.renderItemConfig.getSearchText(i):this.getDisplayText(i);}},{key:"setupEventListeners",value:function 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);}},{key:"addOpenListeners",value:function 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));}},{key:"removeOpenListeners",value:function 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);}},{key:"handleFocus",value:function handleFocus(){this.hasFocus=!0,this.emit("nile-focus");}},{key:"handleBlur",value:function handleBlur(){this.hasFocus=!1,this.emit("nile-blur");}},{key:"handleDocumentFocusIn",value:function handleDocumentFocusIn(i){if(!this.open)return;var s=i.composedPath(),o=s.includes(this),n=this.popup&&s.includes(this.popup),c=this.portal&&this.portalManager.portalContainerElement&&s.includes(this.portalManager.portalContainerElement);o||n||c||this.hide();}},{key:"handleDocumentKeyDown",value:function handleDocumentKeyDown(i){this.shouldIgnoreKeyPress(i)||(this.isEscapeKey(i)&&this.handleEscapeKey(i),this.isEnterOrSpaceKey(i)&&this.handleEnterOrSpaceKey(i));}},{key:"shouldIgnoreKeyPress",value:function shouldIgnoreKeyPress(i){var s=i.target,o=null!==s.closest(".select__clear"),n=null!==s.closest("nile-icon-button");return o||n;}},{key:"isEscapeKey",value:function isEscapeKey(i){return"Escape"===i.key&&this.open;}},{key:"handleEscapeKey",value:function handleEscapeKey(i){i.preventDefault(),i.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0});}},{key:"isEnterOrSpaceKey",value:function isEnterOrSpaceKey(i){return"Enter"===i.key||" "===i.key;}},{key:"handleEnterOrSpaceKey",value:function handleEnterOrSpaceKey(i){i.preventDefault(),i.stopImmediatePropagation(),this.open?this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})):this.show();}},{key:"handleFooterClick",value:function handleFooterClick(i){i.stopPropagation(),i.preventDefault();}},{key:"toggleShowSelected",value:function toggleShowSelected(i){var _this$selectedOptions,_this4=this;if(i.stopPropagation(),i.preventDefault(),0!==((_this$selectedOptions=this.selectedOptions)===null||_this$selectedOptions===void 0?void 0:_this$selectedOptions.length)){if(this.showSelected=!this.showSelected,this.showSelected){this.searchValue="";var _i3=Array.isArray(this.value)?this.value:[this.value];this.data=this.originalOptionItems.filter(function(s){var o=_this4.getItemValue(s);return _i3.some(function(i){return String(i)===String(o);});});}else this.data=_toConsumableArray(this.originalOptionItems);this.portalManager.resetMeasuredHeight(),this.requestUpdate(),this.repaintOptionsContainer();}}},{key:"unSelectAll",value:function unSelectAll(){this.showSelected=!1,this.value=this.multiple?[]:"",this.data=_toConsumableArray(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();}},{key:"handleLabelClick",value:function handleLabelClick(){this.displayInput.focus(),this.hide();}},{key:"handleComboboxMouseDown",value:function handleComboboxMouseDown(i){this.shouldIgnoreComboboxClick(i)||(i.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open);}},{key:"shouldIgnoreComboboxClick",value:function shouldIgnoreComboboxClick(i){var s=i.composedPath().some(function(i){return i instanceof Element&&"nile-icon-button"===i.tagName.toLowerCase();});return this.disabled||s;}},{key:"handleComboboxKeyDown",value:function handleComboboxKeyDown(i){this.isEnterOrSpaceKey(i)&&(i.preventDefault(),this.open=!this.open);}},{key:"handleClearClick",value:function handleClearClick(i){i.stopPropagation(),this.clearSelection();}},{key:"clearSelection",value:function clearSelection(){var _this5=this;this.value,this.value=this.multiple?[]:"",this.selectionChanged(),this.updateComplete.then(function(){_this5.nileInput({value:_this5.value,name:_this5.name}),_this5.nileChange({value:_this5.value,name:_this5.name}),_this5.emit("nile-clear");});}},{key:"handleClearMouseDown",value:function handleClearMouseDown(i){i.stopPropagation();}},{key:"handleOptionClick",value:function handleOptionClick(i){var s=i.target.closest("nile-option");if(this.shouldBlockValueChange(s))return;var o=this.value;this.oldValue=o,s&&!s.disabled&&this.handleOptionSelection(s);}},{key:"shouldBlockValueChange",value:function shouldBlockValueChange(i){return!(!this.blockValueChange||!i)&&(this.emit("nile-block-change",{value:i===null||i===void 0?void 0:i.value,name:this.name}),this.hide(),!0);}},{key:"handleOptionSelection",value:function handleOptionSelection(i){var _this6=this;var s=i.value;this.multiple?this.toggleOptionSelection(s):this.setSelectedOptions(s),this.updateComplete.then(function(){return _this6.displayInput.focus({preventScroll:!0});}),this.value!==this.oldValue&&this.updateComplete.then(function(){_this6.nileInput({value:_this6.value,name:_this6.name}),_this6.nileChange({value:_this6.value,name:_this6.name});}),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0}));}},{key:"setSelectedOptions",value:function setSelectedOptions(i){this.value=i,this.selectionChanged();}},{key:"toggleOptionSelection",value:function toggleOptionSelection(i){var s=Array.isArray(this.value)?this.value:[];s.includes(i)?this.value=s.filter(function(s){return s!==i;}):this.value=[].concat(_toConsumableArray(s),[i]),this.selectionChanged();}},{key:"handleTagRemove",value:function handleTagRemove(i,s){i.stopPropagation(),this.disabled||(this.removeTagFromSelection(s),this.emitTagRemovalEvent(s));}},{key:"removeTagFromSelection",value:function removeTagFromSelection(i){var s=this.value;Array.isArray(s)||(s=s?[s]:[]);var o=s.filter(function(s){return s!==i.value;});this.value=o,this.selectionChanged();}},{key:"emitTagRemovalEvent",value:function emitTagRemovalEvent(i){var _this7=this;this.updateComplete.then(function(){_this7.nileInput({value:_this7.value,name:_this7.name}),_this7.nileChange({value:_this7.value,name:_this7.name}),_this7.emit("nile-tag-remove",{value:_this7.value,name:_this7.name,removedtagvalue:i.value});});}},{key:"selectionChanged",value:function selectionChanged(){var _this$renderItemConfi4,_this$originalOptionI;var i=this.originalOptionItems.length>0?this.originalOptionItems:this.data;if(this.selectedOptions=b.createVirtualOptionsFromValues(this.value,i,this.getDisplayText.bind(this),(_this$renderItemConfi4=this.renderItemConfig)===null||_this$renderItemConfi4===void 0?void 0:_this$renderItemConfi4.getValue),this.multiple)this.placeholder&&0===this.value.length?this.displayLabel="":this.displayLabel=this.selectedOptions.length+" selected";else{var _this$selectedOptions2;var _i4=Array.isArray(this.value)?this.value[0]:this.value,_s2=(_this$selectedOptions2=this.selectedOptions[0])===null||_this$selectedOptions2===void 0?void 0:_this$selectedOptions2.getTextLabel();this.displayLabel=_s2||(_i4!==null&&_i4!==void 0?_i4:"");}this.updateValidity(),0===this.selectedOptions.length&&(this.showSelected=!1,((_this$originalOptionI=this.originalOptionItems)===null||_this$originalOptionI===void 0?void 0:_this$originalOptionI.length)>0&&!this.searchValue&&(this.data=_toConsumableArray(this.originalOptionItems)),this.repaintOptionsContainer()),this.calculateTotalWidthOfTags();}},{key:"handleSearchFocus",value:function handleSearchFocus(){document.removeEventListener("keydown",this.handleDocumentKeyDown);}},{key:"handleSearchBlur",value:function handleSearchBlur(){document.addEventListener("keydown",this.handleDocumentKeyDown);}},{key:"handleSearchChange",value:function handleSearchChange(i){this.searchValue=i.detail.value,this.emit("nile-search",{query:this.searchValue,name:this.name}),this.disableLocalSearch||(this.filterVirtualOptions(this.searchValue),this.repaintOptionsContainer(),this.portalManager.resetMeasuredHeight());}},{key:"repaintOptionsContainer",value:function repaintOptionsContainer(){var _this8=this;this.resetScrollPosition(),this.updateComplete.then(function(){var _this8$shadowRoot;var i=(_this8$shadowRoot=_this8.shadowRoot)===null||_this8$shadowRoot===void 0?void 0:_this8$shadowRoot.querySelector(".virtualized");i&&(_this8.data.length<=5?i.classList.add("no-scroll"):i.classList.remove("no-scroll"));});}},{key:"handleScroll",value:function handleScroll(i){var _this9=this;if(this.showSelected)return;var s=i.target;this.emit("nile-scroll",{scrollTop:s.scrollTop,scrollLeft:s.scrollLeft,name:this.name}),this.scrolling||(this.scrolling=!0,this.emit("nile-scroll-start",{scrollTop:s.scrollTop,scrollLeft:s.scrollLeft,name:this.name})),clearTimeout(this.scrollTimeout),this.scrollTimeout=window.setTimeout(function(){_this9.scrolling&&(_this9.scrolling=!1);},300);Math.ceil(s.scrollTop)>=Math.floor(s.scrollHeight-s.offsetHeight)&&!this.searchValue&&this.emit("nile-scroll-end",{scrollTop:s.scrollTop,scrollLeft:s.scrollLeft,name:this.name,isAtBottom:!0});}},{key:"filterVirtualOptions",value:function filterVirtualOptions(i){var _this$renderItemConfi5;var s=w.filterVirtualOptions(i,this.originalOptionItems,this.data,this.getDisplayText.bind(this),(_this$renderItemConfi5=this.renderItemConfig)===null||_this$renderItemConfi5===void 0?void 0:_this$renderItemConfi5.getSearchText);this.data=s.filteredItems,this.showNoResults=s.showNoResults,this.showSelected=!1,this.requestUpdate();}},{key:"handleInvalid",value:function handleInvalid(i){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(i);}},{key:"handleDisabledChange",value:function handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange());}},{key:"handleValueChange",value:function handleValueChange(){this.selectionChanged(),this.requestUpdate(),this.portal&&this.portalManager.portalContainerElement&&this.portalManager.updatePortalAppendPosition();}},{key:"handleDataChange",value:function handleDataChange(){this.data.length>0&&this.open&&!this.showSelected&&!this.searchValue&&(this.originalOptionItems=_toConsumableArray(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();}},{key:"handleRenderItemConfigChange",value:function handleRenderItemConfigChange(){this.value&&this.data.length>0&&(this.selectionChanged(),this.requestUpdate());}},{key:"handleOptionsLoadingChange",value:function handleOptionsLoadingChange(){this.optionsLoading||0!==this.data.length||(this.showNoResults=!0),this.requestUpdate(),this.portal&&this.portalManager.portalContainerElement&&this.portalManager.updatePortalAppendPosition();}},{key:"handlePortalAppendChange",value:function handlePortalAppendChange(){this.open&&(this.portal?this.portalManager.setupPortalAppend():this.portalManager.cleanupPortalAppend());}},{key:"handleOpenChange",value:function(){var _handleOpenChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(){return _regeneratorRuntime().wrap(function _callee2$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(!(this.open&&!this.disabled)){_context3.next=7;break;}_context3.next=3;return this.handleOpen();case 3:this.showListbox=!0;this.portal&&this.portalManager.setupPortalAppend();_context3.next=11;break;case 7:_context3.next=9;return this.handleClose();case 9:this.showListbox=!1;this.portal&&this.portalManager.cleanupPortalAppend();case 11:case"end":return _context3.stop();}},_callee2,this);}));function handleOpenChange(){return _handleOpenChange.apply(this,arguments);}return handleOpenChange;}()},{key:"handleOpen",value:function(){var _handleOpen=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(){var _this$data;var _g,i,s;return _regeneratorRuntime().wrap(function _callee3$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:this.emit("nile-show",{value:this.value,name:this.name});this.addOpenListeners();this.showNoResults=!((_this$data=this.data)!==null&&_this$data!==void 0&&_this$data.length);_context4.next=5;return l(this);case 5:this.popup.active=!0;_g=g(this,"select.show",{dir:"ltr"}),i=_g.keyframes,s=_g.options;_context4.next=9;return r(this.popup.popup,i,s);case 9:this.wasShowSelectedCheckedOnClose&&(this.showSelected=!1,this.data=_toConsumableArray(this.originalOptionItems),this.wasShowSelectedCheckedOnClose=!1);this.filterVirtualOptions("");this.resetScrollPosition();this.emit("nile-after-show",{value:this.value,name:this.name});case 13:case"end":return _context4.stop();}},_callee3,this);}));function handleOpen(){return _handleOpen.apply(this,arguments);}return handleOpen;}()},{key:"handleClose",value:function(){var _handleClose=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(){var _g2,i,s;return _regeneratorRuntime().wrap(function _callee4$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:this.emit("nile-hide",{value:this.value,name:this.name});this.removeOpenListeners();this.wasShowSelectedCheckedOnClose=this.showSelected;_context5.next=5;return l(this);case 5:_g2=g(this,"select.hide",{dir:"ltr"}),i=_g2.keyframes,s=_g2.options;_context5.next=8;return r(this.popup.popup,i,s);case 8:this.popup.active=!1;this.searchValue="";this.portalManager.resetMeasuredHeight();this.emit("nile-after-hide",{value:this.value,name:this.name});case 12:case"end":return _context5.stop();}},_callee4,this);}));function handleClose(){return _handleClose.apply(this,arguments);}return handleClose;}()},{key:"show",value:function(){var _show=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(){return _regeneratorRuntime().wrap(function _callee5$(_context6){while(1)switch(_context6.prev=_context6.next){case 0:if(!(!this.open&&!this.disabled)){_context6.next=2;break;}return _context6.abrupt("return",(this.open=!0,v(this,"nile-after-show")));case 2:this.open=!1;case 3:case"end":return _context6.stop();}},_callee5,this);}));function show(){return _show.apply(this,arguments);}return show;}()},{key:"hide",value:function(){var _hide=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(){return _regeneratorRuntime().wrap(function _callee6$(_context7){while(1)switch(_context7.prev=_context7.next){case 0:if(!(this.open&&!this.disabled)){_context7.next=2;break;}return _context7.abrupt("return",(this.open=!1,v(this,"nile-after-hide")));case 2:this.open=!1;case 3:case"end":return _context7.stop();}},_callee6,this);}));function hide(){return _hide.apply(this,arguments);}return hide;}()},{key:"checkValidity",value:function checkValidity(){return this.valueInput.checkValidity();}},{key:"getForm",value:function getForm(){return this.formControlController.getForm();}},{key:"reportValidity",value:function reportValidity(){return this.valueInput.reportValidity();}},{key:"setCustomValidity",value:function setCustomValidity(i){this.valueInput.setCustomValidity(i),this.formControlController.updateValidity();}},{key:"focus",value:function focus(i){this.displayInput.focus(i);}},{key:"blur",value:function blur(){this.displayInput.blur();}},{key:"onInputChange",value:function onInputChange(i){i.stopPropagation();}},{key:"render",value:function render(){var i=this.hasSlotController.test("label");this.hasSlotController.test("help-text");var o=this.hasSlotController.test("label-suffix"),n=this.hasSlotController.test("custom-select"),c=!!this.label||!!i,t=this.clearable&&!this.disabled&&this.value.length>0,e=!!this.placeholder&&0===this.value.length,l=!!this.helpText,r=!!this.errorMessage;return s(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <div\n part=\"form-control\"\n class=","\n >\n ","\n ","\n </div>\n "])),j({"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":c,"form-control--has-help-text":l}),this.renderLabel(c,o),this.renderFormControlInput(n,t,e,l,r));}},{key:"renderLabel",value:function renderLabel(i,o){return s(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["\n <label\n id=\"label\"\n part=\"form-control-label\"\n class=\"form-control__label\"\n aria-hidden=","\n @click=","\n >\n <slot name=\"label\">","</slot>\n </label>\n\n ","\n "])),i?"false":"true",this.handleLabelClick,this.label,o?s(_templateObject3||(_templateObject3=_taggedTemplateLiteral([" <slot name=\"label-suffix\"></slot> "]))):"");}},{key:"renderFormControlInput",value:function renderFormControlInput(i,o,n,c,t){return s(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["\n <div part=\"form-control-input\" class=\"form-control-input\">\n ","\n ","\n </div>\n "])),this.renderPopup(i,o,n),this.renderHelpText(c,t));}},{key:"renderPopup",value:function renderPopup(i,o,n){return s(_templateObject5||(_templateObject5=_taggedTemplateLiteral(["\n <nile-popup\n class=","\n placement=","\n strategy=","\n distance=\"6\"\n ?flip=","\n ?shift=","\n sync=","\n auto-size=\"vertical\"\n auto-size-padding=\"10\"\n >\n ","\n ","\n ","\n </nile-popup>\n "])),j({select:!0,"select--warning":this.warning,"select--error":this.error,"select--success":this.success,"select--standard":!0,"select--filled":this.filled,"select--pill":this.pill,"select--open":this.open,"select--disabled":this.disabled,"select--multiple":this.multiple,"select--focused":this.hasFocus,"select--placeholder-visible":n,"select--top":"top"===this.placement,"select--bottom":"bottom"===this.placement,"select--small":"small"===this.size,"select--medium":"medium"===this.size,"select--large":"large"===this.size}),this.placement,this.portal||this.hoist?"fixed":"absolute",!this.portal,!this.portal,f(this.noWidthSync?void 0:"width"),this.renderCustomSelect(i),this.renderCombobox(i,o),this.showListbox?this.renderListbox():s(_templateObject6||(_templateObject6=_taggedTemplateLiteral([""]))));}},{key:"renderCustomSelect",value:function renderCustomSelect(i){return i?s(_templateObject7||(_templateObject7=_taggedTemplateLiteral(["<slot\n slot=\"anchor\"\n name=\"custom-select\"\n class=\"custom-select\"\n @keydown=","\n @mousedown=","\n ></slot>"])),this.handleComboboxKeyDown,this.handleComboboxMouseDown):s(_templateObject8||(_templateObject8=_taggedTemplateLiteral([""])));}},{key:"renderCombobox",value:function renderCombobox(i,o){return s(_templateObject9||(_templateObject9=_taggedTemplateLiteral(["\n <div\n part=\"combobox\"\n class=","\n slot=\"anchor\"\n @keydown=","\n @mousedown=","\n >\n ","\n ","\n ","\n ","\n ","\n ","\n ","\n </div>\n "])),j({select__combobox:!0,"select__hide-default":i}),this.handleComboboxKeyDown,this.handleComboboxMouseDown,this.renderPrefix(),this.renderDisplayInput(),this.renderTags(),this.renderValueInput(),this.renderClearButton(o),this.renderSuffix(),this.renderExpandIcon());}},{key:"renderPrefix",value:function renderPrefix(){return s(_templateObject10||(_templateObject10=_taggedTemplateLiteral(["\n <slot\n part=\"prefix\"\n name=\"prefix\"\n class=","\n ></slot>\n "])),j({select__prefix:!0,multiple:this.multiple}));}},{key:"renderDisplayInput",value:function renderDisplayInput(){return s(_templateObject11||(_templateObject11=_taggedTemplateLiteral(["\n <input\n part=\"display-input\"\n class=\"select__display-input\"\n type=\"text\"\n placeholder=","\n .disabled=","\n .value=","\n autocomplete=\"off\"\n spellcheck=\"false\"\n autocapitalize=\"off\"\n readonly\n aria-controls=\"listbox\"\n aria-expanded=","\n aria-haspopup=\"listbox\"\n aria-labelledby=\"label\"\n aria-disabled=","\n aria-describedby=\"help-text\"\n role=\"combobox\"\n tabindex=\"0\"\n />\n "])),this.placeholder,this.disabled,this.displayLabel,this.open?"true":"false",this.disabled?"true":"false");}},{key:"renderTags",value:function renderTags(){var _this10=this;return this.multiple?s(_templateObject12||(_templateObject12=_taggedTemplateLiteral(["\n <div part=\"tags\" class=\"select__tags\">\n ","\n </div>\n "])),this.selectedOptions.map(function(i,o){if(o<_this10.maxOptionsVisible||_this10.maxOptionsVisible<=0){var _n={select__invisible:o+1>_this10.oldMaxOptionsVisible&&_this10.maxOptionsVisible===1/0};return s(_templateObject13||(_templateObject13=_taggedTemplateLiteral(["\n <nile-tag\n class=","\n part=\"tag\"\n exportparts=\"\n base:tag__base,\n content:tag__content,\n remove-button:tag__remove-button,\n remove-button__base:tag__remove-button__base\n \"\n ?pill=","\n size=","\n removable\n @nile-remove=","\n >\n ","\n </nile-tag>\n "])),j(_n),_this10.pill,_this10.size,function(s){return _this10.handleTagRemove(s,i);},i.getTextLabel());}return o===_this10.maxOptionsVisible?s(_templateObject14||(_templateObject14=_taggedTemplateLiteral(["\n <span class=\"select__tags-count\"\n >+"," More\n </span>\n "])),_this10.selectedOptions.length-o):null;})):s(_templateObject15||(_templateObject15=_taggedTemplateLiteral([""])));}},{key:"renderValueInput",value:function renderValueInput(){var _this11=this;return s(_templateObject16||(_templateObject16=_taggedTemplateLiteral(["\n <input\n class=\"select__value-input\"\n type=\"text\"\n ?disabled=","\n ?required=","\n .value=","\n tabindex=\"-1\"\n aria-hidden=\"true\"\n @focus=","\n @invalid=","\n />\n "])),this.disabled,this.required,Array.isArray(this.value)?this.value.join(", "):this.value,function(){return _this11.focus();},this.handleInvalid);}},{key:"renderClearButton",value:function renderClearButton(i){return i?s(_templateObject17||(_templateObject17=_taggedTemplateLiteral(["\n <button\n part=\"clear-button\"\n class=\"select__clear\"\n type=\"button\"\n aria-label=\"clearEntry\"\n @mousedown=","\n @click=","\n tabindex=\"-1\"\n >\n <slot name=\"clear-icon\">\n <nile-icon name=\"var(--nile-icon-close, var(--ng-icon-x-close))\" method=\"var(--nile-svg-method-fill, var(--ng-svg-method-stroke))\" library=\"system\"></nile-icon>\n </slot>\n </button>\n "])),this.handleClearMouseDown,this.handleClearClick):s(_templateObject18||(_templateObject18=_taggedTemplateLiteral([""])));}},{key:"renderSuffix",value:function renderSuffix(){return s(_templateObject19||(_templateObject19=_taggedTemplateLiteral(["\n <slot\n part=\"suffix\"\n name=\"suffix\"\n class=","\n ></slot>\n "])),j({select__suffix:!0}));}},{key:"renderExpandIcon",value:function renderExpandIcon(){return s(_templateObject20||(_templateObject20=_taggedTemplateLiteral(["\n <slot\n name=\"expand-icon\"\n part=\"expand-icon\"\n class=\"select__expand-icon\"\n >\n <nile-icon library=\"system\" name=\"var(--nile-icon-arrow-down, var(--ng-icon-chevron-down))\" method=\"var(--nile-svg-method-fill, var(--ng-svg-method-stroke))\"></nile-icon>\n </slot>\n "])));}},{key:"renderListbox",value:function renderListbox(){return s(_templateObject21||(_templateObject21=_taggedTemplateLiteral(["\n <div\n id=\"listbox\"\n role=\"listbox\"\n aria-expanded=","\n aria-multiselectable=","\n aria-labelledby=\"label\"\n part=\"listbox\"\n class=\"select__listbox "," ","\"\n tabindex=\"-1\"\n @mouseup=","\n style=","\n >\n ","\n ","\n ","\n ","\n </div>\n "])),this.open?"true":"false",this.multiple?"true":"false",this.searchEnabled?"select__search-enabled ":"",this.portal?"select__portal-append-hidden":"",this.handleOptionClick,this.portal?"display: none;":"",this.renderSearch(),this.renderLoader(),this.getVirtualizedContent(),this.renderFooter());}},{key:"renderSearch",value:function renderSearch(){return this.searchEnabled?s(_templateObject22||(_templateObject22=_taggedTemplateLiteral(["\n <div part=\"search\" class=\"select__search\">\n <nile-input\n size=\"small\"\n clearable\n .value=","\n placeholder=\"","\"\n @nile-input=","\n @nile-focus=","\n @nile-change=\"","\"\n >\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 </div>\n "])),this.searchValue,this.internalSearchPlaceHolder,this.handleSearchChange,this.handleSearchFocus,this.onInputChange):s(_templateObject23||(_templateObject23=_taggedTemplateLiteral([""])));}},{key:"renderLoader",value:function renderLoader(){return this.loading?s(_templateObject24||(_templateObject24=_taggedTemplateLiteral(["\n <span part=\"loader\" class=\"virtual-select-loader\">\n <nile-loader size=\"sm\"></nile-loader>\n </span>\n "]))):this.optionsLoading?s(_templateObject25||(_templateObject25=_taggedTemplateLiteral(["\n <span part=\"loader\" class=\"select__loader\">\n <nile-icon\n class=\"select__loader--icon\"\n name=\"button-loading-blue\"\n ></nile-icon>\n </span>\n "]))):s(_templateObject26||(_templateObject26=_taggedTemplateLiteral([""])));}},{key:"renderFooter",value:function renderFooter(){return this.multiple?s(_templateObject27||(_templateObject27=_taggedTemplateLiteral(["\n <div\n part=\"footer\"\n class=\"select__footer ","\"\n @click=\"","\"\n >\n <span\n @click=\"","\"\n style=\"cursor: pointer;\"\n >\n <nile-checkbox\n ?disabled=\"","\"\n ?checked=\"","\"\n >\n Show Selected</nile-checkbox\n >\n </span>\n ","\n </div>\n "])),this.loading?"loading":"",this.handleFooterClick,this.toggleShowSelected,0===this.selectedOptions.length,this.showSelected,0!==this.selectedOptions.length?s(_templateObject28||(_templateObject28=_taggedTemplateLiteral(["\n <span\n class=\"select__clear\"\n @click=\"","\"\n >\n Clear All\n </span>\n "])),this.unSelectAll):""):s(_templateObject29||(_templateObject29=_taggedTemplateLiteral([""])));}},{key:"renderHelpText",value:function renderHelpText(i,o){return s(_templateObject30||(_templateObject30=_taggedTemplateLiteral(["\n ","\n ","\n "])),i?s(_templateObject31||(_templateObject31=_taggedTemplateLiteral([" <nile-form-help-text>","</nile-form-help-text> "])),this.helpText):"",o?s(_templateObject32||(_templateObject32=_taggedTemplateLiteral(["\n <nile-form-error-message\n >","</nile-form-error-message\n >\n "])),this.errorMessage):"");}},{key:"getVirtualizedContent",value:function getVirtualizedContent(){var _this$renderItemConfi6,_this$renderItemConfi7;return y.getVirtualizedContent(this.data,this.searchEnabled,this.getDisplayText.bind(this),this.value,this.multiple,(_this$renderItemConfi6=this.renderItemConfig)===null||_this$renderItemConfi6===void 0?void 0:_this$renderItemConfi6.getDisplayText,(_this$renderItemConfi7=this.renderItemConfig)===null||_this$renderItemConfi7===void 0?void 0:_this$renderItemConfi7.getValue,this.showNoResults,this.noResultsMessage,this.optionsLoading||this.loading,this.handleScroll.bind(this));}},{key:"nileInput",value:function nileInput(i){this.emit("nile-input",i);}},{key:"nileChange",value:function nileChange(i){this.emit("nile-change",i);}},{key:"updateValidity",value:function updateValidity(){var _this12=this;this.updateComplete.then(function(){_this12.formControlController.updateValidity();});}},{key:"calculateWidthOfSelectTagsDiv",value:function calculateWidthOfSelectTagsDiv(){if(this.shadowRoot){var _i5=this.shadowRoot.querySelector(".select__tags");if(_i5){return _i5.offsetWidth-70;}}return null;}},{key:"calculateTotalWidthOfTags",value:function calculateTotalWidthOfTags(){var _this13=this;this.maxOptionsVisible!==1/0&&(this.oldMaxOptionsVisible=this.maxOptionsVisible),this.maxOptionsVisible=1/0,setTimeout(function(){var i=[];if(_this13.shadowRoot){_this13.shadowRoot.querySelectorAll("nile-tag").forEach(function(s){s instanceof HTMLElement&&i.push(s.offsetWidth);});}if(_this13.value.length!==i.length)return;var s=_this13.calculateWidthOfSelectTagsDiv();if(!s)return;var o=0,n=0;for(var _c=0;_c<i.length;_c++)if(o+=i[_c],o>s){n=_c;break;}_this13.maxOptionsVisible=n;},1);}},{key:"resetScrollPosition",value:function resetScrollPosition(){var _this14=this;this.updateComplete.then(function(){if(_this14.virtualizedContainer&&_this14.virtualizedContainer.isConnected){var _this14$shadowRoot;_this14.virtualizedContainer.scrollTop=0;var _i6=(_this14$shadowRoot=_this14.shadowRoot)===null||_this14$shadowRoot===void 0?void 0:_this14$shadowRoot.querySelector(".select__listbox");_i6&&_i6.isConnected&&(_i6.scrollTop=0);var _s3=_this14.virtualizedContainer.querySelector("lit-virtualizer");_s3&&_s3.isConnected&&(_s3.scrollTop=0);}});}}]);}(u));k.styles=e,i([o(".select")],k.prototype,"popup",void 0),i([o(".select__combobox")],k.prototype,"combobox",void 0),i([o(".select__display-input")],k.prototype,"displayInput",void 0),i([o(".select__value-input")],k.prototype,"valueInput",void 0),i([o(".virtualized")],k.prototype,"virtualizedContainer",void 0),i([n()],k.prototype,"hasFocus",void 0),i([n()],k.prototype,"displayLabel",void 0),i([n()],k.prototype,"selectedOptions",void 0),i([n()],k.prototype,"oldValue",void 0),i([c()],k.prototype,"name",void 0),i([c({type:Array})],k.prototype,"data",void 0),i([n()],k.prototype,"originalOptionItems",void 0),i([c({converter:{fromAttribute:function fromAttribute(i){return i.split(" ");},toAttribute:function toAttribute(i){return i.join(" ");}}})],k.prototype,"value",void 0),i([a()],k.prototype,"defaultValue",void 0),i([c()],k.prototype,"size",void 0),i([c()],k.prototype,"placeholder",void 0),i([c({type:Boolean})],k.prototype,"autoResize",void 0),i([n()],k.prototype,"searchValue",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"searchEnabled",void 0),i([c({attribute:"internal-search-placeholder"})],k.prototype,"internalSearchPlaceHolder",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"disableLocalSearch",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"optionsLoading",void 0),i([c({type:Boolean,reflect:!0,attribute:!0})],k.prototype,"loading",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"multiple",void 0),i([c({attribute:"help-text",reflect:!0})],k.prototype,"helpText",void 0),i([c({attribute:"error-message",reflect:!0})],k.prototype,"errorMessage",void 0),i([c({type:Boolean})],k.prototype,"warning",void 0),i([c({type:Boolean})],k.prototype,"error",void 0),i([c({type:Boolean})],k.prototype,"success",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"disabled",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"clearable",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"open",void 0),i([c({type:Boolean})],k.prototype,"hoist",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"filled",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"pill",void 0),i([c()],k.prototype,"label",void 0),i([c({reflect:!0})],k.prototype,"placement",void 0),i([c({reflect:!0})],k.prototype,"form",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"required",void 0),i([c({type:Boolean})],k.prototype,"showNoResults",void 0),i([c({type:String})],k.prototype,"noResultsMessage",void 0),i([c({type:Boolean})],k.prototype,"showSelected",void 0),i([c({attribute:!1})],k.prototype,"renderItemConfig",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"blockValueChange",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"noWidthSync",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"portal",void 0),i([c({attribute:"max-options-visible",type:Number})],k.prototype,"maxOptionsVisible",void 0),i([n()],k.prototype,"oldMaxOptionsVisible",void 0),i([n()],k.prototype,"showListbox",void 0),i([n()],k.prototype,"wasShowSelectedCheckedOnClose",void 0),i([d("disabled",{waitUntilFirstUpdate:!0})],k.prototype,"handleDisabledChange",null),i([d("value",{waitUntilFirstUpdate:!0})],k.prototype,"handleValueChange",null),i([d("data",{waitUntilFirstUpdate:!0})],k.prototype,"handleDataChange",null),i([d("renderItemConfig",{waitUntilFirstUpdate:!0})],k.prototype,"handleRenderItemConfigChange",null),i([d("optionsLoading",{waitUntilFirstUpdate:!0})],k.prototype,"handleOptionsLoadingChange",null),i([d("portal",{waitUntilFirstUpdate:!0})],k.prototype,"handlePortalAppendChange",null),i([d("open",{waitUntilFirstUpdate:!0})],k.prototype,"handleOpenChange",null),_export("N",k=i([t("nile-virtual-select")],k)),m("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),m("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});}};});
|
|
5
|
+
*/_export("t",x=/*#__PURE__*/function(){function x(i,_ref){var _this=this;var s=_ref.target,o=_ref.config,n=_ref.callback,c=_ref.skipInitial;_classCallCheck(this,x);this.t=new Set(),this.o=!1,this.i=!1,this.h=i,null!==s&&this.t.add(s!==null&&s!==void 0?s:i),this.l=o,this.o=c!==null&&c!==void 0?c:this.o,this.callback=n,window.ResizeObserver?(this.u=new ResizeObserver(function(i){_this.handleChanges(i),_this.h.requestUpdate();}),i.addController(this)):console.warn("ResizeController error: browser does not support ResizeObserver.");}return _createClass(x,[{key:"handleChanges",value:function handleChanges(i){var _this$callback;this.value=(_this$callback=this.callback)===null||_this$callback===void 0?void 0:_this$callback.call(this,i,this.u);}},{key:"hostConnected",value:function hostConnected(){var _iterator=_createForOfIteratorHelper(this.t),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var _i=_step.value;this.observe(_i);}}catch(err){_iterator.e(err);}finally{_iterator.f();}}},{key:"hostDisconnected",value:function hostDisconnected(){this.disconnect();}},{key:"hostUpdated",value:function(){var _hostUpdated=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){return _regeneratorRuntime().wrap(function _callee$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:!this.o&&this.i&&this.handleChanges([]),this.i=!1;case 1:case"end":return _context2.stop();}},_callee,this);}));function hostUpdated(){return _hostUpdated.apply(this,arguments);}return hostUpdated;}()},{key:"observe",value:function observe(i){this.t.add(i),this.u.observe(i,this.l),this.i=!0,this.h.requestUpdate();}},{key:"unobserve",value:function unobserve(i){this.t["delete"](i),this.u.unobserve(i);}},{key:"disconnect",value:function disconnect(){this.u.disconnect();}}]);}());_export("N",k=/*#__PURE__*/function(_u){function k(){var _this2;_classCallCheck(this,k);_this2=_callSuper(this,k,arguments),_this2.formControlController=new p(_assertThisInitialized(_this2),{assumeInteractionOn:["nile-blur","nile-input"]}),_this2.hasSlotController=new h(_assertThisInitialized(_this2),"help-text","label"),_this2.portalManager=new _(_assertThisInitialized(_this2)),_this2.hasFocus=!1,_this2.displayLabel="",_this2.selectedOptions=[],_this2.oldValue="",_this2.scrolling=!1,_this2.name="",_this2.data=[],_this2.originalOptionItems=[],_this2.value="",_this2.defaultValue="",_this2.size="medium",_this2.placeholder="Select...",_this2.autoResize=!1,_this2.searchValue="",_this2.searchEnabled=!1,_this2.internalSearchPlaceHolder="Search...",_this2.disableLocalSearch=!1,_this2.optionsLoading=!1,_this2.loading=!1,_this2.multiple=!1,_this2.helpText="",_this2.errorMessage="",_this2.warning=!1,_this2.error=!1,_this2.success=!1,_this2.disabled=!1,_this2.clearable=!1,_this2.open=!1,_this2.hoist=!1,_this2.filled=!1,_this2.pill=!1,_this2.label="",_this2.placement="bottom",_this2.form="",_this2.required=!1,_this2.showNoResults=!1,_this2.noResultsMessage="No results found",_this2.showSelected=!1,_this2.blockValueChange=!1,_this2.noWidthSync=!1,_this2.portal=!1,_this2.maxOptionsVisible=3,_this2.oldMaxOptionsVisible=1,_this2.showListbox=!1,_this2.wasShowSelectedCheckedOnClose=!1,_this2.handleDocumentMouseDown=function(i){if(!_this2.open)return;var s=i.composedPath(),o=s.includes(_assertThisInitialized(_this2)),n=_this2.popup&&s.includes(_this2.popup),c=_this2.portal&&_this2.portalManager.portalContainerElement&&s.includes(_this2.portalManager.portalContainerElement);o||n||c||_this2.hide();},_this2.handleWindowError=function(i){var _i$error;(((_i$error=i.error)===null||_i$error===void 0?void 0:_i$error.message)||i.message||"").includes("Cannot read properties of null (reading 'insertBefore')")&&i.preventDefault();},_this2.handleWindowResize=function(){_this2.portalManager.updatePortalAppendPosition();},_this2.handleWindowScroll=function(){_this2.portalManager.updatePortalAppendPosition();},_this2.resizeController=new x(_assertThisInitialized(_this2),{callback:function callback(i){var _iterator2=_createForOfIteratorHelper(i),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var _s=_step2.value;_s.target.classList.contains("select__tags")&&_this2.calculateTotalWidthOfTags();}}catch(err){_iterator2.e(err);}finally{_iterator2.f();}}});return _this2;}_inherits(k,_u);return _createClass(k,[{key:"validity",get:function get(){var _this$valueInput;return(_this$valueInput=this.valueInput)===null||_this$valueInput===void 0?void 0:_this$valueInput.validity;}},{key:"validationMessage",get:function get(){var _this$valueInput$vali,_this$valueInput2;return(_this$valueInput$vali=(_this$valueInput2=this.valueInput)===null||_this$valueInput2===void 0?void 0:_this$valueInput2.validationMessage)!==null&&_this$valueInput$vali!==void 0?_this$valueInput$vali:"";}},{key:"connectedCallback",value:function connectedCallback(){var _this3=this;_superPropGet(k,"connectedCallback",this,3)([]),this.initializeComponent(),this.setupEventListeners(),this.updateComplete.then(function(){_this3.value&&_this3.data.length>0&&_this3.selectionChanged();});}},{key:"disconnectedCallback",value:function disconnectedCallback(){this.removeOpenListeners(),this.scrollTimeout&&(clearTimeout(this.scrollTimeout),this.scrollTimeout=void 0),this.portalManager.cleanupPortalAppend();}},{key:"updated",value:function updated(i){if(i.has("value")&&this.selectionChanged(),i.has("autoResize")){var _this$shadowRoot;var _i2=(_this$shadowRoot=this.shadowRoot)===null||_this$shadowRoot===void 0?void 0:_this$shadowRoot.querySelector(".select__tags");this.autoResize&&_i2?this.resizeController.observe(_i2):_i2&&this.resizeController.unobserve(_i2);}}},{key:"initializeComponent",value:function initializeComponent(){this.open=!1,this.emit("nile-init");}},{key:"getDisplayText",value:function getDisplayText(i){var _this$renderItemConfi;return(_this$renderItemConfi=this.renderItemConfig)!==null&&_this$renderItemConfi!==void 0&&_this$renderItemConfi.getDisplayText?this.renderItemConfig.getDisplayText(i):(i===null||i===void 0?void 0:i.label)||(i===null||i===void 0?void 0:i.name)||(i===null||i===void 0?void 0:i.toString())||"";}},{key:"getItemValue",value:function getItemValue(i){var _this$renderItemConfi2;return(_this$renderItemConfi2=this.renderItemConfig)!==null&&_this$renderItemConfi2!==void 0&&_this$renderItemConfi2.getValue?this.renderItemConfig.getValue(i):(i===null||i===void 0?void 0:i.value)||i;}},{key:"getSearchText",value:function getSearchText(i){var _this$renderItemConfi3;return(_this$renderItemConfi3=this.renderItemConfig)!==null&&_this$renderItemConfi3!==void 0&&_this$renderItemConfi3.getSearchText?this.renderItemConfig.getSearchText(i):this.getDisplayText(i);}},{key:"setupEventListeners",value:function 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);}},{key:"addOpenListeners",value:function 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));}},{key:"removeOpenListeners",value:function 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);}},{key:"handleFocus",value:function handleFocus(){this.hasFocus=!0,this.emit("nile-focus");}},{key:"handleBlur",value:function handleBlur(){this.hasFocus=!1,this.emit("nile-blur");}},{key:"handleDocumentFocusIn",value:function handleDocumentFocusIn(i){if(!this.open)return;var s=i.composedPath(),o=s.includes(this),n=this.popup&&s.includes(this.popup),c=this.portal&&this.portalManager.portalContainerElement&&s.includes(this.portalManager.portalContainerElement);o||n||c||this.hide();}},{key:"handleDocumentKeyDown",value:function handleDocumentKeyDown(i){this.shouldIgnoreKeyPress(i)||(this.isEscapeKey(i)&&this.handleEscapeKey(i),this.isEnterOrSpaceKey(i)&&this.handleEnterOrSpaceKey(i));}},{key:"shouldIgnoreKeyPress",value:function shouldIgnoreKeyPress(i){var s=i.target,o=null!==s.closest(".select__clear"),n=null!==s.closest("nile-icon-button");return o||n;}},{key:"isEscapeKey",value:function isEscapeKey(i){return"Escape"===i.key&&this.open;}},{key:"handleEscapeKey",value:function handleEscapeKey(i){i.preventDefault(),i.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0});}},{key:"isEnterOrSpaceKey",value:function isEnterOrSpaceKey(i){return"Enter"===i.key||" "===i.key;}},{key:"handleEnterOrSpaceKey",value:function handleEnterOrSpaceKey(i){i.preventDefault(),i.stopImmediatePropagation(),this.open?this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})):this.show();}},{key:"handleFooterClick",value:function handleFooterClick(i){i.stopPropagation(),i.preventDefault();}},{key:"toggleShowSelected",value:function toggleShowSelected(i){var _this$selectedOptions,_this4=this;if(i.stopPropagation(),i.preventDefault(),0!==((_this$selectedOptions=this.selectedOptions)===null||_this$selectedOptions===void 0?void 0:_this$selectedOptions.length)){if(this.showSelected=!this.showSelected,this.showSelected){this.searchValue="";var _i3=Array.isArray(this.value)?this.value:[this.value];this.data=this.originalOptionItems.filter(function(s){var o=_this4.getItemValue(s);return _i3.some(function(i){return String(i)===String(o);});});}else this.data=_toConsumableArray(this.originalOptionItems);try{this.portalManager.resetMeasuredHeight(),this.requestUpdate(),this.repaintOptionsContainer();}catch(i){console.warn("Error in toggleShowSelected",i),console.log("Error in toggleShowSelected",i);}}}},{key:"unSelectAll",value:function unSelectAll(){this.showSelected=!1,this.value=this.multiple?[]:"",this.data=_toConsumableArray(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();}},{key:"handleLabelClick",value:function handleLabelClick(){this.displayInput.focus(),this.hide();}},{key:"handleComboboxMouseDown",value:function handleComboboxMouseDown(i){this.shouldIgnoreComboboxClick(i)||(i.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open);}},{key:"shouldIgnoreComboboxClick",value:function shouldIgnoreComboboxClick(i){var s=i.composedPath().some(function(i){return i instanceof Element&&"nile-icon-button"===i.tagName.toLowerCase();});return this.disabled||s;}},{key:"handleComboboxKeyDown",value:function handleComboboxKeyDown(i){this.isEnterOrSpaceKey(i)&&(i.preventDefault(),this.open=!this.open);}},{key:"handleClearClick",value:function handleClearClick(i){i.stopPropagation(),this.clearSelection();}},{key:"clearSelection",value:function clearSelection(){var _this5=this;this.value,this.value=this.multiple?[]:"",this.selectionChanged(),this.updateComplete.then(function(){_this5.nileInput({value:_this5.value,name:_this5.name}),_this5.nileChange({value:_this5.value,name:_this5.name}),_this5.emit("nile-clear");});}},{key:"handleClearMouseDown",value:function handleClearMouseDown(i){i.stopPropagation();}},{key:"handleOptionClick",value:function handleOptionClick(i){var s=i.target.closest("nile-option");if(this.shouldBlockValueChange(s))return;var o=this.value;this.oldValue=o,s&&!s.disabled&&this.handleOptionSelection(s);}},{key:"shouldBlockValueChange",value:function shouldBlockValueChange(i){return!(!this.blockValueChange||!i)&&(this.emit("nile-block-change",{value:i===null||i===void 0?void 0:i.value,name:this.name}),this.hide(),!0);}},{key:"handleOptionSelection",value:function handleOptionSelection(i){var _this6=this;var s=i.value;this.multiple?this.toggleOptionSelection(s):this.setSelectedOptions(s),this.updateComplete.then(function(){return _this6.displayInput.focus({preventScroll:!0});}),this.value!==this.oldValue&&this.updateComplete.then(function(){_this6.nileInput({value:_this6.value,name:_this6.name}),_this6.nileChange({value:_this6.value,name:_this6.name});}),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0}));}},{key:"setSelectedOptions",value:function setSelectedOptions(i){this.value=i,this.selectionChanged();}},{key:"toggleOptionSelection",value:function toggleOptionSelection(i){var s=Array.isArray(this.value)?this.value:[];s.includes(i)?this.value=s.filter(function(s){return s!==i;}):this.value=[].concat(_toConsumableArray(s),[i]),this.selectionChanged();}},{key:"handleTagRemove",value:function handleTagRemove(i,s){i.stopPropagation(),this.disabled||(this.removeTagFromSelection(s),this.emitTagRemovalEvent(s));}},{key:"removeTagFromSelection",value:function removeTagFromSelection(i){var s=this.value;Array.isArray(s)||(s=s?[s]:[]);var o=s.filter(function(s){return s!==i.value;});this.value=o,this.selectionChanged();}},{key:"emitTagRemovalEvent",value:function emitTagRemovalEvent(i){var _this7=this;this.updateComplete.then(function(){_this7.nileInput({value:_this7.value,name:_this7.name}),_this7.nileChange({value:_this7.value,name:_this7.name}),_this7.emit("nile-tag-remove",{value:_this7.value,name:_this7.name,removedtagvalue:i.value});});}},{key:"selectionChanged",value:function selectionChanged(){var _this$renderItemConfi4,_this$originalOptionI;var i=this.originalOptionItems.length>0?this.originalOptionItems:this.data;if(this.selectedOptions=b.createVirtualOptionsFromValues(this.value,i,this.getDisplayText.bind(this),(_this$renderItemConfi4=this.renderItemConfig)===null||_this$renderItemConfi4===void 0?void 0:_this$renderItemConfi4.getValue),this.multiple)this.placeholder&&0===this.value.length?this.displayLabel="":this.displayLabel=this.selectedOptions.length+" selected";else{var _this$selectedOptions2;var _i4=Array.isArray(this.value)?this.value[0]:this.value,_s2=(_this$selectedOptions2=this.selectedOptions[0])===null||_this$selectedOptions2===void 0?void 0:_this$selectedOptions2.getTextLabel();this.displayLabel=_s2||(_i4!==null&&_i4!==void 0?_i4:"");}this.updateValidity(),0===this.selectedOptions.length&&(this.showSelected=!1,((_this$originalOptionI=this.originalOptionItems)===null||_this$originalOptionI===void 0?void 0:_this$originalOptionI.length)>0&&!this.searchValue&&(this.data=_toConsumableArray(this.originalOptionItems)),this.repaintOptionsContainer()),this.calculateTotalWidthOfTags();}},{key:"handleSearchFocus",value:function handleSearchFocus(){document.removeEventListener("keydown",this.handleDocumentKeyDown);}},{key:"handleSearchBlur",value:function handleSearchBlur(){document.addEventListener("keydown",this.handleDocumentKeyDown);}},{key:"handleSearchChange",value:function handleSearchChange(i){this.searchValue=i.detail.value,this.emit("nile-search",{query:this.searchValue,name:this.name}),this.disableLocalSearch||(this.filterVirtualOptions(this.searchValue),this.repaintOptionsContainer(),this.portalManager.resetMeasuredHeight());}},{key:"repaintOptionsContainer",value:function repaintOptionsContainer(){var _this8=this;this.resetScrollPosition(),this.updateComplete.then(function(){var _this8$shadowRoot;var i=(_this8$shadowRoot=_this8.shadowRoot)===null||_this8$shadowRoot===void 0?void 0:_this8$shadowRoot.querySelector(".virtualized");i&&(_this8.data.length<=5?i.classList.add("no-scroll"):i.classList.remove("no-scroll"));});}},{key:"handleScroll",value:function handleScroll(i){var _this9=this;if(this.showSelected)return;var s=i.target;this.emit("nile-scroll",{scrollTop:s.scrollTop,scrollLeft:s.scrollLeft,name:this.name}),this.scrolling||(this.scrolling=!0,this.emit("nile-scroll-start",{scrollTop:s.scrollTop,scrollLeft:s.scrollLeft,name:this.name})),clearTimeout(this.scrollTimeout),this.scrollTimeout=window.setTimeout(function(){_this9.scrolling&&(_this9.scrolling=!1);},300);Math.ceil(s.scrollTop)>=Math.floor(s.scrollHeight-s.offsetHeight)&&!this.searchValue&&this.emit("nile-scroll-end",{scrollTop:s.scrollTop,scrollLeft:s.scrollLeft,name:this.name,isAtBottom:!0});}},{key:"filterVirtualOptions",value:function filterVirtualOptions(i){var _this$renderItemConfi5;var s=w.filterVirtualOptions(i,this.originalOptionItems,this.data,this.getDisplayText.bind(this),(_this$renderItemConfi5=this.renderItemConfig)===null||_this$renderItemConfi5===void 0?void 0:_this$renderItemConfi5.getSearchText);this.data=s.filteredItems,this.showNoResults=s.showNoResults,this.showSelected=!1,this.requestUpdate();}},{key:"handleInvalid",value:function handleInvalid(i){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(i);}},{key:"handleDisabledChange",value:function handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange());}},{key:"handleValueChange",value:function handleValueChange(){this.selectionChanged(),this.requestUpdate(),this.portal&&this.portalManager.portalContainerElement&&this.portalManager.updatePortalAppendPosition();}},{key:"handleDataChange",value:function handleDataChange(){this.data.length>0&&this.open&&!this.showSelected&&!this.searchValue&&(this.originalOptionItems=_toConsumableArray(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();}},{key:"handleRenderItemConfigChange",value:function handleRenderItemConfigChange(){this.value&&this.data.length>0&&(this.selectionChanged(),this.requestUpdate());}},{key:"handleOptionsLoadingChange",value:function handleOptionsLoadingChange(){this.optionsLoading||0!==this.data.length||(this.showNoResults=!0),this.requestUpdate(),this.portal&&this.portalManager.portalContainerElement&&this.portalManager.updatePortalAppendPosition();}},{key:"handlePortalAppendChange",value:function handlePortalAppendChange(){this.open&&(this.portal?this.portalManager.setupPortalAppend():this.portalManager.cleanupPortalAppend());}},{key:"handleOpenChange",value:function(){var _handleOpenChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(){return _regeneratorRuntime().wrap(function _callee2$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(!(this.open&&!this.disabled)){_context3.next=7;break;}_context3.next=3;return this.handleOpen();case 3:this.showListbox=!0;this.portal&&this.portalManager.setupPortalAppend();_context3.next=11;break;case 7:_context3.next=9;return this.handleClose();case 9:this.showListbox=!1;this.portal&&this.portalManager.cleanupPortalAppend();case 11:case"end":return _context3.stop();}},_callee2,this);}));function handleOpenChange(){return _handleOpenChange.apply(this,arguments);}return handleOpenChange;}()},{key:"handleOpen",value:function(){var _handleOpen=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(){var _this$data;var _g,i,s;return _regeneratorRuntime().wrap(function _callee3$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:this.emit("nile-show",{value:this.value,name:this.name});this.addOpenListeners();this.showNoResults=!((_this$data=this.data)!==null&&_this$data!==void 0&&_this$data.length);_context4.next=5;return l(this);case 5:this.popup.active=!0;_g=g(this,"select.show",{dir:"ltr"}),i=_g.keyframes,s=_g.options;_context4.next=9;return r(this.popup.popup,i,s);case 9:this.wasShowSelectedCheckedOnClose&&(this.showSelected=!1,this.data=_toConsumableArray(this.originalOptionItems),this.wasShowSelectedCheckedOnClose=!1);this.filterVirtualOptions("");this.resetScrollPosition();this.emit("nile-after-show",{value:this.value,name:this.name});case 13:case"end":return _context4.stop();}},_callee3,this);}));function handleOpen(){return _handleOpen.apply(this,arguments);}return handleOpen;}()},{key:"handleClose",value:function(){var _handleClose=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(){var _g2,i,s;return _regeneratorRuntime().wrap(function _callee4$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:this.emit("nile-hide",{value:this.value,name:this.name});this.removeOpenListeners();this.wasShowSelectedCheckedOnClose=this.showSelected;_context5.next=5;return l(this);case 5:_g2=g(this,"select.hide",{dir:"ltr"}),i=_g2.keyframes,s=_g2.options;_context5.next=8;return r(this.popup.popup,i,s);case 8:this.popup.active=!1;this.searchValue="";this.portalManager.resetMeasuredHeight();this.emit("nile-after-hide",{value:this.value,name:this.name});case 12:case"end":return _context5.stop();}},_callee4,this);}));function handleClose(){return _handleClose.apply(this,arguments);}return handleClose;}()},{key:"show",value:function(){var _show=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(){return _regeneratorRuntime().wrap(function _callee5$(_context6){while(1)switch(_context6.prev=_context6.next){case 0:if(!(!this.open&&!this.disabled)){_context6.next=2;break;}return _context6.abrupt("return",(this.open=!0,v(this,"nile-after-show")));case 2:this.open=!1;case 3:case"end":return _context6.stop();}},_callee5,this);}));function show(){return _show.apply(this,arguments);}return show;}()},{key:"hide",value:function(){var _hide=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(){return _regeneratorRuntime().wrap(function _callee6$(_context7){while(1)switch(_context7.prev=_context7.next){case 0:if(!(this.open&&!this.disabled)){_context7.next=2;break;}return _context7.abrupt("return",(this.open=!1,v(this,"nile-after-hide")));case 2:this.open=!1;case 3:case"end":return _context7.stop();}},_callee6,this);}));function hide(){return _hide.apply(this,arguments);}return hide;}()},{key:"checkValidity",value:function checkValidity(){return this.valueInput.checkValidity();}},{key:"getForm",value:function getForm(){return this.formControlController.getForm();}},{key:"reportValidity",value:function reportValidity(){return this.valueInput.reportValidity();}},{key:"setCustomValidity",value:function setCustomValidity(i){this.valueInput.setCustomValidity(i),this.formControlController.updateValidity();}},{key:"focus",value:function focus(i){this.displayInput.focus(i);}},{key:"blur",value:function blur(){this.displayInput.blur();}},{key:"onInputChange",value:function onInputChange(i){i.stopPropagation();}},{key:"render",value:function render(){var i=this.hasSlotController.test("label");this.hasSlotController.test("help-text");var o=this.hasSlotController.test("label-suffix"),n=this.hasSlotController.test("custom-select"),c=!!this.label||!!i,t=this.clearable&&!this.disabled&&this.value.length>0,e=!!this.placeholder&&0===this.value.length,l=!!this.helpText,r=!!this.errorMessage;return s(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <div\n part=\"form-control\"\n class=","\n >\n ","\n ","\n </div>\n "])),j({"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":c,"form-control--has-help-text":l}),this.renderLabel(c,o),this.renderFormControlInput(n,t,e,l,r));}},{key:"renderLabel",value:function renderLabel(i,o){return s(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["\n <label\n id=\"label\"\n part=\"form-control-label\"\n class=\"form-control__label\"\n aria-hidden=","\n @click=","\n >\n <slot name=\"label\">","</slot>\n </label>\n\n ","\n "])),i?"false":"true",this.handleLabelClick,this.label,o?s(_templateObject3||(_templateObject3=_taggedTemplateLiteral([" <slot name=\"label-suffix\"></slot> "]))):"");}},{key:"renderFormControlInput",value:function renderFormControlInput(i,o,n,c,t){return s(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["\n <div part=\"form-control-input\" class=\"form-control-input\">\n ","\n ","\n </div>\n "])),this.renderPopup(i,o,n),this.renderHelpText(c,t));}},{key:"renderPopup",value:function renderPopup(i,o,n){return s(_templateObject5||(_templateObject5=_taggedTemplateLiteral(["\n <nile-popup\n class=","\n placement=","\n strategy=","\n distance=\"6\"\n ?flip=","\n ?shift=","\n sync=","\n auto-size=\"vertical\"\n auto-size-padding=\"10\"\n >\n ","\n ","\n ","\n </nile-popup>\n "])),j({select:!0,"select--warning":this.warning,"select--error":this.error,"select--success":this.success,"select--standard":!0,"select--filled":this.filled,"select--pill":this.pill,"select--open":this.open,"select--disabled":this.disabled,"select--multiple":this.multiple,"select--focused":this.hasFocus,"select--placeholder-visible":n,"select--top":"top"===this.placement,"select--bottom":"bottom"===this.placement,"select--small":"small"===this.size,"select--medium":"medium"===this.size,"select--large":"large"===this.size}),this.placement,this.portal||this.hoist?"fixed":"absolute",!this.portal,!this.portal,f(this.noWidthSync?void 0:"width"),this.renderCustomSelect(i),this.renderCombobox(i,o),this.showListbox?this.renderListbox():s(_templateObject6||(_templateObject6=_taggedTemplateLiteral([""]))));}},{key:"renderCustomSelect",value:function renderCustomSelect(i){return i?s(_templateObject7||(_templateObject7=_taggedTemplateLiteral(["<slot\n slot=\"anchor\"\n name=\"custom-select\"\n class=\"custom-select\"\n @keydown=","\n @mousedown=","\n ></slot>"])),this.handleComboboxKeyDown,this.handleComboboxMouseDown):s(_templateObject8||(_templateObject8=_taggedTemplateLiteral([""])));}},{key:"renderCombobox",value:function renderCombobox(i,o){return s(_templateObject9||(_templateObject9=_taggedTemplateLiteral(["\n <div\n part=\"combobox\"\n class=","\n slot=\"anchor\"\n @keydown=","\n @mousedown=","\n >\n ","\n ","\n ","\n ","\n ","\n ","\n ","\n </div>\n "])),j({select__combobox:!0,"select__hide-default":i}),this.handleComboboxKeyDown,this.handleComboboxMouseDown,this.renderPrefix(),this.renderDisplayInput(),this.renderTags(),this.renderValueInput(),this.renderClearButton(o),this.renderSuffix(),this.renderExpandIcon());}},{key:"renderPrefix",value:function renderPrefix(){return s(_templateObject10||(_templateObject10=_taggedTemplateLiteral(["\n <slot\n part=\"prefix\"\n name=\"prefix\"\n class=","\n ></slot>\n "])),j({select__prefix:!0,multiple:this.multiple}));}},{key:"renderDisplayInput",value:function renderDisplayInput(){return s(_templateObject11||(_templateObject11=_taggedTemplateLiteral(["\n <input\n part=\"display-input\"\n class=\"select__display-input\"\n type=\"text\"\n placeholder=","\n .disabled=","\n .value=","\n autocomplete=\"off\"\n spellcheck=\"false\"\n autocapitalize=\"off\"\n readonly\n aria-controls=\"listbox\"\n aria-expanded=","\n aria-haspopup=\"listbox\"\n aria-labelledby=\"label\"\n aria-disabled=","\n aria-describedby=\"help-text\"\n role=\"combobox\"\n tabindex=\"0\"\n />\n "])),this.placeholder,this.disabled,this.displayLabel,this.open?"true":"false",this.disabled?"true":"false");}},{key:"renderTags",value:function renderTags(){var _this10=this;return this.multiple?s(_templateObject12||(_templateObject12=_taggedTemplateLiteral(["\n <div part=\"tags\" class=\"select__tags\">\n ","\n </div>\n "])),this.selectedOptions.map(function(i,o){if(o<_this10.maxOptionsVisible||_this10.maxOptionsVisible<=0){var _n={select__invisible:o+1>_this10.oldMaxOptionsVisible&&_this10.maxOptionsVisible===1/0};return s(_templateObject13||(_templateObject13=_taggedTemplateLiteral(["\n <nile-tag\n class=","\n part=\"tag\"\n exportparts=\"\n base:tag__base,\n content:tag__content,\n remove-button:tag__remove-button,\n remove-button__base:tag__remove-button__base\n \"\n ?pill=","\n size=","\n removable\n @nile-remove=","\n >\n ","\n </nile-tag>\n "])),j(_n),_this10.pill,_this10.size,function(s){return _this10.handleTagRemove(s,i);},i.getTextLabel());}return o===_this10.maxOptionsVisible?s(_templateObject14||(_templateObject14=_taggedTemplateLiteral(["\n <span class=\"select__tags-count\"\n >+"," More\n </span>\n "])),_this10.selectedOptions.length-o):null;})):s(_templateObject15||(_templateObject15=_taggedTemplateLiteral([""])));}},{key:"renderValueInput",value:function renderValueInput(){var _this11=this;return s(_templateObject16||(_templateObject16=_taggedTemplateLiteral(["\n <input\n class=\"select__value-input\"\n type=\"text\"\n ?disabled=","\n ?required=","\n .value=","\n tabindex=\"-1\"\n aria-hidden=\"true\"\n @focus=","\n @invalid=","\n />\n "])),this.disabled,this.required,Array.isArray(this.value)?this.value.join(", "):this.value,function(){return _this11.focus();},this.handleInvalid);}},{key:"renderClearButton",value:function renderClearButton(i){return i?s(_templateObject17||(_templateObject17=_taggedTemplateLiteral(["\n <button\n part=\"clear-button\"\n class=\"select__clear\"\n type=\"button\"\n aria-label=\"clearEntry\"\n @mousedown=","\n @click=","\n tabindex=\"-1\"\n >\n <slot name=\"clear-icon\">\n <nile-icon name=\"var(--nile-icon-close, var(--ng-icon-x-close))\" method=\"var(--nile-svg-method-fill, var(--ng-svg-method-stroke))\" library=\"system\"></nile-icon>\n </slot>\n </button>\n "])),this.handleClearMouseDown,this.handleClearClick):s(_templateObject18||(_templateObject18=_taggedTemplateLiteral([""])));}},{key:"renderSuffix",value:function renderSuffix(){return s(_templateObject19||(_templateObject19=_taggedTemplateLiteral(["\n <slot\n part=\"suffix\"\n name=\"suffix\"\n class=","\n ></slot>\n "])),j({select__suffix:!0}));}},{key:"renderExpandIcon",value:function renderExpandIcon(){return s(_templateObject20||(_templateObject20=_taggedTemplateLiteral(["\n <slot\n name=\"expand-icon\"\n part=\"expand-icon\"\n class=\"select__expand-icon\"\n >\n <nile-icon library=\"system\" name=\"var(--nile-icon-arrow-down, var(--ng-icon-chevron-down))\" method=\"var(--nile-svg-method-fill, var(--ng-svg-method-stroke))\"></nile-icon>\n </slot>\n "])));}},{key:"renderListbox",value:function renderListbox(){return s(_templateObject21||(_templateObject21=_taggedTemplateLiteral(["\n <div\n id=\"listbox\"\n role=\"listbox\"\n aria-expanded=","\n aria-multiselectable=","\n aria-labelledby=\"label\"\n part=\"listbox\"\n class=\"select__listbox "," ","\"\n tabindex=\"-1\"\n @mouseup=","\n style=","\n >\n ","\n ","\n ","\n ","\n </div>\n "])),this.open?"true":"false",this.multiple?"true":"false",this.searchEnabled?"select__search-enabled ":"",this.portal?"select__portal-append-hidden":"",this.handleOptionClick,this.portal?"display: none;":"",this.renderSearch(),this.renderLoader(),this.getVirtualizedContent(),this.renderFooter());}},{key:"renderSearch",value:function renderSearch(){return this.searchEnabled?s(_templateObject22||(_templateObject22=_taggedTemplateLiteral(["\n <div part=\"search\" class=\"select__search\">\n <nile-input\n size=\"small\"\n clearable\n .value=","\n placeholder=\"","\"\n @nile-input=","\n @nile-focus=","\n @nile-change=\"","\"\n >\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 </div>\n "])),this.searchValue,this.internalSearchPlaceHolder,this.handleSearchChange,this.handleSearchFocus,this.onInputChange):s(_templateObject23||(_templateObject23=_taggedTemplateLiteral([""])));}},{key:"renderLoader",value:function renderLoader(){return this.loading?s(_templateObject24||(_templateObject24=_taggedTemplateLiteral(["\n <span part=\"loader\" class=\"virtual-select-loader\">\n <nile-loader size=\"sm\"></nile-loader>\n </span>\n "]))):this.optionsLoading?s(_templateObject25||(_templateObject25=_taggedTemplateLiteral(["\n <span part=\"loader\" class=\"select__loader\">\n <nile-icon\n class=\"select__loader--icon\"\n name=\"button-loading-blue\"\n ></nile-icon>\n </span>\n "]))):s(_templateObject26||(_templateObject26=_taggedTemplateLiteral([""])));}},{key:"renderFooter",value:function renderFooter(){return this.multiple?s(_templateObject27||(_templateObject27=_taggedTemplateLiteral(["\n <div\n part=\"footer\"\n class=\"select__footer ","\"\n @click=\"","\"\n >\n <span\n @click=\"","\"\n style=\"cursor: pointer;\"\n >\n <nile-checkbox\n ?disabled=\"","\"\n ?checked=\"","\"\n >\n Show Selected</nile-checkbox\n >\n </span>\n ","\n </div>\n "])),this.loading?"loading":"",this.handleFooterClick,this.toggleShowSelected,0===this.selectedOptions.length,this.showSelected,0!==this.selectedOptions.length?s(_templateObject28||(_templateObject28=_taggedTemplateLiteral(["\n <span\n class=\"select__clear\"\n @click=\"","\"\n >\n Clear All\n </span>\n "])),this.unSelectAll):""):s(_templateObject29||(_templateObject29=_taggedTemplateLiteral([""])));}},{key:"renderHelpText",value:function renderHelpText(i,o){return s(_templateObject30||(_templateObject30=_taggedTemplateLiteral(["\n ","\n ","\n "])),i?s(_templateObject31||(_templateObject31=_taggedTemplateLiteral([" <nile-form-help-text>","</nile-form-help-text> "])),this.helpText):"",o?s(_templateObject32||(_templateObject32=_taggedTemplateLiteral(["\n <nile-form-error-message\n >","</nile-form-error-message\n >\n "])),this.errorMessage):"");}},{key:"getVirtualizedContent",value:function getVirtualizedContent(){var _this$renderItemConfi6,_this$renderItemConfi7;return y.getVirtualizedContent(this.data,this.searchEnabled,this.getDisplayText.bind(this),this.value,this.multiple,(_this$renderItemConfi6=this.renderItemConfig)===null||_this$renderItemConfi6===void 0?void 0:_this$renderItemConfi6.getDisplayText,(_this$renderItemConfi7=this.renderItemConfig)===null||_this$renderItemConfi7===void 0?void 0:_this$renderItemConfi7.getValue,this.showNoResults,this.noResultsMessage,this.optionsLoading||this.loading,this.handleScroll.bind(this));}},{key:"nileInput",value:function nileInput(i){this.emit("nile-input",i);}},{key:"nileChange",value:function nileChange(i){this.emit("nile-change",i);}},{key:"updateValidity",value:function updateValidity(){var _this12=this;this.updateComplete.then(function(){_this12.formControlController.updateValidity();});}},{key:"calculateWidthOfSelectTagsDiv",value:function calculateWidthOfSelectTagsDiv(){if(this.shadowRoot){var _i5=this.shadowRoot.querySelector(".select__tags");if(_i5){return _i5.offsetWidth-70;}}return null;}},{key:"calculateTotalWidthOfTags",value:function calculateTotalWidthOfTags(){var _this13=this;this.maxOptionsVisible!==1/0&&(this.oldMaxOptionsVisible=this.maxOptionsVisible),this.maxOptionsVisible=1/0,setTimeout(function(){var i=[];if(_this13.shadowRoot){_this13.shadowRoot.querySelectorAll("nile-tag").forEach(function(s){s instanceof HTMLElement&&i.push(s.offsetWidth);});}if(_this13.value.length!==i.length)return;var s=_this13.calculateWidthOfSelectTagsDiv();if(!s)return;var o=0,n=0;for(var _c=0;_c<i.length;_c++)if(o+=i[_c],o>s){n=_c;break;}_this13.maxOptionsVisible=n;},1);}},{key:"resetScrollPosition",value:function resetScrollPosition(){var _this14=this;this.updateComplete.then(function(){if(_this14.virtualizedContainer&&_this14.virtualizedContainer.isConnected){var _this14$shadowRoot;_this14.virtualizedContainer.scrollTop=0;var _i6=(_this14$shadowRoot=_this14.shadowRoot)===null||_this14$shadowRoot===void 0?void 0:_this14$shadowRoot.querySelector(".select__listbox");_i6&&_i6.isConnected&&(_i6.scrollTop=0);var _s3=_this14.virtualizedContainer.querySelector("lit-virtualizer");_s3&&_s3.isConnected&&(_s3.scrollTop=0);}});}}]);}(u));k.styles=e,i([o(".select")],k.prototype,"popup",void 0),i([o(".select__combobox")],k.prototype,"combobox",void 0),i([o(".select__display-input")],k.prototype,"displayInput",void 0),i([o(".select__value-input")],k.prototype,"valueInput",void 0),i([o(".virtualized")],k.prototype,"virtualizedContainer",void 0),i([n()],k.prototype,"hasFocus",void 0),i([n()],k.prototype,"displayLabel",void 0),i([n()],k.prototype,"selectedOptions",void 0),i([n()],k.prototype,"oldValue",void 0),i([c()],k.prototype,"name",void 0),i([c({type:Array})],k.prototype,"data",void 0),i([n()],k.prototype,"originalOptionItems",void 0),i([c({converter:{fromAttribute:function fromAttribute(i){return i.split(" ");},toAttribute:function toAttribute(i){return i.join(" ");}}})],k.prototype,"value",void 0),i([a()],k.prototype,"defaultValue",void 0),i([c()],k.prototype,"size",void 0),i([c()],k.prototype,"placeholder",void 0),i([c({type:Boolean})],k.prototype,"autoResize",void 0),i([n()],k.prototype,"searchValue",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"searchEnabled",void 0),i([c({attribute:"internal-search-placeholder"})],k.prototype,"internalSearchPlaceHolder",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"disableLocalSearch",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"optionsLoading",void 0),i([c({type:Boolean,reflect:!0,attribute:!0})],k.prototype,"loading",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"multiple",void 0),i([c({attribute:"help-text",reflect:!0})],k.prototype,"helpText",void 0),i([c({attribute:"error-message",reflect:!0})],k.prototype,"errorMessage",void 0),i([c({type:Boolean})],k.prototype,"warning",void 0),i([c({type:Boolean})],k.prototype,"error",void 0),i([c({type:Boolean})],k.prototype,"success",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"disabled",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"clearable",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"open",void 0),i([c({type:Boolean})],k.prototype,"hoist",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"filled",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"pill",void 0),i([c()],k.prototype,"label",void 0),i([c({reflect:!0})],k.prototype,"placement",void 0),i([c({reflect:!0})],k.prototype,"form",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"required",void 0),i([c({type:Boolean})],k.prototype,"showNoResults",void 0),i([c({type:String})],k.prototype,"noResultsMessage",void 0),i([c({type:Boolean})],k.prototype,"showSelected",void 0),i([c({attribute:!1})],k.prototype,"renderItemConfig",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"blockValueChange",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"noWidthSync",void 0),i([c({type:Boolean,reflect:!0})],k.prototype,"portal",void 0),i([c({attribute:"max-options-visible",type:Number})],k.prototype,"maxOptionsVisible",void 0),i([n()],k.prototype,"oldMaxOptionsVisible",void 0),i([n()],k.prototype,"showListbox",void 0),i([n()],k.prototype,"wasShowSelectedCheckedOnClose",void 0),i([d("disabled",{waitUntilFirstUpdate:!0})],k.prototype,"handleDisabledChange",null),i([d("value",{waitUntilFirstUpdate:!0})],k.prototype,"handleValueChange",null),i([d("data",{waitUntilFirstUpdate:!0})],k.prototype,"handleDataChange",null),i([d("renderItemConfig",{waitUntilFirstUpdate:!0})],k.prototype,"handleRenderItemConfigChange",null),i([d("optionsLoading",{waitUntilFirstUpdate:!0})],k.prototype,"handleOptionsLoadingChange",null),i([d("portal",{waitUntilFirstUpdate:!0})],k.prototype,"handlePortalAppendChange",null),i([d("open",{waitUntilFirstUpdate:!0})],k.prototype,"handleOpenChange",null),_export("N",k=i([t("nile-virtual-select")],k)),m("select.show",{keyframes:[{opacity:0,scale:.9},{opacity:1,scale:1}],options:{duration:100,easing:"ease"}}),m("select.hide",{keyframes:[{opacity:1,scale:1},{opacity:0,scale:.9}],options:{duration:100,easing:"ease"}});}};});
|
|
6
6
|
//# sourceMappingURL=nile-virtual-select.cjs.js.map
|