@babylonjs/shared-ui-components 5.28.0 → 5.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/colorPicker/colorComponentEntry.d.ts +18 -18
  2. package/colorPicker/colorComponentEntry.js +36 -36
  3. package/colorPicker/colorPicker.d.ts +43 -43
  4. package/colorPicker/colorPicker.js +136 -136
  5. package/colorPicker/hexColor.d.ts +20 -20
  6. package/colorPicker/hexColor.js +42 -42
  7. package/components/Button.d.ts +10 -10
  8. package/components/Button.js +6 -6
  9. package/components/Icon.d.ts +6 -6
  10. package/components/Icon.js +6 -6
  11. package/components/Label.d.ts +7 -7
  12. package/components/Label.js +6 -6
  13. package/components/MessageDialog.d.ts +7 -7
  14. package/components/MessageDialog.js +22 -22
  15. package/components/Toggle.d.ts +8 -8
  16. package/components/Toggle.js +15 -15
  17. package/components/bars/CommandBarComponent.d.ts +16 -16
  18. package/components/bars/CommandBarComponent.js +68 -68
  19. package/components/bars/CommandBarComponent.js.map +1 -1
  20. package/components/bars/CommandButtonComponent.d.ts +11 -11
  21. package/components/bars/CommandButtonComponent.js +6 -6
  22. package/components/bars/CommandDropdownComponent.d.ts +26 -26
  23. package/components/bars/CommandDropdownComponent.js +48 -48
  24. package/components/classNames.d.ts +2 -2
  25. package/components/classNames.js +18 -18
  26. package/components/colorPicker/ColorComponentEntry.d.ts +18 -18
  27. package/components/colorPicker/ColorComponentEntry.js +37 -37
  28. package/components/colorPicker/ColorPicker.d.ts +43 -43
  29. package/components/colorPicker/ColorPicker.js +137 -137
  30. package/components/colorPicker/HexColor.d.ts +20 -20
  31. package/components/colorPicker/HexColor.js +45 -45
  32. package/components/layout/DraggableIcon.d.ts +23 -0
  33. package/components/layout/DraggableIcon.js +18 -0
  34. package/components/layout/DraggableIcon.js.map +1 -0
  35. package/components/layout/FlexibleColumn.d.ts +17 -0
  36. package/components/layout/FlexibleColumn.js +12 -0
  37. package/components/layout/FlexibleColumn.js.map +1 -0
  38. package/components/layout/FlexibleDragHandler.d.ts +18 -0
  39. package/components/layout/FlexibleDragHandler.js +88 -0
  40. package/components/layout/FlexibleDragHandler.js.map +1 -0
  41. package/components/layout/FlexibleDropZone.d.ts +19 -0
  42. package/components/layout/FlexibleDropZone.js +12 -0
  43. package/components/layout/FlexibleDropZone.js.map +1 -0
  44. package/components/layout/FlexibleGridContainer.d.ts +10 -0
  45. package/components/layout/FlexibleGridContainer.js +23 -0
  46. package/components/layout/FlexibleGridContainer.js.map +1 -0
  47. package/components/layout/FlexibleGridLayout.d.ts +16 -0
  48. package/components/layout/FlexibleGridLayout.js +24 -0
  49. package/components/layout/FlexibleGridLayout.js.map +1 -0
  50. package/components/layout/FlexibleResizeBar.d.ts +40 -0
  51. package/components/layout/FlexibleResizeBar.js +21 -0
  52. package/components/layout/FlexibleResizeBar.js.map +1 -0
  53. package/components/layout/FlexibleTab.d.ts +34 -0
  54. package/components/layout/FlexibleTab.js +36 -0
  55. package/components/layout/FlexibleTab.js.map +1 -0
  56. package/components/layout/FlexibleTabsContainer.d.ts +28 -0
  57. package/components/layout/FlexibleTabsContainer.js +54 -0
  58. package/components/layout/FlexibleTabsContainer.js.map +1 -0
  59. package/components/layout/LayoutContext.d.ts +12 -0
  60. package/components/layout/LayoutContext.js +3 -0
  61. package/components/layout/LayoutContext.js.map +1 -0
  62. package/components/layout/types.d.ts +82 -0
  63. package/components/layout/types.js +13 -0
  64. package/components/layout/types.js.map +1 -0
  65. package/components/layout/utils.d.ts +25 -0
  66. package/components/layout/utils.js +68 -0
  67. package/components/layout/utils.js.map +1 -0
  68. package/components/lines/ColorLineComponent.d.ts +40 -40
  69. package/components/lines/ColorLineComponent.js +145 -145
  70. package/components/lines/ColorPickerLineComponent.d.ts +33 -33
  71. package/components/lines/ColorPickerLineComponent.js +61 -61
  72. package/components/lines/FileButtonLineComponent.d.ts +16 -16
  73. package/components/lines/FileButtonLineComponent.js +21 -21
  74. package/components/lines/NumericInputComponent.d.ts +31 -31
  75. package/components/lines/NumericInputComponent.js +86 -86
  76. package/lines/booleanLineComponent.d.ts +11 -11
  77. package/lines/booleanLineComponent.js +14 -14
  78. package/lines/buttonLineComponent.d.ts +12 -12
  79. package/lines/buttonLineComponent.js +10 -10
  80. package/lines/checkBoxLineComponent.d.ts +36 -36
  81. package/lines/checkBoxLineComponent.js +88 -88
  82. package/lines/color3LineComponent.d.ts +18 -18
  83. package/lines/color3LineComponent.js +9 -9
  84. package/lines/color4LineComponent.d.ts +18 -18
  85. package/lines/color4LineComponent.js +9 -9
  86. package/lines/colorLineComponent.d.ts +40 -40
  87. package/lines/colorLineComponent.js +144 -144
  88. package/lines/colorPickerComponent.d.ts +31 -31
  89. package/lines/colorPickerComponent.js +60 -60
  90. package/lines/draggableLineComponent.d.ts +9 -9
  91. package/lines/draggableLineComponent.js +12 -12
  92. package/lines/fileButtonLineComponent.d.ts +17 -17
  93. package/lines/fileButtonLineComponent.js +20 -20
  94. package/lines/fileMultipleButtonLineComponent.d.ts +17 -17
  95. package/lines/fileMultipleButtonLineComponent.js +20 -20
  96. package/lines/floatLineComponent.d.ts +50 -50
  97. package/lines/floatLineComponent.js +175 -175
  98. package/lines/hexLineComponent.d.ts +40 -40
  99. package/lines/hexLineComponent.js +121 -121
  100. package/lines/iSelectedLineContainer.d.ts +4 -4
  101. package/lines/iSelectedLineContainer.js +1 -1
  102. package/lines/iconButtonLineComponent.d.ts +11 -11
  103. package/lines/iconButtonLineComponent.js +10 -10
  104. package/lines/iconComponent.d.ts +9 -9
  105. package/lines/iconComponent.js +7 -7
  106. package/lines/indentedTextLineComponent.d.ts +16 -16
  107. package/lines/indentedTextLineComponent.js +26 -26
  108. package/lines/inputArrowsComponent.d.ts +13 -13
  109. package/lines/inputArrowsComponent.js +37 -37
  110. package/lines/lineContainerComponent.d.ts +19 -19
  111. package/lines/lineContainerComponent.js +49 -49
  112. package/lines/linkButtonComponent.d.ts +16 -16
  113. package/lines/linkButtonComponent.js +20 -20
  114. package/lines/matrixLineComponent.d.ts +36 -36
  115. package/lines/matrixLineComponent.js +102 -102
  116. package/lines/messageLineComponent.d.ts +12 -12
  117. package/lines/messageLineComponent.js +14 -14
  118. package/lines/numericInputComponent.d.ts +31 -31
  119. package/lines/numericInputComponent.js +85 -85
  120. package/lines/optionsLineComponent.d.ts +48 -48
  121. package/lines/optionsLineComponent.js +118 -118
  122. package/lines/popup.d.ts +4 -4
  123. package/lines/popup.js +67 -67
  124. package/lines/radioLineComponent.d.ts +21 -21
  125. package/lines/radioLineComponent.js +26 -26
  126. package/lines/sliderLineComponent.d.ts +37 -37
  127. package/lines/sliderLineComponent.js +89 -89
  128. package/lines/targetsProxy.d.ts +11 -11
  129. package/lines/targetsProxy.js +42 -42
  130. package/lines/textInputLineComponent.d.ts +47 -47
  131. package/lines/textInputLineComponent.js +154 -154
  132. package/lines/textLineComponent.d.ts +21 -21
  133. package/lines/textLineComponent.js +30 -30
  134. package/lines/unitButton.d.ts +8 -8
  135. package/lines/unitButton.js +7 -7
  136. package/lines/valueLineComponent.d.ts +15 -15
  137. package/lines/valueLineComponent.js +12 -12
  138. package/lines/vector2LineComponent.d.ts +36 -36
  139. package/lines/vector2LineComponent.js +63 -63
  140. package/lines/vector3LineComponent.d.ts +41 -41
  141. package/lines/vector3LineComponent.js +74 -74
  142. package/lines/vector4LineComponent.d.ts +42 -42
  143. package/lines/vector4LineComponent.js +81 -81
  144. package/nodeGraphSystem/displayLedger.d.ts +5 -5
  145. package/nodeGraphSystem/displayLedger.js +3 -3
  146. package/nodeGraphSystem/frameNodePort.d.ts +25 -25
  147. package/nodeGraphSystem/frameNodePort.js +59 -59
  148. package/nodeGraphSystem/graphCanvas.d.ts +117 -111
  149. package/nodeGraphSystem/graphCanvas.js +1137 -1131
  150. package/nodeGraphSystem/graphCanvas.js.map +1 -1
  151. package/nodeGraphSystem/graphFrame.d.ts +153 -153
  152. package/nodeGraphSystem/graphFrame.js +1328 -1328
  153. package/nodeGraphSystem/graphNode.d.ts +81 -79
  154. package/nodeGraphSystem/graphNode.js +465 -459
  155. package/nodeGraphSystem/graphNode.js.map +1 -1
  156. package/nodeGraphSystem/interfaces/displayManager.d.ts +13 -13
  157. package/nodeGraphSystem/interfaces/displayManager.js +1 -1
  158. package/nodeGraphSystem/interfaces/nodeContainer.d.ts +6 -6
  159. package/nodeGraphSystem/interfaces/nodeContainer.js +1 -1
  160. package/nodeGraphSystem/interfaces/nodeData.d.ts +15 -15
  161. package/nodeGraphSystem/interfaces/nodeData.js +1 -1
  162. package/nodeGraphSystem/interfaces/nodeLocationInfo.d.ts +26 -26
  163. package/nodeGraphSystem/interfaces/nodeLocationInfo.js +1 -1
  164. package/nodeGraphSystem/interfaces/portData.d.ts +28 -28
  165. package/nodeGraphSystem/interfaces/portData.js +7 -7
  166. package/nodeGraphSystem/interfaces/propertyComponentProps.d.ts +6 -6
  167. package/nodeGraphSystem/interfaces/propertyComponentProps.js +1 -1
  168. package/nodeGraphSystem/interfaces/selectionChangedOptions.d.ts +11 -11
  169. package/nodeGraphSystem/interfaces/selectionChangedOptions.js +1 -1
  170. package/nodeGraphSystem/nodeLink.d.ts +31 -31
  171. package/nodeGraphSystem/nodeLink.js +182 -182
  172. package/nodeGraphSystem/nodePort.d.ts +35 -35
  173. package/nodeGraphSystem/nodePort.js +128 -128
  174. package/nodeGraphSystem/propertyLedger.d.ts +8 -8
  175. package/nodeGraphSystem/propertyLedger.js +3 -3
  176. package/nodeGraphSystem/stateManager.d.ts +45 -45
  177. package/nodeGraphSystem/stateManager.js +18 -18
  178. package/nodeGraphSystem/tools.d.ts +5 -5
  179. package/nodeGraphSystem/tools.js +36 -36
  180. package/nodeGraphSystem/typeLedger.d.ts +8 -8
  181. package/nodeGraphSystem/typeLedger.js +2 -2
  182. package/nodeGraphSystem/types/framePortData.d.ts +7 -7
  183. package/nodeGraphSystem/types/framePortData.js +1 -1
  184. package/package.json +4 -3
  185. package/propertyChangedEvent.d.ts +7 -7
  186. package/propertyChangedEvent.js +2 -2
  187. package/stories/Button.stories.d.ts +10 -10
  188. package/stories/Button.stories.js +19 -19
  189. package/stories/Icon.stories.d.ts +9 -9
  190. package/stories/Icon.stories.js +16 -16
  191. package/stories/Label.stories.d.ts +8 -8
  192. package/stories/Label.stories.js +10 -10
  193. package/stories/MessageDialog.stories.d.ts +9 -9
  194. package/stories/MessageDialog.stories.js +19 -19
  195. package/stories/Toggle.stories.d.ts +9 -9
  196. package/stories/Toggle.stories.js +17 -17
  197. package/stories/bars/CommandBarComponent.stories.d.ts +11 -11
  198. package/stories/bars/CommandBarComponent.stories.js +12 -12
  199. package/stories/bars/CommandButtonComponent.stories.d.ts +6 -6
  200. package/stories/bars/CommandButtonComponent.stories.js +6 -6
  201. package/stories/colorPicker/ColorPicker.stories.d.ts +11 -11
  202. package/stories/colorPicker/ColorPicker.stories.js +4 -4
  203. package/stories/layout/FlexibleGridLayout.stories.d.ts +46 -0
  204. package/stories/layout/FlexibleGridLayout.stories.js +48 -0
  205. package/stories/layout/FlexibleGridLayout.stories.js.map +1 -0
  206. package/stories/lines/ColorLineComponent.stories.d.ts +21 -21
  207. package/stories/lines/ColorLineComponent.stories.js +9 -9
  208. package/stories/lines/ColorPickerLineComponent.stories.d.ts +14 -14
  209. package/stories/lines/ColorPickerLineComponent.stories.js +10 -10
  210. package/stories/lines/FileButtonLineComponent.stories.d.ts +6 -6
  211. package/stories/lines/FileButtonLineComponent.stories.js +5 -5
  212. package/stories/lines/NumericInputComponent.stories.d.ts +11 -11
  213. package/stories/lines/NumericInputComponent.stories.js +5 -5
  214. package/stringTools.d.ts +11 -11
  215. package/stringTools.js +88 -88
  216. package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.d.ts +15 -15
  217. package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.js +15 -15
  218. package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.d.ts +15 -15
  219. package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.js +14 -14
  220. package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.d.ts +17 -17
  221. package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.js +55 -55
  222. package/tabs/propertyGrids/gui/controlPropertyGridComponent.d.ts +15 -15
  223. package/tabs/propertyGrids/gui/controlPropertyGridComponent.js +12 -12
  224. package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.d.ts +15 -15
  225. package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.js +15 -15
  226. package/tabs/propertyGrids/gui/gridPropertyGridComponent.d.ts +17 -17
  227. package/tabs/propertyGrids/gui/gridPropertyGridComponent.js +38 -38
  228. package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.d.ts +15 -15
  229. package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.js +16 -16
  230. package/tabs/propertyGrids/gui/imagePropertyGridComponent.d.ts +15 -15
  231. package/tabs/propertyGrids/gui/imagePropertyGridComponent.js +25 -25
  232. package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.d.ts +15 -15
  233. package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.js +17 -17
  234. package/tabs/propertyGrids/gui/linePropertyGridComponent.d.ts +16 -16
  235. package/tabs/propertyGrids/gui/linePropertyGridComponent.js +27 -27
  236. package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.d.ts +15 -15
  237. package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.js +17 -17
  238. package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.d.ts +15 -15
  239. package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.js +15 -15
  240. package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.d.ts +15 -15
  241. package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.js +15 -15
  242. package/tabs/propertyGrids/gui/sliderPropertyGridComponent.d.ts +15 -15
  243. package/tabs/propertyGrids/gui/sliderPropertyGridComponent.js +16 -16
  244. package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.d.ts +15 -15
  245. package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.js +14 -14
  246. package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.d.ts +15 -15
  247. package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.js +34 -34
  248. package/tabs/propertyGrids/lockObject.d.ts +9 -9
  249. package/tabs/propertyGrids/lockObject.js +11 -11
