@joint/core 4.0.4 → 4.1.0

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 (54) hide show
  1. package/README.md +0 -8
  2. package/dist/geometry.js +4962 -6132
  3. package/dist/geometry.min.js +2 -2
  4. package/dist/joint.d.ts +328 -50
  5. package/dist/joint.js +34067 -37565
  6. package/dist/joint.min.js +2 -2
  7. package/dist/joint.nowrap.js +34067 -37565
  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 +42 -3
  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 +15 -5
  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/g/rect.mjs +13 -5
  35. package/src/layout/ports/port.mjs +4 -5
  36. package/src/linkTools/Anchor.mjs +1 -1
  37. package/src/linkTools/Arrowhead.mjs +2 -1
  38. package/src/linkTools/RotateLabel.mjs +110 -0
  39. package/src/linkTools/Segments.mjs +1 -1
  40. package/src/linkTools/Vertices.mjs +41 -4
  41. package/src/linkTools/index.mjs +7 -4
  42. package/src/mvc/View.mjs +0 -1
  43. package/src/mvc/ViewBase.mjs +2 -1
  44. package/src/routers/rightAngle.mjs +538 -140
  45. package/src/shapes/standard.mjs +8 -1
  46. package/src/{dia/attributes → util}/calc.mjs +24 -12
  47. package/src/util/index.mjs +1 -0
  48. package/src/util/util.mjs +39 -0
  49. package/src/util/utilHelpers.mjs +2 -1
  50. package/types/geometry.d.ts +6 -1
  51. package/types/joint.d.ts +321 -48
  52. /package/src/{linkTools → cellTools}/Boundary.mjs +0 -0
  53. /package/src/{linkTools → cellTools}/Connect.mjs +0 -0
  54. /package/src/{linkTools → cellTools}/helpers.mjs +0 -0
