@nyx-ds/treeview 0.1.2 → 0.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.
@@ -1,15 +1,15 @@
1
- (function(_,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("lit"),require("lit/decorators.js"),require("lit/directives/repeat.js"),require("lit/directives/class-map.js"),require("@nyx-ds/core"),require("@lit-labs/virtualizer"),require("@nyx-ds/input"),require("@nyx-ds/checkbox"),require("@nyx-ds/icon"),require("@nyx-ds/button")):typeof define=="function"&&define.amd?define(["exports","lit","lit/decorators.js","lit/directives/repeat.js","lit/directives/class-map.js","@nyx-ds/core","@lit-labs/virtualizer","@nyx-ds/input","@nyx-ds/checkbox","@nyx-ds/icon","@nyx-ds/button"],h):(_=typeof globalThis<"u"?globalThis:_||self,h(_.treeview={},_.lit,_.litDecorators,_.litRepeat,_.litClassMap,_.NyxCore))})(this,(function(_,h,p,Z,b,M){"use strict";function G(n,e){return function(t,i){const{native:s=!1,...r}=i||{},o=s?new Event(e,r):new CustomEvent(e,{detail:t,...r});n.dispatchEvent(o)}}function K(n){return(e,t)=>{Object.defineProperty(e,t,{get(){return G(this,n)},enumerable:!0,configurable:!0})}}const Y=":host{display:flex;flex-direction:column;width:100%;--treeview-radius: var(--nyx-radii-s);--treeview-search-padding: var(--nyx-sizing-1-25) var(--nyx-sizing-1-75) 0 var(--nyx-sizing-1-75);--treeview-header-padding: var(--nyx-sizing-2) var(--nyx-sizing-2) var(--nyx-sizing-1-75) var(--nyx-sizing-2);--treeview-row-padding: var(--nyx-sizing-1) var(--nyx-sizing-2);--treeview-row-gap: var(--nyx-sizing-2);--treeview-col-gap: var(--nyx-sizing-1);--treeview-node-gap: var(--nyx-sizing-1);--treeview-row-min-height: 48px;--treeview-indent-base: 16px;--treeview-indent-step: 24px;--treeview-expander-wrapper-size: var(--nyx-sizing-4);--treeview-expander-padding: var(--nyx-sizing-1-25);--treeview-col-width: var(--treeview-header-icon-size);--treeview-column-count: 0;--treeview-scrollbar-gutter: 15px;--treeview-background: var(--nyx-color-neutral-background-primary);--treeview-border-color: var(--nyx-color-neutral-border-tertiary);--treeview-content-color: var(--nyx-color-neutral-content-primary);--treeview-focus-border-color: var(--nyx-color-brand-border-default);--treeview-row-selected-background: var(--nyx-color-brand-background-softer);--treeview-row-selected-hover-background: var( --nyx-color-brand-background-softer-hover );--treeview-row-selected-color: var(--nyx-color-neutral-content-primary);--treeview-font-family: var(--nyx-font-family-font-family);--treeview-title-font-size: var(--nyx-label-medium-font-size);--treeview-title-line-height: var(--nyx-label-medium-line-height);--treeview-text-font-size: var(--nyx-label-medium-font-size);--treeview-text-line-height: var(--nyx-label-medium-line-height);--treeview-header-icon-size: var(--nyx-label-large-font-size);--treeview-node-icon-size: var(--nyx-label-medium-font-size);--treeview-expander-icon-size: var(--nyx-label-large-font-size);--treeview-row-hover-background: var(--nyx-color-neutral-background-secondary);--treeview-row-hover-color: var(--nyx-color-brand-content-hover)}.nyx-treeview{display:flex;flex-direction:column;width:100%;font-family:var(--treeview-font-family);align-items:flex-start;border-radius:var(--treeview-radius);border:1px solid var(--treeview-border-color);background:var(--treeview-background);box-sizing:border-box}.search-container{display:flex;padding:var(--treeview-search-padding);flex-direction:column;align-items:flex-start;align-self:stretch}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}.tree-scroll{width:100%;display:flex;flex-direction:column;min-height:0}.tree-body--virtual{display:flex;flex-direction:column;flex:1 1 auto;min-height:280px;max-height:var(--treeview-max-height, 480px);overflow:hidden}.tree-virtualizer{flex:1 1 auto;width:100%;min-height:280px;scrollbar-gutter:stable}.node-wrapper--flat{width:100%}.tree-header{display:flex;justify-content:space-between;align-items:center;align-self:stretch;padding:var(--treeview-header-padding);border-bottom:.5px solid var(--treeview-border-color);box-sizing:border-box}.tree-title{color:var(--treeview-content-color);font-size:var(--treeview-title-font-size);line-height:var(--treeview-title-line-height);font-weight:600;flex:1 1 auto;min-width:0}.tree-header--no-columns .tree-title{flex:1 1 auto}.nyx-treeview--no-columns .header-columns,.nyx-treeview--no-columns .node-columns{display:none}.nyx-treeview--no-columns .tree-header{padding-inline-end:var(--nyx-sizing-2, 16px)}.header-columns,.node-columns{display:flex;align-items:center;justify-content:flex-end;gap:var(--treeview-col-gap);flex-shrink:0}.header-columns{padding-inline-end:0}.nyx-treeview--virtual .header-columns{padding-inline-end:var(--treeview-scrollbar-gutter)}.col-cell{min-width:var(--treeview-col-width);width:var(--treeview-col-width);flex:0 0 auto;display:flex;justify-content:center;align-items:center;box-sizing:border-box}.header-columns ::slotted(nyx-icon){display:flex;justify-content:center;align-items:center;--nyx-icon-size: var(--treeview-header-icon-size);color:var(--treeview-content-color)}.tree-body{width:100%;display:flex;flex-direction:column}.node-wrapper{display:flex;flex-direction:column;width:100%}.node-row{--treeview-row-level: 0;display:flex;align-items:center;justify-content:space-between;min-height:var(--treeview-row-min-height);border-bottom:.5px solid var(--treeview-border-color);gap:var(--treeview-row-gap);padding:var(--treeview-row-padding);padding-left:calc(var(--treeview-indent-base) + var(--treeview-row-level) * var(--treeview-indent-step));box-sizing:border-box;background:transparent;color:var(--treeview-content-color);outline:none;cursor:default}.node-row:hover{background:var(--treeview-row-hover-background);color:var(--treeview-row-hover-color)}.node-row:focus-within{background:var(--treeview-row-hover-background)!important;color:var(--treeview-row-hover-color)!important}.node-row:hover .expander nyx-icon,.node-row:hover .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-hover-color)}.node-row:focus-within .expander nyx-icon,.node-row:focus-within .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-hover-color)}.node-row.selectable.selected{background-color:var(--treeview-row-selected-background);color:var(--treeview-row-selected-color)}.node-row.selectable.selected .expander nyx-icon,.node-row.selectable.selected .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-selected-color)}.node-row.selectable.selected:hover{background-color:var(--treeview-row-selected-hover-background);color:var(--treeview-row-selected-color)}.node-row.selectable.selected:focus-within{background-color:var(--treeview-row-selected-background)!important;color:var(--treeview-row-selected-color)!important}.node-row.selectable.selected:focus-within .expander nyx-icon,.node-row.selectable.selected:focus-within .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-selected-color)}.node-row.selectable.selected:hover:focus-within{background-color:var(--treeview-row-selected-hover-background)!important}.node-row:focus-visible{position:relative;z-index:2;outline:2px solid var(--treeview-focus-border-color);outline-offset:-3px;background:var(--treeview-row-hover-background)!important;color:var(--treeview-row-hover-color)}.row-checkbox{display:flex;align-items:center;margin-right:4px}.node-info{display:flex;align-items:center;gap:var(--treeview-node-gap);flex:1 0 0;overflow:hidden;min-height:32px;padding-left:4px}.expander{--button-icon-color: inherit;flex-shrink:0;width:var(--treeview-expander-wrapper-size);min-width:var(--treeview-expander-wrapper-size)}.expander-placeholder{display:block;flex-shrink:0;width:var(--treeview-expander-wrapper-size);min-width:var(--treeview-expander-wrapper-size);height:var(--treeview-expander-wrapper-size)}.expander nyx-icon{--nyx-icon-size: var(--treeview-expander-icon-size);transition:transform .2s ease;transform-origin:center}.expander nyx-icon.expanded{transform:rotate(90deg)}.expander:hover,.expander:focus-within{--button-icon-color: var(--treeview-content-color) !important}.expander:hover nyx-icon,.expander:focus-within nyx-icon{color:var(--treeview-content-color)!important;--nyx-icon-color: var(--treeview-content-color) !important}.node-row:hover .expander:hover,.node-row:hover .expander:focus-within{--button-icon-color: var(--treeview-row-hover-color) !important}.node-row:hover .expander:hover nyx-icon,.node-row:hover .expander:focus-within nyx-icon{color:var(--treeview-row-hover-color)!important;--nyx-icon-color: var(--treeview-row-hover-color) !important}.node-type-icon-wrapper{display:flex;align-items:center;justify-content:center;flex-shrink:0}.node-type-icon-wrapper ::slotted(nyx-icon){--nyx-icon-size: var(--treeview-node-icon-size)}.node-text{font-size:var(--treeview-text-font-size);line-height:var(--treeview-text-line-height);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.node-children{width:100%}@media(max-width:768px){.tree-scroll{overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}.tree-header,.tree-body{min-width:calc(250px + ((var(--treeview-col-width) + var(--treeview-col-gap)) * var(--treeview-column-count)))}.node-text{white-space:normal;display:-webkit-box;line-clamp:2;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}}",X=200;function g(n,e){const t=e.trim().toLowerCase();return t?n.toLowerCase().includes(t):!1}function S(n,e){return n.includes(e)}function C(n){var s;const e=new Map,t=[],i=[];for(let r=n.length-1;r>=0;r--)i.push({node:n[r],parentId:null});for(;i.length>0;){const{node:r,parentId:o}=i.pop(),a=((s=r.children)==null?void 0:s.map(d=>d.id))??[];if(e.set(r.id,{id:r.id,parentId:o,normalizedLabel:r.label.toLowerCase(),childIds:a,hasChildren:a.length>0}),o===null&&t.push(r.id),r.children)for(let d=r.children.length-1;d>=0;d--)i.push({node:r.children[d],parentId:r.id})}return{roots:t,byId:e,size:e.size}}function J(n){const e=[],t=[];for(let i=n.roots.length-1;i>=0;i--)t.push({id:n.roots[i],visited:!1});for(;t.length>0;){const i=t[t.length-1];if(i.visited)t.pop(),e.push(i.id);else{i.visited=!0;const s=n.byId.get(i.id);if(!s)continue;for(let r=s.childIds.length-1;r>=0;r--)t.push({id:s.childIds[r],visited:!1})}}return e}function Q(n,e,t){const i=new Set,s=new Set,r=new Map;for(const o of J(n)){const a=n.byId.get(o);if(!a)continue;const d=S(a.normalizedLabel,e);let l=!1;for(const w of a.childIds)if(r.get(w)){l=!0;break}const c=d||l;if(r.set(o,c),!c||(i.add(o),!a.hasChildren||!l))continue;let v=!1;for(const w of a.childIds){const m=n.byId.get(w);if(m&&S(m.normalizedLabel,e)){v=!0;break}}!t.has(o)&&(!d||v)&&s.add(o)}return{visibleIds:i,expandIds:s}}function ee(n,e){const t=e.trim().toLowerCase();if(!t)return 0;const i=Array.isArray(n)?C(n):n;let s=0;for(const r of i.byId.values())S(r.normalizedLabel,t)&&s++;return s}function te(n,e,t=new Set){const i=e.trim().toLowerCase();if(!i)return{visibleIds:new Set,expandIds:new Set};const s=Array.isArray(n)?C(n):n;return Q(s,i,t)}function N(n,e,t=""){const i=n.children??[],s=t.trim().toLowerCase();return s?i.filter(r=>e.has(r.id)||g(r.label,s)):i.filter(r=>e.has(r.id))}function ie(n,e,t){const i=e.trim().toLowerCase();if(!i)return!1;const s=[n];for(;s.length>0;){const r=s.pop();for(const o of t(r)??[]){if(g(o.label,i))return!0;s.push(o.id)}}return!1}function se(n,e,t){const i=[n];for(;i.length>0;){const s=i.pop();for(const r of t(s)??[]){if(e.has(r.id))return!0;i.push(r.id)}}return!1}function R(n,e,t,i,s,r){return D(n,e,t)&&!se(i,s,r)&&!ie(i,e,r)}function D(n,e,t){return g(n,e)&&!t}function V(n,e,t,i){return t||D(n,e,i)}function z(n,e){var t,i;if(e){if(n.selected)return!0}else if((((t=n.selectedColumns)==null?void 0:t.length)??0)>0)return!0;return((i=n.children)==null?void 0:i.some(s=>z(s,e)))??!1}function P(n,e){const t=n.map((i,s)=>({node:i,index:s}));return t.sort((i,s)=>{const r=z(i.node,e),o=z(s.node,e);return r!==o?r?-1:1:i.index-s.index}),t.map(({node:i})=>{var s;return(s=i.children)!=null&&s.length?{...i,children:P(i.children,e)}:i})}const x=50,re=2;function ne(n){const e=[],t=n.map(s=>({node:s,depth:0,parentId:null}));let i=0;for(;i<t.length;){const s=t[i++],{node:r,depth:o,parentId:a}=s,d=!!(r.children&&r.children.length>0);if(e.push({id:r.id,depth:o,parentId:a,hasChildrenInSource:d}),d)for(const l of r.children)t.push({node:l,depth:o+1,parentId:r.id})}return e}function oe(n,e=x,t=re){const i=new Set;for(const s of n)if(!(s.depth>t)&&(i.add(s.id),i.size>=e))break;return i}function ae(n,e=x){const t=new Set;for(const i of n)if(i.depth===0&&(t.add(i.id),t.size>=e))break;return t}function le(n,e,t){const i=[];for(const s of n)if(s.depth===0&&!e.has(s.id)&&(i.push(s.id),i.length>=t))break;return i}function de(n,e){return n.some(t=>t.depth===0&&!e.has(t.id))}function E(n,e,t){return L(e,n).some(i=>!t.has(i))}function F(n,e){if(!n)return;let t=n.node.id,i=e.get(t);for(;(i==null?void 0:i.parentId)!=null;)t=i.parentId,i=e.get(t);return t}function he(n,e,t,i,s,r){const o=Math.min(Math.max(0,e),Math.max(0,n.length-1));for(let a=o;a>=0;a--){const d=n[a];if(t.has(d.node.id)&&E(d.node.id,i,s))return F(d,r)}return F(n[o],r)}function ce(n,e){const t=[];let i=e.get(n);for(;(i==null?void 0:i.parentId)!=null;)t.push(i.parentId),i=e.get(i.parentId);return t}function q(n,e,t,i){const s=[],r=o=>{s.length>=t||!e.has(o)&&!s.includes(o)&&s.push(o)};if(i!=null){const o=L(n,i);for(const a of o)r(a)}for(const o of n)if(r(o.id),s.length>=t)break;return s}function L(n,e){const t=new Map;for(const r of n){const o=r.parentId;t.has(o)||t.set(o,[]),t.get(o).push(r.id)}const i=[],s=[e];for(;s.length>0;){const r=s.pop();i.push(r);const o=t.get(r);if(o!=null&&o.length)for(let a=o.length-1;a>=0;a--)s.push(o[a])}return i}function ue(n,e,t){return L(n,e).filter(i=>!t.has(i))}function fe(n,e,t,i=x){return ue(n,e,t).slice(0,i)}function k(n){var e;return{...n,selectedColumns:n.selectedColumns?[...n.selectedColumns]:void 0,disabledColumns:n.disabledColumns?[...n.disabledColumns]:void 0,children:(e=n.children)==null?void 0:e.map(t=>k(t)),data:n.data}}function _e(n){const e=new Map,t=i=>{var s;e.set(i.id,i),(s=i.children)==null||s.forEach(t)};return n.forEach(t),e}function pe(n,e,t){const i=s=>{if(!e.has(s.id))return null;const r=t.get(s.id)??s,o=(r.children??[]).map(d=>i(d)).filter(d=>d!==null),a=k(r);return a.children=o.length>0?o:void 0,a};return n.map(s=>i(s)).filter(s=>s!==null)}function B(n){const e=[],t=n.searchTerm.trim().toLowerCase(),i=(s,r,o,a,d=!1)=>{const l=n.hasSearch&&!d?s.filter(c=>n.searchVisibleIds.has(c.id)):s;for(const c of l){const v=n.hasSearch&&!!t&&c.label.toLowerCase().includes(t),w=V(c.label,t,o,a),m=a||!!v;if(e.push({node:c,level:r,revealSubtree:w,parentLabelMatched:m,hasChildrenInSource:n.sourceHasChildren(c.id)}),!n.expandedIds.has(c.id))continue;const O=n.getSourceChildren??($=>{var j;return(j=n.items.find(ye=>ye.id===$))==null?void 0:j.children}),I=!n.hasSearch||w&&R(c.label,t,a,c.id,n.searchVisibleIds,O)?c.children??[]:N(c,n.searchVisibleIds,n.searchTerm);I.length>0&&i(I,r+1,w,m,!0)}};return i(n.items,0,!1,!1),e}function y(n,e){for(const t of n)if(!e.has(t))return!0;return!1}function U(n,e,t,i=x){const s=[],r=o=>{s.length>=i||!e.has(o)&&!s.includes(o)&&s.push(o)};for(const o of n)if(!e.has(o)){r(o);for(const a of ce(o,t))r(a);if(s.length>=i)break}return s}function H(n,e,t,i=x){const s=U(n,e,t,i);return s.length===0?!1:(s.forEach(r=>e.add(r)),!0)}function we(n,e){return e?`Collapse ${n}`:`Expand ${n}`}function ve(n){return`Select ${n}`}function me(n,e){return`${n}, ${e}`}function xe(n){return n===0?"No results found":n===1?"1 result found":`${n} results found`}var be=Object.defineProperty,ge=Object.getOwnPropertyDescriptor,f=(n,e,t,i)=>{for(var s=i>1?void 0:i?ge(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&be(e,t,s),s};const T=class T extends h.LitElement{constructor(){super(...arguments),this._items=[],this._expandedIds=new Set,this._searchTerm="",this._searchStatusMessage="",this._searchVisibleIds=new Set,this._searchUserCollapsedIds=new Set,this._searchManualExpandedIds=new Set,this._expandedIdsBeforeSearch=null,this._flatRows=[],this._loadedIds=new Set,this._activeRowId=null,this._sourceItems=[],this._lazyItemsSourceRef=null,this._treeIndex=[],this._indexById=new Map,this._sourceById=new Map,this._lazyScrollLoading=!1,this._searchIndex=null,this._searchIndexSourceRef=null,this._searchDebounceTimer=null}get options(){return this._options}set options(e){const t=this._options;t!==e&&(this._options=e,e&&(this._applyOptionsChange(),this._generateLightDomIcons()),this.requestUpdate("options",t))}_isLazyEnabled(){var e;return!!((e=this.options)!=null&&e.lazyLoad)}_getLazyPageSize(){var t;const e=(t=this.options)==null?void 0:t.lazyLoadPageSize;return e==null||!Number.isFinite(e)?x:Math.max(1,Math.floor(e))}_hasColumnPermissions(){var e,t,i;return((e=this.options)==null?void 0:e.showColumnPermissions)===!1?!1:(((i=(t=this.options)==null?void 0:t.columns)==null?void 0:i.length)??0)>0}_showRowSelection(){var e;return!!((e=this.options)!=null&&e.showRowSelection)}_showNodeIcons(){var e;return((e=this.options)==null?void 0:e.showNodeIcons)!==!1}_usesSimpleRowSelection(){return this._showRowSelection()&&!this._hasColumnPermissions()}_applyItemsFromOptions(e){var i;let t=e.map(s=>k(s));return(i=this.options)!=null&&i.sortSelectedFirst&&(t=P(t,this._usesSimpleRowSelection())),t}_applyOptionsChange(){if(this.options){if(this._isLazyEnabled()){this.options.items!==this._lazyItemsSourceRef&&(this._initLazyState(),this._resetSearchDerivedState(),this._searchTerm.trim()&&this._recomputeSearchFilter());return}if(this._items=this._applyItemsFromOptions(this.options.items),this._invalidateSearchIndex(),this._activeRowId=null,this._resetSearchDerivedState(),this._searchTerm.trim()){this._recomputeSearchFilter();return}this.options.defaultExpandedLevel!==void 0&&this._expandedIds.size===0&&this._expandToLevel(this._items,0,this.options.defaultExpandedLevel),this._syncActiveRowWithVisibleRows()}}_initLazyState(){var i;this._lazyItemsSourceRef=this.options.items,this._sourceItems=this._applyItemsFromOptions(this.options.items),this._invalidateSearchIndex(),this._treeIndex=ne(this._sourceItems),this._indexById=new Map(this._treeIndex.map(s=>[s.id,s])),this._sourceById=_e(this._sourceItems);const e=(i=this.options)==null?void 0:i.defaultExpandedLevel,t=this._getLazyPageSize();this._loadedIds=e!==void 0&&e>0?oe(this._treeIndex,t):ae(this._treeIndex,t),this._expandedIds=new Set,this._activeRowId=null,this._rebuildMaterializedItems(),e!==void 0&&e>0&&this._applyLazyInitialExpansion(e),this._commitLazyRows()}_applyLazyInitialExpansion(e){this._expandToLevel(this._items,0,e),this._expandedIds=new Set(this._expandedIds)}_rebuildMaterializedItems(){this._items=pe(this._sourceItems,this._loadedIds,this._sourceById)}_selectionRoots(){return this._isLazyEnabled()?this._sourceItems:this._items}_selectionNode(e){return this._isLazyEnabled()?this._sourceById.get(e.id)??e:e}_invalidateSearchIndex(){this._searchIndex=null,this._searchIndexSourceRef=null}_resetSearchDerivedState(){this._searchVisibleIds=new Set,this._searchUserCollapsedIds=new Set,this._searchManualExpandedIds=new Set,this._searchStatusMessage=""}_ensureSearchIndex(){const e=this._selectionRoots();return this._searchIndex&&this._searchIndexSourceRef===e?this._searchIndex:(this._searchIndexSourceRef=e,this._searchIndex=C(e),this._searchIndex)}disconnectedCallback(){super.disconnectedCallback(),this._searchDebounceTimer!==null&&(clearTimeout(this._searchDebounceTimer),this._searchDebounceTimer=null)}_findNodeById(e,t){for(const i of e){if(i.id===t)return i;if(i.children){const s=this._findNodeById(i.children,t);if(s)return s}}}_forEachInSubtree(e,t,i){const s=this._findNodeById(e,t);if(!s)return;const r=o=>{var a;i(o),(a=o.children)==null||a.forEach(r)};r(s)}_getSourceChildren(e){const t=this._isLazyEnabled()?this._sourceById.get(e):this._findNodeById(this._items,e);return t==null?void 0:t.children}_loadMoreNodes(e){if(!this._isLazyEnabled())return;const t=this._getLazyPageSize();let i;if(this._isSearchActive())if(y(this._searchVisibleIds,this._loadedIds))i=U(this._searchVisibleIds,this._loadedIds,this._indexById,t);else if(e!=null&&this._hasExclusiveSearchFolderWithUnloadedChildren())i=q(this._treeIndex,this._loadedIds,t,e);else return;else e!=null?i=q(this._treeIndex,this._loadedIds,t,e):i=le(this._treeIndex,this._loadedIds,t);i.length!==0&&(i.forEach(s=>this._loadedIds.add(s)),this._loadedIds=new Set(this._loadedIds),this._rebuildMaterializedItems(),this._commitLazyRows())}_loadSubtreeForExpand(e){const t=fe(this._treeIndex,e,this._loadedIds,this._getLazyPageSize());t.length!==0&&(t.forEach(i=>this._loadedIds.add(i)),this._loadedIds=new Set(this._loadedIds),this._rebuildMaterializedItems())}_sourceHasChildren(e){var t,i;return!!((i=(t=this._sourceById.get(e))==null?void 0:t.children)!=null&&i.length)}_commitLazyRows(){this._isLazyEnabled()&&this._syncFlatRows()}_syncFlatRows(){this._flatRows=B({items:this._items,expandedIds:this._expandedIds,hasSearch:!!this._searchTerm.trim(),searchTerm:this._searchTerm,searchVisibleIds:this._searchVisibleIds,sourceHasChildren:e=>this._sourceHasChildren(e),getSourceChildren:e=>this._getSourceChildren(e)}),this._syncActiveRowWithVisibleRows()}_setActiveRow(e){this._activeRowId!==e&&(this._activeRowId=e)}_syncActiveRowWithVisibleRows(){const e=this._getVisibleTreeRows();if(e.length===0){this._activeRowId!==null&&(this._activeRowId=null);return}const t=e.some(i=>i.node.id===this._activeRowId);(this._activeRowId===null||!t)&&(this._activeRowId=e[0].node.id)}_getRowTabIndex(e){const t=this._getVisibleTreeRows();if(t.length===0)return-1;const i=this._activeRowId??t[0].node.id;return e===i?0:-1}_rowDomId(e){return`row-${String(e)}`}_rowSelector(e){return`#${CSS.escape(this._rowDomId(e))}`}_isSearchActive(){return!!this._searchTerm.trim()}_getSearchScrollTargetIndex(){const e=this._searchTerm.trim().toLowerCase();if(!e||this._flatRows.length===0)return 0;const t=this._flatRows.map((r,o)=>({row:r,index:o})).filter(({row:r})=>g(r.node.label,e));if(t.length===0)return 0;const i=t.reduce((r,o)=>o.row.level>=r.row.level?o:r),[s]=t;if(t.length>1&&s.row.hasChildrenInSource&&this._expandedIds.has(s.row.node.id)){const r=t.find(({row:o})=>o.level===s.row.level+1&&o.node.label.toLowerCase()===s.row.node.label.toLowerCase());if(r)return r.index}return i.index}_loadUntilSearchTargetVisible(){let e=0;for(;e++<100&&!(this._getSearchScrollTargetIndex()<this._flatRows.length||!y(this._searchVisibleIds,this._loadedIds)&&!this._hasExpandedUnloadedSubtree());){if(y(this._searchVisibleIds,this._loadedIds)){if(!H(this._searchVisibleIds,this._loadedIds,this._indexById,this._getLazyPageSize()))break}else break;this._loadedIds=new Set(this._loadedIds),this._rebuildMaterializedItems(),this._commitLazyRows()}}_scrollToSearchTarget(){!this._isLazyEnabled()||!this._isSearchActive()||this.updateComplete.then(()=>{var i;const e=(i=this.shadowRoot)==null?void 0:i.querySelector("lit-virtualizer"),t=this._getSearchScrollTargetIndex();!(e!=null&&e.scrollToIndex)||t<0||e.scrollToIndex(t,"start")})}_hasExpandedUnloadedSubtree(){for(const e of this._expandedIds)if(E(e,this._treeIndex,this._loadedIds))return!0;return!1}_hasExclusiveSearchFolderWithUnloadedChildren(){if(!this._isSearchActive())return!1;const e=this._searchTerm.trim();if(!e)return!1;for(const t of this._expandedIds){const i=this._sourceById.get(t);if(i&&E(t,this._treeIndex,this._loadedIds)&&R(i.label,e,!1,t,this._searchVisibleIds,s=>this._getSourceChildren(s)))return!0}return!1}_shouldLoadMoreOnScroll(){return this._isLazyEnabled()?this._isSearchActive()?y(this._searchVisibleIds,this._loadedIds)||this._hasExclusiveSearchFolderWithUnloadedChildren():this._hasExpandedUnloadedSubtree()?this._treeIndex.some(e=>!this._loadedIds.has(e.id)):de(this._treeIndex,this._loadedIds):!1}_getLazyLoadPriorityRootId(e){if(!(!this._isSearchActive()&&!this._hasExpandedUnloadedSubtree()))return he(this._flatRows,e,this._expandedIds,this._treeIndex,this._loadedIds,this._indexById)}_getScrollPrefetchMargin(){return Math.min(20,Math.max(5,Math.floor(this._getLazyPageSize()/4)))}_onVirtualizerVisibilityChanged(e){const i=e.last;if(i==null||!this._shouldLoadMoreOnScroll()||this._lazyScrollLoading)return;const s=Math.max(0,this._flatRows.length-this._getScrollPrefetchMargin());i<s||(this._lazyScrollLoading=!0,this._loadMoreNodes(this._getLazyLoadPriorityRootId(i)),this.updateComplete.then(()=>{this._lazyScrollLoading=!1}))}_getTreeAriaLabel(){var e,t;return((t=(e=this.options)==null?void 0:e.title)==null?void 0:t.trim())||"Treeview"}_renderTreeRow(e,t,i){const{isExpanded:s,hasChildren:r,isRowHighlighted:o,isSelectable:a}=i;return h.html`
1
+ (function(p,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("lit"),require("lit/decorators.js"),require("lit/directives/repeat.js"),require("lit/directives/class-map.js"),require("@nyx-ds/core"),require("@lit-labs/virtualizer"),require("@nyx-ds/input"),require("@nyx-ds/checkbox"),require("@nyx-ds/radio"),require("@nyx-ds/icon"),require("@nyx-ds/button")):typeof define=="function"&&define.amd?define(["exports","lit","lit/decorators.js","lit/directives/repeat.js","lit/directives/class-map.js","@nyx-ds/core","@lit-labs/virtualizer","@nyx-ds/input","@nyx-ds/checkbox","@nyx-ds/radio","@nyx-ds/icon","@nyx-ds/button"],c):(p=typeof globalThis<"u"?globalThis:p||self,c(p.treeview={},p.lit,p.litDecorators,p.litRepeat,p.litClassMap,p.NyxCore))})(this,(function(p,c,_,J,b,M){"use strict";var v;function Q(n,e){return function(t,i){const{native:s=!1,...r}=i||{},o=s?new Event(e,r):new CustomEvent(e,{detail:t,...r});n.dispatchEvent(o)}}function X(n){return(e,t)=>{Object.defineProperty(e,t,{get(){return Q(this,n)},enumerable:!0,configurable:!0})}}const ee=":host{display:flex;flex-direction:column;width:100%;--treeview-radius: var(--nyx-radii-s);--treeview-search-padding: var(--nyx-sizing-1-25) var(--nyx-sizing-1-75) 0 var(--nyx-sizing-1-75);--treeview-header-padding: var(--nyx-sizing-2) var(--nyx-sizing-2) var(--nyx-sizing-1-75) var(--nyx-sizing-2);--treeview-row-padding: var(--nyx-sizing-1) var(--nyx-sizing-2);--treeview-row-gap: var(--nyx-sizing-2);--treeview-col-gap: var(--nyx-sizing-1);--treeview-node-gap: var(--nyx-sizing-1);--treeview-row-min-height: 48px;--treeview-indent-base: 16px;--treeview-indent-step: 24px;--treeview-expander-wrapper-size: var(--nyx-sizing-4);--treeview-expander-padding: var(--nyx-sizing-1-25);--treeview-col-width: var(--treeview-header-icon-size);--treeview-column-count: 0;--treeview-scrollbar-gutter: 15px;--treeview-background: var(--nyx-color-neutral-background-primary);--treeview-border-color: var(--nyx-color-neutral-border-tertiary);--treeview-content-color: var(--nyx-color-neutral-content-primary);--treeview-focus-border-color: var(--nyx-color-brand-border-default);--treeview-row-selected-background: var(--nyx-color-brand-background-softer);--treeview-row-selected-hover-background: var( --nyx-color-brand-background-softer-hover );--treeview-row-selected-color: var(--nyx-color-neutral-content-primary);--treeview-font-family: var(--nyx-font-family-font-family);--treeview-title-font-size: var(--nyx-label-medium-font-size);--treeview-title-line-height: var(--nyx-label-medium-line-height);--treeview-text-font-size: var(--nyx-label-medium-font-size);--treeview-text-line-height: var(--nyx-label-medium-line-height);--treeview-header-icon-size: var(--nyx-label-large-font-size);--treeview-node-icon-size: var(--nyx-label-medium-font-size);--treeview-expander-icon-size: var(--nyx-label-large-font-size);--treeview-row-hover-background: var(--nyx-color-neutral-background-secondary);--treeview-row-hover-color: var(--nyx-color-brand-content-hover)}.nyx-treeview{display:flex;flex-direction:column;width:100%;font-family:var(--treeview-font-family);align-items:flex-start;border-radius:var(--treeview-radius);border:1px solid var(--treeview-border-color);background:var(--treeview-background);box-sizing:border-box}.search-container{display:flex;padding:var(--treeview-search-padding);flex-direction:column;align-items:flex-start;align-self:stretch}.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}.tree-scroll{width:100%;display:flex;flex-direction:column;min-height:0}.tree-body--virtual{display:flex;flex-direction:column;flex:1 1 auto;min-height:280px;max-height:var(--treeview-max-height, 480px);overflow:hidden}.tree-virtualizer{flex:1 1 auto;width:100%;min-height:280px;scrollbar-gutter:stable}.node-wrapper--flat{width:100%}.tree-header{display:flex;justify-content:space-between;align-items:center;align-self:stretch;padding:var(--treeview-header-padding);border-bottom:.5px solid var(--treeview-border-color);box-sizing:border-box}.tree-title{color:var(--treeview-content-color);font-size:var(--treeview-title-font-size);line-height:var(--treeview-title-line-height);font-weight:600;flex:1 1 auto;min-width:0}.tree-header--no-columns .tree-title{flex:1 1 auto}.nyx-treeview--no-columns .header-columns,.nyx-treeview--no-columns .node-columns{display:none}.nyx-treeview--no-columns .tree-header{padding-inline-end:var(--nyx-sizing-2, 16px)}.header-columns,.node-columns{display:flex;align-items:center;justify-content:flex-end;gap:var(--treeview-col-gap);flex-shrink:0}.header-columns{padding-inline-end:0}.nyx-treeview--virtual .header-columns{padding-inline-end:var(--treeview-scrollbar-gutter)}.col-cell{min-width:var(--treeview-col-width);width:var(--treeview-col-width);flex:0 0 auto;display:flex;justify-content:center;align-items:center;box-sizing:border-box}.header-columns ::slotted(nyx-icon){display:flex;justify-content:center;align-items:center;--nyx-icon-size: var(--treeview-header-icon-size);color:var(--treeview-content-color)}.tree-body{width:100%;display:flex;flex-direction:column}.node-wrapper{display:flex;flex-direction:column;width:100%}.node-row{--treeview-row-level: 0;display:flex;align-items:center;justify-content:space-between;min-height:var(--treeview-row-min-height);border-bottom:.5px solid var(--treeview-border-color);gap:var(--treeview-row-gap);padding:var(--treeview-row-padding);padding-left:calc(var(--treeview-indent-base) + var(--treeview-row-level) * var(--treeview-indent-step));box-sizing:border-box;background:transparent;color:var(--treeview-content-color);outline:none;cursor:default}.node-row:hover{background:var(--treeview-row-hover-background);color:var(--treeview-row-hover-color)}.node-row:focus-within{background:var(--treeview-row-hover-background)!important;color:var(--treeview-row-hover-color)!important}.node-row:hover .expander nyx-icon,.node-row:hover .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-hover-color)}.node-row:focus-within .expander nyx-icon,.node-row:focus-within .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-hover-color)}.node-row.selectable.selected{background-color:var(--treeview-row-selected-background);color:var(--treeview-row-selected-color)}.node-row.selectable.selected .expander nyx-icon,.node-row.selectable.selected .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-selected-color)}.node-row.selectable.selected:hover{background-color:var(--treeview-row-selected-hover-background);color:var(--treeview-row-selected-color)}.node-row.selectable.selected:focus-within{background-color:var(--treeview-row-selected-background)!important;color:var(--treeview-row-selected-color)!important}.node-row.selectable.selected:focus-within .expander nyx-icon,.node-row.selectable.selected:focus-within .node-type-icon-wrapper ::slotted(nyx-icon){color:var(--treeview-row-selected-color)}.node-row.selectable.selected:hover:focus-within{background-color:var(--treeview-row-selected-hover-background)!important}.node-row:focus-visible{position:relative;z-index:2;outline:2px solid var(--treeview-focus-border-color);outline-offset:-3px;background:var(--treeview-row-hover-background)!important;color:var(--treeview-row-hover-color)}.row-checkbox{display:flex;align-items:center;margin-right:4px}.node-info{display:flex;align-items:center;gap:var(--treeview-node-gap);flex:1 0 0;overflow:hidden;min-height:32px;padding-left:4px}.expander{--button-icon-color: inherit;flex-shrink:0;width:var(--treeview-expander-wrapper-size);min-width:var(--treeview-expander-wrapper-size)}.expander-placeholder{display:block;flex-shrink:0;width:var(--treeview-expander-wrapper-size);min-width:var(--treeview-expander-wrapper-size);height:var(--treeview-expander-wrapper-size)}.expander nyx-icon{--nyx-icon-size: var(--treeview-expander-icon-size);transition:transform .2s ease;transform-origin:center}.expander nyx-icon.expanded{transform:rotate(90deg)}.expander:hover,.expander:focus-within{--button-icon-color: var(--treeview-content-color) !important}.expander:hover nyx-icon,.expander:focus-within nyx-icon{color:var(--treeview-content-color)!important;--nyx-icon-color: var(--treeview-content-color) !important}.node-row:hover .expander:hover,.node-row:hover .expander:focus-within{--button-icon-color: var(--treeview-row-hover-color) !important}.node-row:hover .expander:hover nyx-icon,.node-row:hover .expander:focus-within nyx-icon{color:var(--treeview-row-hover-color)!important;--nyx-icon-color: var(--treeview-row-hover-color) !important}.node-type-icon-wrapper{display:flex;align-items:center;justify-content:center;flex-shrink:0}.node-type-icon-wrapper ::slotted(nyx-icon){--nyx-icon-size: var(--treeview-node-icon-size)}.node-text{font-size:var(--treeview-text-font-size);line-height:var(--treeview-text-line-height);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.node-children{width:100%}@media(max-width:768px){.tree-scroll{overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}.tree-header,.tree-body{min-width:calc(250px + ((var(--treeview-col-width) + var(--treeview-col-gap)) * var(--treeview-column-count)))}.node-text{white-space:normal;display:-webkit-box;line-clamp:2;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}}",te=200;function y(n,e){const t=e.trim().toLowerCase();return t?n.toLowerCase().includes(t):!1}function C(n,e){return n.includes(e)}function R(n){var s;const e=new Map,t=[],i=[];for(let r=n.length-1;r>=0;r--)i.push({node:n[r],parentId:null});for(;i.length>0;){const{node:r,parentId:o}=i.pop(),a=((s=r.children)==null?void 0:s.map(l=>l.id))??[];if(e.set(r.id,{id:r.id,parentId:o,normalizedLabel:r.label.toLowerCase(),childIds:a,hasChildren:a.length>0}),o===null&&t.push(r.id),r.children)for(let l=r.children.length-1;l>=0;l--)i.push({node:r.children[l],parentId:r.id})}return{roots:t,byId:e,size:e.size}}function ie(n){const e=[],t=[];for(let i=n.roots.length-1;i>=0;i--)t.push({id:n.roots[i],visited:!1});for(;t.length>0;){const i=t[t.length-1];if(i.visited)t.pop(),e.push(i.id);else{i.visited=!0;const s=n.byId.get(i.id);if(!s)continue;for(let r=s.childIds.length-1;r>=0;r--)t.push({id:s.childIds[r],visited:!1})}}return e}function se(n,e,t){const i=new Set,s=new Set,r=new Map;for(const o of ie(n)){const a=n.byId.get(o);if(!a)continue;const l=C(a.normalizedLabel,e);let d=!1;for(const w of a.childIds)if(r.get(w)){d=!0;break}const h=l||d;if(r.set(o,h),!h||(i.add(o),!a.hasChildren||!d))continue;let m=!1;for(const w of a.childIds){const x=n.byId.get(w);if(x&&C(x.normalizedLabel,e)){m=!0;break}}!t.has(o)&&(!l||m)&&s.add(o)}return{visibleIds:i,expandIds:s}}function re(n,e){const t=e.trim().toLowerCase();if(!t)return 0;const i=Array.isArray(n)?R(n):n;let s=0;for(const r of i.byId.values())C(r.normalizedLabel,t)&&s++;return s}function ne(n,e,t=new Set){const i=e.trim().toLowerCase();if(!i)return{visibleIds:new Set,expandIds:new Set};const s=Array.isArray(n)?R(n):n;return se(s,i,t)}function N(n,e,t=""){const i=n.children??[],s=t.trim().toLowerCase();return s?i.filter(r=>e.has(r.id)||y(r.label,s)):i.filter(r=>e.has(r.id))}function oe(n,e,t){const i=e.trim().toLowerCase();if(!i)return!1;const s=[n];for(;s.length>0;){const r=s.pop();for(const o of t(r)??[]){if(y(o.label,i))return!0;s.push(o.id)}}return!1}function ae(n,e,t){const i=[n];for(;i.length>0;){const s=i.pop();for(const r of t(s)??[]){if(e.has(r.id))return!0;i.push(r.id)}}return!1}function z(n,e,t,i,s,r){return D(n,e,t)&&!ae(i,s,r)&&!oe(i,e,r)}function D(n,e,t){return y(n,e)&&!t}function P(n,e,t,i){return t||D(n,e,i)}function E(n,e){var t,i;if(e){if(n.selected)return!0}else if((((t=n.selectedColumns)==null?void 0:t.length)??0)>0)return!0;return((i=n.children)==null?void 0:i.some(s=>E(s,e)))??!1}function V(n,e){const t=n.map((i,s)=>({node:i,index:s}));return t.sort((i,s)=>{const r=E(i.node,e),o=E(s.node,e);return r!==o?r?-1:1:i.index-s.index}),t.map(({node:i})=>{var s;return(s=i.children)!=null&&s.length?{...i,children:V(i.children,e)}:i})}const g=50;function le(n){const e=[],t=n.map(s=>({node:s,depth:0,parentId:null}));let i=0;for(;i<t.length;){const s=t[i++],{node:r,depth:o,parentId:a}=s,l=!!(r.children&&r.children.length>0);if(e.push({id:r.id,depth:o,parentId:a,hasChildrenInSource:l}),l)for(const d of r.children)t.push({node:d,depth:o+1,parentId:r.id})}return e}function de(n,e=g){const t=new Set;for(const i of n)if(i.depth===0&&(t.add(i.id),t.size>=e))break;return t}function ce(n,e,t){const i=[];for(const s of n)if(s.depth===0&&!e.has(s.id)&&(i.push(s.id),i.length>=t))break;return i}function he(n,e){return n.some(t=>t.depth===0&&!e.has(t.id))}function ue(n,e,t){return k(e,n).some(i=>!t.has(i))}function q(n,e,t){return e.some(i=>i.parentId===n&&!t.has(i.id))}function U(n,e){if(!n)return;let t=n.node.id,i=e.get(t);for(;(i==null?void 0:i.parentId)!=null;)t=i.parentId,i=e.get(t);return t}function fe(n,e,t,i,s,r){const o=Math.min(Math.max(0,e),Math.max(0,n.length-1));for(let a=o;a>=0;a--){const l=n[a];if(t.has(l.node.id)&&q(l.node.id,i,s))return U(l,r)}return U(n[o],r)}function pe(n,e){const t=[];let i=e.get(n);for(;(i==null?void 0:i.parentId)!=null;)t.push(i.parentId),i=e.get(i.parentId);return t}function F(n,e,t){if(t<0)return[];const i=L(n),s=[];for(const r of e){const o=[{id:r,level:0}];for(;o.length>0;){const a=o.pop();if(a.level>t)continue;s.push(a.id);const l=i.get(a.id);if(!(!(l!=null&&l.length)||a.level>=t))for(let d=l.length-1;d>=0;d--)o.push({id:l[d],level:a.level+1})}}return s}function _e(n,e,t){if(t<=0)return[];const i=L(n),s=[];for(const r of e){const o=[{id:r,level:0}];for(;o.length>0;){const a=o.pop();if(a.level>=t)continue;const l=i.get(a.id);if(l!=null&&l.length){s.push(a.id);for(let d=l.length-1;d>=0;d--)o.push({id:l[d],level:a.level+1})}}}return s}function B(n,e,t,i){const s=[],r=o=>{s.length>=t||!e.has(o)&&!s.includes(o)&&s.push(o)};if(i!=null){const o=k(n,i);for(const a of o)r(a)}for(const o of n)if(r(o.id),s.length>=t)break;return s}function k(n,e){const t=L(n),i=[],s=[e];for(;s.length>0;){const r=s.pop();i.push(r);const o=t.get(r);if(o!=null&&o.length)for(let a=o.length-1;a>=0;a--)s.push(o[a])}return i}function L(n){const e=new Map;for(const t of n){const i=t.parentId;e.has(i)||e.set(i,[]),e.get(i).push(t.id)}return e}function we(n,e,t){return k(n,e).filter(i=>!t.has(i))}function ve(n,e,t,i=g){return we(n,e,t).slice(0,i)}function T(n){var e;return{...n,selectedColumns:n.selectedColumns?[...n.selectedColumns]:void 0,disabledColumns:n.disabledColumns?[...n.disabledColumns]:void 0,children:(e=n.children)==null?void 0:e.map(t=>T(t)),data:n.data}}function me(n){const e=new Map,t=i=>{var s;e.set(i.id,i),(s=i.children)==null||s.forEach(t)};return n.forEach(t),e}function xe(n,e,t){const i=s=>{if(!e.has(s.id))return null;const r=t.get(s.id)??s,o=(r.children??[]).map(l=>i(l)).filter(l=>l!==null),a=T(r);return a.children=o.length>0?o:void 0,a};return n.map(s=>i(s)).filter(s=>s!==null)}function H(n){const e=[],t=n.searchTerm.trim().toLowerCase(),i=(s,r,o,a,l=!1)=>{const d=n.hasSearch&&!l?s.filter(h=>n.searchVisibleIds.has(h.id)):s;for(const h of d){const m=n.hasSearch&&!!t&&h.label.toLowerCase().includes(t),w=P(h.label,t,o,a),x=a||!!m;if(e.push({node:h,level:r,revealSubtree:w,parentLabelMatched:x,hasChildrenInSource:n.sourceHasChildren(h.id)}),!n.expandedIds.has(h.id))continue;const K=n.getSourceChildren??(A=>{var Y;return(Y=n.items.find(Ce=>Ce.id===A))==null?void 0:Y.children}),S=!n.hasSearch||w&&z(h.label,t,a,h.id,n.searchVisibleIds,K)?h.children??[]:N(h,n.searchVisibleIds,n.searchTerm);S.length>0&&i(S,r+1,w,x,!0)}};return i(n.items,0,!1,!1),e}function I(n,e){for(const t of n)if(!e.has(t))return!0;return!1}function O(n,e,t,i=g){const s=[],r=o=>{s.length>=i||!e.has(o)&&!s.includes(o)&&s.push(o)};for(const o of n)if(!e.has(o)){r(o);for(const a of pe(o,t))r(a);if(s.length>=i)break}return s}function W(n,e,t,i=g){const s=O(n,e,t,i);return s.length===0?!1:(s.forEach(r=>e.add(r)),!0)}function be(n,e){return e?`Collapse ${n}`:`Expand ${n}`}function j(n){return`Select ${n}`}function ge(n,e){return`${n}, ${e}`}function ye(n){return n===0?"No results found":n===1?"1 result found":`${n} results found`}var Ie=Object.defineProperty,Se=Object.getOwnPropertyDescriptor,f=(n,e,t,i)=>{for(var s=i>1?void 0:i?Se(e,t):e,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(e,t,s):o(s))||s);return i&&s&&Ie(e,t,s),s};const u=(v=class extends c.LitElement{constructor(){super(...arguments),this._rowSelectionRadioName=`nyx-treeview-row-selection-${v._nextTreeviewId++}`,this._items=[],this._expandedIds=new Set,this._searchTerm="",this._searchStatusMessage="",this._searchVisibleIds=new Set,this._searchUserCollapsedIds=new Set,this._searchManualExpandedIds=new Set,this._expandedIdsBeforeSearch=null,this._flatRows=[],this._loadedIds=new Set,this._activeRowId=null,this._sourceItems=[],this._lazyItemsSourceRef=null,this._treeIndex=[],this._indexById=new Map,this._sourceById=new Map,this._lazyScrollLoading=!1,this._searchIndex=null,this._searchIndexSourceRef=null,this._searchDebounceTimer=null}get options(){return this._options}set options(e){const t=this._options;t!==e&&(this._options=e,e&&(this._applyOptionsChange(),this._generateLightDomIcons()),this.requestUpdate("options",t))}_isLazyEnabled(){var e;return!!((e=this.options)!=null&&e.lazyLoad)}_getLazyPageSize(){var t;const e=(t=this.options)==null?void 0:t.lazyLoadPageSize;return e==null||!Number.isFinite(e)?g:Math.max(1,Math.floor(e))}_hasColumnPermissions(){var e,t,i;return((e=this.options)==null?void 0:e.showColumnPermissions)===!1?!1:(((i=(t=this.options)==null?void 0:t.columns)==null?void 0:i.length)??0)>0}_showRowSelection(){var e;return!!((e=this.options)!=null&&e.showRowSelection)}_usesUniqueRowSelection(){var e;return this._showRowSelection()&&!!((e=this.options)!=null&&e.uniqueSelection)}_showNodeIcons(){var e;return((e=this.options)==null?void 0:e.showNodeIcons)!==!1}_usesSimpleRowSelection(){return this._showRowSelection()&&!this._usesUniqueRowSelection()&&!this._hasColumnPermissions()}_applyItemsFromOptions(e){var i;let t=e.map(s=>T(s));return this._usesUniqueRowSelection()&&this._applyUniqueSelectionConstraint(t),(i=this.options)!=null&&i.sortSelectedFirst&&(t=V(t,this._usesSimpleRowSelection())),t}_applyUniqueSelectionConstraint(e){let t=!1;const i=s=>{s.forEach(r=>{r.selected&&(t?r.selected=!1:t=!0),r.children&&i(r.children)})};i(e)}_applyOptionsChange(){if(this.options){if(this._isLazyEnabled()){this.options.items!==this._lazyItemsSourceRef&&(this._initLazyState(),this._resetSearchDerivedState(),this._searchTerm.trim()&&this._recomputeSearchFilter());return}if(this._items=this._applyItemsFromOptions(this.options.items),this._invalidateSearchIndex(),this._activeRowId=null,this._resetSearchDerivedState(),this._searchTerm.trim()){this._recomputeSearchFilter();return}this.options.defaultExpandedLevel!==void 0&&this._expandedIds.size===0&&this._expandToLevel(this._items,0,this.options.defaultExpandedLevel),this._syncActiveRowWithVisibleRows()}}_initLazyState(){var s;this._lazyItemsSourceRef=this.options.items,this._sourceItems=this._applyItemsFromOptions(this.options.items),this._invalidateSearchIndex(),this._treeIndex=le(this._sourceItems),this._indexById=new Map(this._treeIndex.map(r=>[r.id,r])),this._sourceById=me(this._sourceItems);const e=(s=this.options)==null?void 0:s.defaultExpandedLevel,t=this._getLazyPageSize(),i=de(this._treeIndex,t);this._loadedIds=new Set(i),e!==void 0&&e>0&&this._loadDefaultExpandedLevelForRoots(i,e),this._expandedIds=new Set,e!==void 0&&e>0&&this._applyLazyDefaultExpansion(i,e),this._activeRowId=null,this._rebuildMaterializedItems(),this._commitLazyRows()}_loadDefaultExpandedLevelForRoots(e,t){F(this._treeIndex,e,t).forEach(i=>this._loadedIds.add(i))}_applyLazyDefaultExpansion(e,t){_e(this._treeIndex,e,t).forEach(i=>this._expandedIds.add(i)),this._expandedIds=new Set(this._expandedIds)}_rebuildMaterializedItems(){this._items=xe(this._sourceItems,this._loadedIds,this._sourceById)}_selectionRoots(){return this._isLazyEnabled()?this._sourceItems:this._items}_selectionNode(e){return this._isLazyEnabled()?this._sourceById.get(e.id)??e:e}_invalidateSearchIndex(){this._searchIndex=null,this._searchIndexSourceRef=null}_resetSearchDerivedState(){this._searchVisibleIds=new Set,this._searchUserCollapsedIds=new Set,this._searchManualExpandedIds=new Set,this._searchStatusMessage=""}_ensureSearchIndex(){const e=this._selectionRoots();return this._searchIndex&&this._searchIndexSourceRef===e?this._searchIndex:(this._searchIndexSourceRef=e,this._searchIndex=R(e),this._searchIndex)}disconnectedCallback(){super.disconnectedCallback(),this._searchDebounceTimer!==null&&(clearTimeout(this._searchDebounceTimer),this._searchDebounceTimer=null)}_findNodeById(e,t){for(const i of e){if(i.id===t)return i;if(i.children){const s=this._findNodeById(i.children,t);if(s)return s}}}_forEachInSubtree(e,t,i){const s=this._findNodeById(e,t);if(!s)return;const r=o=>{var a;i(o),(a=o.children)==null||a.forEach(r)};r(s)}_getSourceChildren(e){const t=this._isLazyEnabled()?this._sourceById.get(e):this._findNodeById(this._items,e);return t==null?void 0:t.children}_loadMoreNodes(e){var o,a;if(!this._isLazyEnabled())return;const t=this._getLazyPageSize();let i,s=[];if(this._isSearchActive())if(I(this._searchVisibleIds,this._loadedIds))i=O(this._searchVisibleIds,this._loadedIds,this._indexById,t);else if(e!=null&&this._hasExclusiveSearchFolderWithUnloadedChildren())i=B(this._treeIndex,this._loadedIds,t,e);else return;else if(e!=null)i=B(this._treeIndex,this._loadedIds,t,e);else{s=ce(this._treeIndex,this._loadedIds,t),i=[...s];const l=(o=this.options)==null?void 0:o.defaultExpandedLevel;l!==void 0&&l>0&&i.push(...F(this._treeIndex,s,l))}if(i.length===0)return;i.forEach(l=>this._loadedIds.add(l));const r=(a=this.options)==null?void 0:a.defaultExpandedLevel;s.length>0&&r!==void 0&&r>0&&this._applyLazyDefaultExpansion(s,r),this._loadedIds=new Set(this._loadedIds),this._rebuildMaterializedItems(),this._commitLazyRows()}_loadSubtreeForExpand(e){const t=ve(this._treeIndex,e,this._loadedIds,this._getLazyPageSize());t.length!==0&&(t.forEach(i=>this._loadedIds.add(i)),this._loadedIds=new Set(this._loadedIds),this._rebuildMaterializedItems())}_sourceHasChildren(e){var t,i;return!!((i=(t=this._sourceById.get(e))==null?void 0:t.children)!=null&&i.length)}_commitLazyRows(){this._isLazyEnabled()&&this._syncFlatRows()}_syncFlatRows(){this._flatRows=H({items:this._items,expandedIds:this._expandedIds,hasSearch:!!this._searchTerm.trim(),searchTerm:this._searchTerm,searchVisibleIds:this._searchVisibleIds,sourceHasChildren:e=>this._sourceHasChildren(e),getSourceChildren:e=>this._getSourceChildren(e)}),this._syncActiveRowWithVisibleRows()}_setActiveRow(e){this._activeRowId!==e&&(this._activeRowId=e)}_syncActiveRowWithVisibleRows(){const e=this._getVisibleTreeRows();if(e.length===0){this._activeRowId!==null&&(this._activeRowId=null);return}const t=e.some(i=>i.node.id===this._activeRowId);(this._activeRowId===null||!t)&&(this._activeRowId=e[0].node.id)}_getRowTabIndex(e){const t=this._getVisibleTreeRows();if(t.length===0)return-1;const i=this._activeRowId??t[0].node.id;return e===i?0:-1}_rowDomId(e){return`row-${String(e)}`}_rowSelector(e){return`#${CSS.escape(this._rowDomId(e))}`}_isSearchActive(){return!!this._searchTerm.trim()}_getSearchScrollTargetIndex(){const e=this._searchTerm.trim().toLowerCase();if(!e||this._flatRows.length===0)return 0;const t=this._flatRows.map((r,o)=>({row:r,index:o})).filter(({row:r})=>y(r.node.label,e));if(t.length===0)return 0;const i=t.reduce((r,o)=>o.row.level>=r.row.level?o:r),[s]=t;if(t.length>1&&s.row.hasChildrenInSource&&this._expandedIds.has(s.row.node.id)){const r=t.find(({row:o})=>o.level===s.row.level+1&&o.node.label.toLowerCase()===s.row.node.label.toLowerCase());if(r)return r.index}return i.index}_loadUntilSearchTargetVisible(){let e=0;for(;e++<100&&!(this._getSearchScrollTargetIndex()<this._flatRows.length||!I(this._searchVisibleIds,this._loadedIds)&&!this._hasExpandedUnloadedSubtree());){if(I(this._searchVisibleIds,this._loadedIds)){if(!W(this._searchVisibleIds,this._loadedIds,this._indexById,this._getLazyPageSize()))break}else break;this._loadedIds=new Set(this._loadedIds),this._rebuildMaterializedItems(),this._commitLazyRows()}}_scrollToSearchTarget(){!this._isLazyEnabled()||!this._isSearchActive()||this.updateComplete.then(()=>{var i;const e=(i=this.shadowRoot)==null?void 0:i.querySelector("lit-virtualizer"),t=this._getSearchScrollTargetIndex();!(e!=null&&e.scrollToIndex)||t<0||e.scrollToIndex(t,"start")})}_hasExpandedUnloadedSubtree(){for(const e of this._expandedIds)if(q(e,this._treeIndex,this._loadedIds))return!0;return!1}_hasExclusiveSearchFolderWithUnloadedChildren(){if(!this._isSearchActive())return!1;const e=this._searchTerm.trim();if(!e)return!1;for(const t of this._expandedIds){const i=this._sourceById.get(t);if(i&&ue(t,this._treeIndex,this._loadedIds)&&z(i.label,e,!1,t,this._searchVisibleIds,s=>this._getSourceChildren(s)))return!0}return!1}_shouldLoadMoreOnScroll(){return this._isLazyEnabled()?this._isSearchActive()?I(this._searchVisibleIds,this._loadedIds)||this._hasExclusiveSearchFolderWithUnloadedChildren():this._hasExpandedUnloadedSubtree()?this._treeIndex.some(e=>!this._loadedIds.has(e.id)):he(this._treeIndex,this._loadedIds):!1}_getLazyLoadPriorityRootId(e){if(!(!this._isSearchActive()&&!this._hasExpandedUnloadedSubtree()))return fe(this._flatRows,e,this._expandedIds,this._treeIndex,this._loadedIds,this._indexById)}_getScrollPrefetchMargin(){return Math.min(20,Math.max(5,Math.floor(this._getLazyPageSize()/4)))}_onVirtualizerVisibilityChanged(e){const i=e.last;if(i==null||!this._shouldLoadMoreOnScroll()||this._lazyScrollLoading)return;const s=Math.max(0,this._flatRows.length-this._getScrollPrefetchMargin());i<s||(this._lazyScrollLoading=!0,this._loadMoreNodes(this._getLazyLoadPriorityRootId(i)),this.updateComplete.then(()=>{this._lazyScrollLoading=!1}))}_getTreeAriaLabel(){var e,t;return((t=(e=this.options)==null?void 0:e.title)==null?void 0:t.trim())||"Treeview"}_renderTreeRow(e,t,i){const{isExpanded:s,hasChildren:r,isRowHighlighted:o,isSelectable:a}=i;return c.html`
2
2
  <div
3
3
  id=${this._rowDomId(e.id)}
4
4
  role="treeitem"
5
5
  aria-level=${t+1}
6
- aria-expanded=${r?s?"true":"false":h.nothing}
6
+ aria-expanded=${r?s?"true":"false":c.nothing}
7
7
  class=${b.classMap({"node-row":!0,selectable:a,selected:o})}
8
8
  style="--treeview-row-level: ${t}"
9
9
  tabindex=${this._getRowTabIndex(e.id)}
10
- @mousedown=${d=>d.preventDefault()}
10
+ @mousedown=${l=>l.preventDefault()}
11
11
  @focus=${()=>this._setActiveRow(e.id)}
12
- @keydown=${d=>this._handleRowKeyDown(d,e)}
12
+ @keydown=${l=>this._handleRowKeyDown(l,e)}
13
13
  @focusout=${this._handleRowFocusOut}
14
14
  >
15
15
  <div class="node-info">
@@ -20,14 +20,14 @@
20
20
  </div>
21
21
  ${this._renderColumnCheckboxes(e)}
22
22
  </div>
23
- `}_renderExpanderCell(e,t,i){return i?h.html`
23
+ `}_renderExpanderCell(e,t,i){return i?c.html`
24
24
  <nyx-button
25
25
  class="expander"
26
26
  size="small"
27
27
  button-icon
28
28
  tabindex="-1"
29
29
  hierarchy="ghost"
30
- aria-label=${we(e.label,t)}
30
+ aria-label=${be(e.label,t)}
31
31
  @click=${()=>this._toggleExpand(e,!1)}
32
32
  @keydown=${s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),s.stopPropagation(),this._toggleExpand(e,!0))}}
33
33
  >
@@ -37,17 +37,33 @@
37
37
  .svg=${M.chevronRightRegular}
38
38
  ></nyx-icon>
39
39
  </nyx-button>
40
- `:h.html`<span class="expander-placeholder" aria-hidden="true"></span>`}_renderNodeTypeIcon(e){const t=e.icon;return t?typeof t=="string"?h.html`<nyx-icon name=${t} variant="regular"></nyx-icon>`:h.html`
40
+ `:c.html`<span class="expander-placeholder" aria-hidden="true"></span>`}_renderNodeTypeIcon(e){const t=e.icon;return t?typeof t=="string"?c.html`<nyx-icon name=${t} variant="regular"></nyx-icon>`:c.html`
41
41
  <nyx-icon
42
- name=${t.name??h.nothing}
42
+ name=${t.name??c.nothing}
43
43
  variant=${t.variant??"regular"}
44
- src=${t.src??h.nothing}
44
+ src=${t.src??c.nothing}
45
45
  .svg=${t.svg}
46
46
  ></nyx-icon>
47
- `:h.nothing}_generateLightDomIcons(){var i;if(this.querySelectorAll("[data-auto-generated]").forEach(s=>s.remove()),!this.options||(this._hasColumnPermissions()&&((i=this.options.columns)==null||i.forEach((s,r)=>{s.icon&&this._createIconElement(s.icon,`generated-header-icon-${r}`)})),this._isLazyEnabled()||!this._showNodeIcons()))return;const t=s=>{var r;s.icon&&this._createIconElement(s.icon,`generated-tree-icon-${s.id}`),(r=s.children)==null||r.forEach(t)};this._items.forEach(t)}_createIconElement(e,t){const i=document.createElement("nyx-icon");let s="regular";typeof e=="string"?i.setAttribute("name",e):(e.name&&i.setAttribute("name",e.name),e.variant&&(s=e.variant),e.src&&i.setAttribute("src",e.src),e.svg&&(i.svg=e.svg)),i.setAttribute("variant",s),i.setAttribute("slot",t),i.setAttribute("data-auto-generated",""),this.appendChild(i)}_expandToLevel(e,t,i){e.forEach(s=>{t<i&&(this._expandedIds.add(s.id),s.children&&this._expandToLevel(s.children,t+1,i))})}_isColumnDisabled(e,t){return!!e.disabledColumns&&e.disabledColumns.includes(t)}_isNodeSelected(e,t){return this._isColumnDisabled(e,t)?!1:(e.selectedColumns||[]).includes(t)}_isIndeterminate(e,t){if(e=this._selectionNode(e),!e.children||e.children.length===0)return!1;const i=this._getFlatDescendants(e),s=i.filter(r=>this._isNodeSelected(r,t)).length;return s>0&&s<i.length}_allDescendantsSelected(e,t){return e=this._selectionNode(e),!e.children||e.children.length===0?this._isNodeSelected(e,t):this._getFlatDescendants(e).every(s=>this._isNodeSelected(s,t))}_getFlatDescendants(e){e=this._selectionNode(e);let t=[];return e.children&&e.children.forEach(i=>{const s=this._selectionNode(i);t.push(s),t=t.concat(this._getFlatDescendants(s))}),t}_requiredClosure(e){var a,d,l;const t=((a=this.options)==null?void 0:a.columns)??[],i=new Map(t.map(c=>[c.id,c])),s=[],r=new Set([e]),o=[...((d=i.get(e))==null?void 0:d.requires)??[]];for(;o.length;){const c=o.pop();r.has(c)||(r.add(c),s.push(c),o.push(...((l=i.get(c))==null?void 0:l.requires)??[]))}return s}_dependentsClosure(e){var o;const t=((o=this.options)==null?void 0:o.columns)??[],i=[],s=new Set([e]),r=[e];for(;r.length;){const a=r.pop();for(const d of t)(d.requires??[]).includes(a)&&!s.has(d.id)&&(s.add(d.id),i.push(d.id),r.push(d.id))}return i}_canEnableColumn(e,t){return this._isColumnDisabled(e,t)?!1:this._requiredClosure(t).every(i=>!this._isColumnDisabled(e,i))}_handleCheck(e,t){const i=this._selectionNode(e);if(this._isColumnDisabled(i,t))return;const r=!this._isNodeSelected(i,t),o=this._requiredClosure(t),a=r?[t,...o]:[t,...this._dependentsClosure(t)];this._forEachInSubtree(this._selectionRoots(),e.id,d=>{r&&o.some(c=>this._isColumnDisabled(d,c))||a.forEach(l=>this._toggleNodeState(d,l,r))}),a.forEach(d=>this._updateParents(this._selectionRoots(),e.id,d)),this._triggerChange()}_toggleNodeState(e,t,i){if(this._isColumnDisabled(e,t))return;e.selectedColumns||(e.selectedColumns=[]);const s=e.selectedColumns.indexOf(t);i&&s===-1?e.selectedColumns.push(t):!i&&s>-1&&e.selectedColumns.splice(s,1)}_updateParents(e,t,i){for(const s of e)if(s.children&&s.children.some(r=>r.id===t||this._updateParents(s.children,t,i))){const r=s.children.every(o=>this._allDescendantsSelected(o,i));return this._toggleNodeState(s,i,r&&this._canEnableColumn(s,i)),!0}return!1}_isRowAllSelected(e){var i;if(e=this._selectionNode(e),!((i=this.options)!=null&&i.columns))return!1;const t=this.options.columns.every(s=>this._isColumnDisabled(e,s.id)?!0:this._isNodeSelected(e,s.id));return e.children&&e.children.length>0?t&&e.children.every(s=>this._isRowAllSelected(s)):t}_isRowIndeterminate(e){var s;if(e=this._selectionNode(e),this._isRowAllSelected(e)||!((s=this.options)!=null&&s.columns))return!1;const t=this.options.columns.some(r=>this._isNodeSelected(e,r.id)),i=e.children?e.children.some(r=>this._isRowAllSelected(r)||this._isRowIndeterminate(r)):!1;return t||i}_isSimpleRowAllSelected(e){var t;return e=this._selectionNode(e),(t=e.children)!=null&&t.length?e.children.every(i=>this._isSimpleRowAllSelected(i)):!!e.selected}_isSimpleRowIndeterminate(e){var s;return e=this._selectionNode(e),this._isSimpleRowAllSelected(e)||!((s=e.children)!=null&&s.length)?!1:this._getFlatDescendants(e).filter(r=>r.selected).length>0}_setSimpleRowSelected(e,t){this._forEachInSubtree(this._selectionRoots(),e,i=>{i.selected=t})}_updateSimpleRowParents(e,t){var i;for(const s of e)if((i=s.children)!=null&&i.some(r=>r.id===t||this._updateSimpleRowParents(s.children,t)))return s.selected=s.children.every(r=>this._isSimpleRowAllSelected(r)),!0;return!1}_isRowCheckboxChecked(e){const t=this._selectionNode(e);return this._usesSimpleRowSelection()?this._isSimpleRowAllSelected(t):this._isRowAllSelected(t)}_isRowCheckboxIndeterminate(e){const t=this._selectionNode(e);return this._usesSimpleRowSelection()?this._isSimpleRowIndeterminate(t):this._isRowIndeterminate(t)}_handleRowCheck(e){var s;const i=!this._isRowCheckboxChecked(e);this._usesSimpleRowSelection()?(this._setSimpleRowSelected(e.id,i),this._updateSimpleRowParents(this._selectionRoots(),e.id)):(this._toggleRowRecursively(e.id,i),(s=this.options)!=null&&s.columns&&this.options.columns.forEach(r=>{this._updateParents(this._selectionRoots(),e.id,r.id)})),this._triggerChange()}_applyRowColumnsToNode(e,t){var i;(i=this.options)!=null&&i.columns&&(t?this.options.columns.forEach(s=>{this._canEnableColumn(e,s.id)&&(e.selectedColumns||(e.selectedColumns=[]),e.selectedColumns.includes(s.id)||e.selectedColumns.push(s.id))}):e.selectedColumns=(e.selectedColumns??[]).filter(s=>this._isColumnDisabled(e,s)))}_toggleRowRecursively(e,t){this._forEachInSubtree(this._selectionRoots(),e,i=>{this._applyRowColumnsToNode(i,t)})}_triggerChange(){if(this._isLazyEnabled()){this._rebuildMaterializedItems(),this._commitLazyRows(),this.onChange({items:this._sourceItems},{bubbles:!0,composed:!0});return}this._items=[...this._items],this._invalidateSearchIndex(),this._searchTerm.trim()&&this._recomputeSearchFilter(),this.onChange({items:this._items},{bubbles:!0,composed:!0})}_handleSearchInput(e){const t=e.target.value,i=this._searchTerm,s=t.trim();if(this._searchDebounceTimer!==null&&(clearTimeout(this._searchDebounceTimer),this._searchDebounceTimer=null),!s&&i.trim()){this._applySearchTerm(t,i);return}this._searchDebounceTimer=setTimeout(()=>{this._searchDebounceTimer=null,this._applySearchTerm(t,i)},X)}_applySearchTerm(e,t){const i=t.trim(),s=e.trim();!i&&s?(this._expandedIdsBeforeSearch=new Set(this._expandedIds),this._searchManualExpandedIds=new Set,this._searchUserCollapsedIds=new Set):i&&!s?(this._searchUserCollapsedIds=new Set,this._searchManualExpandedIds=new Set):i&&s&&i.toLowerCase()!==s.toLowerCase()&&(this._searchUserCollapsedIds=new Set,this._searchManualExpandedIds=new Set),this._searchTerm=e,this._recomputeSearchFilter()}_recomputeSearchFilter(){const e=this._searchTerm.trim();if(!e){this._searchVisibleIds=new Set,this._expandedIdsBeforeSearch&&(this._expandedIds=new Set(this._expandedIdsBeforeSearch),this._expandedIdsBeforeSearch=null),this._isLazyEnabled()?this._commitLazyRows():this._syncActiveRowWithVisibleRows(),this._updateSearchStatusMessage();return}const t=this._ensureSearchIndex(),{visibleIds:i,expandIds:s}=te(t,e,this._searchUserCollapsedIds),r=new Set(s);this._searchManualExpandedIds.forEach(o=>{this._searchUserCollapsedIds.has(o)||r.add(o)}),this._searchVisibleIds=i,this._expandedIds=r,this._isLazyEnabled()?(H(i,this._loadedIds,this._indexById,this._getLazyPageSize())&&(this._loadedIds=new Set(this._loadedIds),this._rebuildMaterializedItems()),this._commitLazyRows(),this._loadUntilSearchTargetVisible(),this._scrollToSearchTarget()):this._syncActiveRowWithVisibleRows(),this._updateSearchStatusMessage()}_updateSearchStatusMessage(){const e=this._searchTerm.trim();if(!e){this._searchStatusMessage="";return}const t=this._ensureSearchIndex();this._searchStatusMessage=xe(ee(t,e))}async _toggleExpand(e,t=!1){if(!(this._isLazyEnabled()?this._sourceHasChildren(e.id):!!(e.children&&e.children.length>0)))return;const s=this._expandedIds.has(e.id);s?(this._expandedIds.delete(e.id),this._searchTerm.trim()&&(this._searchUserCollapsedIds.add(e.id),this._searchUserCollapsedIds=new Set(this._searchUserCollapsedIds),this._searchManualExpandedIds.delete(e.id),this._searchManualExpandedIds=new Set(this._searchManualExpandedIds))):(this._expandedIds.add(e.id),this._searchTerm.trim()&&(this._searchManualExpandedIds.add(e.id),this._searchManualExpandedIds=new Set(this._searchManualExpandedIds),this._searchUserCollapsedIds.delete(e.id),this._searchUserCollapsedIds=new Set(this._searchUserCollapsedIds)),this._isLazyEnabled()&&this._loadSubtreeForExpand(e.id)),this._expandedIds=new Set(this._expandedIds),this._isLazyEnabled()?this._commitLazyRows():this._syncActiveRowWithVisibleRows(),!s&&t&&(await this.updateComplete,this._focusFirstVisibleChild(e.id))}_nodeHasChildren(e){return this._isLazyEnabled()?this._sourceHasChildren(e.id):!!(e.children&&e.children.length>0)}_getVisibleTreeRows(){return this._isLazyEnabled()?this._flatRows:B({items:this._items,expandedIds:this._expandedIds,hasSearch:this._isSearchActive(),searchTerm:this._searchTerm,searchVisibleIds:this._searchVisibleIds,sourceHasChildren:e=>{var t;return!!((t=this._getSourceChildren(e))!=null&&t.length)},getSourceChildren:e=>this._getSourceChildren(e)})}_getParentId(e){var s;if(this._isLazyEnabled()){const r=(s=this._indexById.get(e))==null?void 0:s.parentId;return r??void 0}let t;const i=(r,o)=>{for(const a of r){if(a.id===e)return t=o??void 0,!0;if(a.children&&i(a.children,a.id))return!0}return!1};return i(this._items,null),t}_focusRowById(e){this._setActiveRow(e),this.updateComplete.then(()=>{var i,s,r;if(this._isLazyEnabled()){const o=this._flatRows.findIndex(a=>a.node.id===e);if(o>=0){const a=(i=this.shadowRoot)==null?void 0:i.querySelector("lit-virtualizer");(s=a==null?void 0:a.scrollToIndex)==null||s.call(a,o,"nearest")}}const t=(r=this.shadowRoot)==null?void 0:r.querySelector(this._rowSelector(e));t==null||t.focus()})}_focusFirstVisibleChild(e){const t=this._getVisibleTreeRows(),i=t.findIndex(r=>r.node.id===e);if(i<0)return;const s=t[i].level;for(let r=i+1;r<t.length&&!(t[r].level<=s);r++)if(t[r].level===s+1){this._focusRowById(t[r].node.id);return}}async _handleRowKeyDown(e,t){var d;const i=e.currentTarget;if(e.target!==i)return;const s=this._getVisibleTreeRows(),r=s.findIndex(l=>l.node.id===t.id),o=this._nodeHasChildren(t),a=this._expandedIds.has(t.id);if(e.key==="ArrowDown"||e.key==="ArrowUp"){const l=e.key==="ArrowDown"?r+1:r-1;l>=0&&l<s.length&&(e.preventDefault(),this._focusRowById(s[l].node.id));return}if(e.key==="Home"||e.key==="End"){if(s.length===0)return;e.preventDefault();const l=e.key==="Home"?s[0]:s[s.length-1];this._focusRowById(l.node.id);return}if(e.key==="ArrowRight"){if(!o)return;if(e.preventDefault(),!a){await this._toggleExpand(t,!0);return}this._focusFirstVisibleChild(t.id);return}if(e.key==="ArrowLeft"){if(e.preventDefault(),o&&a){await this._toggleExpand(t,!1),i.focus();return}const l=this._getParentId(t.id);l!==void 0&&this._focusRowById(l);return}if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._enableChildren(i);const l=i.querySelector("nyx-checkbox input, nyx-button:not([disabled])");if(l)if(l instanceof HTMLInputElement)l.focus();else{const c=(d=l.shadowRoot)==null?void 0:d.querySelector("button");c==null||c.focus()}return}e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),this._disableChildren(i),i.focus())}_handleRowFocusOut(e){const t=e.currentTarget;t.contains(e.relatedTarget)||this._disableChildren(t)}_enableChildren(e){const t=e.querySelectorAll('input[slot="input"]'),i=e.querySelectorAll("nyx-button");t.forEach(s=>s.setAttribute("tabindex","0")),i.forEach(s=>s.removeAttribute("tabindex"))}_disableChildren(e){const t=e.querySelectorAll('input[slot="input"]'),i=e.querySelectorAll("nyx-button");t.forEach(s=>s.setAttribute("tabindex","-1")),i.forEach(s=>s.setAttribute("tabindex","-1"))}_clearAllFocus(){var i,s;const e=(i=this.shadowRoot)==null?void 0:i.activeElement;e==null||e.blur();const t=(s=this.shadowRoot)==null?void 0:s.querySelectorAll(".node-row");t==null||t.forEach(r=>{this._disableChildren(r)})}_renderRowSelectionCheckbox(e){return this._showRowSelection()?h.html`
47
+ `:c.nothing}_generateLightDomIcons(){var i;if(this.querySelectorAll("[data-auto-generated]").forEach(s=>s.remove()),!this.options||(this._hasColumnPermissions()&&((i=this.options.columns)==null||i.forEach((s,r)=>{s.icon&&this._createIconElement(s.icon,`generated-header-icon-${r}`)})),this._isLazyEnabled()||!this._showNodeIcons()))return;const t=s=>{var r;s.icon&&this._createIconElement(s.icon,`generated-tree-icon-${s.id}`),(r=s.children)==null||r.forEach(t)};this._items.forEach(t)}_createIconElement(e,t){const i=document.createElement("nyx-icon");let s="regular";typeof e=="string"?i.setAttribute("name",e):(e.name&&i.setAttribute("name",e.name),e.variant&&(s=e.variant),e.src&&i.setAttribute("src",e.src),e.svg&&(i.svg=e.svg)),i.setAttribute("variant",s),i.setAttribute("slot",t),i.setAttribute("data-auto-generated",""),this.appendChild(i)}_expandToLevel(e,t,i){e.forEach(s=>{t<i&&(this._expandedIds.add(s.id),s.children&&this._expandToLevel(s.children,t+1,i))})}_isColumnDisabled(e,t){return!!e.disabledColumns&&e.disabledColumns.includes(t)}_isNodeSelected(e,t){return this._isColumnDisabled(e,t)?!1:(e.selectedColumns||[]).includes(t)}_isIndeterminate(e,t){if(e=this._selectionNode(e),!e.children||e.children.length===0)return!1;const i=this._getFlatDescendants(e),s=i.filter(r=>this._isNodeSelected(r,t)).length;return s>0&&s<i.length}_allDescendantsSelected(e,t){return e=this._selectionNode(e),!e.children||e.children.length===0?this._isNodeSelected(e,t):this._getFlatDescendants(e).every(s=>this._isNodeSelected(s,t))}_getFlatDescendants(e){e=this._selectionNode(e);let t=[];return e.children&&e.children.forEach(i=>{const s=this._selectionNode(i);t.push(s),t=t.concat(this._getFlatDescendants(s))}),t}_requiredClosure(e){var a,l,d;const t=((a=this.options)==null?void 0:a.columns)??[],i=new Map(t.map(h=>[h.id,h])),s=[],r=new Set([e]),o=[...((l=i.get(e))==null?void 0:l.requires)??[]];for(;o.length;){const h=o.pop();r.has(h)||(r.add(h),s.push(h),o.push(...((d=i.get(h))==null?void 0:d.requires)??[]))}return s}_dependentsClosure(e){var o;const t=((o=this.options)==null?void 0:o.columns)??[],i=[],s=new Set([e]),r=[e];for(;r.length;){const a=r.pop();for(const l of t)(l.requires??[]).includes(a)&&!s.has(l.id)&&(s.add(l.id),i.push(l.id),r.push(l.id))}return i}_canEnableColumn(e,t){return this._isColumnDisabled(e,t)?!1:this._requiredClosure(t).every(i=>!this._isColumnDisabled(e,i))}_handleCheck(e,t){const i=this._selectionNode(e);if(this._isColumnDisabled(i,t))return;const r=!this._isNodeSelected(i,t),o=this._requiredClosure(t),a=r?[t,...o]:[t,...this._dependentsClosure(t)];this._forEachInSubtree(this._selectionRoots(),e.id,l=>{r&&o.some(h=>this._isColumnDisabled(l,h))||a.forEach(d=>this._toggleNodeState(l,d,r))}),a.forEach(l=>this._updateParents(this._selectionRoots(),e.id,l)),this._triggerChange()}_toggleNodeState(e,t,i){if(this._isColumnDisabled(e,t))return;e.selectedColumns||(e.selectedColumns=[]);const s=e.selectedColumns.indexOf(t);i&&s===-1?e.selectedColumns.push(t):!i&&s>-1&&e.selectedColumns.splice(s,1)}_updateParents(e,t,i){for(const s of e)if(s.children&&s.children.some(r=>r.id===t||this._updateParents(s.children,t,i))){const r=s.children.every(o=>this._allDescendantsSelected(o,i));return this._toggleNodeState(s,i,r&&this._canEnableColumn(s,i)),!0}return!1}_isRowAllSelected(e){var i;if(e=this._selectionNode(e),!((i=this.options)!=null&&i.columns))return!1;const t=this.options.columns.every(s=>this._isColumnDisabled(e,s.id)?!0:this._isNodeSelected(e,s.id));return e.children&&e.children.length>0?t&&e.children.every(s=>this._isRowAllSelected(s)):t}_isRowIndeterminate(e){var s;if(e=this._selectionNode(e),this._isRowAllSelected(e)||!((s=this.options)!=null&&s.columns))return!1;const t=this.options.columns.some(r=>this._isNodeSelected(e,r.id)),i=e.children?e.children.some(r=>this._isRowAllSelected(r)||this._isRowIndeterminate(r)):!1;return t||i}_isSimpleRowAllSelected(e){var t;return e=this._selectionNode(e),(t=e.children)!=null&&t.length?e.children.every(i=>this._isSimpleRowAllSelected(i)):!!e.selected}_isSimpleRowIndeterminate(e){var s;return e=this._selectionNode(e),this._isSimpleRowAllSelected(e)||!((s=e.children)!=null&&s.length)?!1:this._getFlatDescendants(e).filter(r=>r.selected).length>0}_setSimpleRowSelected(e,t){this._forEachInSubtree(this._selectionRoots(),e,i=>{i.selected=t})}_updateSimpleRowParents(e,t){var i;for(const s of e)if((i=s.children)!=null&&i.some(r=>r.id===t||this._updateSimpleRowParents(s.children,t)))return s.selected=s.children.every(r=>this._isSimpleRowAllSelected(r)),!0;return!1}_isRowCheckboxChecked(e){const t=this._selectionNode(e);return this._usesUniqueRowSelection()?!!t.selected:this._usesSimpleRowSelection()?this._isSimpleRowAllSelected(t):this._isRowAllSelected(t)}_isRowCheckboxIndeterminate(e){if(this._usesUniqueRowSelection())return!1;const t=this._selectionNode(e);return this._usesSimpleRowSelection()?this._isSimpleRowIndeterminate(t):this._isRowIndeterminate(t)}_setUniqueRowSelected(e){let t=!1;const i=s=>{s.forEach(r=>{const o=r.id===e;!!r.selected!==o&&(r.selected=o,t=!0),r.children&&i(r.children)})};return i(this._selectionRoots()),t}_handleRowCheck(e){var s;if(this._usesUniqueRowSelection()){this._setUniqueRowSelected(e.id)&&this._triggerChange();return}const i=!this._isRowCheckboxChecked(e);this._usesSimpleRowSelection()?(this._setSimpleRowSelected(e.id,i),this._updateSimpleRowParents(this._selectionRoots(),e.id)):(this._toggleRowRecursively(e.id,i),(s=this.options)!=null&&s.columns&&this.options.columns.forEach(r=>{this._updateParents(this._selectionRoots(),e.id,r.id)})),this._triggerChange()}_applyRowColumnsToNode(e,t){var i;(i=this.options)!=null&&i.columns&&(t?this.options.columns.forEach(s=>{this._canEnableColumn(e,s.id)&&(e.selectedColumns||(e.selectedColumns=[]),e.selectedColumns.includes(s.id)||e.selectedColumns.push(s.id))}):e.selectedColumns=(e.selectedColumns??[]).filter(s=>this._isColumnDisabled(e,s)))}_toggleRowRecursively(e,t){this._forEachInSubtree(this._selectionRoots(),e,i=>{this._applyRowColumnsToNode(i,t)})}_triggerChange(){if(this._isLazyEnabled()){this._rebuildMaterializedItems(),this._commitLazyRows(),this.onChange({items:this._sourceItems},{bubbles:!0,composed:!0});return}this._items=[...this._items],this._invalidateSearchIndex(),this._searchTerm.trim()&&this._recomputeSearchFilter(),this.onChange({items:this._items},{bubbles:!0,composed:!0})}_handleSearchInput(e){const t=e.target.value,i=this._searchTerm,s=t.trim();if(this._searchDebounceTimer!==null&&(clearTimeout(this._searchDebounceTimer),this._searchDebounceTimer=null),!s&&i.trim()){this._applySearchTerm(t,i);return}this._searchDebounceTimer=setTimeout(()=>{this._searchDebounceTimer=null,this._applySearchTerm(t,i)},te)}_applySearchTerm(e,t){const i=t.trim(),s=e.trim();!i&&s?(this._expandedIdsBeforeSearch=new Set(this._expandedIds),this._searchManualExpandedIds=new Set,this._searchUserCollapsedIds=new Set):i&&!s?(this._searchUserCollapsedIds=new Set,this._searchManualExpandedIds=new Set):i&&s&&i.toLowerCase()!==s.toLowerCase()&&(this._searchUserCollapsedIds=new Set,this._searchManualExpandedIds=new Set),this._searchTerm=e,this._recomputeSearchFilter()}_recomputeSearchFilter(){const e=this._searchTerm.trim();if(!e){this._searchVisibleIds=new Set,this._expandedIdsBeforeSearch&&(this._expandedIds=new Set(this._expandedIdsBeforeSearch),this._expandedIdsBeforeSearch=null),this._isLazyEnabled()?this._commitLazyRows():this._syncActiveRowWithVisibleRows(),this._updateSearchStatusMessage();return}const t=this._ensureSearchIndex(),{visibleIds:i,expandIds:s}=ne(t,e,this._searchUserCollapsedIds),r=new Set(s);this._searchManualExpandedIds.forEach(o=>{this._searchUserCollapsedIds.has(o)||r.add(o)}),this._searchVisibleIds=i,this._expandedIds=r,this._isLazyEnabled()?(W(i,this._loadedIds,this._indexById,this._getLazyPageSize())&&(this._loadedIds=new Set(this._loadedIds),this._rebuildMaterializedItems()),this._commitLazyRows(),this._loadUntilSearchTargetVisible(),this._scrollToSearchTarget()):this._syncActiveRowWithVisibleRows(),this._updateSearchStatusMessage()}_updateSearchStatusMessage(){const e=this._searchTerm.trim();if(!e){this._searchStatusMessage="";return}const t=this._ensureSearchIndex();this._searchStatusMessage=ye(re(t,e))}async _toggleExpand(e,t=!1){if(!(this._isLazyEnabled()?this._sourceHasChildren(e.id):!!(e.children&&e.children.length>0)))return;const s=this._expandedIds.has(e.id);s?(this._expandedIds.delete(e.id),this._searchTerm.trim()&&(this._searchUserCollapsedIds.add(e.id),this._searchUserCollapsedIds=new Set(this._searchUserCollapsedIds),this._searchManualExpandedIds.delete(e.id),this._searchManualExpandedIds=new Set(this._searchManualExpandedIds))):(this._expandedIds.add(e.id),this._searchTerm.trim()&&(this._searchManualExpandedIds.add(e.id),this._searchManualExpandedIds=new Set(this._searchManualExpandedIds),this._searchUserCollapsedIds.delete(e.id),this._searchUserCollapsedIds=new Set(this._searchUserCollapsedIds)),this._isLazyEnabled()&&this._loadSubtreeForExpand(e.id)),this._expandedIds=new Set(this._expandedIds),this._isLazyEnabled()?this._commitLazyRows():this._syncActiveRowWithVisibleRows(),!s&&t&&(await this.updateComplete,this._focusFirstVisibleChild(e.id))}_nodeHasChildren(e){return this._isLazyEnabled()?this._sourceHasChildren(e.id):!!(e.children&&e.children.length>0)}_getVisibleTreeRows(){return this._isLazyEnabled()?this._flatRows:H({items:this._items,expandedIds:this._expandedIds,hasSearch:this._isSearchActive(),searchTerm:this._searchTerm,searchVisibleIds:this._searchVisibleIds,sourceHasChildren:e=>{var t;return!!((t=this._getSourceChildren(e))!=null&&t.length)},getSourceChildren:e=>this._getSourceChildren(e)})}_getParentId(e){var s;if(this._isLazyEnabled()){const r=(s=this._indexById.get(e))==null?void 0:s.parentId;return r??void 0}let t;const i=(r,o)=>{for(const a of r){if(a.id===e)return t=o??void 0,!0;if(a.children&&i(a.children,a.id))return!0}return!1};return i(this._items,null),t}_focusRowById(e){this._setActiveRow(e),this.updateComplete.then(()=>{var i,s,r;if(this._isLazyEnabled()){const o=this._flatRows.findIndex(a=>a.node.id===e);if(o>=0){const a=(i=this.shadowRoot)==null?void 0:i.querySelector("lit-virtualizer");(s=a==null?void 0:a.scrollToIndex)==null||s.call(a,o,"nearest")}}const t=(r=this.shadowRoot)==null?void 0:r.querySelector(this._rowSelector(e));t==null||t.focus()})}_focusFirstVisibleChild(e){const t=this._getVisibleTreeRows(),i=t.findIndex(r=>r.node.id===e);if(i<0)return;const s=t[i].level;for(let r=i+1;r<t.length&&!(t[r].level<=s);r++)if(t[r].level===s+1){this._focusRowById(t[r].node.id);return}}async _handleRowKeyDown(e,t){var l;const i=e.currentTarget;if(e.target!==i)return;const s=this._getVisibleTreeRows(),r=s.findIndex(d=>d.node.id===t.id),o=this._nodeHasChildren(t),a=this._expandedIds.has(t.id);if(e.key==="ArrowDown"||e.key==="ArrowUp"){const d=e.key==="ArrowDown"?r+1:r-1;d>=0&&d<s.length&&(e.preventDefault(),this._focusRowById(s[d].node.id));return}if(e.key==="Home"||e.key==="End"){if(s.length===0)return;e.preventDefault();const d=e.key==="Home"?s[0]:s[s.length-1];this._focusRowById(d.node.id);return}if(e.key==="ArrowRight"){if(!o)return;if(e.preventDefault(),!a){await this._toggleExpand(t,!0);return}this._focusFirstVisibleChild(t.id);return}if(e.key==="ArrowLeft"){if(e.preventDefault(),o&&a){await this._toggleExpand(t,!1),i.focus();return}const d=this._getParentId(t.id);d!==void 0&&this._focusRowById(d);return}if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._enableChildren(i);const d=i.querySelector("nyx-checkbox input, nyx-radio input, nyx-button:not([disabled])");if(d)if(d instanceof HTMLInputElement)d.focus();else{const h=(l=d.shadowRoot)==null?void 0:l.querySelector("button");h==null||h.focus()}return}e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),this._disableChildren(i),i.focus())}_handleRowFocusOut(e){const t=e.currentTarget;t.contains(e.relatedTarget)||this._disableChildren(t)}_enableChildren(e){const t=e.querySelectorAll('input[slot="input"]'),i=e.querySelectorAll("nyx-button");t.forEach(s=>s.setAttribute("tabindex","0")),i.forEach(s=>s.removeAttribute("tabindex"))}_disableChildren(e){const t=e.querySelectorAll('input[slot="input"]'),i=e.querySelectorAll("nyx-button");t.forEach(s=>s.setAttribute("tabindex","-1")),i.forEach(s=>s.setAttribute("tabindex","-1"))}_clearAllFocus(){var i,s;const e=(i=this.shadowRoot)==null?void 0:i.activeElement;e==null||e.blur();const t=(s=this.shadowRoot)==null?void 0:s.querySelectorAll(".node-row");t==null||t.forEach(r=>{this._disableChildren(r)})}_renderRowSelectionCheckbox(e){return this._showRowSelection()?this._usesUniqueRowSelection()?c.html`
48
+ <div class="row-checkbox">
49
+ <nyx-radio
50
+ ?checked=${this._isRowCheckboxChecked(e)}
51
+ @click=${t=>{t.stopPropagation(),this._handleRowCheck(e)}}
52
+ >
53
+ <input
54
+ type="radio"
55
+ slot="input"
56
+ tabindex="-1"
57
+ name=${this._rowSelectionRadioName}
58
+ .checked=${this._isRowCheckboxChecked(e)}
59
+ aria-label=${j(e.label)}
60
+ />
61
+ </nyx-radio>
62
+ </div>
63
+ `:c.html`
48
64
  <div class="row-checkbox">
49
65
  <nyx-checkbox
50
- aria-label=${ve(e.label)}
66
+ aria-label=${j(e.label)}
51
67
  ?checked=${this._isRowCheckboxChecked(e)}
52
68
  ?indeterminate=${this._isRowCheckboxIndeterminate(e)}
53
69
  @click=${t=>{t.stopPropagation(),this._handleRowCheck(e)}}
@@ -55,16 +71,16 @@
55
71
  <input type="checkbox" slot="input" tabindex="-1" />
56
72
  </nyx-checkbox>
57
73
  </div>
58
- `:h.nothing}_renderNodeIconCell(e){return this._showNodeIcons()?h.html`
74
+ `:c.nothing}_renderNodeIconCell(e){return this._showNodeIcons()?c.html`
59
75
  <div class="node-type-icon-wrapper">
60
- ${this._isLazyEnabled()?this._renderNodeTypeIcon(e):h.html`<slot name="generated-tree-icon-${e.id}"></slot>`}
76
+ ${this._isLazyEnabled()?this._renderNodeTypeIcon(e):c.html`<slot name="generated-tree-icon-${e.id}"></slot>`}
61
77
  </div>
62
- `:h.nothing}_renderColumnCheckboxes(e){return this._hasColumnPermissions()?h.html`
78
+ `:c.nothing}_renderColumnCheckboxes(e){return this._hasColumnPermissions()?c.html`
63
79
  <div class="node-columns">
64
- ${this.options.columns.map(t=>h.html`
80
+ ${this.options.columns.map(t=>c.html`
65
81
  <div class="col-cell">
66
82
  <nyx-checkbox
67
- aria-label=${me(t.title||`Column ${t.id}`,e.label)}
83
+ aria-label=${ge(t.title||`Column ${t.id}`,e.label)}
68
84
  ?checked=${this._allDescendantsSelected(this._selectionNode(e),t.id)}
69
85
  ?indeterminate=${this._isIndeterminate(this._selectionNode(e),t.id)}
70
86
  ?disabled=${this._isColumnDisabled(this._selectionNode(e),t.id)}
@@ -75,7 +91,7 @@
75
91
  </div>
76
92
  `)}
77
93
  </div>
78
- `:h.nothing}render(){var i,s,r;const e=this._hasColumnPermissions(),t=e?((s=(i=this.options)==null?void 0:i.columns)==null?void 0:s.length)??0:0;return h.html`
94
+ `:c.nothing}render(){var i,s,r;const e=this._hasColumnPermissions(),t=e?((s=(i=this.options)==null?void 0:i.columns)==null?void 0:s.length)??0:0;return c.html`
79
95
  <div
80
96
  class=${b.classMap({"nyx-treeview":!0,"nyx-treeview--no-columns":!e,"nyx-treeview--row-selection":this._showRowSelection(),"nyx-treeview--virtual":this._isLazyEnabled()})}
81
97
  style=${`--treeview-column-count: ${t};`}
@@ -108,15 +124,15 @@
108
124
  class=${b.classMap({"tree-header":!0,"tree-header--no-columns":!e})}
109
125
  >
110
126
  <div class="tree-title">${(r=this.options)==null?void 0:r.title}</div>
111
- ${e?h.html`
127
+ ${e?c.html`
112
128
  <div class="header-columns">
113
- ${this.options.columns.map((o,a)=>h.html`
129
+ ${this.options.columns.map((o,a)=>c.html`
114
130
  <div class="col-cell" title="${o.title||""}">
115
131
  <slot name="generated-header-icon-${a}"></slot>
116
132
  </div>
117
133
  `)}
118
134
  </div>
119
- `:h.nothing}
135
+ `:c.nothing}
120
136
  </div>
121
137
 
122
138
  <div
@@ -124,7 +140,7 @@
124
140
  role="tree"
125
141
  aria-label=${this._getTreeAriaLabel()}
126
142
  >
127
- ${this._isLazyEnabled()?h.html`
143
+ ${this._isLazyEnabled()?c.html`
128
144
  <lit-virtualizer
129
145
  scroller
130
146
  class="tree-virtualizer"
@@ -137,15 +153,15 @@
137
153
  </div>
138
154
  </div>
139
155
  </div>
140
- `}_renderFlatRow(e){const{node:t,level:i,revealSubtree:s,parentLabelMatched:r}=e,o=this._expandedIds.has(t.id),a=e.hasChildrenInSource,d=this._showRowSelection(),l=this._isRowCheckboxChecked(t)||this._isRowCheckboxIndeterminate(t);return h.html`
156
+ `}_renderFlatRow(e){const{node:t,level:i,revealSubtree:s,parentLabelMatched:r}=e,o=this._expandedIds.has(t.id),a=e.hasChildrenInSource,l=this._showRowSelection(),d=this._isRowCheckboxChecked(t)||this._isRowCheckboxIndeterminate(t);return c.html`
141
157
  <div class="node-wrapper node-wrapper--flat">
142
- ${this._renderTreeRow(t,i,{isExpanded:o,hasChildren:a,isRowHighlighted:l,isSelectable:d})}
158
+ ${this._renderTreeRow(t,i,{isExpanded:o,hasChildren:a,isRowHighlighted:d,isSelectable:l})}
143
159
  </div>
144
- `}_renderNodes(e,t,i=!1,s=!1,r=!1){const o=!!this._searchTerm.trim(),a=this._searchTerm.trim().toLowerCase(),d=o&&!r?e.filter(l=>this._searchVisibleIds.has(l.id)):e;return Z.repeat(d,l=>l.id,l=>{const c=this._expandedIds.has(l.id),v=this._isLazyEnabled()?this._sourceHasChildren(l.id):!!(l.children&&l.children.length>0),w=this._isRowCheckboxChecked(l)||this._isRowCheckboxIndeterminate(l),m=this._showRowSelection(),A=V(l.label,a,i,s),W=!o||A&&R(l.label,a,s,l.id,this._searchVisibleIds,$=>this._getSourceChildren($))?l.children:N(l,this._searchVisibleIds,a),I=s||o&&!!a&&l.label.toLowerCase().includes(a);return h.html`
160
+ `}_renderNodes(e,t,i=!1,s=!1,r=!1){const o=!!this._searchTerm.trim(),a=this._searchTerm.trim().toLowerCase(),l=o&&!r?e.filter(d=>this._searchVisibleIds.has(d.id)):e;return J.repeat(l,d=>d.id,d=>{const h=this._expandedIds.has(d.id),m=this._isLazyEnabled()?this._sourceHasChildren(d.id):!!(d.children&&d.children.length>0),w=this._isRowCheckboxChecked(d)||this._isRowCheckboxIndeterminate(d),x=this._showRowSelection(),$=P(d.label,a,i,s),Z=!o||$&&z(d.label,a,s,d.id,this._searchVisibleIds,A=>this._getSourceChildren(A))?d.children:N(d,this._searchVisibleIds,a),S=s||o&&!!a&&d.label.toLowerCase().includes(a);return c.html`
145
161
  <div class="node-wrapper">
146
- ${this._renderTreeRow(l,t,{isExpanded:c,hasChildren:v,isRowHighlighted:w,isSelectable:m})}
147
- ${c&&v?h.html`<div class="node-children" role="group">
148
- ${this._renderNodes(W,t+1,A,I,!0)}
162
+ ${this._renderTreeRow(d,t,{isExpanded:h,hasChildren:m,isRowHighlighted:w,isSelectable:x})}
163
+ ${h&&m?c.html`<div class="node-children" role="group">
164
+ ${this._renderNodes(Z,t+1,$,S,!0)}
149
165
  </div>`:""}
150
166
  </div>
151
- `})}};T.styles=h.unsafeCSS(Y);let u=T;f([p.property({type:Object,noAccessor:!0})],u.prototype,"options",1),f([p.state()],u.prototype,"_items",2),f([p.state()],u.prototype,"_expandedIds",2),f([p.state()],u.prototype,"_searchTerm",2),f([p.state()],u.prototype,"_searchStatusMessage",2),f([p.state()],u.prototype,"_searchVisibleIds",2),f([p.state()],u.prototype,"_searchUserCollapsedIds",2),f([p.state()],u.prototype,"_searchManualExpandedIds",2),f([p.state()],u.prototype,"_flatRows",2),f([p.state()],u.prototype,"_loadedIds",2),f([p.state()],u.prototype,"_activeRowId",2),f([K("nyx-change")],u.prototype,"onChange",2),customElements.get("nyx-treeview")||customElements.define("nyx-treeview",u),_.NyxTreeview=u,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})}));
167
+ `})}},v._nextTreeviewId=0,v.styles=c.unsafeCSS(ee),v);f([_.property({type:Object,noAccessor:!0})],u.prototype,"options",1),f([_.state()],u.prototype,"_items",2),f([_.state()],u.prototype,"_expandedIds",2),f([_.state()],u.prototype,"_searchTerm",2),f([_.state()],u.prototype,"_searchStatusMessage",2),f([_.state()],u.prototype,"_searchVisibleIds",2),f([_.state()],u.prototype,"_searchUserCollapsedIds",2),f([_.state()],u.prototype,"_searchManualExpandedIds",2),f([_.state()],u.prototype,"_flatRows",2),f([_.state()],u.prototype,"_loadedIds",2),f([_.state()],u.prototype,"_activeRowId",2),f([X("nyx-change")],u.prototype,"onChange",2);let G=u;customElements.get("nyx-treeview")||customElements.define("nyx-treeview",G),p.NyxTreeview=G,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nyx-ds/treeview",
3
3
  "private": false,
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "type": "module",
6
6
  "main": "dist/treeview.js",
7
7
  "module": "dist/treeview.js",
@@ -24,6 +24,7 @@
24
24
  "@nyx-ds/core": "^0.1.11",
25
25
  "@nyx-ds/icon": "^0.1.1",
26
26
  "@nyx-ds/input": "^0.1.6",
27
+ "@nyx-ds/radio": "^0.1.4",
27
28
  "lit": "3.2.1",
28
29
  "lit-html": "3.2.1"
29
30
  },
@@ -34,8 +35,9 @@
34
35
  "@nyx-ds/core": "^0.1.11",
35
36
  "@nyx-ds/icon": "^0.1.1",
36
37
  "@nyx-ds/input": "^0.1.6",
38
+ "@nyx-ds/radio": "^0.1.4",
37
39
  "lit": "3.2.1",
38
40
  "lit-html": "3.2.1"
39
41
  },
40
- "gitHead": "220195d9298a9c57fe26f7501b79d1b1e12ecdee"
42
+ "gitHead": "829b491ff3b0f059379f4bfd48f076720d84a9a9"
41
43
  }