@stratusjs/angular 0.9.2 → 0.10.0

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 +1 @@
1
- System.register(["@angular/core","@angular/cdk/drag-drop","@angular/cdk/tree","@angular/platform-browser","@angular/material/icon","rxjs","@stratusjs/runtime/stratus","lodash","@agentepsilon/decko","../core/root.component","../backend.service","@stratusjs/angularjs/services/registry","@stratusjs/core/events/eventManager","@stratusjs/core/environment","@stratusjs/core/misc","@angular/common"],function(e,t){"use strict";var i,s,r,o,n,a,d,c,l,h,p,u,g,f,m,y,D,v,b,S,I=this&&this.__decorate||function(e,t,i,s){var r,o=arguments.length,n=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(n=(o<3?r(n):o>3?r(t,i,n):r(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n},M=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},$=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};t&&t.id;return{setters:[function(e){i=e},function(e){s=e},function(e){r=e},function(e){o=e},function(e){n=e},function(e){a=e},function(e){d=e},function(e){c=e},function(e){l=e},function(e){h=e},function(e){p=e},function(e){u=e},function(e){g=e},function(e){f=e},function(e){m=e},function(e){y=e}],execute:function(){"@stratusjs/angular",D="tree",v=f.cookie("env")?"":".min",b=`${d.Stratus.BaseUrl}${boot.configuration.paths["@stratusjs/angular/*"].replace(/[^/]*$/,"").replace(/\/dist\/$/,"/src/")}`,S=class extends h.RootComponent{constructor(e,t,i,s,o,n){super(),this.iconRegistry=e,this.sanitizer=t,this.backend=i,this.ref=s,this.elementRef=o,this.document=n,this.title=D+"_component",this.isInitialized=!1,this.isDestroyed=!1,this.isStyled=!1,this._=c.default,this.Stratus=d.Stratus,this.registry=new u.Registry,this.onChange=new a.Subject,this.unsettled=!1,this.svgIcons={},this.dblClickWait=500,this.dropLists=[],this.dropListIdMap={},this.dropListMap={},this.expandedNodeSet=new Set,this.dragging=!1,this.expandDelay=1e3,this.dropData=null,this.cdkDropListSortingDisabled=!0,this.treeControl=new r.NestedTreeControl(e=>e.children||[]),this.isBorder=!1,this.isDebug=!1}ngOnInit(){this.uid=c.default.uniqueId(`sa_${c.default.snakeCase(D)}_component_`),d.Stratus.Instances[this.uid]=this,this.hydrate(this.elementRef,this.sanitizer,["title","uid","isInitialized","isDestroyed","isStyled","target","targetSuffix","id","manifest","decouple","direct","api","urlRoot","type","property","_","Stratus","registry","fetched","data","collection","model","dataSub","onChange","subscriber","unsettled","svgIcons","isSingleClick","dblClickWait","dropLists","dropListIdMap","dropListMap","expandedNodeSet","dragging","expandTimeout","expandDelay","dropData","cdkDropListSortingDisabled","tree","treeMap","metaMap","dataSource","treeControl","isBorder","isDebug","iconRegistry","sanitizer","backend","ref","elementRef","document","ngOnInit","ngOnDestroy","refresh","remove","removeNode","nodeIsEqual","fetchData","dataDefer","dataRef","trackDropLists","setExpanded","setExpandedClick","setExpandedDblClick","onDragDrop","onDragMove","showDragData","clearDragData","buildNodePatch","getSvg","addSvgIcon","hydrate","disableRefresh","stagger","reloading"]),d.Stratus.Internals.CssLoader(`${b}/${D}/${D}.component${v}.css`).then(()=>{this.isStyled=!0,this.refresh()}).catch(e=>{console.warn("Issue detected in CSS Loader for Component:",this),console.error(e),this.isStyled=!0,this.refresh()}),c.default.forEach({tree_check:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/check.svg`,tree_add:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/add.svg`,tree_delete:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/delete.svg`,tree_edit:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/edit.svg`,tree_visibility:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/visibility.svg`},(e,t)=>this.iconRegistry.addSvgIcon(t,this.sanitizer.bypassSecurityTrustResourceUrl(e)).getNamedSvgIcon(t)),this.fetchData().then(e=>{if(!(e&&e instanceof g.EventManager))return void console.warn("Unable to bind data from Registry!");const t=()=>{!this.unsettled&&e.completed&&(this.dataDefer(this.subscriber),this.refresh())};e.on("change",t),t(),e.on("add",(e,t)=>{let i=!1;const s=()=>{if(!t.completed)return;if(i)return;if(i=!0,!(t.getIdentifier()in this.treeMap))return void t.meta.set("postPersist",!0);const e=this.treeMap[t.getIdentifier()];e.meta.component&&"openDialog"in e.meta.component?e.meta.component.openDialog():t.meta.set("postPersist",!0)};t.on("change",s),s()})}),this.dataSub=new a.Observable(e=>this.dataDefer(e)),this.dropListIdMap[`${this.uid}_parent_drop_list`]=!0,this.trackDropLists();const e=f.cookie("tree-node-border");e&&m.isJSON(e)&&(this.isBorder=JSON.parse(e));const t=f.cookie("tree-debug");t&&m.isJSON(t)&&(this.isDebug=JSON.parse(t)),this.isInitialized=!0,this.refresh()}ngOnDestroy(){this.isDestroyed=!0}refresh(){return this.isDestroyed?new Promise(e=>e()):(c.default.forEach(this.metaMap,e=>{e.component&&"refresh"in e.component&&e.component.refresh()}),super.refresh())}remove(e){}removeNode(e,t){const i=e.indexOf(t);return-1!==i&&(e.splice(i,1),!0)}nodeIsEqual(e,t){return e&&t?e.id===t.id:e===t}async fetchData(){return this.fetched?this.fetched:this.fetched=this.registry.fetch(d.Stratus.Select(this.elementRef.nativeElement),this)}dataDefer(e){if(this.subscriber=this.subscriber||e,!this.subscriber||!this.collection||!this.collection.completed)return void setTimeout(()=>{this.dataDefer(e)},500);const t=this.dataRef(!0);t&&t.length?e.next(t):setTimeout(()=>this.dataDefer(e),200)}dataRef(e=!1){if(!this.collection)return[];if(!e&&this.tree&&this.tree.length>0)return this.tree;let t=this.collection.models;return t&&c.default.isArray(t)&&t.length?(t=c.default.sortBy(t,["data.priority"]),this.metaMap=this.metaMap||{},this.treeMap={},this.tree=[],c.default.forEach(t,e=>{const t=c.default.get(e,"data.id"),i=c.default.get(e,"data.nestParent.id");this.dropListIdMap[`${this.uid}_node_${t}_drop_list`]=!0,c.default.has(this.metaMap,t)||(this.metaMap[t]={id:t,expanded:!0}),c.default.has(this.treeMap,t)||(this.treeMap[t]={id:t,model:e,children:[],meta:this.metaMap[t]}),this.treeMap[t].model=e,this.treeMap[t].meta=this.metaMap[t],i?(c.default.has(this.treeMap,i)||(this.treeMap[i]={id:i,model:null,children:[],meta:null}),this.treeMap[i].children.push(this.treeMap[t])):this.tree.push(this.treeMap[t])}),this.trackDropLists(),this.tree):[]}trackDropLists(){this.dropLists=[],c.default.forEach(this.dropListIdMap,(e,t)=>{if(!e)return;const i=t in this.dropListMap,s=i?this.dropListMap[t]:document.getElementById(t);s&&(this.dropLists.push(t),i||(this.dropListMap[t]=s))})}setExpanded(e){this.metaMap&&c.default.size(this.metaMap)&&(c.default.forEach(this.metaMap,t=>{t.expanded=e}),this.refresh())}setExpandedClick(e){this.isSingleClick=!0,setTimeout(()=>{this.isSingleClick&&this.setExpanded(e)},this.dblClickWait)}setExpandedDblClick(e){this.isSingleClick=!1,this.setExpanded(e)}async onDragDrop(e){if(!e.isPointerOverContainer)return;const t=e.item.data;if(!t)return;let i=e.container.data;const r=e.previousContainer.data,o=i?i.children:this.dataRef();if(!o)return;this.unsettled=!0;const n=this.dropData.targetId&&this.dropData.targetId in this.treeMap?this.treeMap[c.default.toNumber(this.dropData.targetId)]:null;if(f.cookie("env")&&this.isDebug&&(console.group("onDragDrop()"),c.default.forEach([`model drop: ${t.model.get("name")}`,`list shift: ${e.container.element.nativeElement.id} -> ${e.previousContainer.element.nativeElement.id}`,`index change (event): ${e.previousIndex} -> ${e.currentIndex}`,`current priority: ${t.model.get("priority")}`,`target drop action: ${this.dropData.action}`],e=>console.log(e))),n&&!this.nodeIsEqual(i,n)){if(f.cookie("env")&&this.isDebug&&(console.log(`target drop node differs: ${n.id} -> ${n.model.get("name")}`),console.log("target drop node is the same as target node:",t.id===n.id)),t.id!==n.id)switch(this.dropData.action){case"before":case"after":const e=n.model.get("nestParent.id");i=e&&e in this.treeMap?this.treeMap[e]:null;break;case"inside":i=n}f.cookie("env")&&this.isDebug&&console.log("target drop node selected:",i?`${i.id} -> ${i.model.get("name")}`:"none")}if(!this.nodeIsEqual(i,r)){if(i){switch(this.dropData.action){case"before":case"after":let e=i.children.findIndex(e=>e.id===t.id);"after"===this.dropData.action&&e++,i.children.splice(e,0,t);break;case"inside":i.children.push(t)}i.meta.expanded=!0}r&&this.removeNode(r.children,t),t.model.set("nestParent",this.buildNodePatch(i)),f.cookie("env")&&this.isDebug&&console.log(`new parent: ${t.model.get("nestParent.name")||null}`)}const a=i?i.children:o;let d=e.currentIndex;if(this.cdkDropListSortingDisabled)switch(d=null,this.dropData.action){case"before":case"after":d=a.findIndex(e=>e.id===n.id),"after"===this.dropData.action&&d++,f.cookie("env")&&this.isDebug&&console.log("index change (drop node):",`${e.previousIndex} -> ${d}`)}if(c.default.isNumber(d)){s.moveItemInArray(a,e.previousIndex,d);let i=0;c.default.forEach(a,e=>{e.model&&e.model.set&&e.model.set("priority",i++)}),f.cookie("env")&&this.isDebug&&console.log("new priority:",t.model.get("priority"))}f.cookie("env")&&this.isDebug&&console.groupEnd(),await t.model.save(),this.unsettled=!1,this.collection.throttleTrigger("change")}onDragMove(e){const t=this.document.elementFromPoint(e.pointerPosition.x,e.pointerPosition.y);if(!t)return void this.clearDragData();const i="tree-node-content",s=t.classList.contains(i)?t:t.closest(`.${i}`);if(!s)return void this.clearDragData();this.dropData={targetId:s.getAttribute("data-id")};const r=s.getBoundingClientRect(),o=r.height/3;e.pointerPosition.y-r.top<o?this.dropData.action="before":e.pointerPosition.y-r.top>2*o?this.dropData.action="after":this.dropData.action="inside",this.showDragData()}showDragData(){this.clearDragData(),this.dropData&&this.document.getElementById(`node-${this.dropData.targetId}`).classList.add(`drop-${this.dropData.action}`)}clearDragData(e=!1){e&&(this.dropData=null),this.document.querySelectorAll(".drop-before").forEach(e=>e.classList.remove("drop-before")),this.document.querySelectorAll(".drop-after").forEach(e=>e.classList.remove("drop-after")),this.document.querySelectorAll(".drop-inside").forEach(e=>e.classList.remove("drop-inside"))}buildNodePatch(e=null){if(!e||!e.model)return null;const t={};return c.default.forEach(["id","name"],i=>{const s=e.model.get(i);s&&c.default.set(t,i,s)}),t}getSvg(e,t){const i=this.addSvgIcon(e,t);return new a.Observable(t=>{this.iconRegistry.getNamedSvgIcon(i).subscribe({error(t){console.error(`getSvg(${e}): ${t}`)},complete(){t.next(i)}})})}addSvgIcon(e,t){if(e in this.svgIcons)return this.svgIcons[e];t||(t={});const i=this.svgIcons[e]=c.default.uniqueId("selector_svg");return this.iconRegistry.addSvgIcon(i,this.sanitizer.bypassSecurityTrustResourceUrl(e),t),i}},I([i.Input(),M("design:type",String)],S.prototype,"target",void 0),I([i.Input(),M("design:type",String)],S.prototype,"targetSuffix",void 0),I([i.Input(),M("design:type",Number)],S.prototype,"id",void 0),I([i.Input(),M("design:type",Boolean)],S.prototype,"manifest",void 0),I([i.Input(),M("design:type",Boolean)],S.prototype,"decouple",void 0),I([i.Input(),M("design:type",Boolean)],S.prototype,"direct",void 0),I([i.Input(),M("design:type",Object)],S.prototype,"api",void 0),I([i.Input(),M("design:type",String)],S.prototype,"urlRoot",void 0),I([i.Input(),M("design:type",String)],S.prototype,"type",void 0),I([i.Input(),M("design:type",String)],S.prototype,"property",void 0),I([l.debounce(50),M("design:type",Function),M("design:paramtypes",[Object]),M("design:returntype",void 0)],S.prototype,"onDragMove",null),S=I([i.Component({selector:`sa-${D}`,templateUrl:`${b}/${D}/${D}.component${v}.html`}),$(5,i.Inject(y.DOCUMENT)),M("design:paramtypes",[n.MatIconRegistry,o.DomSanitizer,p.BackendService,i.ChangeDetectorRef,i.ElementRef,Document])],S),e("TreeComponent",S)}}});
1
+ System.register(["@angular/core","@angular/cdk/drag-drop","@angular/cdk/tree","@angular/platform-browser","@angular/material/icon","rxjs","@stratusjs/runtime/stratus","lodash","@agentepsilon/decko","../core/root.component","../backend.service","@stratusjs/angularjs/services/registry","@stratusjs/core/events/eventManager","@stratusjs/core/environment","@stratusjs/core/misc","@angular/common"],function(e,t){"use strict";var i,s,r,o,n,a,d,c,h,l,p,u,g,f,m,y,D,v,b,S,I=this&&this.__decorate||function(e,t,i,s){var r,o=arguments.length,n=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(n=(o<3?r(n):o>3?r(t,i,n):r(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n},M=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},$=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};t&&t.id;return{setters:[function(e){i=e},function(e){s=e},function(e){r=e},function(e){o=e},function(e){n=e},function(e){a=e},function(e){d=e},function(e){c=e},function(e){h=e},function(e){l=e},function(e){p=e},function(e){u=e},function(e){g=e},function(e){f=e},function(e){m=e},function(e){y=e}],execute:function(){"@stratusjs/angular",D="tree",v=f.cookie("env")?"":".min",b=`${d.Stratus.BaseUrl}${boot.configuration.paths["@stratusjs/angular/*"].replace(/[^/]*$/,"").replace(/\/dist\/$/,"/src/")}`,S=class extends l.RootComponent{constructor(e,t,i,s,o,n){super(),this.iconRegistry=e,this.sanitizer=t,this.backend=i,this.ref=s,this.elementRef=o,this.document=n,this.title=D+"_component",this.isInitialized=!1,this.isDestroyed=!1,this.isStyled=!1,this.Stratus=d.Stratus,this.registry=new u.Registry,this.onChange=new a.Subject,this.unsettled=!1,this.svgIcons={},this.dblClickWait=500,this.dropLists=[],this.dropListIdMap={},this.dropListMap={},this.expandedNodeSet=new Set,this.dragging=!1,this.expandDelay=1e3,this.dropData=null,this.cdkDropListSortingDisabled=!0,this.treeControl=new r.NestedTreeControl(e=>e.children||[]),this.isBorder=!1,this.isDebug=!1}ngOnInit(){this.uid=c.uniqueId(`sa_${c.snakeCase(D)}_component_`),d.Stratus.Instances[this.uid]=this,this.hydrate(this.elementRef,this.sanitizer,["title","uid","isInitialized","isDestroyed","isStyled","target","targetSuffix","id","manifest","decouple","direct","api","urlRoot","type","property","Stratus","registry","fetched","data","collection","model","dataSub","onChange","subscriber","unsettled","svgIcons","isSingleClick","dblClickWait","dropLists","dropListIdMap","dropListMap","expandedNodeSet","dragging","expandTimeout","expandDelay","dropData","cdkDropListSortingDisabled","tree","treeMap","metaMap","dataSource","treeControl","isBorder","isDebug","iconRegistry","sanitizer","backend","ref","elementRef","document","ngOnInit","ngOnDestroy","refresh","remove","removeNode","nodeIsEqual","fetchData","dataDefer","dataRef","trackDropLists","setExpanded","setExpandedClick","setExpandedDblClick","onDragDrop","onDragMove","showDragData","clearDragData","buildNodePatch","getSvg","addSvgIcon","hydrate","disableRefresh","stagger","reloading"]),d.Stratus.Internals.CssLoader(`${b}/${D}/${D}.component${v}.css`).then(()=>{this.isStyled=!0,this.refresh().then()}).catch(e=>{console.warn("Issue detected in CSS Loader for Component:",this),console.error(e),this.isStyled=!0,this.refresh().then()}),c.forEach({tree_check:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/check.svg`,tree_add:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/add.svg`,tree_delete:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/delete.svg`,tree_edit:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/edit.svg`,tree_visibility:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/visibility.svg`},(e,t)=>this.iconRegistry.addSvgIcon(t,this.sanitizer.bypassSecurityTrustResourceUrl(e)).getNamedSvgIcon(t)),this.fetchData().then(e=>{if(!(e&&e instanceof g.EventManager))return void console.warn("Unable to bind data from Registry!");const t=()=>{!this.unsettled&&e.completed&&(this.dataDefer(this.subscriber),this.refresh().then())};e.on("change",t),t(),e.on("add",(e,t)=>{let i=!1;const s=()=>{if(!t.completed)return;if(i)return;if(i=!0,!(t.getIdentifier()in this.treeMap))return void t.meta.set("postPersist",!0);const e=this.treeMap[t.getIdentifier()];e.meta.component&&"openDialog"in e.meta.component?e.meta.component.openDialog():t.meta.set("postPersist",!0)};t.on("change",s),s()})}),this.dataSub=new a.Observable(e=>this.dataDefer(e)),this.dropListIdMap[`${this.uid}_parent_drop_list`]=!0,this.trackDropLists();const e=f.cookie("tree-node-border");e&&m.isJSON(e)&&(this.isBorder=JSON.parse(e));const t=f.cookie("tree-debug");t&&m.isJSON(t)&&(this.isDebug=JSON.parse(t)),this.isInitialized=!0,this.refresh().then()}ngOnDestroy(){this.isDestroyed=!0}refresh(){return this.isDestroyed?new Promise(e=>e()):(c.forEach(this.metaMap,e=>{e.component&&"refresh"in e.component&&e.component.refresh()}),super.refresh())}remove(e){}removeNode(e,t){const i=e.indexOf(t);return-1!==i&&(e.splice(i,1),!0)}nodeIsEqual(e,t){return e&&t?e.id===t.id:e===t}async fetchData(){return this.fetched?this.fetched:this.fetched=this.registry.fetch(d.Stratus.Select(this.elementRef.nativeElement),this)}dataDefer(e){if(this.subscriber=this.subscriber||e,!this.subscriber||!this.collection||!this.collection.completed)return void setTimeout(()=>{this.dataDefer(e)},500);const t=this.dataRef(!0);t&&t.length?e.next(t):setTimeout(()=>this.dataDefer(e),200)}dataRef(e=!1){if(!this.collection)return[];if(!e&&this.tree&&this.tree.length>0)return this.tree;let t=this.collection.models;return t&&c.isArray(t)&&t.length?(t=c.sortBy(t,["data.priority"]),this.metaMap=this.metaMap||{},this.treeMap={},this.tree=[],c.forEach(t,e=>{const t=c.get(e,"data.id"),i=c.get(e,"data.nestParent.id");this.dropListIdMap[`${this.uid}_node_${t}_drop_list`]=!0,c.has(this.metaMap,t)||(this.metaMap[t]={id:t,expanded:!0}),c.has(this.treeMap,t)||(this.treeMap[t]={id:t,model:e,children:[],meta:this.metaMap[t]}),this.treeMap[t].model=e,this.treeMap[t].meta=this.metaMap[t],i?(c.has(this.treeMap,i)||(this.treeMap[i]={id:i,model:null,children:[],meta:null}),this.treeMap[i].children.push(this.treeMap[t])):this.tree.push(this.treeMap[t])}),this.trackDropLists(),this.tree):[]}trackDropLists(){this.dropLists=[],c.forEach(this.dropListIdMap,(e,t)=>{if(!e)return;const i=t in this.dropListMap,s=i?this.dropListMap[t]:document.getElementById(t);s&&(this.dropLists.push(t),i||(this.dropListMap[t]=s))})}setExpanded(e){this.metaMap&&c.size(this.metaMap)&&(c.forEach(this.metaMap,t=>{t.expanded=e}),this.refresh().then())}setExpandedClick(e){this.isSingleClick=!0,setTimeout(()=>{this.isSingleClick&&this.setExpanded(e)},this.dblClickWait)}setExpandedDblClick(e){this.isSingleClick=!1,this.setExpanded(e)}async onDragDrop(e){if(!e.isPointerOverContainer)return;const t=e.item.data;if(!t)return;let i=e.container.data;const r=e.previousContainer.data,o=i?i.children:this.dataRef();if(!o)return;this.unsettled=!0;const n=this.dropData.targetId&&this.dropData.targetId in this.treeMap?this.treeMap[c.toNumber(this.dropData.targetId)]:null;if(f.cookie("env")&&this.isDebug&&(console.group("onDragDrop()"),c.forEach([`model drop: ${t.model.get("name")}`,`list shift: ${e.container.element.nativeElement.id} -> ${e.previousContainer.element.nativeElement.id}`,`index change (event): ${e.previousIndex} -> ${e.currentIndex}`,`current priority: ${t.model.get("priority")}`,`target drop action: ${this.dropData.action}`],e=>console.log(e))),n&&!this.nodeIsEqual(i,n)){if(f.cookie("env")&&this.isDebug&&(console.log(`target drop node differs: ${n.id} -> ${n.model.get("name")}`),console.log("target drop node is the same as target node:",t.id===n.id)),t.id!==n.id)switch(this.dropData.action){case"before":case"after":const e=n.model.get("nestParent.id");i=e&&e in this.treeMap?this.treeMap[e]:null;break;case"inside":i=n}f.cookie("env")&&this.isDebug&&console.log("target drop node selected:",i?`${i.id} -> ${i.model.get("name")}`:"none")}if(!this.nodeIsEqual(i,r)){if(i){switch(this.dropData.action){case"before":case"after":let e=i.children.findIndex(e=>e.id===t.id);"after"===this.dropData.action&&e++,i.children.splice(e,0,t);break;case"inside":i.children.push(t)}i.meta.expanded=!0}r&&this.removeNode(r.children,t),t.model.set("nestParent",this.buildNodePatch(i)),f.cookie("env")&&this.isDebug&&console.log(`new parent: ${t.model.get("nestParent.name")||null}`)}const a=i?i.children:o;let d=e.currentIndex;if(this.cdkDropListSortingDisabled)switch(d=null,this.dropData.action){case"before":case"after":d=a.findIndex(e=>e.id===n.id),"after"===this.dropData.action&&d++,f.cookie("env")&&this.isDebug&&console.log("index change (drop node):",`${e.previousIndex} -> ${d}`)}if(c.isNumber(d)){s.moveItemInArray(a,e.previousIndex,d);let i=0;c.forEach(a,e=>{e.model&&e.model.set&&e.model.set("priority",i++)}),f.cookie("env")&&this.isDebug&&console.log("new priority:",t.model.get("priority"))}f.cookie("env")&&this.isDebug&&console.groupEnd(),await t.model.save(),this.unsettled=!1,this.collection.throttleTrigger("change")}onDragMove(e){const t=this.document.elementFromPoint(e.pointerPosition.x,e.pointerPosition.y);if(!t)return void this.clearDragData();const i="tree-node-content",s=t.classList.contains(i)?t:t.closest(`.${i}`);if(!s)return void this.clearDragData();this.dropData={targetId:s.getAttribute("data-id")};const r=s.getBoundingClientRect(),o=r.height/3;e.pointerPosition.y-r.top<o?this.dropData.action="before":e.pointerPosition.y-r.top>2*o?this.dropData.action="after":this.dropData.action="inside",this.showDragData()}showDragData(){this.clearDragData(),this.dropData&&this.document.getElementById(`node-${this.dropData.targetId}`).classList.add(`drop-${this.dropData.action}`)}clearDragData(e=!1){e&&(this.dropData=null),this.document.querySelectorAll(".drop-before").forEach(e=>e.classList.remove("drop-before")),this.document.querySelectorAll(".drop-after").forEach(e=>e.classList.remove("drop-after")),this.document.querySelectorAll(".drop-inside").forEach(e=>e.classList.remove("drop-inside"))}buildNodePatch(e=null){if(!e||!e.model)return null;const t={};return c.forEach(["id","name"],i=>{const s=e.model.get(i);s&&c.set(t,i,s)}),t}getSvg(e,t){const i=this.addSvgIcon(e,t);return new a.Observable(t=>{this.iconRegistry.getNamedSvgIcon(i).subscribe({error(t){console.error(`getSvg(${e}): ${t}`)},complete(){t.next(i)}})})}addSvgIcon(e,t){if(e in this.svgIcons)return this.svgIcons[e];t||(t={});const i=this.svgIcons[e]=c.uniqueId("selector_svg");return this.iconRegistry.addSvgIcon(i,this.sanitizer.bypassSecurityTrustResourceUrl(e),t),i}},I([i.Input(),M("design:type",String)],S.prototype,"target",void 0),I([i.Input(),M("design:type",String)],S.prototype,"targetSuffix",void 0),I([i.Input(),M("design:type",Number)],S.prototype,"id",void 0),I([i.Input(),M("design:type",Boolean)],S.prototype,"manifest",void 0),I([i.Input(),M("design:type",Boolean)],S.prototype,"decouple",void 0),I([i.Input(),M("design:type",Boolean)],S.prototype,"direct",void 0),I([i.Input(),M("design:type",Object)],S.prototype,"api",void 0),I([i.Input(),M("design:type",String)],S.prototype,"urlRoot",void 0),I([i.Input(),M("design:type",String)],S.prototype,"type",void 0),I([i.Input(),M("design:type",String)],S.prototype,"property",void 0),I([h.debounce(50),M("design:type",Function),M("design:paramtypes",[Object]),M("design:returntype",void 0)],S.prototype,"onDragMove",null),S=I([i.Component({selector:`sa-${D}`,templateUrl:`${b}/${D}/${D}.component${v}.html`}),$(5,i.Inject(y.DOCUMENT)),M("design:paramtypes",[n.MatIconRegistry,o.DomSanitizer,p.BackendService,i.ChangeDetectorRef,i.ElementRef,Document])],S),e("TreeComponent",S)}}});
@@ -36,7 +36,19 @@ import {
36
36
 
37
37
  // External
38
38
  import {Stratus} from '@stratusjs/runtime/stratus'
39
- import _ from 'lodash'
39
+ import {
40
+ forEach,
41
+ get,
42
+ has,
43
+ isArray,
44
+ isNumber,
45
+ set,
46
+ size,
47
+ snakeCase,
48
+ sortBy,
49
+ toNumber,
50
+ uniqueId
51
+ } from 'lodash'
40
52
  import {keys} from 'ts-transformer-keys'
41
53
  import {debounce} from '@agentepsilon/decko'
42
54
 
@@ -161,7 +173,6 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
161
173
  @Input() property: string
162
174
 
163
175
  // Dependencies
164
- _ = _
165
176
  Stratus = Stratus
166
177
 
167
178
  // Stratus Data Connectivity
@@ -228,7 +239,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
228
239
 
229
240
  ngOnInit() {
230
241
  // Initialization
231
- this.uid = _.uniqueId(`sa_${_.snakeCase(moduleName)}_component_`)
242
+ this.uid = uniqueId(`sa_${snakeCase(moduleName)}_component_`)
232
243
  Stratus.Instances[this.uid] = this
233
244
 
234
245
  // Hydrate Root App Inputs
@@ -239,18 +250,18 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
239
250
  Stratus.Internals.CssLoader(`${localDir}/${moduleName}/${moduleName}.component${min}.css`)
240
251
  .then(() => {
241
252
  this.isStyled = true
242
- this.refresh()
253
+ this.refresh().then()
243
254
  })
244
255
  .catch((err: any) => {
245
256
  console.warn('Issue detected in CSS Loader for Component:', this)
246
257
  console.error(err)
247
258
  this.isStyled = true
248
- this.refresh()
259
+ this.refresh().then()
249
260
  })
250
261
 
251
262
  // SVG Icons
252
263
  // TODO: Make this into a single service
253
- _.forEach({
264
+ forEach({
254
265
  tree_check: `${Stratus.BaseUrl}sitetheorycore/images/icons/check.svg`,
255
266
  tree_add: `${Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/add.svg`,
256
267
  tree_delete: `${Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/delete.svg`,
@@ -272,7 +283,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
272
283
  return
273
284
  }
274
285
  this.dataDefer(this.subscriber)
275
- this.refresh()
286
+ this.refresh().then()
276
287
  }
277
288
  data.on('change', onDataChange)
278
289
  onDataChange()
@@ -311,7 +322,8 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
311
322
  }
312
323
  // Since the Node is available, create the dialog
313
324
  // console.log('direct dialog:', model)
314
- // FIXME: This is set to ignore because it previously checked if `instanceof TreeNodeComponent`, which caused a circular reference.
325
+ // FIXME: This is set to ignore because it previously checked if `instanceof TreeNodeComponent`,
326
+ // which caused a circular reference.
315
327
  // @ts-ignore
316
328
  node.meta.component.openDialog()
317
329
  }
@@ -341,7 +353,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
341
353
  this.isInitialized = true
342
354
 
343
355
  // Force UI Redraw
344
- this.refresh()
356
+ this.refresh().then()
345
357
  }
346
358
 
347
359
  // async ngOnInit() {
@@ -357,7 +369,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
357
369
  return new Promise<void>(resolve => resolve())
358
370
  }
359
371
  // TODO: Refresh treeNodeComponents through a map
360
- _.forEach(this.metaMap, (meta: NodeMeta) => {
372
+ forEach(this.metaMap, (meta: NodeMeta) => {
361
373
  if (!meta.component || !('refresh' in meta.component)) {
362
374
  return
363
375
  }
@@ -433,26 +445,26 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
433
445
  }
434
446
  // TODO: Break away from the registry here... It's not responsive enough.
435
447
  let models = this.collection.models
436
- if (!models || !_.isArray(models) || !models.length) {
448
+ if (!models || !isArray(models) || !models.length) {
437
449
  return []
438
450
  }
439
- models = _.sortBy(models, ['data.priority'])
451
+ models = sortBy(models, ['data.priority'])
440
452
  // Convert Collection Models to Nested Tree to optimize references
441
453
  this.metaMap = this.metaMap || {}
442
454
  this.treeMap = {}
443
455
  this.tree = []
444
- _.forEach(models, (model: any) => {
445
- const modelId = _.get(model, 'data.id')
446
- const parentId = _.get(model, 'data.nestParent.id')
456
+ forEach(models, (model: any) => {
457
+ const modelId = get(model, 'data.id')
458
+ const parentId = get(model, 'data.nestParent.id')
447
459
  this.dropListIdMap[`${this.uid}_node_${modelId}_drop_list`] = true
448
- if (!_.has(this.metaMap, modelId)) {
460
+ if (!has(this.metaMap, modelId)) {
449
461
  this.metaMap[modelId] = {
450
462
  id: modelId,
451
463
  // TODO: This is the default setting for the UI and should be a component setting
452
464
  expanded: true
453
465
  }
454
466
  }
455
- if (!_.has(this.treeMap, modelId)) {
467
+ if (!has(this.treeMap, modelId)) {
456
468
  this.treeMap[modelId] = {
457
469
  id: modelId,
458
470
  model,
@@ -463,7 +475,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
463
475
  this.treeMap[modelId].model = model
464
476
  this.treeMap[modelId].meta = this.metaMap[modelId]
465
477
  if (parentId) {
466
- if (!_.has(this.treeMap, parentId)) {
478
+ if (!has(this.treeMap, parentId)) {
467
479
  this.treeMap[parentId] = {
468
480
  id: parentId,
469
481
  model: null,
@@ -486,7 +498,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
486
498
 
487
499
  private trackDropLists() {
488
500
  this.dropLists = []
489
- _.forEach(this.dropListIdMap, (value: boolean, key: string) => {
501
+ forEach(this.dropListIdMap, (value: boolean, key: string) => {
490
502
  if (!value) {
491
503
  return
492
504
  }
@@ -505,13 +517,13 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
505
517
  }
506
518
 
507
519
  private setExpanded(expanded: boolean): void {
508
- if (!this.metaMap || !_.size(this.metaMap)) {
520
+ if (!this.metaMap || !size(this.metaMap)) {
509
521
  return
510
522
  }
511
- _.forEach(this.metaMap, (nodeMeta: NodeMeta) => {
523
+ forEach(this.metaMap, (nodeMeta: NodeMeta) => {
512
524
  nodeMeta.expanded = expanded
513
525
  })
514
- this.refresh()
526
+ this.refresh().then()
515
527
  }
516
528
 
517
529
  public setExpandedClick(expanded: boolean): void {
@@ -593,12 +605,12 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
593
605
  // Find Drop Node (For Comparisons)
594
606
  const targetDropNode =
595
607
  (this.dropData.targetId && this.dropData.targetId in this.treeMap) ?
596
- this.treeMap[_.toNumber(this.dropData.targetId)] : null
608
+ this.treeMap[toNumber(this.dropData.targetId)] : null
597
609
 
598
610
  // Debug Data
599
611
  if (cookie('env') && this.isDebug) {
600
612
  console.group('onDragDrop()')
601
- _.forEach(
613
+ forEach(
602
614
  [
603
615
  `model drop: ${targetNode.model.get('name')}`,
604
616
  `list shift: ${event.container.element.nativeElement.id} -> ${event.previousContainer.element.nativeElement.id}`,
@@ -690,12 +702,12 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
690
702
  }
691
703
 
692
704
  // Handle new cell placement
693
- if (_.isNumber(targetDropIndex)) {
705
+ if (isNumber(targetDropIndex)) {
694
706
  // Move cell in array
695
707
  moveItemInArray(branch, event.previousIndex, targetDropIndex)
696
708
  // Generate new priority
697
709
  let priority = 0
698
- _.forEach(branch, (node: Node) => {
710
+ forEach(branch, (node: Node) => {
699
711
  if (!node.model || !node.model.set) {
700
712
  return
701
713
  }
@@ -755,7 +767,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
755
767
 
756
768
  // private isNotSelfDrop(event: CdkDragDrop<any> | CdkDragEnter<any> | CdkDragExit<any>): boolean {
757
769
  // console.log('isNotSelfDrop:', event.item.data, event.item.data)
758
- // return !_.isEqual(event.item.data, event.item.data)
770
+ // return !isEqual(event.item.data, event.item.data)
759
771
  // }
760
772
 
761
773
  @debounce(50)
@@ -821,7 +833,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
821
833
  return null
822
834
  }
823
835
  const nodePatch = {}
824
- _.forEach([
836
+ forEach([
825
837
  'id',
826
838
  'name'
827
839
  ], (key: string) => {
@@ -829,7 +841,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
829
841
  if (!value) {
830
842
  return
831
843
  }
832
- _.set(nodePatch, key, value)
844
+ set(nodePatch, key, value)
833
845
  })
834
846
  return nodePatch
835
847
  }
@@ -839,9 +851,9 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
839
851
  // return []
840
852
  // }
841
853
  // // TODO: Instead of a filter, like this, it would be better to search the tree
842
- // return _.filter(this.dataRef(), function (child) {
843
- // const modelId = _.get(model, 'data.id')
844
- // const parentId = _.get(child, 'data.nestParent.id')
854
+ // return filter(this.dataRef(), function (child) {
855
+ // const modelId = get(model, 'data.id')
856
+ // const parentId = get(child, 'data.nestParent.id')
845
857
  // return modelId && parentId && modelId === parentId
846
858
  // })
847
859
  // }
@@ -879,7 +891,7 @@ export class TreeComponent extends RootComponent implements OnInit, OnDestroy {
879
891
  if (!options) {
880
892
  options = {}
881
893
  }
882
- const uid = this.svgIcons[url] = _.uniqueId('selector_svg')
894
+ const uid = this.svgIcons[url] = uniqueId('selector_svg')
883
895
  this.iconRegistry.addSvgIcon(uid, this.sanitizer.bypassSecurityTrustResourceUrl(url), options)
884
896
  return uid
885
897
  }