-
Notifications
You must be signed in to change notification settings - Fork 11
/
chunk-DXB22PMR.js
1 lines (1 loc) · 12.7 KB
/
chunk-DXB22PMR.js
1
import{g as k,ia as N,la as u}from"./chunk-GBKJFEQZ.js";var n=class r{get treeService(){return this.service||this.parentNode&&this.parentNode.treeService}constructor(s,e=null,t=null){if(this._title="",this.level=0,this.parentNode=null,this._icon="",this._children=[],this._isLeaf=!1,this._isChecked=!1,this._isSelectable=!1,this._isDisabled=!1,this._isDisableCheckbox=!1,this._isExpanded=!1,this._isHalfChecked=!1,this._isSelected=!1,this._isLoading=!1,this.canHide=!1,this.isMatched=!1,this.service=null,s instanceof r)return s;this.service=t||null,this.origin=s,this.key=s.key,this.parentNode=e,this._title=s.title||"---",this._icon=s.icon||"",this._isLeaf=s.isLeaf||!1,this._children=[],this._isChecked=s.checked||!1,this._isSelectable=s.disabled||s.selectable!==!1,this._isDisabled=s.disabled||!1,this._isDisableCheckbox=s.disableCheckbox||!1,this._isExpanded=s.isLeaf?!1:s.expanded||!1,this._isHalfChecked=!1,this._isSelected=!s.disabled&&s.selected||!1,this._isLoading=!1,this.isMatched=!1,e?this.level=e.level+1:this.level=0;let i=this.treeService;i?.treeNodePostProcessor?.(this),typeof s.children<"u"&&s.children!==null&&s.children.forEach(h=>{i&&!i.isCheckStrictly&&s.checked&&!s.disabled&&!h.disabled&&!h.disableCheckbox&&(h.checked=s.checked),this._children.push(new r(h,this))})}get title(){return this._title}set title(s){this._title=s,this.update()}get icon(){return this._icon}set icon(s){this._icon=s,this.update()}get children(){return this._children}set children(s){this._children=s,this.update()}get isLeaf(){return this._isLeaf}set isLeaf(s){this._isLeaf=s,this.update()}get isChecked(){return this._isChecked}set isChecked(s){this._isChecked=s,this.origin.checked=s,this.afterValueChange("isChecked")}get isHalfChecked(){return this._isHalfChecked}set isHalfChecked(s){this._isHalfChecked=s,this.afterValueChange("isHalfChecked")}get isSelectable(){return this._isSelectable}set isSelectable(s){this._isSelectable=s,this.update()}get isDisabled(){return this._isDisabled}set isDisabled(s){this._isDisabled=s,this.update()}get isDisableCheckbox(){return this._isDisableCheckbox}set isDisableCheckbox(s){this._isDisableCheckbox=s,this.update()}get isExpanded(){return this._isExpanded}set isExpanded(s){this._isExpanded=s,this.origin.expanded=s,this.afterValueChange("isExpanded"),this.afterValueChange("reRender")}get isSelected(){return this._isSelected}set isSelected(s){this._isSelected=s,this.origin.selected=s,this.afterValueChange("isSelected")}get isLoading(){return this._isLoading}set isLoading(s){this._isLoading=s,this.update()}setSyncChecked(s=!1,e=!1){this.setChecked(s,e),this.treeService&&!this.treeService.isCheckStrictly&&this.treeService.conduct(this)}setChecked(s=!1,e=!1){this.origin.checked=s,this.isChecked=s,this.isHalfChecked=e}setExpanded(s){this._isExpanded=s,this.origin.expanded=s,this.afterValueChange("isExpanded")}getParentNode(){return this.parentNode}getChildren(){return this.children}addChildren(s,e=-1){this.isLeaf||(s.forEach(t=>{let i=d=>{d.getChildren().forEach(c=>{c.level=c.getParentNode().level+1,c.origin.level=c.level,i(c)})},h=t;h instanceof r?h.parentNode=this:h=new r(t,this),h.level=this.level+1,h.origin.level=h.level,i(h);try{e===-1?this.children.push(h):this.children.splice(e,0,h)}catch{}}),this.origin.children=this.getChildren().map(t=>t.origin),this.isLoading=!1),this.afterValueChange("addChildren"),this.afterValueChange("reRender")}clearChildren(){this.afterValueChange("clearChildren"),this.children=[],this.origin.children=[],this.afterValueChange("reRender")}remove(){let s=this.getParentNode();s&&(s.children=s.getChildren().filter(e=>e.key!==this.key),s.origin.children=s.origin.children.filter(e=>e.key!==this.key),this.afterValueChange("remove"),this.afterValueChange("reRender"))}afterValueChange(s){if(this.treeService)switch(s){case"isChecked":this.treeService.setCheckedNodeList(this);break;case"isHalfChecked":this.treeService.setHalfCheckedNodeList(this);break;case"isExpanded":this.treeService.setExpandedNodeList(this);break;case"isSelected":this.treeService.setNodeActive(this);break;case"clearChildren":this.treeService.afterRemove(this.getChildren());break;case"remove":this.treeService.afterRemove([this]);break;case"reRender":this.treeService.flattenTreeData(this.treeService.rootNodes,this.treeService.getExpandedNodeList().map(e=>e.key));break}this.update()}update(){this.component&&this.component.markForCheck()}};function o(r){let{isDisabled:s,isDisableCheckbox:e}=r;return!!(s||e)}function g(r,s){return s.length>0&&s.indexOf(r)>-1}function S(r,s){return`${r}-${s}`}function p(r,s){return r??s}function y(r=[],s=[]){let e=new Set(s===!0?[]:s),t=[];function i(h,d=null){return h.map((c,a)=>{let f=S(d?d.pos:"0",a),L=p(c.key,f);c.isStart=[...d?d.isStart:[],a===0],c.isEnd=[...d?d.isEnd:[],a===h.length-1];let l={parent:d,pos:f,children:[],data:c,isStart:[...d?d.isStart:[],a===0],isEnd:[...d?d.isEnd:[],a===h.length-1]};return t.push(l),s===!0||e.has(L)||c.isExpanded?l.children=i(c.children||[],l):l.children=[],l})}return i(r),t}var _=(()=>{class r{constructor(){this.DRAG_SIDE_RANGE=.25,this.DRAG_MIN_GAP=2,this.isCheckStrictly=!1,this.isMultiple=!1,this.rootNodes=[],this.flattenNodes$=new k([]),this.selectedNodeList=[],this.expandedNodeList=[],this.checkedNodeList=[],this.halfCheckedNodeList=[],this.matchedNodeList=[]}initTree(e){this.rootNodes=e,this.expandedNodeList=[],this.selectedNodeList=[],this.halfCheckedNodeList=[],this.checkedNodeList=[],this.matchedNodeList=[]}flattenTreeData(e,t=[]){this.flattenNodes$.next(y(e,t).map(i=>i.data))}getSelectedNode(){return this.selectedNode}getSelectedNodeList(){return this.conductNodeState("select")}getCheckedNodeKeys(){let e=[],t=this.getCheckedNodeList(),i=h=>{h.forEach(d=>{e.push(d.key),!(d.children.length<1)&&i(d.children)})};return i(t),e}getCheckedNodeList(){return this.conductNodeState("check")}getHalfCheckedNodeList(){return this.conductNodeState("halfCheck")}getExpandedNodeList(){return this.conductNodeState("expand")}getMatchedNodeList(){return this.conductNodeState("match")}isArrayOfNzTreeNode(e){return e.every(t=>t instanceof n)}setSelectedNode(e){this.selectedNode=e}setNodeActive(e){!this.isMultiple&&e.isSelected&&(this.selectedNodeList.forEach(t=>{e.key!==t.key&&(t.isSelected=!1)}),this.selectedNodeList=[]),this.setSelectedNodeList(e,this.isMultiple)}setSelectedNodeList(e,t=!1){let i=this.getIndexOfArray(this.selectedNodeList,e.key);t?e.isSelected&&i===-1&&this.selectedNodeList.push(e):e.isSelected&&i===-1&&(this.selectedNodeList=[e]),e.isSelected||(this.selectedNodeList=this.selectedNodeList.filter(h=>h.key!==e.key))}setHalfCheckedNodeList(e){let t=this.getIndexOfArray(this.halfCheckedNodeList,e.key);e.isHalfChecked&&t===-1?this.halfCheckedNodeList.push(e):!e.isHalfChecked&&t>-1&&(this.halfCheckedNodeList=this.halfCheckedNodeList.filter(i=>e.key!==i.key))}setCheckedNodeList(e){let t=this.getIndexOfArray(this.checkedNodeList,e.key);e.isChecked&&t===-1?this.checkedNodeList.push(e):!e.isChecked&&t>-1&&(this.checkedNodeList=this.checkedNodeList.filter(i=>e.key!==i.key))}conductNodeState(e="check"){let t=[];switch(e){case"select":t=this.selectedNodeList;break;case"expand":t=this.expandedNodeList;break;case"match":t=this.matchedNodeList;break;case"check":t=this.checkedNodeList;let i=h=>{let d=h.getParentNode();return d?this.checkedNodeList.findIndex(c=>c.key===d.key)>-1?!0:i(d):!1};this.isCheckStrictly||(t=this.checkedNodeList.filter(h=>!i(h)));break;case"halfCheck":this.isCheckStrictly||(t=this.halfCheckedNodeList);break}return t}setExpandedNodeList(e){if(e.isLeaf)return;let t=this.getIndexOfArray(this.expandedNodeList,e.key);e.isExpanded&&t===-1?this.expandedNodeList.push(e):!e.isExpanded&&t>-1&&this.expandedNodeList.splice(t,1)}setMatchedNodeList(e){let t=this.getIndexOfArray(this.matchedNodeList,e.key);e.isMatched&&t===-1?this.matchedNodeList.push(e):!e.isMatched&&t>-1&&this.matchedNodeList.splice(t,1)}refreshCheckState(e=!1){e||this.checkedNodeList.forEach(t=>{this.conduct(t,e)})}conduct(e,t=!1){let i=e.isChecked;e&&!t&&(this.conductUp(e),this.conductDown(e,i))}conductUp(e){let t=e.getParentNode();t&&(o(t)||(t.children.every(i=>o(i)||!i.isHalfChecked&&i.isChecked)?(t.isChecked=!0,t.isHalfChecked=!1):t.children.some(i=>i.isHalfChecked||i.isChecked)?(t.isChecked=!1,t.isHalfChecked=!0):(t.isChecked=!1,t.isHalfChecked=!1)),this.setCheckedNodeList(t),this.setHalfCheckedNodeList(t),this.conductUp(t))}conductDown(e,t){o(e)||(e.isChecked=t,e.isHalfChecked=!1,this.setCheckedNodeList(e),this.setHalfCheckedNodeList(e),e.children.forEach(i=>{this.conductDown(i,t)}))}afterRemove(e){let t=i=>{this.selectedNodeList=this.selectedNodeList.filter(h=>h.key!==i.key),this.expandedNodeList=this.expandedNodeList.filter(h=>h.key!==i.key),this.checkedNodeList=this.checkedNodeList.filter(h=>h.key!==i.key),i.children&&i.children.forEach(h=>{t(h)})};e.forEach(i=>{t(i)}),this.refreshCheckState(this.isCheckStrictly)}refreshDragNode(e){e.children.length===0?this.conductUp(e):e.children.forEach(t=>{this.refreshDragNode(t)})}resetNodeLevel(e){let t=e.getParentNode();t?e.level=t.level+1:e.level=0;for(let i of e.children)this.resetNodeLevel(i)}calcDropPosition(e){let{clientY:t}=e,{top:i,bottom:h,height:d}=e.target.getBoundingClientRect(),c=Math.max(d*this.DRAG_SIDE_RANGE,this.DRAG_MIN_GAP);return t<=i+c?-1:t>=h-c?1:0}dropAndApply(e,t=-1){if(!e||t>1)return;let i=e.treeService,h=e.getParentNode(),d=this.selectedNode.getParentNode();switch(d?d.children=d.children.filter(c=>c.key!==this.selectedNode.key):this.rootNodes=this.rootNodes.filter(c=>c.key!==this.selectedNode.key),t){case 0:e.addChildren([this.selectedNode]),this.resetNodeLevel(e);break;case-1:case 1:let c=t===1?1:0;if(h){h.addChildren([this.selectedNode],h.children.indexOf(e)+c);let a=this.selectedNode.getParentNode();a&&this.resetNodeLevel(a)}else{let a=this.rootNodes.indexOf(e)+c;this.rootNodes.splice(a,0,this.selectedNode),this.rootNodes[a].parentNode=null,this.resetNodeLevel(this.rootNodes[a])}break}this.rootNodes.forEach(c=>{c.treeService||(c.service=i),this.refreshDragNode(c)})}formatEvent(e,t,i){let h={eventName:e,node:t,event:i};switch(e){case"dragstart":case"dragenter":case"dragover":case"dragleave":case"drop":case"dragend":Object.assign(h,{dragNode:this.getSelectedNode()});break;case"click":case"dblclick":Object.assign(h,{selectedKeys:this.selectedNodeList}),Object.assign(h,{nodes:this.selectedNodeList}),Object.assign(h,{keys:this.selectedNodeList.map(c=>c.key)});break;case"check":let d=this.getCheckedNodeList();Object.assign(h,{checkedKeys:d}),Object.assign(h,{nodes:d}),Object.assign(h,{keys:d.map(c=>c.key)});break;case"search":Object.assign(h,{matchedKeys:this.getMatchedNodeList()}),Object.assign(h,{nodes:this.getMatchedNodeList()}),Object.assign(h,{keys:this.getMatchedNodeList().map(c=>c.key)});break;case"expand":Object.assign(h,{nodes:this.expandedNodeList}),Object.assign(h,{keys:this.expandedNodeList.map(c=>c.key)});break}return h}getIndexOfArray(e,t){return e.findIndex(i=>i.key===t)}conductCheck(e,t){this.checkedNodeList=[],this.halfCheckedNodeList=[];let i=h=>{h.forEach(d=>{e===null?d.isChecked=!!d.origin.checked:g(d.key,e||[])?(d.isChecked=!0,d.isHalfChecked=!1):(d.isChecked=!1,d.isHalfChecked=!1),d.children.length>0&&i(d.children)})};i(this.rootNodes),this.refreshCheckState(t)}conductExpandedKeys(e=[]){let t=new Set(e===!0?[]:e);this.expandedNodeList=[];let i=h=>{h.forEach(d=>{d.setExpanded(e===!0||t.has(d.key)||d.isExpanded===!0),d.isExpanded&&this.setExpandedNodeList(d),d.children.length>0&&i(d.children)})};i(this.rootNodes)}conductSelectedKeys(e,t){this.selectedNodeList.forEach(h=>h.isSelected=!1),this.selectedNodeList=[];let i=h=>h.every(d=>{if(g(d.key,e)){if(d.isSelected=!0,this.setSelectedNodeList(d),!t)return!1}else d.isSelected=!1;return d.children.length>0?i(d.children):!0});i(this.rootNodes)}expandNodeAllParentBySearch(e){let t=i=>{if(i&&(i.canHide=!1,i.setExpanded(!0),this.setExpandedNodeList(i),i.getParentNode()))return t(i.getParentNode())};t(e.getParentNode())}static{this.\u0275fac=function(t){return new(t||r)}}static{this.\u0275prov=N({token:r,factory:r.\u0275fac})}}return r})(),m=new u("NzTreeHigherOrder"),C=class{constructor(s){this.nzTreeService=s}coerceTreeNodes(s){let e=[];return this.nzTreeService.isArrayOfNzTreeNode(s)?e=s.map(t=>(t.service=this.nzTreeService,t)):e=s.map(t=>new n(t,null,this.nzTreeService)),e}getTreeNodes(){return this.nzTreeService.rootNodes}getTreeNodeByKey(s){let e=[],t=i=>{e.push(i),i.getChildren().forEach(h=>{t(h)})};return this.getTreeNodes().forEach(i=>{t(i)}),e.find(i=>i.key===s)||null}getCheckedNodeList(){return this.nzTreeService.getCheckedNodeList()}getSelectedNodeList(){return this.nzTreeService.getSelectedNodeList()}getHalfCheckedNodeList(){return this.nzTreeService.getHalfCheckedNodeList()}getExpandedNodeList(){return this.nzTreeService.getExpandedNodeList()}getMatchedNodeList(){return this.nzTreeService.getMatchedNodeList()}};export{n as a,y as b,_ as c,m as d,C as e};