polly-graph 0.1.9 → 0.1.10
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 +47 -6
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +47 -6
- package/package.json +6 -2
package/dist/index.cjs
CHANGED
|
@@ -5114,14 +5114,35 @@ function createNodeHover(nodeSelection, hoverStyle) {
|
|
|
5114
5114
|
if (hoverStyle) {
|
|
5115
5115
|
nodeSelection.on("mouseenter.hover", function(_event, node) {
|
|
5116
5116
|
const circle = this;
|
|
5117
|
+
if (circle.dataset.selected === "true") {
|
|
5118
|
+
return;
|
|
5119
|
+
}
|
|
5117
5120
|
circle.setAttribute("stroke", hoverStyle.stroke ?? node.style?.stroke ?? "#ffffff");
|
|
5118
5121
|
circle.setAttribute("stroke-width", String(hoverStyle.strokeWidth ?? node.style?.strokeWidth ?? 1.5));
|
|
5119
5122
|
circle.setAttribute("opacity", String(hoverStyle.opacity ?? node.style?.opacity ?? 1));
|
|
5120
5123
|
}).on("mouseleave.hover", function(_event, node) {
|
|
5121
5124
|
const circle = this;
|
|
5122
|
-
circle.
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
+
if (circle.dataset.selected === "true") {
|
|
5126
|
+
return;
|
|
5127
|
+
}
|
|
5128
|
+
circle.style.stroke = "";
|
|
5129
|
+
circle.style.strokeWidth = "";
|
|
5130
|
+
circle.style.opacity = "";
|
|
5131
|
+
if (!node.style?.stroke) {
|
|
5132
|
+
circle.setAttribute("stroke", "#ffffff");
|
|
5133
|
+
} else {
|
|
5134
|
+
circle.setAttribute("stroke", node.style.stroke);
|
|
5135
|
+
}
|
|
5136
|
+
if (!node.style?.strokeWidth) {
|
|
5137
|
+
circle.setAttribute("stroke-width", "1.5");
|
|
5138
|
+
} else {
|
|
5139
|
+
circle.setAttribute("stroke-width", String(node.style.strokeWidth));
|
|
5140
|
+
}
|
|
5141
|
+
if (!node.style?.opacity) {
|
|
5142
|
+
circle.setAttribute("opacity", "1");
|
|
5143
|
+
} else {
|
|
5144
|
+
circle.setAttribute("opacity", String(node.style.opacity));
|
|
5145
|
+
}
|
|
5125
5146
|
});
|
|
5126
5147
|
}
|
|
5127
5148
|
const svgElement = firstNode.ownerSVGElement;
|
|
@@ -5518,6 +5539,8 @@ function bindNodeTooltip(params) {
|
|
|
5518
5539
|
destroy: () => {
|
|
5519
5540
|
},
|
|
5520
5541
|
reposition: () => {
|
|
5542
|
+
},
|
|
5543
|
+
hide: () => {
|
|
5521
5544
|
}
|
|
5522
5545
|
};
|
|
5523
5546
|
}
|
|
@@ -5527,6 +5550,9 @@ function bindNodeTooltip(params) {
|
|
|
5527
5550
|
"mouseenter.tooltip",
|
|
5528
5551
|
function(event, node) {
|
|
5529
5552
|
const target = this;
|
|
5553
|
+
if (target.dataset.selected === "true") {
|
|
5554
|
+
return;
|
|
5555
|
+
}
|
|
5530
5556
|
activeTarget = target;
|
|
5531
5557
|
const customContent = params.tooltipConfig?.renderContent?.(node);
|
|
5532
5558
|
const content = customContent ?? getDefaultContent(node);
|
|
@@ -5536,6 +5562,11 @@ function bindNodeTooltip(params) {
|
|
|
5536
5562
|
"mousemove.tooltip",
|
|
5537
5563
|
function() {
|
|
5538
5564
|
const target = this;
|
|
5565
|
+
if (target.dataset.selected === "true") {
|
|
5566
|
+
activeTarget = null;
|
|
5567
|
+
tooltip.hide();
|
|
5568
|
+
return;
|
|
5569
|
+
}
|
|
5539
5570
|
activeTarget = target;
|
|
5540
5571
|
tooltip.move(target);
|
|
5541
5572
|
}
|
|
@@ -5552,12 +5583,16 @@ function bindNodeTooltip(params) {
|
|
|
5552
5583
|
}
|
|
5553
5584
|
tooltip.move(activeTarget);
|
|
5554
5585
|
}
|
|
5586
|
+
function hide() {
|
|
5587
|
+
activeTarget = null;
|
|
5588
|
+
tooltip.hide();
|
|
5589
|
+
}
|
|
5555
5590
|
function destroy() {
|
|
5556
5591
|
activeTarget = null;
|
|
5557
5592
|
params.selection.on(".tooltip", null);
|
|
5558
5593
|
tooltip.destroy();
|
|
5559
5594
|
}
|
|
5560
|
-
return { destroy, reposition };
|
|
5595
|
+
return { destroy, reposition, hide };
|
|
5561
5596
|
}
|
|
5562
5597
|
function getDefaultContent(node) {
|
|
5563
5598
|
return `
|
|
@@ -5787,17 +5822,22 @@ var SelectionManager = class {
|
|
|
5787
5822
|
layers;
|
|
5788
5823
|
linkMarkerSnapshots;
|
|
5789
5824
|
root;
|
|
5790
|
-
|
|
5825
|
+
tooltipBinding;
|
|
5826
|
+
constructor(eventEmitter, config, layers, linkMarkerSnapshots, root2, tooltipBinding) {
|
|
5791
5827
|
this.eventEmitter = eventEmitter;
|
|
5792
5828
|
this.config = config;
|
|
5793
5829
|
this.layers = layers;
|
|
5794
5830
|
this.linkMarkerSnapshots = linkMarkerSnapshots;
|
|
5795
5831
|
this.root = root2;
|
|
5832
|
+
this.tooltipBinding = tooltipBinding;
|
|
5796
5833
|
}
|
|
5797
5834
|
/**
|
|
5798
5835
|
* Select a node, automatically deselecting any current selection
|
|
5799
5836
|
*/
|
|
5800
5837
|
selectNode(nodeElement, nodeData) {
|
|
5838
|
+
if (this.tooltipBinding) {
|
|
5839
|
+
this.tooltipBinding.hide();
|
|
5840
|
+
}
|
|
5801
5841
|
this.clearHoverState();
|
|
5802
5842
|
this.clearSelection();
|
|
5803
5843
|
this.bringNodeToFront(nodeElement, nodeData);
|
|
@@ -6199,7 +6239,8 @@ var InteractionManager = class {
|
|
|
6199
6239
|
this.manager.config.interaction.selection,
|
|
6200
6240
|
this.manager.layers,
|
|
6201
6241
|
this.manager.linkMarkerSnapshots,
|
|
6202
|
-
this.manager.rootSelection
|
|
6242
|
+
this.manager.rootSelection,
|
|
6243
|
+
this.manager.tooltipBinding || void 0
|
|
6203
6244
|
);
|
|
6204
6245
|
this.setupSelectionHandlers(selections);
|
|
6205
6246
|
this.setupBackgroundClickHandler();
|
package/dist/index.d.cts
CHANGED
|
@@ -537,6 +537,12 @@ interface RenderableGraphLink {
|
|
|
537
537
|
readonly markerEnd: string;
|
|
538
538
|
}
|
|
539
539
|
|
|
540
|
+
interface NodeTooltipBinding {
|
|
541
|
+
destroy(): void;
|
|
542
|
+
reposition(): void;
|
|
543
|
+
hide(): void;
|
|
544
|
+
}
|
|
545
|
+
|
|
540
546
|
/**
|
|
541
547
|
* Centralized selection management for graph nodes and links.
|
|
542
548
|
* Simplifies selection logic and ensures consistent behavior.
|
|
@@ -560,7 +566,8 @@ declare class SelectionManager {
|
|
|
560
566
|
private readonly layers;
|
|
561
567
|
private readonly linkMarkerSnapshots;
|
|
562
568
|
private readonly root;
|
|
563
|
-
|
|
569
|
+
private readonly tooltipBinding?;
|
|
570
|
+
constructor(eventEmitter: TypedGraphEventEmitter, config: SelectionInteractionConfig, layers: GraphLayers, linkMarkerSnapshots: Map<SVGLineElement, string | null>, root: Selection<SVGGElement, unknown, null, undefined>, tooltipBinding?: NodeTooltipBinding);
|
|
564
571
|
/**
|
|
565
572
|
* Select a node, automatically deselecting any current selection
|
|
566
573
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -537,6 +537,12 @@ interface RenderableGraphLink {
|
|
|
537
537
|
readonly markerEnd: string;
|
|
538
538
|
}
|
|
539
539
|
|
|
540
|
+
interface NodeTooltipBinding {
|
|
541
|
+
destroy(): void;
|
|
542
|
+
reposition(): void;
|
|
543
|
+
hide(): void;
|
|
544
|
+
}
|
|
545
|
+
|
|
540
546
|
/**
|
|
541
547
|
* Centralized selection management for graph nodes and links.
|
|
542
548
|
* Simplifies selection logic and ensures consistent behavior.
|
|
@@ -560,7 +566,8 @@ declare class SelectionManager {
|
|
|
560
566
|
private readonly layers;
|
|
561
567
|
private readonly linkMarkerSnapshots;
|
|
562
568
|
private readonly root;
|
|
563
|
-
|
|
569
|
+
private readonly tooltipBinding?;
|
|
570
|
+
constructor(eventEmitter: TypedGraphEventEmitter, config: SelectionInteractionConfig, layers: GraphLayers, linkMarkerSnapshots: Map<SVGLineElement, string | null>, root: Selection<SVGGElement, unknown, null, undefined>, tooltipBinding?: NodeTooltipBinding);
|
|
564
571
|
/**
|
|
565
572
|
* Select a node, automatically deselecting any current selection
|
|
566
573
|
*/
|
package/dist/index.js
CHANGED
|
@@ -5082,14 +5082,35 @@ function createNodeHover(nodeSelection, hoverStyle) {
|
|
|
5082
5082
|
if (hoverStyle) {
|
|
5083
5083
|
nodeSelection.on("mouseenter.hover", function(_event, node) {
|
|
5084
5084
|
const circle = this;
|
|
5085
|
+
if (circle.dataset.selected === "true") {
|
|
5086
|
+
return;
|
|
5087
|
+
}
|
|
5085
5088
|
circle.setAttribute("stroke", hoverStyle.stroke ?? node.style?.stroke ?? "#ffffff");
|
|
5086
5089
|
circle.setAttribute("stroke-width", String(hoverStyle.strokeWidth ?? node.style?.strokeWidth ?? 1.5));
|
|
5087
5090
|
circle.setAttribute("opacity", String(hoverStyle.opacity ?? node.style?.opacity ?? 1));
|
|
5088
5091
|
}).on("mouseleave.hover", function(_event, node) {
|
|
5089
5092
|
const circle = this;
|
|
5090
|
-
circle.
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
+
if (circle.dataset.selected === "true") {
|
|
5094
|
+
return;
|
|
5095
|
+
}
|
|
5096
|
+
circle.style.stroke = "";
|
|
5097
|
+
circle.style.strokeWidth = "";
|
|
5098
|
+
circle.style.opacity = "";
|
|
5099
|
+
if (!node.style?.stroke) {
|
|
5100
|
+
circle.setAttribute("stroke", "#ffffff");
|
|
5101
|
+
} else {
|
|
5102
|
+
circle.setAttribute("stroke", node.style.stroke);
|
|
5103
|
+
}
|
|
5104
|
+
if (!node.style?.strokeWidth) {
|
|
5105
|
+
circle.setAttribute("stroke-width", "1.5");
|
|
5106
|
+
} else {
|
|
5107
|
+
circle.setAttribute("stroke-width", String(node.style.strokeWidth));
|
|
5108
|
+
}
|
|
5109
|
+
if (!node.style?.opacity) {
|
|
5110
|
+
circle.setAttribute("opacity", "1");
|
|
5111
|
+
} else {
|
|
5112
|
+
circle.setAttribute("opacity", String(node.style.opacity));
|
|
5113
|
+
}
|
|
5093
5114
|
});
|
|
5094
5115
|
}
|
|
5095
5116
|
const svgElement = firstNode.ownerSVGElement;
|
|
@@ -5486,6 +5507,8 @@ function bindNodeTooltip(params) {
|
|
|
5486
5507
|
destroy: () => {
|
|
5487
5508
|
},
|
|
5488
5509
|
reposition: () => {
|
|
5510
|
+
},
|
|
5511
|
+
hide: () => {
|
|
5489
5512
|
}
|
|
5490
5513
|
};
|
|
5491
5514
|
}
|
|
@@ -5495,6 +5518,9 @@ function bindNodeTooltip(params) {
|
|
|
5495
5518
|
"mouseenter.tooltip",
|
|
5496
5519
|
function(event, node) {
|
|
5497
5520
|
const target = this;
|
|
5521
|
+
if (target.dataset.selected === "true") {
|
|
5522
|
+
return;
|
|
5523
|
+
}
|
|
5498
5524
|
activeTarget = target;
|
|
5499
5525
|
const customContent = params.tooltipConfig?.renderContent?.(node);
|
|
5500
5526
|
const content = customContent ?? getDefaultContent(node);
|
|
@@ -5504,6 +5530,11 @@ function bindNodeTooltip(params) {
|
|
|
5504
5530
|
"mousemove.tooltip",
|
|
5505
5531
|
function() {
|
|
5506
5532
|
const target = this;
|
|
5533
|
+
if (target.dataset.selected === "true") {
|
|
5534
|
+
activeTarget = null;
|
|
5535
|
+
tooltip.hide();
|
|
5536
|
+
return;
|
|
5537
|
+
}
|
|
5507
5538
|
activeTarget = target;
|
|
5508
5539
|
tooltip.move(target);
|
|
5509
5540
|
}
|
|
@@ -5520,12 +5551,16 @@ function bindNodeTooltip(params) {
|
|
|
5520
5551
|
}
|
|
5521
5552
|
tooltip.move(activeTarget);
|
|
5522
5553
|
}
|
|
5554
|
+
function hide() {
|
|
5555
|
+
activeTarget = null;
|
|
5556
|
+
tooltip.hide();
|
|
5557
|
+
}
|
|
5523
5558
|
function destroy() {
|
|
5524
5559
|
activeTarget = null;
|
|
5525
5560
|
params.selection.on(".tooltip", null);
|
|
5526
5561
|
tooltip.destroy();
|
|
5527
5562
|
}
|
|
5528
|
-
return { destroy, reposition };
|
|
5563
|
+
return { destroy, reposition, hide };
|
|
5529
5564
|
}
|
|
5530
5565
|
function getDefaultContent(node) {
|
|
5531
5566
|
return `
|
|
@@ -5755,17 +5790,22 @@ var SelectionManager = class {
|
|
|
5755
5790
|
layers;
|
|
5756
5791
|
linkMarkerSnapshots;
|
|
5757
5792
|
root;
|
|
5758
|
-
|
|
5793
|
+
tooltipBinding;
|
|
5794
|
+
constructor(eventEmitter, config, layers, linkMarkerSnapshots, root2, tooltipBinding) {
|
|
5759
5795
|
this.eventEmitter = eventEmitter;
|
|
5760
5796
|
this.config = config;
|
|
5761
5797
|
this.layers = layers;
|
|
5762
5798
|
this.linkMarkerSnapshots = linkMarkerSnapshots;
|
|
5763
5799
|
this.root = root2;
|
|
5800
|
+
this.tooltipBinding = tooltipBinding;
|
|
5764
5801
|
}
|
|
5765
5802
|
/**
|
|
5766
5803
|
* Select a node, automatically deselecting any current selection
|
|
5767
5804
|
*/
|
|
5768
5805
|
selectNode(nodeElement, nodeData) {
|
|
5806
|
+
if (this.tooltipBinding) {
|
|
5807
|
+
this.tooltipBinding.hide();
|
|
5808
|
+
}
|
|
5769
5809
|
this.clearHoverState();
|
|
5770
5810
|
this.clearSelection();
|
|
5771
5811
|
this.bringNodeToFront(nodeElement, nodeData);
|
|
@@ -6167,7 +6207,8 @@ var InteractionManager = class {
|
|
|
6167
6207
|
this.manager.config.interaction.selection,
|
|
6168
6208
|
this.manager.layers,
|
|
6169
6209
|
this.manager.linkMarkerSnapshots,
|
|
6170
|
-
this.manager.rootSelection
|
|
6210
|
+
this.manager.rootSelection,
|
|
6211
|
+
this.manager.tooltipBinding || void 0
|
|
6171
6212
|
);
|
|
6172
6213
|
this.setupSelectionHandlers(selections);
|
|
6173
6214
|
this.setupBackgroundClickHandler();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polly-graph",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Reusable D3-based graph visualization SDK with configurable nodes, links, labels, interactions, and layout behaviors.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Badal",
|
|
@@ -52,7 +52,11 @@
|
|
|
52
52
|
"lint": "eslint \"src/**/*.ts\"",
|
|
53
53
|
"typecheck": "tsc --noEmit",
|
|
54
54
|
"test": "vitest run --passWithNoTests",
|
|
55
|
-
"prepublishOnly": "npm run lint && npm run typecheck && npm run test && npm run build"
|
|
55
|
+
"prepublishOnly": "npm run lint && npm run typecheck && npm run test && npm run build",
|
|
56
|
+
"version:patch": "npm version patch",
|
|
57
|
+
"version:minor": "npm version minor",
|
|
58
|
+
"version:major": "npm version major",
|
|
59
|
+
"version:prerelease": "npm version prerelease"
|
|
56
60
|
},
|
|
57
61
|
"dependencies": {
|
|
58
62
|
"d3": "7.9.0"
|