@@ -1,460 +1,466 @@
1
- import * as React from "react";
2
- import { NodePort } from "./nodePort.js";
3
- import { PropertyLedger } from "./propertyLedger.js";
4
- import { DisplayLedger } from "./displayLedger.js";
5
- import localStyles from "./graphNode.modules.scss";
6
- import commonStyles from "./common.modules.scss";
7
- export class GraphNode {
8
- constructor(content, stateManager) {
9
- this.content = content;
10
- this._inputPorts = [];
11
- this._outputPorts = [];
12
- this._links = [];
13
- this._x = 0;
14
- this._y = 0;
15
- this._gridAlignedX = 0;
16
- this._gridAlignedY = 0;
17
- this._mouseStartPointX = null;
18
- this._mouseStartPointY = null;
19
- this._displayManager = null;
20
- this._isVisible = true;
21
- this._enclosingFrameId = -1;
22
- this._stateManager = stateManager;
23
- this._onSelectionChangedObserver = this._stateManager.onSelectionChangedObservable.add((options) => {
24
- const { selection: node } = options || {};
25
- if (node === this) {
26
- this._visual.classList.add(localStyles["selected"]);
27
- }
28
- else {
29
- setTimeout(() => {
30
- if (this._ownerCanvas.selectedNodes.indexOf(this) === -1) {
31
- this._visual.classList.remove(localStyles["selected"]);
32
- }
33
- });
34
- }
35
- });
36
- this._onUpdateRequiredObserver = this._stateManager.onUpdateRequiredObservable.add((data) => {
37
- if (data !== this.content.data) {
38
- return;
39
- }
40
- this.refresh();
41
- });
42
- this._onSelectionBoxMovedObserver = this._stateManager.onSelectionBoxMoved.add((rect1) => {
43
- const rect2 = this._visual.getBoundingClientRect();
44
- const overlap = !(rect1.right < rect2.left || rect1.left > rect2.right || rect1.bottom < rect2.top || rect1.top > rect2.bottom);
45
- this.setIsSelected(overlap, true);
46
- });
47
- this._onFrameCreatedObserver = this._stateManager.onFrameCreatedObservable.add((frame) => {
48
- if (this._ownerCanvas.frames.some((f) => f.nodes.indexOf(this) !== -1)) {
49
- return;
50
- }
51
- if (this.isOverlappingFrame(frame)) {
52
- frame.nodes.push(this);
53
- }
54
- });
55
- }
56
- get isVisible() {
57
- return this._isVisible;
58
- }
59
- set isVisible(value) {
60
- this._isVisible = value;
61
- if (!value) {
62
- this._visual.classList.add(commonStyles["hidden"]);
63
- }
64
- else {
65
- this._visual.classList.remove(commonStyles["hidden"]);
66
- this._upateNodePortNames();
67
- }
68
- for (const link of this._links) {
69
- link.isVisible = value;
70
- }
71
- this._refreshLinks();
72
- }
73
- _upateNodePortNames() {
74
- for (const port of this._inputPorts.concat(this._outputPorts)) {
75
- if (port.hasLabel()) {
76
- port.portName = port.portData.name;
77
- }
78
- }
79
- }
80
- get outputPorts() {
81
- return this._outputPorts;
82
- }
83
- get inputPorts() {
84
- return this._inputPorts;
85
- }
86
- get links() {
87
- return this._links;
88
- }
89
- get gridAlignedX() {
90
- return this._gridAlignedX;
91
- }
92
- get gridAlignedY() {
93
- return this._gridAlignedY;
94
- }
95
- get x() {
96
- return this._x;
97
- }
98
- set x(value) {
99
- if (this._x === value) {
100
- return;
101
- }
102
- this._x = value;
103
- this._gridAlignedX = this._ownerCanvas.getGridPosition(value);
104
- this._visual.style.left = `${this._gridAlignedX}px`;
105
- this._refreshLinks();
106
- this._refreshFrames();
107
- }
108
- get y() {
109
- return this._y;
110
- }
111
- set y(value) {
112
- if (this._y === value) {
113
- return;
114
- }
115
- this._y = value;
116
- this._gridAlignedY = this._ownerCanvas.getGridPosition(value);
117
- this._visual.style.top = `${this._gridAlignedY}px`;
118
- this._refreshLinks();
119
- this._refreshFrames();
120
- }
121
- get width() {
122
- return this._visual.clientWidth;
123
- }
124
- get height() {
125
- return this._visual.clientHeight;
126
- }
127
- get id() {
128
- return this.content.uniqueId;
129
- }
130
- get name() {
131
- return this.content.name;
132
- }
133
- get isSelected() {
134
- return this._isSelected;
135
- }
136
- get enclosingFrameId() {
137
- return this._enclosingFrameId;
138
- }
139
- set enclosingFrameId(value) {
140
- this._enclosingFrameId = value;
141
- }
142
- set isSelected(value) {
143
- this.setIsSelected(value, false);
144
- }
145
- setIsSelected(value, marqueeSelection) {
146
- if (this._isSelected === value) {
147
- return;
148
- }
149
- this._isSelected = value;
150
- if (!value) {
151
- this._visual.classList.remove(localStyles["selected"]);
152
- const indexInSelection = this._ownerCanvas.selectedNodes.indexOf(this);
153
- if (indexInSelection > -1) {
154
- this._ownerCanvas.selectedNodes.splice(indexInSelection, 1);
155
- }
156
- }
157
- else {
158
- this._stateManager.onSelectionChangedObservable.notifyObservers({ selection: this, marqueeSelection });
159
- }
160
- }
161
- isOverlappingFrame(frame) {
162
- const rect2 = this._visual.getBoundingClientRect();
163
- const rect1 = frame.element.getBoundingClientRect();
164
- // Add a tiny margin
165
- rect1.width -= 5;
166
- rect1.height -= 5;
167
- const isOverlappingFrame = !(rect1.right < rect2.left || rect1.left > rect2.right || rect1.bottom < rect2.top || rect1.top > rect2.bottom);
168
- if (isOverlappingFrame) {
169
- this.enclosingFrameId = frame.id;
170
- }
171
- return isOverlappingFrame;
172
- }
173
- getPortForPortData(portData) {
174
- for (const port of this._inputPorts) {
175
- const attachedPoint = port.portData;
176
- if (attachedPoint === portData || (attachedPoint.ownerData === portData.ownerData && attachedPoint.internalName === portData.internalName)) {
177
- return port;
178
- }
179
- }
180
- for (const port of this._outputPorts) {
181
- const attachedPoint = port.portData;
182
- if (attachedPoint === portData || (attachedPoint.ownerData === portData.ownerData && attachedPoint.internalName === portData.internalName)) {
183
- return port;
184
- }
185
- }
186
- return null;
187
- }
188
- getPortDataForPortDataContent(data) {
189
- for (const port of this._inputPorts) {
190
- const attachedPoint = port.portData;
191
- if (attachedPoint.data === data) {
192
- return attachedPoint;
193
- }
194
- }
195
- for (const port of this._outputPorts) {
196
- const attachedPoint = port.portData;
197
- if (attachedPoint.data === data) {
198
- return attachedPoint;
199
- }
200
- }
201
- return null;
202
- }
203
- getLinksForPortDataContent(data) {
204
- return this._links.filter((link) => link.portA.portData.data === data || link.portB.portData.data === data);
205
- }
206
- getLinksForPortData(portData) {
207
- return this._links.filter((link) => link.portA.portData === portData || link.portB.portData === portData);
208
- }
209
- _refreshFrames() {
210
- if (this._ownerCanvas._frameIsMoving || this._ownerCanvas._isLoading) {
211
- return;
212
- }
213
- // Frames
214
- for (const frame of this._ownerCanvas.frames) {
215
- frame.syncNode(this);
216
- }
217
- }
218
- _refreshLinks() {
219
- if (this._ownerCanvas._isLoading) {
220
- return;
221
- }
222
- for (const link of this._links) {
223
- link.update();
224
- }
225
- }
226
- refresh() {
227
- if (this._displayManager) {
228
- this._header.innerHTML = this._displayManager.getHeaderText(this.content);
229
- this._displayManager.updatePreviewContent(this.content, this._content);
230
- this._visual.style.background = this._displayManager.getBackgroundColor(this.content);
231
- const additionalClass = this._displayManager.getHeaderClass(this.content);
232
- this._header.classList.value = localStyles.header;
233
- this._headerContainer.classList.value = localStyles["header-container"];
234
- if (additionalClass) {
235
- this._headerContainer.classList.add(additionalClass);
236
- }
237
- if (this._displayManager.updateFullVisualContent) {
238
- this._displayManager.updateFullVisualContent(this.content, {
239
- visual: this._visual,
240
- header: this._header,
241
- headerContainer: this._headerContainer,
242
- headerIcon: this._headerIcon,
243
- headerIconImg: this._headerIconImg,
244
- comments: this._comments,
245
- connections: this._connections,
246
- inputsContainer: this._inputsContainer,
247
- outputsContainer: this._outputsContainer,
248
- content: this._content,
249
- selectionBorder: this._selectionBorder,
250
- });
251
- }
252
- }
253
- else {
254
- this._header.innerHTML = this.content.name;
255
- }
256
- for (const port of this._inputPorts) {
257
- port.refresh();
258
- }
259
- for (const port of this._outputPorts) {
260
- port.refresh();
261
- }
262
- if (this.enclosingFrameId !== -1) {
263
- const index = this._ownerCanvas.frames.findIndex((frame) => frame.id === this.enclosingFrameId);
264
- if (index >= 0 && this._ownerCanvas.frames[index].isCollapsed) {
265
- this._ownerCanvas.frames[index].redrawFramePorts();
266
- }
267
- }
268
- this._comments.innerHTML = this.content.comments || "";
269
- this._comments.title = this.content.comments || "";
270
- this.content.prepareHeaderIcon(this._headerIcon, this._headerIconImg);
271
- }
272
- _onDown(evt) {
273
- // Check if this is coming from the port
274
- if (evt.target && evt.target.nodeName === "IMG") {
275
- return;
276
- }
277
- const indexInSelection = this._ownerCanvas.selectedNodes.indexOf(this);
278
- if (indexInSelection === -1) {
279
- this._stateManager.onSelectionChangedObservable.notifyObservers({ selection: this });
280
- }
281
- else if (evt.ctrlKey) {
282
- this.setIsSelected(false, false);
283
- }
284
- evt.stopPropagation();
285
- for (const selectedNode of this._ownerCanvas.selectedNodes) {
286
- selectedNode.cleanAccumulation();
287
- }
288
- this._mouseStartPointX = evt.clientX;
289
- this._mouseStartPointY = evt.clientY;
290
- this._visual.setPointerCapture(evt.pointerId);
291
- }
292
- cleanAccumulation(useCeil = false) {
293
- this.x = this._ownerCanvas.getGridPosition(this.x, useCeil);
294
- this.y = this._ownerCanvas.getGridPosition(this.y, useCeil);
295
- }
296
- _onUp(evt) {
297
- evt.stopPropagation();
298
- for (const selectedNode of this._ownerCanvas.selectedNodes) {
299
- selectedNode.cleanAccumulation();
300
- }
301
- this._mouseStartPointX = null;
302
- this._mouseStartPointY = null;
303
- this._visual.releasePointerCapture(evt.pointerId);
304
- if (!this._ownerCanvas._targetLinkCandidate) {
305
- return;
306
- }
307
- // Connect the ports
308
- const inputs = [];
309
- const outputs = [];
310
- const availableNodeInputs = [];
311
- const availableNodeOutputs = [];
312
- const leftNode = this._ownerCanvas._targetLinkCandidate.nodeA;
313
- const rightNode = this._ownerCanvas._targetLinkCandidate.nodeB;
314
- // Delete previous
315
- this._ownerCanvas._targetLinkCandidate.dispose();
316
- this._ownerCanvas._targetLinkCandidate = null;
317
- // Get the ports
318
- availableNodeInputs.push(...this.content.inputs.filter((i) => !i.isConnected));
319
- availableNodeOutputs.push(...this.content.outputs);
320
- inputs.push(...leftNode.content.outputs);
321
- outputs.push(...rightNode.content.inputs.filter((i) => !i.isConnected));
322
- // Reconnect
323
- this._ownerCanvas.automaticRewire(inputs, availableNodeInputs, true);
324
- this._ownerCanvas.automaticRewire(availableNodeOutputs, outputs, true);
325
- this._stateManager.onRebuildRequiredObservable.notifyObservers(false);
326
- }
327
- _onMove(evt) {
328
- this._ownerCanvas._targetLinkCandidate = null;
329
- if (this._mouseStartPointX === null || this._mouseStartPointY === null || evt.ctrlKey) {
330
- return;
331
- }
332
- // Move
333
- const newX = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
334
- const newY = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
335
- for (const selectedNode of this._ownerCanvas.selectedNodes) {
336
- selectedNode.x += newX;
337
- selectedNode.y += newY;
338
- }
339
- for (const frame of this._ownerCanvas.selectedFrames) {
340
- frame._moveFrame(newX, newY);
341
- }
342
- this._mouseStartPointX = evt.clientX;
343
- this._mouseStartPointY = evt.clientY;
344
- evt.stopPropagation();
345
- if (this._inputPorts.some((p) => p.portData.isConnected) || this._outputPorts.some((o) => o.portData.hasEndpoints)) {
346
- return;
347
- }
348
- // Check wires that could be underneath
349
- const rect = this._visual.getBoundingClientRect();
350
- for (const link of this._ownerCanvas.links) {
351
- if (link.portA.node === this || link.portB.node === this) {
352
- link.isTargetCandidate = false;
353
- continue;
354
- }
355
- link.isTargetCandidate = link.intersectsWith(rect);
356
- if (link.isTargetCandidate) {
357
- if (this._ownerCanvas._targetLinkCandidate !== link) {
358
- if (this._ownerCanvas._targetLinkCandidate) {
359
- this._ownerCanvas._targetLinkCandidate.isTargetCandidate = false;
360
- }
361
- this._ownerCanvas._targetLinkCandidate = link;
362
- }
363
- }
364
- }
365
- }
366
- renderProperties() {
367
- let control = PropertyLedger.RegisteredControls[this.content.getClassName()];
368
- if (!control) {
369
- control = PropertyLedger.DefaultControl;
370
- }
371
- return React.createElement(control, {
372
- stateManager: this._stateManager,
373
- nodeData: this.content,
374
- });
375
- }
376
- appendVisual(root, owner) {
377
- this._ownerCanvas = owner;
378
- // Display manager
379
- const displayManagerClass = DisplayLedger.RegisteredControls[this.content.getClassName()];
380
- if (displayManagerClass) {
381
- this._displayManager = new displayManagerClass();
382
- }
383
- // DOM
384
- this._visual = root.ownerDocument.createElement("div");
385
- this._visual.classList.add(localStyles.visual);
386
- this._visual.addEventListener("pointerdown", (evt) => this._onDown(evt));
387
- this._visual.addEventListener("pointerup", (evt) => this._onUp(evt));
388
- this._visual.addEventListener("pointermove", (evt) => this._onMove(evt));
389
- this._headerContainer = root.ownerDocument.createElement("div");
390
- this._headerContainer.classList.add(localStyles["header-container"]);
391
- this._visual.appendChild(this._headerContainer);
392
- this._header = root.ownerDocument.createElement("div");
393
- this._header.classList.add(localStyles.header);
394
- this._headerContainer.appendChild(this._header);
395
- this._headerIcon = root.ownerDocument.createElement("div");
396
- this._headerIcon.classList.add(localStyles.headerIcon);
397
- this._headerIconImg = root.ownerDocument.createElement("img");
398
- this._headerIcon.appendChild(this._headerIconImg);
399
- this._headerContainer.appendChild(this._headerIcon);
400
- this._selectionBorder = root.ownerDocument.createElement("div");
401
- this._selectionBorder.classList.add("selection-border");
402
- this._visual.appendChild(this._selectionBorder);
403
- this._connections = root.ownerDocument.createElement("div");
404
- this._connections.classList.add(localStyles.connections);
405
- this._visual.appendChild(this._connections);
406
- this._inputsContainer = root.ownerDocument.createElement("div");
407
- this._inputsContainer.classList.add(commonStyles.inputsContainer);
408
- this._connections.appendChild(this._inputsContainer);
409
- this._outputsContainer = root.ownerDocument.createElement("div");
410
- this._outputsContainer.classList.add(commonStyles.outputsContainer);
411
- this._connections.appendChild(this._outputsContainer);
412
- this._content = root.ownerDocument.createElement("div");
413
- this._content.classList.add(localStyles.content);
414
- this._visual.appendChild(this._content);
415
- root.appendChild(this._visual);
416
- // Comments
417
- this._comments = root.ownerDocument.createElement("div");
418
- this._comments.classList.add(localStyles.comments);
419
- this._visual.appendChild(this._comments);
420
- // Connections
421
- for (const input of this.content.inputs) {
422
- this._inputPorts.push(NodePort.CreatePortElement(input, this, this._inputsContainer, this._displayManager, this._stateManager));
423
- }
424
- for (const output of this.content.outputs) {
425
- this._outputPorts.push(NodePort.CreatePortElement(output, this, this._outputsContainer, this._displayManager, this._stateManager));
426
- }
427
- this.refresh();
428
- }
429
- dispose() {
430
- // notify frame observers that this node is being deleted
431
- this._stateManager.onGraphNodeRemovalObservable.notifyObservers(this);
432
- if (this._onSelectionChangedObserver) {
433
- this._stateManager.onSelectionChangedObservable.remove(this._onSelectionChangedObserver);
434
- }
435
- if (this._onUpdateRequiredObserver) {
436
- this._stateManager.onUpdateRequiredObservable.remove(this._onUpdateRequiredObserver);
437
- }
438
- if (this._onSelectionBoxMovedObserver) {
439
- this._stateManager.onSelectionBoxMoved.remove(this._onSelectionBoxMovedObserver);
440
- }
441
- if (this._visual.parentElement) {
442
- this._visual.parentElement.removeChild(this._visual);
443
- }
444
- if (this._onFrameCreatedObserver) {
445
- this._stateManager.onFrameCreatedObservable.remove(this._onFrameCreatedObserver);
446
- }
447
- for (const port of this._inputPorts) {
448
- port.dispose();
449
- }
450
- for (const port of this._outputPorts) {
451
- port.dispose();
452
- }
453
- const links = this._links.slice(0);
454
- for (const link of links) {
455
- link.dispose();
456
- }
457
- this.content.dispose();
458
- }
459
- }
1
+ import * as React from "react";
2
+ import { NodePort } from "./nodePort.js";
3
+ import { PropertyLedger } from "./propertyLedger.js";
4
+ import { DisplayLedger } from "./displayLedger.js";
5
+ import localStyles from "./graphNode.modules.scss";
6
+ import commonStyles from "./common.modules.scss";
7
+ export class GraphNode {
8
+ constructor(content, stateManager) {
9
+ this.content = content;
10
+ this._inputPorts = [];
11
+ this._outputPorts = [];
12
+ this._links = [];
13
+ this._x = 0;
14
+ this._y = 0;
15
+ this._gridAlignedX = 0;
16
+ this._gridAlignedY = 0;
17
+ this._mouseStartPointX = null;
18
+ this._mouseStartPointY = null;
19
+ this._displayManager = null;
20
+ this._isVisible = true;
21
+ this._enclosingFrameId = -1;
22
+ this._stateManager = stateManager;
23
+ this._onSelectionChangedObserver = this._stateManager.onSelectionChangedObservable.add((options) => {
24
+ const { selection: node } = options || {};
25
+ if (node === this) {
26
+ this._visual.classList.add(localStyles["selected"]);
27
+ }
28
+ else {
29
+ setTimeout(() => {
30
+ if (this._ownerCanvas.selectedNodes.indexOf(this) === -1) {
31
+ this._visual.classList.remove(localStyles["selected"]);
32
+ }
33
+ });
34
+ }
35
+ });
36
+ this._onUpdateRequiredObserver = this._stateManager.onUpdateRequiredObservable.add((data) => {
37
+ if (data !== this.content.data) {
38
+ return;
39
+ }
40
+ this.refresh();
41
+ });
42
+ this._onSelectionBoxMovedObserver = this._stateManager.onSelectionBoxMoved.add((rect1) => {
43
+ const rect2 = this._visual.getBoundingClientRect();
44
+ const overlap = !(rect1.right < rect2.left || rect1.left > rect2.right || rect1.bottom < rect2.top || rect1.top > rect2.bottom);
45
+ this.setIsSelected(overlap, true);
46
+ });
47
+ this._onFrameCreatedObserver = this._stateManager.onFrameCreatedObservable.add((frame) => {
48
+ if (this._ownerCanvas.frames.some((f) => f.nodes.indexOf(this) !== -1)) {
49
+ return;
50
+ }
51
+ if (this.isOverlappingFrame(frame)) {
52
+ frame.nodes.push(this);
53
+ }
54
+ });
55
+ }
56
+ addClassToVisual(className) {
57
+ this._visual.classList.add(className);
58
+ }
59
+ removeClassFromVisual(className) {
60
+ this._visual.classList.remove(className);
61
+ }
62
+ get isVisible() {
63
+ return this._isVisible;
64
+ }
65
+ set isVisible(value) {
66
+ this._isVisible = value;
67
+ if (!value) {
68
+ this._visual.classList.add(commonStyles["hidden"]);
69
+ }
70
+ else {
71
+ this._visual.classList.remove(commonStyles["hidden"]);
72
+ this._upateNodePortNames();
73
+ }
74
+ for (const link of this._links) {
75
+ link.isVisible = value;
76
+ }
77
+ this._refreshLinks();
78
+ }
79
+ _upateNodePortNames() {
80
+ for (const port of this._inputPorts.concat(this._outputPorts)) {
81
+ if (port.hasLabel()) {
82
+ port.portName = port.portData.name;
83
+ }
84
+ }
85
+ }
86
+ get outputPorts() {
87
+ return this._outputPorts;
88
+ }
89
+ get inputPorts() {
90
+ return this._inputPorts;
91
+ }
92
+ get links() {
93
+ return this._links;
94
+ }
95
+ get gridAlignedX() {
96
+ return this._gridAlignedX;
97
+ }
98
+ get gridAlignedY() {
99
+ return this._gridAlignedY;
100
+ }
101
+ get x() {
102
+ return this._x;
103
+ }
104
+ set x(value) {
105
+ if (this._x === value) {
106
+ return;
107
+ }
108
+ this._x = value;
109
+ this._gridAlignedX = this._ownerCanvas.getGridPosition(value);
110
+ this._visual.style.left = `${this._gridAlignedX}px`;
111
+ this._refreshLinks();
112
+ this._refreshFrames();
113
+ }
114
+ get y() {
115
+ return this._y;
116
+ }
117
+ set y(value) {
118
+ if (this._y === value) {
119
+ return;
120
+ }
121
+ this._y = value;
122
+ this._gridAlignedY = this._ownerCanvas.getGridPosition(value);
123
+ this._visual.style.top = `${this._gridAlignedY}px`;
124
+ this._refreshLinks();
125
+ this._refreshFrames();
126
+ }
127
+ get width() {
128
+ return this._visual.clientWidth;
129
+ }
130
+ get height() {
131
+ return this._visual.clientHeight;
132
+ }
133
+ get id() {
134
+ return this.content.uniqueId;
135
+ }
136
+ get name() {
137
+ return this.content.name;
138
+ }
139
+ get isSelected() {
140
+ return this._isSelected;
141
+ }
142
+ get enclosingFrameId() {
143
+ return this._enclosingFrameId;
144
+ }
145
+ set enclosingFrameId(value) {
146
+ this._enclosingFrameId = value;
147
+ }
148
+ set isSelected(value) {
149
+ this.setIsSelected(value, false);
150
+ }
151
+ setIsSelected(value, marqueeSelection) {
152
+ if (this._isSelected === value) {
153
+ return;
154
+ }
155
+ this._isSelected = value;
156
+ if (!value) {
157
+ this._visual.classList.remove(localStyles["selected"]);
158
+ const indexInSelection = this._ownerCanvas.selectedNodes.indexOf(this);
159
+ if (indexInSelection > -1) {
160
+ this._ownerCanvas.selectedNodes.splice(indexInSelection, 1);
161
+ }
162
+ }
163
+ else {
164
+ this._stateManager.onSelectionChangedObservable.notifyObservers({ selection: this, marqueeSelection });
165
+ }
166
+ }
167
+ isOverlappingFrame(frame) {
168
+ const rect2 = this._visual.getBoundingClientRect();
169
+ const rect1 = frame.element.getBoundingClientRect();
170
+ // Add a tiny margin
171
+ rect1.width -= 5;
172
+ rect1.height -= 5;
173
+ const isOverlappingFrame = !(rect1.right < rect2.left || rect1.left > rect2.right || rect1.bottom < rect2.top || rect1.top > rect2.bottom);
174
+ if (isOverlappingFrame) {
175
+ this.enclosingFrameId = frame.id;
176
+ }
177
+ return isOverlappingFrame;
178
+ }
179
+ getPortForPortData(portData) {
180
+ for (const port of this._inputPorts) {
181
+ const attachedPoint = port.portData;
182
+ if (attachedPoint === portData || (attachedPoint.ownerData === portData.ownerData && attachedPoint.internalName === portData.internalName)) {
183
+ return port;
184
+ }
185
+ }
186
+ for (const port of this._outputPorts) {
187
+ const attachedPoint = port.portData;
188
+ if (attachedPoint === portData || (attachedPoint.ownerData === portData.ownerData && attachedPoint.internalName === portData.internalName)) {
189
+ return port;
190
+ }
191
+ }
192
+ return null;
193
+ }
194
+ getPortDataForPortDataContent(data) {
195
+ for (const port of this._inputPorts) {
196
+ const attachedPoint = port.portData;
197
+ if (attachedPoint.data === data) {
198
+ return attachedPoint;
199
+ }
200
+ }
201
+ for (const port of this._outputPorts) {
202
+ const attachedPoint = port.portData;
203
+ if (attachedPoint.data === data) {
204
+ return attachedPoint;
205
+ }
206
+ }
207
+ return null;
208
+ }
209
+ getLinksForPortDataContent(data) {
210
+ return this._links.filter((link) => link.portA.portData.data === data || link.portB.portData.data === data);
211
+ }
212
+ getLinksForPortData(portData) {
213
+ return this._links.filter((link) => link.portA.portData === portData || link.portB.portData === portData);
214
+ }
215
+ _refreshFrames() {
216
+ if (this._ownerCanvas._frameIsMoving || this._ownerCanvas._isLoading) {
217
+ return;
218
+ }
219
+ // Frames
220
+ for (const frame of this._ownerCanvas.frames) {
221
+ frame.syncNode(this);
222
+ }
223
+ }
224
+ _refreshLinks() {
225
+ if (this._ownerCanvas._isLoading) {
226
+ return;
227
+ }
228
+ for (const link of this._links) {
229
+ link.update();
230
+ }
231
+ }
232
+ refresh() {
233
+ if (this._displayManager) {
234
+ this._header.innerHTML = this._displayManager.getHeaderText(this.content);
235
+ this._displayManager.updatePreviewContent(this.content, this._content);
236
+ this._visual.style.background = this._displayManager.getBackgroundColor(this.content);
237
+ const additionalClass = this._displayManager.getHeaderClass(this.content);
238
+ this._header.classList.value = localStyles.header;
239
+ this._headerContainer.classList.value = localStyles["header-container"];
240
+ if (additionalClass) {
241
+ this._headerContainer.classList.add(additionalClass);
242
+ }
243
+ if (this._displayManager.updateFullVisualContent) {
244
+ this._displayManager.updateFullVisualContent(this.content, {
245
+ visual: this._visual,
246
+ header: this._header,
247
+ headerContainer: this._headerContainer,
248
+ headerIcon: this._headerIcon,
249
+ headerIconImg: this._headerIconImg,
250
+ comments: this._comments,
251
+ connections: this._connections,
252
+ inputsContainer: this._inputsContainer,
253
+ outputsContainer: this._outputsContainer,
254
+ content: this._content,
255
+ selectionBorder: this._selectionBorder,
256
+ });
257
+ }
258
+ }
259
+ else {
260
+ this._header.innerHTML = this.content.name;
261
+ }
262
+ for (const port of this._inputPorts) {
263
+ port.refresh();
264
+ }
265
+ for (const port of this._outputPorts) {
266
+ port.refresh();
267
+ }
268
+ if (this.enclosingFrameId !== -1) {
269
+ const index = this._ownerCanvas.frames.findIndex((frame) => frame.id === this.enclosingFrameId);
270
+ if (index >= 0 && this._ownerCanvas.frames[index].isCollapsed) {
271
+ this._ownerCanvas.frames[index].redrawFramePorts();
272
+ }
273
+ }
274
+ this._comments.innerHTML = this.content.comments || "";
275
+ this._comments.title = this.content.comments || "";
276
+ this.content.prepareHeaderIcon(this._headerIcon, this._headerIconImg);
277
+ }
278
+ _onDown(evt) {
279
+ // Check if this is coming from the port
280
+ if (evt.target && evt.target.nodeName === "IMG") {
281
+ return;
282
+ }
283
+ const indexInSelection = this._ownerCanvas.selectedNodes.indexOf(this);
284
+ if (indexInSelection === -1) {
285
+ this._stateManager.onSelectionChangedObservable.notifyObservers({ selection: this });
286
+ }
287
+ else if (evt.ctrlKey) {
288
+ this.setIsSelected(false, false);
289
+ }
290
+ evt.stopPropagation();
291
+ for (const selectedNode of this._ownerCanvas.selectedNodes) {
292
+ selectedNode.cleanAccumulation();
293
+ }
294
+ this._mouseStartPointX = evt.clientX;
295
+ this._mouseStartPointY = evt.clientY;
296
+ this._visual.setPointerCapture(evt.pointerId);
297
+ }
298
+ cleanAccumulation(useCeil = false) {
299
+ this.x = this._ownerCanvas.getGridPosition(this.x, useCeil);
300
+ this.y = this._ownerCanvas.getGridPosition(this.y, useCeil);
301
+ }
302
+ _onUp(evt) {
303
+ evt.stopPropagation();
304
+ for (const selectedNode of this._ownerCanvas.selectedNodes) {
305
+ selectedNode.cleanAccumulation();
306
+ }
307
+ this._mouseStartPointX = null;
308
+ this._mouseStartPointY = null;
309
+ this._visual.releasePointerCapture(evt.pointerId);
310
+ if (!this._ownerCanvas._targetLinkCandidate) {
311
+ return;
312
+ }
313
+ // Connect the ports
314
+ const inputs = [];
315
+ const outputs = [];
316
+ const availableNodeInputs = [];
317
+ const availableNodeOutputs = [];
318
+ const leftNode = this._ownerCanvas._targetLinkCandidate.nodeA;
319
+ const rightNode = this._ownerCanvas._targetLinkCandidate.nodeB;
320
+ // Delete previous
321
+ this._ownerCanvas._targetLinkCandidate.dispose();
322
+ this._ownerCanvas._targetLinkCandidate = null;
323
+ // Get the ports
324
+ availableNodeInputs.push(...this.content.inputs.filter((i) => !i.isConnected));
325
+ availableNodeOutputs.push(...this.content.outputs);
326
+ inputs.push(...leftNode.content.outputs);
327
+ outputs.push(...rightNode.content.inputs.filter((i) => !i.isConnected));
328
+ // Reconnect
329
+ this._ownerCanvas.automaticRewire(inputs, availableNodeInputs, true);
330
+ this._ownerCanvas.automaticRewire(availableNodeOutputs, outputs, true);
331
+ this._stateManager.onRebuildRequiredObservable.notifyObservers(false);
332
+ }
333
+ _onMove(evt) {
334
+ this._ownerCanvas._targetLinkCandidate = null;
335
+ if (this._mouseStartPointX === null || this._mouseStartPointY === null || evt.ctrlKey) {
336
+ return;
337
+ }
338
+ // Move
339
+ const newX = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
340
+ const newY = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
341
+ for (const selectedNode of this._ownerCanvas.selectedNodes) {
342
+ selectedNode.x += newX;
343
+ selectedNode.y += newY;
344
+ }
345
+ for (const frame of this._ownerCanvas.selectedFrames) {
346
+ frame._moveFrame(newX, newY);
347
+ }
348
+ this._mouseStartPointX = evt.clientX;
349
+ this._mouseStartPointY = evt.clientY;
350
+ evt.stopPropagation();
351
+ if (this._inputPorts.some((p) => p.portData.isConnected) || this._outputPorts.some((o) => o.portData.hasEndpoints)) {
352
+ return;
353
+ }
354
+ // Check wires that could be underneath
355
+ const rect = this._visual.getBoundingClientRect();
356
+ for (const link of this._ownerCanvas.links) {
357
+ if (link.portA.node === this || link.portB.node === this) {
358
+ link.isTargetCandidate = false;
359
+ continue;
360
+ }
361
+ link.isTargetCandidate = link.intersectsWith(rect);
362
+ if (link.isTargetCandidate) {
363
+ if (this._ownerCanvas._targetLinkCandidate !== link) {
364
+ if (this._ownerCanvas._targetLinkCandidate) {
365
+ this._ownerCanvas._targetLinkCandidate.isTargetCandidate = false;
366
+ }
367
+ this._ownerCanvas._targetLinkCandidate = link;
368
+ }
369
+ }
370
+ }
371
+ }
372
+ renderProperties() {
373
+ let control = PropertyLedger.RegisteredControls[this.content.getClassName()];
374
+ if (!control) {
375
+ control = PropertyLedger.DefaultControl;
376
+ }
377
+ return React.createElement(control, {
378
+ stateManager: this._stateManager,
379
+ nodeData: this.content,
380
+ });
381
+ }
382
+ appendVisual(root, owner) {
383
+ this._ownerCanvas = owner;
384
+ // Display manager
385
+ const displayManagerClass = DisplayLedger.RegisteredControls[this.content.getClassName()];
386
+ if (displayManagerClass) {
387
+ this._displayManager = new displayManagerClass();
388
+ }
389
+ // DOM
390
+ this._visual = root.ownerDocument.createElement("div");
391
+ this._visual.classList.add(localStyles.visual);
392
+ this._visual.addEventListener("pointerdown", (evt) => this._onDown(evt));
393
+ this._visual.addEventListener("pointerup", (evt) => this._onUp(evt));
394
+ this._visual.addEventListener("pointermove", (evt) => this._onMove(evt));
395
+ this._headerContainer = root.ownerDocument.createElement("div");
396
+ this._headerContainer.classList.add(localStyles["header-container"]);
397
+ this._visual.appendChild(this._headerContainer);
398
+ this._header = root.ownerDocument.createElement("div");
399
+ this._header.classList.add(localStyles.header);
400
+ this._headerContainer.appendChild(this._header);
401
+ this._headerIcon = root.ownerDocument.createElement("div");
402
+ this._headerIcon.classList.add(localStyles.headerIcon);
403
+ this._headerIconImg = root.ownerDocument.createElement("img");
404
+ this._headerIcon.appendChild(this._headerIconImg);
405
+ this._headerContainer.appendChild(this._headerIcon);
406
+ this._selectionBorder = root.ownerDocument.createElement("div");
407
+ this._selectionBorder.classList.add("selection-border");
408
+ this._visual.appendChild(this._selectionBorder);
409
+ this._connections = root.ownerDocument.createElement("div");
410
+ this._connections.classList.add(localStyles.connections);
411
+ this._visual.appendChild(this._connections);
412
+ this._inputsContainer = root.ownerDocument.createElement("div");
413
+ this._inputsContainer.classList.add(commonStyles.inputsContainer);
414
+ this._connections.appendChild(this._inputsContainer);
415
+ this._outputsContainer = root.ownerDocument.createElement("div");
416
+ this._outputsContainer.classList.add(commonStyles.outputsContainer);
417
+ this._connections.appendChild(this._outputsContainer);
418
+ this._content = root.ownerDocument.createElement("div");
419
+ this._content.classList.add(localStyles.content);
420
+ this._visual.appendChild(this._content);
421
+ root.appendChild(this._visual);
422
+ // Comments
423
+ this._comments = root.ownerDocument.createElement("div");
424
+ this._comments.classList.add(localStyles.comments);
425
+ this._visual.appendChild(this._comments);
426
+ // Connections
427
+ for (const input of this.content.inputs) {
428
+ this._inputPorts.push(NodePort.CreatePortElement(input, this, this._inputsContainer, this._displayManager, this._stateManager));
429
+ }
430
+ for (const output of this.content.outputs) {
431
+ this._outputPorts.push(NodePort.CreatePortElement(output, this, this._outputsContainer, this._displayManager, this._stateManager));
432
+ }
433
+ this.refresh();
434
+ }
435
+ dispose() {
436
+ // notify frame observers that this node is being deleted
437
+ this._stateManager.onGraphNodeRemovalObservable.notifyObservers(this);
438
+ if (this._onSelectionChangedObserver) {
439
+ this._stateManager.onSelectionChangedObservable.remove(this._onSelectionChangedObserver);
440
+ }
441
+ if (this._onUpdateRequiredObserver) {
442
+ this._stateManager.onUpdateRequiredObservable.remove(this._onUpdateRequiredObserver);
443
+ }
444
+ if (this._onSelectionBoxMovedObserver) {
445
+ this._stateManager.onSelectionBoxMoved.remove(this._onSelectionBoxMovedObserver);
446
+ }
447
+ if (this._visual.parentElement) {
448
+ this._visual.parentElement.removeChild(this._visual);
449
+ }
450
+ if (this._onFrameCreatedObserver) {
451
+ this._stateManager.onFrameCreatedObservable.remove(this._onFrameCreatedObserver);
452
+ }
453
+ for (const port of this._inputPorts) {
454
+ port.dispose();
455
+ }
456
+ for (const port of this._outputPorts) {
457
+ port.dispose();
458
+ }
459
+ const links = this._links.slice(0);
460
+ for (const link of links) {
461
+ link.dispose();
462
+ }
463
+ this.content.dispose();
464
+ }
465
+ }
460
466
  //# sourceMappingURL=graphNode.js.map