@babylonjs/shared-ui-components 5.28.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 (312) hide show
  1. package/colorPicker/colorComponentEntry.d.ts +18 -0
  2. package/colorPicker/colorComponentEntry.js +37 -0
  3. package/colorPicker/colorComponentEntry.js.map +1 -0
  4. package/colorPicker/colorPicker.d.ts +43 -0
  5. package/colorPicker/colorPicker.js +137 -0
  6. package/colorPicker/colorPicker.js.map +1 -0
  7. package/colorPicker/hexColor.d.ts +20 -0
  8. package/colorPicker/hexColor.js +43 -0
  9. package/colorPicker/hexColor.js.map +1 -0
  10. package/components/Button.d.ts +10 -0
  11. package/components/Button.js +7 -0
  12. package/components/Button.js.map +1 -0
  13. package/components/Icon.d.ts +6 -0
  14. package/components/Icon.js +7 -0
  15. package/components/Icon.js.map +1 -0
  16. package/components/Label.d.ts +7 -0
  17. package/components/Label.js +7 -0
  18. package/components/Label.js.map +1 -0
  19. package/components/MessageDialog.d.ts +7 -0
  20. package/components/MessageDialog.js +23 -0
  21. package/components/MessageDialog.js.map +1 -0
  22. package/components/Toggle.d.ts +8 -0
  23. package/components/Toggle.js +16 -0
  24. package/components/Toggle.js.map +1 -0
  25. package/components/bars/CommandBarComponent.d.ts +16 -0
  26. package/components/bars/CommandBarComponent.js +69 -0
  27. package/components/bars/CommandBarComponent.js.map +1 -0
  28. package/components/bars/CommandButtonComponent.d.ts +11 -0
  29. package/components/bars/CommandButtonComponent.js +7 -0
  30. package/components/bars/CommandButtonComponent.js.map +1 -0
  31. package/components/bars/CommandDropdownComponent.d.ts +26 -0
  32. package/components/bars/CommandDropdownComponent.js +49 -0
  33. package/components/bars/CommandDropdownComponent.js.map +1 -0
  34. package/components/classNames.d.ts +2 -0
  35. package/components/classNames.js +19 -0
  36. package/components/classNames.js.map +1 -0
  37. package/components/colorPicker/ColorComponentEntry.d.ts +18 -0
  38. package/components/colorPicker/ColorComponentEntry.js +38 -0
  39. package/components/colorPicker/ColorComponentEntry.js.map +1 -0
  40. package/components/colorPicker/ColorPicker.d.ts +43 -0
  41. package/components/colorPicker/ColorPicker.js +138 -0
  42. package/components/colorPicker/ColorPicker.js.map +1 -0
  43. package/components/colorPicker/HexColor.d.ts +20 -0
  44. package/components/colorPicker/HexColor.js +46 -0
  45. package/components/colorPicker/HexColor.js.map +1 -0
  46. package/components/lines/ColorLineComponent.d.ts +40 -0
  47. package/components/lines/ColorLineComponent.js +146 -0
  48. package/components/lines/ColorLineComponent.js.map +1 -0
  49. package/components/lines/ColorPickerLineComponent.d.ts +33 -0
  50. package/components/lines/ColorPickerLineComponent.js +62 -0
  51. package/components/lines/ColorPickerLineComponent.js.map +1 -0
  52. package/components/lines/FileButtonLineComponent.d.ts +16 -0
  53. package/components/lines/FileButtonLineComponent.js +22 -0
  54. package/components/lines/FileButtonLineComponent.js.map +1 -0
  55. package/components/lines/NumericInputComponent.d.ts +31 -0
  56. package/components/lines/NumericInputComponent.js +87 -0
  57. package/components/lines/NumericInputComponent.js.map +1 -0
  58. package/license.md +71 -0
  59. package/lines/booleanLineComponent.d.ts +11 -0
  60. package/lines/booleanLineComponent.js +15 -0
  61. package/lines/booleanLineComponent.js.map +1 -0
  62. package/lines/buttonLineComponent.d.ts +12 -0
  63. package/lines/buttonLineComponent.js +11 -0
  64. package/lines/buttonLineComponent.js.map +1 -0
  65. package/lines/checkBoxLineComponent.d.ts +36 -0
  66. package/lines/checkBoxLineComponent.js +89 -0
  67. package/lines/checkBoxLineComponent.js.map +1 -0
  68. package/lines/color3LineComponent.d.ts +18 -0
  69. package/lines/color3LineComponent.js +10 -0
  70. package/lines/color3LineComponent.js.map +1 -0
  71. package/lines/color4LineComponent.d.ts +18 -0
  72. package/lines/color4LineComponent.js +10 -0
  73. package/lines/color4LineComponent.js.map +1 -0
  74. package/lines/colorLineComponent.d.ts +40 -0
  75. package/lines/colorLineComponent.js +145 -0
  76. package/lines/colorLineComponent.js.map +1 -0
  77. package/lines/colorPickerComponent.d.ts +31 -0
  78. package/lines/colorPickerComponent.js +61 -0
  79. package/lines/colorPickerComponent.js.map +1 -0
  80. package/lines/draggableLineComponent.d.ts +9 -0
  81. package/lines/draggableLineComponent.js +13 -0
  82. package/lines/draggableLineComponent.js.map +1 -0
  83. package/lines/fileButtonLineComponent.d.ts +17 -0
  84. package/lines/fileButtonLineComponent.js +21 -0
  85. package/lines/fileButtonLineComponent.js.map +1 -0
  86. package/lines/fileMultipleButtonLineComponent.d.ts +17 -0
  87. package/lines/fileMultipleButtonLineComponent.js +21 -0
  88. package/lines/fileMultipleButtonLineComponent.js.map +1 -0
  89. package/lines/floatLineComponent.d.ts +50 -0
  90. package/lines/floatLineComponent.js +176 -0
  91. package/lines/floatLineComponent.js.map +1 -0
  92. package/lines/hexLineComponent.d.ts +40 -0
  93. package/lines/hexLineComponent.js +122 -0
  94. package/lines/hexLineComponent.js.map +1 -0
  95. package/lines/iSelectedLineContainer.d.ts +4 -0
  96. package/lines/iSelectedLineContainer.js +2 -0
  97. package/lines/iSelectedLineContainer.js.map +1 -0
  98. package/lines/iconButtonLineComponent.d.ts +11 -0
  99. package/lines/iconButtonLineComponent.js +11 -0
  100. package/lines/iconButtonLineComponent.js.map +1 -0
  101. package/lines/iconComponent.d.ts +9 -0
  102. package/lines/iconComponent.js +8 -0
  103. package/lines/iconComponent.js.map +1 -0
  104. package/lines/indentedTextLineComponent.d.ts +16 -0
  105. package/lines/indentedTextLineComponent.js +27 -0
  106. package/lines/indentedTextLineComponent.js.map +1 -0
  107. package/lines/inputArrowsComponent.d.ts +13 -0
  108. package/lines/inputArrowsComponent.js +38 -0
  109. package/lines/inputArrowsComponent.js.map +1 -0
  110. package/lines/lineContainerComponent.d.ts +19 -0
  111. package/lines/lineContainerComponent.js +50 -0
  112. package/lines/lineContainerComponent.js.map +1 -0
  113. package/lines/linkButtonComponent.d.ts +16 -0
  114. package/lines/linkButtonComponent.js +21 -0
  115. package/lines/linkButtonComponent.js.map +1 -0
  116. package/lines/matrixLineComponent.d.ts +36 -0
  117. package/lines/matrixLineComponent.js +103 -0
  118. package/lines/matrixLineComponent.js.map +1 -0
  119. package/lines/messageLineComponent.d.ts +12 -0
  120. package/lines/messageLineComponent.js +15 -0
  121. package/lines/messageLineComponent.js.map +1 -0
  122. package/lines/numericInputComponent.d.ts +31 -0
  123. package/lines/numericInputComponent.js +86 -0
  124. package/lines/numericInputComponent.js.map +1 -0
  125. package/lines/optionsLineComponent.d.ts +48 -0
  126. package/lines/optionsLineComponent.js +119 -0
  127. package/lines/optionsLineComponent.js.map +1 -0
  128. package/lines/popup.d.ts +4 -0
  129. package/lines/popup.js +68 -0
  130. package/lines/popup.js.map +1 -0
  131. package/lines/radioLineComponent.d.ts +21 -0
  132. package/lines/radioLineComponent.js +27 -0
  133. package/lines/radioLineComponent.js.map +1 -0
  134. package/lines/sliderLineComponent.d.ts +37 -0
  135. package/lines/sliderLineComponent.js +90 -0
  136. package/lines/sliderLineComponent.js.map +1 -0
  137. package/lines/targetsProxy.d.ts +11 -0
  138. package/lines/targetsProxy.js +43 -0
  139. package/lines/targetsProxy.js.map +1 -0
  140. package/lines/textInputLineComponent.d.ts +47 -0
  141. package/lines/textInputLineComponent.js +155 -0
  142. package/lines/textInputLineComponent.js.map +1 -0
  143. package/lines/textLineComponent.d.ts +21 -0
  144. package/lines/textLineComponent.js +31 -0
  145. package/lines/textLineComponent.js.map +1 -0
  146. package/lines/unitButton.d.ts +8 -0
  147. package/lines/unitButton.js +8 -0
  148. package/lines/unitButton.js.map +1 -0
  149. package/lines/valueLineComponent.d.ts +15 -0
  150. package/lines/valueLineComponent.js +13 -0
  151. package/lines/valueLineComponent.js.map +1 -0
  152. package/lines/vector2LineComponent.d.ts +36 -0
  153. package/lines/vector2LineComponent.js +64 -0
  154. package/lines/vector2LineComponent.js.map +1 -0
  155. package/lines/vector3LineComponent.d.ts +41 -0
  156. package/lines/vector3LineComponent.js +75 -0
  157. package/lines/vector3LineComponent.js.map +1 -0
  158. package/lines/vector4LineComponent.d.ts +42 -0
  159. package/lines/vector4LineComponent.js +82 -0
  160. package/lines/vector4LineComponent.js.map +1 -0
  161. package/nodeGraphSystem/displayLedger.d.ts +5 -0
  162. package/nodeGraphSystem/displayLedger.js +4 -0
  163. package/nodeGraphSystem/displayLedger.js.map +1 -0
  164. package/nodeGraphSystem/frameNodePort.d.ts +25 -0
  165. package/nodeGraphSystem/frameNodePort.js +60 -0
  166. package/nodeGraphSystem/frameNodePort.js.map +1 -0
  167. package/nodeGraphSystem/graphCanvas.d.ts +111 -0
  168. package/nodeGraphSystem/graphCanvas.js +1132 -0
  169. package/nodeGraphSystem/graphCanvas.js.map +1 -0
  170. package/nodeGraphSystem/graphFrame.d.ts +153 -0
  171. package/nodeGraphSystem/graphFrame.js +1329 -0
  172. package/nodeGraphSystem/graphFrame.js.map +1 -0
  173. package/nodeGraphSystem/graphNode.d.ts +79 -0
  174. package/nodeGraphSystem/graphNode.js +460 -0
  175. package/nodeGraphSystem/graphNode.js.map +1 -0
  176. package/nodeGraphSystem/interfaces/displayManager.d.ts +13 -0
  177. package/nodeGraphSystem/interfaces/displayManager.js +2 -0
  178. package/nodeGraphSystem/interfaces/displayManager.js.map +1 -0
  179. package/nodeGraphSystem/interfaces/nodeContainer.d.ts +6 -0
  180. package/nodeGraphSystem/interfaces/nodeContainer.js +2 -0
  181. package/nodeGraphSystem/interfaces/nodeContainer.js.map +1 -0
  182. package/nodeGraphSystem/interfaces/nodeData.d.ts +15 -0
  183. package/nodeGraphSystem/interfaces/nodeData.js +2 -0
  184. package/nodeGraphSystem/interfaces/nodeData.js.map +1 -0
  185. package/nodeGraphSystem/interfaces/nodeLocationInfo.d.ts +26 -0
  186. package/nodeGraphSystem/interfaces/nodeLocationInfo.js +2 -0
  187. package/nodeGraphSystem/interfaces/nodeLocationInfo.js.map +1 -0
  188. package/nodeGraphSystem/interfaces/portData.d.ts +28 -0
  189. package/nodeGraphSystem/interfaces/portData.js +8 -0
  190. package/nodeGraphSystem/interfaces/portData.js.map +1 -0
  191. package/nodeGraphSystem/interfaces/propertyComponentProps.d.ts +6 -0
  192. package/nodeGraphSystem/interfaces/propertyComponentProps.js +2 -0
  193. package/nodeGraphSystem/interfaces/propertyComponentProps.js.map +1 -0
  194. package/nodeGraphSystem/interfaces/selectionChangedOptions.d.ts +11 -0
  195. package/nodeGraphSystem/interfaces/selectionChangedOptions.js +2 -0
  196. package/nodeGraphSystem/interfaces/selectionChangedOptions.js.map +1 -0
  197. package/nodeGraphSystem/nodeLink.d.ts +31 -0
  198. package/nodeGraphSystem/nodeLink.js +183 -0
  199. package/nodeGraphSystem/nodeLink.js.map +1 -0
  200. package/nodeGraphSystem/nodePort.d.ts +35 -0
  201. package/nodeGraphSystem/nodePort.js +129 -0
  202. package/nodeGraphSystem/nodePort.js.map +1 -0
  203. package/nodeGraphSystem/propertyLedger.d.ts +8 -0
  204. package/nodeGraphSystem/propertyLedger.js +4 -0
  205. package/nodeGraphSystem/propertyLedger.js.map +1 -0
  206. package/nodeGraphSystem/stateManager.d.ts +45 -0
  207. package/nodeGraphSystem/stateManager.js +19 -0
  208. package/nodeGraphSystem/stateManager.js.map +1 -0
  209. package/nodeGraphSystem/tools.d.ts +5 -0
  210. package/nodeGraphSystem/tools.js +37 -0
  211. package/nodeGraphSystem/tools.js.map +1 -0
  212. package/nodeGraphSystem/typeLedger.d.ts +8 -0
  213. package/nodeGraphSystem/typeLedger.js +3 -0
  214. package/nodeGraphSystem/typeLedger.js.map +1 -0
  215. package/nodeGraphSystem/types/framePortData.d.ts +7 -0
  216. package/nodeGraphSystem/types/framePortData.js +2 -0
  217. package/nodeGraphSystem/types/framePortData.js.map +1 -0
  218. package/package.json +55 -0
  219. package/propertyChangedEvent.d.ts +7 -0
  220. package/propertyChangedEvent.js +3 -0
  221. package/propertyChangedEvent.js.map +1 -0
  222. package/readme.md +6 -0
  223. package/stories/Button.stories.d.ts +10 -0
  224. package/stories/Button.stories.js +20 -0
  225. package/stories/Button.stories.js.map +1 -0
  226. package/stories/Icon.stories.d.ts +9 -0
  227. package/stories/Icon.stories.js +17 -0
  228. package/stories/Icon.stories.js.map +1 -0
  229. package/stories/Label.stories.d.ts +8 -0
  230. package/stories/Label.stories.js +11 -0
  231. package/stories/Label.stories.js.map +1 -0
  232. package/stories/MessageDialog.stories.d.ts +9 -0
  233. package/stories/MessageDialog.stories.js +20 -0
  234. package/stories/MessageDialog.stories.js.map +1 -0
  235. package/stories/Toggle.stories.d.ts +9 -0
  236. package/stories/Toggle.stories.js +18 -0
  237. package/stories/Toggle.stories.js.map +1 -0
  238. package/stories/bars/CommandBarComponent.stories.d.ts +11 -0
  239. package/stories/bars/CommandBarComponent.stories.js +13 -0
  240. package/stories/bars/CommandBarComponent.stories.js.map +1 -0
  241. package/stories/bars/CommandButtonComponent.stories.d.ts +6 -0
  242. package/stories/bars/CommandButtonComponent.stories.js +7 -0
  243. package/stories/bars/CommandButtonComponent.stories.js.map +1 -0
  244. package/stories/colorPicker/ColorPicker.stories.d.ts +11 -0
  245. package/stories/colorPicker/ColorPicker.stories.js +5 -0
  246. package/stories/colorPicker/ColorPicker.stories.js.map +1 -0
  247. package/stories/lines/ColorLineComponent.stories.d.ts +21 -0
  248. package/stories/lines/ColorLineComponent.stories.js +10 -0
  249. package/stories/lines/ColorLineComponent.stories.js.map +1 -0
  250. package/stories/lines/ColorPickerLineComponent.stories.d.ts +14 -0
  251. package/stories/lines/ColorPickerLineComponent.stories.js +11 -0
  252. package/stories/lines/ColorPickerLineComponent.stories.js.map +1 -0
  253. package/stories/lines/FileButtonLineComponent.stories.d.ts +6 -0
  254. package/stories/lines/FileButtonLineComponent.stories.js +6 -0
  255. package/stories/lines/FileButtonLineComponent.stories.js.map +1 -0
  256. package/stories/lines/NumericInputComponent.stories.d.ts +11 -0
  257. package/stories/lines/NumericInputComponent.stories.js +6 -0
  258. package/stories/lines/NumericInputComponent.stories.js.map +1 -0
  259. package/stringTools.d.ts +11 -0
  260. package/stringTools.js +89 -0
  261. package/stringTools.js.map +1 -0
  262. package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.d.ts +15 -0
  263. package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.js +16 -0
  264. package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.js.map +1 -0
  265. package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.d.ts +15 -0
  266. package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.js +15 -0
  267. package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.js.map +1 -0
  268. package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.d.ts +17 -0
  269. package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.js +56 -0
  270. package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.js.map +1 -0
  271. package/tabs/propertyGrids/gui/controlPropertyGridComponent.d.ts +15 -0
  272. package/tabs/propertyGrids/gui/controlPropertyGridComponent.js +13 -0
  273. package/tabs/propertyGrids/gui/controlPropertyGridComponent.js.map +1 -0
  274. package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.d.ts +15 -0
  275. package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.js +16 -0
  276. package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.js.map +1 -0
  277. package/tabs/propertyGrids/gui/gridPropertyGridComponent.d.ts +17 -0
  278. package/tabs/propertyGrids/gui/gridPropertyGridComponent.js +39 -0
  279. package/tabs/propertyGrids/gui/gridPropertyGridComponent.js.map +1 -0
  280. package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.d.ts +15 -0
  281. package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.js +17 -0
  282. package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.js.map +1 -0
  283. package/tabs/propertyGrids/gui/imagePropertyGridComponent.d.ts +15 -0
  284. package/tabs/propertyGrids/gui/imagePropertyGridComponent.js +26 -0
  285. package/tabs/propertyGrids/gui/imagePropertyGridComponent.js.map +1 -0
  286. package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.d.ts +15 -0
  287. package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.js +18 -0
  288. package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.js.map +1 -0
  289. package/tabs/propertyGrids/gui/linePropertyGridComponent.d.ts +16 -0
  290. package/tabs/propertyGrids/gui/linePropertyGridComponent.js +28 -0
  291. package/tabs/propertyGrids/gui/linePropertyGridComponent.js.map +1 -0
  292. package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.d.ts +15 -0
  293. package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.js +18 -0
  294. package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.js.map +1 -0
  295. package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.d.ts +15 -0
  296. package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.js +16 -0
  297. package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.js.map +1 -0
  298. package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.d.ts +15 -0
  299. package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.js +16 -0
  300. package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.js.map +1 -0
  301. package/tabs/propertyGrids/gui/sliderPropertyGridComponent.d.ts +15 -0
  302. package/tabs/propertyGrids/gui/sliderPropertyGridComponent.js +17 -0
  303. package/tabs/propertyGrids/gui/sliderPropertyGridComponent.js.map +1 -0
  304. package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.d.ts +15 -0
  305. package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.js +15 -0
  306. package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.js.map +1 -0
  307. package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.d.ts +15 -0
  308. package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.js +35 -0
  309. package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.js.map +1 -0
  310. package/tabs/propertyGrids/lockObject.d.ts +9 -0
  311. package/tabs/propertyGrids/lockObject.js +12 -0
  312. package/tabs/propertyGrids/lockObject.js.map +1 -0
