@api-client/ui 0.2.2 → 0.2.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.
Files changed (170) hide show
  1. package/package.json +7 -2
  2. package/test/env.ts +15 -0
  3. package/test/tsconfig.json +1 -7
  4. package/web-test-runner.config.js +5 -1
  5. package/build/src/visualization/elements/VizAssociationElement.d.ts +0 -4
  6. package/build/src/visualization/elements/VizAssociationElement.d.ts.map +0 -1
  7. package/build/src/visualization/elements/VizAssociationElement.js +0 -4
  8. package/build/src/visualization/elements/VizAssociationElement.js.map +0 -1
  9. package/build/src/visualization/elements/VizWorkspaceElement.d.ts +0 -110
  10. package/build/src/visualization/elements/VizWorkspaceElement.d.ts.map +0 -1
  11. package/build/src/visualization/elements/VizWorkspaceElement.js +0 -321
  12. package/build/src/visualization/elements/VizWorkspaceElement.js.map +0 -1
  13. package/build/src/visualization/elements/WorkspaceStyles.d.ts +0 -3
  14. package/build/src/visualization/elements/WorkspaceStyles.d.ts.map +0 -1
  15. package/build/src/visualization/elements/WorkspaceStyles.js +0 -168
  16. package/build/src/visualization/elements/WorkspaceStyles.js.map +0 -1
  17. package/build/src/visualization/lib/AnchorFinder.d.ts +0 -64
  18. package/build/src/visualization/lib/AnchorFinder.d.ts.map +0 -1
  19. package/build/src/visualization/lib/AnchorFinder.js +0 -107
  20. package/build/src/visualization/lib/AnchorFinder.js.map +0 -1
  21. package/build/src/visualization/lib/AnchorUtils.d.ts +0 -10
  22. package/build/src/visualization/lib/AnchorUtils.d.ts.map +0 -1
  23. package/build/src/visualization/lib/AnchorUtils.js +0 -44
  24. package/build/src/visualization/lib/AnchorUtils.js.map +0 -1
  25. package/build/src/visualization/lib/AssociationAnchors.d.ts +0 -134
  26. package/build/src/visualization/lib/AssociationAnchors.d.ts.map +0 -1
  27. package/build/src/visualization/lib/AssociationAnchors.js +0 -351
  28. package/build/src/visualization/lib/AssociationAnchors.js.map +0 -1
  29. package/build/src/visualization/lib/LabelSketch.d.ts +0 -16
  30. package/build/src/visualization/lib/LabelSketch.d.ts.map +0 -1
  31. package/build/src/visualization/lib/LabelSketch.js +0 -53
  32. package/build/src/visualization/lib/LabelSketch.js.map +0 -1
  33. package/build/src/visualization/lib/LineSketch.d.ts +0 -26
  34. package/build/src/visualization/lib/LineSketch.d.ts.map +0 -1
  35. package/build/src/visualization/lib/LineSketch.js +0 -55
  36. package/build/src/visualization/lib/LineSketch.js.map +0 -1
  37. package/build/src/visualization/lib/Point.d.ts +0 -74
  38. package/build/src/visualization/lib/Point.d.ts.map +0 -1
  39. package/build/src/visualization/lib/Point.js +0 -121
  40. package/build/src/visualization/lib/Point.js.map +0 -1
  41. package/build/src/visualization/lib/PositionUtils.d.ts +0 -65
  42. package/build/src/visualization/lib/PositionUtils.d.ts.map +0 -1
  43. package/build/src/visualization/lib/PositionUtils.js +0 -205
  44. package/build/src/visualization/lib/PositionUtils.js.map +0 -1
  45. package/build/src/visualization/lib/SelectionManager.d.ts +0 -183
  46. package/build/src/visualization/lib/SelectionManager.d.ts.map +0 -1
  47. package/build/src/visualization/lib/SelectionManager.js +0 -481
  48. package/build/src/visualization/lib/SelectionManager.js.map +0 -1
  49. package/build/src/visualization/lib/ShapeArtist.d.ts +0 -45
  50. package/build/src/visualization/lib/ShapeArtist.d.ts.map +0 -1
  51. package/build/src/visualization/lib/ShapeArtist.js +0 -209
  52. package/build/src/visualization/lib/ShapeArtist.js.map +0 -1
  53. package/build/src/visualization/lib/SvgMarkers.d.ts +0 -14
  54. package/build/src/visualization/lib/SvgMarkers.d.ts.map +0 -1
  55. package/build/src/visualization/lib/SvgMarkers.js +0 -77
  56. package/build/src/visualization/lib/SvgMarkers.js.map +0 -1
  57. package/build/src/visualization/lib/TipSketch.d.ts +0 -26
  58. package/build/src/visualization/lib/TipSketch.d.ts.map +0 -1
  59. package/build/src/visualization/lib/TipSketch.js +0 -77
  60. package/build/src/visualization/lib/TipSketch.js.map +0 -1
  61. package/build/src/visualization/lib/TouchSupport.d.ts +0 -14
  62. package/build/src/visualization/lib/TouchSupport.d.ts.map +0 -1
  63. package/build/src/visualization/lib/TouchSupport.js +0 -55
  64. package/build/src/visualization/lib/TouchSupport.js.map +0 -1
  65. package/build/src/visualization/lib/Utils.d.ts +0 -25
  66. package/build/src/visualization/lib/Utils.d.ts.map +0 -1
  67. package/build/src/visualization/lib/Utils.js +0 -59
  68. package/build/src/visualization/lib/Utils.js.map +0 -1
  69. package/build/src/visualization/lib/VisualizationTypes.d.ts +0 -216
  70. package/build/src/visualization/lib/VisualizationTypes.d.ts.map +0 -1
  71. package/build/src/visualization/lib/VisualizationTypes.js +0 -3
  72. package/build/src/visualization/lib/VisualizationTypes.js.map +0 -1
  73. package/build/src/visualization/lib/WorkspaceAlignment.d.ts +0 -51
  74. package/build/src/visualization/lib/WorkspaceAlignment.d.ts.map +0 -1
  75. package/build/src/visualization/lib/WorkspaceAlignment.js +0 -243
  76. package/build/src/visualization/lib/WorkspaceAlignment.js.map +0 -1
  77. package/build/src/visualization/lib/WorkspaceDebugging.d.ts +0 -104
  78. package/build/src/visualization/lib/WorkspaceDebugging.d.ts.map +0 -1
  79. package/build/src/visualization/lib/WorkspaceDebugging.js +0 -286
  80. package/build/src/visualization/lib/WorkspaceDebugging.js.map +0 -1
  81. package/build/src/visualization/lib/WorkspaceEdges.d.ts +0 -293
  82. package/build/src/visualization/lib/WorkspaceEdges.d.ts.map +0 -1
  83. package/build/src/visualization/lib/WorkspaceEdges.js +0 -1073
  84. package/build/src/visualization/lib/WorkspaceEdges.js.map +0 -1
  85. package/build/src/visualization/lib/WorkspaceGestures.d.ts +0 -119
  86. package/build/src/visualization/lib/WorkspaceGestures.d.ts.map +0 -1
  87. package/build/src/visualization/lib/WorkspaceGestures.js +0 -376
  88. package/build/src/visualization/lib/WorkspaceGestures.js.map +0 -1
  89. package/build/src/visualization/lib/WorkspaceSizing.d.ts +0 -66
  90. package/build/src/visualization/lib/WorkspaceSizing.d.ts.map +0 -1
  91. package/build/src/visualization/lib/WorkspaceSizing.js +0 -168
  92. package/build/src/visualization/lib/WorkspaceSizing.js.map +0 -1
  93. package/build/src/visualization/lib/lines/RectilinearLine.d.ts +0 -114
  94. package/build/src/visualization/lib/lines/RectilinearLine.d.ts.map +0 -1
  95. package/build/src/visualization/lib/lines/RectilinearLine.js +0 -605
  96. package/build/src/visualization/lib/lines/RectilinearLine.js.map +0 -1
  97. package/build/src/visualization/lib/tips/RectilinearTip.d.ts +0 -26
  98. package/build/src/visualization/lib/tips/RectilinearTip.d.ts.map +0 -1
  99. package/build/src/visualization/lib/tips/RectilinearTip.js +0 -149
  100. package/build/src/visualization/lib/tips/RectilinearTip.js.map +0 -1
  101. package/build/src/visualization/lib/tips/TipArtist.d.ts +0 -22
  102. package/build/src/visualization/lib/tips/TipArtist.d.ts.map +0 -1
  103. package/build/src/visualization/lib/tips/TipArtist.js +0 -31
  104. package/build/src/visualization/lib/tips/TipArtist.js.map +0 -1
  105. package/build/src/visualization/lib/types.d.ts +0 -164
  106. package/build/src/visualization/lib/types.d.ts.map +0 -1
  107. package/build/src/visualization/lib/types.js +0 -2
  108. package/build/src/visualization/lib/types.js.map +0 -1
  109. package/build/src/visualization/plugin/dnd/DragAndDropPlugin.d.ts +0 -126
  110. package/build/src/visualization/plugin/dnd/DragAndDropPlugin.d.ts.map +0 -1
  111. package/build/src/visualization/plugin/dnd/DragAndDropPlugin.js +0 -260
  112. package/build/src/visualization/plugin/dnd/DragAndDropPlugin.js.map +0 -1
  113. package/build/src/visualization/plugin/group-selection/GroupSelection.d.ts +0 -93
  114. package/build/src/visualization/plugin/group-selection/GroupSelection.d.ts.map +0 -1
  115. package/build/src/visualization/plugin/group-selection/GroupSelection.js +0 -250
  116. package/build/src/visualization/plugin/group-selection/GroupSelection.js.map +0 -1
  117. package/build/src/visualization/plugin/positioning/DataModelLayout.d.ts +0 -10
  118. package/build/src/visualization/plugin/positioning/DataModelLayout.d.ts.map +0 -1
  119. package/build/src/visualization/plugin/positioning/DataModelLayout.js +0 -105
  120. package/build/src/visualization/plugin/positioning/DataModelLayout.js.map +0 -1
  121. package/build/src/visualization/plugin/positioning/WorkspaceLayout.d.ts +0 -93
  122. package/build/src/visualization/plugin/positioning/WorkspaceLayout.d.ts.map +0 -1
  123. package/build/src/visualization/plugin/positioning/WorkspaceLayout.js +0 -96
  124. package/build/src/visualization/plugin/positioning/WorkspaceLayout.js.map +0 -1
  125. package/build/src/visualization/viz-association.d.ts +0 -7
  126. package/build/src/visualization/viz-association.d.ts.map +0 -1
  127. package/build/src/visualization/viz-association.js +0 -3
  128. package/build/src/visualization/viz-association.js.map +0 -1
  129. package/build/src/visualization/viz-workspace.d.ts +0 -7
  130. package/build/src/visualization/viz-workspace.d.ts.map +0 -1
  131. package/build/src/visualization/viz-workspace.js +0 -3
  132. package/build/src/visualization/viz-workspace.js.map +0 -1
  133. package/src/visualization/elements/VizAssociationElement.ts +0 -3
  134. package/src/visualization/elements/VizWorkspaceElement.ts +0 -302
  135. package/src/visualization/elements/WorkspaceStyles.ts +0 -168
  136. package/src/visualization/lib/AnchorFinder.ts +0 -112
  137. package/src/visualization/lib/AnchorUtils.ts +0 -53
  138. package/src/visualization/lib/AssociationAnchors.ts +0 -418
  139. package/src/visualization/lib/LabelSketch.ts +0 -67
  140. package/src/visualization/lib/LineSketch.ts +0 -62
  141. package/src/visualization/lib/Point.ts +0 -134
  142. package/src/visualization/lib/PositionUtils.ts +0 -218
  143. package/src/visualization/lib/SelectionManager.ts +0 -513
  144. package/src/visualization/lib/ShapeArtist.ts +0 -222
  145. package/src/visualization/lib/SvgMarkers.ts +0 -80
  146. package/src/visualization/lib/TipSketch.ts +0 -91
  147. package/src/visualization/lib/TouchSupport.ts +0 -72
  148. package/src/visualization/lib/Utils.ts +0 -63
  149. package/src/visualization/lib/VisualizationTypes.ts +0 -232
  150. package/src/visualization/lib/WorkspaceAlignment.ts +0 -261
  151. package/src/visualization/lib/WorkspaceDebugging.ts +0 -313
  152. package/src/visualization/lib/WorkspaceEdges.ts +0 -1153
  153. package/src/visualization/lib/WorkspaceGestures.ts +0 -400
  154. package/src/visualization/lib/WorkspaceSizing.ts +0 -181
  155. package/src/visualization/lib/lines/RectilinearLine.ts +0 -589
  156. package/src/visualization/lib/tips/RectilinearTip.ts +0 -156
  157. package/src/visualization/lib/tips/TipArtist.ts +0 -34
  158. package/src/visualization/lib/types.ts +0 -173
  159. package/src/visualization/plugin/dnd/DragAndDropPlugin.ts +0 -294
  160. package/src/visualization/plugin/group-selection/GroupSelection.ts +0 -271
  161. package/src/visualization/plugin/positioning/DataModelLayout.ts +0 -114
  162. package/src/visualization/plugin/positioning/WorkspaceLayout.ts +0 -149
  163. package/src/visualization/viz-association.ts +0 -9
  164. package/src/visualization/viz-workspace.ts +0 -9
  165. package/test/env.d.ts +0 -9
  166. package/test/env.js +0 -7
  167. package/test/visualization/lib/AnchorFinder.test.ts +0 -313
  168. package/test/visualization/lib/AnchorUtils.test.ts +0 -178
  169. package/test/visualization/lib/PositionUtils.test.ts +0 -406
  170. package/test/visualization/lib/test-styles.css +0 -80
