@aquera/nile-elements 1.2.0-beta-1.2 → 1.2.0-beta-1.4

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 CHANGED
@@ -25,10 +25,10 @@
25
25
  -->
26
26
 
27
27
 
28
- <nile-inline-sidebar id="sidebar">
28
+ <nile-inline-sidebar id="sidebar" >
29
29
  <nile-inline-sidebar-group >
30
30
  <nile-inline-sidebar-item>Basic Details</nile-inline-sidebar-item>
31
- <nile-inline-sidebar-item>Creation Email Details</nile-inline-sidebar-item>
31
+ <nile-inline-sidebar-item>Creation skdjnasjnd asdasdjnasdas sdasdsdnas da sd asd asd asdoasd</nile-inline-sidebar-item>
32
32
  <nile-inline-sidebar-item active>Deactivation Email Details</nile-inline-sidebar-item>
33
33
  <nile-inline-sidebar-item>Advanced Details</nile-inline-sidebar-item>
34
34
  <nile-inline-sidebar-item disabled>Admin Email Options</nile-inline-sidebar-item>
package/dist/index.js CHANGED
@@ -13996,7 +13996,7 @@ nile-rte-toolbar-item nile-button[data-active]::part(base):hover {
13996
13996
 
13997
13997
 
13998
13998
 
13999
- `,tS={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 MS=class extends Ne{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(),Fp(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(eS.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=tS[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?$p(this.editorEl,"backgroundColor",M,"data-rte-bg"):function(e,t){$p(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=Pp(M.getRangeAt(0).startContainer,e);if(!i)return;if(i.tagName.toLowerCase()===t)return;const n=document.createElement(t);for(;i.firstChild;)n.appendChild(i.firstChild);i.replaceWith(n);const o=document.createRange();o.selectNodeContents(n),o.collapse(!0),M.removeAllRanges(),M.addRange(o)}(this.editorEl,M):"font"===t&&function(e,t){const M=document.getSelection();if(!M||0===M.rangeCount)return;const i=M.getRangeAt(0);if(i.collapsed){const e=document.createElement("span");e.style.fontFamily=t,e.appendChild(document.createTextNode("​")),i.insertNode(e);const n=document.createRange();return n.setStart(e.firstChild,1),n.collapse(!0),M.removeAllRanges(),void M.addRange(n)}Bp(i,"span",{style:`font-family:${t}`})}(this.editorEl,M),this.updateContent(),this.updateToolbarState()}))}}else e.addEventListener("change",(e=>{this.focusAndRestore();const t=e.detail;Jp(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":Fp(this.editorEl,"strong");break;case"italic":Fp(this.editorEl,"em");break;case"underline":Fp(this.editorEl,"u");break;case"left":Jp(this.editorEl,"left");break;case"center":Jp(this.editorEl,"center");break;case"right":Jp(this.editorEl,"right");break;case"justify":Jp(this.editorEl,"justify");break;case"ul":Kp(this.editorEl,"ul"),this.updateContent(),this.updateToolbarState();break;case"ol":Kp(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=Pp(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})(),N=!!M.closest("a"),a=n.style.textAlign||getComputedStyle(n).textAlign||"start",l="start"===a?"left":a,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",N),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=Rp(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=Rp(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})],MS.prototype,"value",void 0),e([ue({type:Boolean,attribute:!0,reflect:!0})],MS.prototype,"noStyles",void 0),e([ue({type:Boolean,attribute:"singlelineeditor",reflect:!0})],MS.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)}})],MS.prototype,"mentions",void 0),e([ce()],MS.prototype,"content",void 0),MS=e([le("nile-rich-text-editor")],MS);"undefined"!=typeof window&&(window.nileElementsVersion='"1.2.0-beta-1.2"',window.nileVersion="__NILE_VERSION__");const iS=r`
13999
+ `,tS={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 MS=class extends Ne{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(),Fp(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(eS.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=tS[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?$p(this.editorEl,"backgroundColor",M,"data-rte-bg"):function(e,t){$p(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=Pp(M.getRangeAt(0).startContainer,e);if(!i)return;if(i.tagName.toLowerCase()===t)return;const n=document.createElement(t);for(;i.firstChild;)n.appendChild(i.firstChild);i.replaceWith(n);const o=document.createRange();o.selectNodeContents(n),o.collapse(!0),M.removeAllRanges(),M.addRange(o)}(this.editorEl,M):"font"===t&&function(e,t){const M=document.getSelection();if(!M||0===M.rangeCount)return;const i=M.getRangeAt(0);if(i.collapsed){const e=document.createElement("span");e.style.fontFamily=t,e.appendChild(document.createTextNode("​")),i.insertNode(e);const n=document.createRange();return n.setStart(e.firstChild,1),n.collapse(!0),M.removeAllRanges(),void M.addRange(n)}Bp(i,"span",{style:`font-family:${t}`})}(this.editorEl,M),this.updateContent(),this.updateToolbarState()}))}}else e.addEventListener("change",(e=>{this.focusAndRestore();const t=e.detail;Jp(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":Fp(this.editorEl,"strong");break;case"italic":Fp(this.editorEl,"em");break;case"underline":Fp(this.editorEl,"u");break;case"left":Jp(this.editorEl,"left");break;case"center":Jp(this.editorEl,"center");break;case"right":Jp(this.editorEl,"right");break;case"justify":Jp(this.editorEl,"justify");break;case"ul":Kp(this.editorEl,"ul"),this.updateContent(),this.updateToolbarState();break;case"ol":Kp(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=Pp(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})(),N=!!M.closest("a"),a=n.style.textAlign||getComputedStyle(n).textAlign||"start",l="start"===a?"left":a,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",N),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=Rp(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=Rp(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})],MS.prototype,"value",void 0),e([ue({type:Boolean,attribute:!0,reflect:!0})],MS.prototype,"noStyles",void 0),e([ue({type:Boolean,attribute:"singlelineeditor",reflect:!0})],MS.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)}})],MS.prototype,"mentions",void 0),e([ce()],MS.prototype,"content",void 0),MS=e([le("nile-rich-text-editor")],MS);"undefined"!=typeof window&&(window.nileElementsVersion='"1.2.0-beta-1.4"',window.nileVersion="__NILE_VERSION__");const iS=r`
14000
14000
  :host {
14001
14001
  --sidebar-width: 240px;
14002
14002
  --sidebar-collapsed-width: 70px;
@@ -15016,19 +15016,39 @@ nile-button.toggle-btn::part(base) {
15016
15016
  padding-top: var(--nile-spacing-2xl);
15017
15017
  padding-bottom: var(--nile-spacing-2xl);
15018
15018
  }
15019
+
15020
+
15021
+ nile-side-bar-action-menu {
15022
+ width: fit-content;
15023
+ max-width: 400px;
15024
+ min-width: 200px;
15025
+ }
15019
15026
 
15020
15027
  nile-side-bar-action-menu::part(menu__items-wrapper) {
15021
- width: 200px;
15022
- height: 200px;
15023
- padding-top: var(--nile-spacing-lg);
15024
- padding-bottom: var(--nile-spacing-lg);
15025
- max-width: 200px;
15028
+ width: 100%;
15029
+ max-width: 400px;
15030
+ padding-top: var(--nile-spacing-lg);
15031
+ padding-bottom: var(--nile-spacing-lg);
15026
15032
  }
15033
+
15027
15034
  nile-side-bar-action-menu-item::part(base) {
15028
- margin-left: 0;
15029
- margin-right: 0;
15035
+ width: 100%;
15036
+ margin-left: 0;
15037
+ margin-right: 0;
15038
+ border-radius: 0;
15039
+ }
15040
+
15041
+ nile-side-bar-action-menu-item::part(label) {
15042
+ display: block;
15043
+ width: 100%;
15044
+ white-space: nowrap;
15045
+ overflow: hidden;
15046
+ text-overflow: ellipsis;
15030
15047
  }
15031
- `;let bS=class extends Re{constructor(){super(...arguments),this.collapsed=!1,this.fixed=!1,this.activeIndex=-1,this.handleItemSelect=e=>{const t=e.detail.item,M=this.sidebarItems.indexOf(t);this.sidebarItems.forEach(((e,t)=>e.active=t===M)),this.activeIndex=M,this.dispatchEvent(new CustomEvent("nile-change",{detail:{selectedItem:t,index:M},bubbles:!0,composed:!0})),this.requestUpdate()}}static get styles(){return[CS]}get sidebarItems(){if(!this.defaultSlot)return[];return this.defaultSlot.assignedElements({flatten:!0}).flatMap((e=>"nile-inline-sidebar-item"===e.tagName.toLowerCase()?[e]:Array.from(e.querySelectorAll("nile-inline-sidebar-item"))))}connectedCallback(){super.connectedCallback(),this.addEventListener("nile-click",this.handleItemSelect),this.mutationObserver=new MutationObserver((()=>this.syncActiveFromItems()))}disconnectedCallback(){super.disconnectedCallback(),this.mutationObserver?.disconnect(),this.removeEventListener("nile-click",this.handleItemSelect)}firstUpdated(){this.observeSidebarItems(),this.syncActiveFromItems(),this.fixed&&(this.collapsed=!1)}observeSidebarItems(){this.sidebarItems?.length&&this.mutationObserver&&this.sidebarItems.forEach((e=>this.mutationObserver.observe(e,{attributes:!0,attributeFilter:["active"]})))}syncActiveFromItems(){if(!this.sidebarItems?.length)return;const e=this.sidebarItems.findIndex((e=>e.hasAttribute("active")));-1!==e&&e!==this.activeIndex&&(this.activeIndex=e,this.requestUpdate())}toggleCollapse(){this.fixed||(this.collapsed=!this.collapsed,console.log("[Sidebar] Toggled collapse →",this.collapsed),this.dispatchEvent(new CustomEvent("nile-toggle",{detail:{collapsed:this.collapsed},bubbles:!0,composed:!0})))}handleMenuItemClick(e){const t=this.sidebarItems[e];if(!t||t.hasAttribute("disabled"))return;this.sidebarItems.forEach(((t,M)=>t.active=M===e)),this.activeIndex=e,this.dispatchEvent(new CustomEvent("nile-click",{detail:{item:t},bubbles:!0,composed:!0}));const M=t.href;M&&(window.location.href=M),this.requestUpdate()}get menuItemsTemplate(){return this.sidebarItems?.length?this.sidebarItems.map(((e,t)=>R`
15048
+
15049
+
15050
+
15051
+ `;let bS=class extends Re{constructor(){super(...arguments),this.collapsed=!1,this.fixed=!1,this.showTooltip=!1,this.activeIndex=-1,this.handleItemSelect=e=>{const t=e.detail.item,M=this.sidebarItems.indexOf(t);this.sidebarItems.forEach(((e,t)=>e.active=t===M)),this.activeIndex=M,this.dispatchEvent(new CustomEvent("nile-change",{detail:{selectedItem:t,index:M},bubbles:!0,composed:!0})),this.requestUpdate()}}static get styles(){return[CS]}get sidebarItems(){if(!this.defaultSlot)return[];return this.defaultSlot.assignedElements({flatten:!0}).flatMap((e=>"nile-inline-sidebar-item"===e.tagName.toLowerCase()?[e]:Array.from(e.querySelectorAll("nile-inline-sidebar-item"))))}connectedCallback(){super.connectedCallback(),this.addEventListener("nile-click",this.handleItemSelect),this.mutationObserver=new MutationObserver((()=>this.syncActiveFromItems()))}disconnectedCallback(){super.disconnectedCallback(),this.mutationObserver?.disconnect(),this.removeEventListener("nile-click",this.handleItemSelect)}firstUpdated(){this.observeSidebarItems(),this.syncActiveFromItems(),this.fixed&&(this.collapsed=!1)}observeSidebarItems(){this.sidebarItems?.length&&this.mutationObserver&&this.sidebarItems.forEach((e=>this.mutationObserver.observe(e,{attributes:!0,attributeFilter:["active"]})))}syncActiveFromItems(){if(!this.sidebarItems?.length)return;const e=this.sidebarItems.findIndex((e=>e.hasAttribute("active")));-1!==e&&e!==this.activeIndex&&(this.activeIndex=e,this.requestUpdate())}toggleCollapse(){this.fixed||(this.collapsed=!this.collapsed,console.log("[Sidebar] Toggled collapse →",this.collapsed),this.dispatchEvent(new CustomEvent("nile-toggle",{detail:{collapsed:this.collapsed},bubbles:!0,composed:!0})))}handleMenuItemClick(e){const t=this.sidebarItems[e];if(!t||t.hasAttribute("disabled"))return;this.sidebarItems.forEach(((t,M)=>t.active=M===e)),this.activeIndex=e;const M=t.textContent?.trim()||"",i=t.href;this.dispatchEvent(new CustomEvent("nile-click",{detail:{item:t,href:i,text:M},bubbles:!0,composed:!0})),i&&(window.location.href=i),this.requestUpdate()}get menuItemsTemplate(){return this.sidebarItems?.length?this.sidebarItems.map(((e,t)=>{const M=R`
15032
15052
  <nile-side-bar-action-menu-item
15033
15053
  ?disabled=${e.hasAttribute("disabled")}
15034
15054
  ?active=${this.activeIndex===t}
@@ -15036,7 +15056,15 @@ margin-right: 0;
15036
15056
  >
15037
15057
  ${e.textContent}
15038
15058
  </nile-side-bar-action-menu-item>
15039
- `)):null}render(){return R`
15059
+ `;return this.showTooltip?R`
15060
+ <nile-tooltip
15061
+ content=${e.textContent}
15062
+ hoist
15063
+ placement="right"
15064
+ >
15065
+ ${M}
15066
+ </nile-tooltip>
15067
+ `:M})):null}render(){return R`
15040
15068
  <div class="sidebar" part="base">
15041
15069
  <div class="sidebar-header" part="header">
15042
15070
  ${this.fixed?null:this.collapsed?R`
@@ -15076,7 +15104,7 @@ margin-right: 0;
15076
15104
  ></slot>
15077
15105
  </nav>
15078
15106
  </div>
15079
- `}};e([ue({type:Boolean,reflect:!0})],bS.prototype,"collapsed",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],bS.prototype,"fixed",void 0),e([ce()],bS.prototype,"activeIndex",void 0),e([Ie("slot")],bS.prototype,"defaultSlot",void 0),bS=e([le("nile-inline-sidebar")],bS);const US=r`
15107
+ `}};e([ue({type:Boolean,reflect:!0})],bS.prototype,"collapsed",void 0),e([ue({type:Boolean,reflect:!0,attribute:!0})],bS.prototype,"fixed",void 0),e([ue({type:Boolean,reflect:!0})],bS.prototype,"showTooltip",void 0),e([ce()],bS.prototype,"activeIndex",void 0),e([Ie("slot")],bS.prototype,"defaultSlot",void 0),bS=e([le("nile-inline-sidebar")],bS);const US=r`
15080
15108
  :host {
15081
15109
  display: block;
15082
15110
  font-family: var(--nile-font-family-sans-serif);
@@ -1,2 +1,2 @@
1
- function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}System.register(["tslib","lit","lit/decorators.js","./nile-inline-sidebar.css.cjs.js","../internal/nile-element.cjs.js"],function(_export,_context){"use strict";var t,e,i,s,n,l,a,o,_templateObject,_templateObject2,_templateObject3,_templateObject4,r;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){e=_lit.html;},function(_litDecoratorsJs){i=_litDecoratorsJs.property;s=_litDecoratorsJs.state;n=_litDecoratorsJs.query;l=_litDecoratorsJs.customElement;},function(_nileInlineSidebarCssCjsJs){a=_nileInlineSidebarCssCjsJs.s;},function(_internalNileElementCjsJs){o=_internalNileElementCjsJs.N;}],execute:function execute(){_export("N",r=/*#__PURE__*/function(_o){function r(){var _this;_classCallCheck(this,r);_this=_callSuper(this,r,arguments),_this.collapsed=!1,_this.fixed=!1,_this.activeIndex=-1,_this.handleItemSelect=function(t){var e=t.detail.item,i=_this.sidebarItems.indexOf(e);_this.sidebarItems.forEach(function(t,e){return t.active=e===i;}),_this.activeIndex=i,_this.dispatchEvent(new CustomEvent("nile-change",{detail:{selectedItem:e,index:i},bubbles:!0,composed:!0})),_this.requestUpdate();};return _this;}_inherits(r,_o);return _createClass(r,[{key:"sidebarItems",get:function get(){if(!this.defaultSlot)return[];return this.defaultSlot.assignedElements({flatten:!0}).flatMap(function(t){return"nile-inline-sidebar-item"===t.tagName.toLowerCase()?[t]:Array.from(t.querySelectorAll("nile-inline-sidebar-item"));});}},{key:"connectedCallback",value:function connectedCallback(){var _this2=this;_superPropGet(r,"connectedCallback",this,3)([]),this.addEventListener("nile-click",this.handleItemSelect),this.mutationObserver=new MutationObserver(function(){return _this2.syncActiveFromItems();});}},{key:"disconnectedCallback",value:function disconnectedCallback(){var _this$mutationObserve;_superPropGet(r,"disconnectedCallback",this,3)([]),(_this$mutationObserve=this.mutationObserver)!==null&&_this$mutationObserve!==void 0&&_this$mutationObserve.disconnect(),this.removeEventListener("nile-click",this.handleItemSelect);}},{key:"firstUpdated",value:function firstUpdated(){this.observeSidebarItems(),this.syncActiveFromItems(),this.fixed&&(this.collapsed=!1);}},{key:"observeSidebarItems",value:function observeSidebarItems(){var _this$sidebarItems,_this3=this;((_this$sidebarItems=this.sidebarItems)===null||_this$sidebarItems===void 0?void 0:_this$sidebarItems.length)&&this.mutationObserver&&this.sidebarItems.forEach(function(t){return _this3.mutationObserver.observe(t,{attributes:!0,attributeFilter:["active"]});});}},{key:"syncActiveFromItems",value:function syncActiveFromItems(){var _this$sidebarItems2;if(!((_this$sidebarItems2=this.sidebarItems)!==null&&_this$sidebarItems2!==void 0&&_this$sidebarItems2.length))return;var t=this.sidebarItems.findIndex(function(t){return t.hasAttribute("active");});-1!==t&&t!==this.activeIndex&&(this.activeIndex=t,this.requestUpdate());}},{key:"toggleCollapse",value:function toggleCollapse(){this.fixed||(this.collapsed=!this.collapsed,console.log("[Sidebar] Toggled collapse →",this.collapsed),this.dispatchEvent(new CustomEvent("nile-toggle",{detail:{collapsed:this.collapsed},bubbles:!0,composed:!0})));}},{key:"handleMenuItemClick",value:function handleMenuItemClick(t){var e=this.sidebarItems[t];if(!e||e.hasAttribute("disabled"))return;this.sidebarItems.forEach(function(e,i){return e.active=i===t;}),this.activeIndex=t,this.dispatchEvent(new CustomEvent("nile-click",{detail:{item:e},bubbles:!0,composed:!0}));var i=e.href;i&&(window.location.href=i),this.requestUpdate();}},{key:"menuItemsTemplate",get:function get(){var _this$sidebarItems3,_this4=this;return(_this$sidebarItems3=this.sidebarItems)!==null&&_this$sidebarItems3!==void 0&&_this$sidebarItems3.length?this.sidebarItems.map(function(t,i){return e(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <nile-side-bar-action-menu-item\n ?disabled=","\n ?active=","\n @click=","\n >\n ","\n </nile-side-bar-action-menu-item>\n "])),t.hasAttribute("disabled"),_this4.activeIndex===i,function(){return _this4.handleMenuItemClick(i);},t.textContent);}):null;}},{key:"render",value:function render(){var _this5=this;return e(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["\n <div class=\"sidebar\" part=\"base\">\n <div class=\"sidebar-header\" part=\"header\">\n ","\n </div>\n\n <nav\n class=\"sidebar-nav\"\n style=","\n part=\"nav-items\"\n >\n <slot\n @slotchange=","\n ></slot>\n </nav>\n </div>\n "])),this.fixed?null:this.collapsed?e(_templateObject3||(_templateObject3=_taggedTemplateLiteral(["\n <nile-side-bar-action\n class=\"toggle-action\"\n placement=\"bottom-start\"\n hoist\n open\n triggerDropdown=\"hover\"\n >\n <nile-button\n slot=\"trigger\"\n class=\"toggle-btn\"\n variant=\"tertiary\"\n @click=","\n >\n <nile-icon name=\"menu_close\"></nile-icon>\n </nile-button>\n <nile-side-bar-action-menu>\n ","\n </nile-side-bar-action-menu>\n </nile-side-bar-action>\n "])),this.toggleCollapse,this.menuItemsTemplate):e(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["\n <nile-button class=\"toggle-btn\" variant=\"tertiary\" @click=",">\n <nile-icon name=\"menu_open\"></nile-icon>\n </nile-button>\n "])),this.toggleCollapse),this.collapsed?"display:none;":"",function(){console.log("[Sidebar] Slot content updated"),_this5.requestUpdate(),_this5.observeSidebarItems(),_this5.syncActiveFromItems();});}}],[{key:"styles",get:function get(){return[a];}}]);}(o));t([i({type:Boolean,reflect:!0})],r.prototype,"collapsed",void 0),t([i({type:Boolean,reflect:!0,attribute:!0})],r.prototype,"fixed",void 0),t([s()],r.prototype,"activeIndex",void 0),t([n("slot")],r.prototype,"defaultSlot",void 0),_export("N",r=t([l("nile-inline-sidebar")],r));}};});
1
+ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}System.register(["tslib","lit","lit/decorators.js","./nile-inline-sidebar.css.cjs.js","../internal/nile-element.cjs.js"],function(_export,_context){"use strict";var t,e,i,s,n,l,o,a,_templateObject,_templateObject2,_templateObject3,_templateObject4,_templateObject5,r;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}return{setters:[function(_tslib){t=_tslib.__decorate;},function(_lit){e=_lit.html;},function(_litDecoratorsJs){i=_litDecoratorsJs.property;s=_litDecoratorsJs.state;n=_litDecoratorsJs.query;l=_litDecoratorsJs.customElement;},function(_nileInlineSidebarCssCjsJs){o=_nileInlineSidebarCssCjsJs.s;},function(_internalNileElementCjsJs){a=_internalNileElementCjsJs.N;}],execute:function execute(){_export("N",r=/*#__PURE__*/function(_a){function r(){var _this;_classCallCheck(this,r);_this=_callSuper(this,r,arguments),_this.collapsed=!1,_this.fixed=!1,_this.showTooltip=!1,_this.activeIndex=-1,_this.handleItemSelect=function(t){var e=t.detail.item,i=_this.sidebarItems.indexOf(e);_this.sidebarItems.forEach(function(t,e){return t.active=e===i;}),_this.activeIndex=i,_this.dispatchEvent(new CustomEvent("nile-change",{detail:{selectedItem:e,index:i},bubbles:!0,composed:!0})),_this.requestUpdate();};return _this;}_inherits(r,_a);return _createClass(r,[{key:"sidebarItems",get:function get(){if(!this.defaultSlot)return[];return this.defaultSlot.assignedElements({flatten:!0}).flatMap(function(t){return"nile-inline-sidebar-item"===t.tagName.toLowerCase()?[t]:Array.from(t.querySelectorAll("nile-inline-sidebar-item"));});}},{key:"connectedCallback",value:function connectedCallback(){var _this2=this;_superPropGet(r,"connectedCallback",this,3)([]),this.addEventListener("nile-click",this.handleItemSelect),this.mutationObserver=new MutationObserver(function(){return _this2.syncActiveFromItems();});}},{key:"disconnectedCallback",value:function disconnectedCallback(){var _this$mutationObserve;_superPropGet(r,"disconnectedCallback",this,3)([]),(_this$mutationObserve=this.mutationObserver)!==null&&_this$mutationObserve!==void 0&&_this$mutationObserve.disconnect(),this.removeEventListener("nile-click",this.handleItemSelect);}},{key:"firstUpdated",value:function firstUpdated(){this.observeSidebarItems(),this.syncActiveFromItems(),this.fixed&&(this.collapsed=!1);}},{key:"observeSidebarItems",value:function observeSidebarItems(){var _this$sidebarItems,_this3=this;((_this$sidebarItems=this.sidebarItems)===null||_this$sidebarItems===void 0?void 0:_this$sidebarItems.length)&&this.mutationObserver&&this.sidebarItems.forEach(function(t){return _this3.mutationObserver.observe(t,{attributes:!0,attributeFilter:["active"]});});}},{key:"syncActiveFromItems",value:function syncActiveFromItems(){var _this$sidebarItems2;if(!((_this$sidebarItems2=this.sidebarItems)!==null&&_this$sidebarItems2!==void 0&&_this$sidebarItems2.length))return;var t=this.sidebarItems.findIndex(function(t){return t.hasAttribute("active");});-1!==t&&t!==this.activeIndex&&(this.activeIndex=t,this.requestUpdate());}},{key:"toggleCollapse",value:function toggleCollapse(){this.fixed||(this.collapsed=!this.collapsed,console.log("[Sidebar] Toggled collapse →",this.collapsed),this.dispatchEvent(new CustomEvent("nile-toggle",{detail:{collapsed:this.collapsed},bubbles:!0,composed:!0})));}},{key:"handleMenuItemClick",value:function handleMenuItemClick(t){var _e$textContent;var e=this.sidebarItems[t];if(!e||e.hasAttribute("disabled"))return;this.sidebarItems.forEach(function(e,i){return e.active=i===t;}),this.activeIndex=t;var i=((_e$textContent=e.textContent)===null||_e$textContent===void 0?void 0:_e$textContent.trim())||"",s=e.href;this.dispatchEvent(new CustomEvent("nile-click",{detail:{item:e,href:s,text:i},bubbles:!0,composed:!0})),s&&(window.location.href=s),this.requestUpdate();}},{key:"menuItemsTemplate",get:function get(){var _this$sidebarItems3,_this4=this;return(_this$sidebarItems3=this.sidebarItems)!==null&&_this$sidebarItems3!==void 0&&_this$sidebarItems3.length?this.sidebarItems.map(function(t,i){var s=e(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n <nile-side-bar-action-menu-item\n ?disabled=","\n ?active=","\n @click=","\n >\n ","\n </nile-side-bar-action-menu-item>\n "])),t.hasAttribute("disabled"),_this4.activeIndex===i,function(){return _this4.handleMenuItemClick(i);},t.textContent);return _this4.showTooltip?e(_templateObject2||(_templateObject2=_taggedTemplateLiteral(["\n <nile-tooltip\n content=","\n hoist\n placement=\"right\"\n >\n ","\n </nile-tooltip>\n "])),t.textContent,s):s;}):null;}},{key:"render",value:function render(){var _this5=this;return e(_templateObject3||(_templateObject3=_taggedTemplateLiteral(["\n <div class=\"sidebar\" part=\"base\">\n <div class=\"sidebar-header\" part=\"header\">\n ","\n </div>\n\n <nav\n class=\"sidebar-nav\"\n style=","\n part=\"nav-items\"\n >\n <slot\n @slotchange=","\n ></slot>\n </nav>\n </div>\n "])),this.fixed?null:this.collapsed?e(_templateObject4||(_templateObject4=_taggedTemplateLiteral(["\n <nile-side-bar-action\n class=\"toggle-action\"\n placement=\"bottom-start\"\n hoist\n open\n triggerDropdown=\"hover\"\n >\n <nile-button\n slot=\"trigger\"\n class=\"toggle-btn\"\n variant=\"tertiary\"\n @click=","\n >\n <nile-icon name=\"menu_close\"></nile-icon>\n </nile-button>\n <nile-side-bar-action-menu>\n ","\n </nile-side-bar-action-menu>\n </nile-side-bar-action>\n "])),this.toggleCollapse,this.menuItemsTemplate):e(_templateObject5||(_templateObject5=_taggedTemplateLiteral(["\n <nile-button class=\"toggle-btn\" variant=\"tertiary\" @click=",">\n <nile-icon name=\"menu_open\"></nile-icon>\n </nile-button>\n "])),this.toggleCollapse),this.collapsed?"display:none;":"",function(){console.log("[Sidebar] Slot content updated"),_this5.requestUpdate(),_this5.observeSidebarItems(),_this5.syncActiveFromItems();});}}],[{key:"styles",get:function get(){return[o];}}]);}(a));t([i({type:Boolean,reflect:!0})],r.prototype,"collapsed",void 0),t([i({type:Boolean,reflect:!0,attribute:!0})],r.prototype,"fixed",void 0),t([i({type:Boolean,reflect:!0})],r.prototype,"showTooltip",void 0),t([s()],r.prototype,"activeIndex",void 0),t([n("slot")],r.prototype,"defaultSlot",void 0),_export("N",r=t([l("nile-inline-sidebar")],r));}};});
2
2
  //# sourceMappingURL=nile-inline-sidebar.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nile-inline-sidebar.cjs.js","sources":["../../../src/nile-inline-sidebar/nile-inline-sidebar.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, CSSResultArray, TemplateResult } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { styles } from './nile-inline-sidebar.css';\nimport NileElement from '../internal/nile-element';\n\n/**\n * Nile inline sidebar component.\n *\n * @tag nile-inline-sidebar\n */\n@customElement('nile-inline-sidebar')\nexport class NileInlineSidebar extends NileElement {\n /** Whether the sidebar is collapsed */\n @property({ type: Boolean, reflect: true }) collapsed = false;\n\n /** If true, disables collapse functionality and hides the toggle button */\n @property({ type: Boolean, reflect: true, attribute: true }) fixed = false;\n\n /** Holds the active item index */\n @state() private activeIndex: number = -1;\n\n /** Reference to the default slot */\n @query('slot') private defaultSlot!: HTMLSlotElement;\n\n /** Mutation observer for reactive child updates */\n private mutationObserver?: MutationObserver;\n\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n /** Computed getter that collects all sidebar items recursively */\n private get sidebarItems(): HTMLElement[] {\n if (!this.defaultSlot) return [];\n const assigned = this.defaultSlot.assignedElements({ flatten: true });\n const items = assigned.flatMap((el) =>\n el.tagName.toLowerCase() === 'nile-inline-sidebar-item'\n ? [el]\n : Array.from(el.querySelectorAll('nile-inline-sidebar-item')),\n );\n return items as HTMLElement[];\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Listen for user-triggered selection\n this.addEventListener('nile-click', this.handleItemSelect);\n\n // Initialize the mutation observer for reactive attribute watching\n this.mutationObserver = new MutationObserver(() => this.syncActiveFromItems());\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.mutationObserver?.disconnect();\n this.removeEventListener('nile-click', this.handleItemSelect);\n }\n\n firstUpdated() {\n this.observeSidebarItems();\n this.syncActiveFromItems();\n\n if (this.fixed) {\n this.collapsed = false;\n }\n }\n\n private observeSidebarItems() {\n if (!this.sidebarItems?.length || !this.mutationObserver) return;\n this.sidebarItems.forEach((item) =>\n this.mutationObserver!.observe(item, { attributes: true, attributeFilter: ['active'] }),\n );\n }\n\n private syncActiveFromItems() {\n if (!this.sidebarItems?.length) return;\n const activeIndex = this.sidebarItems.findIndex((item) => item.hasAttribute('active'));\n if (activeIndex !== -1 && activeIndex !== this.activeIndex) {\n this.activeIndex = activeIndex;\n this.requestUpdate();\n }\n }\n\n private handleItemSelect = (event: CustomEvent) => {\n const selectedItem = event.detail.item as HTMLElement;\n const index = this.sidebarItems.indexOf(selectedItem);\n\n this.sidebarItems.forEach((item, i) => (item as any).active = i === index);\n this.activeIndex = index;\n\n this.dispatchEvent(\n new CustomEvent('nile-change', {\n detail: { selectedItem, index },\n bubbles: true,\n composed: true,\n }),\n );\n\n this.requestUpdate();\n };\n\n private toggleCollapse() {\n if (this.fixed) return; \n this.collapsed = !this.collapsed;\n console.log('[Sidebar] Toggled collapse →', this.collapsed);\n\n this.dispatchEvent(\n new CustomEvent('nile-toggle', {\n detail: { collapsed: this.collapsed },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private handleMenuItemClick(index: number) {\n const selectedItem = this.sidebarItems[index];\n if (!selectedItem || selectedItem.hasAttribute('disabled')) return;\n\n this.sidebarItems.forEach((item, i) => (item as any).active = i === index);\n this.activeIndex = index;\n\n this.dispatchEvent(\n new CustomEvent('nile-click', {\n detail: { item: selectedItem },\n bubbles: true,\n composed: true,\n }),\n );\n\n const href = (selectedItem as any).href;\n if (href) window.location.href = href;\n\n this.requestUpdate();\n }\n\n private get menuItemsTemplate() {\n if (!this.sidebarItems?.length) return null;\n return this.sidebarItems.map(\n (item, index) => html`\n <nile-side-bar-action-menu-item\n ?disabled=${item.hasAttribute('disabled')}\n ?active=${this.activeIndex === index}\n @click=${() => this.handleMenuItemClick(index)}\n >\n ${item.textContent}\n </nile-side-bar-action-menu-item>\n `,\n );\n }\n\n /** Main render function */\n public render(): TemplateResult {\n return html`\n <div class=\"sidebar\" part=\"base\">\n <div class=\"sidebar-header\" part=\"header\">\n ${!this.fixed\n ? this.collapsed\n ? html`\n <nile-side-bar-action\n class=\"toggle-action\"\n placement=\"bottom-start\"\n hoist\n open\n triggerDropdown=\"hover\"\n >\n <nile-button\n slot=\"trigger\"\n class=\"toggle-btn\"\n variant=\"tertiary\"\n @click=${this.toggleCollapse}\n >\n <nile-icon name=\"menu_close\"></nile-icon>\n </nile-button>\n <nile-side-bar-action-menu>\n ${this.menuItemsTemplate}\n </nile-side-bar-action-menu>\n </nile-side-bar-action>\n `\n : html`\n <nile-button class=\"toggle-btn\" variant=\"tertiary\" @click=${this.toggleCollapse}>\n <nile-icon name=\"menu_open\"></nile-icon>\n </nile-button>\n `\n : null}\n </div>\n\n <nav\n class=\"sidebar-nav\"\n style=${this.collapsed ? 'display:none;' : ''}\n part=\"nav-items\"\n >\n <slot\n @slotchange=${() => {\n console.log('[Sidebar] Slot content updated');\n this.requestUpdate();\n this.observeSidebarItems(); // rebind observer to new items\n this.syncActiveFromItems(); // resync active index\n }}\n ></slot>\n </nav>\n </div>\n `;\n }\n}\n\nexport default NileInlineSidebar;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-inline-sidebar': NileInlineSidebar;\n }\n}\n"],"names":["NileInlineSidebar","r","constructor","this","collapsed","fixed","activeIndex","handleItemSelect","event","selectedItem","detail","item","index","sidebarItems","indexOf","forEach","i","active","dispatchEvent","CustomEvent","bubbles","composed","requestUpdate","_this","_inherits","_o","_createClass","key","get","defaultSlot","assignedElements","flatten","flatMap","el","tagName","toLowerCase","Array","from","querySelectorAll","value","connectedCallback","super","addEventListener","mutationObserver","MutationObserver","syncActiveFromItems","disconnectedCallback","disconnect","removeEventListener","firstUpdated","observeSidebarItems","length","observe","attributes","attributeFilter","findIndex","hasAttribute","toggleCollapse","console","log","handleMenuItemClick","href","window","location","map","html","_templateObject","_taggedTemplateLiteral","textContent","render","_this5","_templateObject2","_templateObject3","menuItemsTemplate","_templateObject4","__decorate","styles","NileElement","property","type","Boolean","reflect","prototype","attribute","state","query","_export","customElement"],"mappings":"uwHAkBaA,4BAAN,SAAAC,EAAA,CAAAC,KAAAA,KAAAA,CAAAA,eAAAA,MAAAA,CAAAA,qCAEuCC,KAAAA,CAASC,SAAAA,CAAAA,CAAG,EAGKD,KAAAA,CAAKE,KAAAA,CAAAA,CAAG,CAGpDF,CAAAA,KAAAA,CAAWG,aAAY,CAiEhCH,CAAAA,KAAA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ar.ts"],"sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, CSSResultArray, TemplateResult } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { styles } from './nile-inline-sidebar.css';\nimport NileElement from '../internal/nile-element';\n\n/**\n * Nile inline sidebar component.\n *\n * @tag nile-inline-sidebar\n */\n@customElement('nile-inline-sidebar')\nexport class NileInlineSidebar extends NileElement {\n /** Whether the sidebar is collapsed */\n @property({ type: Boolean, reflect: true }) collapsed = false;\n\n /** If true, disables collapse functionality and hides the toggle button */\n @property({ type: Boolean, reflect: true, attribute: true }) fixed = false;\n\n @property({ type: Boolean, reflect: true }) showTooltip = false;\n\n /** Holds the active item index */\n @state() private activeIndex: number = -1;\n\n /** Reference to the default slot */\n @query('slot') private defaultSlot!: HTMLSlotElement;\n\n /** Mutation observer for reactive child updates */\n private mutationObserver?: MutationObserver;\n\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n /** Computed getter that collects all sidebar items recursively */\n private get sidebarItems(): HTMLElement[] {\n if (!this.defaultSlot) return [];\n const assigned = this.defaultSlot.assignedElements({ flatten: true });\n const items = assigned.flatMap((el) =>\n el.tagName.toLowerCase() === 'nile-inline-sidebar-item'\n ? [el]\n : Array.from(el.querySelectorAll('nile-inline-sidebar-item')),\n );\n return items as HTMLElement[];\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Listen for user-triggered selection\n this.addEventListener('nile-click', this.handleItemSelect);\n\n // Initialize the mutation observer for reactive attribute watching\n this.mutationObserver = new MutationObserver(() => this.syncActiveFromItems());\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.mutationObserver?.disconnect();\n this.removeEventListener('nile-click', this.handleItemSelect);\n }\n\n firstUpdated() {\n this.observeSidebarItems();\n this.syncActiveFromItems();\n\n if (this.fixed) {\n this.collapsed = false;\n }\n }\n\n private observeSidebarItems() {\n if (!this.sidebarItems?.length || !this.mutationObserver) return;\n this.sidebarItems.forEach((item) =>\n this.mutationObserver!.observe(item, { attributes: true, attributeFilter: ['active'] }),\n );\n }\n\n private syncActiveFromItems() {\n if (!this.sidebarItems?.length) return;\n const activeIndex = this.sidebarItems.findIndex((item) => item.hasAttribute('active'));\n if (activeIndex !== -1 && activeIndex !== this.activeIndex) {\n this.activeIndex = activeIndex;\n this.requestUpdate();\n }\n }\n\n private handleItemSelect = (event: CustomEvent) => {\n const selectedItem = event.detail.item as HTMLElement;\n const index = this.sidebarItems.indexOf(selectedItem);\n\n this.sidebarItems.forEach((item, i) => (item as any).active = i === index);\n this.activeIndex = index;\n\n this.dispatchEvent(\n new CustomEvent('nile-change', {\n detail: { selectedItem, index },\n bubbles: true,\n composed: true,\n }),\n );\n\n this.requestUpdate();\n };\n\n private toggleCollapse() {\n if (this.fixed) return; \n this.collapsed = !this.collapsed;\n console.log('[Sidebar] Toggled collapse →', this.collapsed);\n\n this.dispatchEvent(\n new CustomEvent('nile-toggle', {\n detail: { collapsed: this.collapsed },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private handleMenuItemClick(index: number) {\n const selectedItem = this.sidebarItems[index];\n if (!selectedItem || selectedItem.hasAttribute('disabled')) return;\n\n this.sidebarItems.forEach((item, i) => (item as any).active = i === index);\n this.activeIndex = index;\n const text = selectedItem.textContent?.trim() || '';\n const href = (selectedItem as any).href;\n this.dispatchEvent(\n new CustomEvent('nile-click', {\n detail: { item: selectedItem, href, text },\n bubbles: true,\n composed: true,\n }),\n );\n\n\n if (href) window.location.href = href;\n\n this.requestUpdate();\n }\n\n private get menuItemsTemplate() {\n if (!this.sidebarItems?.length) return null;\n \n return this.sidebarItems.map((item, index) => {\n const content = html`\n <nile-side-bar-action-menu-item\n ?disabled=${item.hasAttribute('disabled')}\n ?active=${this.activeIndex === index}\n @click=${() => this.handleMenuItemClick(index)}\n >\n ${item.textContent}\n </nile-side-bar-action-menu-item>\n `;\n \n return this.showTooltip\n ? html`\n <nile-tooltip\n content=${item.textContent}\n hoist\n placement=\"right\"\n >\n ${content}\n </nile-tooltip>\n `\n : content;\n });\n }\n \n\n /** Main render function */\n public render(): TemplateResult {\n return html`\n <div class=\"sidebar\" part=\"base\">\n <div class=\"sidebar-header\" part=\"header\">\n ${!this.fixed\n ? this.collapsed\n ? html`\n <nile-side-bar-action\n class=\"toggle-action\"\n placement=\"bottom-start\"\n hoist\n open\n triggerDropdown=\"hover\"\n >\n <nile-button\n slot=\"trigger\"\n class=\"toggle-btn\"\n variant=\"tertiary\"\n @click=${this.toggleCollapse}\n >\n <nile-icon name=\"menu_close\"></nile-icon>\n </nile-button>\n <nile-side-bar-action-menu>\n ${this.menuItemsTemplate}\n </nile-side-bar-action-menu>\n </nile-side-bar-action>\n `\n : html`\n <nile-button class=\"toggle-btn\" variant=\"tertiary\" @click=${this.toggleCollapse}>\n <nile-icon name=\"menu_open\"></nile-icon>\n </nile-button>\n `\n : null}\n </div>\n\n <nav\n class=\"sidebar-nav\"\n style=${this.collapsed ? 'display:none;' : ''}\n part=\"nav-items\"\n >\n <slot\n @slotchange=${() => {\n console.log('[Sidebar] Slot content updated');\n this.requestUpdate();\n this.observeSidebarItems(); // rebind observer to new items\n this.syncActiveFromItems(); // resync active index\n }}\n ></slot>\n </nav>\n </div>\n `;\n }\n}\n\nexport default NileInlineSidebar;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-inline-sidebar': NileInlineSidebar;\n }\n}\n"],"names":["NileInlineSidebar","r","this","collapsed","fixed","showTooltip","activeIndex","handleItemSelect","event","selectedItem","detail","item","index","sidebarItems","indexOf","forEach","i","active","dispatchEvent","CustomEvent","bubbles","composed","requestUpdate","_this","_inherits","_a","_createClass","key","get","defaultSlot","assignedElements","flatten","flatMap","el","tagName","toLowerCase","Array","from","querySelectorAll","value","connectedCallback","super","addEventListener","mutationObserver","MutationObserver","syncActiveFromItems","disconnectedCallback","disconnect","removeEventListener","firstUpdated","observeSidebarItems","length","observe","attributes","attributeFilter","_this$sidebarItems2","findIndex","hasAttribute","toggleCollapse","console","log","handleMenuItemClick","text","textContent","trim","href","window","location","_this$sidebarItems3","_this4","map","content","html","_templateObject","_taggedTemplateLiteral","_templateObject2","render","_templateObject3","_templateObject4","menuItemsTemplate","_templateObject5","__decorate","styles","NileElement","property","type","Boolean","reflect","prototype","attribute","state","query","customElement"],"mappings":"wxHAkBaA,CAAAA,uBAAAA,EAAAA,EAAN,SAAAC,EAAA,qEAEuCC,EAAAA,KAAAA,CAASC,SAAG,CAAA,CAAA,CAAA,CAGKD,KAAAA,CAAKE,KAAG,CAAA,CAAA,CAAA,CAEzBF,KAAAA,CAAWG,WAAAA,CAAAA,CAAG,EAGzCH,KAAAA,CAAWI,WAAAA,CAAAA,CAAY,CAiEhCJ,CAAAA,KAAAA,CAAAK,iBAAoBC,SAAAA,CAC1B,CAAA,CAAA,GAAMC,CAAAA,CAAeD,CAAAA,CAAAA,CAAME,MAAOC,CAAAA,IAAAA,CAC5BC,CAAQV,CAAAA,KAAAA,CAAKW,aAAaC,OAAQL,CAAAA,CAAAA,CAAAA,CAExCP,KAAAA,CAAKW,YAAAA,CAAaE,QAAQ,SAACJ,CAAAA,CAAMK,CAAOL,QAAAA,CAAAA,CAAAA,CAAaM,OAASD,CAAMJ,GAAAA,CAAAA,EAAAA,CAAAA,CACpEV,KAAAA,CAAKI,WAAAA,CAAcM,EAEnBV,KAAAA,CAAKgB,aAAAA,CACH,GAAIC,CAAAA,WAAAA,CAAY,cAAe,CAC7BT,MAAAA,CAAQ,CAAED,YAAAA,CAAAA,CAAAA,CAAcG,SACxBQ,OAAS,CAAA,CAAA,CAAA,CACTC,QAAU,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAIdnB,KAAAA,CAAKoB,aAAe,CAAA,CAAA,EAyHvB,QAAAC,KAAA,EAjMQC,SAAA,CAAAvB,CAAA,CAAAwB,EAAA,SAAAC,YAAA,CAAAzB,CAAA,GAAA0B,GAAA,gBAAAC,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A,EAMrC,CAhN2CoC,KAAAA,GAAAA,UAAAA,GAAAA,CAgBrC,SAAArD,IAAA,CACL,CAAA,MAAO,CAACsD,CAAAA,CACT,EAGD,MAvBqCC,CAAhC,GAEuCF,CAAAA,CAAA,CAA3CG,CAAAA,CAAS,CAAEC,IAAAA,CAAMC,OAASC,CAAAA,OAAAA,CAAAA,CAAS,CAA0BvF,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAwF,SAAA,CAAA,WAAA,CAAA,IAAA,EAGDP,CAAAA,CAAAA,CAAAA,CAAA,CAA5DG,CAAAA,CAAS,CAAEC,IAAAA,CAAMC,OAASC,CAAAA,OAAAA,CAAAA,CAAS,CAAME,CAAAA,SAAAA,CAAAA,CAAW,CAAsBzF,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAwF,SAAA,CAAA,OAAA,CAAA,IAAA,EAE/BP,CAAAA,CAAAA,CAAAA,CAAA,CAA3CG,CAAAA,CAAS,CAAEC,IAAMC,CAAAA,OAAAA,CAASC,OAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA4BvF,CAAAwF,CAAAA,SAAAA,CAAA,aAAA,CAAA,IAAA,EAAA,CAAA,CAG/CP,CAAA,CAAA,CAAhBS,CAAyC1F,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAwF,SAAA,CAAA,aAAA,CAAA,IAAA,EAGnBP,CAAAA,CAAAA,CAAAA,CAAA,CAAtBU,CAAAA,CAAM,MAA8C3F,CAAAA,CAAAA,CAAAA,CAAAA,CAAAwF,SAAA,CAAA,aAAA,CAAA,IAAA,EAb1CxF,CAAAA,CAAAA,OAAAA,KAAAA,CAAAA,CAAiBiF,CAAA,CAAA,CAD7BW,CAAc,CAAA,qBAAA,CAAA,CAAA,CACF5F"}
