@openremote/or-tree-menu 1.24.1 → 1.24.2
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/dist/umd/index.bundle.js
CHANGED
|
@@ -726,10 +726,10 @@
|
|
|
726
726
|
${this._getSortActionTemplate(this.sortBy,this.sortOptions)}
|
|
727
727
|
</div>
|
|
728
728
|
</div>
|
|
729
|
-
`}_getSortActionTemplate(t,e){return function(t,e,n,i,r,a=!
|
|
729
|
+
`}_getSortActionTemplate(t,e){return function(t,e,n,i,r=!1,a=!0,o=!1,l=!1,d="menu",c=!1){let s=null;return j`
|
|
730
730
|
<span>
|
|
731
|
-
<span @click="${t=>{if(e){if(s
|
|
732
|
-
${e?j`<or-mwc-menu ?multiselect="${
|
|
731
|
+
<span @click="${t=>{if(e){if(c&&s){var n,i;let e,r=t.currentTarget;n=s,(i=r)||(i=document.body),e=i.getBoundingClientRect(),Object.assign(n.style,{position:"fixed",top:`${e.bottom}px`,left:`${e.left}px`,zIndex:"1000",display:"block"})}t.currentTarget.parentElement.lastElementChild.open()}}}">${t}</span>
|
|
732
|
+
${e?j`<or-mwc-menu ?multiselect="${r}" @or-mwc-menu-closed="${()=>{}}" @or-mwc-menu-changed="${t=>{i&&i(t.detail)}}" .translateValues="${a}" .values="${n}" .menuItems="${e}" .midHeight="${o}" .fullWidth="${l}" id="${d}" ${tN(t=>s=t)}></or-mwc-menu>`:""}
|
|
733
733
|
</span>
|
|
734
734
|
`}(j`<or-mwc-input type=${t2.BUTTON} icon="sort-variant" title="${is.i18next.t("sort")}"></or-mwc-input>`,(e||[]).map(t=>({value:t,text:t})),t,t=>this._onSortClick(String(t)))}_getErrorTemplate(){return j``}_onSortClick(t){this.sortBy=t}_onTreeGroupClick(t){let e=t.currentTarget,n=e.parentElement,i=(t,e)=>{t.select(),this._lastSelectedNode=e,this._notifyNodesSelect()};switch(this.selection){case t5.LEAF:return;case t5.MULTI:if(t.shiftKey&&this._lastSelectedNode){let t=Array.from(this._uiNodes||[]),e=n.getGroupNode();if(e){let n=t.indexOf(e),i=t.indexOf(this._lastSelectedNode);this._selectNodesBetween(t,n,i);return}}else if(t.ctrlKey)return void i(n,e);this.deselectAllNodes(),i(n,e);return;case t5.SINGLE:this.deselectAllNodes(),i(n,e);return}}_onTreeNodeClick(t){let e=t.currentTarget;if(e)if(this.selection===t5.MULTI){if(t.shiftKey&&this._lastSelectedNode){let t=Array.from(this._uiNodes||[]),n=t.indexOf(this._lastSelectedNode),i=t.indexOf(e);if(n>-1&&i>-1)return void this._selectNodesBetween(t,n,i)}else if(t.ctrlKey)return void this._selectNode(e);this.deselectAllNodes(),this._selectNode(e);return}else{this.deselectAllNodes(),this._selectNode(e);return}}_onDragStart(t,e){var n;t.target?null==(n=t.dataTransfer)||n.setData("treeNode",JSON.stringify(e)):t.preventDefault()}_onDragOverList(t){this.draggable&&t.preventDefault()}_onDragOverSingleNode(t,e,n){if(this.draggable&&(t.preventDefault(),n)){let t=this._getUiNodeFromTree(n);null==t||t.setAttribute("drophover","true")}}_onDragOverGroup(t,e){this.draggable&&(t.preventDefault(),t.currentTarget.setAttribute("drophover","true"))}_onDragLeaveSingleNode(t,e,n){if(n&&this.draggable){t.preventDefault();let e=this._getUiNodeFromTree(n);null==e||e.removeAttribute("drophover")}}_onDragLeaveGroup(t,e){this.draggable&&t.currentTarget.removeAttribute("drophover")}_onDragDropList(t){this._onDragDropGroup(t)}_onDragDropSingleNode(t,e,n){this._onDragDropGroup(t,n)}_onDragDropGroup(t,e){var n,i;if(this.draggable){t.preventDefault(),t.stopPropagation(),e&&(null==(n=this._getUiNodeFromTree(e))||n.removeAttribute("drophover"));let r=[],a=null==(i=t.dataTransfer)?void 0:i.getData("treeNode");if(a){let t=JSON.parse(a);t&&r.push(t)}if(this.selection===t5.MULTI){let t=this._findSelectedTreeNodes();(t=t.filter(t=>!t.children)).length>0&&(this.deselectAllNodes(),r.push(...t.filter(t=>!r.find(e=>JSON.stringify(e)===JSON.stringify(t)))))}(null==e?void 0:e.children)&&(r=r.filter(t=>{var n;return!(null==(n=e.children)?void 0:n.find(e=>e.id===t.id))})),r.length>0&&this._dispatchCancellableDragEvent(r,e,this.nodes).then(()=>{this.nodes=iK(r,e,this.nodes)}).catch(t=>{})}}_dispatchCancellableDragEvent(t,e,n=[]){return new Promise((i,r)=>{this.dispatchEvent(new iJ(t,e,n))?i():r()})}_selectNode(t,e=!0){if(t){if(e){let e=[...this._findSelectedTreeNodes()],n=this._getTreeNodeFromTree(t);if(n&&e.push(n),!this._dispatchSelectEvent(e))return}t.selected=!0,this._lastSelectedNode=t}}_selectNodesBetween(t,e,n,i=!0){let r=[];if(e<n)for(let i=e;i<=n;i++)r.push(t[i]);else if(e>n)for(let i=n;i<=e;i++)r.push(t[i]);if(i){let t=r.map(t=>this._getTreeNodeFromTree(t)).filter(t=>t);if(!this._notifyNodesSelect(t))return}r.forEach(t=>this._selectNode(t))}_notifyNodesSelect(t){var e,n,i,r;return e=this,n=void 0,i=void 0,r=function*(){return yield this.getUpdateComplete(),t||(t=this._findSelectedTreeNodes()),this._dispatchSelectEvent(t)},new(i||(i=Promise))(function(t,a){function o(t){try{d(r.next(t))}catch(t){a(t)}}function l(t){try{d(r.throw(t))}catch(t){a(t)}}function d(e){var n;e.done?t(e.value):((n=e.value)instanceof i?n:new i(function(t){t(n)})).then(o,l)}d((r=r.apply(e,n||[])).next())})}_findSelectedTreeNodes(t=Array.from(this._uiNodes||[]),e=this._treeNodeCache){let n=t.filter(t=>t.selected),i=Array.from(e.entries());return n.map(t=>i.find(e=>e[1]===t.id)).map(t=>null==t?void 0:t[0]).filter(t=>void 0!==t)}_getTreeNodeFromTree(t,e=this._treeNodeCache){var n;return null==(n=Array.from(e.entries()).find(e=>e[1]===t.id))?void 0:n[0]}_getUiNodeFromTree(t,e=this._treeNodeCache){var n;let i=Array.from(e.entries()),r=JSON.stringify(t),a=null==(n=i.find(t=>JSON.stringify(t[0])===r))?void 0:n[1];return a?this.shadowRoot.getElementById(a):void 0}_dispatchSelectEvent(t){return this.dispatchEvent(new iW(t||[]))}deselectAllNodes(){(this._uiGroups||[]).forEach(t=>t.deselect()),(this._uiNodes||[]).forEach(t=>t.selected=!1)}_sortNodes(t,e,n=!1){console.debug(`Sorting nodes in the tree menu using '${e}'`);let i=t.filter(t=>void 0!==t.children);if(i.forEach(t=>{var n;return null==(n=t.children)?void 0:n.sort(this._getSortFunction(e))}),n){let n=t.filter(t=>void 0===t.children);return i.sort(this._getSortFunction(e)),n.sort(this._getSortFunction(e)),[...i,...n]}return t.sort(this._getSortFunction(e))}_setTreeNodeId(t,e=io.Util.generateUniqueUUID()){return this._treeNodeCache.get(t)?this._treeNodeCache.get(t):(this._treeNodeCache.set(t,e),e)}_getSortFunction(t){return t===t4.Z_TO_A?(t,e)=>e.label.localeCompare(t.label):io.Util.sortByString(t=>t.label)}expandGroup(t){this.updateComplete.then(()=>{let e=this.nodes.find(e=>e.id===t&&e.children);e&&(e.expanded=!0,this.requestUpdate())})}};i5([tf({type:Array})],i3.prototype,"nodes",void 0),i5([tf({type:String})],i3.prototype,"selection",void 0),i5([tf({type:Boolean})],i3.prototype,"draggable",void 0),i5([tf({type:Boolean,attribute:"no-header"})],i3.prototype,"noHeader",void 0),i5([tf({type:String,attribute:"menu-title"})],i3.prototype,"menuTitle",void 0),i5([tf({type:Array,attribute:"sort-options"})],i3.prototype,"sortOptions",void 0),i5([tf({type:String,attribute:"sort-by",reflect:!0})],i3.prototype,"sortBy",void 0),i5([tf({type:Boolean,attribute:"group-first"})],i3.prototype,"groupFirst",void 0),i5([tv("or-tree-node")],i3.prototype,"_uiNodes",void 0),i5([tv("or-tree-group")],i3.prototype,"_uiGroups",void 0),i3=i5([tp("or-tree-menu")],i3)})(),o})());
|
|
735
735
|
//# sourceMappingURL=index.bundle.js.map
|