@joint/core 4.1.0-beta.1 → 4.1.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.
@@ -1,4 +1,4 @@
1
- /*! JointJS v4.1.0-beta.1 (2024-10-30) - JavaScript diagramming library
1
+ /*! JointJS v4.1.1 (2024-12-02) - 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.1.0-beta.1 (2024-10-30) - JavaScript diagramming library
1
+ /*! JointJS v4.1.1 (2024-12-02) - JavaScript diagramming library
2
2
 
3
3
 
4
4
  This Source Code Form is subject to the terms of the Mozilla Public
package/dist/version.mjs CHANGED
@@ -1,3 +1,3 @@
1
- var version = "4.1.0-beta.1";
1
+ var version = "4.1.1";
2
2
 
3
3
  export { version };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joint/core",
3
3
  "title": "JointJS",
4
- "version": "4.1.0-beta.1",
4
+ "version": "4.1.1",
5
5
  "description": "JavaScript diagramming library",
6
6
  "sideEffects": false,
7
7
  "main": "./dist/joint.min.js",
@@ -52,15 +52,7 @@ export const ToolsView = mvc.View.extend({
52
52
  const tool = tools[i];
53
53
  tool.updateVisibility();
54
54
  if (!tool.isVisible()) continue;
55
- if (!this.isRendered) {
56
- // There is at least one visible tool
57
- this.isRendered = Array(n).fill(false);
58
- }
59
- if (!this.isRendered[i]) {
60
- // First update executes render()
61
- tool.render();
62
- this.isRendered[i] = true;
63
- } else if (opt.tool !== tool.cid) {
55
+ if (this.ensureToolRendered(tools, i) && opt.tool !== tool.cid) {
64
56
  tool.update();
65
57
  }
66
58
  }
@@ -79,6 +71,20 @@ export const ToolsView = mvc.View.extend({
79
71
  return this;
80
72
  },
81
73
 
74
+ ensureToolRendered(tools, i) {
75
+ if (!this.isRendered) {
76
+ // There is at least one visible tool
77
+ this.isRendered = Array(tools.length).fill(false);
78
+ }
79
+ if (!this.isRendered[i]) {
80
+ // First update executes render()
81
+ tools[i].render();
82
+ this.isRendered[i] = true;
83
+ return false;
84
+ }
85
+ return true;
86
+ },
87
+
82
88
  focusTool: function(focusedTool) {
83
89
 
84
90
  var tools = this.tools;
@@ -103,7 +109,7 @@ export const ToolsView = mvc.View.extend({
103
109
  tool.show();
104
110
  // Check if the tool is conditionally visible too
105
111
  if (tool.isVisible()) {
106
- tool.update();
112
+ this.ensureToolRendered(tools, i) && tool.update();
107
113
  }
108
114
  }
109
115
  }
@@ -115,7 +121,12 @@ export const ToolsView = mvc.View.extend({
115
121
  },
116
122
 
117
123
  show: function() {
118
- return this.blurTool(null);
124
+ this.blurTool(null);
125
+ // If this the first time the tools are shown, make sure they are mounted
126
+ if (!this.isMounted()) {
127
+ this.mount();
128
+ }
129
+ return this;
119
130
  },
120
131
 
121
132
  onRemove: function() {
package/types/joint.d.ts CHANGED
@@ -22,6 +22,9 @@ type _DeepPartial<T> = {
22
22
 
23
23
  type DeepPartial<T> = _DeepPartial<_DeepRequired<T>>;
24
24
 
25
+ // We use `DOMElement` later in the code, to avoid conflicts with the `dia.Element` type.
26
+ type DOMElement = Element;
27
+
25
28
  export namespace dia {
26
29
 
27
30
  type Event = mvc.TriggeredEvent;
@@ -395,7 +398,7 @@ export namespace dia {
395
398
 
396
399
  type UnsetCallback<V> = (
397
400
  this: V,
398
- node: Element,
401
+ node: DOMElement,
399
402
  nodeAttributes: { [name: string]: any },
400
403
  cellView: V
401
404
  ) => string | Array<string> | null | void;
@@ -404,7 +407,7 @@ export namespace dia {
404
407
  this: V,
405
408
  attributeValue: any,
406
409
  refBBox: g.Rect,
407
- node: Element,
410
+ node: DOMElement,
408
411
  nodeAttributes: { [name: string]: any },
409
412
  cellView: V
410
413
  ) => { [key: string]: any } | string | number | void;
@@ -413,7 +416,7 @@ export namespace dia {
413
416
  this: V,
414
417
  attributeValue: any,
415
418
  refBBox: g.Rect,
416
- node: Element,
419
+ node: DOMElement,
417
420
  nodeAttributes: { [name: string]: any },
418
421
  cellView: V
419
422
  ) => dia.Point | null | void;
@@ -422,7 +425,7 @@ export namespace dia {
422
425
  this: V,
423
426
  attributeValue: any,
424
427
  nodeBBox: g.Rect,
425
- node: Element,
428
+ node: DOMElement,
426
429
  nodeAttributes: { [name: string]: any },
427
430
  cellView: V
428
431
  ) => dia.Point | null | void;
@@ -923,7 +926,7 @@ export namespace dia {
923
926
 
924
927
  isNodeConnection(node: SVGElement): boolean;
925
928
 
926
- getEventTarget(evt: dia.Event, opt?: { fromPoint?: boolean }): Element;
929
+ getEventTarget(evt: dia.Event, opt?: { fromPoint?: boolean }): DOMElement;
927
930
 
928
931
  checkMouseleave(evt: dia.Event): void;
929
932
 
@@ -1044,7 +1047,7 @@ export namespace dia {
1044
1047
 
1045
1048
  class ElementView<E extends Element = Element> extends CellViewGeneric<E> {
1046
1049
 
1047
- update(element?: E, renderingOnlyAttrs?: { [key: string]: any }): void;
1050
+ update(element?: DOMElement, renderingOnlyAttrs?: { [key: string]: any }): void;
1048
1051
 
1049
1052
  setInteractivity(value: boolean | ElementView.InteractivityOptions): void;
1050
1053
 
@@ -1053,9 +1056,9 @@ export namespace dia {
1053
1056
  getTargetParentView(evt: dia.Event): CellView | null;
1054
1057
 
1055
1058
  findPortNode(portId: string | number): SVGElement | null;
1056
- findPortNode(portId: string | number, selector: string): E | null;
1059
+ findPortNode(portId: string | number, selector: string): DOMElement | null;
1057
1060
 
1058
- findPortNodes(portId: string | number, groupSelector: string): E[];
1061
+ findPortNodes(portId: string | number, groupSelector: string): DOMElement[];
1059
1062
 
1060
1063
  protected renderMarkup(): void;
1061
1064
 
@@ -1204,9 +1207,9 @@ export namespace dia {
1204
1207
  getEndMagnet(endType: dia.LinkEnd): SVGElement | null;
1205
1208
 
1206
1209
  findLabelNode(labelIndex: string | number): SVGElement | null;
1207
- findLabelNode(labelIndex: string | number, selector: string): Element | null;
1210
+ findLabelNode(labelIndex: string | number, selector: string): DOMElement | null;
1208
1211
 
1209
- findLabelNodes(labelIndex: string | number, groupSelector: string): Element[];
1212
+ findLabelNodes(labelIndex: string | number, groupSelector: string): DOMElement[];
1210
1213
 
1211
1214
  removeRedundantLinearVertices(opt?: dia.ModelSetOptions): number;
1212
1215
 
@@ -2584,6 +2587,8 @@ export namespace shapes {
2584
2587
 
2585
2588
  export namespace util {
2586
2589
 
2590
+ export function cloneCells(cells: dia.Cell[]): { [id: string]: dia.Cell };
2591
+
2587
2592
  export function isCalcExpression(value: any): boolean;
2588
2593
 
2589
2594
  export function evalCalcFormula(formula: string, rect: g.PlainRect): number;
@@ -2645,27 +2650,27 @@ export namespace util {
2645
2650
 
2646
2651
  export function imageToDataUri(url: string, callback: (err: Error | null, dataUri: string) => void): void;
2647
2652
 
2648
- export function getElementBBox(el: Element): dia.BBox;
2653
+ export function getElementBBox(el: DOMElement): dia.BBox;
2649
2654
 
2650
2655
  export function sortElements(
2651
2656
  elements: mvc.$Element,
2652
- comparator: (a: Element, b: Element) => number
2653
- ): Element[];
2657
+ comparator: (a: DOMElement, b: DOMElement) => number
2658
+ ): DOMElement[];
2654
2659
 
2655
- export function setAttributesBySelector(el: Element, attrs: { [selector: string]: { [attribute: string]: any }}): void;
2660
+ export function setAttributesBySelector(el: DOMElement, attrs: { [selector: string]: { [attribute: string]: any }}): void;
2656
2661
 
2657
2662
  export function normalizeSides(sides: dia.Sides): dia.PaddingJSON;
2658
2663
 
2659
2664
  export function template(html: string): (data: any) => string;
2660
2665
 
2661
- export function toggleFullScreen(el?: Element): void;
2666
+ export function toggleFullScreen(el?: DOMElement): void;
2662
2667
 
2663
2668
  export function objectDifference(object: object, base: object, opt?: { maxDepth?: number }): object;
2664
2669
 
2665
2670
  interface DOMJSONDocument {
2666
2671
  fragment: DocumentFragment;
2667
- selectors: { [key: string]: Element };
2668
- groupSelectors: { [key: string]: Element[] };
2672
+ selectors: { [key: string]: DOMElement };
2673
+ groupSelectors: { [key: string]: DOMElement[] };
2669
2674
  }
2670
2675
 
2671
2676
  export function parseDOMJSON(json: dia.MarkupJSON): DOMJSONDocument;
@@ -2996,7 +3001,7 @@ export namespace mvc {
2996
3001
  type Dom = unknown;
2997
3002
  // The following types represent the DOM elements that can be passed to the
2998
3003
  // $() function.
2999
- type $Element<T extends Element = Element> = string | T | T[] | Dom;
3004
+ type $Element<T extends DOMElement = DOMElement> = string | T | T[] | Dom;
3000
3005
  type $HTMLElement = $Element<HTMLElement>;
3001
3006
  type $SVGElement = $Element<SVGElement>;
3002
3007
 
@@ -3004,7 +3009,7 @@ export namespace mvc {
3004
3009
  duration?: number;
3005
3010
  delay?: number;
3006
3011
  easing?: string;
3007
- complete?: (this: Element) => void;
3012
+ complete?: (this: DOMElement) => void;
3008
3013
  }
3009
3014
 
3010
3015
  interface Event {
@@ -3027,7 +3032,7 @@ export namespace mvc {
3027
3032
  screenX: number | undefined;
3028
3033
  screenY: number | undefined;
3029
3034
  /** @deprecated */
