@joint/core 4.0.2 → 4.0.4

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
@@ -1,17 +1,17 @@
1
1
  # JointJS - JavaScript diagramming library powering exceptional UIs
2
2
 
3
- [![Build Status](https://travis-ci.com/clientIO/joint.svg?branch=master)](https://travis-ci.com/clientIO/joint)
3
+ [![Build Status](https://app.travis-ci.com/clientIO/joint.svg?token=YC3doXGarvYwgzfqe9zy&branch=master)](https://app.travis-ci.com/clientIO/joint)
4
4
  [![Total Discussion](https://img.shields.io/github/discussions/badges/shields)](https://github.com/clientIO/joint/discussions)
5
5
  [![NPM Version](https://img.shields.io/npm/v/jointjs)](https://www.npmjs.com/package/jointjs)
6
6
  [![NPM License](https://img.shields.io/npm/l/jointjs?color=blue)](https://github.com/clientIO/joint/blob/master/LICENSE)
7
7
 
8
- [JointJS](https://jointjs.com) is a tested and proven *JavaScript*/*Typescript* diagramming library that helps developers and companies of any size build visual and No-Code/Low-Code applications faster and with confidence. It’s a flexible tool from which a wide range of UIs can be created (interactive diagramming applications, drawing tools, data visualizations, UIs for monitoring systems, and many more). It can become the foundational layer of your next application and help you bring your idea to market in days, not months or years.
8
+ [JointJS](https://jointjs.com) is a tested and proven *JavaScript*/*Typescript* diagramming library that helps developers and companies of any size build visual and No-Code/Low-Code applications faster and with confidence. It’s a flexible tool from which a wide range of UIs can be created (interactive diagramming applications, drawing tools, data visualizations, UIs for monitoring systems, and many more). It can become the foundational layer of your next application and help you bring your idea to market in days, not months or years.
9
9
 
10
10
  ![Use Cases](https://user-images.githubusercontent.com/3967880/200360293-808f148c-32af-4f46-bec1-b4ae4e1592a0.jpg)
11
11
 
12
12
  Further **information**, **examples** and **documentation** can be found at [jointjs.com](https://jointjs.com).
13
13
 
14
- :1234: Get started with [tutorials](https://resources.jointjs.com/tutorial).
14
+ :1234: Get started with [tutorials](https://docs.jointjs.com).
15
15
 
16
16
  :bulb: To ask a question, share feedback, or engage in a discussion with other community members, visit our [GitHub discussions](https://github.com/clientIO/joint/discussions).
17
17
 
package/dist/geometry.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! JointJS v4.0.2 (2024-04-09) - JavaScript diagramming library
1
+ /*! JointJS v4.0.4 (2024-05-31) - JavaScript diagramming library
2
2
 
3
3
 
4
4
  This Source Code Form is subject to the terms of the Mozilla Public
@@ -1,4 +1,4 @@
1
- /*! JointJS v4.0.2 (2024-04-09) - JavaScript diagramming library
1
+ /*! JointJS v4.0.4 (2024-05-31) - JavaScript diagramming library
2
2
 
3
3
 
4
4
  This Source Code Form is subject to the terms of the Mozilla Public
package/dist/joint.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /*! JointJS v4.0.2 (2024-04-09) - JavaScript diagramming library
1
+ /*! JointJS v4.0.4 (2024-05-31) - JavaScript diagramming library
2
2
 
3
3
 
4
4
  This Source Code Form is subject to the terms of the Mozilla Public
@@ -618,6 +618,16 @@ export declare namespace connectors {
618
618
  var curve: CurveConnector;
619
619
  }
620
620
 
621
+ declare type DeepPartial<T> = _DeepPartial<_DeepRequired<T>>;
622
+
623
+ declare type _DeepPartial<T> = {
624
+ [P in keyof T]?: T[P] extends object ? _DeepPartial<T[P]> : T[P];
625
+ };
626
+
627
+ declare type _DeepRequired<T> = {
628
+ [P in keyof T]-?: T[P] extends object ? _DeepRequired<T[P]> : T[P];
629
+ };
630
+
621
631
  export declare namespace dia {
622
632
 
623
633
  export type Event = mvc.TriggeredEvent;
@@ -933,7 +943,7 @@ export declare namespace dia {
933
943
 
934
944
  export class Cell<A extends ObjectHash = Cell.Attributes, S extends mvc.ModelSetOptions = dia.ModelSetOptions> extends mvc.Model<A, S> {
935
945
 
936
- constructor(attributes?: A, opt?: Cell.ConstructorOptions);
946
+ constructor(attributes?: DeepPartial<A>, opt?: Cell.ConstructorOptions);
937
947
 
938
948
  id: Cell.ID;
939
949
  graph: Graph;
@@ -967,7 +977,7 @@ export declare namespace dia {
967
977
  isEmbedded(): boolean;
968
978
 
969
979
  prop(key: Path): any;
970
- prop(object: Partial<A>, opt?: Cell.Options): this;
980
+ prop(object: DeepPartial<A>, opt?: Cell.Options): this;
971
981
  prop(key: Path, value: any, opt?: Cell.Options): this;
972
982
 
973
983
  removeProp(path: Path, opt?: Cell.Options): this;
@@ -4487,6 +4497,8 @@ export declare namespace mvc {
4487
4497
 
4488
4498
  isMounted(): boolean;
4489
4499
 
4500
+ protected findAttributeNode(attributeName: string, node: Element): Element | null;
4501
+
4490
4502
  protected init(): void;
4491
4503
 
4492
4504
  protected onRender(): void;
package/dist/joint.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! JointJS v4.0.2 (2024-04-09) - JavaScript diagramming library
1
+ /*! JointJS v4.0.4 (2024-05-31) - JavaScript diagramming library
2
2
 
3
3
 
4
4
  This Source Code Form is subject to the terms of the Mozilla Public
@@ -17410,6 +17410,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
17410
17410
  return (attrs.text !== undefined);
17411
17411
  }
17412
17412
 
17413
+ var FONT_ATTRIBUTES = ['font-weight', 'font-family', 'font-size', 'letter-spacing', 'text-transform'];
17414
+
17413
17415
  var textAttributesNS = {
17414
17416
 
17415
17417
  'line-height': {
@@ -17525,18 +17527,28 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
17525
17527
  var text = value.text;
17526
17528
  if (text === undefined) { text = attrs.text; }
17527
17529
  if (text !== undefined) {
17530
+
17528
17531
  var breakTextFn = value.breakText || breakText;
17529
17532
  var computedStyles = getComputedStyle(node);
17533
+ var wrapFontAttributes = {};
17534
+ // The font size attributes must be set on the node
17535
+ // to get the correct text wrapping.
17536
+ // TODO: set the native SVG attributes before special attributes
17537
+ for (var i = 0; i < FONT_ATTRIBUTES.length; i++) {
17538
+ var name = FONT_ATTRIBUTES[i];
17539
+ if (name in attrs) {
17540
+ node.setAttribute(name, attrs[name]);
17541
+ }
17542
+ // Note: computedStyles is a live object
17543
+ // i.e. the properties are evaluated when accessed.
17544
+ wrapFontAttributes[name] = computedStyles[name];
17545
+ }
17530
17546
 
17531
- wrappedText = breakTextFn('' + text, size, {
17532
- 'font-weight': computedStyles.fontWeight,
17533
- 'font-family': computedStyles.fontFamily,
17534
- 'text-transform': computedStyles.textTransform,
17535
- 'font-size': computedStyles.fontSize,
17536
- 'letter-spacing': computedStyles.letterSpacing,
17537
- // The `line-height` attribute in SVG is JoinJS specific.
17538
- 'lineHeight': attrs['line-height'],
17539
- }, {
17547
+ // The `line-height` attribute in SVG is JoinJS specific.
17548
+ // TODO: change the `lineHeight` to breakText option.
17549
+ wrapFontAttributes.lineHeight = attrs['line-height'];
17550
+
17551
+ wrappedText = breakTextFn('' + text, size, wrapFontAttributes, {
17540
17552
  // Provide an existing SVG Document here
17541
17553
  // instead of creating a temporary one over again.
17542
17554
  svgDocument: this.paper.svg,
@@ -17550,7 +17562,11 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
17550
17562
  wrappedText = '';
17551
17563
  }
17552
17564
  textAttributesNS.text.set.call(this, wrappedText, refBBox, node, attrs);
17553
- }
17565
+ },
17566
+ // We expose the font attributes list to allow
17567
+ // the user to take other custom font attributes into account
17568
+ // when wrapping the text.
17569
+ FONT_ATTRIBUTES: FONT_ATTRIBUTES
17554
17570
  },
17555
17571
 
17556
17572
  'title': {
@@ -20344,6 +20360,13 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
20344
20360
  'port-group': port.group
20345
20361
  });
20346
20362
 
20363
+ // If the port ID is a number, we need to add
20364
+ // extra information to the port element to distinguish
20365
+ // between ports with the same ID but different types.
20366
+ if (isNumber(port.id)) {
20367
+ portElement.attr('port-id-type', 'number');
20368
+ }
20369
+
20347
20370
  var labelMarkupDef = this._getPortLabelMarkup(port.label);
20348
20371
  if (Array.isArray(labelMarkupDef)) {
20349
20372
  // JSON Markup
@@ -21610,6 +21633,11 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
21610
21633
  svgforeignobject: function() {
21611
21634
  return !!document.createElementNS &&
21612
21635
  /SVGForeignObject/.test(({}).toString.call(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')));
21636
+ },
21637
+
21638
+ // works for iOS browsers too
21639
+ isSafari: function() {
21640
+ return /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor);
21613
21641
  }
21614
21642
  },
21615
21643
 
@@ -23866,23 +23894,25 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
23866
23894
  return this;
23867
23895
  },
23868
23896
 
23869
- findAttribute: function(attributeName, node) {
23870
-
23897
+ findAttributeNode: function(attributeName, node) {
23871
23898
  var currentNode = node;
23872
-
23873
23899
  while (currentNode && currentNode.nodeType === 1) {
23874
- var attributeValue = currentNode.getAttribute(attributeName);
23875
23900
  // attribute found
23876
- if (attributeValue) { return attributeValue; }
23901
+ // (empty value does not count as attribute found)
23902
+ if (currentNode.getAttribute(attributeName)) { return currentNode; }
23877
23903
  // do not climb up the DOM
23878
23904
  if (currentNode === this.el) { return null; }
23879
23905
  // try parent node
23880
23906
  currentNode = currentNode.parentNode;
23881
23907
  }
23882
-
23883
23908
  return null;
23884
23909
  },
23885
23910
 
23911
+ findAttribute: function(attributeName, node) {
23912
+ var matchedNode = this.findAttributeNode(attributeName, node);
23913
+ return matchedNode && matchedNode.getAttribute(attributeName);
23914
+ },
23915
+
23886
23916
  // Override the mvc ViewBase `_ensureElement()` method in order to create an
23887
23917
  // svg element (e.g., `<g>`) node that wraps all the nodes of the Cell view.
23888
23918
  // Expose class name setter as a separate method.
@@ -30606,13 +30636,18 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
30606
30636
 
30607
30637
  var model = this.model;
30608
30638
  var id = model.id;
30609
- var port = this.findAttribute('port', magnet);
30639
+ // Find a node with the `port` attribute set on it.
30640
+ var portNode = this.findAttributeNode('port', magnet);
30610
30641
  // Find a unique `selector` of the element under pointer that is a magnet.
30611
30642
  var selector = magnet.getAttribute('joint-selector');
30612
30643
 
30613
30644
  var end = { id: id };
30614
30645
  if (selector != null) { end.magnet = selector; }
30615
- if (port != null) {
30646
+ if (portNode != null) {
30647
+ var port = portNode.getAttribute('port');
30648
+ if (portNode.getAttribute('port-id-type') === 'number') {
30649
+ port = parseInt(port, 10);
30650
+ }
30616
30651
  end.port = port;
30617
30652
  if (!model.hasPort(port) && !selector) {
30618
30653
  // port created via the `port` attribute (not API)
@@ -32471,6 +32506,11 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
32471
32506
  this.updateHighlighters(true);
32472
32507
  this.updateTools(opt);
32473
32508
  flags = this.removeFlag(flags, [Flags$2.RENDER, Flags$2.UPDATE, Flags$2.LABELS, Flags$2.TOOLS, Flags$2.CONNECTOR]);
32509
+
32510
+ if (env.test('isSafari')) {
32511
+ this.__fixSafariBug268376();
32512
+ }
32513
+
32474
32514
  return flags;
32475
32515
  }
32476
32516
 
@@ -32524,6 +32564,20 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
32524
32564
  return flags;
32525
32565
  },
32526
32566
 
32567
+ __fixSafariBug268376: function() {
32568
+ // Safari has a bug where any change after the first render is not reflected in the DOM.
32569
+ // https://bugs.webkit.org/show_bug.cgi?id=268376
32570
+ var ref = this;
32571
+ var el = ref.el;
32572
+ var childNodes = Array.from(el.childNodes);
32573
+ var fragment = document.createDocumentFragment();
32574
+ for (var i = 0, n = childNodes.length; i < n; i++) {
32575
+ el.removeChild(childNodes[i]);
32576
+ fragment.appendChild(childNodes[i]);
32577
+ }
32578
+ el.appendChild(fragment);
32579
+ },
32580
+
32527
32581
  requestConnectionUpdate: function(opt) {
32528
32582
  this.requestUpdate(this.getFlag(Flags$2.UPDATE), opt);
32529
32583
  },
@@ -34667,6 +34721,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
34667
34721
  },
34668
34722
 
34669
34723
  renderGrid: function renderGrid() {
34724
+ var this$1 = this;
34725
+
34670
34726
 
34671
34727
  var ref = this;
34672
34728
  var paper = ref.options.paper;
@@ -34686,7 +34742,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
34686
34742
 
34687
34743
  gridSettings.forEach(function (gridLayerSetting, index) {
34688
34744
 
34689
- var id = 'pattern_' + index;
34745
+ var id = this$1._getPatternId(index);
34690
34746
  var options = merge({}, gridLayerSetting);
34691
34747
  var scaleFactor = options.scaleFactor; if ( scaleFactor === void 0 ) scaleFactor = 1;
34692
34748
  options.width = gridSize * scaleFactor || 1;
@@ -34714,6 +34770,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
34714
34770
  },
34715
34771
 
34716
34772
  updateGrid: function updateGrid() {
34773
+ var this$1 = this;
34774
+
34717
34775
 
34718
34776
  var ref = this;
34719
34777
  var grid = ref._gridCache;
@@ -34734,12 +34792,16 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
34734
34792
  }
34735
34793
  gridSettings.forEach(function (options, index) {
34736
34794
  if (isFunction(options.update)) {
34737
- var vPattern = patterns['pattern_' + index];
34795
+ var vPattern = patterns[this$1._getPatternId(index)];
34738
34796
  options.update(vPattern.node.firstChild, options, paper);
34739
34797
  }
34740
34798
  });
34741
34799
  },
34742
34800
 
34801
+ _getPatternId: function _getPatternId(index) {
34802
+ return ("pattern_" + (this.options.paper.cid) + "_" + index);
34803
+ },
34804
+
34743
34805
  _getGridRefs: function _getGridRefs() {
34744
34806
  var ref = this;
34745
34807
  var grid = ref._gridCache;
@@ -38964,12 +39026,14 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
38964
39026
  evt.stopPropagation();
38965
39027
  evt.preventDefault();
38966
39028
  var relatedView = this.relatedView;
39029
+ var paper = relatedView.paper;
38967
39030
  relatedView.model.startBatch('arrowhead-move', { ui: true, tool: this.cid });
38968
39031
  relatedView.startArrowheadMove(this.arrowheadType);
38969
39032
  this.delegateDocumentEvents();
38970
- relatedView.paper.undelegateEvents();
39033
+ paper.undelegateEvents();
38971
39034
  this.focus();
38972
39035
  this.el.style.pointerEvents = 'none';
39036
+ relatedView.notifyPointerdown.apply(relatedView, paper.getPointerArgs(evt));
38973
39037
  },
38974
39038
  onPointerMove: function(evt) {
38975
39039
  var normalizedEvent = normalizeEvent(evt);
@@ -39924,7 +39988,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
39924
39988
  Control: Control
39925
39989
  });
39926
39990
 
39927
- var version = "4.0.2";
39991
+ var version = "4.0.4";
39928
39992
 
39929
39993
  var Vectorizer = V;
39930
39994
  var layout = { PortLabel: PortLabel, Port: Port };