polly-graph 0.1.14 → 0.1.15
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.
- package/dist/index.cjs +55 -7
- package/dist/index.js +55 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4868,10 +4868,7 @@ function renderLinkLabels(params, links) {
|
|
|
4868
4868
|
const labelSelection = params.root.select('[data-layer="link-labels"]').selectAll(".link-label").data(renderableLinks, (item) => getLinkKey2(item.link)).join("g").attr("class", "link-label").style("opacity", (item) => {
|
|
4869
4869
|
const visibility = item.style.label.visibility ?? "always";
|
|
4870
4870
|
return visibility === "always" ? 1 : 0;
|
|
4871
|
-
}).style("pointer-events", (
|
|
4872
|
-
const visibility = item.style.label.visibility ?? "always";
|
|
4873
|
-
return visibility === "always" ? "auto" : "none";
|
|
4874
|
-
}).style("cursor", "pointer");
|
|
4871
|
+
}).style("pointer-events", "none").style("cursor", "pointer");
|
|
4875
4872
|
labelSelection.selectAll("rect").data((item) => [item]).join("rect").attr("rx", (item) => item.style.label.borderRadius).attr("ry", (item) => item.style.label.borderRadius).attr("fill", (item) => item.style.label.backgroundFill).attr("stroke", (item) => item.style.label.borderColor).attr("stroke-width", (item) => item.style.label.borderWidth);
|
|
4876
4873
|
const textSelection = labelSelection.selectAll("text").data((item) => [item]).join("text").attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("font-size", (item) => item.style.label.fontSize).attr("fill", (item) => item.style.label.textColor).text((item) => item.link.label ?? "");
|
|
4877
4874
|
textSelection.each(function(item) {
|
|
@@ -5579,7 +5576,7 @@ function createLinkHover(linkSelection, hoverStyle) {
|
|
|
5579
5576
|
}
|
|
5580
5577
|
}
|
|
5581
5578
|
const labelSelection2 = root2.select('[data-layer="link-labels"]').selectAll(".link-label");
|
|
5582
|
-
labelSelection2.filter((item) => item.link === renderableLink.link && item.style.label.visibility === "hover").style("opacity", 1)
|
|
5579
|
+
labelSelection2.filter((item) => item.link === renderableLink.link && item.style.label.visibility === "hover").style("opacity", 1);
|
|
5583
5580
|
}).on("mouseleave.hover", function(_event, renderableLink) {
|
|
5584
5581
|
const hoveredElement = this;
|
|
5585
5582
|
let targetLinkElement;
|
|
@@ -5876,7 +5873,47 @@ function getDefaultContent(node) {
|
|
|
5876
5873
|
|
|
5877
5874
|
// src/utils/node-link-selection.utils.ts
|
|
5878
5875
|
function createLinkHitArea(root2, linkSelection) {
|
|
5879
|
-
return root2.select('[data-layer="links"]').selectAll("
|
|
5876
|
+
return root2.select('[data-layer="links"]').selectAll("rect.link-hit-area").data(linkSelection.data()).join("rect").attr("class", "link-hit-area").attr("fill", "rgba(0,0,0,0)").style("pointer-events", "fill").style("cursor", "pointer").attr("opacity", 0).each(function(item) {
|
|
5877
|
+
const rectElement = this;
|
|
5878
|
+
updateHitAreaDimensions(rectElement, item, root2);
|
|
5879
|
+
});
|
|
5880
|
+
}
|
|
5881
|
+
function updateHitAreaDimensions(rectElement, item, root2) {
|
|
5882
|
+
const source = item.link.source;
|
|
5883
|
+
const target = item.link.target;
|
|
5884
|
+
if (!source.x || !source.y || !target.x || !target.y) return;
|
|
5885
|
+
const midX = (source.x + target.x) / 2;
|
|
5886
|
+
const midY = (source.y + target.y) / 2;
|
|
5887
|
+
const linkPadding = Math.max(item.style.strokeWidth || 2, item.style.arrow.size) * 2;
|
|
5888
|
+
let width = linkPadding;
|
|
5889
|
+
let height = linkPadding;
|
|
5890
|
+
if (item.link.label) {
|
|
5891
|
+
const labelElement = root2.select('[data-layer="link-labels"]').selectAll(".link-label").filter((labelItem) => labelItem.link === item.link).node();
|
|
5892
|
+
if (labelElement) {
|
|
5893
|
+
try {
|
|
5894
|
+
const textElement = labelElement.querySelector("text");
|
|
5895
|
+
const rectElement2 = labelElement.querySelector("rect");
|
|
5896
|
+
if (textElement && rectElement2) {
|
|
5897
|
+
const bbox = textElement.getBBox();
|
|
5898
|
+
const labelWidth = bbox.width + item.style.label.paddingX * 2;
|
|
5899
|
+
const labelHeight = bbox.height + item.style.label.paddingY * 2;
|
|
5900
|
+
width = Math.max(width, labelWidth + 10);
|
|
5901
|
+
height = Math.max(height, labelHeight + 10);
|
|
5902
|
+
}
|
|
5903
|
+
} catch {
|
|
5904
|
+
const text = item.link.label ?? "";
|
|
5905
|
+
const fontSize = item.style.label.fontSize;
|
|
5906
|
+
const estimatedWidth = text.length * fontSize * 0.6 + item.style.label.paddingX * 2 + 10;
|
|
5907
|
+
const estimatedHeight = fontSize + item.style.label.paddingY * 2 + 10;
|
|
5908
|
+
width = Math.max(width, estimatedWidth);
|
|
5909
|
+
height = Math.max(height, estimatedHeight);
|
|
5910
|
+
}
|
|
5911
|
+
}
|
|
5912
|
+
}
|
|
5913
|
+
rectElement.setAttribute("x", String(midX - width / 2));
|
|
5914
|
+
rectElement.setAttribute("y", String(midY - height / 2));
|
|
5915
|
+
rectElement.setAttribute("width", String(width));
|
|
5916
|
+
rectElement.setAttribute("height", String(height));
|
|
5880
5917
|
}
|
|
5881
5918
|
|
|
5882
5919
|
// src/utils/get-link-target-point.ts
|
|
@@ -6588,7 +6625,18 @@ var InteractionManager = class {
|
|
|
6588
6625
|
}
|
|
6589
6626
|
if (this.manager.simulation) {
|
|
6590
6627
|
this.manager.simulation.on("tick.hitarea", () => {
|
|
6591
|
-
linkHitAreaSelection.
|
|
6628
|
+
linkHitAreaSelection.each(function(item) {
|
|
6629
|
+
const source = item.link.source;
|
|
6630
|
+
const target = item.link.target;
|
|
6631
|
+
if (!source.x || !source.y || !target.x || !target.y) return;
|
|
6632
|
+
const rectElement = this;
|
|
6633
|
+
const midX = (source.x + target.x) / 2;
|
|
6634
|
+
const midY = (source.y + target.y) / 2;
|
|
6635
|
+
const width = parseFloat(rectElement.getAttribute("width") || "20");
|
|
6636
|
+
const height = parseFloat(rectElement.getAttribute("height") || "20");
|
|
6637
|
+
rectElement.setAttribute("x", String(midX - width / 2));
|
|
6638
|
+
rectElement.setAttribute("y", String(midY - height / 2));
|
|
6639
|
+
});
|
|
6592
6640
|
});
|
|
6593
6641
|
}
|
|
6594
6642
|
if (this.manager.selectionManager) {
|
package/dist/index.js
CHANGED
|
@@ -4836,10 +4836,7 @@ function renderLinkLabels(params, links) {
|
|
|
4836
4836
|
const labelSelection = params.root.select('[data-layer="link-labels"]').selectAll(".link-label").data(renderableLinks, (item) => getLinkKey2(item.link)).join("g").attr("class", "link-label").style("opacity", (item) => {
|
|
4837
4837
|
const visibility = item.style.label.visibility ?? "always";
|
|
4838
4838
|
return visibility === "always" ? 1 : 0;
|
|
4839
|
-
}).style("pointer-events", (
|
|
4840
|
-
const visibility = item.style.label.visibility ?? "always";
|
|
4841
|
-
return visibility === "always" ? "auto" : "none";
|
|
4842
|
-
}).style("cursor", "pointer");
|
|
4839
|
+
}).style("pointer-events", "none").style("cursor", "pointer");
|
|
4843
4840
|
labelSelection.selectAll("rect").data((item) => [item]).join("rect").attr("rx", (item) => item.style.label.borderRadius).attr("ry", (item) => item.style.label.borderRadius).attr("fill", (item) => item.style.label.backgroundFill).attr("stroke", (item) => item.style.label.borderColor).attr("stroke-width", (item) => item.style.label.borderWidth);
|
|
4844
4841
|
const textSelection = labelSelection.selectAll("text").data((item) => [item]).join("text").attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("font-size", (item) => item.style.label.fontSize).attr("fill", (item) => item.style.label.textColor).text((item) => item.link.label ?? "");
|
|
4845
4842
|
textSelection.each(function(item) {
|
|
@@ -5547,7 +5544,7 @@ function createLinkHover(linkSelection, hoverStyle) {
|
|
|
5547
5544
|
}
|
|
5548
5545
|
}
|
|
5549
5546
|
const labelSelection2 = root2.select('[data-layer="link-labels"]').selectAll(".link-label");
|
|
5550
|
-
labelSelection2.filter((item) => item.link === renderableLink.link && item.style.label.visibility === "hover").style("opacity", 1)
|
|
5547
|
+
labelSelection2.filter((item) => item.link === renderableLink.link && item.style.label.visibility === "hover").style("opacity", 1);
|
|
5551
5548
|
}).on("mouseleave.hover", function(_event, renderableLink) {
|
|
5552
5549
|
const hoveredElement = this;
|
|
5553
5550
|
let targetLinkElement;
|
|
@@ -5844,7 +5841,47 @@ function getDefaultContent(node) {
|
|
|
5844
5841
|
|
|
5845
5842
|
// src/utils/node-link-selection.utils.ts
|
|
5846
5843
|
function createLinkHitArea(root2, linkSelection) {
|
|
5847
|
-
return root2.select('[data-layer="links"]').selectAll("
|
|
5844
|
+
return root2.select('[data-layer="links"]').selectAll("rect.link-hit-area").data(linkSelection.data()).join("rect").attr("class", "link-hit-area").attr("fill", "rgba(0,0,0,0)").style("pointer-events", "fill").style("cursor", "pointer").attr("opacity", 0).each(function(item) {
|
|
5845
|
+
const rectElement = this;
|
|
5846
|
+
updateHitAreaDimensions(rectElement, item, root2);
|
|
5847
|
+
});
|
|
5848
|
+
}
|
|
5849
|
+
function updateHitAreaDimensions(rectElement, item, root2) {
|
|
5850
|
+
const source = item.link.source;
|
|
5851
|
+
const target = item.link.target;
|
|
5852
|
+
if (!source.x || !source.y || !target.x || !target.y) return;
|
|
5853
|
+
const midX = (source.x + target.x) / 2;
|
|
5854
|
+
const midY = (source.y + target.y) / 2;
|
|
5855
|
+
const linkPadding = Math.max(item.style.strokeWidth || 2, item.style.arrow.size) * 2;
|
|
5856
|
+
let width = linkPadding;
|
|
5857
|
+
let height = linkPadding;
|
|
5858
|
+
if (item.link.label) {
|
|
5859
|
+
const labelElement = root2.select('[data-layer="link-labels"]').selectAll(".link-label").filter((labelItem) => labelItem.link === item.link).node();
|
|
5860
|
+
if (labelElement) {
|
|
5861
|
+
try {
|
|
5862
|
+
const textElement = labelElement.querySelector("text");
|
|
5863
|
+
const rectElement2 = labelElement.querySelector("rect");
|
|
5864
|
+
if (textElement && rectElement2) {
|
|
5865
|
+
const bbox = textElement.getBBox();
|
|
5866
|
+
const labelWidth = bbox.width + item.style.label.paddingX * 2;
|
|
5867
|
+
const labelHeight = bbox.height + item.style.label.paddingY * 2;
|
|
5868
|
+
width = Math.max(width, labelWidth + 10);
|
|
5869
|
+
height = Math.max(height, labelHeight + 10);
|
|
5870
|
+
}
|
|
5871
|
+
} catch {
|
|
5872
|
+
const text = item.link.label ?? "";
|
|
5873
|
+
const fontSize = item.style.label.fontSize;
|
|
5874
|
+
const estimatedWidth = text.length * fontSize * 0.6 + item.style.label.paddingX * 2 + 10;
|
|
5875
|
+
const estimatedHeight = fontSize + item.style.label.paddingY * 2 + 10;
|
|
5876
|
+
width = Math.max(width, estimatedWidth);
|
|
5877
|
+
height = Math.max(height, estimatedHeight);
|
|
5878
|
+
}
|
|
5879
|
+
}
|
|
5880
|
+
}
|
|
5881
|
+
rectElement.setAttribute("x", String(midX - width / 2));
|
|
5882
|
+
rectElement.setAttribute("y", String(midY - height / 2));
|
|
5883
|
+
rectElement.setAttribute("width", String(width));
|
|
5884
|
+
rectElement.setAttribute("height", String(height));
|
|
5848
5885
|
}
|
|
5849
5886
|
|
|
5850
5887
|
// src/utils/get-link-target-point.ts
|
|
@@ -6556,7 +6593,18 @@ var InteractionManager = class {
|
|
|
6556
6593
|
}
|
|
6557
6594
|
if (this.manager.simulation) {
|
|
6558
6595
|
this.manager.simulation.on("tick.hitarea", () => {
|
|
6559
|
-
linkHitAreaSelection.
|
|
6596
|
+
linkHitAreaSelection.each(function(item) {
|
|
6597
|
+
const source = item.link.source;
|
|
6598
|
+
const target = item.link.target;
|
|
6599
|
+
if (!source.x || !source.y || !target.x || !target.y) return;
|
|
6600
|
+
const rectElement = this;
|
|
6601
|
+
const midX = (source.x + target.x) / 2;
|
|
6602
|
+
const midY = (source.y + target.y) / 2;
|
|
6603
|
+
const width = parseFloat(rectElement.getAttribute("width") || "20");
|
|
6604
|
+
const height = parseFloat(rectElement.getAttribute("height") || "20");
|
|
6605
|
+
rectElement.setAttribute("x", String(midX - width / 2));
|
|
6606
|
+
rectElement.setAttribute("y", String(midY - height / 2));
|
|
6607
|
+
});
|
|
6560
6608
|
});
|
|
6561
6609
|
}
|
|
6562
6610
|
if (this.manager.selectionManager) {
|
package/package.json
CHANGED