-
Notifications
You must be signed in to change notification settings - Fork 0
/
chunk-IB43PNHG.js
1 lines (1 loc) · 3.33 KB
/
chunk-IB43PNHG.js
1
import{o as s}from"./chunk-2UOGX6KS.js";import"./chunk-FB7CDEED.js";import{$a as o,Oa as g,Pa as f,V as d,Wa as v,Xa as C,Ya as T,Za as m,_a as u,db as h,mb as M,pb as D,ya as c,yb as l}from"./chunk-XIWENJHJ.js";import"./chunk-BL3FZZIZ.js";function b(i,n){if(i&1&&o(0,"drag-tree",2),i&2){let S=n.$implicit;f("node",S)}}var _=(()=>{let n=class n{constructor(){this.node={}}dragStart(e){console.log("dragStart - start"),e.dataTransfer.setData("text/plain",this.node.id),e.stopPropagation(),console.log("dragStart - end")}};n.\u0275fac=function(t){return new(t||n)},n.\u0275cmp=d({type:n,selectors:[["drag-tree"]],inputs:{node:"node"},standalone:!0,features:[l],decls:5,vars:3,consts:[["draggable","true",1,"shadow",3,"dragstart"],[1,"subtree"],[3,"node"]],template:function(t,r){t&1&&(m(0,"div",0),h("dragstart",function(a){return r.dragStart(a)}),M(1),u(),m(2,"div",1),C(3,b,1,1,"drag-tree",2,v),u()),t&2&&(g("data-id",r.node.id),c(),D("",r.node.name," (",r.node.id,")"),c(2),T(r.node.children))},dependencies:[n,s],styles:["div[_ngcontent-%COMP%]{margin-left:15px;transition:margin-left .2s ease-out}div[draggable=true][_ngcontent-%COMP%]{cursor:move}div[draggable=true][_ngcontent-%COMP%]:active{opacity:.5}"]});let i=n;return i})();var F=(()=>{let n=class n{constructor(){this.node={},this.tree=this.generateTree(),this.nodesMap=this.createNodesMap(this.tree),this.setParents(this.tree)}generateTree(){var e={id:"1",name:"Root",parent:null,children:[{id:"2",name:"Child 1",parent:null,children:[{id:"3",parent:null,name:"Child 1.1",children:[{id:"5",parent:null,name:"Child 1.1.1",children:[]},{id:"6",parent:null,name:"Child 1.1.2",children:[]}]},{id:"4",parent:null,name:"Child 1.2",children:[]}]},{id:"7",parent:null,name:"Child 2",children:[{id:"8",parent:null,name:"Child 2.1",children:[]},{id:"9",parent:null,name:"Child 2.2",children:[{id:"10",parent:null,name:"Child 2.2.1",children:[]}]}]}]};return e}createNodesMap(e,t={}){return t[e.id]=e,e.children.forEach(r=>this.createNodesMap(r,t)),t}setParents(e,t=null){e.parent=t,e.children.forEach(r=>this.setParents(r,e))}dragOver(e){e.preventDefault()}drop(e){if(e.preventDefault(),!e.dataTransfer)return;let t=e.dataTransfer.getData("text/plain"),r=this.nodesMap[t];if(!r)return;let p=e.target.getAttribute("data-id");if(!p)return;let a=this.nodesMap[p];a.id!==r.id&&this.moveNode(r,a)}moveNode(e,t){if(e.parent){let r=e.parent.children.indexOf(e);r!==-1&&(e.parent.children=[...e.parent.children.slice(0,r),...e.parent.children.slice(r+1)])}t.children=[...t.children,e],e.parent=t,this.print(this.tree,"")}print(e,t){console.log(`${t}id:${e.id}:${e.name}`);for(let r of e.children)this.print(r,t+" ")}};n.\u0275fac=function(t){return new(t||n)},n.\u0275cmp=d({type:n,selectors:[["drag-trees"]],inputs:{node:"node"},standalone:!0,features:[l],decls:2,vars:1,consts:[[1,"full-width","full-height","scrollable",3,"dragover","drop"],[3,"node"]],template:function(t,r){t&1&&(m(0,"div",0),h("dragover",function(a){return r.dragOver(a)})("drop",function(a){return r.drop(a)}),o(1,"drag-tree",1),u()),t&2&&(c(),f("node",r.tree))},dependencies:[s,_]});let i=n;return i})();var R=(()=>{let n=class n{};n.\u0275fac=function(t){return new(t||n)},n.\u0275cmp=d({type:n,selectors:[["test-four-page"]],standalone:!0,features:[l],decls:1,vars:0,template:function(t,r){t&1&&o(0,"drag-trees")},dependencies:[s,F]});let i=n;return i})();export{R as TestFourPage};