@abi-software/map-utilities 1.1.3-beta.4 → 1.1.3-beta.6

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.
@@ -28364,8 +28364,9 @@ Ea.warnings = function(t) {
28364
28364
  };
28365
28365
  Ea.version = ZL;
28366
28366
  Ea.stylesheet = Ea.Stylesheet = o0;
28367
- let jL = class {
28368
- constructor(e, r) {
28367
+ let jL = class extends EventTarget {
28368
+ constructor(r, n) {
28369
+ super();
28369
28370
  Kr(this, "cyg", null);
28370
28371
  Kr(this, "nodes", []);
28371
28372
  Kr(this, "edges", []);
@@ -28373,16 +28374,16 @@ let jL = class {
28373
28374
  Kr(this, "dendrites", []);
28374
28375
  Kr(this, "labelCache", /* @__PURE__ */ new Map());
28375
28376
  Kr(this, "graphCanvas", null);
28376
- this.labelCache = e, this.graphCanvas = r;
28377
- }
28378
- async addConnectivity(e) {
28379
- if (this.axons = e.axons.map((r) => JSON.stringify(r)), this.dendrites = e.dendrites.map((r) => JSON.stringify(r)), e.connectivity.length)
28380
- for (const r of e.connectivity) {
28381
- const n = await this.graphNode(r[0]), a = await this.graphNode(r[1]);
28382
- this.nodes.push(n), this.nodes.push(a), this.edges.push({
28383
- id: `${n.id}_${a.id}`,
28384
- source: n.id,
28385
- target: a.id
28377
+ this.labelCache = r, this.graphCanvas = n;
28378
+ }
28379
+ async addConnectivity(r) {
28380
+ if (this.axons = r.axons.map((n) => JSON.stringify(n)), this.dendrites = r.dendrites.map((n) => JSON.stringify(n)), r.connectivity.length)
28381
+ for (const n of r.connectivity) {
28382
+ const a = await this.graphNode(n[0]), i = await this.graphNode(n[1]);
28383
+ this.nodes.push(a), this.nodes.push(i), this.edges.push({
28384
+ id: `${a.id}_${i.id}`,
28385
+ source: a.id,
28386
+ target: i.id
28386
28387
  });
28387
28388
  }
28388
28389
  else
@@ -28391,43 +28392,51 @@ let jL = class {
28391
28392
  label: "NO PATHS"
28392
28393
  });
28393
28394
  }
28394
- showConnectivity(e) {
28395
- this.cyg = new JL(this, e);
28395
+ showConnectivity(r) {
28396
+ this.cyg = new JL(this, r), this.cyg.on("tap-node", (n) => {
28397
+ const a = new CustomEvent("tap-node", {
28398
+ detail: n.detail
28399
+ });
28400
+ this.dispatchEvent(a);
28401
+ });
28396
28402
  }
28397
28403
  clearConnectivity() {
28398
- var e;
28399
- (e = this.cyg) != null && e.cy && (this.cyg.cy.remove(), this.cyg.cy = null);
28404
+ var r;
28405
+ (r = this.cyg) != null && r.cy && (this.cyg.cy.remove(), this.cyg.cy = null);
28400
28406
  }
28401
28407
  reset() {
28402
- var e;
28403
- (e = this.cyg) != null && e.cy && this.cyg.cy.reset();
28404
- }
28405
- enableZoom(e) {
28406
28408
  var r;
28407
- (r = this.cyg) != null && r.cy && this.cyg.cy.userZoomingEnabled(e);
28409
+ (r = this.cyg) != null && r.cy && this.cyg.cy.reset();
28410
+ }
28411
+ enableZoom(r) {
28412
+ var n;
28413
+ (n = this.cyg) != null && n.cy && this.cyg.cy.userZoomingEnabled(r);
28408
28414
  }
28409
28415
  get elements() {
28410
28416
  return [
28411
- ...this.nodes.map((e) => ({ data: e })),
28412
- ...this.edges.map((e) => ({ data: e }))
28417
+ ...this.nodes.map((r) => ({ data: r })),
28418
+ ...this.edges.map((r) => ({ data: r }))
28413
28419
  ];
28414
28420
  }
28415
28421
  get roots() {
28416
28422
  return this.dendrites;
28417
28423
  }
28418
- async graphNode(e) {
28419
- const r = JSON.stringify(e), n = [e[0], ...e[1]], a = [];
28420
- for (const o of n) {
28421
- const s = this.labelCache.has(o) ? this.labelCache.get(o) : "";
28422
- a.push(s);
28424
+ async graphNode(r) {
28425
+ const n = JSON.stringify(r), a = [r[0], ...r[1]], i = [];
28426
+ for (const s of a) {
28427
+ const u = this.labelCache.has(s) ? this.labelCache.get(s) : "";
28428
+ i.push(u);
28423
28429
  }
28424
- n.push(...a);
28425
- const i = {
28426
- id: r,
28427
- label: n.join(`
28430
+ a.push(...i);
28431
+ const o = {
28432
+ id: n,
28433
+ label: a.join(`
28428
28434
  `)
28429
28435
  };
28430
- return this.axons.includes(r) ? this.dendrites.includes(r) ? i["both-a-d"] = !0 : i.axon = !0 : this.dendrites.includes(r) && (i.dendrite = !0), i;
28436
+ return this.axons.includes(n) ? this.dendrites.includes(n) ? o["both-a-d"] = !0 : o.axon = !0 : this.dendrites.includes(n) && (o.dendrite = !0), o;
28437
+ }
28438
+ on(r, n) {
28439
+ this.addEventListener(r, n);
28431
28440
  }
28432
28441
  };
28433
28442
  const QL = [
@@ -28471,44 +28480,54 @@ const QL = [
28471
28480
  }
28472
28481
  }
28473
28482
  ];
28474
- class JL {
28475
- constructor(e, r) {
28483
+ class JL extends EventTarget {
28484
+ constructor(r, n) {
28485
+ var a;
28486
+ super();
28476
28487
  Kr(this, "cy");
28477
28488
  Kr(this, "tooltip");
28478
- var n;
28479
28489
  this.cy = Ea({
28480
- container: r,
28481
- elements: e.elements,
28490
+ container: n,
28491
+ elements: r.elements,
28482
28492
  layout: {
28483
28493
  name: "breadthfirst",
28484
28494
  circle: !1,
28485
- roots: e.roots
28495
+ roots: r.roots
28486
28496
  },
28487
28497
  directed: !0,
28488
28498
  style: QL,
28489
28499
  minZoom: 0.5,
28490
28500
  maxZoom: 10,
28491
28501
  wheelSensitivity: 0.4
28492
- }).on("mouseover", "node", this.overNode.bind(this)).on("mouseout", "node", this.exitNode.bind(this)).on("position", "node", this.moveNode.bind(this)), this.tooltip = document.createElement("div"), this.tooltip.className = "cy-graph-tooltip", this.tooltip.hidden = !0, (n = r == null ? void 0 : r.lastChild) == null || n.appendChild(this.tooltip);
28502
+ }).on("mouseover", "node", this.overNode.bind(this)).on("mouseout", "node", this.exitNode.bind(this)).on("position", "node", this.moveNode.bind(this)).on("tap", "node", 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);
28493
28503
  }
28494
28504
  remove() {
28495
28505
  this.cy && this.cy.destroy();
28496
28506
  }
28497
- checkRightBoundary(e) {
28498
- var r;
28499
- e + this.tooltip.offsetWidth >= ((r = this.tooltip.parentElement) == null ? void 0 : r.offsetWidth) && (this.tooltip.style.left = `${e - this.tooltip.offsetWidth}px`);
28507
+ checkRightBoundary(r) {
28508
+ var n;
28509
+ r + this.tooltip.offsetWidth >= ((n = this.tooltip.parentElement) == null ? void 0 : n.offsetWidth) && (this.tooltip.style.left = `${r - this.tooltip.offsetWidth}px`);
28500
28510
  }
28501
- overNode(e) {
28502
- const r = e.target;
28503
- this.tooltip.innerText = r.data().label, this.tooltip.style.left = `${e.renderedPosition.x}px`, this.tooltip.style.top = `${e.renderedPosition.y}px`, this.tooltip.hidden = !1, this.checkRightBoundary(e.renderedPosition.x);
28511
+ overNode(r) {
28512
+ const n = r.target;
28513
+ this.tooltip.innerText = n.data().label, this.tooltip.style.left = `${r.renderedPosition.x}px`, this.tooltip.style.top = `${r.renderedPosition.y}px`, this.tooltip.hidden = !1, this.checkRightBoundary(r.renderedPosition.x);
28504
28514
  }
28505
- moveNode(e) {
28506
- const r = e.target;
28507
- this.tooltip.style.left = `${r.renderedPosition().x}px`, this.tooltip.style.top = `${r.renderedPosition().y}px`, this.checkRightBoundary(r.renderedPosition().x);
28515
+ moveNode(r) {
28516
+ const n = r.target;
28517
+ this.tooltip.style.left = `${n.renderedPosition().x}px`, this.tooltip.style.top = `${n.renderedPosition().y}px`, this.checkRightBoundary(n.renderedPosition().x);
28508
28518
  }
28509
- exitNode(e) {
28519
+ exitNode(r) {
28510
28520
  this.tooltip.hidden = !0;
28511
28521
  }
28522
+ tapNode(r) {
28523
+ const a = r.target.data(), i = new CustomEvent("tap-node", {
28524
+ detail: a
28525
+ });
28526
+ this.dispatchEvent(i);
28527
+ }
28528
+ on(r, n) {
28529
+ this.addEventListener(r, n);
28530
+ }
28512
28531
  }
28513
28532
  const eF = 1.3, tF = 24 * 60 * 60 * 1e3, rF = "Reset position", fv = "Lock zoom (to scroll)", nF = "Unlock zoom", aF = "#8300bf", iF = {
28514
28533
  name: "ConnectivityGraph",
@@ -28583,7 +28602,11 @@ const eF = 1.3, tF = 24 * 60 * 60 * 1e3, rF = "Reset position", fv = "Lock zoom
28583
28602
  },
28584
28603
  showGraph: async function(t) {
28585
28604
  const e = this.$refs.graphCanvas;
28586
- this.showSpinner(), this.connectivityGraph = new jL(this.labelCache, e), await this.connectivityGraph.addConnectivity(this.knowledgeByPath.get(t)), this.hideSpinner(), this.connectivityGraph.showConnectivity(e);
28605
+ this.showSpinner(), this.connectivityGraph = new jL(this.labelCache, e), await this.connectivityGraph.addConnectivity(this.knowledgeByPath.get(t)), this.hideSpinner(), this.connectivityGraph.showConnectivity(e), this.connectivityGraph.on("tap-node", (r) => {
28606
+ const { label: n } = r.detail, a = n.split(`
28607
+ `);
28608
+ this.$emit("tap-node", a);
28609
+ });
28587
28610
  },
28588
28611
  query: async function(t, e) {
28589
28612
  const r = `${this.mapServer}knowledge/query/`, n = { sql: t, params: e };
@@ -28652,15 +28675,19 @@ const eF = 1.3, tF = 24 * 60 * 60 * 1e3, rF = "Reset position", fv = "Lock zoom
28652
28675
  getCachedTermLabels: async function() {
28653
28676
  if (this.labelledTerms.size) {
28654
28677
  const t = await this.query(
28655
- `
28656
- select entity, label from labels
28657
- where entity in (?${", ?".repeat(this.labelledTerms.size - 1)})`,
28678
+ `select entity, knowledge from knowledge
28679
+ where entity in (?${", ?".repeat(this.labelledTerms.size - 1)})
28680
+ order by source desc`,
28658
28681
  [...this.labelledTerms.values()]
28659
28682
  );
28660
- for (const r of t.values)
28661
- this.labelCache.set(r[0], r[1]);
28662
- const e = Object.fromEntries(this.labelCache);
28663
- sessionStorage.setItem("connectivity-graph-labels", JSON.stringify(e)), this.updateCacheExpiry();
28683
+ let e = null;
28684
+ for (const [n, a] of t.values)
28685
+ if (n !== e) {
28686
+ const i = JSON.parse(a);
28687
+ this.labelCache.set(n, i.label || n), e = n;
28688
+ }
28689
+ const r = Object.fromEntries(this.labelCache);
28690
+ sessionStorage.setItem("connectivity-graph-labels", JSON.stringify(r)), this.updateCacheExpiry();
28664
28691
  }
28665
28692
  },
28666
28693
  cacheNodeLabels: function(t) {
@@ -28690,7 +28717,7 @@ const eF = 1.3, tF = 24 * 60 * 60 * 1e3, rF = "Reset position", fv = "Lock zoom
28690
28717
  }, oF = { class: "connectivity-graph" }, sF = {
28691
28718
  ref: "graphCanvas",
28692
28719
  class: "graph-canvas"
28693
- }, lF = { class: "control-panel" }, uF = /* @__PURE__ */ P0('<div class="node-key" data-v-ec98b14b><div class="key-head" data-v-ec98b14b>Node type:</div><div data-v-ec98b14b><div data-v-ec98b14b><span data-v-ec98b14b>Node:</span><span class="key-box" style="background:#80F0F0;" data-v-ec98b14b></span></div><div data-v-ec98b14b><span data-v-ec98b14b>Axon:</span><span class="key-box" style="background:green;" data-v-ec98b14b></span></div><div data-v-ec98b14b><span data-v-ec98b14b>Dendrite:</span><span class="key-box" style="background:red;" data-v-ec98b14b></span></div><div data-v-ec98b14b><span data-v-ec98b14b>Both:</span><span class="key-box" style="background:gray;" data-v-ec98b14b></span></div></div></div>', 1), cF = { class: "tools" }, dF = { class: "visually-hidden" }, fF = { class: "visually-hidden" };
28720
+ }, lF = { class: "control-panel" }, uF = /* @__PURE__ */ P0('<div class="node-key" data-v-528570f4><div class="key-head" data-v-528570f4>Node type:</div><div data-v-528570f4><div data-v-528570f4><span data-v-528570f4>Node:</span><span class="key-box" style="background:#80F0F0;" data-v-528570f4></span></div><div data-v-528570f4><span data-v-528570f4>Axon:</span><span class="key-box" style="background:green;" data-v-528570f4></span></div><div data-v-528570f4><span data-v-528570f4>Dendrite:</span><span class="key-box" style="background:red;" data-v-528570f4></span></div><div data-v-528570f4><span data-v-528570f4>Both:</span><span class="key-box" style="background:gray;" data-v-528570f4></span></div></div></div>', 1), cF = { class: "tools" }, dF = { class: "visually-hidden" }, fF = { class: "visually-hidden" };
28694
28721
  function vF(t, e, r, n, a, i) {
28695
28722
  const o = Xb, s = Vt, u = pn, l = xo, c = g2, d = w2, v = tc;
28696
28723
  return je(($(), Z("div", oF, [
@@ -28754,7 +28781,7 @@ function vF(t, e, r, n, a, i) {
28754
28781
  [v, t.loading]
28755
28782
  ]);
28756
28783
  }
28757
- const CF = /* @__PURE__ */ rn(iF, [["render", vF], ["__scopeId", "data-v-ec98b14b"]]);
28784
+ const CF = /* @__PURE__ */ rn(iF, [["render", vF], ["__scopeId", "data-v-528570f4"]]);
28758
28785
  export {
28759
28786
  CF as ConnectivityGraph,
28760
28787
  wF as CopyToClipboard,