package/types/joint.d.ts CHANGED
@@ -65,10 +65,11 @@ export namespace dia {
65
65
  type OrthogonalDirection =
66
66
  'left' | 'top' | 'right' | 'bottom';
67
67
 
68
- type Direction =
69
- OrthogonalDirection |
68
+ type DiagonalDirection =
70
69
  'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
71
70
 
71
+ type Direction = OrthogonalDirection | DiagonalDirection;
72
+
72
73
  type LinkEnd =
73
74
  'source' | 'target';
74
75
 
@@ -162,6 +163,20 @@ export namespace dia {
162
163
  breadthFirst?: boolean;
163
164
  }
164
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
+
165
180
  class Cells extends mvc.Collection<Cell> {
166
181
  graph: Graph;
167
182
  cellNamespace: any;
@@ -238,17 +253,48 @@ export namespace dia {
238
253
 
239
254
  getCommonAncestor(...cells: Cell[]): Element | undefined;
240
255
 
241
- toJSON(): any;
256
+ toJSON(opt?: { cellAttributes?: dia.Cell.ExportOptions }): any;
242
257
 
243
258
  fromJSON(json: any, opt?: S): this;
244
259
 
245
260
  clear(opt?: { [key: string]: any }): this;
246
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 */
247
291
  findModelsFromPoint(p: Point): Element[];
248
292
 
249
- findModelsInArea(rect: BBox, opt?: { strict?: boolean }): Element[];
293
+ /** @deprecated use `findElementsInArea` instead */
294
+ findModelsInArea(rect: BBox, opt?: Graph.FindInAreaOptions): Element[];
250
295
 
251
- findModelsUnderElement(element: Element, opt?: { searchBy?: 'bbox' | PositionName }): Element[];
296
+ /** @deprecated use `findElementsUnderElement` instead */
297
+ findModelsUnderElement(element: Element, opt?: Graph.FindUnderElementOptions): Element[];
252
298
 
253
299
  getBBox(): g.Rect | null;
254
300
 
@@ -262,6 +308,10 @@ export namespace dia {
262
308
 
263
309
  removeCells(cells: Cell[], opt?: Cell.DisconnectableOptions): this;
264
310
 
311
+ transferCellEmbeds(sourceCell: Cell, targetCell: Cell, opt?: S): void;
312
+
313
+ transferCellConnectedLinks(sourceCell: Cell, targetCell: Cell, opt?: Graph.ConnectionOptions): void;
314
+
265
315
  resize(width: number, height: number, opt?: S): this;
266
316
 
267
317
  resizeCells(width: number, height: number, cells: Cell[], opt?: S): this;
@@ -306,6 +356,10 @@ export namespace dia {
306
356
  [key: string]: any;
307
357
  }
308
358
 
359
+ interface EmbedOptions extends Options {
360
+ reparent?: boolean;
361
+ }
362
+
309
363
  interface EmbeddableOptions<T = boolean> extends Options {
310
364
  deep?: T;
311
365
  }
@@ -333,6 +387,52 @@ export namespace dia {
333
387
  interface ConstructorOptions extends Graph.Options {
334
388
  mergeArrays?: boolean;
335
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
+ }
336
436
  }
337
437
 
338
438
  class Cell<A extends ObjectHash = Cell.Attributes, S extends mvc.ModelSetOptions = dia.ModelSetOptions> extends mvc.Model<A, S> {
@@ -350,7 +450,7 @@ export namespace dia {
350
450
 
351
451
  protected stopScheduledTransitions(path?: string, delim?: string): void;
352
452
 
353
- toJSON(): Cell.JSON<any, A>;
453
+ toJSON(opt?: dia.Cell.ExportOptions): Cell.JSON<any, A>;
354
454
 
355
455
  remove(opt?: Cell.DisconnectableOptions): this;
356
456
 
@@ -392,7 +492,7 @@ export namespace dia {
392
492
 
393
493
  stopTransitions(path?: string, delim?: string): this;
394
494
 
395
- embed(cell: Cell | Cell[], opt?: Graph.Options): this;
495
+ embed(cell: Cell | Cell[], opt?: Cell.EmbedOptions): this;
396
496
 
397
497
  unembed(cell: Cell | Cell[], opt?: Graph.Options): this;
398
498
 
@@ -503,6 +603,10 @@ export namespace dia {
503
603
  deep?: boolean;
504
604
  }
505
605
 
606
+ interface ResizeOptions extends Cell.Options {
607
+ direction?: Direction;
608
+ }
609
+
506
610
  interface BBoxOptions extends Cell.EmbeddableOptions {
507
611
  rotate?: boolean;
508
612
  }
@@ -516,9 +620,10 @@ export namespace dia {
516
620
  position(x: number, y: number, opt?: Element.PositionOptions): this;
517
621
 
518
622
  size(): Size;
519
- 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;
520
625
 
521
- resize(width: number, height: number, opt?: { direction?: Direction, [key: string]: any }): this;
626
+ resize(width: number, height: number, opt?: Element.ResizeOptions): this;
522
627
 
523
628
  rotate(deg: number, absolute?: boolean, origin?: Point, opt?: { [key: string]: any }): this;
524
629
 
@@ -558,6 +663,8 @@ export namespace dia {
558
663
 
559
664
  getPortIndex(port: string | Element.Port): number;
560
665
 
666
+ getPortGroupNames(): string[];
667
+
561
668
  portProp(portId: string, path: dia.Path): any;
562
669
 
563
670
  portProp(portId: string, path: dia.Path, value?: any, opt?: S): Element;
@@ -565,6 +672,8 @@ export namespace dia {
565
672
  protected generatePortId(): string | number;
566
673
 
567
674
  static define(type: string, defaults?: any, protoProps?: any, staticProps?: any): Cell.Constructor<Element>;
675
+
676
+ static attributes: { [attributeName: string]: Cell.PresentationAttributeDefinition<ElementView> };
568
677
  }
569
678
 
570
679
  // dia.Link
@@ -713,6 +822,8 @@ export namespace dia {
713
822
  translate(tx: number, ty: number, opt?: S): this;
714
823
 
715
824
  static define(type: string, defaults?: any, protoProps?: any, staticProps?: any): Cell.Constructor<Link>;
825
+
826
+ static attributes: { [attributeName: string]: Cell.PresentationAttributeDefinition<LinkView> };
716
827
  }
717
828
 
718
829
  // dia.CellView
@@ -830,6 +941,14 @@ export namespace dia {
830
941
 
831
942
  isDefaultInteractionPrevented(evt: dia.Event): boolean;
832
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
+
833
952
  protected findBySelector(selector: string, root?: SVGElement): SVGElement[];
834
953
 
835
954
  protected removeHighlighters(): void;
@@ -931,6 +1050,8 @@ export namespace dia {
931
1050
 
932
1051
  getDelegatedView(): ElementView | null;
933
1052
 
1053
+ getTargetParentView(evt: dia.Event): CellView | null;
1054
+
934
1055
  findPortNode(portId: string | number): SVGElement | null;
935
1056
  findPortNode(portId: string | number, selector: string): E | null;
936
1057
 
@@ -1019,6 +1140,11 @@ export namespace dia {
1019
1140
  options: LinkView.Options<L>;
1020
1141
  sourceAnchor: g.Point;
1021
1142
  targetAnchor: g.Point;
1143
+ sourcePoint: g.Point;
1144
+ targetPoint: g.Point;
1145
+ sourceBBox: g.Rect;
1146
+ targetBBox: g.Rect;
1147
+ route: g.Point[];
1022
1148
 
1023
1149
  sendToken(token: SVGElement, duration?: number, callback?: () => void): void;
1024
1150
  sendToken(token: SVGElement, opt?: { duration?: number, direction?: string, connection?: string }, callback?: () => void): void;
@@ -1225,6 +1351,11 @@ export namespace dia {
1225
1351
  afterRender?: AfterRenderCallback;
1226
1352
  }
1227
1353
 
1354
+ interface SnapLinksOptions {
1355
+ radius?: number;
1356
+ findInAreaOptions?: FindInAreaOptions;
1357
+ }
1358
+
1228
1359
  type PointConstraintCallback = (x: number, y: number, opt: any) => Point;
1229
1360
  type RestrictTranslateCallback = (elementView: ElementView, x0: number, y0: number) => BBox | boolean | PointConstraintCallback;
1230
1361
  type FindParentByType = 'bbox' | 'pointer' | PositionName;
@@ -1243,7 +1374,7 @@ export namespace dia {
1243
1374
  highlighting?: boolean | Record<string | dia.CellView.Highlighting, highlighters.HighlighterJSON | boolean>;
1244
1375
  interactive?: ((cellView: CellView, event: string) => boolean | CellView.InteractivityOptions) | boolean | CellView.InteractivityOptions;
1245
1376
  snapLabels?: boolean;
1246
- snapLinks?: boolean | { radius: number };
1377
+ snapLinks?: boolean | SnapLinksOptions;
1247
1378
  snapLinksSelf?: boolean | { distance: number };
1248
1379
  markAvailable?: boolean;
1249
1380
  // validations
@@ -1417,6 +1548,20 @@ export namespace dia {
1417
1548
  // custom
1418
1549
  [eventName: string]: mvc.EventHandler;
1419
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
+ }
1420
1565
  }
1421
1566
 
1422
1567
  class Paper extends mvc.View<Graph> {
@@ -1510,19 +1655,52 @@ export namespace dia {
1510
1655
 
1511
1656
  findViewByModel<T extends ElementView | LinkView>(model: Cell | Cell.ID): T;
1512
1657
 
1513
- 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[];
1514
1664
 
1515
- 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[];
1516
1671
 
1517
- fitToContent(opt?: Paper.FitToContentOptions): g.Rect;
1518
- 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[];
1519
1678
 
1520
- 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[];
1521
1685
 
1522
1686
  /**
1523
- * @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
1524
1690
  */
1525
- 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;
1526
1704
 
1527
1705
  transformToFitContent(opt?: Paper.TransformToFitContentOptions): void;
1528
1706
 
@@ -1595,7 +1773,6 @@ export namespace dia {
1595
1773
  mountBatchSize?: number;
1596
1774
  unmountBatchSize?: number;
1597
1775
  viewport?: Paper.ViewportCallback;
1598
- progress?: Paper.ProgressCallback;
1599
1776
  }): void;
1600
1777
 
1601
1778
  checkViewport(opt?: {
@@ -1610,10 +1787,10 @@ export namespace dia {
1610
1787
  updateViews(opt?: {
1611
1788
  batchSize?: number;
1612
1789
  viewport?: Paper.ViewportCallback;
1613
- progress?: Paper.ProgressCallback;
1614
1790
  }): {
1615
1791
  updated: number;
1616
1792
  batches: number;
1793
+ priority: number;
1617
1794
  };
1618
1795
 
1619
1796
  hasScheduledUpdates(): boolean;
@@ -1753,6 +1930,21 @@ export namespace dia {
1753
1930
  protected customEventTrigger(event: dia.Event, view: CellView, rootNode?: SVGElement): dia.Event | null;
1754
1931
 
1755
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;
1756
1948
  }
1757
1949
 
1758
1950
  namespace PaperLayer {
@@ -1814,21 +2006,25 @@ export namespace dia {
1814
2006
  }
1815
2007
 
1816
2008
  namespace ToolView {
1817
- 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> {
1818
2013
  focusOpacity?: number;
2014
+ visibility?: VisibilityCallback<V>;
1819
2015
  }
1820
2016
  }
1821
2017
 
1822
- class ToolView extends mvc.View<undefined, SVGElement> {
2018
+ class ToolView<V = dia.CellView> extends mvc.View<undefined, SVGElement> {
1823
2019
 
1824
2020
  name: string | null;
1825
2021
  parentView: ToolsView;
1826
2022
  relatedView: dia.CellView;
1827
2023
  paper: Paper;
1828
2024
 
1829
- constructor(opt?: ToolView.Options);
2025
+ constructor(opt?: ToolView.Options<V>);
1830
2026
 
1831
- configure(opt?: ToolView.Options): this;
2027
+ configure(opt?: ToolView.Options<V>): this;
1832
2028
 
1833
2029
  protected simulateRelatedView(el: SVGElement): void;
1834
2030
 
@@ -1838,6 +2034,12 @@ export namespace dia {
1838
2034
 
1839
2035
  isVisible(): boolean;
1840
2036
 
2037
+ isExplicitlyVisible(): boolean;
2038
+
2039
+ updateVisibility(): void;
2040
+
2041
+ protected computeVisibility(): boolean;
2042
+
1841
2043
  focus(): void;
1842
2044
 
1843
2045
  blur(): void;
@@ -1930,6 +2132,11 @@ export namespace dia {
1930
2132
  cellView: dia.CellView
1931
2133
  ): T[];
1932
2134
 
2135
+ static getAll<T extends HighlighterView = HighlighterView>(
2136
+ paper: dia.Paper,
2137
+ id?: string
2138
+ ): T[];
2139
+
1933
2140
  static update(cellView: dia.CellView, id?: string): void;
1934
2141
 
1935
2142
  static transform(cellView: dia.CellView, id?: string): void;
@@ -2377,6 +2584,14 @@ export namespace shapes {
2377
2584
 
2378
2585
  export namespace util {
2379
2586
 
2587
+ export function cloneCells(cells: dia.Cell[]): { [id: string]: dia.Cell };
2588
+
2589
+ export function isCalcExpression(value: any): boolean;
2590
+
2591
+ export function evalCalcFormula(formula: string, rect: g.PlainRect): number;
2592
+
2593
+ export function evalCalcExpression(expression: string, rect: g.PlainRect): string;
2594
+
2380
2595
  export function hashCode(str: string): string;
2381
2596
 
2382
2597
  export function getByPath(object: { [key: string]: any }, path: string | string[], delim?: string): any;
@@ -2447,6 +2662,8 @@ export namespace util {
2447
2662
 
2448
2663
  export function toggleFullScreen(el?: Element): void;
2449
2664
 
2665
+ export function objectDifference(object: object, base: object, opt?: { maxDepth?: number }): object;
2666
+
2450
2667
  interface DOMJSONDocument {
2451
2668
  fragment: DocumentFragment;
2452
2669
  selectors: { [key: string]: Element };
@@ -4077,9 +4294,9 @@ export namespace elementTools {
4077
4294
 
4078
4295
  namespace Button {
4079
4296
 
4080
- type ActionCallback = (evt: dia.Event, view: dia.ElementView, tool: dia.ToolView) => void;
4297
+ type ActionCallback = (evt: dia.Event, view: dia.ElementView, tool: Button) => void;
4081
4298
 
4082
- interface Options extends dia.ToolView.Options {
4299
+ interface Options extends dia.ToolView.Options<dia.ElementView> {
4083
4300
  x?: number | string;
4084
4301
  y?: number | string;
4085
4302
  offset?: { x?: number, y?: number };
@@ -4091,7 +4308,7 @@ export namespace elementTools {
4091
4308
  }
4092
4309
  }
4093
4310
 
4094
- class Button extends dia.ToolView {
4311
+ class Button extends dia.ToolView<dia.ElementView> {
4095
4312
 
4096
4313
  constructor(opt?: Button.Options);
4097
4314
 
@@ -4133,20 +4350,20 @@ export namespace elementTools {
4133
4350
  }
4134
4351
 
4135
4352
  namespace Boundary {
4136
- interface Options extends dia.ToolView.Options {
4353
+ interface Options extends dia.ToolView.Options<dia.ElementView> {
4137
4354
  padding?: number | dia.Sides;
4138
4355
  useModelGeometry?: boolean;
4139
4356
  rotate?: boolean;
4140
4357
  }
4141
4358
  }
4142
4359
 
4143
- class Boundary extends dia.ToolView {
4360
+ class Boundary extends dia.ToolView<dia.ElementView> {
4144
4361
 
4145
4362
  constructor(opt?: Boundary.Options);
4146
4363
  }
4147
4364
 
4148
4365
  namespace Control {
4149
- interface Options extends dia.ToolView.Options {
4366
+ interface Options extends dia.ToolView.Options<dia.ElementView> {
4150
4367
  selector?: string | null;
4151
4368
  padding?: number;
4152
4369
  handleAttributes?: Partial<attributes.NativeSVGAttributes>;
@@ -4154,13 +4371,13 @@ export namespace elementTools {
4154
4371
  }
4155
4372
  }
4156
4373
 
4157
- abstract class Control<T extends mvc.ViewOptions<undefined, SVGElement> = Control.Options> extends dia.ToolView {
4374
+ abstract class Control<T extends mvc.ViewOptions<undefined, SVGElement> = Control.Options> extends dia.ToolView<dia.ElementView> {
4158
4375
  options: T;
4159
4376
  constructor(opt?: T);
4160
4377
 
4161
4378
  protected getPosition(view: dia.ElementView): dia.Point;
4162
- protected setPosition(view: dia.ElementView, coordinates: g.Point): void;
4163
- protected resetPosition(view: dia.ElementView): void;
4379
+ protected setPosition(view: dia.ElementView, coordinates: g.Point, evt: dia.Event): void;
4380
+ protected resetPosition(view: dia.ElementView, evt: dia.Event): void;
4164
4381
 
4165
4382
  protected updateHandle(handleNode: SVGElement): void;
4166
4383
  protected updateExtras(extrasNode: SVGElement): void;
@@ -4185,7 +4402,7 @@ export namespace elementTools {
4185
4402
  }
4186
4403
  }
4187
4404
 
4188
- class HoverConnect extends linkTools.Connect {
4405
+ class HoverConnect extends Connect {
4189
4406
 
4190
4407
  constructor(opt?: HoverConnect.Options);
4191
4408
  }
@@ -4212,11 +4429,15 @@ export namespace linkTools {
4212
4429
  protected onPointerClick(evt: dia.Event): void;
4213
4430
  }
4214
4431
 
4215
- interface Options extends dia.ToolView.Options {
4432
+ interface VertexAddingOptions {
4433
+ interactiveLineNode: string;
4434
+ }
4435
+
4436
+ interface Options extends dia.ToolView.Options<dia.LinkView> {
4216
4437
  handleClass?: typeof VertexHandle;
4217
4438
  snapRadius?: number;
4218
4439
  redundancyRemoval?: boolean;
4219
- vertexAdding?: boolean;
4440
+ vertexAdding?: boolean | Partial<VertexAddingOptions>;
4220
4441
  vertexRemoving?: boolean;
4221
4442
  vertexMoving?: boolean;
4222
4443
  stopPropagation?: boolean;
@@ -4224,7 +4445,7 @@ export namespace linkTools {
4224
4445
  }
4225
4446
  }
4226
4447
 
4227
- class Vertices extends dia.ToolView {
4448
+ class Vertices extends dia.ToolView<dia.LinkView> {
4228
4449
 
4229
4450
  constructor(opt?: Vertices.Options);
4230
4451
  }
@@ -4240,7 +4461,7 @@ export namespace linkTools {
4240
4461
  protected onPointerUp(evt: dia.Event): void;
4241
4462
  }
4242
4463
 
4243
- interface Options extends dia.ToolView.Options {
4464
+ interface Options extends dia.ToolView.Options<dia.LinkView> {
4244
4465
  handleClass?: typeof SegmentHandle;
4245
4466
  snapRadius?: number;
4246
4467
  snapHandle?: boolean;
@@ -4252,19 +4473,19 @@ export namespace linkTools {
4252
4473
  }
4253
4474
  }
4254
4475
 
4255
- class Segments extends dia.ToolView {
4476
+ class Segments extends dia.ToolView<dia.LinkView> {
4256
4477
 
4257
4478
  constructor(opt?: Segments.Options);
4258
4479
  }
4259
4480
 
4260
4481
  namespace Arrowhead {
4261
4482
 
4262
- interface Options extends dia.ToolView.Options {
4483
+ interface Options extends dia.ToolView.Options<dia.LinkView> {
4263
4484
  scale?: number;
4264
4485
  }
4265
4486
  }
4266
4487
 
4267
- abstract class Arrowhead extends dia.ToolView {
4488
+ abstract class Arrowhead extends dia.ToolView<dia.LinkView> {
4268
4489
 
4269
4490
  ratio: number;
4270
4491
  arrowheadType: string;
@@ -4289,7 +4510,7 @@ export namespace linkTools {
4289
4510
  }
4290
4511
 
4291
4512
  namespace Anchor {
4292
- interface Options extends dia.ToolView.Options {
4513
+ interface Options extends dia.ToolView.Options<dia.LinkView> {
4293
4514
  snap?: AnchorCallback<dia.Point>;
4294
4515
  anchor?: AnchorCallback<anchors.AnchorJSON>;
4295
4516
  resetAnchor?: boolean | anchors.AnchorJSON;
@@ -4303,7 +4524,7 @@ export namespace linkTools {
4303
4524
  }
4304
4525
  }
4305
4526
 
4306
- abstract class Anchor extends dia.ToolView {
4527
+ abstract class Anchor extends dia.ToolView<dia.LinkView> {
4307
4528
 
4308
4529
  type: string;
4309
4530
 
@@ -4322,10 +4543,14 @@ export namespace linkTools {
4322
4543
 
4323
4544
  namespace Button {
4324
4545
 
4325
- type ActionCallback = (evt: dia.Event, view: dia.LinkView, tool: dia.ToolView) => void;
4546
+ type ActionCallback = (evt: dia.Event, view: dia.LinkView, tool: Button) => void;
4326
4547
 
4327
- interface Options extends dia.ToolView.Options {
4328
- distance?: number | string;
4548
+ type Distance = number | string;
4549
+
4550
+ type DistanceCallback = (this: Button, view: dia.LinkView, tool: Button) => Distance;
4551
+
4552
+ interface Options extends dia.ToolView.Options<dia.LinkView> {
4553
+ distance?: Distance | DistanceCallback;
4329
4554
  offset?: number;
4330
4555
  rotate?: boolean;
4331
4556
  action?: ActionCallback;
@@ -4334,7 +4559,7 @@ export namespace linkTools {
4334
4559
  }
4335
4560
  }
4336
4561
 
4337
- class Button extends dia.ToolView {
4562
+ class Button extends dia.ToolView<dia.LinkView> {
4338
4563
 
4339
4564
  constructor(opt?: Button.Options);
4340
4565
 
@@ -4368,13 +4593,13 @@ export namespace linkTools {
4368
4593
  }
4369
4594
 
4370
4595
  namespace Boundary {
4371
- interface Options extends dia.ToolView.Options {
4596
+ interface Options extends dia.ToolView.Options<dia.LinkView> {
4372
4597
  padding?: number | dia.Sides;
4373
4598
  useModelGeometry?: boolean;
4374
4599
  }
4375
4600
  }
4376
4601
 
4377
- class Boundary extends dia.ToolView {
4602
+ class Boundary extends dia.ToolView<dia.LinkView> {
4378
4603
 
4379
4604
  constructor(opt?: Boundary.Options);
4380
4605
  }
@@ -4410,4 +4635,52 @@ export namespace linkTools {
4410
4635
 
4411
4636
  protected onMouseleave(evt: dia.Event): void;
4412
4637
  }
4638
+
4639
+ namespace Control {
4640
+ interface Options extends dia.ToolView.Options {
4641
+ selector?: string | null;
4642
+ padding?: number;
4643
+ handleAttributes?: Partial<attributes.NativeSVGAttributes>;
4644
+ scale?: number;
4645
+ }
4646
+ }
4647
+
4648
+ abstract class Control<T extends mvc.ViewOptions<undefined, SVGElement> = Control.Options> extends dia.ToolView {
4649
+ options: T;
4650
+ constructor(opt?: T);
4651
+
4652
+ protected getPosition(view: dia.LinkView): dia.Point;
4653
+ protected setPosition(view: dia.LinkView, coordinates: g.Point): void;
4654
+ protected resetPosition(view: dia.LinkView): void;
4655
+
4656
+ protected updateHandle(handleNode: SVGElement): void;
4657
+ protected updateExtras(extrasNode: SVGElement): void;
4658
+ protected toggleExtras(visible: boolean): void;
4659
+
4660
+ protected onPointerDown(evt: dia.Event): void;
4661
+ protected onPointerMove(evt: dia.Event): void;
4662
+ protected onPointerUp(evt: dia.Event): void;
4663
+ protected onPointerDblClick(evt: dia.Event): void;
4664
+ }
4665
+
4666
+ namespace RotateLabel {
4667
+
4668
+ interface Options extends Control.Options {
4669
+ offset?: number | dia.Point;
4670
+ buttonColor?: string;
4671
+ iconColor?: string;
4672
+ outlineColor?: string;
4673
+ }
4674
+ }
4675
+
4676
+ class RotateLabel extends Control<RotateLabel.Options> {
4677
+
4678
+ constructor(opt?: RotateLabel.Options);
4679
+
4680
+ protected getLabelPosition(label: dia.Link.Label): dia.Link.LabelPosition;
4681
+
4682
+ protected getLabelIndex(): number;
4683
+
4684
+ protected getLabel(): dia.Link.Label | null;
4685
+ }
4413
4686
  }