@joint/core 4.0.2 → 4.0.3

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.
@@ -1,4 +1,4 @@
1
- /*! JointJS v4.0.2 (2024-04-09) - JavaScript diagramming library
1
+ /*! JointJS v4.0.3 (2024-05-14) - JavaScript diagramming library
2
2
 
3
3
 
4
4
  This Source Code Form is subject to the terms of the Mozilla Public
@@ -20341,6 +20341,13 @@ var joint = (function (exports) {
20341
20341
  'port-group': port.group
20342
20342
  });
20343
20343
 
20344
+ // If the port ID is a number, we need to add
20345
+ // extra information to the port element to distinguish
20346
+ // between ports with the same ID but different types.
20347
+ if (isNumber(port.id)) {
20348
+ portElement.attr('port-id-type', 'number');
20349
+ }
20350
+
20344
20351
  var labelMarkupDef = this._getPortLabelMarkup(port.label);
20345
20352
  if (Array.isArray(labelMarkupDef)) {
20346
20353
  // JSON Markup
@@ -23863,23 +23870,25 @@ var joint = (function (exports) {
23863
23870
  return this;
23864
23871
  },
23865
23872
 
23866
- findAttribute: function(attributeName, node) {
23867
-
23873
+ findAttributeNode: function(attributeName, node) {
23868
23874
  var currentNode = node;
23869
-
23870
23875
  while (currentNode && currentNode.nodeType === 1) {
23871
- var attributeValue = currentNode.getAttribute(attributeName);
23872
23876
  // attribute found
23873
- if (attributeValue) { return attributeValue; }
23877
+ // (empty value does not count as attribute found)
23878
+ if (currentNode.getAttribute(attributeName)) { return currentNode; }
23874
23879
  // do not climb up the DOM
23875
23880
  if (currentNode === this.el) { return null; }
23876
23881
  // try parent node
23877
23882
  currentNode = currentNode.parentNode;
23878
23883
  }
23879
-
23880
23884
  return null;
23881
23885
  },
23882
23886
 
23887
+ findAttribute: function(attributeName, node) {
23888
+ var matchedNode = this.findAttributeNode(attributeName, node);
23889
+ return matchedNode && matchedNode.getAttribute(attributeName);
23890
+ },
23891
+
23883
23892
  // Override the mvc ViewBase `_ensureElement()` method in order to create an
23884
23893
  // svg element (e.g., `<g>`) node that wraps all the nodes of the Cell view.
23885
23894
  // Expose class name setter as a separate method.
@@ -30603,13 +30612,18 @@ var joint = (function (exports) {
30603
30612
 
30604
30613
  var model = this.model;
30605
30614
  var id = model.id;
30606
- var port = this.findAttribute('port', magnet);
30615
+ // Find a node with the `port` attribute set on it.
30616
+ var portNode = this.findAttributeNode('port', magnet);
30607
30617
  // Find a unique `selector` of the element under pointer that is a magnet.
30608
30618
  var selector = magnet.getAttribute('joint-selector');
30609
30619
 
30610
30620
  var end = { id: id };
30611
30621
  if (selector != null) { end.magnet = selector; }
30612
- if (port != null) {
30622
+ if (portNode != null) {
30623
+ var port = portNode.getAttribute('port');
30624
+ if (portNode.getAttribute('port-id-type') === 'number') {
30625
+ port = parseInt(port, 10);
30626
+ }
30613
30627
  end.port = port;
30614
30628
  if (!model.hasPort(port) && !selector) {
30615
30629
  // port created via the `port` attribute (not API)
@@ -34664,6 +34678,8 @@ var joint = (function (exports) {
34664
34678
  },
34665
34679
 
34666
34680
  renderGrid: function renderGrid() {
34681
+ var this$1 = this;
34682
+
34667
34683
 
34668
34684
  var ref = this;
34669
34685
  var paper = ref.options.paper;
@@ -34683,7 +34699,7 @@ var joint = (function (exports) {
34683
34699
 
34684
34700
  gridSettings.forEach(function (gridLayerSetting, index) {
34685
34701
 
34686
- var id = 'pattern_' + index;
34702
+ var id = this$1._getPatternId(index);
34687
34703
  var options = merge({}, gridLayerSetting);
34688
34704
  var scaleFactor = options.scaleFactor; if ( scaleFactor === void 0 ) scaleFactor = 1;
34689
34705
  options.width = gridSize * scaleFactor || 1;
@@ -34711,6 +34727,8 @@ var joint = (function (exports) {
34711
34727
  },
34712
34728
 
34713
34729
  updateGrid: function updateGrid() {
34730
+ var this$1 = this;
34731
+
34714
34732
 
34715
34733
  var ref = this;
34716
34734
  var grid = ref._gridCache;
@@ -34731,12 +34749,16 @@ var joint = (function (exports) {
34731
34749
  }
34732
34750
  gridSettings.forEach(function (options, index) {
34733
34751
  if (isFunction(options.update)) {
34734
- var vPattern = patterns['pattern_' + index];
34752
+ var vPattern = patterns[this$1._getPatternId(index)];
34735
34753
  options.update(vPattern.node.firstChild, options, paper);
34736
34754
  }
34737
34755
  });
34738
34756
  },
34739
34757
 
34758
+ _getPatternId: function _getPatternId(index) {
34759
+ return ("pattern_" + (this.options.paper.cid) + "_" + index);
34760
+ },
34761
+
34740
34762
  _getGridRefs: function _getGridRefs() {
34741
34763
  var ref = this;
34742
34764
  var grid = ref._gridCache;
@@ -38961,12 +38983,14 @@ var joint = (function (exports) {
38961
38983
  evt.stopPropagation();
38962
38984
  evt.preventDefault();
38963
38985
  var relatedView = this.relatedView;
38986
+ var paper = relatedView.paper;
38964
38987
  relatedView.model.startBatch('arrowhead-move', { ui: true, tool: this.cid });
38965
38988
  relatedView.startArrowheadMove(this.arrowheadType);
38966
38989
  this.delegateDocumentEvents();
38967
- relatedView.paper.undelegateEvents();
38990
+ paper.undelegateEvents();
38968
38991
  this.focus();
38969
38992
  this.el.style.pointerEvents = 'none';
38993
+ relatedView.notifyPointerdown.apply(relatedView, paper.getPointerArgs(evt));
38970
38994
  },
38971
38995
  onPointerMove: function(evt) {
38972
38996
  var normalizedEvent = normalizeEvent(evt);
@@ -39921,7 +39945,7 @@ var joint = (function (exports) {
39921
39945
  Control: Control
39922
39946
  });
39923
39947
 
39924
- var version = "4.0.2";
39948
+ var version = "4.0.3";
39925
39949
 
39926
39950
  var Vectorizer = V;
39927
39951
  var layout = { PortLabel: PortLabel, Port: Port };