@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,250 +0,0 @@
1
- import { getRelativeClickPoint, getObjectBoundingClientRect } from '../../lib/PositionUtils.js';
2
- export const mouseDownHandler = Symbol('mouseDownHandler');
3
- export const mouseUpHandler = Symbol('mouseUpHandler');
4
- export const mouseMoveHandler = Symbol('mouseMoveHandler');
5
- export const connectedValue = Symbol('connectedValue');
6
- const CLS = 'selection-zone';
7
- /**
8
- * A plugin that adds support for a group selection via pointer device on the visualization workspace.
9
- *
10
- * This plugin draws a selection rectangle from the starting position until the pointer is released.
11
- * Each selectable element that is inside the rectangle is selected.
12
- *
13
- * After the modeling workspace is created create instance of this class and call `connect()` function
14
- * to start listening for the events. Call `disconnect()` when the workspace is no longer in use.
15
- */
16
- export class GroupSelection {
17
- target;
18
- [connectedValue] = false;
19
- /**
20
- * @returns True when the plug-in is listening for the input events.
21
- */
22
- get connected() {
23
- return this[connectedValue];
24
- }
25
- /**
26
- * Whether a selection is currently being made.
27
- */
28
- selecting = false;
29
- /**
30
- * The element that is being rendered as a selection box.
31
- */
32
- selectionZone = null;
33
- /**
34
- * The click start point
35
- */
36
- startPoint = null;
37
- /**
38
- * The position delta between the start and the current pointer position.
39
- */
40
- delta = null;
41
- /**
42
- * @param target The target workspace element.
43
- */
44
- constructor(target) {
45
- this.target = target;
46
- this[mouseUpHandler] = this[mouseUpHandler].bind(this);
47
- this[mouseDownHandler] = this[mouseDownHandler].bind(this);
48
- this[mouseMoveHandler] = this[mouseMoveHandler].bind(this);
49
- this[connectedValue] = false;
50
- }
51
- connect() {
52
- this.target.addEventListener('mousedown', this[mouseDownHandler]);
53
- document.body.addEventListener('mouseup', this[mouseUpHandler]);
54
- document.body.addEventListener('mousemove', this[mouseMoveHandler]);
55
- this[connectedValue] = true;
56
- }
57
- disconnect() {
58
- this.target.removeEventListener('mousedown', this[mouseDownHandler]);
59
- document.body.removeEventListener('mouseup', this[mouseUpHandler]);
60
- document.body.removeEventListener('mousemove', this[mouseMoveHandler]);
61
- this[connectedValue] = false;
62
- }
63
- reset() {
64
- this.startPoint = null;
65
- this.delta = null;
66
- this.selectionZone = null;
67
- this.selecting = false;
68
- }
69
- [mouseDownHandler](e) {
70
- if (e.target !== this.target || e.button !== 0) {
71
- return;
72
- }
73
- // e.preventDefault();
74
- this.selecting = true;
75
- this.startPoint = this.pointFromEvent(e);
76
- }
77
- [mouseMoveHandler](e) {
78
- if (!this.selecting) {
79
- return;
80
- }
81
- if (!this.selectionZone) {
82
- this.appendSelectionZone(this.startPoint);
83
- }
84
- const current = this.pointFromEvent(e);
85
- this.updateSelectionSize(current);
86
- // // See notes in this function.
87
- this.detectEdges(e);
88
- this.detectSelected();
89
- e.preventDefault();
90
- }
91
- [mouseUpHandler](e) {
92
- if (!this.selecting) {
93
- return;
94
- }
95
- this.clearWorkspace();
96
- this.reset();
97
- e.preventDefault();
98
- }
99
- /**
100
- * Removes the selection rectangle from the workspace
101
- */
102
- clearWorkspace() {
103
- const target = this.target.canvas;
104
- const nodes = target.querySelectorAll(`.${CLS}`);
105
- Array.from(nodes).forEach((n) => target.removeChild(n));
106
- }
107
- /**
108
- * Handles the drop event on one of the children.
109
- * @returns coordinates of the click on the workspace as it would be
110
- * not scaled.
111
- */
112
- pointFromEvent(e) {
113
- const { clientX, clientY } = e;
114
- return getRelativeClickPoint(clientX, clientY, this.target);
115
- }
116
- /**
117
- * Adds a selection box in the place of the click.
118
- * @param position The starting position of the element.
119
- */
120
- appendSelectionZone(position) {
121
- const selectionZone = document.createElement('div');
122
- selectionZone.classList.add(CLS);
123
- const { x, y } = position;
124
- selectionZone.style.top = `${y}px`;
125
- selectionZone.style.left = `${x}px`;
126
- this.target.canvas.append(selectionZone);
127
- this.selectionZone = selectionZone;
128
- }
129
- /**
130
- * Moves the workspace if needed.
131
- */
132
- detectEdges(e) {
133
- const { clientX, clientY } = e;
134
- this.target.scrollIfNeeded(clientX, clientY);
135
- }
136
- /**
137
- * Redraws the selection rectangle to current point
138
- * @param {Point} current
139
- */
140
- updateSelectionSize(current) {
141
- const { x: x1, y: y1 } = this.startPoint;
142
- const { x: x2, y: y2 } = current;
143
- const dx = x2 - x1;
144
- const dy = y2 - y1;
145
- if (dx >= 0) {
146
- this.selectionZone.style.width = `${dx}px`;
147
- }
148
- else {
149
- this.selectionZone.style.width = `${Math.abs(dx)}px`;
150
- const xPos = x1 + dx;
151
- this.selectionZone.style.left = `${xPos}px`;
152
- }
153
- if (dy >= 0) {
154
- this.selectionZone.style.height = `${dy}px`;
155
- }
156
- else {
157
- this.selectionZone.style.height = `${Math.abs(dy)}px`;
158
- const yPos = y1 + dy;
159
- this.selectionZone.style.top = `${yPos}px`;
160
- }
161
- }
162
- detectSelected() {
163
- const selectionManager = this.target.selection;
164
- const items = selectionManager.selectable;
165
- if (!items.length) {
166
- return;
167
- }
168
- const selected = [];
169
- const rect = this.getSelectionRect();
170
- items.forEach((node) => {
171
- const box = getObjectBoundingClientRect(node, this.target);
172
- if (this.collide(rect, box)) {
173
- selected.push(node);
174
- }
175
- });
176
- const targetSelected = [];
177
- selectionManager.selected.forEach((i) => {
178
- if (selectionManager.isSelectable(i.node)) {
179
- targetSelected.push(i.node);
180
- }
181
- });
182
- if (selected.length === targetSelected.length) {
183
- // This is a possible optimization to reduce number of computations.
184
- // Assumption is being made that the actual change can only be made
185
- // when adding or removing a selection (one by one) as the selection
186
- // would have to at the same time select a rectangle and deselect another
187
- // which probably is impossible (?).
188
- return;
189
- }
190
- if (selected.length > 0) {
191
- targetSelected.forEach((node) => {
192
- if (!selected.includes(node) && selectionManager.isSelected(node)) {
193
- selectionManager.setUnselected(node);
194
- }
195
- });
196
- selected.forEach((node) => {
197
- if (!selectionManager.isSelected(node)) {
198
- selectionManager.setSelected(node);
199
- }
200
- });
201
- }
202
- else if (targetSelected.length) {
203
- targetSelected.forEach((node) => selectionManager.setUnselected(node));
204
- }
205
- }
206
- /**
207
- * Reads scaled selection rectangle
208
- * @return A DOMRect object for the selection rectangle
209
- */
210
- getSelectionRect() {
211
- const node = this.selectionZone;
212
- const top = this.getSafeStyleValue(node, 'top');
213
- const left = this.getSafeStyleValue(node, 'left');
214
- const width = this.getSafeStyleValue(node, 'width');
215
- const height = this.getSafeStyleValue(node, 'height');
216
- return new DOMRect(left, top, width, height);
217
- }
218
- /**
219
- * @param node The node to read the style property from.
220
- * @param prop The name of the css property to read
221
- * @returns The value of the property or 0 if not found.
222
- */
223
- getSafeStyleValue(node, prop) {
224
- let value = node.style.getPropertyValue(prop);
225
- if (!value) {
226
- return 0;
227
- }
228
- value = value.replace('px', '');
229
- const result = Number(value);
230
- if (Number.isNaN(result)) {
231
- return 0;
232
- }
233
- return result;
234
- }
235
- /**
236
- * Tests whether a current node collides with the selection rectangle.
237
- * @param selectionRect The selection computed rectangle
238
- * @param rect The Rect of the target element.
239
- * @returns True if the selection rectangle collides with `node`
240
- */
241
- collide(selectionRect, rect) {
242
- const { x: x1, y: y1, width: w1, height: h1 } = selectionRect;
243
- const { x: x2, y: y2, width: w2, height: h2 } = rect;
244
- if (x1 < x2 + w2 && x1 + w1 > x2 && y1 < y2 + h2 && y1 + h1 > y2) {
245
- return true;
246
- }
247
- return false;
248
- }
249
- }
250
- //# sourceMappingURL=GroupSelection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GroupSelection.js","sourceRoot":"","sources":["../../../../../src/visualization/plugin/group-selection/GroupSelection.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAE/F,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAA;AAC1D,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAA;AACtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAA;AAC1D,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAA;AAEtD,MAAM,GAAG,GAAG,gBAAgB,CAAA;AAE5B;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAc;IAiCN;IAhCnB,CAAC,cAAc,CAAC,GAAG,KAAK,CAAA;IAExB;;OAEG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,cAAc,CAAC,CAAA;IAC7B,CAAC;IAED;;OAEG;IACH,SAAS,GAAG,KAAK,CAAA;IAEjB;;OAEG;IACH,aAAa,GAA0B,IAAI,CAAA;IAE3C;;OAEG;IACH,UAAU,GAAiB,IAAI,CAAA;IAE/B;;OAEG;IACH,KAAK,GAAiB,IAAI,CAAA;IAE1B;;OAEG;IACH,YAAmB,MAA2B;QAA3B,WAAM,GAAN,MAAM,CAAqB;QAC5C,IAAI,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACtD,IAAI,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC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AE,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAA;QACpD,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC;YACjE,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport VizWorkspaceElement from '../../elements/VizWorkspaceElement.js'\nimport { Point } from '../../lib/Point.js'\nimport { getRelativeClickPoint, getObjectBoundingClientRect } from '../../lib/PositionUtils.js'\n\nexport const mouseDownHandler = Symbol('mouseDownHandler')\nexport const mouseUpHandler = Symbol('mouseUpHandler')\nexport const mouseMoveHandler = Symbol('mouseMoveHandler')\nexport const connectedValue = Symbol('connectedValue')\n\nconst CLS = 'selection-zone'\n\n/**\n * A plugin that adds support for a group selection via pointer device on the visualization workspace.\n *\n * This plugin draws a selection rectangle from the starting position until the pointer is released.\n * Each selectable element that is inside the rectangle is selected.\n *\n * After the modeling workspace is created create instance of this class and call `connect()` function\n * to start listening for the events. Call `disconnect()` when the workspace is no longer in use.\n */\nexport class GroupSelection {\n [connectedValue] = false\n\n /**\n * @returns True when the plug-in is listening for the input events.\n */\n get connected(): boolean {\n return this[connectedValue]\n }\n\n /**\n * Whether a selection is currently being made.\n */\n selecting = false\n\n /**\n * The element that is being rendered as a selection box.\n */\n selectionZone: HTMLDivElement | null = null\n\n /**\n * The click start point\n */\n startPoint: Point | null = null\n\n /**\n * The position delta between the start and the current pointer position.\n */\n delta: Point | null = null\n\n /**\n * @param target The target workspace element.\n */\n constructor(public target: VizWorkspaceElement) {\n this[mouseUpHandler] = this[mouseUpHandler].bind(this)\n this[mouseDownHandler] = this[mouseDownHandler].bind(this)\n this[mouseMoveHandler] = this[mouseMoveHandler].bind(this)\n this[connectedValue] = false\n }\n\n connect(): void {\n this.target.addEventListener('mousedown', this[mouseDownHandler])\n document.body.addEventListener('mouseup', this[mouseUpHandler])\n document.body.addEventListener('mousemove', this[mouseMoveHandler])\n this[connectedValue] = true\n }\n\n disconnect(): void {\n this.target.removeEventListener('mousedown', this[mouseDownHandler])\n document.body.removeEventListener('mouseup', this[mouseUpHandler])\n document.body.removeEventListener('mousemove', this[mouseMoveHandler])\n this[connectedValue] = false\n }\n\n reset(): void {\n this.startPoint = null\n this.delta = null\n this.selectionZone = null\n this.selecting = false\n }\n\n [mouseDownHandler](e: MouseEvent): void {\n if (e.target !== this.target || e.button !== 0) {\n return\n }\n // e.preventDefault();\n this.selecting = true\n this.startPoint = this.pointFromEvent(e)\n }\n\n [mouseMoveHandler](e: MouseEvent): void {\n if (!this.selecting) {\n return\n }\n if (!this.selectionZone) {\n this.appendSelectionZone(this.startPoint!)\n }\n const current = this.pointFromEvent(e)\n this.updateSelectionSize(current)\n // // See notes in this function.\n this.detectEdges(e)\n this.detectSelected()\n e.preventDefault()\n }\n\n [mouseUpHandler](e: MouseEvent): void {\n if (!this.selecting) {\n return\n }\n this.clearWorkspace()\n this.reset()\n e.preventDefault()\n }\n\n /**\n * Removes the selection rectangle from the workspace\n */\n clearWorkspace(): void {\n const target = this.target.canvas!\n const nodes = target.querySelectorAll(`.${CLS}`)\n Array.from(nodes).forEach((n) => target.removeChild(n))\n }\n\n /**\n * Handles the drop event on one of the children.\n * @returns coordinates of the click on the workspace as it would be\n * not scaled.\n */\n pointFromEvent(e: MouseEvent): Point {\n const { clientX, clientY } = e\n return getRelativeClickPoint(clientX, clientY, this.target)\n }\n\n /**\n * Adds a selection box in the place of the click.\n * @param position The starting position of the element.\n */\n appendSelectionZone(position: Point): void {\n const selectionZone = document.createElement('div')\n selectionZone.classList.add(CLS)\n const { x, y } = position\n selectionZone.style.top = `${y}px`\n selectionZone.style.left = `${x}px`\n this.target.canvas!.append(selectionZone)\n this.selectionZone = selectionZone\n }\n\n /**\n * Moves the workspace if needed.\n */\n detectEdges(e: MouseEvent): void {\n const { clientX, clientY } = e\n this.target.scrollIfNeeded(clientX, clientY)\n }\n\n /**\n * Redraws the selection rectangle to current point\n * @param {Point} current\n */\n updateSelectionSize(current: Point): void {\n const { x: x1, y: y1 } = this.startPoint!\n const { x: x2, y: y2 } = current\n const dx = x2 - x1\n const dy = y2 - y1\n if (dx >= 0) {\n this.selectionZone!.style.width = `${dx}px`\n } else {\n this.selectionZone!.style.width = `${Math.abs(dx)}px`\n const xPos = x1 + dx\n this.selectionZone!.style.left = `${xPos}px`\n }\n if (dy >= 0) {\n this.selectionZone!.style.height = `${dy}px`\n } else {\n this.selectionZone!.style.height = `${Math.abs(dy)}px`\n const yPos = y1 + dy\n this.selectionZone!.style.top = `${yPos}px`\n }\n }\n\n detectSelected(): void {\n const selectionManager = this.target.selection\n const items = selectionManager.selectable\n if (!items.length) {\n return\n }\n const selected: Element[] = []\n const rect = this.getSelectionRect()\n items.forEach((node) => {\n const box = getObjectBoundingClientRect(node, this.target)\n if (this.collide(rect, box)) {\n selected.push(node)\n }\n })\n const targetSelected: Element[] = []\n selectionManager.selected.forEach((i) => {\n if (selectionManager.isSelectable(i.node)) {\n targetSelected.push(i.node)\n }\n })\n if (selected.length === targetSelected.length) {\n // This is a possible optimization to reduce number of computations.\n // Assumption is being made that the actual change can only be made\n // when adding or removing a selection (one by one) as the selection\n // would have to at the same time select a rectangle and deselect another\n // which probably is impossible (?).\n return\n }\n if (selected.length > 0) {\n targetSelected.forEach((node) => {\n if (!selected.includes(node) && selectionManager.isSelected(node)) {\n selectionManager.setUnselected(node)\n }\n })\n selected.forEach((node) => {\n if (!selectionManager.isSelected(node)) {\n selectionManager.setSelected(node)\n }\n })\n } else if (targetSelected.length) {\n targetSelected.forEach((node) => selectionManager.setUnselected(node))\n }\n }\n\n /**\n * Reads scaled selection rectangle\n * @return A DOMRect object for the selection rectangle\n */\n getSelectionRect(): DOMRect {\n const node = this.selectionZone!\n const top = this.getSafeStyleValue(node, 'top')\n const left = this.getSafeStyleValue(node, 'left')\n const width = this.getSafeStyleValue(node, 'width')\n const height = this.getSafeStyleValue(node, 'height')\n return new DOMRect(left, top, width, height)\n }\n\n /**\n * @param node The node to read the style property from.\n * @param prop The name of the css property to read\n * @returns The value of the property or 0 if not found.\n */\n getSafeStyleValue(node: HTMLElement, prop: string): number {\n let value = node.style.getPropertyValue(prop)\n if (!value) {\n return 0\n }\n value = value.replace('px', '')\n const result = Number(value)\n if (Number.isNaN(result)) {\n return 0\n }\n return result\n }\n\n /**\n * Tests whether a current node collides with the selection rectangle.\n * @param selectionRect The selection computed rectangle\n * @param rect The Rect of the target element.\n * @returns True if the selection rectangle collides with `node`\n */\n collide(selectionRect: DOMRect, rect: DOMRect): boolean {\n const { x: x1, y: y1, width: w1, height: h1 } = selectionRect\n const { x: x2, y: y2, width: w2, height: h2 } = rect\n if (x1 < x2 + w2 && x1 + w1 > x2 && y1 < y2 + h2 && y1 + h1 > y2) {\n return true\n }\n return false\n }\n}\n"]}
@@ -1,10 +0,0 @@
1
- import { type Graph } from '@api-client/graph/graph/Graph.js';
2
- import { type EdgeConfig, type GraphLabel, type NodeConfig } from '@api-client/graph/layout/types.js';
3
- import { type PositioningResult, WorkspaceLayout } from './WorkspaceLayout.js';
4
- import { type DataModel } from '@api-client/core/legacy.js';
5
- export declare class DataModelLayout extends WorkspaceLayout {
6
- layout(model: DataModel): PositioningResult | null;
7
- addEntityNode(graph: Graph<GraphLabel, NodeConfig, EdgeConfig>, key: string, rect: DOMRect): void;
8
- ensureAddEntity(graph: Graph<GraphLabel, NodeConfig, EdgeConfig>, entityKey: string): boolean;
9
- }
10
- //# sourceMappingURL=DataModelLayout.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DataModelLayout.d.ts","sourceRoot":"","sources":["../../../../../src/visualization/plugin/positioning/DataModelLayout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,kCAAkC,CAAA;AAE7D,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACrG,OAAO,EAAgB,KAAK,iBAAiB,EAAuB,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACjH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAE3D,qBAAa,eAAgB,SAAQ,eAAe;IAClD,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,iBAAiB,GAAG,IAAI;IAsFlD,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI;IAQjG,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;CAW9F"}
@@ -1,105 +0,0 @@
1
- import layout from '@api-client/graph/layout/layout.js';
2
- import { LayoutWeight, WorkspaceLayout } from './WorkspaceLayout.js';
3
- export class DataModelLayout extends WorkspaceLayout {
4
- layout(model) {
5
- const { entities } = model;
6
- if (!entities.length) {
7
- return null;
8
- }
9
- this.readPositions = {};
10
- const g = this.initGraph();
11
- const selfEntities = entities.map((i) => i.key);
12
- const addedEntities = [];
13
- // parents first
14
- entities.forEach((entity) => {
15
- if (!this.ensureAddEntity(g, entity.key)) {
16
- return;
17
- }
18
- addedEntities.push(entity.key);
19
- entity.parents.forEach((id) => {
20
- if (selfEntities.includes(id) || addedEntities.includes(id) || g.node(id)) {
21
- return;
22
- }
23
- this.ensureAddEntity(g, id);
24
- const config = {
25
- minLen: 1,
26
- weight: LayoutWeight.Parent,
27
- };
28
- g.setEdge(entity.key, id, config);
29
- });
30
- entity.associations.forEach((item) => {
31
- const targets = item.getTargets();
32
- if (!targets.length) {
33
- return;
34
- }
35
- if (targets.length === 1) {
36
- // classic association
37
- const [target] = targets;
38
- this.ensureAddEntity(g, target.key);
39
- addedEntities.push(target.key);
40
- // TODO: Union layout.
41
- }
42
- });
43
- });
44
- // once all entities are set we can add edges
45
- entities.forEach((entity) => {
46
- entity.associations.forEach((item) => {
47
- const targets = item.getTargets();
48
- if (!targets.length) {
49
- return;
50
- }
51
- if (targets.length === 1) {
52
- // classic association
53
- const [target] = targets;
54
- const isSelf = target === entity;
55
- const config = {
56
- minLen: 2,
57
- weight: isSelf ? LayoutWeight.Self : LayoutWeight.Internal,
58
- };
59
- g.setEdge(entity.key, target.key, config);
60
- }
61
- else {
62
- // TODO: Union layout.
63
- }
64
- });
65
- });
66
- layout(g);
67
- const nodes = [];
68
- g.nodes().forEach((id) => {
69
- const def = g.node(id);
70
- if (!def) {
71
- return;
72
- }
73
- const result = { ...def };
74
- result.x -= Math.round(result.width / 2);
75
- result.y -= Math.round(result.height / 2);
76
- nodes.push({
77
- id,
78
- node: result,
79
- });
80
- });
81
- return {
82
- graph: g,
83
- nodes,
84
- };
85
- }
86
- addEntityNode(graph, key, rect) {
87
- const { width, height } = rect;
88
- graph.setNode(key, {
89
- width,
90
- height,
91
- });
92
- }
93
- ensureAddEntity(graph, entityKey) {
94
- if (graph.node(entityKey)) {
95
- return false;
96
- }
97
- const position = this.readDimensions(entityKey);
98
- if (!position) {
99
- return false;
100
- }
101
- this.addEntityNode(graph, entityKey, position);
102
- return true;
103
- }
104
- }
105
- //# sourceMappingURL=DataModelLayout.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DataModelLayout.js","sourceRoot":"","sources":["../../../../../src/visualization/plugin/positioning/DataModelLayout.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,oCAAoC,CAAA;AAEvD,OAAO,EAAE,YAAY,EAA+C,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAGjH,MAAM,OAAO,eAAgB,SAAQ,eAAe;IAClD,MAAM,CAAC,KAAgB;QACrB,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CA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Content":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport { type Graph } from '@api-client/graph/graph/Graph.js'\nimport layout from '@api-client/graph/layout/layout.js'\nimport { type EdgeConfig, type GraphLabel, type NodeConfig } from '@api-client/graph/layout/types.js'\nimport { LayoutWeight, type PositioningResult, type PositionResult, WorkspaceLayout } from './WorkspaceLayout.js'\nimport { type DataModel } from '@api-client/core/legacy.js'\n\nexport class DataModelLayout extends WorkspaceLayout {\n layout(model: DataModel): PositioningResult | null {\n const { entities } = model\n if (!entities.length) {\n return null\n }\n this.readPositions = {}\n const g = this.initGraph()\n\n const selfEntities = entities.map((i) => i.key)\n const addedEntities: string[] = []\n\n // parents first\n entities.forEach((entity) => {\n if (!this.ensureAddEntity(g, entity.key)) {\n return\n }\n addedEntities.push(entity.key)\n entity.parents.forEach((id) => {\n if (selfEntities.includes(id) || addedEntities.includes(id) || g.node(id)) {\n return\n }\n this.ensureAddEntity(g, id)\n const config: EdgeConfig = {\n minLen: 1,\n weight: LayoutWeight.Parent,\n }\n g.setEdge(entity.key, id, config)\n })\n entity.associations.forEach((item) => {\n const targets = item.getTargets()\n if (!targets.length) {\n return\n }\n if (targets.length === 1) {\n // classic association\n const [target] = targets\n this.ensureAddEntity(g, target.key)\n addedEntities.push(target.key)\n // TODO: Union layout.\n }\n })\n })\n // once all entities are set we can add edges\n entities.forEach((entity) => {\n entity.associations.forEach((item) => {\n const targets = item.getTargets()\n if (!targets.length) {\n return\n }\n if (targets.length === 1) {\n // classic association\n const [target] = targets\n const isSelf = target === entity\n const config: EdgeConfig = {\n minLen: 2,\n weight: isSelf ? LayoutWeight.Self : LayoutWeight.Internal,\n }\n g.setEdge(entity.key, target.key, config)\n } else {\n // TODO: Union layout.\n }\n })\n })\n\n layout(g)\n\n const nodes: PositionResult[] = []\n g.nodes().forEach((id) => {\n const def = g.node(id)!\n if (!def) {\n return\n }\n const result: NodeConfig = { ...def }\n result.x! -= Math.round(result.width! / 2)\n result.y! -= Math.round(result.height! / 2)\n nodes.push({\n id,\n node: result,\n })\n })\n return {\n graph: g,\n nodes,\n }\n }\n\n addEntityNode(graph: Graph<GraphLabel, NodeConfig, EdgeConfig>, key: string, rect: DOMRect): void {\n const { width, height } = rect\n graph.setNode(key, {\n width,\n height,\n })\n }\n\n ensureAddEntity(graph: Graph<GraphLabel, NodeConfig, EdgeConfig>, entityKey: string): boolean {\n if (graph.node(entityKey)) {\n return false\n }\n const position = this.readDimensions(entityKey)\n if (!position) {\n return false\n }\n this.addEntityNode(graph, entityKey, position)\n return true\n }\n}\n"]}
@@ -1,93 +0,0 @@
1
- import { Graph } from '@api-client/graph/graph/Graph.js';
2
- import type { EdgeConfig, NodeConfig, GraphLabel, RankDirOptions, AlignOptions, RankerOptions, AcyclicerOptions } from '@api-client/graph/layout/types.js';
3
- import VizWorkspaceElement from '../../elements/VizWorkspaceElement.js';
4
- export interface PositionedEdge {
5
- /**
6
- * The width of the label
7
- */
8
- width?: number;
9
- /**
10
- * The height of the label
11
- */
12
- height?: number;
13
- /**
14
- * The Id of the originating node
15
- */
16
- id: string;
17
- /**
18
- * The id of the target node
19
- */
20
- target: string;
21
- /**
22
- * Edge's weight, if possible to determine
23
- */
24
- weight?: number;
25
- }
26
- export interface PositionResult {
27
- id: string;
28
- node: NodeConfig;
29
- }
30
- export interface PositioningResult {
31
- graph: Graph<GraphLabel, NodeConfig, EdgeConfig>;
32
- nodes: PositionResult[];
33
- }
34
- export declare enum LayoutWeight {
35
- External = 1,
36
- Internal = 10,
37
- Parent = 40,
38
- Self = 80
39
- }
40
- /**
41
- * A helper library that computes positioning of a data model
42
- * in the visualization workspace.
43
- */
44
- export declare class WorkspaceLayout {
45
- workspace: VizWorkspaceElement;
46
- readPositions: Record<string, DOMRect>;
47
- /**
48
- * Direction for rank nodes. Can be TB, BT, LR, or RL, where T = top, B = bottom, L = left, and R = right.
49
- */
50
- rankDir?: RankDirOptions;
51
- /**
52
- * Alignment for rank nodes. Can be UL, UR, DL, or DR, where U = up, D = down, L = left, and R = right.
53
- */
54
- align?: AlignOptions;
55
- /**
56
- * Type of algorithm to assign a rank to each node in the input graph.
57
- */
58
- ranker?: RankerOptions;
59
- /**
60
- * If set to greedy, uses a greedy heuristic for finding a feedback arc set for a graph.
61
- * A feedback arc set is a set of edges that can be removed to make a graph acyclic.
62
- */
63
- acyclicer?: AcyclicerOptions;
64
- /**
65
- * Number of pixels that separate edges horizontally in the layout.
66
- */
67
- edgeSeparation: number;
68
- /**
69
- * Number of pixels between each rank in the layout.
70
- */
71
- rankSeparation: number;
72
- /**
73
- * Number of pixels that separate nodes horizontally in the layout.
74
- */
75
- nodeSeparation: number;
76
- /**
77
- * Graph margin LR
78
- */
79
- marginX: number;
80
- /**
81
- * Graph margin TB
82
- */
83
- marginY: number;
84
- constructor(workspace: VizWorkspaceElement);
85
- /**
86
- * Reads workspace object dimensions
87
- * @param {string} id Domain id of the object
88
- * @returns {DOMRect}
89
- */
90
- readDimensions(id: string): DOMRect | undefined;
91
- initGraph(): Graph<GraphLabel, NodeConfig, EdgeConfig>;
92
- }
93
- //# sourceMappingURL=WorkspaceLayout.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WorkspaceLayout.d.ts","sourceRoot":"","sources":["../../../../../src/visualization/plugin/positioning/WorkspaceLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAA;AACxD,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,gBAAgB,EACjB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,mBAAmB,MAAM,uCAAuC,CAAA;AAGvE,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IACV;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,UAAU,CAAA;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAA;IAChD,KAAK,EAAE,cAAc,EAAE,CAAA;CACxB;AAMD,oBAAY,YAAY;IACtB,QAAQ,IAAI;IACZ,QAAQ,KAAK;IACb,MAAM,KAAK;IACX,IAAI,KAAK;CACV;AAED;;;GAGG;AACH,qBAAa,eAAe;IAiDP,SAAS,EAAE,mBAAmB;IAhDjD,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAK;IAE3C;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IAExB;;OAEG;IACH,KAAK,CAAC,EAAE,YAAY,CAAA;IAEpB;;OAEG;IACH,MAAM,CAAC,EAAE,aAAa,CAAA;IAEtB;;;OAGG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAE5B;;OAEG;IACH,cAAc,SAAK;IAEnB;;OAEG;IACH,cAAc,SAAK;IAEnB;;OAEG;IACH,cAAc,SAAK;IAEnB;;OAEG;IACH,OAAO,SAAK;IAEZ;;OAEG;IACH,OAAO,SAAK;gBAEO,SAAS,EAAE,mBAAmB;IAEjD;;;;OAIG;IACH,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAa/C,SAAS,IAAI,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC;CAkBvD"}
@@ -1,96 +0,0 @@
1
- import { Graph } from '@api-client/graph/graph/Graph.js';
2
- import { getObjectBoundingClientRect } from '../../lib/PositionUtils.js';
3
- // 01 - external association
4
- // 10 - association (internal)
5
- // 20 - parent association
6
- // 40 - self association
7
- export var LayoutWeight;
8
- (function (LayoutWeight) {
9
- LayoutWeight[LayoutWeight["External"] = 1] = "External";
10
- LayoutWeight[LayoutWeight["Internal"] = 10] = "Internal";
11
- LayoutWeight[LayoutWeight["Parent"] = 40] = "Parent";
12
- LayoutWeight[LayoutWeight["Self"] = 80] = "Self";
13
- })(LayoutWeight || (LayoutWeight = {}));
14
- /**
15
- * A helper library that computes positioning of a data model
16
- * in the visualization workspace.
17
- */
18
- export class WorkspaceLayout {
19
- workspace;
20
- readPositions = {};
21
- /**
22
- * Direction for rank nodes. Can be TB, BT, LR, or RL, where T = top, B = bottom, L = left, and R = right.
23
- */
24
- rankDir;
25
- /**
26
- * Alignment for rank nodes. Can be UL, UR, DL, or DR, where U = up, D = down, L = left, and R = right.
27
- */
28
- align;
29
- /**
30
- * Type of algorithm to assign a rank to each node in the input graph.
31
- */
32
- ranker;
33
- /**
34
- * If set to greedy, uses a greedy heuristic for finding a feedback arc set for a graph.
35
- * A feedback arc set is a set of edges that can be removed to make a graph acyclic.
36
- */
37
- acyclicer;
38
- /**
39
- * Number of pixels that separate edges horizontally in the layout.
40
- */
41
- edgeSeparation = 20;
42
- /**
43
- * Number of pixels between each rank in the layout.
44
- */
45
- rankSeparation = 60; // 80
46
- /**
47
- * Number of pixels that separate nodes horizontally in the layout.
48
- */
49
- nodeSeparation = 60; // 80
50
- /**
51
- * Graph margin LR
52
- */
53
- marginX = 40;
54
- /**
55
- * Graph margin TB
56
- */
57
- marginY = 40;
58
- constructor(workspace) {
59
- this.workspace = workspace;
60
- }
61
- /**
62
- * Reads workspace object dimensions
63
- * @param {string} id Domain id of the object
64
- * @returns {DOMRect}
65
- */
66
- readDimensions(id) {
67
- if (this.readPositions[id]) {
68
- return this.readPositions[id];
69
- }
70
- const element = this.workspace.querySelector(`[data-key="${id}"]`);
71
- if (!element) {
72
- return undefined;
73
- }
74
- const rect = getObjectBoundingClientRect(element, this.workspace);
75
- this.readPositions[id] = rect;
76
- return rect;
77
- }
78
- initGraph() {
79
- const g = new Graph();
80
- const { rankDir, align, ranker, acyclicer, edgeSeparation, rankSeparation, nodeSeparation, marginX, marginY } = this;
81
- g.setGraph({
82
- edgeSeparation,
83
- rankSeparation,
84
- nodeSeparation,
85
- rankDir,
86
- align,
87
- ranker,
88
- acyclicer,
89
- marginX,
90
- marginY,
91
- });
92
- // g.setDefaultEdgeLabel(() => { return {}; });
93
- return g;
94
- }
95
- }
96
- //# sourceMappingURL=WorkspaceLayout.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WorkspaceLayout.js","sourceRoot":"","sources":["../../../../../src/visualization/plugin/positioning/WorkspaceLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAA;AAWxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAmCxE,4BAA4B;AAC5B,8BAA8B;AAC9B,0BAA0B;AAC1B,wBAAwB;AACxB,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uDAAY,CAAA;IACZ,wDAAa,CAAA;IACb,oDAAW,CAAA;IACX,gDAAS,CAAA;AACX,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED;;;GAGG;AACH,MAAM,OAAO,eAAe;IAiDP;IAhDnB,aAAa,GAA4B,EAAE,CAAA;IAE3C;;OAEG;IACH,OAAO,CAAiB;IAExB;;OAEG;IACH,KAAK,CAAe;IAEpB;;OAEG;IACH,MAAM,CAAgB;IAEtB;;;OAGG;IACH,SAAS,CAAmB;IAE5B;;OAEG;IACH,cAAc,GAAG,EAAE,CAAA;IAEnB;;OAEG;IACH,cAAc,GAAG,EAAE,CAAA,CAAC,KAAK;IAEzB;;OAEG;IACH,cAAc,GAAG,EAAE,CAAA,CAAC,KAAK;IAEzB;;OAEG;IACH,OAAO,GAAG,EAAE,CAAA;IAEZ;;OAEG;IACH,OAAO,GAAG,EAAE,CAAA;IAEZ,YAAmB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAG,CAAC;IAErD;;;;OAIG;IACH,cAAc,CAAC,EAAU;QACvB,IAAI,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;QAC/B,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;QAClE,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,MAAM,IAAI,GAAG,2BAA2B,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QACjE,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;QAC7B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,SAAS;QACP,MAAM,CAAC,GAAG,IAAI,KAAK,EAAsC,CAAA;QACzD,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;QACpH,CAAC,CAAC,QAAQ,CAAC;YACT,cAAc;YACd,cAAc;YACd,cAAc;YACd,OAAO;YACP,KAAK;YACL,MAAM;YACN,SAAS;YACT,OAAO;YACP,OAAO;SACR,CAAC,CAAA;QAEF,+CAA+C;QAC/C,OAAO,CAAC,CAAA;IACV,CAAC;CACF","sourcesContent":["import { Graph } from '@api-client/graph/graph/Graph.js'\nimport type {\n EdgeConfig,\n NodeConfig,\n GraphLabel,\n RankDirOptions,\n AlignOptions,\n RankerOptions,\n AcyclicerOptions,\n} from '@api-client/graph/layout/types.js'\nimport VizWorkspaceElement from '../../elements/VizWorkspaceElement.js'\nimport { getObjectBoundingClientRect } from '../../lib/PositionUtils.js'\n\nexport interface PositionedEdge {\n /**\n * The width of the label\n */\n width?: number\n /**\n * The height of the label\n */\n height?: number\n /**\n * The Id of the originating node\n */\n id: string\n /**\n * The id of the target node\n */\n target: string\n /**\n * Edge's weight, if possible to determine\n */\n weight?: number\n}\n\nexport interface PositionResult {\n id: string\n node: NodeConfig\n}\n\nexport interface PositioningResult {\n graph: Graph<GraphLabel, NodeConfig, EdgeConfig>\n nodes: PositionResult[]\n}\n\n// 01 - external association\n// 10 - association (internal)\n// 20 - parent association\n// 40 - self association\nexport enum LayoutWeight {\n External = 1,\n Internal = 10,\n Parent = 40,\n Self = 80,\n}\n\n/**\n * A helper library that computes positioning of a data model\n * in the visualization workspace.\n */\nexport class WorkspaceLayout {\n readPositions: Record<string, DOMRect> = {}\n\n /**\n * Direction for rank nodes. Can be TB, BT, LR, or RL, where T = top, B = bottom, L = left, and R = right.\n */\n rankDir?: RankDirOptions\n\n /**\n * Alignment for rank nodes. Can be UL, UR, DL, or DR, where U = up, D = down, L = left, and R = right.\n */\n align?: AlignOptions\n\n /**\n * Type of algorithm to assign a rank to each node in the input graph.\n */\n ranker?: RankerOptions\n\n /**\n * If set to greedy, uses a greedy heuristic for finding a feedback arc set for a graph.\n * A feedback arc set is a set of edges that can be removed to make a graph acyclic.\n */\n acyclicer?: AcyclicerOptions\n\n /**\n * Number of pixels that separate edges horizontally in the layout.\n */\n edgeSeparation = 20\n\n /**\n * Number of pixels between each rank in the layout.\n */\n rankSeparation = 60 // 80\n\n /**\n * Number of pixels that separate nodes horizontally in the layout.\n */\n nodeSeparation = 60 // 80\n\n /**\n * Graph margin LR\n */\n marginX = 40\n\n /**\n * Graph margin TB\n */\n marginY = 40\n\n constructor(public workspace: VizWorkspaceElement) {}\n\n /**\n * Reads workspace object dimensions\n * @param {string} id Domain id of the object\n * @returns {DOMRect}\n */\n readDimensions(id: string): DOMRect | undefined {\n if (this.readPositions[id]) {\n return this.readPositions[id]\n }\n const element = this.workspace.querySelector(`[data-key=\"${id}\"]`)\n if (!element) {\n return undefined\n }\n const rect = getObjectBoundingClientRect(element, this.workspace)\n this.readPositions[id] = rect\n return rect\n }\n\n initGraph(): Graph<GraphLabel, NodeConfig, EdgeConfig> {\n const g = new Graph<GraphLabel, NodeConfig, EdgeConfig>()\n const { rankDir, align, ranker, acyclicer, edgeSeparation, rankSeparation, nodeSeparation, marginX, marginY } = this\n g.setGraph({\n edgeSeparation,\n rankSeparation,\n nodeSeparation,\n rankDir,\n align,\n ranker,\n acyclicer,\n marginX,\n marginY,\n })\n\n // g.setDefaultEdgeLabel(() => { return {}; });\n return g\n }\n}\n"]}
@@ -1,7 +0,0 @@
1
- import Element from './elements/VizAssociationElement.js';
2
- declare global {
3
- interface HTMLElementTagNameMap {
4
- 'viz-association': Element;
5
- }
6
- }
7
- //# sourceMappingURL=viz-association.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"viz-association.d.ts","sourceRoot":"","sources":["../../../src/visualization/viz-association.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,qCAAqC,CAAA;AAIzD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,OAAO,CAAA;KAC3B;CACF"}
@@ -1,3 +0,0 @@
1
- import Element from './elements/VizAssociationElement.js';
2
- window.customElements.define('viz-association', Element);
3
- //# sourceMappingURL=viz-association.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"viz-association.js","sourceRoot":"","sources":["../../../src/visualization/viz-association.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,qCAAqC,CAAA;AAEzD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA","sourcesContent":["import Element from './elements/VizAssociationElement.js'\n\nwindow.customElements.define('viz-association', Element)\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'viz-association': Element\n }\n}\n"]}
@@ -1,7 +0,0 @@
1
- import Element from './elements/VizWorkspaceElement.js';
2
- declare global {
3
- interface HTMLElementTagNameMap {
4
- 'viz-workspace': Element;
5
- }
6
- }
7
- //# sourceMappingURL=viz-workspace.d.ts.map