@@ -0,0 +1,1329 @@
1
+ import { Observable } from "@babylonjs/core/Misc/observable.js";
2
+ import { Color3 } from "@babylonjs/core/Maths/math.color.js";
3
+ import { FrameNodePort } from "./frameNodePort.js";
4
+ import { StringTools } from "../stringTools.js";
5
+ import styles from "./graphFrame.modules.scss";
6
+ import commonStyles from "./common.modules.scss";
7
+ import { ClassNames } from "shared-ui-components/components/classNames";
8
+ var ResizingDirection;
9
+ (function (ResizingDirection) {
10
+ ResizingDirection[ResizingDirection["Right"] = 0] = "Right";
11
+ ResizingDirection[ResizingDirection["Left"] = 1] = "Left";
12
+ ResizingDirection[ResizingDirection["Top"] = 2] = "Top";
13
+ ResizingDirection[ResizingDirection["Bottom"] = 3] = "Bottom";
14
+ ResizingDirection[ResizingDirection["TopRight"] = 4] = "TopRight";
15
+ ResizingDirection[ResizingDirection["TopLeft"] = 5] = "TopLeft";
16
+ ResizingDirection[ResizingDirection["BottomRight"] = 6] = "BottomRight";
17
+ ResizingDirection[ResizingDirection["BottomLeft"] = 7] = "BottomLeft";
18
+ })(ResizingDirection || (ResizingDirection = {}));
19
+ export var FramePortPosition;
20
+ (function (FramePortPosition) {
21
+ FramePortPosition[FramePortPosition["Top"] = 0] = "Top";
22
+ FramePortPosition[FramePortPosition["Middle"] = 1] = "Middle";
23
+ FramePortPosition[FramePortPosition["Bottom"] = 2] = "Bottom";
24
+ })(FramePortPosition || (FramePortPosition = {}));
25
+ export class GraphFrame {
26
+ constructor(candidate, canvas, doNotCaptureNodes = false) {
27
+ this._collapsedWidth = 200;
28
+ this._x = 0;
29
+ this._y = 0;
30
+ this._gridAlignedX = 0;
31
+ this._gridAlignedY = 0;
32
+ this._nodes = [];
33
+ this._mouseStartPointX = null;
34
+ this._mouseStartPointY = null;
35
+ this._onNodeLinkDisposedObservers = [];
36
+ this._isCollapsed = false;
37
+ this._frameInPorts = [];
38
+ this._frameOutPorts = [];
39
+ this._controlledPorts = []; // Ports on Nodes that are shown on outside of frame
40
+ this._exposedInPorts = [];
41
+ this._exposedOutPorts = [];
42
+ this._minFrameHeight = 40;
43
+ this._minFrameWidth = 220;
44
+ this.onExpandStateChanged = new Observable();
45
+ this._closeSVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><g id="Layer_2" data-name="Layer 2"><path d="M16,15l5.85,5.84-1,1L15,15.93,9.15,21.78l-1-1L14,15,8.19,9.12l1-1L15,14l5.84-5.84,1,1Z"/></g></svg>`;
46
+ this._expandSVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><g id="Layer_2" data-name="Layer 2"><path d="M22.31,7.69V22.31H7.69V7.69ZM21.19,8.81H8.81V21.19H21.19Zm-6.75,6.75H11.06V14.44h3.38V11.06h1.12v3.38h3.38v1.12H15.56v3.38H14.44Z"/></g></svg>`;
47
+ this._collapseSVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><g id="Layer_2" data-name="Layer 2"><path d="M22.31,7.69V22.31H7.69V7.69ZM21.19,8.81H8.81V21.19H21.19Zm-2.25,6.75H11.06V14.44h7.88Z"/></g></svg>`;
48
+ this._initResizing = (evt) => {
49
+ evt.stopPropagation();
50
+ this._mouseStartPointX = evt.clientX;
51
+ this._mouseStartPointY = evt.clientY;
52
+ this._frameIsResizing = true;
53
+ };
54
+ this._cleanUpResizing = (evt) => {
55
+ evt.stopPropagation();
56
+ this._frameIsResizing = false;
57
+ this._resizingDirection = null;
58
+ this._mouseStartPointX = null;
59
+ this._mouseStartPointY = null;
60
+ this._mouseXLimit = null;
61
+ this.refresh();
62
+ };
63
+ this._updateMinHeightWithComments = () => {
64
+ if (this.comments && this.comments.length > 0) {
65
+ const minFrameHeightWithComments = this._commentsElement.offsetHeight + 40;
66
+ this._minFrameHeight = minFrameHeightWithComments;
67
+ }
68
+ };
69
+ this._onRightHandlePointerDown = (evt) => {
70
+ if (this.isCollapsed) {
71
+ return;
72
+ }
73
+ this._initResizing(evt);
74
+ this._resizingDirection = ResizingDirection.Right;
75
+ this._mouseXLimit = evt.clientX - (this.width - this._minFrameWidth);
76
+ this._ownerCanvas.hostCanvas.addEventListener("pointerup", this._onRightHandlePointerUp);
77
+ this._ownerCanvas.hostCanvas.addEventListener("pointermove", this._onRightHandlePointerMove);
78
+ };
79
+ this._onRightHandlePointerMove = (evt) => {
80
+ const slack = (this.element.offsetWidth - this._minFrameWidth) * this._ownerCanvas.zoom;
81
+ const xLimit = this._mouseStartPointX - slack;
82
+ this._moveRightHandle(evt, xLimit);
83
+ };
84
+ this._moveRightHandle = (evt, xLimit) => {
85
+ // tslint:disable-next-line: no-this-assignment
86
+ if (this._mouseXLimit) {
87
+ if (!this._isResizingRight() || this._mouseStartPointX === null || this._mouseStartPointY === null || evt.clientX < xLimit) {
88
+ return;
89
+ }
90
+ if (this._isResizingRight()) {
91
+ evt.stopPropagation();
92
+ const distanceMouseMoved = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
93
+ this._expandRight(distanceMouseMoved, evt.clientX);
94
+ this._mouseStartPointX = evt.clientX;
95
+ }
96
+ }
97
+ };
98
+ this._onRightHandlePointerUp = (evt) => {
99
+ if (this._isResizingRight()) {
100
+ this.width = parseFloat(this.element.style.width.replace("px", ""));
101
+ this._ownerCanvas.hostCanvas.removeEventListener("pointerup", this._onRightHandlePointerUp);
102
+ this._ownerCanvas.hostCanvas.removeEventListener("pointermove", this._onRightHandlePointerMove);
103
+ this._cleanUpResizing(evt);
104
+ }
105
+ };
106
+ this._onBottomHandlePointerDown = (evt) => {
107
+ if (this.isCollapsed) {
108
+ return;
109
+ }
110
+ this._initResizing(evt);
111
+ this._resizingDirection = ResizingDirection.Bottom;
112
+ this._ownerCanvas.hostCanvas.addEventListener("pointermove", this._onBottomHandlePointerMove);
113
+ this._ownerCanvas.hostCanvas.addEventListener("pointerup", this._onBottomHandlePointerUp);
114
+ };
115
+ this._onBottomHandlePointerMove = (evt) => {
116
+ const slack = (this.element.offsetHeight - this._minFrameHeight) * this._ownerCanvas.zoom;
117
+ const yLimit = this._mouseStartPointY - slack;
118
+ this._moveBottomHandle(evt, yLimit);
119
+ };
120
+ this._moveBottomHandle = (evt, yLimit) => {
121
+ if (this._resizingDirection !== ResizingDirection.Bottom || this._mouseStartPointX === null || this._mouseStartPointY === null || evt.clientY < yLimit) {
122
+ return;
123
+ }
124
+ if (this._resizingDirection === ResizingDirection.Bottom) {
125
+ evt.stopPropagation();
126
+ const distanceMouseMoved = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
127
+ this._expandBottom(distanceMouseMoved);
128
+ this._mouseStartPointY = evt.clientY;
129
+ }
130
+ };
131
+ this._onBottomHandlePointerUp = (evt) => {
132
+ if (this._resizingDirection === ResizingDirection.Bottom) {
133
+ this.height = parseFloat(this.element.style.height.replace("px", ""));
134
+ this._ownerCanvas.hostCanvas.removeEventListener("pointermove", this._onBottomHandlePointerMove);
135
+ this._ownerCanvas.hostCanvas.removeEventListener("pointerup", this._onBottomHandlePointerUp);
136
+ this._cleanUpResizing(evt);
137
+ }
138
+ };
139
+ this._onLeftHandlePointerDown = (evt) => {
140
+ if (this.isCollapsed) {
141
+ return;
142
+ }
143
+ this._initResizing(evt);
144
+ this._resizingDirection = ResizingDirection.Left;
145
+ this._mouseXLimit = evt.clientX + this.width - this._minFrameWidth;
146
+ this._ownerCanvas.hostCanvas.addEventListener("pointerup", this._onLeftHandlePointerUp);
147
+ this._ownerCanvas.hostCanvas.addEventListener("pointermove", this._onLeftHandlePointerMove);
148
+ };
149
+ this._onLeftHandlePointerMove = (evt) => {
150
+ const slack = (this.element.offsetWidth - this._minFrameWidth) * this._ownerCanvas.zoom;
151
+ const xLimit = this._mouseStartPointX + slack;
152
+ this._moveLeftHandle(evt, xLimit);
153
+ };
154
+ this._moveLeftHandle = (evt, xLimit) => {
155
+ if (this._mouseXLimit) {
156
+ if (this._resizingDirection !== ResizingDirection.Left || this._mouseStartPointX === null || this._mouseStartPointY === null || evt.clientX > xLimit) {
157
+ return;
158
+ }
159
+ if (this._resizingDirection === ResizingDirection.Left) {
160
+ evt.stopPropagation();
161
+ const distanceMouseMoved = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
162
+ this._expandLeft(distanceMouseMoved);
163
+ this._mouseStartPointX = evt.clientX;
164
+ }
165
+ }
166
+ };
167
+ this._onLeftHandlePointerUp = (evt) => {
168
+ if (this._resizingDirection === ResizingDirection.Left) {
169
+ this.x = parseFloat(this.element.style.left.replace("px", ""));
170
+ this.width = parseFloat(this.element.style.width.replace("px", ""));
171
+ this._ownerCanvas.hostCanvas.removeEventListener("pointerup", this._onLeftHandlePointerUp);
172
+ this._ownerCanvas.hostCanvas.removeEventListener("pointermove", this._onLeftHandlePointerMove);
173
+ this._cleanUpResizing(evt);
174
+ }
175
+ };
176
+ this._onTopHandlePointerDown = (evt) => {
177
+ if (this.isCollapsed) {
178
+ return;
179
+ }
180
+ this._initResizing(evt);
181
+ this._resizingDirection = ResizingDirection.Top;
182
+ this._ownerCanvas.hostCanvas.addEventListener("pointerup", this._onTopHandlePointerUp);
183
+ this._ownerCanvas.hostCanvas.addEventListener("pointermove", this._onTopHandlePointerMove);
184
+ };
185
+ this._onTopHandlePointerMove = (evt) => {
186
+ const slack = (this.element.offsetHeight - this._minFrameHeight) * this._ownerCanvas.zoom;
187
+ const yLimit = this._mouseStartPointY + slack;
188
+ this._moveTopHandle(evt, yLimit);
189
+ };
190
+ this._moveTopHandle = (evt, yLimit) => {
191
+ if (!this._isResizingTop() || this._mouseStartPointX === null || this._mouseStartPointY === null || evt.clientY > yLimit) {
192
+ return;
193
+ }
194
+ if (this._isResizingTop()) {
195
+ evt.stopPropagation();
196
+ const distanceMouseMoved = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
197
+ this._expandTop(distanceMouseMoved);
198
+ this._mouseStartPointY = evt.clientY;
199
+ }
200
+ };
201
+ this._onTopHandlePointerUp = (evt) => {
202
+ if (this._isResizingTop()) {
203
+ this.y = parseFloat(this.element.style.top.replace("px", ""));
204
+ this.height = parseFloat(this.element.style.height.replace("px", ""));
205
+ this._ownerCanvas.hostCanvas.removeEventListener("pointerup", this._onTopHandlePointerUp);
206
+ this._ownerCanvas.hostCanvas.removeEventListener("pointermove", this._onTopHandlePointerMove);
207
+ this._cleanUpResizing(evt);
208
+ }
209
+ };
210
+ this._onTopRightHandlePointerDown = (evt) => {
211
+ if (this.isCollapsed) {
212
+ return;
213
+ }
214
+ this._initResizing(evt);
215
+ this._resizingDirection = ResizingDirection.TopRight;
216
+ this._ownerCanvas.hostCanvas.addEventListener("pointerup", this._onTopRightHandlePointerUp);
217
+ this._ownerCanvas.hostCanvas.addEventListener("pointermove", this._onTopRightHandlePointerMove);
218
+ };
219
+ this._onTopRightHandlePointerMove = (evt) => {
220
+ const topSlack = (this.element.offsetHeight - this._minFrameHeight) * this._ownerCanvas.zoom;
221
+ const yLimit = this._mouseStartPointY + topSlack;
222
+ const rightSlack = (this.element.offsetWidth - this._minFrameWidth) * this._ownerCanvas.zoom;
223
+ const xLimit = this._mouseStartPointX - rightSlack;
224
+ this._moveTopRightHandle(evt, xLimit, yLimit);
225
+ };
226
+ this._moveTopRightHandle = (evt, xLimit, yLimit) => {
227
+ if (!(this._isResizingTop() && this._isResizingRight()) || this._mouseStartPointX === null || this._mouseStartPointY === null) {
228
+ return;
229
+ }
230
+ if (this._isResizingRight() && this._isResizingTop()) {
231
+ evt.stopPropagation();
232
+ if (evt.clientY < yLimit && evt.clientX > xLimit) {
233
+ // able to move in X and Y
234
+ const distanceMouseMovedX = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
235
+ this._expandRight(distanceMouseMovedX, evt.clientX);
236
+ this._mouseStartPointX = evt.clientX;
237
+ const distanceMouseMovedY = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
238
+ this._expandTop(distanceMouseMovedY);
239
+ this._mouseStartPointY = evt.clientY;
240
+ }
241
+ else if (evt.clientY > yLimit && evt.clientX > xLimit) {
242
+ // able to move in X but not Y
243
+ const distanceMouseMovedX = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
244
+ this._expandRight(distanceMouseMovedX, evt.clientX);
245
+ this._mouseStartPointX = evt.clientX;
246
+ }
247
+ else if (evt.clientY < yLimit && evt.clientX < xLimit) {
248
+ // able to move in Y but not X
249
+ const distanceMouseMovedY = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
250
+ this._expandTop(distanceMouseMovedY);
251
+ this._mouseStartPointY = evt.clientY;
252
+ }
253
+ }
254
+ };
255
+ this._onTopRightHandlePointerUp = (evt) => {
256
+ evt.stopPropagation();
257
+ if (this._resizingDirection === ResizingDirection.TopRight) {
258
+ this.y = parseFloat(this.element.style.top.replace("px", ""));
259
+ this.height = parseFloat(this.element.style.height.replace("px", ""));
260
+ this.width = parseFloat(this.element.style.width.replace("px", ""));
261
+ this._ownerCanvas.hostCanvas.removeEventListener("pointerup", this._onTopRightHandlePointerUp);
262
+ this._ownerCanvas.hostCanvas.removeEventListener("pointermove", this._onTopRightHandlePointerMove);
263
+ this._cleanUpResizing(evt);
264
+ }
265
+ };
266
+ this._onBottomRightHandlePointerDown = (evt) => {
267
+ if (this.isCollapsed) {
268
+ return;
269
+ }
270
+ this._initResizing(evt);
271
+ this._resizingDirection = ResizingDirection.BottomRight;
272
+ this._ownerCanvas.hostCanvas.addEventListener("pointerup", this._onBottomRightHandlePointerUp);
273
+ this._ownerCanvas.hostCanvas.addEventListener("pointermove", this._onBottomRightHandlePointerMove);
274
+ };
275
+ this._onBottomRightHandlePointerMove = (evt) => {
276
+ const bottomSlack = (this.element.offsetHeight - this._minFrameHeight) * this._ownerCanvas.zoom;
277
+ const yLimit = this._mouseStartPointY - bottomSlack;
278
+ const rightSlack = (this.element.offsetWidth - this._minFrameWidth) * this._ownerCanvas.zoom;
279
+ const xLimit = this._mouseStartPointX - rightSlack;
280
+ this._moveBottomRightHandle(evt, xLimit, yLimit);
281
+ };
282
+ this._moveBottomRightHandle = (evt, xLimit, yLimit) => {
283
+ if (!(this._isResizingBottom() && this._isResizingRight()) || this._mouseStartPointX === null || this._mouseStartPointY === null) {
284
+ return;
285
+ }
286
+ if (this._isResizingRight() && this._isResizingBottom()) {
287
+ evt.stopPropagation();
288
+ if (evt.clientY > yLimit && evt.clientX > xLimit) {
289
+ // able to move in X and Y
290
+ const distanceMouseMovedX = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
291
+ this._expandRight(distanceMouseMovedX, evt.clientX);
292
+ this._mouseStartPointX = evt.clientX;
293
+ const distanceMouseMovedY = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
294
+ this._expandBottom(distanceMouseMovedY);
295
+ this._mouseStartPointY = evt.clientY;
296
+ }
297
+ else if (evt.clientY < yLimit && evt.clientX > xLimit) {
298
+ // able to move in X but not Y
299
+ const distanceMouseMovedX = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
300
+ this._expandRight(distanceMouseMovedX, evt.clientX);
301
+ this._mouseStartPointX = evt.clientX;
302
+ }
303
+ else if (evt.clientY > yLimit && evt.clientX < xLimit) {
304
+ // able to move in Y but not X
305
+ const distanceMouseMovedY = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
306
+ this._expandBottom(distanceMouseMovedY);
307
+ this._mouseStartPointY = evt.clientY;
308
+ }
309
+ }
310
+ };
311
+ this._onBottomRightHandlePointerUp = (evt) => {
312
+ if (this._resizingDirection === ResizingDirection.BottomRight) {
313
+ this.height = parseFloat(this.element.style.height.replace("px", ""));
314
+ this.width = parseFloat(this.element.style.width.replace("px", ""));
315
+ this._ownerCanvas.hostCanvas.removeEventListener("pointerup", this._onBottomRightHandlePointerUp);
316
+ this._ownerCanvas.hostCanvas.removeEventListener("pointermove", this._onBottomRightHandlePointerMove);
317
+ this._cleanUpResizing(evt);
318
+ }
319
+ };
320
+ //@ts-ignore
321
+ this._onBottomLeftHandlePointerDown = (evt) => {
322
+ if (this.isCollapsed) {
323
+ return;
324
+ }
325
+ this._initResizing(evt);
326
+ this._resizingDirection = ResizingDirection.BottomLeft;
327
+ this._mouseXLimit = evt.clientX + this.width - this._minFrameWidth;
328
+ this._ownerCanvas.hostCanvas.addEventListener("pointerup", this._onBottomLeftHandlePointerUp);
329
+ this._ownerCanvas.hostCanvas.addEventListener("pointermove", this._onBottomLeftHandlePointerMove);
330
+ };
331
+ this._onBottomLeftHandlePointerMove = (evt) => {
332
+ const bottomSlack = (this.element.offsetHeight - this._minFrameHeight) * this._ownerCanvas.zoom;
333
+ const yLimit = this._mouseStartPointY - bottomSlack;
334
+ const leftSlack = (this.element.offsetWidth - this._minFrameWidth) * this._ownerCanvas.zoom;
335
+ const xLimit = this._mouseStartPointX + leftSlack;
336
+ this._moveBottomLeftHandle(evt, xLimit, yLimit);
337
+ };
338
+ this._moveBottomLeftHandle = (evt, xLimit, yLimit) => {
339
+ if (!(this._isResizingBottom() && this._isResizingLeft()) || this._mouseStartPointX === null || this._mouseStartPointY === null) {
340
+ return;
341
+ }
342
+ if (this._isResizingLeft() && this._isResizingBottom()) {
343
+ evt.stopPropagation();
344
+ if (evt.clientY > yLimit && evt.clientX < xLimit) {
345
+ // able to move in X and Y
346
+ const distanceMouseMovedX = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
347
+ this._expandLeft(distanceMouseMovedX);
348
+ this._mouseStartPointX = evt.clientX;
349
+ const distanceMouseMovedY = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
350
+ this._expandBottom(distanceMouseMovedY);
351
+ this._mouseStartPointY = evt.clientY;
352
+ }
353
+ else if (evt.clientY < yLimit && evt.clientX < xLimit) {
354
+ // able to move in X but not Y
355
+ const distanceMouseMovedX = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
356
+ this._expandLeft(distanceMouseMovedX);
357
+ this._mouseStartPointX = evt.clientX;
358
+ }
359
+ else if (evt.clientY > yLimit && evt.clientX > xLimit) {
360
+ // able to move in Y but not X
361
+ const distanceMouseMovedY = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
362
+ this._expandBottom(distanceMouseMovedY);
363
+ this._mouseStartPointY = evt.clientY;
364
+ }
365
+ }
366
+ };
367
+ this._onBottomLeftHandlePointerUp = (evt) => {
368
+ evt.stopPropagation();
369
+ if (this._resizingDirection === ResizingDirection.BottomLeft) {
370
+ this.height = parseFloat(this.element.style.height.replace("px", ""));
371
+ this.x = parseFloat(this.element.style.left.replace("px", ""));
372
+ this.width = parseFloat(this.element.style.width.replace("px", ""));
373
+ this._ownerCanvas.hostCanvas.removeEventListener("pointerup", this._onBottomLeftHandlePointerUp);
374
+ this._ownerCanvas.hostCanvas.removeEventListener("pointermove", this._onBottomLeftHandlePointerMove);
375
+ this._cleanUpResizing(evt);
376
+ }
377
+ };
378
+ //@ts-ignore
379
+ this._onTopLeftHandlePointerDown = (evt) => {
380
+ if (this.isCollapsed) {
381
+ return;
382
+ }
383
+ this._initResizing(evt);
384
+ this._resizingDirection = ResizingDirection.TopLeft;
385
+ this._mouseXLimit = evt.clientX + this.width - this._minFrameWidth;
386
+ this._ownerCanvas.hostCanvas.addEventListener("pointerup", this._onTopLeftHandlePointerUp);
387
+ this._ownerCanvas.hostCanvas.addEventListener("pointermove", this._onTopLeftHandlePointerMove);
388
+ };
389
+ this._onTopLeftHandlePointerMove = (evt) => {
390
+ const topSlack = (this.element.offsetHeight - this._minFrameHeight) * this._ownerCanvas.zoom;
391
+ const yLimit = this._mouseStartPointY + topSlack;
392
+ const leftSlack = (this.element.offsetWidth - this._minFrameWidth) * this._ownerCanvas.zoom;
393
+ const xLimit = this._mouseStartPointX + leftSlack;
394
+ this._moveTopLeftHandle(evt, xLimit, yLimit);
395
+ };
396
+ this._moveTopLeftHandle = (evt, xLimit, yLimit) => {
397
+ if (!(this._isResizingTop() && this._isResizingLeft()) || this._mouseStartPointX === null || this._mouseStartPointY === null) {
398
+ return;
399
+ }
400
+ if (this._isResizingLeft() && this._isResizingTop()) {
401
+ evt.stopPropagation();
402
+ if (evt.clientY < yLimit && evt.clientX < xLimit) {
403
+ // able to move in X and Y
404
+ const distanceMouseMovedX = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
405
+ this._expandLeft(distanceMouseMovedX);
406
+ this._mouseStartPointX = evt.clientX;
407
+ const distanceMouseMovedY = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
408
+ this._expandTop(distanceMouseMovedY);
409
+ this._mouseStartPointY = evt.clientY;
410
+ }
411
+ else if (evt.clientY > yLimit && evt.clientX < xLimit) {
412
+ // able to move in X but not Y
413
+ const distanceMouseMovedX = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
414
+ this._expandLeft(distanceMouseMovedX);
415
+ this._mouseStartPointX = evt.clientX;
416
+ }
417
+ else if (evt.clientY < yLimit && evt.clientX > xLimit) {
418
+ // able to move in Y but not X
419
+ const distanceMouseMovedY = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
420
+ this._expandTop(distanceMouseMovedY);
421
+ this._mouseStartPointY = evt.clientY;
422
+ }
423
+ }
424
+ };
425
+ this._onTopLeftHandlePointerUp = (evt) => {
426
+ evt.stopPropagation();
427
+ if (this._resizingDirection === ResizingDirection.TopLeft) {
428
+ this.y = parseFloat(this.element.style.top.replace("px", ""));
429
+ this.height = parseFloat(this.element.style.height.replace("px", ""));
430
+ this.x = parseFloat(this.element.style.left.replace("px", ""));
431
+ this.width = parseFloat(this.element.style.width.replace("px", ""));
432
+ this._ownerCanvas.hostCanvas.removeEventListener("pointerup", this._onTopLeftHandlePointerUp);
433
+ this._ownerCanvas.hostCanvas.removeEventListener("pointermove", this._onTopLeftHandlePointerMove);
434
+ this._cleanUpResizing(evt);
435
+ }
436
+ };
437
+ this._id = GraphFrame._FrameCounter++;
438
+ this._ownerCanvas = canvas;
439
+ const root = canvas.frameContainer;
440
+ this.element = root.ownerDocument.createElement("div");
441
+ this.element.classList.add(commonStyles["frame-box"]);
442
+ root.appendChild(this.element);
443
+ this._headerElement = root.ownerDocument.createElement("div");
444
+ this._headerElement.classList.add(styles["frame-box-header"]);
445
+ this._headerElement.addEventListener("dblclick", () => {
446
+ this.isCollapsed = !this.isCollapsed;
447
+ });
448
+ this.element.appendChild(this._headerElement);
449
+ this._borderElement = root.ownerDocument.createElement("div");
450
+ this._borderElement.classList.add(styles["frame-box-border"]);
451
+ this.element.appendChild(this._borderElement);
452
+ this.element.classList.add(styles.expanded);
453
+ // add resizing side handles
454
+ const rightHandle = root.ownerDocument.createElement("div");
455
+ rightHandle.className = styles["right-handle"];
456
+ this.element.appendChild(rightHandle);
457
+ rightHandle.addEventListener("pointerdown", this._onRightHandlePointerDown);
458
+ const leftHandle = root.ownerDocument.createElement("div");
459
+ leftHandle.className = styles["left-handle"];
460
+ this.element.appendChild(leftHandle);
461
+ leftHandle.addEventListener("pointerdown", this._onLeftHandlePointerDown);
462
+ const bottomHandle = root.ownerDocument.createElement("div");
463
+ bottomHandle.className = styles["bottom-handle"];
464
+ this.element.appendChild(bottomHandle);
465
+ bottomHandle.addEventListener("pointerdown", this._onBottomHandlePointerDown);
466
+ const topHandle = root.ownerDocument.createElement("div");
467
+ topHandle.className = styles["top-handle"];
468
+ this.element.appendChild(topHandle);
469
+ topHandle.addEventListener("pointerdown", this._onTopHandlePointerDown);
470
+ const topRightCornerHandle = root.ownerDocument.createElement("div");
471
+ topRightCornerHandle.className = ClassNames({ "right-handle": true, "top-right-corner-handle": true }, styles);
472
+ this.element.appendChild(topRightCornerHandle);
473
+ topRightCornerHandle.addEventListener("pointerdown", this._onTopRightHandlePointerDown);
474
+ const bottomRightCornerHandle = root.ownerDocument.createElement("div");
475
+ bottomRightCornerHandle.className = ClassNames({ "right-handle": true, "bottom-right-corner-handle": true }, styles);
476
+ this.element.appendChild(bottomRightCornerHandle);
477
+ bottomRightCornerHandle.addEventListener("pointerdown", this._onBottomRightHandlePointerDown);
478
+ const topLeftCornerHandle = root.ownerDocument.createElement("div");
479
+ topLeftCornerHandle.className = ClassNames({ "left-handle": true, "top-left-corner-handle": true }, styles);
480
+ this.element.appendChild(topLeftCornerHandle);
481
+ topLeftCornerHandle.addEventListener("pointerdown", this._onTopLeftHandlePointerDown);
482
+ const bottomLeftCornerHandle = root.ownerDocument.createElement("div");
483
+ bottomLeftCornerHandle.className = ClassNames({ "left-handle": true, "bottom-left-corner-handle": true }, styles);
484
+ this.element.appendChild(bottomLeftCornerHandle);
485
+ bottomLeftCornerHandle.addEventListener("pointerdown", this._onBottomLeftHandlePointerDown);
486
+ // add header elements
487
+ this._headerTextElement = root.ownerDocument.createElement("div");
488
+ this._headerTextElement.classList.add(styles["frame-box-header-title"]);
489
+ this._headerElement.appendChild(this._headerTextElement);
490
+ this._headerCollapseElement = root.ownerDocument.createElement("div");
491
+ this._headerCollapseElement.classList.add(styles["frame-box-header-collapse"]);
492
+ this._headerCollapseElement.classList.add(styles["frame-box-header-button"]);
493
+ this._headerCollapseElement.title = "Collapse";
494
+ this._headerCollapseElement.ondragstart = () => false;
495
+ this._headerCollapseElement.addEventListener("pointerdown", (evt) => {
496
+ this._headerCollapseElement.classList.add("down");
497
+ evt.stopPropagation();
498
+ });
499
+ this._headerCollapseElement.addEventListener("pointerup", (evt) => {
500
+ evt.stopPropagation();
501
+ this._headerCollapseElement.classList.remove("down");
502
+ this.isCollapsed = !this.isCollapsed;
503
+ });
504
+ this._headerCollapseElement.innerHTML = this._collapseSVG;
505
+ this._headerElement.appendChild(this._headerCollapseElement);
506
+ this._headerCloseElement = root.ownerDocument.createElement("div");
507
+ this._headerCloseElement.classList.add(styles["frame-box-header-close"]);
508
+ this._headerCloseElement.classList.add(styles["frame-box-header-button"]);
509
+ this._headerCloseElement.title = "Close";
510
+ this._headerCloseElement.ondragstart = () => false;
511
+ this._headerCloseElement.addEventListener("pointerdown", (evt) => {
512
+ evt.stopPropagation();
513
+ });
514
+ this._headerCloseElement.addEventListener("pointerup", (evt) => {
515
+ evt.stopPropagation();
516
+ this.dispose();
517
+ });
518
+ this._headerCloseElement.innerHTML = this._closeSVG;
519
+ this._headerElement.appendChild(this._headerCloseElement);
520
+ this._portContainer = root.ownerDocument.createElement("div");
521
+ this._portContainer.classList.add(styles["port-container"]);
522
+ this.element.appendChild(this._portContainer);
523
+ this._outputPortContainer = root.ownerDocument.createElement("div");
524
+ this._outputPortContainer.classList.add(commonStyles["outputsContainer"]);
525
+ this._portContainer.appendChild(this._outputPortContainer);
526
+ this._inputPortContainer = root.ownerDocument.createElement("div");
527
+ this._inputPortContainer.classList.add(commonStyles["inputsContainer"]);
528
+ this._portContainer.appendChild(this._inputPortContainer);
529
+ this.name = "Frame";
530
+ this.color = Color3.FromInts(72, 72, 72);
531
+ if (candidate) {
532
+ this.x = parseFloat(candidate.style.left.replace("px", ""));
533
+ this.y = parseFloat(candidate.style.top.replace("px", ""));
534
+ this.width = parseFloat(candidate.style.width.replace("px", ""));
535
+ this.height = parseFloat(candidate.style.height.replace("px", ""));
536
+ this.cleanAccumulation();
537
+ }
538
+ this._headerTextElement.addEventListener("pointerdown", (evt) => this._onDown(evt));
539
+ this._headerTextElement.addEventListener("pointerup", (evt) => this._onUp(evt));
540
+ this._headerTextElement.addEventListener("pointermove", (evt) => this._onMove(evt));
541
+ this._onSelectionChangedObserver = canvas.stateManager.onSelectionChangedObservable.add(() => {
542
+ if (this._ownerCanvas.selectedFrames.indexOf(this) !== -1) {
543
+ this._borderElement.classList.add(styles["selected"]);
544
+ }
545
+ else {
546
+ this._borderElement.classList.remove(styles["selected"]);
547
+ }
548
+ });
549
+ canvas.stateManager.onSelectionBoxMoved.add((rect1) => {
550
+ const rect2 = this.element.getBoundingClientRect();
551
+ const overlap = !(rect1.right < rect2.left || rect1.left > rect2.right || rect1.bottom < rect2.top || rect1.top > rect2.bottom);
552
+ if (overlap) {
553
+ canvas.stateManager.onSelectionChangedObservable.notifyObservers({ selection: this, forceKeepSelection: true, marqueeSelection: true });
554
+ }
555
+ });
556
+ this._onGraphNodeRemovalObserver = canvas.stateManager.onGraphNodeRemovalObservable.add((node) => {
557
+ // remove node from this._nodes
558
+ const index = this._nodes.indexOf(node);
559
+ if (index === -1) {
560
+ return;
561
+ }
562
+ else {
563
+ node.enclosingFrameId = -1;
564
+ this._nodes.splice(index, 1);
565
+ }
566
+ });
567
+ this._onExposePortOnFrameObserver = canvas.stateManager.onExposePortOnFrameObservable.add((node) => {
568
+ if (this.nodes.indexOf(node) === -1) {
569
+ return;
570
+ }
571
+ this.redrawFramePorts();
572
+ });
573
+ this._commentsElement = document.createElement("div");
574
+ this._commentsElement.className = styles["frame-comments"];
575
+ this._commentsElement.style.color = "white";
576
+ this._commentsElement.style.fontSize = "16px";
577
+ const commentSpan = document.createElement("span");
578
+ commentSpan.className = styles["frame-comment-span"];
579
+ this._commentsElement.appendChild(commentSpan);
580
+ this.element.appendChild(this._commentsElement);
581
+ // Get nodes
582
+ if (!doNotCaptureNodes) {
583
+ this.refresh();
584
+ }
585
+ }
586
+ get id() {
587
+ return this._id;
588
+ }
589
+ get isCollapsed() {
590
+ return this._isCollapsed;
591
+ }
592
+ _createInputPort(port, node) {
593
+ const localPort = FrameNodePort.CreateFrameNodePortElement(port.portData, node, this._inputPortContainer, null, this._ownerCanvas.stateManager, true, GraphFrame._FramePortCounter++, this.id);
594
+ this._frameInPorts.push(localPort);
595
+ port.delegatedPort = localPort;
596
+ this._controlledPorts.push(port);
597
+ port.exposedPortPosition = this._exposedInPorts.findIndex((nodePort) => nodePort === port);
598
+ if (port.exposedPortPosition < 0) {
599
+ this._exposedInPorts.push(port);
600
+ port.exposedPortPosition = this._exposedInPorts.length - 1;
601
+ }
602
+ }
603
+ // Mark ports with FramePortPosition for re-arrangement support
604
+ _markFramePortPositions() {
605
+ // mark FrameInPorts
606
+ if (this._frameInPorts.length == 2) {
607
+ this._frameInPorts[0].framePortPosition = FramePortPosition.Top;
608
+ this._frameInPorts[1].framePortPosition = FramePortPosition.Bottom;
609
+ }
610
+ else {
611
+ for (let i = 0; i < this._frameInPorts.length; i++) {
612
+ const port = this._frameInPorts[i];
613
+ if (i === 0) {
614
+ port.framePortPosition = FramePortPosition.Top;
615
+ }
616
+ else if (i === this._frameInPorts.length - 1) {
617
+ port.framePortPosition = FramePortPosition.Bottom;
618
+ }
619
+ else {
620
+ port.framePortPosition = FramePortPosition.Middle;
621
+ }
622
+ }
623
+ }
624
+ // mark FrameOutPorts
625
+ if (this._frameOutPorts.length == 2) {
626
+ this._frameOutPorts[0].framePortPosition = FramePortPosition.Top;
627
+ this._frameOutPorts[1].framePortPosition = FramePortPosition.Bottom;
628
+ }
629
+ else {
630
+ for (let i = 0; i < this._frameOutPorts.length; i++) {
631
+ const port = this._frameOutPorts[i];
632
+ if (i === 0) {
633
+ port.framePortPosition = FramePortPosition.Top;
634
+ }
635
+ else if (i === this._frameInPorts.length - 1) {
636
+ port.framePortPosition = FramePortPosition.Bottom;
637
+ }
638
+ else {
639
+ port.framePortPosition = FramePortPosition.Middle;
640
+ }
641
+ }
642
+ }
643
+ }
644
+ _createFramePorts() {
645
+ for (const node of this._nodes) {
646
+ node.isVisible = false;
647
+ }
648
+ for (let i = 0; i < this._exposedOutPorts.length;) {
649
+ // Output
650
+ const port = this._exposedOutPorts[i];
651
+ if (port) {
652
+ if (port.node === null || port.node.enclosingFrameId != this.id) {
653
+ if (this._removePortFromExposedWithNode(port, this._exposedOutPorts))
654
+ continue;
655
+ }
656
+ else {
657
+ if (!this._createOutputPorts(port, port.node) && this._removePortFromExposedWithNode(port, this._exposedOutPorts)) {
658
+ continue;
659
+ }
660
+ }
661
+ }
662
+ ++i;
663
+ }
664
+ for (let i = 0; i < this._exposedInPorts.length;) {
665
+ // Input
666
+ const port = this._exposedInPorts[i];
667
+ if (!port || port.node === null || port.node.enclosingFrameId != this.id) {
668
+ if (this._removePortFromExposedWithNode(port, this._exposedInPorts)) {
669
+ continue;
670
+ }
671
+ }
672
+ else {
673
+ if (!this._createInputPorts(port, port.node) && this._removePortFromExposedWithNode(port, this._exposedInPorts)) {
674
+ continue;
675
+ }
676
+ }
677
+ ++i;
678
+ }
679
+ for (const node of this._nodes) {
680
+ for (const port of node.outputPorts) {
681
+ // Output
682
+ port.exposedPortPosition = this._exposedOutPorts.findIndex((nodePort) => nodePort === port);
683
+ if (port.exposedPortPosition < 0) {
684
+ if (this._createOutputPorts(port, node)) {
685
+ port.node.enclosingFrameId = this.id;
686
+ this._exposedOutPorts.push(port);
687
+ port.exposedPortPosition = this._exposedOutPorts.length - 1;
688
+ }
689
+ }
690
+ }
691
+ for (const port of node.inputPorts) {
692
+ // Input
693
+ port.exposedPortPosition = this._exposedInPorts.findIndex((nodePort) => nodePort === port);
694
+ if (port.exposedPortPosition < 0) {
695
+ this._createInputPorts(port, node);
696
+ }
697
+ }
698
+ }
699
+ }
700
+ _removePortFromExposedWithNode(port, exposedPorts) {
701
+ const index = exposedPorts.findIndex((nodePort) => nodePort === port);
702
+ if (index >= 0) {
703
+ exposedPorts.splice(index, 1);
704
+ if (port) {
705
+ port.exposedPortPosition = -1;
706
+ }
707
+ return true;
708
+ }
709
+ return false;
710
+ }
711
+ _removePortFromExposedWithLink(nodeLink, exposedPorts) {
712
+ const aPort = exposedPorts.findIndex((nodePort) => nodePort === nodeLink.portA);
713
+ const bPort = exposedPorts.findIndex((nodePort) => nodePort === nodeLink.portB);
714
+ if (aPort >= 0) {
715
+ if (!nodeLink.portA.exposedOnFrame) {
716
+ exposedPorts.splice(aPort, 1);
717
+ nodeLink.portA.exposedPortPosition = -1;
718
+ return true;
719
+ }
720
+ }
721
+ else if (bPort >= 0) {
722
+ if (nodeLink.portB && !nodeLink.portB.exposedOnFrame) {
723
+ exposedPorts.splice(bPort, 1);
724
+ nodeLink.portB.exposedPortPosition = -1;
725
+ return true;
726
+ }
727
+ }
728
+ return false;
729
+ }
730
+ _createInputPorts(port, node) {
731
+ if (port.portData.isConnected) {
732
+ let portAdded = false;
733
+ for (const link of node.links) {
734
+ if (link.portB === port && this.nodes.indexOf(link.nodeA) === -1) {
735
+ this._createInputPort(port, node);
736
+ link.isVisible = true;
737
+ portAdded = true;
738
+ const onLinkDisposedObserver = link.onDisposedObservable.add((nodeLink) => {
739
+ if (this._removePortFromExposedWithLink(nodeLink, this._exposedInPorts)) {
740
+ this.redrawFramePorts();
741
+ }
742
+ });
743
+ this._onNodeLinkDisposedObservers.push(onLinkDisposedObserver);
744
+ }
745
+ }
746
+ if (portAdded)
747
+ return true;
748
+ }
749
+ else if (port.exposedOnFrame) {
750
+ this._createInputPort(port, node);
751
+ return true;
752
+ }
753
+ return false;
754
+ }
755
+ _createOutputPorts(port, node) {
756
+ if (port.portData.hasEndpoints) {
757
+ let portAdded = false;
758
+ for (const link of node.links) {
759
+ if (link.portA === port && this.nodes.indexOf(link.nodeB) === -1) {
760
+ let localPort;
761
+ if (!portAdded) {
762
+ portAdded = true;
763
+ localPort = FrameNodePort.CreateFrameNodePortElement(port.portData, link.nodeA, this._outputPortContainer, null, this._ownerCanvas.stateManager, false, GraphFrame._FramePortCounter++, this.id);
764
+ this._frameOutPorts.push(localPort);
765
+ link.isVisible = true;
766
+ const onLinkDisposedObserver = link.onDisposedObservable.add((nodeLink) => {
767
+ if (this._removePortFromExposedWithLink(nodeLink, this._exposedOutPorts)) {
768
+ this.redrawFramePorts();
769
+ }
770
+ });
771
+ this._onNodeLinkDisposedObservers.push(onLinkDisposedObserver);
772
+ }
773
+ else if (this.nodes.indexOf(link.nodeB) === -1) {
774
+ link.isVisible = true;
775
+ localPort = this.ports.filter((p) => p.portData === port.portData)[0];
776
+ }
777
+ else {
778
+ localPort = this.ports.filter((p) => p.portData === port.portData)[0];
779
+ }
780
+ port.delegatedPort = localPort;
781
+ this._controlledPorts.push(port);
782
+ }
783
+ else if (port.exposedPortPosition >= 0 && !portAdded) {
784
+ const localPort = FrameNodePort.CreateFrameNodePortElement(port.portData, node, this._outputPortContainer, null, this._ownerCanvas.stateManager, false, GraphFrame._FramePortCounter++, this.id);
785
+ this._frameOutPorts.push(localPort);
786
+ port.delegatedPort = localPort;
787
+ this._controlledPorts.push(port);
788
+ portAdded = true;
789
+ }
790
+ }
791
+ if (portAdded)
792
+ return true;
793
+ }
794
+ else if (port.exposedOnFrame) {
795
+ const localPort = FrameNodePort.CreateFrameNodePortElement(port.portData, node, this._outputPortContainer, null, this._ownerCanvas.stateManager, false, GraphFrame._FramePortCounter++, this.id);
796
+ this._frameOutPorts.push(localPort);
797
+ port.delegatedPort = localPort;
798
+ this._controlledPorts.push(port);
799
+ return true;
800
+ }
801
+ return false;
802
+ }
803
+ redrawFramePorts() {
804
+ if (!this.isCollapsed) {
805
+ return;
806
+ }
807
+ this._outputPortContainer.innerHTML = "";
808
+ this._inputPortContainer.innerHTML = "";
809
+ this.ports.forEach((framePort) => {
810
+ framePort.dispose();
811
+ });
812
+ this._controlledPorts.forEach((port) => {
813
+ port.delegatedPort = null;
814
+ port.refresh();
815
+ });
816
+ this._frameInPorts = [];
817
+ this._frameOutPorts = [];
818
+ this._controlledPorts = [];
819
+ this._createFramePorts();
820
+ this._markFramePortPositions();
821
+ this.ports.forEach((framePort) => framePort.node._refreshLinks());
822
+ }
823
+ set isCollapsed(value) {
824
+ if (this._isCollapsed === value) {
825
+ return;
826
+ }
827
+ this._isCollapsed = value;
828
+ this._ownerCanvas._frameIsMoving = true;
829
+ // Need to delegate the outside ports to the frame
830
+ if (value) {
831
+ this.element.classList.add(styles.collapsed);
832
+ this.element.classList.remove(styles.expanded);
833
+ this._headerElement.classList.add(styles.collapsedHeader);
834
+ this._moveFrame((this.width - this._collapsedWidth) / 2, 0);
835
+ this._createFramePorts();
836
+ this._markFramePortPositions();
837
+ }
838
+ else {
839
+ this.element.classList.add(styles.expanded);
840
+ this.element.classList.remove(styles.collapsed);
841
+ this._headerElement.classList.remove(styles.collapsedHeader);
842
+ this._outputPortContainer.innerHTML = "";
843
+ this._inputPortContainer.innerHTML = "";
844
+ this._frameInPorts.forEach((p) => {
845
+ p.dispose();
846
+ });
847
+ this._frameOutPorts.forEach((p) => {
848
+ p.dispose();
849
+ });
850
+ this._controlledPorts.forEach((port) => {
851
+ port.delegatedPort = null;
852
+ port.refresh();
853
+ });
854
+ this._frameInPorts = [];
855
+ this._frameOutPorts = [];
856
+ this._controlledPorts = [];
857
+ this._onNodeLinkDisposedObservers = [];
858
+ for (const node of this._nodes) {
859
+ node.isVisible = true;
860
+ }
861
+ this._moveFrame(-(this.width - this._collapsedWidth) / 2, 0);
862
+ }
863
+ this.cleanAccumulation();
864
+ this._ownerCanvas._frameIsMoving = false;
865
+ // UI
866
+ if (this._isCollapsed) {
867
+ this._headerCollapseElement.innerHTML = this._expandSVG;
868
+ this._headerCollapseElement.title = "Expand";
869
+ }
870
+ else {
871
+ this._headerCollapseElement.innerHTML = this._collapseSVG;
872
+ this._headerCollapseElement.title = "Collapse";
873
+ }
874
+ this.onExpandStateChanged.notifyObservers(this);
875
+ }
876
+ get nodes() {
877
+ return this._nodes;
878
+ }
879
+ get ports() {
880
+ return this._frameInPorts.concat(this._frameOutPorts);
881
+ }
882
+ get name() {
883
+ return this._name;
884
+ }
885
+ set name(value) {
886
+ this._name = value;
887
+ this._headerTextElement.innerHTML = value;
888
+ }
889
+ get color() {
890
+ return this._color;
891
+ }
892
+ set color(value) {
893
+ this._color = value;
894
+ this._headerElement.style.background = `rgba(${value.r * 255}, ${value.g * 255}, ${value.b * 255}, 1)`;
895
+ this._headerElement.style.borderColor = `rgba(${value.r * 255}, ${value.g * 255}, ${value.b * 255}, 1)`;
896
+ this.element.style.background = `rgba(${value.r * 255}, ${value.g * 255}, ${value.b * 255}, 0.7)`;
897
+ }
898
+ get x() {
899
+ return this._x;
900
+ }
901
+ set x(value) {
902
+ if (this._x === value) {
903
+ return;
904
+ }
905
+ this._x = value;
906
+ this._gridAlignedX = this._ownerCanvas.getGridPosition(value);
907
+ this.element.style.left = `${this._gridAlignedX}px`;
908
+ }
909
+ get y() {
910
+ return this._y;
911
+ }
912
+ set y(value) {
913
+ if (this._y === value) {
914
+ return;
915
+ }
916
+ this._y = value;
917
+ this._gridAlignedY = this._ownerCanvas.getGridPosition(value);
918
+ this.element.style.top = `${this._gridAlignedY}px`;
919
+ }
920
+ get width() {
921
+ return this._width;
922
+ }
923
+ set width(value) {
924
+ if (this._width === value) {
925
+ return;
926
+ }
927
+ const viableWidth = value > this._minFrameWidth ? value : this._minFrameWidth;
928
+ this._width = viableWidth;
929
+ const gridAlignedRight = this._ownerCanvas.getGridPositionCeil(viableWidth + this._gridAlignedX);
930
+ this.element.style.width = `${gridAlignedRight - this._gridAlignedX}px`;
931
+ }
932
+ get height() {
933
+ return this._height;
934
+ }
935
+ set height(value) {
936
+ if (this._height === value) {
937
+ return;
938
+ }
939
+ this._height = value;
940
+ const gridAlignedBottom = this._ownerCanvas.getGridPositionCeil(value + this._gridAlignedY);
941
+ this.element.style.height = `${gridAlignedBottom - this._gridAlignedY}px`;
942
+ }
943
+ get comments() {
944
+ return this._comments;
945
+ }
946
+ set comments(comments) {
947
+ if (comments && !this._comments && comments.length > 0) {
948
+ this.element.style.gridTemplateRows = "40px min-content 1fr";
949
+ this._borderElement.style.gridRow = "1 / span 3";
950
+ this._portContainer.style.gridRow = "3";
951
+ this._commentsElement.classList.add("has-comments");
952
+ }
953
+ else if (!comments) {
954
+ this.element.style.gridTemplateRows = "40px calc(100% - 40px)";
955
+ this._borderElement.style.gridRow = "1 / span 2";
956
+ this._portContainer.style.gridRow = "2";
957
+ this._commentsElement.classList.remove("has-comments");
958
+ }
959
+ if (comments === "" || (comments && comments.length >= 0)) {
960
+ this._commentsElement.children[0].innerText = comments;
961
+ }
962
+ this.height = this._borderElement.offsetHeight;
963
+ this._comments = comments;
964
+ this._updateMinHeightWithComments();
965
+ }
966
+ refresh() {
967
+ this._nodes = [];
968
+ this._ownerCanvas.stateManager.onFrameCreatedObservable.notifyObservers(this);
969
+ }
970
+ addNode(node) {
971
+ const index = this.nodes.indexOf(node);
972
+ if (index === -1) {
973
+ this.nodes.push(node);
974
+ }
975
+ }
976
+ removeNode(node) {
977
+ const index = this.nodes.indexOf(node);
978
+ if (index > -1) {
979
+ node.enclosingFrameId = -1;
980
+ this.nodes.splice(index, 1);
981
+ }
982
+ }
983
+ syncNode(node) {
984
+ if (this.isCollapsed) {
985
+ return;
986
+ }
987
+ if (node.isOverlappingFrame(this)) {
988
+ this.addNode(node);
989
+ }
990
+ else {
991
+ this.removeNode(node);
992
+ }
993
+ }
994
+ cleanAccumulation() {
995
+ for (const selectedNode of this._nodes) {
996
+ selectedNode.cleanAccumulation();
997
+ }
998
+ this.x = this._ownerCanvas.getGridPosition(this.x);
999
+ this.y = this._ownerCanvas.getGridPosition(this.y);
1000
+ }
1001
+ _onDown(evt) {
1002
+ this._headerTextElement.setPointerCapture(evt.pointerId);
1003
+ const indexInSelection = this._ownerCanvas.selectedFrames.indexOf(this);
1004
+ if (indexInSelection === -1) {
1005
+ this._ownerCanvas.stateManager.onSelectionChangedObservable.notifyObservers({ selection: this });
1006
+ }
1007
+ else if (evt.ctrlKey) {
1008
+ this._ownerCanvas.selectedFrames.splice(indexInSelection, 1);
1009
+ this.element.classList.remove("selected");
1010
+ }
1011
+ this._ownerCanvas._frameIsMoving = true;
1012
+ this._mouseStartPointX = evt.clientX;
1013
+ this._mouseStartPointY = evt.clientY;
1014
+ evt.stopPropagation();
1015
+ }
1016
+ move(newX, newY, align = true) {
1017
+ const oldX = this.x;
1018
+ const oldY = this.y;
1019
+ this.x = newX;
1020
+ this.y = newY;
1021
+ for (const selectedNode of this._nodes) {
1022
+ selectedNode.x += this.x - oldX;
1023
+ selectedNode.y += this.y - oldY;
1024
+ if (align) {
1025
+ selectedNode.cleanAccumulation(true);
1026
+ }
1027
+ }
1028
+ }
1029
+ _onUp(evt) {
1030
+ evt.stopPropagation();
1031
+ this.cleanAccumulation();
1032
+ this._mouseStartPointX = null;
1033
+ this._mouseStartPointY = null;
1034
+ this._headerTextElement.releasePointerCapture(evt.pointerId);
1035
+ this._ownerCanvas._frameIsMoving = false;
1036
+ }
1037
+ _moveFrame(offsetX, offsetY) {
1038
+ this.x += offsetX;
1039
+ this.y += offsetY;
1040
+ for (const selectedNode of this._nodes) {
1041
+ selectedNode.x += offsetX;
1042
+ selectedNode.y += offsetY;
1043
+ }
1044
+ }
1045
+ _onMove(evt) {
1046
+ if (this._mouseStartPointX === null || this._mouseStartPointY === null || evt.ctrlKey || this._frameIsResizing) {
1047
+ return;
1048
+ }
1049
+ const newX = (evt.clientX - this._mouseStartPointX) / this._ownerCanvas.zoom;
1050
+ const newY = (evt.clientY - this._mouseStartPointY) / this._ownerCanvas.zoom;
1051
+ for (const frame of this._ownerCanvas.selectedFrames) {
1052
+ frame._moveFrame(newX, newY);
1053
+ }
1054
+ for (const node of this._ownerCanvas.selectedNodes) {
1055
+ node.x += newX;
1056
+ node.y += newY;
1057
+ }
1058
+ this._mouseStartPointX = evt.clientX;
1059
+ this._mouseStartPointY = evt.clientY;
1060
+ evt.stopPropagation();
1061
+ }
1062
+ moveFramePortUp(nodePort) {
1063
+ let elementsArray;
1064
+ if (nodePort.isInput) {
1065
+ if (this._inputPortContainer.children.length < 2) {
1066
+ return;
1067
+ }
1068
+ elementsArray = Array.from(this._inputPortContainer.childNodes);
1069
+ const indexInContainer = this._frameInPorts.findIndex((framePort) => framePort === nodePort);
1070
+ [this._exposedInPorts[indexInContainer - 1], this._exposedInPorts[indexInContainer]] = [
1071
+ this._exposedInPorts[indexInContainer],
1072
+ this._exposedInPorts[indexInContainer - 1],
1073
+ ]; // swap idicies
1074
+ this._movePortUp(elementsArray, nodePort, this._frameInPorts);
1075
+ }
1076
+ else {
1077
+ if (this._outputPortContainer.children.length < 2) {
1078
+ return;
1079
+ }
1080
+ elementsArray = Array.from(this._outputPortContainer.childNodes);
1081
+ const indexInContainer = this._frameOutPorts.findIndex((framePort) => framePort === nodePort);
1082
+ [this._exposedOutPorts[indexInContainer - 1], this._exposedOutPorts[indexInContainer]] = [
1083
+ this._exposedOutPorts[indexInContainer],
1084
+ this._exposedOutPorts[indexInContainer - 1],
1085
+ ]; // swap idicies
1086
+ this._movePortUp(elementsArray, nodePort, this._frameOutPorts);
1087
+ }
1088
+ this.ports.forEach((framePort) => framePort.node._refreshLinks());
1089
+ }
1090
+ _movePortUp(elementsArray, nodePort, framePortList) {
1091
+ var _a;
1092
+ // update UI
1093
+ const indexInElementArray = elementsArray.findIndex((elem) => elem.dataset.framePortId === `${nodePort.framePortId}`);
1094
+ if (indexInElementArray === 0) {
1095
+ return;
1096
+ }
1097
+ const secondPortElement = elementsArray[indexInElementArray];
1098
+ const firstPortElement = elementsArray[indexInElementArray - 1];
1099
+ (_a = firstPortElement.parentElement) === null || _a === void 0 ? void 0 : _a.insertBefore(secondPortElement, firstPortElement);
1100
+ // update Frame Port Container
1101
+ const indexInContainer = framePortList.findIndex((framePort) => framePort === nodePort);
1102
+ [framePortList[indexInContainer - 1], framePortList[indexInContainer]] = [framePortList[indexInContainer], framePortList[indexInContainer - 1]]; // swap idicies
1103
+ //special case framePortList.length == 2
1104
+ if (framePortList.length == 2) {
1105
+ framePortList[1].framePortPosition = FramePortPosition.Bottom;
1106
+ framePortList[0].framePortPosition = FramePortPosition.Top;
1107
+ }
1108
+ else {
1109
+ // notify nodePort if it is now at Top (indexInElementArray === 1)
1110
+ if (indexInElementArray === 1) {
1111
+ framePortList[1].framePortPosition = FramePortPosition.Middle;
1112
+ framePortList[0].framePortPosition = FramePortPosition.Top;
1113
+ }
1114
+ else if (indexInContainer === elementsArray.length - 1) {
1115
+ framePortList[framePortList.length - 1].framePortPosition = FramePortPosition.Bottom;
1116
+ framePortList[framePortList.length - 2].framePortPosition = FramePortPosition.Middle;
1117
+ }
1118
+ else {
1119
+ nodePort.framePortPosition = FramePortPosition.Middle;
1120
+ }
1121
+ }
1122
+ }
1123
+ moveFramePortDown(nodePort) {
1124
+ let elementsArray;
1125
+ if (nodePort.isInput) {
1126
+ if (this._inputPortContainer.children.length < 2) {
1127
+ return;
1128
+ }
1129
+ elementsArray = Array.from(this._inputPortContainer.childNodes);
1130
+ const indexInContainer = this._frameInPorts.findIndex((framePort) => framePort === nodePort);
1131
+ [this._exposedInPorts[indexInContainer], this._exposedInPorts[indexInContainer + 1]] = [
1132
+ this._exposedInPorts[indexInContainer + 1],
1133
+ this._exposedInPorts[indexInContainer],
1134
+ ]; // swap idicies
1135
+ this._movePortDown(elementsArray, nodePort, this._frameInPorts);
1136
+ }
1137
+ else {
1138
+ if (this._outputPortContainer.children.length < 2) {
1139
+ return;
1140
+ }
1141
+ elementsArray = Array.from(this._outputPortContainer.childNodes);
1142
+ const indexInContainer = this._frameOutPorts.findIndex((framePort) => framePort === nodePort);
1143
+ [this._exposedOutPorts[indexInContainer], this._exposedOutPorts[indexInContainer + 1]] = [
1144
+ this._exposedOutPorts[indexInContainer + 1],
1145
+ this._exposedOutPorts[indexInContainer],
1146
+ ]; // swap idicies
1147
+ this._movePortDown(elementsArray, nodePort, this._frameOutPorts);
1148
+ }
1149
+ this.ports.forEach((framePort) => framePort.node._refreshLinks());
1150
+ }
1151
+ _movePortDown(elementsArray, nodePort, framePortList) {
1152
+ var _a;
1153
+ // update UI
1154
+ const indexInElementArray = elementsArray.findIndex((elem) => elem.dataset.framePortId === `${nodePort.framePortId}`);
1155
+ if (indexInElementArray === elementsArray.length - 1) {
1156
+ return;
1157
+ }
1158
+ const firstPort = elementsArray[indexInElementArray];
1159
+ const secondPort = elementsArray[indexInElementArray + 1];
1160
+ (_a = firstPort.parentElement) === null || _a === void 0 ? void 0 : _a.insertBefore(secondPort, firstPort);
1161
+ // update Frame Port Container
1162
+ const indexInContainer = framePortList.findIndex((framePort) => framePort === nodePort);
1163
+ [framePortList[indexInContainer], framePortList[indexInContainer + 1]] = [framePortList[indexInContainer + 1], framePortList[indexInContainer]]; // swap idicies
1164
+ // notify nodePort if it is now at bottom (indexInContainer === elementsArray.length-2)
1165
+ if (framePortList.length == 2) {
1166
+ framePortList[0].framePortPosition = FramePortPosition.Top;
1167
+ framePortList[1].framePortPosition = FramePortPosition.Bottom;
1168
+ }
1169
+ else {
1170
+ if (indexInContainer === elementsArray.length - 2) {
1171
+ framePortList[elementsArray.length - 2].framePortPosition = FramePortPosition.Middle;
1172
+ framePortList[elementsArray.length - 1].framePortPosition = FramePortPosition.Bottom;
1173
+ }
1174
+ else if (indexInContainer === 0) {
1175
+ framePortList[0].framePortPosition = FramePortPosition.Top;
1176
+ framePortList[1].framePortPosition = FramePortPosition.Middle;
1177
+ }
1178
+ else {
1179
+ nodePort.framePortPosition = FramePortPosition.Middle;
1180
+ }
1181
+ }
1182
+ }
1183
+ _isResizingTop() {
1184
+ return this._resizingDirection === ResizingDirection.Top || this._resizingDirection === ResizingDirection.TopRight || this._resizingDirection === ResizingDirection.TopLeft;
1185
+ }
1186
+ _isResizingRight() {
1187
+ return (this._resizingDirection === ResizingDirection.Right ||
1188
+ this._resizingDirection === ResizingDirection.TopRight ||
1189
+ this._resizingDirection === ResizingDirection.BottomRight);
1190
+ }
1191
+ _isResizingBottom() {
1192
+ return (this._resizingDirection === ResizingDirection.Bottom ||
1193
+ this._resizingDirection === ResizingDirection.BottomLeft ||
1194
+ this._resizingDirection === ResizingDirection.BottomRight);
1195
+ }
1196
+ _isResizingLeft() {
1197
+ return (this._resizingDirection === ResizingDirection.Left || this._resizingDirection === ResizingDirection.TopLeft || this._resizingDirection === ResizingDirection.BottomLeft);
1198
+ }
1199
+ _expandLeft(widthModification) {
1200
+ const frameElementWidth = parseFloat(this.element.style.width.replace("px", ""));
1201
+ const frameElementLeft = parseFloat(this.element.style.left.replace("px", ""));
1202
+ this.element.style.width = `${frameElementWidth - widthModification}px`;
1203
+ this.element.style.left = `${frameElementLeft + widthModification}px`;
1204
+ this._updateMinHeightWithComments();
1205
+ }
1206
+ _expandTop(heightModification) {
1207
+ const frameElementHeight = parseFloat(this.element.style.height.replace("px", ""));
1208
+ const frameElementTop = parseFloat(this.element.style.top.replace("px", ""));
1209
+ this.element.style.height = `${frameElementHeight - heightModification}px`;
1210
+ this.element.style.top = `${frameElementTop + heightModification}px`;
1211
+ }
1212
+ _expandRight(widthModification, x) {
1213
+ const frameElementWidth = parseFloat(this.element.style.width.replace("px", ""));
1214
+ if (frameElementWidth + widthModification > 20) {
1215
+ this._mouseStartPointX = x;
1216
+ this.element.style.width = `${frameElementWidth + widthModification}px`;
1217
+ }
1218
+ this._updateMinHeightWithComments();
1219
+ }
1220
+ _expandBottom(heightModification) {
1221
+ const frameElementHeight = parseFloat(this.element.style.height.replace("px", ""));
1222
+ this.element.style.height = `${frameElementHeight + heightModification}px`;
1223
+ }
1224
+ dispose() {
1225
+ var _a;
1226
+ if (this._onSelectionChangedObserver) {
1227
+ this._ownerCanvas.stateManager.onSelectionChangedObservable.remove(this._onSelectionChangedObserver);
1228
+ }
1229
+ if (this._onGraphNodeRemovalObserver) {
1230
+ this._ownerCanvas.stateManager.onGraphNodeRemovalObservable.remove(this._onGraphNodeRemovalObserver);
1231
+ }
1232
+ if (this._onExposePortOnFrameObserver) {
1233
+ this._ownerCanvas.stateManager.onExposePortOnFrameObservable.remove(this._onExposePortOnFrameObserver);
1234
+ }
1235
+ (_a = this.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.element);
1236
+ this._ownerCanvas.frames.splice(this._ownerCanvas.frames.indexOf(this), 1);
1237
+ this.onExpandStateChanged.clear();
1238
+ }
1239
+ _serializePortData(exposedPorts) {
1240
+ if (exposedPorts.length > 0) {
1241
+ for (let i = 0; i < exposedPorts.length; ++i) {
1242
+ if (exposedPorts[i]) {
1243
+ exposedPorts[i].exposedPortPosition = i;
1244
+ }
1245
+ }
1246
+ }
1247
+ }
1248
+ serialize(saveCollapsedState) {
1249
+ this._serializePortData(this._exposedInPorts);
1250
+ this._serializePortData(this._exposedOutPorts);
1251
+ return {
1252
+ x: this._x,
1253
+ y: this._y,
1254
+ width: this._width,
1255
+ height: this._height,
1256
+ color: this._color.asArray(),
1257
+ name: this.name,
1258
+ isCollapsed: saveCollapsedState ? this.isCollapsed : true,
1259
+ blocks: this.nodes.map((n) => n.content.uniqueId),
1260
+ comments: this._comments,
1261
+ };
1262
+ }
1263
+ export() {
1264
+ const state = this._ownerCanvas.stateManager;
1265
+ const json = state.exportData(state.data, this);
1266
+ StringTools.DownloadAsFile(state.hostDocument, json, this._name + ".json");
1267
+ }
1268
+ adjustPorts() {
1269
+ for (const node of this.nodes) {
1270
+ for (const port of node.outputPorts) {
1271
+ // Output
1272
+ if (port.exposedOnFrame) {
1273
+ if (port.exposedPortPosition !== -1) {
1274
+ this._exposedOutPorts[port.exposedPortPosition] = port;
1275
+ }
1276
+ }
1277
+ }
1278
+ for (const port of node.inputPorts) {
1279
+ // Imports
1280
+ if (port.exposedOnFrame) {
1281
+ if (port.exposedPortPosition !== -1) {
1282
+ this._exposedInPorts[port.exposedPortPosition] = port;
1283
+ }
1284
+ }
1285
+ }
1286
+ }
1287
+ }
1288
+ static Parse(serializationData, canvas, map) {
1289
+ const newFrame = new GraphFrame(null, canvas, true);
1290
+ const isCollapsed = !!serializationData.isCollapsed;
1291
+ newFrame.x = serializationData.x;
1292
+ newFrame.y = serializationData.y;
1293
+ newFrame.width = serializationData.width;
1294
+ newFrame.height = serializationData.height;
1295
+ newFrame.name = serializationData.name;
1296
+ newFrame.color = Color3.FromArray(serializationData.color);
1297
+ newFrame.comments = serializationData.comments;
1298
+ if (serializationData.blocks && map) {
1299
+ for (const blockId of serializationData.blocks) {
1300
+ const actualId = map[blockId];
1301
+ const node = canvas.nodes.filter((n) => n.content.uniqueId === actualId);
1302
+ if (node.length) {
1303
+ newFrame.nodes.push(node[0]);
1304
+ node[0].enclosingFrameId = newFrame.id;
1305
+ }
1306
+ }
1307
+ }
1308
+ else {
1309
+ newFrame.refresh();
1310
+ }
1311
+ newFrame.adjustPorts();
1312
+ newFrame.isCollapsed = isCollapsed;
1313
+ if (isCollapsed) {
1314
+ canvas._frameIsMoving = true;
1315
+ newFrame._moveFrame(-(newFrame.width - newFrame._collapsedWidth) / 2, 0);
1316
+ const diff = serializationData.x - newFrame.x;
1317
+ newFrame._moveFrame(diff, 0);
1318
+ newFrame.cleanAccumulation();
1319
+ for (const selectedNode of newFrame.nodes) {
1320
+ selectedNode.refresh();
1321
+ }
1322
+ canvas._frameIsMoving = false;
1323
+ }
1324
+ return newFrame;
1325
+ }
1326
+ }
1327
+ GraphFrame._FrameCounter = 0;
1328
+ GraphFrame._FramePortCounter = 0;
1329
+ //# sourceMappingURL=graphFrame.js.map