@@ -1,2 +1,2 @@
1
- System.register(["lit"],function(_export,_context){"use strict";var i,_templateObject,e;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}return{setters:[function(_lit){i=_lit.css;}],execute:function execute(){_export("s",e=i(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n:host {\n display: block;\n height: 100%;\n}\n.sidebar {\n display: flex;\n flex-direction: column;\n height: 100%;\n background: white;\n border-right: 1px solid var(--nile-colors-neutral-400);\n transition: width 0.3s ease;\n position: relative; \n}\n.toggle-btn {\n position: absolute;\n top: var(--nile-spacing-2xl);\n right: -14px; \n z-index: 10;\n}\n\nnile-button.toggle-btn::part(base) {\n width: 30px;\n height: 30px;\n}\n:host(:not([collapsed])) .sidebar {\n width: 216px;\n}\n:host([collapsed]) .sidebar {\n width: 0px;\n}\n:host([collapsed]) .sidebar-nav {\n display: none;\n}\n.sidebar-header {\n display: flex;\n justify-content: flex-end;\n}\n.sidebar-nav {\n display: flex;\n flex-direction: column;\n gap: var(--nile-spacing-xs);\n padding-right: var(--nile-spacing-xl);\npadding-top: var(--nile-spacing-2xl);\n padding-bottom: var(--nile-spacing-2xl);\n}\n\nnile-side-bar-action-menu::part(menu__items-wrapper) {\nwidth: 200px;\nheight: 200px;\npadding-top: var(--nile-spacing-lg);\npadding-bottom: var(--nile-spacing-lg);\nmax-width: 200px;\n}\nnile-side-bar-action-menu-item::part(base) {\nmargin-left: 0;\nmargin-right: 0;\n}\n"]))));}};});
1
+ System.register(["lit"],function(_export,_context){"use strict";var i,_templateObject,e;function _taggedTemplateLiteral(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}));}return{setters:[function(_lit){i=_lit.css;}],execute:function execute(){_export("s",e=i(_templateObject||(_templateObject=_taggedTemplateLiteral(["\n:host {\n display: block;\n height: 100%;\n}\n.sidebar {\n display: flex;\n flex-direction: column;\n height: 100%;\n background: white;\n border-right: 1px solid var(--nile-colors-neutral-400);\n transition: width 0.3s ease;\n position: relative; \n}\n.toggle-btn {\n position: absolute;\n top: var(--nile-spacing-2xl);\n right: -14px; \n z-index: 10;\n}\n\nnile-button.toggle-btn::part(base) {\n width: 30px;\n height: 30px;\n}\n:host(:not([collapsed])) .sidebar {\n width: 216px;\n}\n:host([collapsed]) .sidebar {\n width: 0px;\n}\n:host([collapsed]) .sidebar-nav {\n display: none;\n}\n.sidebar-header {\n display: flex;\n justify-content: flex-end;\n}\n.sidebar-nav {\n display: flex;\n flex-direction: column;\n gap: var(--nile-spacing-xs);\n padding-right: var(--nile-spacing-xl);\npadding-top: var(--nile-spacing-2xl);\n padding-bottom: var(--nile-spacing-2xl);\n}\n \n\nnile-side-bar-action-menu {\n width: fit-content; \n max-width: 400px; \n min-width: 200px; \n}\n\nnile-side-bar-action-menu::part(menu__items-wrapper) {\n width: 100%; \n max-width: 400px;\n padding-top: var(--nile-spacing-lg);\n padding-bottom: var(--nile-spacing-lg);\n}\n\nnile-side-bar-action-menu-item::part(base) {\n width: 100%; \n margin-left: 0;\n margin-right: 0;\n border-radius: 0;\n}\n\nnile-side-bar-action-menu-item::part(label) {\n display: block;\n width: 100%; \n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis; \n}\n\n\n\n"]))));}};});
2
2
  //# sourceMappingURL=nile-inline-sidebar.css.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nile-inline-sidebar.css.cjs.js","sources":["../../../src/nile-inline-sidebar/nile-inline-sidebar.css.ts"],"sourcesContent":["/**\n* Copyright Aquera Inc 2023\n*\n* This source code is licensed under the BSD-3-Clause license found in the\n* LICENSE file in the root directory of this source tree.\n*/\n\nimport { css } from 'lit';\n\nexport const styles = css`\n:host {\n display: block;\n height: 100%;\n}\n.sidebar {\n display: flex;\n flex-direction: column;\n height: 100%;\n background: white;\n border-right: 1px solid var(--nile-colors-neutral-400);\n transition: width 0.3s ease;\n position: relative; \n}\n.toggle-btn {\n position: absolute;\n top: var(--nile-spacing-2xl);\n right: -14px; \n z-index: 10;\n}\n\nnile-button.toggle-btn::part(base) {\n width: 30px;\n height: 30px;\n}\n:host(:not([collapsed])) .sidebar {\n width: 216px;\n}\n:host([collapsed]) .sidebar {\n width: 0px;\n}\n:host([collapsed]) .sidebar-nav {\n display: none;\n}\n.sidebar-header {\n display: flex;\n justify-content: flex-end;\n}\n.sidebar-nav {\n display: flex;\n flex-direction: column;\n gap: var(--nile-spacing-xs);\n padding-right: var(--nile-spacing-xl);\npadding-top: var(--nile-spacing-2xl);\n padding-bottom: var(--nile-spacing-2xl);\n}\n\nnile-side-bar-action-menu::part(menu__items-wrapper) {\nwidth: 200px;\nheight: 200px;\npadding-top: var(--nile-spacing-lg);\npadding-bottom: var(--nile-spacing-lg);\nmax-width: 200px;\n}\nnile-side-bar-action-menu-item::part(base) {\nmargin-left: 0;\nmargin-right: 0;\n}\n`;\n"],"names":["styles","css","_templateObject","_taggedTemplateLiteral"],"mappings":"oTASaA,CAAAA,CAASC,CAAG,CAAAC,eAAA,GAAAA,eAAA,CAAAC,sBAAA"}
1
+ {"version":3,"file":"nile-inline-sidebar.css.cjs.js","sources":["../../../src/nile-inline-sidebar/nile-inline-sidebar.css.ts"],"sourcesContent":["/**\n* Copyright Aquera Inc 2023\n*\n* This source code is licensed under the BSD-3-Clause license found in the\n* LICENSE file in the root directory of this source tree.\n*/\n\nimport { css } from 'lit';\n\nexport const styles = css`\n:host {\n display: block;\n height: 100%;\n}\n.sidebar {\n display: flex;\n flex-direction: column;\n height: 100%;\n background: white;\n border-right: 1px solid var(--nile-colors-neutral-400);\n transition: width 0.3s ease;\n position: relative; \n}\n.toggle-btn {\n position: absolute;\n top: var(--nile-spacing-2xl);\n right: -14px; \n z-index: 10;\n}\n\nnile-button.toggle-btn::part(base) {\n width: 30px;\n height: 30px;\n}\n:host(:not([collapsed])) .sidebar {\n width: 216px;\n}\n:host([collapsed]) .sidebar {\n width: 0px;\n}\n:host([collapsed]) .sidebar-nav {\n display: none;\n}\n.sidebar-header {\n display: flex;\n justify-content: flex-end;\n}\n.sidebar-nav {\n display: flex;\n flex-direction: column;\n gap: var(--nile-spacing-xs);\n padding-right: var(--nile-spacing-xl);\npadding-top: var(--nile-spacing-2xl);\n padding-bottom: var(--nile-spacing-2xl);\n}\n \n\nnile-side-bar-action-menu {\n width: fit-content; \n max-width: 400px; \n min-width: 200px; \n}\n\nnile-side-bar-action-menu::part(menu__items-wrapper) {\n width: 100%; \n max-width: 400px;\n padding-top: var(--nile-spacing-lg);\n padding-bottom: var(--nile-spacing-lg);\n}\n\nnile-side-bar-action-menu-item::part(base) {\n width: 100%; \n margin-left: 0;\n margin-right: 0;\n border-radius: 0;\n}\n\nnile-side-bar-action-menu-item::part(label) {\n display: block;\n width: 100%; \n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis; \n}\n\n\n\n`;\n"],"names":["styles","css","_templateObject","_taggedTemplateLiteral"],"mappings":"oTASaA,CAAAA,CAASC,CAAG,CAAAC,eAAA,GAAAA,eAAA,CAAAC,sBAAA"}
@@ -44,16 +44,36 @@ nile-button.toggle-btn::part(base) {
44
44
  padding-top: var(--nile-spacing-2xl);
45
45
  padding-bottom: var(--nile-spacing-2xl);
46
46
  }
47
+
48
+
49
+ nile-side-bar-action-menu {
50
+ width: fit-content;
51
+ max-width: 400px;
52
+ min-width: 200px;
53
+ }
47
54
 
48
55
  nile-side-bar-action-menu::part(menu__items-wrapper) {
49
- width: 200px;
50
- height: 200px;
51
- padding-top: var(--nile-spacing-lg);
52
- padding-bottom: var(--nile-spacing-lg);
53
- max-width: 200px;
56
+ width: 100%;
57
+ max-width: 400px;
58
+ padding-top: var(--nile-spacing-lg);
59
+ padding-bottom: var(--nile-spacing-lg);
54
60
  }
61
+
55
62
  nile-side-bar-action-menu-item::part(base) {
56
- margin-left: 0;
57
- margin-right: 0;
63
+ width: 100%;
64
+ margin-left: 0;
65
+ margin-right: 0;
66
+ border-radius: 0;
58
67
  }
68
+
69
+ nile-side-bar-action-menu-item::part(label) {
70
+ display: block;
71
+ width: 100%;
72
+ white-space: nowrap;
73
+ overflow: hidden;
74
+ text-overflow: ellipsis;
75
+ }
76
+
77
+
78
+
59
79
  `;export{e as s};
@@ -1,4 +1,4 @@
1
- import{__decorate as t}from"tslib";import{html as e}from"lit";import{property as i,state as s,query as n,customElement as l}from"lit/decorators.js";import{s as a}from"./nile-inline-sidebar.css.esm.js";import{N as o}from"../internal/nile-element.esm.js";let r=class extends o{constructor(){super(...arguments),this.collapsed=!1,this.fixed=!1,this.activeIndex=-1,this.handleItemSelect=t=>{const e=t.detail.item,i=this.sidebarItems.indexOf(e);this.sidebarItems.forEach(((t,e)=>t.active=e===i)),this.activeIndex=i,this.dispatchEvent(new CustomEvent("nile-change",{detail:{selectedItem:e,index:i},bubbles:!0,composed:!0})),this.requestUpdate()}}static get styles(){return[a]}get sidebarItems(){if(!this.defaultSlot)return[];return this.defaultSlot.assignedElements({flatten:!0}).flatMap((t=>"nile-inline-sidebar-item"===t.tagName.toLowerCase()?[t]:Array.from(t.querySelectorAll("nile-inline-sidebar-item"))))}connectedCallback(){super.connectedCallback(),this.addEventListener("nile-click",this.handleItemSelect),this.mutationObserver=new MutationObserver((()=>this.syncActiveFromItems()))}disconnectedCallback(){super.disconnectedCallback(),this.mutationObserver?.disconnect(),this.removeEventListener("nile-click",this.handleItemSelect)}firstUpdated(){this.observeSidebarItems(),this.syncActiveFromItems(),this.fixed&&(this.collapsed=!1)}observeSidebarItems(){this.sidebarItems?.length&&this.mutationObserver&&this.sidebarItems.forEach((t=>this.mutationObserver.observe(t,{attributes:!0,attributeFilter:["active"]})))}syncActiveFromItems(){if(!this.sidebarItems?.length)return;const t=this.sidebarItems.findIndex((t=>t.hasAttribute("active")));-1!==t&&t!==this.activeIndex&&(this.activeIndex=t,this.requestUpdate())}toggleCollapse(){this.fixed||(this.collapsed=!this.collapsed,console.log("[Sidebar] Toggled collapse →",this.collapsed),this.dispatchEvent(new CustomEvent("nile-toggle",{detail:{collapsed:this.collapsed},bubbles:!0,composed:!0})))}handleMenuItemClick(t){const e=this.sidebarItems[t];if(!e||e.hasAttribute("disabled"))return;this.sidebarItems.forEach(((e,i)=>e.active=i===t)),this.activeIndex=t,this.dispatchEvent(new CustomEvent("nile-click",{detail:{item:e},bubbles:!0,composed:!0}));const i=e.href;i&&(window.location.href=i),this.requestUpdate()}get menuItemsTemplate(){return this.sidebarItems?.length?this.sidebarItems.map(((t,i)=>e`
1
+ import{__decorate as t}from"tslib";import{html as e}from"lit";import{property as i,state as s,query as n,customElement as l}from"lit/decorators.js";import{s as o}from"./nile-inline-sidebar.css.esm.js";import{N as a}from"../internal/nile-element.esm.js";let r=class extends a{constructor(){super(...arguments),this.collapsed=!1,this.fixed=!1,this.showTooltip=!1,this.activeIndex=-1,this.handleItemSelect=t=>{const e=t.detail.item,i=this.sidebarItems.indexOf(e);this.sidebarItems.forEach(((t,e)=>t.active=e===i)),this.activeIndex=i,this.dispatchEvent(new CustomEvent("nile-change",{detail:{selectedItem:e,index:i},bubbles:!0,composed:!0})),this.requestUpdate()}}static get styles(){return[o]}get sidebarItems(){if(!this.defaultSlot)return[];return this.defaultSlot.assignedElements({flatten:!0}).flatMap((t=>"nile-inline-sidebar-item"===t.tagName.toLowerCase()?[t]:Array.from(t.querySelectorAll("nile-inline-sidebar-item"))))}connectedCallback(){super.connectedCallback(),this.addEventListener("nile-click",this.handleItemSelect),this.mutationObserver=new MutationObserver((()=>this.syncActiveFromItems()))}disconnectedCallback(){super.disconnectedCallback(),this.mutationObserver?.disconnect(),this.removeEventListener("nile-click",this.handleItemSelect)}firstUpdated(){this.observeSidebarItems(),this.syncActiveFromItems(),this.fixed&&(this.collapsed=!1)}observeSidebarItems(){this.sidebarItems?.length&&this.mutationObserver&&this.sidebarItems.forEach((t=>this.mutationObserver.observe(t,{attributes:!0,attributeFilter:["active"]})))}syncActiveFromItems(){if(!this.sidebarItems?.length)return;const t=this.sidebarItems.findIndex((t=>t.hasAttribute("active")));-1!==t&&t!==this.activeIndex&&(this.activeIndex=t,this.requestUpdate())}toggleCollapse(){this.fixed||(this.collapsed=!this.collapsed,console.log("[Sidebar] Toggled collapse →",this.collapsed),this.dispatchEvent(new CustomEvent("nile-toggle",{detail:{collapsed:this.collapsed},bubbles:!0,composed:!0})))}handleMenuItemClick(t){const e=this.sidebarItems[t];if(!e||e.hasAttribute("disabled"))return;this.sidebarItems.forEach(((e,i)=>e.active=i===t)),this.activeIndex=t;const i=e.textContent?.trim()||"",s=e.href;this.dispatchEvent(new CustomEvent("nile-click",{detail:{item:e,href:s,text:i},bubbles:!0,composed:!0})),s&&(window.location.href=s),this.requestUpdate()}get menuItemsTemplate(){return this.sidebarItems?.length?this.sidebarItems.map(((t,i)=>{const s=e`
2
2
  <nile-side-bar-action-menu-item
3
3
  ?disabled=${t.hasAttribute("disabled")}
4
4
  ?active=${this.activeIndex===i}
@@ -6,7 +6,15 @@ import{__decorate as t}from"tslib";import{html as e}from"lit";import{property as
6
6
  >
7
7
  ${t.textContent}
8
8
  </nile-side-bar-action-menu-item>
9
- `)):null}render(){return e`
9
+ `;return this.showTooltip?e`
10
+ <nile-tooltip
11
+ content=${t.textContent}
12
+ hoist
13
+ placement="right"
14
+ >
15
+ ${s}
16
+ </nile-tooltip>
17
+ `:s})):null}render(){return e`
10
18
  <div class="sidebar" part="base">
11
19
  <div class="sidebar-header" part="header">
12
20
  ${this.fixed?null:this.collapsed?e`
@@ -46,4 +54,4 @@ import{__decorate as t}from"tslib";import{html as e}from"lit";import{property as
46
54
  ></slot>
47
55
  </nav>
48
56
  </div>
49
- `}};t([i({type:Boolean,reflect:!0})],r.prototype,"collapsed",void 0),t([i({type:Boolean,reflect:!0,attribute:!0})],r.prototype,"fixed",void 0),t([s()],r.prototype,"activeIndex",void 0),t([n("slot")],r.prototype,"defaultSlot",void 0),r=t([l("nile-inline-sidebar")],r);export{r as N};
57
+ `}};t([i({type:Boolean,reflect:!0})],r.prototype,"collapsed",void 0),t([i({type:Boolean,reflect:!0,attribute:!0})],r.prototype,"fixed",void 0),t([i({type:Boolean,reflect:!0})],r.prototype,"showTooltip",void 0),t([s()],r.prototype,"activeIndex",void 0),t([n("slot")],r.prototype,"defaultSlot",void 0),r=t([l("nile-inline-sidebar")],r);export{r as N};
@@ -51,17 +51,37 @@ nile-button.toggle-btn::part(base) {
51
51
  padding-top: var(--nile-spacing-2xl);
52
52
  padding-bottom: var(--nile-spacing-2xl);
53
53
  }
54
+
55
+
56
+ nile-side-bar-action-menu {
57
+ width: fit-content;
58
+ max-width: 400px;
59
+ min-width: 200px;
60
+ }
54
61
 
55
62
  nile-side-bar-action-menu::part(menu__items-wrapper) {
56
- width: 200px;
57
- height: 200px;
58
- padding-top: var(--nile-spacing-lg);
59
- padding-bottom: var(--nile-spacing-lg);
60
- max-width: 200px;
63
+ width: 100%;
64
+ max-width: 400px;
65
+ padding-top: var(--nile-spacing-lg);
66
+ padding-bottom: var(--nile-spacing-lg);
61
67
  }
68
+
62
69
  nile-side-bar-action-menu-item::part(base) {
63
- margin-left: 0;
64
- margin-right: 0;
70
+ width: 100%;
71
+ margin-left: 0;
72
+ margin-right: 0;
73
+ border-radius: 0;
65
74
  }
75
+
76
+ nile-side-bar-action-menu-item::part(label) {
77
+ display: block;
78
+ width: 100%;
79
+ white-space: nowrap;
80
+ overflow: hidden;
81
+ text-overflow: ellipsis;
82
+ }
83
+
84
+
85
+
66
86
  `;
67
87
  //# sourceMappingURL=nile-inline-sidebar.css.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nile-inline-sidebar.css.js","sourceRoot":"","sources":["../../../src/nile-inline-sidebar/nile-inline-sidebar.css.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AAEF,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DxB,CAAC","sourcesContent":["/**\n* Copyright Aquera Inc 2023\n*\n* This source code is licensed under the BSD-3-Clause license found in the\n* LICENSE file in the root directory of this source tree.\n*/\n\nimport { css } from 'lit';\n\nexport const styles = css`\n:host {\n display: block;\n height: 100%;\n}\n.sidebar {\n display: flex;\n flex-direction: column;\n height: 100%;\n background: white;\n border-right: 1px solid var(--nile-colors-neutral-400);\n transition: width 0.3s ease;\n position: relative; \n}\n.toggle-btn {\n position: absolute;\n top: var(--nile-spacing-2xl);\n right: -14px; \n z-index: 10;\n}\n\nnile-button.toggle-btn::part(base) {\n width: 30px;\n height: 30px;\n}\n:host(:not([collapsed])) .sidebar {\n width: 216px;\n}\n:host([collapsed]) .sidebar {\n width: 0px;\n}\n:host([collapsed]) .sidebar-nav {\n display: none;\n}\n.sidebar-header {\n display: flex;\n justify-content: flex-end;\n}\n.sidebar-nav {\n display: flex;\n flex-direction: column;\n gap: var(--nile-spacing-xs);\n padding-right: var(--nile-spacing-xl);\npadding-top: var(--nile-spacing-2xl);\n padding-bottom: var(--nile-spacing-2xl);\n}\n\nnile-side-bar-action-menu::part(menu__items-wrapper) {\nwidth: 200px;\nheight: 200px;\npadding-top: var(--nile-spacing-lg);\npadding-bottom: var(--nile-spacing-lg);\nmax-width: 200px;\n}\nnile-side-bar-action-menu-item::part(base) {\nmargin-left: 0;\nmargin-right: 0;\n}\n`;\n"]}
1
+ {"version":3,"file":"nile-inline-sidebar.css.js","sourceRoot":"","sources":["../../../src/nile-inline-sidebar/nile-inline-sidebar.css.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AAEF,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8ExB,CAAC","sourcesContent":["/**\n* Copyright Aquera Inc 2023\n*\n* This source code is licensed under the BSD-3-Clause license found in the\n* LICENSE file in the root directory of this source tree.\n*/\n\nimport { css } from 'lit';\n\nexport const styles = css`\n:host {\n display: block;\n height: 100%;\n}\n.sidebar {\n display: flex;\n flex-direction: column;\n height: 100%;\n background: white;\n border-right: 1px solid var(--nile-colors-neutral-400);\n transition: width 0.3s ease;\n position: relative; \n}\n.toggle-btn {\n position: absolute;\n top: var(--nile-spacing-2xl);\n right: -14px; \n z-index: 10;\n}\n\nnile-button.toggle-btn::part(base) {\n width: 30px;\n height: 30px;\n}\n:host(:not([collapsed])) .sidebar {\n width: 216px;\n}\n:host([collapsed]) .sidebar {\n width: 0px;\n}\n:host([collapsed]) .sidebar-nav {\n display: none;\n}\n.sidebar-header {\n display: flex;\n justify-content: flex-end;\n}\n.sidebar-nav {\n display: flex;\n flex-direction: column;\n gap: var(--nile-spacing-xs);\n padding-right: var(--nile-spacing-xl);\npadding-top: var(--nile-spacing-2xl);\n padding-bottom: var(--nile-spacing-2xl);\n}\n \n\nnile-side-bar-action-menu {\n width: fit-content; \n max-width: 400px; \n min-width: 200px; \n}\n\nnile-side-bar-action-menu::part(menu__items-wrapper) {\n width: 100%; \n max-width: 400px;\n padding-top: var(--nile-spacing-lg);\n padding-bottom: var(--nile-spacing-lg);\n}\n\nnile-side-bar-action-menu-item::part(base) {\n width: 100%; \n margin-left: 0;\n margin-right: 0;\n border-radius: 0;\n}\n\nnile-side-bar-action-menu-item::part(label) {\n display: block;\n width: 100%; \n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis; \n}\n\n\n\n`;\n"]}
@@ -16,6 +16,7 @@ export declare class NileInlineSidebar extends NileElement {
16
16
  collapsed: boolean;
17
17
  /** If true, disables collapse functionality and hides the toggle button */
18
18
  fixed: boolean;
19
+ showTooltip: boolean;
19
20
  /** Holds the active item index */
20
21
  private activeIndex;
21
22
  /** Reference to the default slot */
@@ -21,6 +21,7 @@ let NileInlineSidebar = class NileInlineSidebar extends NileElement {
21
21
  this.collapsed = false;
22
22
  /** If true, disables collapse functionality and hides the toggle button */
23
23
  this.fixed = false;
24
+ this.showTooltip = false;
24
25
  /** Holds the active item index */
25
26
  this.activeIndex = -1;
26
27
  this.handleItemSelect = (event) => {
@@ -99,12 +100,13 @@ let NileInlineSidebar = class NileInlineSidebar extends NileElement {
99
100
  return;
100
101
  this.sidebarItems.forEach((item, i) => item.active = i === index);
101
102
  this.activeIndex = index;
103
+ const text = selectedItem.textContent?.trim() || '';
104
+ const href = selectedItem.href;
102
105
  this.dispatchEvent(new CustomEvent('nile-click', {
103
- detail: { item: selectedItem },
106
+ detail: { item: selectedItem, href, text },
104
107
  bubbles: true,
105
108
  composed: true,
106
109
  }));
107
- const href = selectedItem.href;
108
110
  if (href)
109
111
  window.location.href = href;
110
112
  this.requestUpdate();
@@ -112,7 +114,8 @@ let NileInlineSidebar = class NileInlineSidebar extends NileElement {
112
114
  get menuItemsTemplate() {
113
115
  if (!this.sidebarItems?.length)
114
116
  return null;
115
- return this.sidebarItems.map((item, index) => html `
117
+ return this.sidebarItems.map((item, index) => {
118
+ const content = html `
116
119
  <nile-side-bar-action-menu-item
117
120
  ?disabled=${item.hasAttribute('disabled')}
118
121
  ?active=${this.activeIndex === index}
@@ -120,7 +123,19 @@ let NileInlineSidebar = class NileInlineSidebar extends NileElement {
120
123
  >
121
124
  ${item.textContent}
122
125
  </nile-side-bar-action-menu-item>
123
- `);
126
+ `;
127
+ return this.showTooltip
128
+ ? html `
129
+ <nile-tooltip
130
+ content=${item.textContent}
131
+ hoist
132
+ placement="right"
133
+ >
134
+ ${content}
135
+ </nile-tooltip>
136
+ `
137
+ : content;
138
+ });
124
139
  }
125
140
  /** Main render function */
126
141
  render() {
@@ -182,6 +197,9 @@ __decorate([
182
197
  __decorate([
183
198
  property({ type: Boolean, reflect: true, attribute: true })
184
199
  ], NileInlineSidebar.prototype, "fixed", void 0);
200
+ __decorate([
201
+ property({ type: Boolean, reflect: true })
202
+ ], NileInlineSidebar.prototype, "showTooltip", void 0);
185
203
  __decorate([
186
204
  state()
187
205
  ], NileInlineSidebar.prototype, "activeIndex", void 0);