apextree 1.6.0 → 1.6.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.
package/README.md CHANGED
@@ -76,7 +76,7 @@ The layout can be configured by either setting the properties in the table below
76
76
  | groupLeafNodesSpacing | 10 | Spacing between stacked leaf nodes |
77
77
  | tooltipId | `apextree-tooltip-container` | The tooltip HTML element id |
78
78
  | tooltipTemplate | defaultNodeTemplate | The HTML template for tooltip |
79
- | tooltipMaxWidth | 300 | The max width of the tooltip in pixels |
79
+ | tooltipMaxWidth | undefined | The max width of the tooltip in pixels |
80
80
  | tooltipMinWidth | 100 | The min width of the tooltip in pixels |
81
81
  | tooltipBorderColor | `#BCBCBC` | The border color of tooltip |
82
82
  | tooltipBGColor | `#FFFFFF` | The background color of tooltip |
@@ -10081,7 +10081,7 @@ const applyButtonHoverEffects = (buttonGroup) => {
10081
10081
  buttonGroup.attr("style", "cursor: pointer;");
10082
10082
  });
10083
10083
  };
10084
- const highlightToPath = (selfNode, nodeMap, isHighlighted, options, chartContext) => {
10084
+ const highlightToPath = (selfNode, nodeMap, isHighlighted, options, chartContext, containerClassName) => {
10085
10085
  const nodeOptions = selfNode == null ? void 0 : selfNode.options;
10086
10086
  const nodeBorderWidth = (nodeOptions == null ? void 0 : nodeOptions.borderWidth) || options.borderWidth;
10087
10087
  let borderColor = (nodeOptions == null ? void 0 : nodeOptions.borderColor) || options.borderColor;
@@ -10091,7 +10091,7 @@ const highlightToPath = (selfNode, nodeMap, isHighlighted, options, chartContext
10091
10091
  backgroundColor = (nodeOptions == null ? void 0 : nodeOptions.nodeBGColorHover) || options.nodeBGColorHover;
10092
10092
  }
10093
10093
  const selfContentElement = chartContext.querySelector(
10094
- `[data-self='${selfNode.id}'] foreignObject div`
10094
+ `#${containerClassName} [data-self='${selfNode.id}'] foreignObject div`
10095
10095
  );
10096
10096
  if (selfContentElement && !selfNode.id.endsWith("_leafs")) {
10097
10097
  selfContentElement.style.borderWidth = `${nodeBorderWidth}px`;
@@ -10099,7 +10099,7 @@ const highlightToPath = (selfNode, nodeMap, isHighlighted, options, chartContext
10099
10099
  selfContentElement.style.backgroundColor = backgroundColor;
10100
10100
  }
10101
10101
  if (selfNode.parent) {
10102
- const edge = chartContext.getElementById(`${selfNode.parent}-${selfNode.id}`);
10102
+ const edge = chartContext.querySelector(`#${containerClassName} #${selfNode.parent}-${selfNode.id}`);
10103
10103
  if (isHighlighted) {
10104
10104
  setAttributes(edge, {
10105
10105
  stroke: options.edgeColorHover,
@@ -10112,7 +10112,7 @@ const highlightToPath = (selfNode, nodeMap, isHighlighted, options, chartContext
10112
10112
  });
10113
10113
  }
10114
10114
  if (selfNode.parent) {
10115
- highlightToPath(nodeMap[selfNode.parent], nodeMap, isHighlighted, options, chartContext);
10115
+ highlightToPath(nodeMap[selfNode.parent], nodeMap, isHighlighted, options, chartContext, containerClassName);
10116
10116
  }
10117
10117
  }
10118
10118
  };
@@ -16298,6 +16298,7 @@ class Graph2 extends Paper {
16298
16298
  const node = this.nodeMap[nodeId];
16299
16299
  const { options } = this;
16300
16300
  const {
16301
+ containerClassName,
16301
16302
  contentKey,
16302
16303
  direction,
16303
16304
  enableTooltip,
@@ -16366,14 +16367,28 @@ class Graph2 extends Paper {
16366
16367
  const { self: self2 } = this.node.dataset;
16367
16368
  const selfNode = graphInstance.nodeMap[self2];
16368
16369
  if (selfNode) {
16369
- highlightToPath(selfNode, graphInstance.nodeMap, true, options, graphInstance.chartContext);
16370
+ highlightToPath(
16371
+ selfNode,
16372
+ graphInstance.nodeMap,
16373
+ true,
16374
+ options,
16375
+ graphInstance.chartContext,
16376
+ containerClassName
16377
+ );
16370
16378
  }
16371
16379
  });
16372
16380
  group.on("mouseout", function() {
16373
16381
  const { self: self2 } = this.node.dataset;
16374
16382
  const selfNode = graphInstance.nodeMap[self2];
16375
16383
  if (selfNode) {
16376
- highlightToPath(selfNode, graphInstance.nodeMap, false, options, graphInstance.chartContext);
16384
+ highlightToPath(
16385
+ selfNode,
16386
+ graphInstance.nodeMap,
16387
+ false,
16388
+ options,
16389
+ graphInstance.chartContext,
16390
+ containerClassName
16391
+ );
16377
16392
  }
16378
16393
  });
16379
16394
  }
@@ -16420,6 +16435,7 @@ class Graph2 extends Paper {
16420
16435
  const { options } = this;
16421
16436
  const {
16422
16437
  borderRadius,
16438
+ containerClassName,
16423
16439
  contentKey,
16424
16440
  direction,
16425
16441
  enableExpandCollapse,
@@ -16481,14 +16497,28 @@ class Graph2 extends Paper {
16481
16497
  const { self: self2 } = this.node.dataset;
16482
16498
  const selfNode = graphInstance.nodeMap[self2];
16483
16499
  if (selfNode) {
16484
- highlightToPath(selfNode, graphInstance.nodeMap, true, options, graphInstance.chartContext);
16500
+ highlightToPath(
16501
+ selfNode,
16502
+ graphInstance.nodeMap,
16503
+ true,
16504
+ options,
16505
+ graphInstance.chartContext,
16506
+ containerClassName
16507
+ );
16485
16508
  }
16486
16509
  });
16487
16510
  group.on("mouseout", function() {
16488
16511
  const { self: self2 } = this.node.dataset;
16489
16512
  const selfNode = graphInstance.nodeMap[self2];
16490
16513
  if (selfNode) {
16491
- highlightToPath(selfNode, graphInstance.nodeMap, false, options, graphInstance.chartContext);
16514
+ highlightToPath(
16515
+ selfNode,
16516
+ graphInstance.nodeMap,
16517
+ false,
16518
+ options,
16519
+ graphInstance.chartContext,
16520
+ containerClassName
16521
+ );
16492
16522
  }
16493
16523
  });
16494
16524
  }
@@ -16572,7 +16602,12 @@ class ApexTree extends BaseChart {
16572
16602
  constructor(element, options = {}) {
16573
16603
  const instanceId = "tree_" + Math.random().toString(36).substr(2, 9);
16574
16604
  super(element, instanceId);
16575
- this.options = { ...DefaultOptions, ...options };
16605
+ const uniqueContainerClassName = options.containerClassName ? `${options.containerClassName}-${instanceId}` : `root-${instanceId}`;
16606
+ this.options = {
16607
+ ...DefaultOptions,
16608
+ ...options,
16609
+ containerClassName: uniqueContainerClassName
16610
+ };
16576
16611
  const { height: height2, width: width2 } = this.options;
16577
16612
  this.graph = new Graph2(this.element, this.options, this.chartContext);
16578
16613
  this.setupElementDimensions(width2, height2);