@joint/core 4.0.3 → 4.1.0-beta.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.
Files changed (55) hide show
  1. package/README.md +2 -10
  2. package/dist/geometry.js +4962 -6132
  3. package/dist/geometry.min.js +2 -2
  4. package/dist/joint.d.ts +338 -52
  5. package/dist/joint.js +34067 -37525
  6. package/dist/joint.min.js +2 -2
  7. package/dist/joint.nowrap.js +34067 -37525
  8. package/dist/joint.nowrap.min.js +2 -2
  9. package/dist/vectorizer.js +7288 -8907
  10. package/dist/vectorizer.min.js +2 -2
  11. package/dist/version.mjs +1 -1
  12. package/package.json +10 -15
  13. package/src/{linkTools → cellTools}/Button.mjs +8 -6
  14. package/src/{elementTools → cellTools}/Control.mjs +3 -3
  15. package/src/{linkTools → cellTools}/HoverConnect.mjs +1 -1
  16. package/src/dia/Cell.mjs +60 -33
  17. package/src/dia/CellView.mjs +75 -8
  18. package/src/dia/ElementView.mjs +13 -8
  19. package/src/dia/Graph.mjs +148 -40
  20. package/src/dia/HighlighterView.mjs +8 -4
  21. package/src/dia/LinkView.mjs +61 -4
  22. package/src/dia/Paper.mjs +84 -0
  23. package/src/dia/ToolView.mjs +29 -4
  24. package/src/dia/ToolsView.mjs +25 -10
  25. package/src/dia/attributes/connection.mjs +5 -0
  26. package/src/dia/attributes/defs.mjs +3 -0
  27. package/src/dia/attributes/eval.mjs +3 -3
  28. package/src/dia/attributes/index.mjs +3 -0
  29. package/src/dia/attributes/shape.mjs +4 -0
  30. package/src/dia/attributes/text.mjs +41 -15
  31. package/src/dia/ports.mjs +4 -0
  32. package/src/elementTools/HoverConnect.mjs +5 -5
  33. package/src/elementTools/index.mjs +5 -4
  34. package/src/env/index.mjs +5 -0
  35. package/src/g/rect.mjs +13 -5
  36. package/src/layout/ports/port.mjs +4 -5
  37. package/src/linkTools/Anchor.mjs +1 -1
  38. package/src/linkTools/Arrowhead.mjs +2 -1
  39. package/src/linkTools/RotateLabel.mjs +110 -0
  40. package/src/linkTools/Segments.mjs +1 -1
  41. package/src/linkTools/Vertices.mjs +41 -4
  42. package/src/linkTools/index.mjs +7 -4
  43. package/src/mvc/View.mjs +0 -1
  44. package/src/mvc/ViewBase.mjs +2 -1
  45. package/src/routers/rightAngle.mjs +538 -140
  46. package/src/shapes/standard.mjs +8 -1
  47. package/src/{dia/attributes → util}/calc.mjs +24 -12
  48. package/src/util/index.mjs +1 -0
  49. package/src/util/util.mjs +39 -0
  50. package/src/util/utilHelpers.mjs +2 -1
  51. package/types/geometry.d.ts +6 -1
  52. package/types/joint.d.ts +331 -50
  53. /package/src/{linkTools → cellTools}/Boundary.mjs +0 -0
  54. /package/src/{linkTools → cellTools}/Connect.mjs +0 -0
  55. /package/src/{linkTools → cellTools}/helpers.mjs +0 -0
