@abi-software/map-utilities 1.2.1-beta.0 → 1.2.1-beta.1

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.
@@ -26822,7 +26822,12 @@ class RO extends EventTarget {
26822
26822
  this.tooltip.hidden = !0;
26823
26823
  }
26824
26824
  tapNode(r) {
26825
- const a = r.target.data(), { label: i } = a, o = Eu(i), s = new CustomEvent("tap-node", {
26825
+ const n = r.target, a = n.data();
26826
+ let { label: i } = a;
26827
+ i && n.isNode() && n.selected() && (i = "", setTimeout(() => {
26828
+ n.unselect();
26829
+ }));
26830
+ const o = Eu(i), s = new CustomEvent("tap-node", {
26826
26831
  detail: o
26827
26832
  });
26828
26833
  this.dispatchEvent(s);
@@ -39,7 +39,7 @@ Licensed under The MIT License (http://opensource.org/licenses/MIT)
39
39
  `).map(e=>e&&e[0]>="a"&&e[0]<="z"?e.charAt(0).toUpperCase()+e.slice(1):e).join(`
40
40
  `)}function Fc(t){const e=t?t.split(`
41
41
  `):[],r=[];for(let n=0;n<e.length/2;n++)r.push({id:e[n],label:e[n+e.length/2]});return r}function hD(t,e){t.sort((r,n)=>r.id<n.id?-1:r.id>n.id?1:0),e.sort((r,n)=>r.id<n.id?-1:r.id>n.id?1:0);for(let r=0;r<t.length;r++)if(JSON.stringify(t[r])!==JSON.stringify(e[r]))return!1;return!0}class pD extends EventTarget{constructor(r,n){var a;super();gr(this,"cy");gr(this,"tooltip");this.cy=Yn({container:n,elements:r.elements,layout:{name:"breadthfirst",circle:!1,roots:r.roots},directed:!0,style:dD,minZoom:.5,maxZoom:10,wheelSensitivity:.4}).on("mouseover","node",this.overNode.bind(this)).on("mouseout","node",this.exitNode.bind(this)).on("position","node",this.moveNode.bind(this)).on("tap",this.tapNode.bind(this)),this.tooltip=document.createElement("div"),this.tooltip.className="cy-graph-tooltip",this.tooltip.hidden=!0,(a=n==null?void 0:n.lastChild)==null||a.appendChild(this.tooltip)}remove(){this.cy&&this.cy.destroy()}checkRightBoundary(r){var n;r+this.tooltip.offsetWidth>=((n=this.tooltip.parentElement)==null?void 0:n.offsetWidth)&&(this.tooltip.style.left=`${r-this.tooltip.offsetWidth}px`)}overNode(r){const a=r.target.data(),{label:i}=a,l=Fc(i).map(u=>u.label+" ("+u.id+")");this.tooltip.innerText=Iv(l.join(`
42
- `)),this.tooltip.style.left=`${r.renderedPosition.x}px`,this.tooltip.style.top=`${r.renderedPosition.y}px`,this.tooltip.style.maxWidth="240px",this.tooltip.style.zIndex=2,this.tooltip.hidden=!1,this.checkRightBoundary(r.renderedPosition.x)}moveNode(r){const n=r.target;this.tooltip.style.left=`${n.renderedPosition().x}px`,this.tooltip.style.top=`${n.renderedPosition().y}px`,this.checkRightBoundary(n.renderedPosition().x)}exitNode(r){this.tooltip.hidden=!0}tapNode(r){const a=r.target.data(),{label:i}=a,s=Fc(i),l=new CustomEvent("tap-node",{detail:s});this.dispatchEvent(l)}on(r,n){this.addEventListener(r,n)}}const vD=t=>t&&t.charAt(0).toUpperCase()+t.slice(1),gD=1.3,mD=24*60*60*1e3,yD="Reset position",Fv="Lock zoom",bD="Unlock zoom",wD="Zoom in",CD="Zoom out",Av=.25,kD="#8300bf",xD=3e3,ED={name:"ConnectivityGraph",props:{entry:{type:String,default:""},mapServer:{type:String,default:""},selectedConnectivityData:{type:Array,default:[]}},data:function(){return{loading:!0,connectivityGraph:null,selectedSource:"",pathList:[],schemaVersion:"",knowledgeByPath:new Map,labelledTerms:new Set,labelCache:new Map,resetLabel:yD,zoomLockLabel:Fv,zoomInLabel:wD,zoomOutLabel:CD,iconColor:kD,zoomEnabled:!1,errorMessage:"",errorConnectivities:""}},mounted(){this.refreshCache(),this.loadCacheData(),this.run().then(t=>{this.showGraph(this.entry)})},methods:{loadCacheData:function(){const t=sessionStorage.getItem("connectivity-graph-source"),e=sessionStorage.getItem("connectivity-graph-labels"),r=sessionStorage.getItem("connectivity-graph-pathlist"),n=sessionStorage.getItem("connectivity-graph-schema-version");if(t&&(this.selectedSource=t),r&&(this.pathList=JSON.parse(r)),e){const a=JSON.parse(e);this.labelCache=new Map(Object.entries(a))}n&&(this.schemaVersion=n)},removeAllCacheData:function(){["connectivity-graph-expiry","connectivity-graph-source","connectivity-graph-labels","connectivity-graph-pathlist","connectivity-graph-schema-version"].forEach(e=>{sessionStorage.removeItem(e)})},refreshCache:function(){const t=sessionStorage.getItem("connectivity-graph-expiry");new Date().getTime()>t&&this.removeAllCacheData()},updateCacheExpiry:function(){const e=new Date().getTime()+mD;sessionStorage.setItem("connectivity-graph-expiry",e)},run:async function(){if(this.schemaVersion||(this.schemaVersion=await this.getSchemaVersion(),sessionStorage.setItem("connectivity-graph-schema-version",this.schemaVersion),this.updateCacheExpiry()),this.schemaVersion<gD){console.warn("No Server!");return}this.showSpinner(),this.selectedSource||(this.selectedSource=await this.setSourceList(),sessionStorage.setItem("connectivity-graph-source",this.selectedSource),this.updateCacheExpiry()),await this.setPathList(this.selectedSource),this.hideSpinner()},showGraph:async function(t){const e=this.$refs.graphCanvas;this.showSpinner(),this.connectivityGraph=new uD(this.labelCache,e),await this.connectivityGraph.addConnectivity(this.knowledgeByPath.get(t)),this.hideSpinner(),this.connectivityGraph.showConnectivity(e),this.selectedConnectivityData.length&&this.connectivityGraph.selectConnectivity(this.selectedConnectivityData),this.connectivityGraph.on("tap-node",r=>{const n=r.detail;this.$emit("tap-node",n)})},query:async function(t,e){const r=`${this.mapServer}knowledge/query/`,n={sql:t,params:e};try{const a=await fetch(r,{method:"POST",headers:{Accept:"application/json; charset=utf-8","Cache-Control":"no-store","Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`Cannot access ${r}`);return await a.json()}catch{return{values:[]}}},setSourceList:async function(){const t=await this.getJsonData(`${this.mapServer}knowledge/sources`),e=t?t.sources||[]:[];let r="";for(const n of e)n&&r===""&&(r=n);return r},loadPathData:async function(t){const e=await this.query(`select entity, knowledge from knowledge
42
+ `)),this.tooltip.style.left=`${r.renderedPosition.x}px`,this.tooltip.style.top=`${r.renderedPosition.y}px`,this.tooltip.style.maxWidth="240px",this.tooltip.style.zIndex=2,this.tooltip.hidden=!1,this.checkRightBoundary(r.renderedPosition.x)}moveNode(r){const n=r.target;this.tooltip.style.left=`${n.renderedPosition().x}px`,this.tooltip.style.top=`${n.renderedPosition().y}px`,this.checkRightBoundary(n.renderedPosition().x)}exitNode(r){this.tooltip.hidden=!0}tapNode(r){const n=r.target,a=n.data();let{label:i}=a;i&&n.isNode()&&n.selected()&&(i="",setTimeout(()=>{n.unselect()}));const s=Fc(i),l=new CustomEvent("tap-node",{detail:s});this.dispatchEvent(l)}on(r,n){this.addEventListener(r,n)}}const vD=t=>t&&t.charAt(0).toUpperCase()+t.slice(1),gD=1.3,mD=24*60*60*1e3,yD="Reset position",Fv="Lock zoom",bD="Unlock zoom",wD="Zoom in",CD="Zoom out",Av=.25,kD="#8300bf",xD=3e3,ED={name:"ConnectivityGraph",props:{entry:{type:String,default:""},mapServer:{type:String,default:""},selectedConnectivityData:{type:Array,default:[]}},data:function(){return{loading:!0,connectivityGraph:null,selectedSource:"",pathList:[],schemaVersion:"",knowledgeByPath:new Map,labelledTerms:new Set,labelCache:new Map,resetLabel:yD,zoomLockLabel:Fv,zoomInLabel:wD,zoomOutLabel:CD,iconColor:kD,zoomEnabled:!1,errorMessage:"",errorConnectivities:""}},mounted(){this.refreshCache(),this.loadCacheData(),this.run().then(t=>{this.showGraph(this.entry)})},methods:{loadCacheData:function(){const t=sessionStorage.getItem("connectivity-graph-source"),e=sessionStorage.getItem("connectivity-graph-labels"),r=sessionStorage.getItem("connectivity-graph-pathlist"),n=sessionStorage.getItem("connectivity-graph-schema-version");if(t&&(this.selectedSource=t),r&&(this.pathList=JSON.parse(r)),e){const a=JSON.parse(e);this.labelCache=new Map(Object.entries(a))}n&&(this.schemaVersion=n)},removeAllCacheData:function(){["connectivity-graph-expiry","connectivity-graph-source","connectivity-graph-labels","connectivity-graph-pathlist","connectivity-graph-schema-version"].forEach(e=>{sessionStorage.removeItem(e)})},refreshCache:function(){const t=sessionStorage.getItem("connectivity-graph-expiry");new Date().getTime()>t&&this.removeAllCacheData()},updateCacheExpiry:function(){const e=new Date().getTime()+mD;sessionStorage.setItem("connectivity-graph-expiry",e)},run:async function(){if(this.schemaVersion||(this.schemaVersion=await this.getSchemaVersion(),sessionStorage.setItem("connectivity-graph-schema-version",this.schemaVersion),this.updateCacheExpiry()),this.schemaVersion<gD){console.warn("No Server!");return}this.showSpinner(),this.selectedSource||(this.selectedSource=await this.setSourceList(),sessionStorage.setItem("connectivity-graph-source",this.selectedSource),this.updateCacheExpiry()),await this.setPathList(this.selectedSource),this.hideSpinner()},showGraph:async function(t){const e=this.$refs.graphCanvas;this.showSpinner(),this.connectivityGraph=new uD(this.labelCache,e),await this.connectivityGraph.addConnectivity(this.knowledgeByPath.get(t)),this.hideSpinner(),this.connectivityGraph.showConnectivity(e),this.selectedConnectivityData.length&&this.connectivityGraph.selectConnectivity(this.selectedConnectivityData),this.connectivityGraph.on("tap-node",r=>{const n=r.detail;this.$emit("tap-node",n)})},query:async function(t,e){const r=`${this.mapServer}knowledge/query/`,n={sql:t,params:e};try{const a=await fetch(r,{method:"POST",headers:{Accept:"application/json; charset=utf-8","Cache-Control":"no-store","Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`Cannot access ${r}`);return await a.json()}catch{return{values:[]}}},setSourceList:async function(){const t=await this.getJsonData(`${this.mapServer}knowledge/sources`),e=t?t.sources||[]:[];let r="";for(const n of e)n&&r===""&&(r=n);return r},loadPathData:async function(t){const e=await this.query(`select entity, knowledge from knowledge
43
43
  where entity like 'ilxtr:%' and source=?
44
44
  order by entity`,[t]);return e?e.values:[]},setPathList:async function(t){this.pathList.length||(this.pathList=await this.loadPathData(t),sessionStorage.setItem("connectivity-graph-pathlist",JSON.stringify(this.pathList)),this.updateCacheExpiry()),this.knowledgeByPath.clear(),this.labelledTerms=new Set;for(const[e,r]of this.pathList){const n=JSON.parse(r);"connectivity"in n&&(this.knowledgeByPath.set(e,n),this.cacheLabels(n))}return this.labelCache.size||await this.getCachedTermLabels(),""},getSchemaVersion:async function(){const t=await this.getJsonData(`${this.mapServer}knowledge/schema-version`);return t&&+t.version||0},getJsonData:async function(t){try{const e=await fetch(t,{method:"GET",headers:{Accept:"application/json; charset=utf-8","Cache-Control":"no-store","Content-Type":"application/json"}});return e.ok||console.error(`Cannot access ${t}`),await e.json()}catch{return null}},getCachedTermLabels:async function(){if(this.labelledTerms.size){const t=await this.query(`select entity, knowledge from knowledge
45
45
  where entity in (?${", ?".repeat(this.labelledTerms.size-1)})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/map-utilities",
3
- "version": "1.2.1-beta.0",
3
+ "version": "1.2.1-beta.1",
4
4
  "files": [
5
5
  "dist/*",
6
6
  "src/*",
@@ -415,7 +415,15 @@ class CytoscapeGraph extends EventTarget
415
415
  {
416
416
  const node = event.target
417
417
  const data = node.data()
418
- const { label } = data
418
+ let { label } = data
419
+
420
+ if (label && node.isNode() && node.selected()) {
421
+ label = ''
422
+ setTimeout(() => {
423
+ node.unselect()
424
+ })
425
+ }
426
+
419
427
  const connectivityData = getConnectivityData(label)
420
428
 
421
429
  const tapEvent = new CustomEvent('tap-node', {