3030
- toElement: Element | undefined;
3035
+ toElement: DOMElement | undefined;
3031
3036
  // PointerEvent
3032
3037
  pointerId: number | undefined;
3033
3038
  pointerType: string | undefined;
@@ -3392,7 +3397,7 @@ export namespace mvc {
3392
3397
 
3393
3398
  }
3394
3399
 
3395
- interface ViewBaseOptions<TModel extends (Model | undefined) = Model, TElement extends Element = HTMLElement> {
3400
+ interface ViewBaseOptions<TModel extends (Model | undefined) = Model, TElement extends DOMElement = HTMLElement> {
3396
3401
  model?: TModel | undefined;
3397
3402
  // TODO: quickfix, this can't be fixed easy. The collection does not need to have the same model as the parent view.
3398
3403
  collection?: Collection<any> | undefined; // was: Collection<TModel>;
@@ -3406,7 +3411,7 @@ export namespace mvc {
3406
3411
 
3407
3412
  type ViewBaseEventListener = (event: mvc.Event) => void;
3408
3413
 
3409
- class ViewBase<TModel extends (Model | undefined) = Model, TElement extends Element = HTMLElement> extends EventsMixin implements Events {
3414
+ class ViewBase<TModel extends (Model | undefined) = Model, TElement extends DOMElement = HTMLElement> extends EventsMixin implements Events {
3410
3415
  /**
3411
3416
  * Do not use, prefer TypeScript's extend functionality.
3412
3417
  */
@@ -3458,7 +3463,7 @@ export namespace mvc {
3458
3463
  protected _setAttributes(attributes: Record<string, any>): void;
3459
3464
  }
3460
3465
 
3461
- interface ViewOptions<T extends (mvc.Model | undefined), E extends Element = HTMLElement> extends mvc.ViewBaseOptions<T, E> {
3466
+ interface ViewOptions<T extends (mvc.Model | undefined), E extends DOMElement = HTMLElement> extends mvc.ViewBaseOptions<T, E> {
3462
3467
  theme?: string;
3463
3468
  [key: string]: any;
3464
3469
  }
@@ -3467,7 +3472,7 @@ export namespace mvc {
3467
3472
  [key: string]: any;
3468
3473
  }
3469
3474
 
3470
- class View<T extends (mvc.Model | undefined), E extends Element = HTMLElement> extends mvc.ViewBase<T, E> {
3475
+ class View<T extends (mvc.Model | undefined), E extends DOMElement = HTMLElement> extends mvc.ViewBase<T, E> {
3471
3476
 
3472
3477
  constructor(opt?: ViewOptions<T, E>);
3473
3478
 
@@ -3495,7 +3500,7 @@ export namespace mvc {
3495
3500
 
3496
3501
  children?: dia.MarkupJSON;
3497
3502
 
3498
- childNodes?: { [key: string]: Element } | null;
3503
+ childNodes?: { [key: string]: DOMElement } | null;
3499
3504
 
3500
3505
  style?: { [key: string]: any };
3501
3506
 
@@ -3507,9 +3512,9 @@ export namespace mvc {
3507
3512
 
3508
3513
  undelegateDocumentEvents(): this;
3509
3514
 
3510
- delegateElementEvents(element: Element, events?: mvc.EventsHash, data?: viewEventData): this;
3515
+ delegateElementEvents(element: DOMElement, events?: mvc.EventsHash, data?: viewEventData): this;
3511
3516
 
3512
- undelegateElementEvents(element: Element): this;
3517
+ undelegateElementEvents(element: DOMElement): this;
3513
3518
 
3514
3519
  eventData(evt: dia.Event): viewEventData;
3515
3520
  eventData(evt: dia.Event, data: viewEventData): this;
@@ -3519,7 +3524,7 @@ export namespace mvc {
3519
3524
 
3520
3525
  renderChildren(children?: dia.MarkupJSON): this;
3521
3526
 
3522
- findAttribute(attributeName: string, node: Element): string | null;
3527
+ findAttribute(attributeName: string, node: DOMElement): string | null;
3523
3528
 
3524
3529
  confirmUpdate(flag: number, opt: { [key: string]: any }): number;
3525
3530
 
@@ -3527,7 +3532,7 @@ export namespace mvc {
3527
3532
 
3528
3533
  isMounted(): boolean;
3529
3534
 
3530
- protected findAttributeNode(attributeName: string, node: Element): Element | null;
3535
+ protected findAttributeNode(attributeName: string, node: DOMElement): DOMElement | null;
3531
3536
 
3532
3537
  protected init(): void;
3533
3538