package/types/joint.d.ts CHANGED
@@ -12,6 +12,16 @@ export namespace config {
12
12
 
13
13
  type NativeEvent = Event;
14
14
 
15
+ type _DeepRequired<T> = {
16
+ [P in keyof T]-?: T[P] extends object ? _DeepRequired<T[P]> : T[P];
17
+ };
18
+
19
+ type _DeepPartial<T> = {
20
+ [P in keyof T]?: T[P] extends object ? _DeepPartial<T[P]> : T[P];
21
+ };
22
+
23
+ type DeepPartial<T> = _DeepPartial<_DeepRequired<T>>;
24
+
15
25
  export namespace dia {
16
26
 
17
27
  type Event = mvc.TriggeredEvent;
@@ -55,10 +65,11 @@ export namespace dia {
55
65
  type OrthogonalDirection =
56
66
  'left' | 'top' | 'right' | 'bottom';
57
67
 
58
- type Direction =
59
- OrthogonalDirection |
68
+ type DiagonalDirection =
60
69
  'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
61
70
 
71
+ type Direction = OrthogonalDirection | DiagonalDirection;
72
+
62
73
  type LinkEnd =
63
74
  'source' | 'target';
64
75
 
@@ -152,6 +163,20 @@ export namespace dia {
152
163
  breadthFirst?: boolean;
153
164
  }
154
165
 
166
+ interface FindAtPointOptions extends Options {
167
+ strict?: boolean;
168
+ }
169
+
170
+ interface FindInAreaOptions extends Options {
171
+ strict?: boolean;
172
+ }
173
+
174
+ type SearchByKey = 'bbox' | PositionName;
175
+
176
+ interface FindUnderElementOptions extends FindInAreaOptions, FindAtPointOptions {
177
+ searchBy?: SearchByKey;
178
+ }
179
+
155
180
  class Cells extends mvc.Collection<Cell> {
156
181
  graph: Graph;
157
182
  cellNamespace: any;
@@ -228,17 +253,48 @@ export namespace dia {
228
253
 
229
254
  getCommonAncestor(...cells: Cell[]): Element | undefined;
230
255
 
231
- toJSON(): any;
256
+ toJSON(opt?: { cellAttributes?: dia.Cell.ExportOptions }): any;
232
257
 
233
258
  fromJSON(json: any, opt?: S): this;
234
259
 
235
260
  clear(opt?: { [key: string]: any }): this;
236
261
 
262
+ findElementsAtPoint(p: Point, opt?: Graph.FindAtPointOptions): Element[];
263
+
264
+ findElementsInArea(rect: BBox, opt?: Graph.FindInAreaOptions): Element[];
265
+
266
+ findElementsUnderElement(element: Element, opt?: Graph.FindUnderElementOptions): Element[];
267
+
268
+ findLinksAtPoint(p: Point, opt?: Graph.FindAtPointOptions): Link[];
269
+
270
+ findLinksInArea(rect: BBox, opt?: Graph.FindInAreaOptions): Link[];
271
+
272
+ findLinksUnderElement(element: Element, opt?: Graph.FindUnderElementOptions): Link[];
273
+
274
+ findCellsAtPoint(p: Point, opt?: Graph.FindAtPointOptions): Cell[];
275
+
276
+ findCellsInArea(rect: BBox, opt?: Graph.FindInAreaOptions): Cell[];
277
+
278
+ findCellsUnderElement(element: Element, opt?: Graph.FindUnderElementOptions): Cell[];
279
+
280
+ protected _getFindUnderElementGeometry(element: Element, searchBy: Graph.SearchByKey): g.Point | g.Rect;
281
+
282
+ protected _validateCellsUnderElement<T extends Cell[]>(cells: T, element: Element): T;
283
+
284
+ protected _isValidElementUnderElement(el1: Element, el2: Element): boolean;
285
+
286
+ protected _isValidLinkUnderElement(link: Link, element: Element): boolean;
287
+
288
+ protected _filterCellsUnderElement(cells: Cell[], element: Element, opt: Graph.FindUnderElementOptions): Cell[];
289
+
290
+ /** @deprecated use `findElementsAtPoint` instead */
237
291
  findModelsFromPoint(p: Point): Element[];
238
292
 
239
- findModelsInArea(rect: BBox, opt?: { strict?: boolean }): Element[];
293
+ /** @deprecated use `findElementsInArea` instead */
294
+ findModelsInArea(rect: BBox, opt?: Graph.FindInAreaOptions): Element[];
240
295
 
241
- findModelsUnderElement(element: Element, opt?: { searchBy?: 'bbox' | PositionName }): Element[];
296
+ /** @deprecated use `findElementsUnderElement` instead */
297
+ findModelsUnderElement(element: Element, opt?: Graph.FindUnderElementOptions): Element[];
242
298
 
243
299
  getBBox(): g.Rect | null;
244
300
 
@@ -252,6 +308,10 @@ export namespace dia {
252
308
 
253
309
  removeCells(cells: Cell[], opt?: Cell.DisconnectableOptions): this;
254
310
 
311
+ transferCellEmbeds(sourceCell: Cell, targetCell: Cell, opt?: S): void;
312
+
313
+ transferCellConnectedLinks(sourceCell: Cell, targetCell: Cell, opt?: Graph.ConnectionOptions): void;
314
+
255
315
  resize(width: number, height: number, opt?: S): this;
256
316
 
257
317
  resizeCells(width: number, height: number, cells: Cell[], opt?: S): this;
@@ -296,6 +356,10 @@ export namespace dia {
296
356
  [key: string]: any;
297
357
  }
298
358
 
359
+ interface EmbedOptions extends Options {
360
+ reparent?: boolean;
361
+ }
362
+
299
363
  interface EmbeddableOptions<T = boolean> extends Options {
300
364
  deep?: T;
301
365
  }
@@ -323,11 +387,57 @@ export namespace dia {
323
387
  interface ConstructorOptions extends Graph.Options {
324
388
  mergeArrays?: boolean;
325
389
  }
390
+
391
+ interface ExportOptions {
392
+ ignoreDefault?: boolean | string[];
393
+ ignoreEmptyAttributes?: boolean;
394
+ }
395
+
396
+ type UnsetCallback<V> = (
397
+ this: V,
398
+ node: Element,
399
+ nodeAttributes: { [name: string]: any },
400
+ cellView: V
401
+ ) => string | Array<string> | null | void;
402
+
403
+ type SetCallback<V> = (
404
+ this: V,
405
+ attributeValue: any,
406
+ refBBox: g.Rect,
407
+ node: Element,
408
+ nodeAttributes: { [name: string]: any },
409
+ cellView: V
410
+ ) => { [key: string]: any } | string | number | void;
411
+
412
+ type PositionCallback<V> = (
413
+ this: V,
414
+ attributeValue: any,
415
+ refBBox: g.Rect,
416
+ node: Element,
417
+ nodeAttributes: { [name: string]: any },
418
+ cellView: V
419
+ ) => dia.Point | null | void;
420
+
421
+ type OffsetCallback<V> = (
422
+ this: V,
423
+ attributeValue: any,
424
+ nodeBBox: g.Rect,
425
+ node: Element,
426
+ nodeAttributes: { [name: string]: any },
427
+ cellView: V
428
+ ) => dia.Point | null | void;
429
+
430
+ interface PresentationAttributeDefinition<V = dia.CellView> {
431
+ set?: SetCallback<V> | string;
432
+ unset?: UnsetCallback<V> | string | Array<string>;
433
+ position?: PositionCallback<V>;
434
+ offset?: OffsetCallback<V>;
435
+ }
326
436
  }
327
437
 
328
438
  class Cell<A extends ObjectHash = Cell.Attributes, S extends mvc.ModelSetOptions = dia.ModelSetOptions> extends mvc.Model<A, S> {
329
439
 
330
- constructor(attributes?: A, opt?: Cell.ConstructorOptions);
440
+ constructor(attributes?: DeepPartial<A>, opt?: Cell.ConstructorOptions);
331
441
 
332
442
  id: Cell.ID;
333
443
  graph: Graph;
@@ -340,7 +450,7 @@ export namespace dia {
340
450
 
341
451
  protected stopScheduledTransitions(path?: string, delim?: string): void;
342
452
 
343
- toJSON(): Cell.JSON<any, A>;
453
+ toJSON(opt?: dia.Cell.ExportOptions): Cell.JSON<any, A>;
344
454
 
345
455
  remove(opt?: Cell.DisconnectableOptions): this;
346
456
 
@@ -361,7 +471,7 @@ export namespace dia {
361
471
  isEmbedded(): boolean;
362
472
 
363
473
  prop(key: Path): any;
364
- prop(object: Partial<A>, opt?: Cell.Options): this;
474
+ prop(object: DeepPartial<A>, opt?: Cell.Options): this;
365
475
  prop(key: Path, value: any, opt?: Cell.Options): this;
366
476
 
367
477
  removeProp(path: Path, opt?: Cell.Options): this;
@@ -382,7 +492,7 @@ export namespace dia {
382
492
 
383
493
  stopTransitions(path?: string, delim?: string): this;
384
494
 
385
- embed(cell: Cell | Cell[], opt?: Graph.Options): this;
495
+ embed(cell: Cell | Cell[], opt?: Cell.EmbedOptions): this;
386
496
 
387
497
  unembed(cell: Cell | Cell[], opt?: Graph.Options): this;
388
498
 
@@ -493,6 +603,10 @@ export namespace dia {
493
603
  deep?: boolean;
494
604
  }
495
605
 
606
+ interface ResizeOptions extends Cell.Options {
607
+ direction?: Direction;
608
+ }
609
+
496
610
  interface BBoxOptions extends Cell.EmbeddableOptions {
497
611
  rotate?: boolean;
498
612
  }
@@ -506,9 +620,10 @@ export namespace dia {
506
620
  position(x: number, y: number, opt?: Element.PositionOptions): this;
507
621
 
508
622
  size(): Size;
509
- size(width: number, height?: number, opt?: { direction?: Direction, [key: string]: any }): this;
623
+ size(size: Partial<Size>, opt?: Element.ResizeOptions): this;
624
+ size(width: number, height: number, opt?: Element.ResizeOptions): this;
510
625
 
511
- resize(width: number, height: number, opt?: { direction?: Direction, [key: string]: any }): this;
626
+ resize(width: number, height: number, opt?: Element.ResizeOptions): this;
512
627
 
513
628
  rotate(deg: number, absolute?: boolean, origin?: Point, opt?: { [key: string]: any }): this;
514
629
 
@@ -548,6 +663,8 @@ export namespace dia {
548
663
 
549
664
  getPortIndex(port: string | Element.Port): number;
550
665
 
666
+ getPortGroupNames(): string[];
667
+
551
668
  portProp(portId: string, path: dia.Path): any;
552
669
 
553
670
  portProp(portId: string, path: dia.Path, value?: any, opt?: S): Element;
@@ -555,6 +672,8 @@ export namespace dia {
555
672
  protected generatePortId(): string | number;
556
673
 
557
674
  static define(type: string, defaults?: any, protoProps?: any, staticProps?: any): Cell.Constructor<Element>;
675
+
676
+ static attributes: { [attributeName: string]: Cell.PresentationAttributeDefinition<ElementView> };
558
677
  }
559
678
 
560
679
  // dia.Link
@@ -703,6 +822,8 @@ export namespace dia {
703
822
  translate(tx: number, ty: number, opt?: S): this;
704
823
 
705
824
  static define(type: string, defaults?: any, protoProps?: any, staticProps?: any): Cell.Constructor<Link>;
825
+
826
+ static attributes: { [attributeName: string]: Cell.PresentationAttributeDefinition<LinkView> };
706
827
  }
707
828
 
708
829
  // dia.CellView
@@ -820,6 +941,14 @@ export namespace dia {
820
941
 
821
942
  isDefaultInteractionPrevented(evt: dia.Event): boolean;
822
943
 
944
+ isIntersecting(geometryShape: g.Shape, geometryData?: g.SegmentSubdivisionsOpt | null): boolean;
945
+
946
+ protected isEnclosedIn(area: g.Rect): boolean;
947
+
948
+ protected isInArea(area: g.Rect, options: g.StrictOpt): boolean;
949
+
950
+ protected isAtPoint(point: g.Point, options: g.StrictOpt): boolean;
951
+
823
952
  protected findBySelector(selector: string, root?: SVGElement): SVGElement[];
824
953
 
825
954
  protected removeHighlighters(): void;
@@ -921,6 +1050,8 @@ export namespace dia {
921
1050
 
922
1051
  getDelegatedView(): ElementView | null;
923
1052
 
1053
+ getTargetParentView(evt: dia.Event): CellView | null;
1054
+
924
1055
  findPortNode(portId: string | number): SVGElement | null;
925
1056
  findPortNode(portId: string | number, selector: string): E | null;
926
1057
 
@@ -1009,6 +1140,11 @@ export namespace dia {
1009
1140
  options: LinkView.Options<L>;
1010
1141
  sourceAnchor: g.Point;
1011
1142
  targetAnchor: g.Point;
1143
+ sourcePoint: g.Point;
1144
+ targetPoint: g.Point;
1145
+ sourceBBox: g.Rect;
1146
+ targetBBox: g.Rect;
1147
+ route: g.Point[];
1012
1148
 
1013
1149
  sendToken(token: SVGElement, duration?: number, callback?: () => void): void;
1014
1150
  sendToken(token: SVGElement, opt?: { duration?: number, direction?: string, connection?: string }, callback?: () => void): void;
@@ -1215,6 +1351,11 @@ export namespace dia {
1215
1351
  afterRender?: AfterRenderCallback;
1216
1352
  }
1217
1353
 
1354
+ interface SnapLinksOptions {
1355
+ radius?: number;
1356
+ findInAreaOptions?: FindInAreaOptions;
1357
+ }
1358
+
1218
1359
  type PointConstraintCallback = (x: number, y: number, opt: any) => Point;
1219
1360
  type RestrictTranslateCallback = (elementView: ElementView, x0: number, y0: number) => BBox | boolean | PointConstraintCallback;
1220
1361
  type FindParentByType = 'bbox' | 'pointer' | PositionName;
@@ -1233,7 +1374,7 @@ export namespace dia {
1233
1374
  highlighting?: boolean | Record<string | dia.CellView.Highlighting, highlighters.HighlighterJSON | boolean>;
1234
1375
  interactive?: ((cellView: CellView, event: string) => boolean | CellView.InteractivityOptions) | boolean | CellView.InteractivityOptions;
1235
1376
  snapLabels?: boolean;
1236
- snapLinks?: boolean | { radius: number };
1377
+ snapLinks?: boolean | SnapLinksOptions;
1237
1378
  snapLinksSelf?: boolean | { distance: number };
1238
1379
  markAvailable?: boolean;
1239
1380
  // validations
@@ -1407,6 +1548,20 @@ export namespace dia {
1407
1548
  // custom
1408
1549
  [eventName: string]: mvc.EventHandler;
1409
1550
  }
1551
+
1552
+ interface BufferOptions {
1553
+ /**
1554
+ * A buffer around the area to extend the search to
1555
+ * to mitigate the differences between the model and view geometry.
1556
+ */
1557
+ buffer?: number;
1558
+ }
1559
+
1560
+ interface FindAtPointOptions extends Graph.FindAtPointOptions, BufferOptions {
1561
+ }
1562
+
1563
+ interface FindInAreaOptions extends Graph.FindInAreaOptions, BufferOptions {
1564
+ }
1410
1565
  }
1411
1566
 
1412
1567
  class Paper extends mvc.View<Graph> {
@@ -1500,19 +1655,52 @@ export namespace dia {
1500
1655
 
1501
1656
  findViewByModel<T extends ElementView | LinkView>(model: Cell | Cell.ID): T;
1502
1657
 
1503
- findViewsFromPoint(point: string | Point): ElementView[];
1658
+ /**
1659
+ * Finds all the element views at the specified point
1660
+ * @param point a point in local paper coordinates
1661
+ * @param opt options for the search
1662
+ */
1663
+ findElementViewsAtPoint(point: Point, opt?: Paper.FindAtPointOptions): ElementView[];
1504
1664
 
1505
- findViewsInArea(rect: BBox, opt?: { strict?: boolean }): ElementView[];
1665
+ /**
1666
+ * Finds all the link views at the specified point
1667
+ * @param point a point in local paper coordinates
1668
+ * @param opt options for the search
1669
+ */
1670
+ findLinkViewsAtPoint(point: Point, opt?: Paper.FindAtPointOptions): LinkView[];
1506
1671
 
1507
- fitToContent(opt?: Paper.FitToContentOptions): g.Rect;
1508
- fitToContent(gridWidth?: number, gridHeight?: number, padding?: number, opt?: any): g.Rect;
1672
+ /**
1673
+ * Finds all the cell views at the specified point
1674
+ * @param point a point in local paper coordinates
1675
+ * @param opt options for the search
1676
+ */
1677
+ findCellViewsAtPoint(point: Point, opt?: Paper.FindAtPointOptions): CellView[];
1509
1678
 
1510
- getFitToContentArea(opt?: Paper.FitToContentOptions): g.Rect;
1679
+ /**
1680
+ * Finds all the element views in the specified area
1681
+ * @param area a rectangle in local paper coordinates
1682
+ * @param opt options for the search
1683
+ */
1684
+ findElementViewsInArea(area: BBox, opt?: Paper.FindInAreaOptions): ElementView[];
1511
1685
 
1512
1686
  /**
1513
- * @deprecated use transformToFitContent
1687
+ * Finds all the link views in the specified area
1688
+ * @param area a rectangle in local paper coordinates
1689
+ * @param opt options for the search
1514
1690
  */
1515
- scaleContentToFit(opt?: Paper.ScaleContentOptions): void;
1691
+ findLinkViewsInArea(area: BBox, opt?: Paper.FindInAreaOptions): LinkView[];
1692
+
1693
+ /**
1694
+ * Finds all the cell views in the specified area
1695
+ * @param area a rectangle in local paper coordinates
1696
+ * @param opt options for the search
1697
+ */
1698
+ findCellViewsInArea(area: BBox, opt?: Paper.FindInAreaOptions): CellView[];
1699
+
1700
+ fitToContent(opt?: Paper.FitToContentOptions): g.Rect;
1701
+ fitToContent(gridWidth?: number, gridHeight?: number, padding?: number, opt?: any): g.Rect;
1702
+
1703
+ getFitToContentArea(opt?: Paper.FitToContentOptions): g.Rect;
1516
1704
 
1517
1705
  transformToFitContent(opt?: Paper.TransformToFitContentOptions): void;
1518
1706
 
@@ -1585,7 +1773,6 @@ export namespace dia {
1585
1773
  mountBatchSize?: number;
1586
1774
  unmountBatchSize?: number;
1587
1775
  viewport?: Paper.ViewportCallback;
1588
- progress?: Paper.ProgressCallback;
1589
1776
  }): void;
1590
1777
 
1591
1778
  checkViewport(opt?: {
@@ -1600,10 +1787,10 @@ export namespace dia {
1600
1787
  updateViews(opt?: {
1601
1788
  batchSize?: number;
1602
1789
  viewport?: Paper.ViewportCallback;
1603
- progress?: Paper.ProgressCallback;
1604
1790
  }): {
1605
1791
  updated: number;
1606
1792
  batches: number;
1793
+ priority: number;
1607
1794
  };
1608
1795
 
1609
1796
  hasScheduledUpdates(): boolean;
@@ -1743,6 +1930,21 @@ export namespace dia {
1743
1930
  protected customEventTrigger(event: dia.Event, view: CellView, rootNode?: SVGElement): dia.Event | null;
1744
1931
 
1745
1932
  protected addStylesheet(stylesheet: string): void;
1933
+
1934
+ /**
1935
+ * @deprecated use `findElementViewsAtPoint()
1936
+ */
1937
+ findViewsFromPoint(point: string | Point): ElementView[];
1938
+
1939
+ /**
1940
+ * @deprecated use `findElementViewsInArea()
1941
+ */
1942
+ findViewsInArea(rect: BBox, opt?: { strict?: boolean }): ElementView[];
1943
+
1944
+ /**
1945
+ * @deprecated use transformToFitContent
1946
+ */
1947
+ scaleContentToFit(opt?: Paper.ScaleContentOptions): void;
1746
1948
  }
1747
1949
 
1748
1950
  namespace PaperLayer {
@@ -1804,21 +2006,25 @@ export namespace dia {
1804
2006
  }
1805
2007
 
1806
2008
  namespace ToolView {
1807
- interface Options extends mvc.ViewOptions<undefined, SVGElement> {
2009
+
2010
+ type VisibilityCallback<V = dia.CellView> = (this: ToolView, view: V, tool: ToolView) => boolean;
2011
+
2012
+ interface Options<V = dia.CellView> extends mvc.ViewOptions<undefined, SVGElement> {
1808
2013
  focusOpacity?: number;
2014
+ visibility?: VisibilityCallback<V>;
1809
2015
  }
1810
2016
  }
1811
2017
 
1812
- class ToolView extends mvc.View<undefined, SVGElement> {
2018
+ class ToolView<V = dia.CellView> extends mvc.View<undefined, SVGElement> {
1813
2019
 
1814
2020
  name: string | null;
1815
2021
  parentView: ToolsView;
1816
2022
  relatedView: dia.CellView;
1817
2023
  paper: Paper;
1818
2024
 
1819
- constructor(opt?: ToolView.Options);
2025
+ constructor(opt?: ToolView.Options<V>);
1820
2026
 
1821
- configure(opt?: ToolView.Options): this;
2027
+ configure(opt?: ToolView.Options<V>): this;
1822
2028
 
1823
2029
  protected simulateRelatedView(el: SVGElement): void;
1824
2030
 
@@ -1828,6 +2034,12 @@ export namespace dia {
1828
2034
 
1829
2035
  isVisible(): boolean;
1830
2036
 
2037
+ isExplicitlyVisible(): boolean;
2038
+
2039
+ updateVisibility(): void;
2040
+
2041
+ protected computeVisibility(): boolean;
2042
+
1831
2043
  focus(): void;
1832
2044
 
1833
2045
  blur(): void;
@@ -1920,6 +2132,11 @@ export namespace dia {
1920
2132
  cellView: dia.CellView
1921
2133
  ): T[];
1922
2134
 
2135
+ static getAll<T extends HighlighterView = HighlighterView>(
2136
+ paper: dia.Paper,
2137
+ id?: string
2138
+ ): T[];
2139
+
1923
2140
  static update(cellView: dia.CellView, id?: string): void;
1924
2141
 
1925
2142
  static transform(cellView: dia.CellView, id?: string): void;
@@ -2367,6 +2584,12 @@ export namespace shapes {
2367
2584
 
2368
2585
  export namespace util {
2369
2586
 
2587
+ export function isCalcExpression(value: any): boolean;
2588
+
2589
+ export function evalCalcFormula(formula: string, rect: g.PlainRect): number;
2590
+
2591
+ export function evalCalcExpression(expression: string, rect: g.PlainRect): string;
2592
+
2370
2593
  export function hashCode(str: string): string;
2371
2594
 
2372
2595
  export function getByPath(object: { [key: string]: any }, path: string | string[], delim?: string): any;
@@ -2437,6 +2660,8 @@ export namespace util {
2437
2660
 
2438
2661
  export function toggleFullScreen(el?: Element): void;
2439
2662
 
2663
+ export function objectDifference(object: object, base: object, opt?: { maxDepth?: number }): object;
2664
+
2440
2665
  interface DOMJSONDocument {
2441
2666
  fragment: DocumentFragment;
2442
2667
  selectors: { [key: string]: Element };
@@ -4067,9 +4292,9 @@ export namespace elementTools {
4067
4292
 
4068
4293
  namespace Button {
4069
4294
 
4070
- type ActionCallback = (evt: dia.Event, view: dia.ElementView, tool: dia.ToolView) => void;
4295
+ type ActionCallback = (evt: dia.Event, view: dia.ElementView, tool: Button) => void;
4071
4296
 
4072
- interface Options extends dia.ToolView.Options {
4297
+ interface Options extends dia.ToolView.Options<dia.ElementView> {
4073
4298
  x?: number | string;
4074
4299
  y?: number | string;
4075
4300
  offset?: { x?: number, y?: number };
@@ -4081,7 +4306,7 @@ export namespace elementTools {
4081
4306
  }
4082
4307
  }
4083
4308
 
4084
- class Button extends dia.ToolView {
4309
+ class Button extends dia.ToolView<dia.ElementView> {
4085
4310
 
4086
4311
  constructor(opt?: Button.Options);
4087
4312
 
@@ -4123,20 +4348,20 @@ export namespace elementTools {
4123
4348
  }
4124
4349
 
4125
4350
  namespace Boundary {
4126
- interface Options extends dia.ToolView.Options {
4351
+ interface Options extends dia.ToolView.Options<dia.ElementView> {
4127
4352
  padding?: number | dia.Sides;
4128
4353
  useModelGeometry?: boolean;
4129
4354
  rotate?: boolean;
4130
4355
  }
4131
4356
  }
4132
4357
 
4133
- class Boundary extends dia.ToolView {
4358
+ class Boundary extends dia.ToolView<dia.ElementView> {
4134
4359
 
4135
4360
  constructor(opt?: Boundary.Options);
4136
4361
  }
4137
4362
 
4138
4363
  namespace Control {
4139
- interface Options extends dia.ToolView.Options {
4364
+ interface Options extends dia.ToolView.Options<dia.ElementView> {
4140
4365
  selector?: string | null;
4141
4366
  padding?: number;
4142
4367
  handleAttributes?: Partial<attributes.NativeSVGAttributes>;
@@ -4144,13 +4369,13 @@ export namespace elementTools {
4144
4369
  }
4145
4370
  }
4146
4371
 
4147
- abstract class Control<T extends mvc.ViewOptions<undefined, SVGElement> = Control.Options> extends dia.ToolView {
4372
+ abstract class Control<T extends mvc.ViewOptions<undefined, SVGElement> = Control.Options> extends dia.ToolView<dia.ElementView> {
4148
4373
  options: T;
4149
4374
  constructor(opt?: T);
4150
4375
 
4151
4376
  protected getPosition(view: dia.ElementView): dia.Point;
4152
- protected setPosition(view: dia.ElementView, coordinates: g.Point): void;
4153
- protected resetPosition(view: dia.ElementView): void;
4377
+ protected setPosition(view: dia.ElementView, coordinates: g.Point, evt: dia.Event): void;
4378
+ protected resetPosition(view: dia.ElementView, evt: dia.Event): void;
4154
4379
 
4155
4380
  protected updateHandle(handleNode: SVGElement): void;
4156
4381
  protected updateExtras(extrasNode: SVGElement): void;
@@ -4175,7 +4400,7 @@ export namespace elementTools {
4175
4400
  }
4176
4401
  }
4177
4402
 
4178
- class HoverConnect extends linkTools.Connect {
4403
+ class HoverConnect extends Connect {
4179
4404
 
4180
4405
  constructor(opt?: HoverConnect.Options);
4181
4406
  }
@@ -4202,11 +4427,15 @@ export namespace linkTools {
4202
4427
  protected onPointerClick(evt: dia.Event): void;
4203
4428
  }
4204
4429
 
4205
- interface Options extends dia.ToolView.Options {
4430
+ interface VertexAddingOptions {
4431
+ interactiveLineNode: string;
4432
+ }
4433
+
4434
+ interface Options extends dia.ToolView.Options<dia.LinkView> {
4206
4435
  handleClass?: typeof VertexHandle;
4207
4436
  snapRadius?: number;
4208
4437
  redundancyRemoval?: boolean;
4209
- vertexAdding?: boolean;
4438
+ vertexAdding?: boolean | Partial<VertexAddingOptions>;
4210
4439
  vertexRemoving?: boolean;
4211
4440
  vertexMoving?: boolean;
4212
4441
  stopPropagation?: boolean;
@@ -4214,7 +4443,7 @@ export namespace linkTools {
4214
4443
  }
4215
4444
  }
4216
4445
 
4217
- class Vertices extends dia.ToolView {
4446
+ class Vertices extends dia.ToolView<dia.LinkView> {
4218
4447
 
4219
4448
  constructor(opt?: Vertices.Options);
4220
4449
  }
@@ -4230,7 +4459,7 @@ export namespace linkTools {
4230
4459
  protected onPointerUp(evt: dia.Event): void;
4231
4460
  }
4232
4461
 
4233
- interface Options extends dia.ToolView.Options {
4462
+ interface Options extends dia.ToolView.Options<dia.LinkView> {
4234
4463
  handleClass?: typeof SegmentHandle;
4235
4464
  snapRadius?: number;
4236
4465
  snapHandle?: boolean;
@@ -4242,19 +4471,19 @@ export namespace linkTools {
4242
4471
  }
4243
4472
  }
4244
4473
 
4245
- class Segments extends dia.ToolView {
4474
+ class Segments extends dia.ToolView<dia.LinkView> {
4246
4475
 
4247
4476
  constructor(opt?: Segments.Options);
4248
4477
  }
4249
4478
 
4250
4479
  namespace Arrowhead {
4251
4480
 
4252
- interface Options extends dia.ToolView.Options {
4481
+ interface Options extends dia.ToolView.Options<dia.LinkView> {
4253
4482
  scale?: number;
4254
4483
  }
4255
4484
  }
4256
4485
 
4257
- abstract class Arrowhead extends dia.ToolView {
4486
+ abstract class Arrowhead extends dia.ToolView<dia.LinkView> {
4258
4487
 
4259
4488
  ratio: number;
4260
4489
  arrowheadType: string;
@@ -4279,7 +4508,7 @@ export namespace linkTools {
4279
4508
  }
4280
4509
 
4281
4510
  namespace Anchor {
4282
- interface Options extends dia.ToolView.Options {
4511
+ interface Options extends dia.ToolView.Options<dia.LinkView> {
4283
4512
  snap?: AnchorCallback<dia.Point>;
4284
4513
  anchor?: AnchorCallback<anchors.AnchorJSON>;
4285
4514
  resetAnchor?: boolean | anchors.AnchorJSON;
@@ -4293,7 +4522,7 @@ export namespace linkTools {
4293
4522
  }
4294
4523
  }
4295
4524
 
4296
- abstract class Anchor extends dia.ToolView {
4525
+ abstract class Anchor extends dia.ToolView<dia.LinkView> {
4297
4526
 
4298
4527
  type: string;
4299
4528
 
@@ -4312,10 +4541,14 @@ export namespace linkTools {
4312
4541
 
4313
4542
  namespace Button {
4314
4543
 
4315
- type ActionCallback = (evt: dia.Event, view: dia.LinkView, tool: dia.ToolView) => void;
4544
+ type ActionCallback = (evt: dia.Event, view: dia.LinkView, tool: Button) => void;
4316
4545
 
4317
- interface Options extends dia.ToolView.Options {
4318
- distance?: number | string;
4546
+ type Distance = number | string;
4547
+
4548
+ type DistanceCallback = (this: Button, view: dia.LinkView, tool: Button) => Distance;
4549
+
4550
+ interface Options extends dia.ToolView.Options<dia.LinkView> {
4551
+ distance?: Distance | DistanceCallback;
4319
4552
  offset?: number;
4320
4553
  rotate?: boolean;
4321
4554
  action?: ActionCallback;
@@ -4324,7 +4557,7 @@ export namespace linkTools {
4324
4557
  }
4325
4558
  }
4326
4559
 
4327
- class Button extends dia.ToolView {
4560
+ class Button extends dia.ToolView<dia.LinkView> {
4328
4561
 
4329
4562
  constructor(opt?: Button.Options);
4330
4563
 
@@ -4358,13 +4591,13 @@ export namespace linkTools {
4358
4591
  }
4359
4592
 
4360
4593
  namespace Boundary {
4361
- interface Options extends dia.ToolView.Options {
4594
+ interface Options extends dia.ToolView.Options<dia.LinkView> {
4362
4595
  padding?: number | dia.Sides;
4363
4596
  useModelGeometry?: boolean;
4364
4597
  }
4365
4598
  }
4366
4599
 
4367
- class Boundary extends dia.ToolView {
4600
+ class Boundary extends dia.ToolView<dia.LinkView> {
4368
4601
 
4369
4602
  constructor(opt?: Boundary.Options);
4370
4603
  }
@@ -4400,4 +4633,52 @@ export namespace linkTools {
4400
4633
 
4401
4634
  protected onMouseleave(evt: dia.Event): void;
4402
4635
  }
4636
+
4637
+ namespace Control {
4638
+ interface Options extends dia.ToolView.Options {
4639
+ selector?: string | null;
4640
+ padding?: number;
4641
+ handleAttributes?: Partial<attributes.NativeSVGAttributes>;
4642
+ scale?: number;
4643
+ }
4644
+ }
4645
+
4646
+ abstract class Control<T extends mvc.ViewOptions<undefined, SVGElement> = Control.Options> extends dia.ToolView {
4647
+ options: T;
4648
+ constructor(opt?: T);
4649
+
4650
+ protected getPosition(view: dia.LinkView): dia.Point;
4651
+ protected setPosition(view: dia.LinkView, coordinates: g.Point): void;
4652
+ protected resetPosition(view: dia.LinkView): void;
4653
+
4654
+ protected updateHandle(handleNode: SVGElement): void;
4655
+ protected updateExtras(extrasNode: SVGElement): void;
4656
+ protected toggleExtras(visible: boolean): void;
4657
+
4658
+ protected onPointerDown(evt: dia.Event): void;
4659
+ protected onPointerMove(evt: dia.Event): void;
4660
+ protected onPointerUp(evt: dia.Event): void;
4661
+ protected onPointerDblClick(evt: dia.Event): void;
4662
+ }
4663
+
4664
+ namespace RotateLabel {
4665
+
4666
+ interface Options extends Control.Options {
4667
+ offset?: number | dia.Point;
4668
+ buttonColor?: string;
4669
+ iconColor?: string;
4670
+ outlineColor?: string;
4671
+ }
4672
+ }
4673
+
4674
+ class RotateLabel extends Control<RotateLabel.Options> {
4675
+
4676
+ constructor(opt?: RotateLabel.Options);
4677
+
4678
+ protected getLabelPosition(label: dia.Link.Label): dia.Link.LabelPosition;
4679
+
4680
+ protected getLabelIndex(): number;
4681
+
4682
+ protected getLabel(): dia.Link.Label | null;
4683
+ }
4403
4684
  }