@@ -1,121 +0,0 @@
1
- /**
2
- * An object representing a point in a 2-d space (Euclidean space)
3
- */
4
- export class Point {
5
- x;
6
- y;
7
- /**
8
- * @param x The x coordinate or the array with x and y position values
9
- * @param y Optional when the `x` is an array. The y position of the point
10
- */
11
- constructor(x, y) {
12
- let xValue;
13
- let yValue;
14
- if (Array.isArray(x)) {
15
- ;
16
- [xValue, yValue] = x;
17
- }
18
- else {
19
- xValue = x;
20
- yValue = y;
21
- }
22
- this.x = xValue;
23
- this.y = yValue;
24
- }
25
- /**
26
- * Copies the current point as new object
27
- * @return A copy of the object
28
- */
29
- copy() {
30
- return new Point(this.x, this.y);
31
- }
32
- /**
33
- * Validates the point value.
34
- * @return True if the point has valid values.
35
- */
36
- validate() {
37
- const { x, y } = this;
38
- return !Number.isNaN(x) && !Number.isNaN(y);
39
- }
40
- /**
41
- * Adds another point to this point and returns a new point.
42
- * @param v Point or a number to add.
43
- * @returns Created new point
44
- */
45
- add(v) {
46
- if (v instanceof Point) {
47
- return new Point(this.x + v.x, this.y + v.y);
48
- }
49
- return new Point(this.x + v, this.y + v);
50
- }
51
- /**
52
- * Subtracts another point from this point and returns a new point.
53
- * @param v Point or a number to add.
54
- * @returns Created new point
55
- */
56
- subtract(v) {
57
- if (v instanceof Point) {
58
- return new Point(this.x - v.x, this.y - v.y);
59
- }
60
- return new Point(this.x - v, this.y - v);
61
- }
62
- /**
63
- * Multiplies this point by another point or a number and returns a new point.
64
- * @param v Point or a number to add.
65
- * @returns Created new point
66
- */
67
- multiply(v) {
68
- if (v instanceof Point) {
69
- return new Point(this.x * v.x, this.y * v.y);
70
- }
71
- return new Point(this.x * v, this.y * v);
72
- }
73
- /**
74
- * Divides this point by another point or a number and returns a new point.
75
- * @param v Point or a number to add.
76
- * @returns Created new point
77
- */
78
- divide(v) {
79
- if (v instanceof Point) {
80
- return new Point(this.x / v.x, this.y / v.y);
81
- }
82
- return new Point(this.x / v, this.y / v);
83
- }
84
- /**
85
- * Subtracts another point to this point and returns a new point.
86
- * @param v Point or a number to add.
87
- * @returns True when points are equal
88
- */
89
- equals(v) {
90
- return this.x === v.x && this.y === v.y;
91
- }
92
- /**
93
- * Computes an angle to another point in radians.
94
- * @param v Point or a number to add.
95
- * @returns True when points are equal
96
- */
97
- angle(v) {
98
- return Math.atan2(v.y - this.y, v.x - this.x);
99
- }
100
- /**
101
- * Computes an angle to another point in degrees.
102
- * @param v Point or a number to add.
103
- * @returns True when points are equal
104
- */
105
- degrees(v) {
106
- return (this.angle(v) * 180) / Math.PI;
107
- }
108
- /**
109
- * Computes the distance to the other point.
110
- */
111
- distance(other) {
112
- return Math.sqrt((this.x - other.x) ** 2 + (this.y - other.y) ** 2);
113
- }
114
- /**
115
- * Computes the distance between two points.
116
- */
117
- static distance(p1, p2) {
118
- return p1.distance(p2);
119
- }
120
- }
121
- //# sourceMappingURL=Point.js.map
@@ -1 +0,0 @@
1
- {"version":3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AAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IAC/C,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,CAAQ;QACd,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAA;IACxC,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,KAAY;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;IACrE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,EAAS,EAAE,EAAS;QAClC,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IACxB,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport { xPositionOrCoord } from './types.js'\n\n/**\n * An object representing a point in a 2-d space (Euclidean space)\n */\nexport class Point {\n x: number\n\n y: number\n\n /**\n * @param x The x coordinate or the array with x and y position values\n * @param y Optional when the `x` is an array. The y position of the point\n */\n constructor(x: xPositionOrCoord, y?: number) {\n let xValue\n let yValue\n if (Array.isArray(x)) {\n ;[xValue, yValue] = x\n } else {\n xValue = x\n yValue = y\n }\n this.x = xValue\n this.y = yValue!\n }\n\n /**\n * Copies the current point as new object\n * @return A copy of the object\n */\n copy(): Point {\n return new Point(this.x, this.y)\n }\n\n /**\n * Validates the point value.\n * @return True if the point has valid values.\n */\n validate(): boolean {\n const { x, y } = this\n return !Number.isNaN(x) && !Number.isNaN(y)\n }\n\n /**\n * Adds another point to this point and returns a new point.\n * @param v Point or a number to add.\n * @returns Created new point\n */\n add(v: Point | number): Point {\n if (v instanceof Point) {\n return new Point(this.x + v.x, this.y + v.y)\n }\n return new Point(this.x + v, this.y + v)\n }\n\n /**\n * Subtracts another point from this point and returns a new point.\n * @param v Point or a number to add.\n * @returns Created new point\n */\n subtract(v: Point | number): Point {\n if (v instanceof Point) {\n return new Point(this.x - v.x, this.y - v.y)\n }\n return new Point(this.x - v, this.y - v)\n }\n\n /**\n * Multiplies this point by another point or a number and returns a new point.\n * @param v Point or a number to add.\n * @returns Created new point\n */\n multiply(v: Point | number): Point {\n if (v instanceof Point) {\n return new Point(this.x * v.x, this.y * v.y)\n }\n return new Point(this.x * v, this.y * v)\n }\n\n /**\n * Divides this point by another point or a number and returns a new point.\n * @param v Point or a number to add.\n * @returns Created new point\n */\n divide(v: Point | number): Point {\n if (v instanceof Point) {\n return new Point(this.x / v.x, this.y / v.y)\n }\n return new Point(this.x / v, this.y / v)\n }\n\n /**\n * Subtracts another point to this point and returns a new point.\n * @param v Point or a number to add.\n * @returns True when points are equal\n */\n equals(v: Point): boolean {\n return this.x === v.x && this.y === v.y\n }\n\n /**\n * Computes an angle to another point in radians.\n * @param v Point or a number to add.\n * @returns True when points are equal\n */\n angle(v: Point): number {\n return Math.atan2(v.y - this.y, v.x - this.x)\n }\n\n /**\n * Computes an angle to another point in degrees.\n * @param v Point or a number to add.\n * @returns True when points are equal\n */\n degrees(v: Point): number {\n return (this.angle(v) * 180) / Math.PI\n }\n\n /**\n * Computes the distance to the other point.\n */\n distance(other: Point): number {\n return Math.sqrt((this.x - other.x) ** 2 + (this.y - other.y) ** 2)\n }\n\n /**\n * Computes the distance between two points.\n */\n static distance(p1: Point, p2: Point): number {\n return p1.distance(p2)\n }\n}\n"]}
@@ -1,65 +0,0 @@
1
- import VizWorkspaceElement from '../elements/VizWorkspaceElement.js';
2
- import { Point } from './Point.js';
3
- import { IEdgeDirections } from './types.js';
4
- /**
5
- * Computes a point from the `x` and `y` coordinates of the viewport and applies
6
- * the current scale to it to correctly position the click coordinates.
7
- *
8
- * @param wrapper The relatively positioned wrapper
9
- * @param container The absolutely positioned container
10
- * @param scale The current scale applied to the container
11
- * @returns A point with x and y scaled coordinates.
12
- */
13
- export declare function clickPoint(x: number, y: number, wrapper: HTMLElement, container: HTMLElement, scale: number): Point;
14
- /**
15
- * Computes a point from the `x` and `y` coordinates of the viewport and applies
16
- * the current scale to it to correctly position the click coordinates.
17
- *
18
- * @param workspace The workspace element
19
- * @returns A point with x and y scaled coordinates.
20
- */
21
- export declare function getRelativeClickPoint(x: number, y: number, workspace: VizWorkspaceElement): Point;
22
- /**
23
- * Computes the direction for both start and end points relative to their
24
- * shapes.
25
- * The `end` property describes the direction of an abstract arrow would be pointing to.
26
- * The `start` is the direction facing the beginning of the path.
27
- *
28
- * @param sp The start point to calculate the direction from
29
- * @param ep The end point to calculate the direction to
30
- * @param sBox DOM rectangle of the source
31
- * @param eBox DOM rectangle of the target
32
- */
33
- export declare function findDirection(sp: Point, ep: Point, sBox: DOMRect, eBox: DOMRect): IEdgeDirections;
34
- /**
35
- * Finds a pair of points closest to each other but from both sets.
36
- *
37
- * @param s1 First set.
38
- * @param s2 Second set.
39
- * @param avoid1 Avoid these points (when possible) from the set1
40
- * @param avoid2 Avoid these points (when possible) from the set2
41
- * @returns A list of two points closest to each other or null if there were no points in the set.
42
- */
43
- export declare function closetsPair(s1: Point[], s2: Point[], avoid1?: Point[], avoid2?: Point[]): Point[] | null;
44
- /**
45
- * Filters out invalid points
46
- */
47
- export declare function filterPoints(points: Point[]): Point[];
48
- /**
49
- * Computes a point of the click inside the workspace element (not the content wrapper).
50
- * This then can be used to position elements that are not inside the visualization
51
- * workspace.
52
- *
53
- * @param workspace The workspace element
54
- * @returns A point with x and y scaled coordinates.
55
- */
56
- export declare function getWorkspaceClick(x: number, y: number, workspace: VizWorkspaceElement): Point;
57
- export declare function getObjectBoundingClientRect(element: Element, workspace: VizWorkspaceElement): DOMRect;
58
- /**
59
- * Dispatches the `positionchange` custom event on an element that has been positioned.
60
- *
61
- * @param dx The difference in the `x` position in relation to the object position before the move
62
- * @param dy The difference in the `y` position in relation to the object position before the move
63
- */
64
- export declare function notifyMoved(element: EventTarget, dx: number, dy: number): void;
65
- //# sourceMappingURL=PositionUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PositionUtils.d.ts","sourceRoot":"","sources":["../../../../src/visualization/lib/PositionUtils.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,MAAM,oCAAoC,CAAA;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,eAAe,EAAgB,MAAM,YAAY,CAAA;AAE1D;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAYnH;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,GAAG,KAAK,CAGjG;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,eAAe,CA4BjG;AAmBD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,GAAE,KAAK,EAAO,EAAE,MAAM,GAAE,KAAK,EAAO,GAAG,KAAK,EAAE,GAAG,IAAI,CA+BhH;AAiCD;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAErD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,GAAG,KAAK,CAK7F;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAKrG;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAW9E"}
@@ -1,205 +0,0 @@
1
- import { Point } from './Point.js';
2
- /**
3
- * Computes a point from the `x` and `y` coordinates of the viewport and applies
4
- * the current scale to it to correctly position the click coordinates.
5
- *
6
- * @param wrapper The relatively positioned wrapper
7
- * @param container The absolutely positioned container
8
- * @param scale The current scale applied to the container
9
- * @returns A point with x and y scaled coordinates.
10
- */
11
- export function clickPoint(x, y, wrapper, container, scale) {
12
- const { left: vLeft, top: vTop } = wrapper.getBoundingClientRect();
13
- const { left: cLeft, top: cTop } = container.getBoundingClientRect();
14
- const workspaceRelativeX = cLeft - vLeft;
15
- const workspaceRelativeY = cTop - vTop;
16
- const viewportRelativeXClick = x - vLeft;
17
- const viewportRelativeYClick = y - vTop;
18
- const realWorkspaceXClick = viewportRelativeXClick - workspaceRelativeX;
19
- const realWorkspaceYClick = viewportRelativeYClick - workspaceRelativeY;
20
- const relativeXClick = realWorkspaceXClick / scale;
21
- const relativeYClick = realWorkspaceYClick / scale;
22
- return new Point(relativeXClick, relativeYClick);
23
- }
24
- /**
25
- * Computes a point from the `x` and `y` coordinates of the viewport and applies
26
- * the current scale to it to correctly position the click coordinates.
27
- *
28
- * @param workspace The workspace element
29
- * @returns A point with x and y scaled coordinates.
30
- */
31
- export function getRelativeClickPoint(x, y, workspace) {
32
- const { scale, canvas } = workspace;
33
- return clickPoint(x, y, workspace, canvas, scale);
34
- }
35
- /**
36
- * Computes the direction for both start and end points relative to their
37
- * shapes.
38
- * The `end` property describes the direction of an abstract arrow would be pointing to.
39
- * The `start` is the direction facing the beginning of the path.
40
- *
41
- * @param sp The start point to calculate the direction from
42
- * @param ep The end point to calculate the direction to
43
- * @param sBox DOM rectangle of the source
44
- * @param eBox DOM rectangle of the target
45
- */
46
- export function findDirection(sp, ep, sBox, eBox) {
47
- const padding = 10;
48
- let end;
49
- let start;
50
- if (Math.abs(eBox.left - ep.x) < padding) {
51
- end = 'east';
52
- }
53
- else if (Math.abs(eBox.right - ep.x) < padding) {
54
- end = 'west';
55
- }
56
- else if (Math.abs(eBox.bottom - ep.y) < padding) {
57
- end = 'south';
58
- }
59
- else {
60
- end = 'north';
61
- }
62
- if (Math.abs(sBox.left - sp.x) < padding) {
63
- start = 'west';
64
- }
65
- else if (Math.abs(sBox.right - sp.x) < padding) {
66
- start = 'east';
67
- }
68
- else if (Math.abs(sBox.top - sp.y) < padding) {
69
- start = 'north';
70
- }
71
- else {
72
- start = 'south';
73
- }
74
- return {
75
- end,
76
- start,
77
- };
78
- }
79
- // /**
80
- // * @param {Point} p1
81
- // * @param {Point} p2
82
- // * @param {Point} p3
83
- // * @param {Point} p4
84
- // * @returns {boolean} True when the pair of points (p1, p2) and (p3, p4) are the same on any order.
85
- // */
86
- // export function theSamePair(p1, p2, p3, p4) {
87
- // if (p1.x === p3.x && p1.y === p3.y && p2.x === p4.x && p2.y === p4.y) {
88
- // return true;
89
- // }
90
- // if (p1.x === p4.x && p1.y === p4.y && p2.x === p3.x && p2.y === p3.y) {
91
- // return true;
92
- // }
93
- // return false;
94
- // }
95
- /**
96
- * Finds a pair of points closest to each other but from both sets.
97
- *
98
- * @param s1 First set.
99
- * @param s2 Second set.
100
- * @param avoid1 Avoid these points (when possible) from the set1
101
- * @param avoid2 Avoid these points (when possible) from the set2
102
- * @returns A list of two points closest to each other or null if there were no points in the set.
103
- */
104
- export function closetsPair(s1, s2, avoid1 = [], avoid2 = []) {
105
- const avoidSet1 = new Set(avoid1.map((p) => `${p.x},${p.y}`));
106
- const avoidSet2 = new Set(avoid2.map((p) => `${p.x},${p.y}`));
107
- const filteredS1 = s1.filter((p) => !avoidSet1.has(`${p.x},${p.y}`));
108
- const filteredS2 = s2.filter((p) => !avoidSet2.has(`${p.x},${p.y}`));
109
- if (filteredS1.length === 0 || filteredS2.length === 0) {
110
- return null;
111
- }
112
- let minSquaredDistance = Number.MAX_SAFE_INTEGER;
113
- let p;
114
- let q;
115
- filteredS1.forEach((sp) => {
116
- filteredS2.forEach((sq) => {
117
- const squaredDistance = (sp.x - sq.x) ** 2 + (sp.y - sq.y) ** 2;
118
- if (squaredDistance < minSquaredDistance) {
119
- minSquaredDistance = squaredDistance;
120
- p = sp;
121
- q = sq;
122
- }
123
- });
124
- });
125
- if (p && q) {
126
- return [p, q];
127
- }
128
- return null; // Return null if no pair is found.
129
- }
130
- // export function closetsPair(s1: Point[], s2: Point[], avoid1: Point[] = [], avoid2: Point[] = []): Point[] | null {
131
- // let distance = Number.MAX_SAFE_INTEGER
132
- // let p: Point | undefined
133
- // let q: Point | undefined
134
- // s1.forEach((sp) => {
135
- // if (avoid1.some((i) => i.x === sp.x && i.y === sp.y)) {
136
- // return
137
- // }
138
- // s2.forEach((sq) => {
139
- // if (avoid2.some((i) => i.x === sq.x && i.y === sq.y)) {
140
- // return
141
- // }
142
- // const d = sp.distance(sq)
143
- // if (d < distance) {
144
- // distance = d
145
- // p = sp
146
- // q = sq
147
- // }
148
- // })
149
- // })
150
- // if (!p && !!(avoid1.length || avoid2.length)) {
151
- // return closetsPair(s1, s2)
152
- // }
153
- // if (!p) {
154
- // return null
155
- // }
156
- // if (q) {
157
- // return [p, q]
158
- // }
159
- // return [p]
160
- // }
161
- /**
162
- * Filters out invalid points
163
- */
164
- export function filterPoints(points) {
165
- return points.filter((v) => v.validate());
166
- }
167
- /**
168
- * Computes a point of the click inside the workspace element (not the content wrapper).
169
- * This then can be used to position elements that are not inside the visualization
170
- * workspace.
171
- *
172
- * @param workspace The workspace element
173
- * @returns A point with x and y scaled coordinates.
174
- */
175
- export function getWorkspaceClick(x, y, workspace) {
176
- const { left, top } = workspace.getBoundingClientRect();
177
- const workspaceX = x - left;
178
- const workspaceY = y - top;
179
- return new Point(workspaceX, workspaceY);
180
- }
181
- export function getObjectBoundingClientRect(element, workspace) {
182
- const box = element.getBoundingClientRect();
183
- const { x, y } = getRelativeClickPoint(box.x, box.y, workspace);
184
- const { scale } = workspace;
185
- return new DOMRect(x, y, box.width / scale, box.height / scale);
186
- }
187
- /**
188
- * Dispatches the `positionchange` custom event on an element that has been positioned.
189
- *
190
- * @param dx The difference in the `x` position in relation to the object position before the move
191
- * @param dy The difference in the `y` position in relation to the object position before the move
192
- */
193
- export function notifyMoved(element, dx, dy) {
194
- const e = new CustomEvent('positionchange', {
195
- composed: true,
196
- cancelable: true,
197
- bubbles: true,
198
- detail: {
199
- dx,
200
- dy,
201
- },
202
- });
203
- element.dispatchEvent(e);
204
- }
205
- //# sourceMappingURL=PositionUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PositionUtils.js","sourceRoot":"","sources":["../../../../src/visualization/lib/PositionUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGlC;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,CAAS,EAAE,CAAS,EAAE,OAAoB,EAAE,SAAsB,EAAE,KAAa;IAC1G,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAA;IAClE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAAA;IACpE,MAAM,kBAAkB,GAAG,KAAK,GAAG,KAAK,CAAA;IACxC,MAAM,kBAAkB,GAAG,IAAI,GAAG,IAAI,CAAA;IACtC,MAAM,sBAAsB,GAAG,CAAC,GAAG,KAAK,CAAA;IACxC,MAAM,sBAAsB,GAAG,CAAC,GAAG,IAAI,CAAA;IACvC,MAAM,mBAAmB,GAAG,sBAA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,CAAC,CAAA;AACjE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,OAAoB,EAAE,EAAU,EAAE,EAAU;IACtE,MAAM,CAAC,GAAG,IAAI,WAAW,CAAC,gBAAgB,EAAE;QAC1C,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,IAAI;QACb,MAAM,EAAE;YACN,EAAE;YACF,EAAE;SACH;KACF,CAAC,CAAA;IACF,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAA;AAC1B,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport VizWorkspaceElement from '../elements/VizWorkspaceElement.js'\nimport { Point } from './Point.js'\nimport { IEdgeDirections, GeoDirection } from './types.js'\n\n/**\n * Computes a point from the `x` and `y` coordinates of the viewport and applies\n * the current scale to it to correctly position the click coordinates.\n *\n * @param wrapper The relatively positioned wrapper\n * @param container The absolutely positioned container\n * @param scale The current scale applied to the container\n * @returns A point with x and y scaled coordinates.\n */\nexport function clickPoint(x: number, y: number, wrapper: HTMLElement, container: HTMLElement, scale: number): Point {\n const { left: vLeft, top: vTop } = wrapper.getBoundingClientRect()\n const { left: cLeft, top: cTop } = container.getBoundingClientRect()\n const workspaceRelativeX = cLeft - vLeft\n const workspaceRelativeY = cTop - vTop\n const viewportRelativeXClick = x - vLeft\n const viewportRelativeYClick = y - vTop\n const realWorkspaceXClick = viewportRelativeXClick - workspaceRelativeX\n const realWorkspaceYClick = viewportRelativeYClick - workspaceRelativeY\n const relativeXClick = realWorkspaceXClick / scale\n const relativeYClick = realWorkspaceYClick / scale\n return new Point(relativeXClick, relativeYClick)\n}\n\n/**\n * Computes a point from the `x` and `y` coordinates of the viewport and applies\n * the current scale to it to correctly position the click coordinates.\n *\n * @param workspace The workspace element\n * @returns A point with x and y scaled coordinates.\n */\nexport function getRelativeClickPoint(x: number, y: number, workspace: VizWorkspaceElement): Point {\n const { scale, canvas } = workspace\n return clickPoint(x, y, workspace, canvas!, scale)\n}\n\n/**\n * Computes the direction for both start and end points relative to their\n * shapes.\n * The `end` property describes the direction of an abstract arrow would be pointing to.\n * The `start` is the direction facing the beginning of the path.\n *\n * @param sp The start point to calculate the direction from\n * @param ep The end point to calculate the direction to\n * @param sBox DOM rectangle of the source\n * @param eBox DOM rectangle of the target\n */\nexport function findDirection(sp: Point, ep: Point, sBox: DOMRect, eBox: DOMRect): IEdgeDirections {\n const padding = 10\n let end: GeoDirection\n let start: GeoDirection\n if (Math.abs(eBox.left - ep.x) < padding) {\n end = 'east'\n } else if (Math.abs(eBox.right - ep.x) < padding) {\n end = 'west'\n } else if (Math.abs(eBox.bottom - ep.y) < padding) {\n end = 'south'\n } else {\n end = 'north'\n }\n\n if (Math.abs(sBox.left - sp.x) < padding) {\n start = 'west'\n } else if (Math.abs(sBox.right - sp.x) < padding) {\n start = 'east'\n } else if (Math.abs(sBox.top - sp.y) < padding) {\n start = 'north'\n } else {\n start = 'south'\n }\n\n return {\n end,\n start,\n }\n}\n\n// /**\n// * @param {Point} p1\n// * @param {Point} p2\n// * @param {Point} p3\n// * @param {Point} p4\n// * @returns {boolean} True when the pair of points (p1, p2) and (p3, p4) are the same on any order.\n// */\n// export function theSamePair(p1, p2, p3, p4) {\n// if (p1.x === p3.x && p1.y === p3.y && p2.x === p4.x && p2.y === p4.y) {\n// return true;\n// }\n// if (p1.x === p4.x && p1.y === p4.y && p2.x === p3.x && p2.y === p3.y) {\n// return true;\n// }\n// return false;\n// }\n\n/**\n * Finds a pair of points closest to each other but from both sets.\n *\n * @param s1 First set.\n * @param s2 Second set.\n * @param avoid1 Avoid these points (when possible) from the set1\n * @param avoid2 Avoid these points (when possible) from the set2\n * @returns A list of two points closest to each other or null if there were no points in the set.\n */\nexport function closetsPair(s1: Point[], s2: Point[], avoid1: Point[] = [], avoid2: Point[] = []): Point[] | null {\n const avoidSet1 = new Set(avoid1.map((p) => `${p.x},${p.y}`))\n const avoidSet2 = new Set(avoid2.map((p) => `${p.x},${p.y}`))\n\n const filteredS1 = s1.filter((p) => !avoidSet1.has(`${p.x},${p.y}`))\n const filteredS2 = s2.filter((p) => !avoidSet2.has(`${p.x},${p.y}`))\n\n if (filteredS1.length === 0 || filteredS2.length === 0) {\n return null\n }\n\n let minSquaredDistance = Number.MAX_SAFE_INTEGER\n let p: Point | undefined\n let q: Point | undefined\n\n filteredS1.forEach((sp) => {\n filteredS2.forEach((sq) => {\n const squaredDistance = (sp.x - sq.x) ** 2 + (sp.y - sq.y) ** 2\n if (squaredDistance < minSquaredDistance) {\n minSquaredDistance = squaredDistance\n p = sp\n q = sq\n }\n })\n })\n\n if (p && q) {\n return [p, q]\n }\n\n return null // Return null if no pair is found.\n}\n// export function closetsPair(s1: Point[], s2: Point[], avoid1: Point[] = [], avoid2: Point[] = []): Point[] | null {\n// let distance = Number.MAX_SAFE_INTEGER\n// let p: Point | undefined\n// let q: Point | undefined\n// s1.forEach((sp) => {\n// if (avoid1.some((i) => i.x === sp.x && i.y === sp.y)) {\n// return\n// }\n// s2.forEach((sq) => {\n// if (avoid2.some((i) => i.x === sq.x && i.y === sq.y)) {\n// return\n// }\n// const d = sp.distance(sq)\n// if (d < distance) {\n// distance = d\n// p = sp\n// q = sq\n// }\n// })\n// })\n// if (!p && !!(avoid1.length || avoid2.length)) {\n// return closetsPair(s1, s2)\n// }\n// if (!p) {\n// return null\n// }\n// if (q) {\n// return [p, q]\n// }\n// return [p]\n// }\n\n/**\n * Filters out invalid points\n */\nexport function filterPoints(points: Point[]): Point[] {\n return points.filter((v) => v.validate())\n}\n\n/**\n * Computes a point of the click inside the workspace element (not the content wrapper).\n * This then can be used to position elements that are not inside the visualization\n * workspace.\n *\n * @param workspace The workspace element\n * @returns A point with x and y scaled coordinates.\n */\nexport function getWorkspaceClick(x: number, y: number, workspace: VizWorkspaceElement): Point {\n const { left, top } = workspace.getBoundingClientRect()\n const workspaceX = x - left\n const workspaceY = y - top\n return new Point(workspaceX, workspaceY)\n}\n\nexport function getObjectBoundingClientRect(element: Element, workspace: VizWorkspaceElement): DOMRect {\n const box = element.getBoundingClientRect()\n const { x, y } = getRelativeClickPoint(box.x, box.y, workspace)\n const { scale } = workspace\n return new DOMRect(x, y, box.width / scale, box.height / scale)\n}\n\n/**\n * Dispatches the `positionchange` custom event on an element that has been positioned.\n *\n * @param dx The difference in the `x` position in relation to the object position before the move\n * @param dy The difference in the `y` position in relation to the object position before the move\n */\nexport function notifyMoved(element: EventTarget, dx: number, dy: number): void {\n const e = new CustomEvent('positionchange', {\n composed: true,\n cancelable: true,\n bubbles: true,\n detail: {\n dx,\n dy,\n },\n })\n element.dispatchEvent(e)\n}\n"]}
@@ -1,183 +0,0 @@
1
- import VizWorkspaceElement from '../elements/VizWorkspaceElement.js';
2
- import { ISelectedDomain } from './types.js';
3
- export declare const clickHandler: unique symbol;
4
- export declare const observeItems: unique symbol;
5
- export declare const mutationHandler: unique symbol;
6
- export declare const mutationObserver: unique symbol;
7
- export declare const processAddedNodes: unique symbol;
8
- export declare const processRemovedNodes: unique symbol;
9
- export declare const processAttributeChanged: unique symbol;
10
- export declare const propagateSelection: unique symbol;
11
- export declare const selectAssociations: unique symbol;
12
- export declare const selectReverseAssociations: unique symbol;
13
- export declare const propagateDeselection: unique symbol;
14
- export declare const deselectAssociations: unique symbol;
15
- export declare const deselectReverseAssociations: unique symbol;
16
- export declare const notifyChanged: unique symbol;
17
- export declare const selectedItemsValue: unique symbol;
18
- export declare const selectedIdsValue: unique symbol;
19
- /**
20
- * A class that takes care of selection in the visualization workspace.
21
- */
22
- export declare class SelectionManager {
23
- target: VizWorkspaceElement;
24
- /**
25
- * The list of currently selected elements
26
- */
27
- [selectedItemsValue]: Set<Element>;
28
- /**
29
- * The list of currently selected domain ids
30
- */
31
- [selectedIdsValue]: ISelectedDomain[];
32
- [mutationObserver]?: MutationObserver;
33
- /**
34
- * @returns A set of currently selected items.
35
- */
36
- get selectedItems(): Set<Element>;
37
- /**
38
- * @returns A list of currently selected domain ids.
39
- */
40
- get selected(): ISelectedDomain[];
41
- /**
42
- * @returns A list of all selectable items
43
- */
44
- get selectable(): Element[];
45
- constructor(target: VizWorkspaceElement);
46
- /**
47
- * Initializes the library. Should be called when the workspace is ready to render content.
48
- */
49
- connect(): void;
50
- /**
51
- * Cleans up and removes listeners
52
- */
53
- disconnect(): void;
54
- /**
55
- * Checks if given element is marked as selectable target
56
- * @param selectable The element to test for `selectable` or `data-selectable` attribute
57
- * @returns True if the element can be selected
58
- */
59
- isSelectable(selectable: Element): boolean;
60
- /**
61
- * Checks if given element is marked as selected
62
- * @param selectable The element to test for `selected` or `data-selected` attribute
63
- * @returns True if the element is marked as selected
64
- */
65
- isSelected(selectable: Element): boolean;
66
- /**
67
- * Marks an element as selected
68
- * @param selectable The element to add the selected mark to.
69
- */
70
- setSelected(selectable: Element): void;
71
- /**
72
- * Marks an element as not selected
73
- * @param selectable The element to remove the selected mark from.
74
- */
75
- setUnselected(selectable: Element): void;
76
- /**
77
- * Deselects all currently selected items.
78
- */
79
- selectAll(): void;
80
- /**
81
- * Deselects all currently selected items.
82
- */
83
- deselectAll(): void;
84
- /**
85
- * Selects objects that are selectable by their `key`.
86
- *
87
- * The `addToSelection` argument is equivalent of calling `deselectAll()` and then `select(...)`.
88
- *
89
- * @param keys The list of domain ids of objects to select.
90
- * @param addToSelection If true it adds to the current selection rather than replacing it.
91
- */
92
- select(keys: string[], addToSelection?: boolean): void;
93
- /**
94
- * Removes objects from selection.
95
- *
96
- * @param keys The list of domain ids of objects to deselect.
97
- */
98
- deselect(keys: string[]): void;
99
- /**
100
- * Synchronizes the selection state with the view
101
- */
102
- syncView(): void;
103
- /**
104
- * Reads the attribute value to get the `key` property.
105
- * @param selectable
106
- * @returns The domain id of the object or `null` when not found
107
- */
108
- readKey(selectable: Element): string | null;
109
- /**
110
- * Finds a workspace element that has the domain id.
111
- * @param id Target domain id
112
- */
113
- getDomainTarget(id: string): Element | null;
114
- /**
115
- * Finds a workspace element that has the domain id and is selectable.
116
- * @param id Target domain id
117
- */
118
- getSelectableDomainTarget(id: string): Element | null;
119
- [clickHandler](e: PointerEvent): void;
120
- /**
121
- * Observe items change in the element's light DOM
122
- * @returns The observer handler
123
- */
124
- [observeItems](): MutationObserver;
125
- /**
126
- * Processes mutations in the workspace and manages selection state.
127
- * @param mutationsList List of mutations.
128
- */
129
- [mutationHandler](mutationsList: MutationRecord[]): void;
130
- /**
131
- * Processes added to the canvas elements.
132
- * @param nodes The list of added nodes
133
- */
134
- [processAddedNodes](nodes: NodeList): void;
135
- /**
136
- * Processes removed from the canvas elements.
137
- * @param nodes The list of removed nodes
138
- */
139
- [processRemovedNodes](nodes: NodeList): void;
140
- /**
141
- * Processes changed attribute on any element in the canvas
142
- * @param node Changed element
143
- * @param prop Changed property
144
- */
145
- [processAttributeChanged](node: Element, prop: string): void;
146
- /**
147
- * Sets selection to the elements that are related to the `selectable` element.
148
- *
149
- * A related element is an element that is an association target to the `selectable`
150
- * ot the `selectable` has `parent` attribute.
151
- *
152
- * The related are not added to the `selectedItems` set and does not have `selected` attribute.
153
- * They are marked with `second-selected` attribute.
154
- */
155
- [propagateSelection](selectable: Element): void;
156
- /**
157
- * Marks `viz-association` and referenced targets of the `selectable` as a secondary selection.
158
- */
159
- [selectAssociations](selectable: Element): void;
160
- /**
161
- * Similar to `[selectAssociations]()` but it selects associations where
162
- * the `selectable` is the target.
163
- */
164
- [selectReverseAssociations](selectable: Element): void;
165
- /**
166
- * Removes secondary selection from the elements that are related to the `selectable` element.
167
- *
168
- * A related element is an element that is an association target to the `selectable`
169
- * ot the `selectable` has `parent` attribute.
170
- */
171
- [propagateDeselection](selectable: Element): void;
172
- /**
173
- * Removes secondary selection mark from `viz-association`
174
- */
175
- [deselectAssociations](selectable: Element): void;
176
- /**
177
- * Similar to `[selectAssociation]()` but it selects associations where
178
- * the `selectable` is the target.
179
- */
180
- [deselectReverseAssociations](selectable: Element): void;
181
- [notifyChanged](): void;
182
- }
183
- //# sourceMappingURL=SelectionManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SelectionManager.d.ts","sourceRoot":"","sources":["../../../../src/visualization/lib/SelectionManager.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,oCAAoC,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C,eAAO,MAAM,YAAY,eAAyB,CAAA;AAClD,eAAO,MAAM,YAAY,eAAyB,CAAA;AAClD,eAAO,MAAM,eAAe,eAA4B,CAAA;AACxD,eAAO,MAAM,gBAAgB,eAA6B,CAAA;AAC1D,eAAO,MAAM,iBAAiB,eAA8B,CAAA;AAC5D,eAAO,MAAM,mBAAmB,eAAgC,CAAA;AAChE,eAAO,MAAM,uBAAuB,eAAoC,CAAA;AACxE,eAAO,MAAM,kBAAkB,eAA+B,CAAA;AAC9D,eAAO,MAAM,kBAAkB,eAA8B,CAAA;AAC7D,eAAO,MAAM,yBAAyB,eAAsC,CAAA;AAC5E,eAAO,MAAM,oBAAoB,eAAiC,CAAA;AAClE,eAAO,MAAM,oBAAoB,eAAiC,CAAA;AAClE,eAAO,MAAM,2BAA2B,eAAwC,CAAA;AAChF,eAAO,MAAM,aAAa,eAA0B,CAAA;AACpD,eAAO,MAAM,kBAAkB,eAA+B,CAAA;AAC9D,eAAO,MAAM,gBAAgB,eAA6B,CAAA;AAE1D;;GAEG;AACH,qBAAa,gBAAgB;IAmCR,MAAM,EAAE,mBAAmB;IAlC9C;;OAEG;IACH,CAAC,kBAAkB,CAAC,eAAsB;IAE1C;;OAEG;IACH,CAAC,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAM;IAE3C,CAAC,gBAAgB,CAAC,CAAC,EAAE,gBAAgB,CAAA;IAErC;;OAEG;IACH,IAAI,aAAa,IAAI,GAAG,CAAC,OAAO,CAAC,CAEhC;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,eAAe,EAAE,CAEhC;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,OAAO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