@foblex/flow 1.5.0 → 1.5.1

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 (198) hide show
  1. package/domain/get-output-rect-in-flow/get-output-rect-in-flow-request.d.ts +4 -0
  2. package/domain/get-output-rect-in-flow/get-output-rect-in-flow-response.d.ts +7 -0
  3. package/domain/get-output-rect-in-flow/get-output-rect-in-flow.handler.d.ts +14 -0
  4. package/domain/get-output-rect-in-flow/index.d.ts +3 -0
  5. package/domain/index.d.ts +2 -1
  6. package/domain/providers.d.ts +3 -2
  7. package/domain/redraw-connections/index.d.ts +2 -0
  8. package/domain/redraw-connections/redraw-connections-request.d.ts +3 -0
  9. package/{f-flow/domain → domain}/redraw-connections/redraw-connections.handler.d.ts +8 -6
  10. package/esm2022/domain/get-connection-vector/get-connection-vector.handler.mjs +10 -3
  11. package/esm2022/domain/get-output-rect-in-flow/get-output-rect-in-flow-request.mjs +6 -0
  12. package/esm2022/domain/get-output-rect-in-flow/get-output-rect-in-flow-response.mjs +7 -0
  13. package/esm2022/domain/get-output-rect-in-flow/get-output-rect-in-flow.handler.mjs +33 -0
  14. package/esm2022/domain/get-output-rect-in-flow/index.mjs +4 -0
  15. package/esm2022/domain/index.mjs +3 -2
  16. package/esm2022/domain/providers.mjs +6 -4
  17. package/esm2022/domain/redraw-connections/index.mjs +3 -0
  18. package/esm2022/domain/redraw-connections/redraw-connections-request.mjs +5 -0
  19. package/esm2022/domain/redraw-connections/redraw-connections.handler.mjs +54 -0
  20. package/esm2022/f-canvas/f-canvas-base.mjs +3 -4
  21. package/esm2022/f-components-store.mjs +1 -1
  22. package/esm2022/f-connection/common/f-connection-base.mjs +2 -2
  23. package/esm2022/f-connection/common/f-path/f-connection-path.component.mjs +2 -2
  24. package/esm2022/f-connection/common/i-has-connection-from-to.mjs +1 -1
  25. package/esm2022/f-connection/common/mixins/change-connection-selection.mixin.mjs +1 -1
  26. package/esm2022/f-connection/common/mixins/change-connection-visibility.mixin.mjs +1 -1
  27. package/esm2022/f-connection/f-connection/f-connection.component.mjs +5 -5
  28. package/esm2022/f-connection/f-connection-for-create/f-connection-for-create.component.mjs +2 -2
  29. package/esm2022/f-draggable/connections/create-connection/create-connection.drag-handler.mjs +6 -7
  30. package/esm2022/f-draggable/connections/create-connection/create-connection.on-pointer-up.mjs +3 -3
  31. package/esm2022/f-draggable/connections/create-connection/create-connection.prepare-drag-sequence.mjs +8 -8
  32. package/esm2022/f-draggable/connections/create-connection/f-create-connection.event.mjs +7 -0
  33. package/esm2022/f-draggable/connections/create-connection/index.mjs +2 -2
  34. package/esm2022/f-draggable/connections/reassign-connection/f-reassign-connection.event.mjs +9 -0
  35. package/esm2022/f-draggable/connections/reassign-connection/index.mjs +2 -2
  36. package/esm2022/f-draggable/connections/reassign-connection/reassign-connection.drag-handler.mjs +8 -9
  37. package/esm2022/f-draggable/connections/reassign-connection/reassign-connection.on-pointer-up.mjs +3 -3
  38. package/esm2022/f-draggable/connections/reassign-connection/reassign-connection.prepare-drag-sequence.mjs +7 -7
  39. package/esm2022/f-draggable/external-item/external-item.drag-handler.mjs +1 -1
  40. package/esm2022/f-draggable/external-item/external-item.on-pointer-up.mjs +3 -3
  41. package/esm2022/f-draggable/external-item/external-item.prepare-drag-sequence.mjs +3 -3
  42. package/esm2022/f-draggable/external-item/f-create-node.event.mjs +7 -0
  43. package/esm2022/f-draggable/external-item/index.mjs +2 -2
  44. package/esm2022/f-draggable/f-draggable-base.mjs +1 -1
  45. package/esm2022/f-draggable/f-draggable-data-context.mjs +1 -1
  46. package/esm2022/f-draggable/f-draggable.directive.mjs +3 -3
  47. package/esm2022/f-draggable/index.mjs +13 -0
  48. package/esm2022/f-draggable/node/connection-source.drag-handler.mjs +6 -7
  49. package/esm2022/f-draggable/node/connection-target.drag-handler.mjs +6 -7
  50. package/esm2022/f-draggable/node/connection.drag-handler.mjs +6 -7
  51. package/esm2022/f-draggable/node/node.prepare-drag-sequence.mjs +11 -11
  52. package/esm2022/f-draggable/single-select/f-selection-change-event.mjs +7 -0
  53. package/esm2022/f-draggable/single-select/index.mjs +2 -2
  54. package/esm2022/f-external-item/f-external-item-base.mjs +11 -0
  55. package/esm2022/f-external-item/f-external-item.directive.mjs +44 -0
  56. package/esm2022/f-external-item/f-external-item.service.mjs +28 -0
  57. package/esm2022/f-external-item/index.mjs +5 -0
  58. package/esm2022/f-external-item/is-external-item.mjs +7 -0
  59. package/esm2022/f-flow/f-flow.component.mjs +14 -20
  60. package/esm2022/f-flow/index.mjs +1 -2
  61. package/esm2022/f-flow.module.mjs +5 -4
  62. package/esm2022/f-line-alignment/domain/i-line-alignment-rect.mjs +2 -0
  63. package/esm2022/f-line-alignment/domain/i-line-alignment-result.mjs +2 -0
  64. package/esm2022/f-line-alignment/domain/i-nearest-coordinate-result.mjs +2 -0
  65. package/esm2022/f-line-alignment/domain/index.mjs +7 -0
  66. package/esm2022/f-line-alignment/domain/line-element.mjs +23 -0
  67. package/esm2022/f-line-alignment/domain/line-service.mjs +33 -0
  68. package/esm2022/f-line-alignment/domain/nearest-coordinate.mjs +100 -0
  69. package/esm2022/f-line-alignment/f-line-alignment-base.mjs +11 -0
  70. package/esm2022/f-line-alignment/f-line-alignment.component.mjs +90 -0
  71. package/esm2022/f-line-alignment/index.mjs +4 -0
  72. package/esm2022/f-mediator/f-flow-mediator.mjs +24 -0
  73. package/esm2022/f-mediator/f-handler-register.mjs +7 -0
  74. package/esm2022/f-mediator/index.mjs +3 -0
  75. package/esm2022/f-selection-area/domain/i-selection-area-rect.mjs +2 -0
  76. package/esm2022/f-selection-area/domain/index.mjs +2 -0
  77. package/esm2022/f-selection-area/f-selection-area-base.mjs +11 -0
  78. package/esm2022/f-selection-area/f-selection-area.component.mjs +44 -0
  79. package/esm2022/f-selection-area/index.mjs +4 -0
  80. package/esm2022/public-api.mjs +6 -3
  81. package/f-canvas/f-canvas-base.d.ts +3 -4
  82. package/f-components-store.d.ts +1 -1
  83. package/f-connection/common/f-connection-base.d.ts +2 -2
  84. package/f-connection/common/i-has-connection-from-to.d.ts +1 -1
  85. package/f-connection/common/mixins/change-connection-selection.mixin.d.ts +1 -2
  86. package/f-connection/common/mixins/change-connection-visibility.mixin.d.ts +1 -2
  87. package/f-connection/f-connection/f-connection.component.d.ts +2 -2
  88. package/f-connection/f-connection-for-create/f-connection-for-create.component.d.ts +1 -1
  89. package/f-draggable/connections/create-connection/create-connection.drag-handler.d.ts +3 -4
  90. package/f-draggable/connections/create-connection/create-connection.prepare-drag-sequence.d.ts +4 -4
  91. package/f-draggable/connections/create-connection/f-create-connection.event.d.ts +5 -0
  92. package/f-draggable/connections/create-connection/index.d.ts +1 -1
  93. package/f-draggable/connections/reassign-connection/f-reassign-connection.event.d.ts +7 -0
  94. package/f-draggable/connections/reassign-connection/index.d.ts +1 -1
  95. package/f-draggable/connections/reassign-connection/reassign-connection.drag-handler.d.ts +4 -4
  96. package/f-draggable/connections/reassign-connection/reassign-connection.prepare-drag-sequence.d.ts +4 -4
  97. package/f-draggable/external-item/external-item.drag-handler.d.ts +1 -1
  98. package/f-draggable/external-item/external-item.prepare-drag-sequence.d.ts +1 -1
  99. package/f-draggable/external-item/{create-node.event.d.ts → f-create-node.event.d.ts} +1 -1
  100. package/f-draggable/external-item/index.d.ts +1 -1
  101. package/f-draggable/f-draggable-base.d.ts +8 -8
  102. package/f-draggable/f-draggable-data-context.d.ts +2 -1
  103. package/f-draggable/f-draggable.directive.d.ts +7 -7
  104. package/f-draggable/{public-api.d.ts → index.d.ts} +0 -1
  105. package/f-draggable/node/connection-source.drag-handler.d.ts +4 -4
  106. package/f-draggable/node/connection-target.drag-handler.d.ts +4 -4
  107. package/f-draggable/node/connection.drag-handler.d.ts +4 -4
  108. package/f-draggable/node/node.prepare-drag-sequence.d.ts +4 -4
  109. package/f-draggable/single-select/{selection-change-event.d.ts → f-selection-change-event.d.ts} +1 -1
  110. package/f-draggable/single-select/index.d.ts +1 -1
  111. package/f-flow/f-flow.component.d.ts +3 -3
  112. package/f-flow/index.d.ts +0 -1
  113. package/f-flow.module.d.ts +3 -3
  114. package/{f-draggable/components/f-line-alignment → f-line-alignment}/f-line-alignment-base.d.ts +1 -1
  115. package/{f-draggable/components/f-line-alignment → f-line-alignment}/f-line-alignment.component.d.ts +4 -4
  116. package/f-mediator/f-flow-mediator.d.ts +12 -0
  117. package/f-mediator/f-handler-register.d.ts +5 -0
  118. package/f-mediator/index.d.ts +2 -0
  119. package/{f-draggable/components/f-selection-area → f-selection-area}/f-selection-area.component.d.ts +1 -1
  120. package/fesm2022/foblex-flow.mjs +1089 -1127
  121. package/fesm2022/foblex-flow.mjs.map +1 -1
  122. package/package.json +2 -2
  123. package/public-api.d.ts +5 -2
  124. package/common-behaviours/change-position.d.ts +0 -10
  125. package/common-behaviours/change-zoom/change-zoom.d.ts +0 -6
  126. package/common-behaviours/change-zoom/i-can-change-zoom.d.ts +0 -6
  127. package/common-behaviours/change-zoom/index.d.ts +0 -2
  128. package/common-behaviours/constructor.d.ts +0 -2
  129. package/common-behaviours/fit-to-parent/fit-to-parent.d.ts +0 -6
  130. package/common-behaviours/fit-to-parent/i-can-fit-to-parent.d.ts +0 -4
  131. package/common-behaviours/fit-to-parent/index.d.ts +0 -2
  132. package/common-behaviours/i-transformable.d.ts +0 -4
  133. package/common-behaviours/index.d.ts +0 -6
  134. package/common-behaviours/one-to-one-centering/i-can-one-to-one-centering.d.ts +0 -4
  135. package/common-behaviours/one-to-one-centering/index.d.ts +0 -2
  136. package/common-behaviours/one-to-one-centering/one-to-one-centering.d.ts +0 -6
  137. package/domain/get-output-rect-in-flow.handler.d.ts +0 -19
  138. package/esm2022/common-behaviours/change-position.mjs +0 -15
  139. package/esm2022/common-behaviours/change-zoom/change-zoom.mjs +0 -25
  140. package/esm2022/common-behaviours/change-zoom/i-can-change-zoom.mjs +0 -2
  141. package/esm2022/common-behaviours/change-zoom/index.mjs +0 -3
  142. package/esm2022/common-behaviours/constructor.mjs +0 -2
  143. package/esm2022/common-behaviours/fit-to-parent/fit-to-parent.mjs +0 -27
  144. package/esm2022/common-behaviours/fit-to-parent/i-can-fit-to-parent.mjs +0 -2
  145. package/esm2022/common-behaviours/fit-to-parent/index.mjs +0 -3
  146. package/esm2022/common-behaviours/i-transformable.mjs +0 -2
  147. package/esm2022/common-behaviours/index.mjs +0 -7
  148. package/esm2022/common-behaviours/one-to-one-centering/i-can-one-to-one-centering.mjs +0 -2
  149. package/esm2022/common-behaviours/one-to-one-centering/index.mjs +0 -3
  150. package/esm2022/common-behaviours/one-to-one-centering/one-to-one-centering.mjs +0 -24
  151. package/esm2022/domain/get-output-rect-in-flow.handler.mjs +0 -25
  152. package/esm2022/f-draggable/components/f-external-item/f-external-item-base.mjs +0 -11
  153. package/esm2022/f-draggable/components/f-external-item/f-external-item.directive.mjs +0 -44
  154. package/esm2022/f-draggable/components/f-external-item/f-external-item.service.mjs +0 -28
  155. package/esm2022/f-draggable/components/f-external-item/index.mjs +0 -5
  156. package/esm2022/f-draggable/components/f-external-item/is-external-item.mjs +0 -7
  157. package/esm2022/f-draggable/components/f-line-alignment/domain/i-line-alignment-rect.mjs +0 -2
  158. package/esm2022/f-draggable/components/f-line-alignment/domain/i-line-alignment-result.mjs +0 -2
  159. package/esm2022/f-draggable/components/f-line-alignment/domain/i-nearest-coordinate-result.mjs +0 -2
  160. package/esm2022/f-draggable/components/f-line-alignment/domain/index.mjs +0 -7
  161. package/esm2022/f-draggable/components/f-line-alignment/domain/line-element.mjs +0 -23
  162. package/esm2022/f-draggable/components/f-line-alignment/domain/line-service.mjs +0 -33
  163. package/esm2022/f-draggable/components/f-line-alignment/domain/nearest-coordinate.mjs +0 -100
  164. package/esm2022/f-draggable/components/f-line-alignment/f-line-alignment-base.mjs +0 -11
  165. package/esm2022/f-draggable/components/f-line-alignment/f-line-alignment.component.mjs +0 -90
  166. package/esm2022/f-draggable/components/f-line-alignment/index.mjs +0 -4
  167. package/esm2022/f-draggable/components/f-selection-area/domain/i-selection-area-rect.mjs +0 -2
  168. package/esm2022/f-draggable/components/f-selection-area/domain/index.mjs +0 -2
  169. package/esm2022/f-draggable/components/f-selection-area/f-selection-area-base.mjs +0 -11
  170. package/esm2022/f-draggable/components/f-selection-area/f-selection-area.component.mjs +0 -44
  171. package/esm2022/f-draggable/components/f-selection-area/index.mjs +0 -4
  172. package/esm2022/f-draggable/components/index.mjs +0 -4
  173. package/esm2022/f-draggable/connections/create-connection/create-connection.event.mjs +0 -7
  174. package/esm2022/f-draggable/connections/reassign-connection/reassign-connection.event.mjs +0 -9
  175. package/esm2022/f-draggable/external-item/create-node.event.mjs +0 -7
  176. package/esm2022/f-draggable/public-api.mjs +0 -14
  177. package/esm2022/f-draggable/single-select/selection-change-event.mjs +0 -7
  178. package/esm2022/f-flow/domain/redraw-connections/redraw-connections.handler.mjs +0 -46
  179. package/f-draggable/components/index.d.ts +0 -3
  180. package/f-draggable/connections/create-connection/create-connection.event.d.ts +0 -5
  181. package/f-draggable/connections/reassign-connection/reassign-connection.event.d.ts +0 -7
  182. /package/{f-draggable/components/f-external-item → f-external-item}/f-external-item-base.d.ts +0 -0
  183. /package/{f-draggable/components/f-external-item → f-external-item}/f-external-item.directive.d.ts +0 -0
  184. /package/{f-draggable/components/f-external-item → f-external-item}/f-external-item.service.d.ts +0 -0
  185. /package/{f-draggable/components/f-external-item → f-external-item}/index.d.ts +0 -0
  186. /package/{f-draggable/components/f-external-item → f-external-item}/is-external-item.d.ts +0 -0
  187. /package/{f-draggable/components/f-line-alignment → f-line-alignment}/domain/i-line-alignment-rect.d.ts +0 -0
  188. /package/{f-draggable/components/f-line-alignment → f-line-alignment}/domain/i-line-alignment-result.d.ts +0 -0
  189. /package/{f-draggable/components/f-line-alignment → f-line-alignment}/domain/i-nearest-coordinate-result.d.ts +0 -0
  190. /package/{f-draggable/components/f-line-alignment → f-line-alignment}/domain/index.d.ts +0 -0
  191. /package/{f-draggable/components/f-line-alignment → f-line-alignment}/domain/line-element.d.ts +0 -0
  192. /package/{f-draggable/components/f-line-alignment → f-line-alignment}/domain/line-service.d.ts +0 -0
  193. /package/{f-draggable/components/f-line-alignment → f-line-alignment}/domain/nearest-coordinate.d.ts +0 -0
  194. /package/{f-draggable/components/f-line-alignment → f-line-alignment}/index.d.ts +0 -0
  195. /package/{f-draggable/components/f-selection-area → f-selection-area}/domain/i-selection-area-rect.d.ts +0 -0
  196. /package/{f-draggable/components/f-selection-area → f-selection-area}/domain/index.d.ts +0 -0
  197. /package/{f-draggable/components/f-selection-area → f-selection-area}/f-selection-area-base.d.ts +0 -0
  198. /package/{f-draggable/components/f-selection-area → f-selection-area}/index.d.ts +0 -0
@@ -1,96 +1,10 @@
1
- import { PointExtensions, TransformModelExtensions, DomElementExtensions, RectExtensions, BooleanExtensions, sanitizeElementId, Point, GuidExtensions, VectorExtensions, EventExtensions, SizeExtensions, MouseEventExtensions, IMouseEvent, ITouchDownEvent, ITouchMoveEvent, ITouchUpEvent } from '@foblex/core';
2
1
  import * as i0 from '@angular/core';
3
2
  import { InjectionToken, Component, ChangeDetectionStrategy, Input, Directive, Injectable, ContentChild, Inject, ViewChild, ContentChildren, Optional, SkipSelf, EventEmitter, Output, NgModule } from '@angular/core';
3
+ import { TransformModelExtensions, DomElementExtensions, PointExtensions, RectExtensions, BooleanExtensions, sanitizeElementId, Point, GuidExtensions, VectorExtensions, EventExtensions, mixinChangePosition, mixinFitToParent, mixinOneToOneCentering, mixinChangeZoom, SizeExtensions, MouseEventExtensions, IMouseEvent, ITouchDownEvent, ITouchMoveEvent, ITouchUpEvent } from '@foblex/core';
4
4
  import { Subject, Observable, Subscription, startWith, debounceTime } from 'rxjs';
5
+ import { __decorate } from 'tslib';
5
6
  import { DOCUMENT, CommonModule } from '@angular/common';
6
7
 
7
- function mixinChangeZoom(base) {
8
- return class extends base {
9
- setZoom(scaleValue, toPosition) {
10
- if (scaleValue !== this.transform.scale) {
11
- const summaryPosition = PointExtensions.sum(this.transform.scaledPosition, this.transform.position);
12
- const newX = toPosition.x - (toPosition.x - summaryPosition.x) * scaleValue / this.transform.scale;
13
- const newY = toPosition.y - (toPosition.y - summaryPosition.y) * scaleValue / this.transform.scale;
14
- this.transform.scale = scaleValue;
15
- this.transform.scaledPosition = PointExtensions.sub(PointExtensions.initialize(newX, newY), this.transform.position);
16
- }
17
- }
18
- setScalePosition(value) {
19
- this.transform.scaledPosition = value;
20
- }
21
- resetZoom() {
22
- this.transform.scale = 1;
23
- this.transform.scaledPosition = PointExtensions.initialize();
24
- }
25
- constructor(...args) {
26
- super(...args);
27
- }
28
- };
29
- }
30
-
31
- function mixinFitToParent(base) {
32
- return class extends base {
33
- fitToParent(rect, parentRect, points) {
34
- this.transform.scaledPosition = PointExtensions.initialize();
35
- this.transform.position = this.getZeroPositionWithoutScale(points);
36
- const itemsContainerWidth = rect.width / this.transform.scale;
37
- const itemsContainerHeight = rect.height / this.transform.scale;
38
- if ((itemsContainerWidth > parentRect.width || itemsContainerHeight > parentRect.height) ||
39
- itemsContainerWidth < parentRect.width && itemsContainerHeight < parentRect.height) {
40
- this.transform.scale = Math.min(parentRect.width / itemsContainerWidth, parentRect.height / itemsContainerHeight);
41
- }
42
- const newX = (parentRect.width - itemsContainerWidth * this.transform.scale) / 2 - this.transform.position.x * this.transform.scale;
43
- const newY = (parentRect.height - itemsContainerHeight * this.transform.scale) / 2 - this.transform.position.y * this.transform.scale;
44
- this.transform.position = PointExtensions.initialize(newX, newY);
45
- }
46
- getZeroPositionWithoutScale(points) {
47
- const xPoint = points.length ? Math.min(...points.map((point) => point.x)) : 0;
48
- const yPoint = points.length ? Math.min(...points.map((point) => point.y)) : 0;
49
- return PointExtensions.initialize(xPoint, yPoint);
50
- }
51
- constructor(...args) {
52
- super(...args);
53
- }
54
- };
55
- }
56
-
57
- function mixinOneToOneCentering(base) {
58
- return class extends base {
59
- oneToOneCentering(rect, parentRect, points) {
60
- this.transform.scaledPosition = PointExtensions.initialize();
61
- this.transform.position = this.getZeroPositionWithoutScale(points);
62
- const itemsContainerWidth = rect.width / this.transform.scale;
63
- const itemsContainerHeight = rect.height / this.transform.scale;
64
- this.transform.scale = 1;
65
- const newX = (parentRect.width - itemsContainerWidth * this.transform.scale) / 2 - this.transform.position.x * this.transform.scale;
66
- const newY = (parentRect.height - itemsContainerHeight * this.transform.scale) / 2 - this.transform.position.y * this.transform.scale;
67
- this.transform.position = PointExtensions.initialize(newX, newY);
68
- }
69
- getZeroPositionWithoutScale(points) {
70
- const xPoint = points.length ? Math.min(...points.map((point) => point.x)) : 0;
71
- const yPoint = points.length ? Math.min(...points.map((point) => point.y)) : 0;
72
- return PointExtensions.initialize(xPoint, yPoint);
73
- }
74
- constructor(...args) {
75
- super(...args);
76
- }
77
- };
78
- }
79
-
80
- function mixinChangePosition(base) {
81
- return class extends base {
82
- getPosition() {
83
- return this.transform.position;
84
- }
85
- setPosition(position) {
86
- this.transform.position = PointExtensions.copy(position);
87
- }
88
- constructor(...args) {
89
- super(...args);
90
- }
91
- };
92
- }
93
-
94
8
  const F_BACKGROUND_PATTERN = new InjectionToken('F_BACKGROUND_PATTERN');
95
9
 
96
10
  let uniqueId$9 = 0;
@@ -1221,7 +1135,7 @@ class FConnectionPathComponent {
1221
1135
  this.hostElement.setAttribute('marker-end', `url(#${this.getMarkerId(EFMarkerType.END)})`);
1222
1136
  }
1223
1137
  getMarkerId(type) {
1224
- return sanitizeElementId(`${getFlowUid()}-${type}-${this.base.id}`);
1138
+ return sanitizeElementId(`${getFlowUid()}-${type}-${this.base.fConnectionId}`);
1225
1139
  }
1226
1140
  isSelected() {
1227
1141
  return this.hostElement.getAttribute('marker-start') === `url(#${this.getMarkerId(EFMarkerType.SELECTED_START)})`;
@@ -1360,7 +1274,7 @@ class FConnectionBase extends MIXIN_BASE$1 {
1360
1274
  this.fDefs.nativeElement.innerHTML = '';
1361
1275
  this.fMarkers.forEach((marker) => {
1362
1276
  const markerElement = DomElementExtensions.createSvgElement('marker');
1363
- markerElement.setAttribute('id', getFlowUid() + '-' + marker.type + '-' + this.id);
1277
+ markerElement.setAttribute('id', getFlowUid() + '-' + marker.type + '-' + this.fConnectionId);
1364
1278
  markerElement.setAttribute('markerHeight', `${marker.height}`);
1365
1279
  markerElement.setAttribute('markerWidth', `${marker.width}`);
1366
1280
  markerElement.setAttribute('orient', 'auto');
@@ -1432,7 +1346,7 @@ class FConnectionForCreateComponent extends FConnectionBase {
1432
1346
  constructor(elementReference, fComponentsStore) {
1433
1347
  super(elementReference);
1434
1348
  this.fComponentsStore = fComponentsStore;
1435
- this.id = `f-connection-for-create-${uniqueId$4++}`;
1349
+ this.fConnectionId = `f-connection-for-create-${uniqueId$4++}`;
1436
1350
  this.fText = '';
1437
1351
  this.fStartColor = 'black';
1438
1352
  this.fEndColor = 'black';
@@ -1515,7 +1429,7 @@ class FConnectionComponent extends FConnectionBase {
1515
1429
  constructor(elementReference, fComponentsStore) {
1516
1430
  super(elementReference);
1517
1431
  this.fComponentsStore = fComponentsStore;
1518
- this.id = `f-connection-${uniqueId$3++}`;
1432
+ this.fConnectionId = `f-connection-${uniqueId$3++}`;
1519
1433
  this.fText = '';
1520
1434
  this.fStartColor = 'black';
1521
1435
  this.fEndColor = 'black';
@@ -1530,16 +1444,16 @@ class FConnectionComponent extends FConnectionBase {
1530
1444
  this.fComponentsStore.removeConnection(this);
1531
1445
  }
1532
1446
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FConnectionComponent, deps: [{ token: i0.ElementRef }, { token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Component }); }
1533
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.2.1", type: FConnectionComponent, selector: "f-connection", inputs: { id: "id", fText: "fText", fStartColor: "fStartColor", fEndColor: "fEndColor", fOutputId: "fOutputId", fInputId: "fInputId", fBehavior: ["fBehavior", "fBehavior", castToConnectionBehavior], fType: ["fType", "fType", castToConnectionType], disabled: "disabled" }, host: { properties: { "attr.id": "id", "class.f-connection-disabled": "disabled" }, classAttribute: "f-component f-connection" }, providers: [{ provide: F_CONNECTION, useExisting: FConnectionComponent }], queries: [{ propertyName: "fMarkers", predicate: F_MARKER, descendants: true }], viewQueries: [{ propertyName: "fDefs", first: true, predicate: ["defs"], descendants: true, static: true }, { propertyName: "fPath", first: true, predicate: CONNECTION_PATH, descendants: true, static: true }, { propertyName: "fGradient", first: true, predicate: CONNECTION_GRADIENT, descendants: true, static: true }, { propertyName: "fDragHandle", first: true, predicate: FConnectionDragHandleComponent, descendants: true, static: true }, { propertyName: "fSelection", first: true, predicate: FConnectionSelectionComponent, descendants: true, static: true }, { propertyName: "fTextComponent", first: true, predicate: CONNECTION_TEXT, descendants: true, static: true }, { propertyName: "fConnectionCenter", first: true, predicate: ["fConnectionCenter"], descendants: true, static: true }], exportAs: ["fComponent"], usesInheritance: true, ngImport: i0, template: "<svg xmlns=\"http://www.w3.org/2000/svg\" style=\"overflow: visible; display: block; vertical-align: middle;\">\n <defs #defs></defs>\n <g class=\"f-connection-group\">\n <linearGradient fConnectionGradient></linearGradient>\n <path fConnectionSelection [attr.d]=\"path\"></path>\n <g>\n <path f-connection-path\n [attr.d]=\"path\">\n </path>\n <circle f-connection-drag-handle r=\"8\"></circle>\n </g>\n <text f-connection-text></text>\n </g>\n <ng-content></ng-content>\n</svg>\n<div #fConnectionCenter class=\"f-connection-center\">\n <ng-content select=\"[fConnectionCenter]\"></ng-content>\n</div>\n", styles: [":host{pointer-events:none;position:absolute}:host svg{overflow:visible}:host svg .f-connection-group{pointer-events:all}\n"], dependencies: [{ kind: "component", type: FConnectionDragHandleComponent, selector: "circle[f-connection-drag-handle]" }, { kind: "component", type: FConnectionGradientComponent, selector: "linearGradient[fConnectionGradient]" }, { kind: "component", type: FConnectionPathComponent, selector: "path[f-connection-path]" }, { kind: "component", type: FConnectionTextComponent, selector: "text[f-connection-text]" }, { kind: "component", type: FConnectionSelectionComponent, selector: "path[fConnectionSelection]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1447
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "17.2.1", type: FConnectionComponent, selector: "f-connection", inputs: { fConnectionId: "fConnectionId", fText: "fText", fStartColor: "fStartColor", fEndColor: "fEndColor", fOutputId: "fOutputId", fInputId: "fInputId", fBehavior: ["fBehavior", "fBehavior", castToConnectionBehavior], fType: ["fType", "fType", castToConnectionType], disabled: "disabled" }, host: { properties: { "attr.id": "fConnectionId", "class.f-connection-disabled": "disabled" }, classAttribute: "f-component f-connection" }, providers: [{ provide: F_CONNECTION, useExisting: FConnectionComponent }], queries: [{ propertyName: "fMarkers", predicate: F_MARKER, descendants: true }], viewQueries: [{ propertyName: "fDefs", first: true, predicate: ["defs"], descendants: true, static: true }, { propertyName: "fPath", first: true, predicate: CONNECTION_PATH, descendants: true, static: true }, { propertyName: "fGradient", first: true, predicate: CONNECTION_GRADIENT, descendants: true, static: true }, { propertyName: "fDragHandle", first: true, predicate: FConnectionDragHandleComponent, descendants: true, static: true }, { propertyName: "fSelection", first: true, predicate: FConnectionSelectionComponent, descendants: true, static: true }, { propertyName: "fTextComponent", first: true, predicate: CONNECTION_TEXT, descendants: true, static: true }, { propertyName: "fConnectionCenter", first: true, predicate: ["fConnectionCenter"], descendants: true, static: true }], exportAs: ["fComponent"], usesInheritance: true, ngImport: i0, template: "<svg xmlns=\"http://www.w3.org/2000/svg\" style=\"overflow: visible; display: block; vertical-align: middle;\">\n <defs #defs></defs>\n <g class=\"f-connection-group\">\n <linearGradient fConnectionGradient></linearGradient>\n <path fConnectionSelection [attr.d]=\"path\"></path>\n <g>\n <path f-connection-path\n [attr.d]=\"path\">\n </path>\n <circle f-connection-drag-handle r=\"8\"></circle>\n </g>\n <text f-connection-text></text>\n </g>\n <ng-content></ng-content>\n</svg>\n<div #fConnectionCenter class=\"f-connection-center\">\n <ng-content select=\"[fConnectionCenter]\"></ng-content>\n</div>\n", styles: [":host{pointer-events:none;position:absolute}:host svg{overflow:visible}:host svg .f-connection-group{pointer-events:all}\n"], dependencies: [{ kind: "component", type: FConnectionDragHandleComponent, selector: "circle[f-connection-drag-handle]" }, { kind: "component", type: FConnectionGradientComponent, selector: "linearGradient[fConnectionGradient]" }, { kind: "component", type: FConnectionPathComponent, selector: "path[f-connection-path]" }, { kind: "component", type: FConnectionTextComponent, selector: "text[f-connection-text]" }, { kind: "component", type: FConnectionSelectionComponent, selector: "path[fConnectionSelection]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1534
1448
  }
1535
1449
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FConnectionComponent, decorators: [{
1536
1450
  type: Component,
1537
1451
  args: [{ selector: "f-connection", exportAs: 'fComponent', changeDetection: ChangeDetectionStrategy.OnPush, host: {
1538
- '[attr.id]': 'id',
1452
+ '[attr.id]': 'fConnectionId',
1539
1453
  class: "f-component f-connection",
1540
1454
  '[class.f-connection-disabled]': 'disabled',
1541
1455
  }, providers: [{ provide: F_CONNECTION, useExisting: FConnectionComponent }], template: "<svg xmlns=\"http://www.w3.org/2000/svg\" style=\"overflow: visible; display: block; vertical-align: middle;\">\n <defs #defs></defs>\n <g class=\"f-connection-group\">\n <linearGradient fConnectionGradient></linearGradient>\n <path fConnectionSelection [attr.d]=\"path\"></path>\n <g>\n <path f-connection-path\n [attr.d]=\"path\">\n </path>\n <circle f-connection-drag-handle r=\"8\"></circle>\n </g>\n <text f-connection-text></text>\n </g>\n <ng-content></ng-content>\n</svg>\n<div #fConnectionCenter class=\"f-connection-center\">\n <ng-content select=\"[fConnectionCenter]\"></ng-content>\n</div>\n", styles: [":host{pointer-events:none;position:absolute}:host svg{overflow:visible}:host svg .f-connection-group{pointer-events:all}\n"] }]
1542
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FComponentsStore }], propDecorators: { id: [{
1456
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FComponentsStore }], propDecorators: { fConnectionId: [{
1543
1457
  type: Input
1544
1458
  }], fText: [{
1545
1459
  type: Input
@@ -1978,7 +1892,45 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
1978
1892
  type: Directive
1979
1893
  }], ctorParameters: () => [] });
1980
1894
 
1981
- class GetConnectionVectorHandler {
1895
+ class GetConnectionVectorRequest {
1896
+ constructor(outputRect, inputRect, behavior, outputSide, inputSide) {
1897
+ this.outputRect = outputRect;
1898
+ this.inputRect = inputRect;
1899
+ this.behavior = behavior;
1900
+ this.outputSide = outputSide;
1901
+ this.inputSide = inputSide;
1902
+ }
1903
+ }
1904
+
1905
+ class FFlowMediator {
1906
+ constructor(injector) {
1907
+ this.injector = injector;
1908
+ }
1909
+ static { this.handlers = new Map(); }
1910
+ static register(type, handler) {
1911
+ this.handlers.set(type.name, handler);
1912
+ }
1913
+ send(request) {
1914
+ const handler = FFlowMediator.handlers.get(request.constructor.name);
1915
+ if (!handler) {
1916
+ throw new Error('Handler not registered for request type.');
1917
+ }
1918
+ return this.injector.get(handler).handle(request);
1919
+ }
1920
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FFlowMediator, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
1921
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FFlowMediator }); }
1922
+ }
1923
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FFlowMediator, decorators: [{
1924
+ type: Injectable
1925
+ }], ctorParameters: () => [{ type: i0.Injector }] });
1926
+
1927
+ function FHandlerRegister(requestType) {
1928
+ return function (constructor) {
1929
+ FFlowMediator.register(requestType, constructor);
1930
+ };
1931
+ }
1932
+
1933
+ let GetConnectionVectorHandler = class GetConnectionVectorHandler {
1982
1934
  constructor() {
1983
1935
  this.behaviorHandlers = {
1984
1936
  [EFConnectionBehavior.FLOATING.toString()]: this.floatingBehavior,
@@ -2014,7 +1966,10 @@ class GetConnectionVectorHandler {
2014
1966
  }
2015
1967
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionVectorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2016
1968
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionVectorHandler }); }
2017
- }
1969
+ };
1970
+ GetConnectionVectorHandler = __decorate([
1971
+ FHandlerRegister(GetConnectionVectorRequest)
1972
+ ], GetConnectionVectorHandler);
2018
1973
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionVectorHandler, decorators: [{
2019
1974
  type: Injectable
2020
1975
  }] });
@@ -2045,13 +2000,9 @@ const positionFixedOutbound = {
2045
2000
  },
2046
2001
  };
2047
2002
 
2048
- class GetConnectionVectorRequest {
2049
- constructor(outputRect, inputRect, behavior, outputSide, inputSide) {
2050
- this.outputRect = outputRect;
2051
- this.inputRect = inputRect;
2052
- this.behavior = behavior;
2053
- this.outputSide = outputSide;
2054
- this.inputSide = inputSide;
2003
+ class GetOutputRectInFlowRequest {
2004
+ constructor(fOutputId) {
2005
+ this.fOutputId = fOutputId;
2055
2006
  }
2056
2007
  }
2057
2008
 
@@ -2065,6 +2016,109 @@ function requiredOutput() {
2065
2016
  return new Error(`The node must contain at least one fOutput if there is an fOutlet`);
2066
2017
  }
2067
2018
 
2019
+ class GetOutputRectInFlowResponse {
2020
+ constructor(rect, fConnectableSide) {
2021
+ this.rect = rect;
2022
+ this.fConnectableSide = fConnectableSide;
2023
+ }
2024
+ }
2025
+
2026
+ class GetElementRectInFlowHandler {
2027
+ get transform() {
2028
+ return this.fComponentsStore.transform;
2029
+ }
2030
+ get flowHost() {
2031
+ return this.fComponentsStore.flowHost;
2032
+ }
2033
+ constructor(fComponentsStore) {
2034
+ this.fComponentsStore = fComponentsStore;
2035
+ }
2036
+ handle(element) {
2037
+ const systemRect = RectExtensions.fromElement(element);
2038
+ const position = Point.fromPoint(systemRect).elementTransform(this.flowHost).sub(this.transform.scaledPosition).sub(this.transform.position).div(this.transform.scale);
2039
+ const size = SizeExtensions.initialize(systemRect.width / this.transform.scale, systemRect.height / this.transform.scale);
2040
+ const result = RectExtensions.initialize(position.x, position.y, size.width, size.height);
2041
+ return result;
2042
+ }
2043
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetElementRectInFlowHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2044
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetElementRectInFlowHandler }); }
2045
+ }
2046
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetElementRectInFlowHandler, decorators: [{
2047
+ type: Injectable
2048
+ }], ctorParameters: () => [{ type: FComponentsStore }] });
2049
+
2050
+ let GetOutputRectInFlowHandler = class GetOutputRectInFlowHandler {
2051
+ constructor(fComponentsStore, getElementRectInFlowHandler) {
2052
+ this.fComponentsStore = fComponentsStore;
2053
+ this.getElementRectInFlowHandler = getElementRectInFlowHandler;
2054
+ }
2055
+ handle(request) {
2056
+ const output = this.fComponentsStore.fOutputs.find((x) => x.id === request.fOutputId);
2057
+ if (!output) {
2058
+ throw OutputNotFound(request.fOutputId);
2059
+ }
2060
+ const result = this.getElementRectInFlowHandler.handle(output.hostElement);
2061
+ return new GetOutputRectInFlowResponse(result, output.fConnectableSide);
2062
+ }
2063
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutputRectInFlowHandler, deps: [{ token: FComponentsStore }, { token: GetElementRectInFlowHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2064
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutputRectInFlowHandler }); }
2065
+ };
2066
+ GetOutputRectInFlowHandler = __decorate([
2067
+ FHandlerRegister(GetOutputRectInFlowRequest)
2068
+ ], GetOutputRectInFlowHandler);
2069
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutputRectInFlowHandler, decorators: [{
2070
+ type: Injectable
2071
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: GetElementRectInFlowHandler }] });
2072
+
2073
+ class RedrawConnectionsRequest {
2074
+ constructor() {
2075
+ }
2076
+ }
2077
+
2078
+ let RedrawConnectionsHandler = class RedrawConnectionsHandler {
2079
+ constructor(fComponentsStore, getElementRectInFlowHandler, fMediator) {
2080
+ this.fComponentsStore = fComponentsStore;
2081
+ this.getElementRectInFlowHandler = getElementRectInFlowHandler;
2082
+ this.fMediator = fMediator;
2083
+ }
2084
+ handle(request) {
2085
+ this.resetConnectors();
2086
+ this.fComponentsStore.fTempConnection?.setMarkers();
2087
+ this.fComponentsStore.fConnections.forEach((connection) => {
2088
+ const output = this.fComponentsStore.fOutputs.find((x) => x.id === connection.fOutputId);
2089
+ const input = this.fComponentsStore.fInputs.find((x) => x.id === connection.fInputId);
2090
+ if (output && input) {
2091
+ this.setupConnection(output, input, connection);
2092
+ }
2093
+ });
2094
+ }
2095
+ resetConnectors() {
2096
+ this.fComponentsStore.fOutputs.forEach((output) => output.setConnected(false));
2097
+ this.fComponentsStore.fInputs.forEach((input) => input.setConnected(false));
2098
+ }
2099
+ setupConnection(output, input, connection) {
2100
+ output.setConnected(true);
2101
+ input.setConnected(true);
2102
+ const vector = this.getVector(output, input, connection);
2103
+ connection.setVector(vector.point1, output.fConnectableSide, vector.point2, input.fConnectableSide);
2104
+ connection.setMarkers();
2105
+ connection.initialize();
2106
+ }
2107
+ getVector(output, input, connection) {
2108
+ const outputRect = this.getElementRectInFlowHandler.handle(output.hostElement);
2109
+ const inputRect = this.getElementRectInFlowHandler.handle(input.hostElement);
2110
+ return this.fMediator.send(new GetConnectionVectorRequest(outputRect, inputRect, connection.fBehavior, output.fConnectableSide, input.fConnectableSide));
2111
+ }
2112
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: RedrawConnectionsHandler, deps: [{ token: FComponentsStore }, { token: GetElementRectInFlowHandler }, { token: FFlowMediator }], target: i0.ɵɵFactoryTarget.Injectable }); }
2113
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: RedrawConnectionsHandler }); }
2114
+ };
2115
+ RedrawConnectionsHandler = __decorate([
2116
+ FHandlerRegister(RedrawConnectionsRequest)
2117
+ ], RedrawConnectionsHandler);
2118
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: RedrawConnectionsHandler, decorators: [{
2119
+ type: Injectable
2120
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: GetElementRectInFlowHandler }, { type: FFlowMediator }] });
2121
+
2068
2122
  class GetAllNodesRectHandler {
2069
2123
  constructor(fComponentsStore) {
2070
2124
  this.fComponentsStore = fComponentsStore;
@@ -2102,30 +2156,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
2102
2156
  type: Injectable
2103
2157
  }], ctorParameters: () => [{ type: FComponentsStore }] });
2104
2158
 
2105
- class GetElementRectInFlowHandler {
2106
- get transform() {
2107
- return this.fComponentsStore.transform;
2108
- }
2109
- get flowHost() {
2110
- return this.fComponentsStore.flowHost;
2111
- }
2112
- constructor(fComponentsStore) {
2113
- this.fComponentsStore = fComponentsStore;
2114
- }
2115
- handle(element) {
2116
- const systemRect = RectExtensions.fromElement(element);
2117
- const position = Point.fromPoint(systemRect).elementTransform(this.flowHost).sub(this.transform.scaledPosition).sub(this.transform.position).div(this.transform.scale);
2118
- const size = SizeExtensions.initialize(systemRect.width / this.transform.scale, systemRect.height / this.transform.scale);
2119
- const result = RectExtensions.initialize(position.x, position.y, size.width, size.height);
2120
- return result;
2121
- }
2122
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetElementRectInFlowHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2123
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetElementRectInFlowHandler }); }
2124
- }
2125
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetElementRectInFlowHandler, decorators: [{
2126
- type: Injectable
2127
- }], ctorParameters: () => [{ type: FComponentsStore }] });
2128
-
2129
2159
  class GetIncomingConnectionsHandler {
2130
2160
  get fConnections() {
2131
2161
  return this.fComponentsStore.fConnections;
@@ -2186,26 +2216,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
2186
2216
  type: Injectable
2187
2217
  }], ctorParameters: () => [{ type: FComponentsStore }, { type: GetElementRectInFlowHandler }] });
2188
2218
 
2189
- class GetOutputRectInFlowHandler {
2190
- constructor(fComponentsStore, getElementRectInFlowHandler) {
2191
- this.fComponentsStore = fComponentsStore;
2192
- this.getElementRectInFlowHandler = getElementRectInFlowHandler;
2193
- }
2194
- handle(outputId) {
2195
- const output = this.fComponentsStore.fOutputs.find((x) => x.id === outputId);
2196
- if (!output) {
2197
- throw OutputNotFound(outputId);
2198
- }
2199
- const result = this.getElementRectInFlowHandler.handle(output.hostElement);
2200
- return { rect: result, fConnectableSide: output.fConnectableSide };
2201
- }
2202
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutputRectInFlowHandler, deps: [{ token: FComponentsStore }, { token: GetElementRectInFlowHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2203
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutputRectInFlowHandler }); }
2204
- }
2205
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutputRectInFlowHandler, decorators: [{
2206
- type: Injectable
2207
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: GetElementRectInFlowHandler }] });
2208
-
2209
2219
  class UpdateNodeLayerHandler {
2210
2220
  get fNodesContainer() {
2211
2221
  return this.fComponentsStore.fCanvas?.fNodesContainer?.nativeElement;
@@ -2307,11 +2317,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
2307
2317
  }], ctorParameters: () => [{ type: FComponentsStore }] });
2308
2318
 
2309
2319
  const COMMON_PROVIDERS = [
2310
- GetAllNodesRectHandler,
2311
2320
  GetConnectionVectorHandler,
2321
+ GetOutputRectInFlowHandler,
2322
+ RedrawConnectionsHandler,
2323
+ GetAllNodesRectHandler,
2312
2324
  GetConnectionHandler,
2313
2325
  GetElementRectInFlowHandler,
2314
- GetOutputRectInFlowHandler,
2315
2326
  GetInputRectInFlowHandler,
2316
2327
  GetIncomingConnectionsHandler,
2317
2328
  GetOutgoingConnectionsHandler,
@@ -2493,942 +2504,644 @@ const CANVAS_PROVIDERS = [
2493
2504
  CanvasPrepareDragSequence
2494
2505
  ];
2495
2506
 
2496
- const F_EXTERNAL_ITEM = new InjectionToken('F_EXTERNAL_ITEM');
2497
- class FExternalItemBase {
2498
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
2499
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FExternalItemBase, ngImport: i0 }); }
2500
- }
2501
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemBase, decorators: [{
2502
- type: Directive
2503
- }] });
2504
-
2505
- function isExternalItem(element) {
2506
- return !!element.closest('[fExternalItem]');
2507
- }
2508
- function getExternalItem(element) {
2509
- return element.closest('[fExternalItem]');
2510
- }
2511
-
2512
- class FExternalItemService {
2513
- constructor() {
2514
- this.items = [];
2507
+ class FindFirstCanBeConnectedOutputByOutletHandler {
2508
+ get fNodes() {
2509
+ return this.fComponentsStore.fNodes;
2515
2510
  }
2516
- registerItem(item) {
2517
- this.items.push(item);
2511
+ get fOutputs() {
2512
+ return this.fComponentsStore.fOutputs;
2518
2513
  }
2519
- getItem(element) {
2520
- return this.items.find(item => item.hostElement === element);
2514
+ constructor(fComponentsStore) {
2515
+ this.fComponentsStore = fComponentsStore;
2521
2516
  }
2522
- removeItem(item) {
2523
- const index = this.items.indexOf(item);
2524
- if (index !== -1) {
2525
- this.items.splice(index, 1);
2517
+ handle(outlet) {
2518
+ let result;
2519
+ const node = this.fNodes.find((x) => x.isContains(outlet.hostElement));
2520
+ if (!node) {
2521
+ throw new Error('Node not found');
2522
+ }
2523
+ const outputsOfNode = this.fOutputs.filter((x) => {
2524
+ return node.isContains(x.hostElement) && x.canBeConnected;
2525
+ });
2526
+ if (outputsOfNode.length > 0) {
2527
+ result = outputsOfNode[0];
2526
2528
  }
2529
+ return result;
2527
2530
  }
2528
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2529
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemService, providedIn: 'root' }); }
2531
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindFirstCanBeConnectedOutputByOutletHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2532
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindFirstCanBeConnectedOutputByOutletHandler }); }
2530
2533
  }
2531
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemService, decorators: [{
2532
- type: Injectable,
2533
- args: [{
2534
- providedIn: 'root'
2535
- }]
2536
- }] });
2537
-
2538
- let uniqueId$1 = 0;
2539
- class FExternalItemDirective extends FExternalItemBase {
2540
- get hostElement() {
2541
- return this.elementReference.nativeElement;
2534
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindFirstCanBeConnectedOutputByOutletHandler, decorators: [{
2535
+ type: Injectable
2536
+ }], ctorParameters: () => [{ type: FComponentsStore }] });
2537
+
2538
+ class CreateConnectionDragHandler {
2539
+ constructor(fMediator, connection, mouseDownPoint) {
2540
+ this.fMediator = fMediator;
2541
+ this.connection = connection;
2542
+ this.mouseDownPoint = mouseDownPoint;
2543
+ this.type = EFDraggableType.CREATE_CONNECTION;
2544
+ this.onPointerDownFromConnectorRect = RectExtensions.initialize();
2545
+ this.onPointerDownToConnectorRect = RectExtensions.initialize();
2546
+ this.outputSide = EFConnectableSide.BOTTOM;
2542
2547
  }
2543
- constructor(elementReference, fExternalItemService) {
2544
- super();
2545
- this.elementReference = elementReference;
2546
- this.fExternalItemService = fExternalItemService;
2547
- this.id = `f-external-item-${uniqueId$1++}`;
2548
+ initialize() {
2549
+ const outputRect = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
2550
+ this.outputSide = outputRect.fConnectableSide;
2551
+ this.onPointerDownFromConnectorRect = outputRect.rect;
2552
+ this.onPointerDownToConnectorRect = RectExtensions.initialize(this.mouseDownPoint.x, this.mouseDownPoint.y, 0, 0);
2553
+ this.connection.show();
2554
+ this.move(new Point(0, 0));
2548
2555
  }
2549
- ngOnInit() {
2550
- this.fExternalItemService.registerItem(this);
2556
+ move(difference) {
2557
+ const toPoint = RectExtensions.addPoint(this.onPointerDownToConnectorRect, difference);
2558
+ const vector = this.fMediator.send(new GetConnectionVectorRequest(this.onPointerDownFromConnectorRect, toPoint, this.connection.fBehavior, this.outputSide, EFConnectableSide.TOP));
2559
+ this.connection.setVector(vector.point1, this.outputSide, vector.point2, EFConnectableSide.TOP);
2560
+ this.connection.redraw();
2551
2561
  }
2552
- ngOnDestroy() {
2553
- this.fExternalItemService.removeItem(this);
2562
+ complete() {
2563
+ this.connection.redraw();
2564
+ this.connection.hide();
2554
2565
  }
2555
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemDirective, deps: [{ token: i0.ElementRef }, { token: FExternalItemService }], target: i0.ɵɵFactoryTarget.Directive }); }
2556
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FExternalItemDirective, selector: "[fExternalItem]", inputs: { id: "id", data: "data" }, host: { properties: { "attr.id": "id" }, classAttribute: "f-component f-external-item" }, providers: [
2557
- { provide: F_EXTERNAL_ITEM, useExisting: FExternalItemDirective }
2558
- ], usesInheritance: true, ngImport: i0 }); }
2559
2566
  }
2560
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemDirective, decorators: [{
2561
- type: Directive,
2562
- args: [{
2563
- selector: "[fExternalItem]",
2564
- host: {
2565
- '[attr.id]': 'id',
2566
- class: "f-component f-external-item",
2567
- },
2568
- providers: [
2569
- { provide: F_EXTERNAL_ITEM, useExisting: FExternalItemDirective }
2570
- ],
2571
- }]
2572
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FExternalItemService }], propDecorators: { id: [{
2573
- type: Input
2574
- }], data: [{
2575
- type: Input
2576
- }] } });
2577
2567
 
2578
- class LineElement {
2579
- constructor(hostElement) {
2580
- this.hostElement = hostElement;
2581
- this.element = DomElementExtensions.createHtmlElement('div');
2582
- this.hostElement.appendChild(this.element);
2583
- this.element.classList.add('f-line');
2568
+ class FCreateConnectionEvent {
2569
+ constructor(fOutputId, fInputId) {
2570
+ this.fOutputId = fOutputId;
2571
+ this.fInputId = fInputId;
2584
2572
  }
2585
- hide() {
2586
- this.element.style.display = 'none';
2573
+ }
2574
+
2575
+ class FirstNotConnectedInputOfNodeUnderPointerHandler {
2576
+ get fNodes() {
2577
+ return this.fComponentsStore.fNodes;
2587
2578
  }
2588
- show() {
2589
- this.element.style.display = 'block';
2579
+ get fInputs() {
2580
+ return this.fComponentsStore.fInputs;
2590
2581
  }
2591
- draw(object) {
2592
- this.element.style.position = 'absolute';
2593
- Object.keys(object).forEach((key) => {
2594
- // @ts-ignore
2595
- this.element.style[key] = object[key] + 'px';
2582
+ constructor(fComponentsStore) {
2583
+ this.fComponentsStore = fComponentsStore;
2584
+ }
2585
+ handle(event) {
2586
+ const position = event.getPosition();
2587
+ const elementsFromPoint = document.elementsFromPoint(position.x, position.y);
2588
+ const nodes = elementsFromPoint.map((element) => {
2589
+ return this.fNodes.find((x) => x.isContains(element));
2590
+ }).filter((x) => !!x);
2591
+ const inputs = nodes.map((x) => {
2592
+ return this.fInputs.filter((i) => x.isContains(i.hostElement)).find((i) => {
2593
+ return !i.isConnected && i.canBeConnected;
2594
+ });
2596
2595
  });
2596
+ const result = inputs.find((x) => !!x);
2597
+ return result;
2597
2598
  }
2599
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FirstNotConnectedInputOfNodeUnderPointerHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2600
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FirstNotConnectedInputOfNodeUnderPointerHandler }); }
2598
2601
  }
2602
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FirstNotConnectedInputOfNodeUnderPointerHandler, decorators: [{
2603
+ type: Injectable
2604
+ }], ctorParameters: () => [{ type: FComponentsStore }] });
2599
2605
 
2600
- class LineService {
2601
- constructor(hostElement) {
2602
- this.hostElement = hostElement;
2603
- this.fHorizontalLine = new LineElement(this.hostElement);
2604
- this.fVerticalLine = new LineElement(this.hostElement);
2606
+ class InputsUnderPointerHandler {
2607
+ get fInputs() {
2608
+ return this.fComponentsStore.fInputs;
2605
2609
  }
2606
- drawVerticalLine(x, size, transform) {
2607
- this.fVerticalLine.show();
2608
- this.fVerticalLine.draw({
2609
- left: x * transform.scale + transform.position.x + transform.scaledPosition.x,
2610
- top: 0,
2611
- width: 1,
2612
- height: size.height
2613
- });
2610
+ constructor(fComponentsStore) {
2611
+ this.fComponentsStore = fComponentsStore;
2614
2612
  }
2615
- drawHorizontalLine(y, size, transform) {
2616
- this.fHorizontalLine.show();
2617
- this.fHorizontalLine.draw({
2618
- left: 0,
2619
- top: y * transform.scale + transform.position.y + transform.scaledPosition.y,
2620
- width: size.width,
2621
- height: 1
2622
- });
2613
+ handle(event) {
2614
+ const position = event.getPosition();
2615
+ const elementsFromPoint = document.elementsFromPoint(position.x, position.y);
2616
+ return elementsFromPoint.filter((x) => isNodeInput(x)).map((element) => {
2617
+ return this.fInputs.find((x) => x.isContains(element));
2618
+ }).filter((x) => !!x);
2623
2619
  }
2624
- hideVerticalLine() {
2625
- this.fVerticalLine.hide();
2620
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: InputsUnderPointerHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2621
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: InputsUnderPointerHandler }); }
2622
+ }
2623
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: InputsUnderPointerHandler, decorators: [{
2624
+ type: Injectable
2625
+ }], ctorParameters: () => [{ type: FComponentsStore }] });
2626
+
2627
+ class FindInputsUnderPointerRequest {
2628
+ constructor(event, dragHandler) {
2629
+ this.event = event;
2630
+ this.dragHandler = dragHandler;
2626
2631
  }
2627
- hideHorizontalLine() {
2628
- this.fHorizontalLine.hide();
2632
+ }
2633
+
2634
+ class FindInputsUnderPointerHandler {
2635
+ get fNodes() {
2636
+ return this.fComponentsStore.fNodes;
2637
+ }
2638
+ constructor(fComponentsStore, inputsUnderPointerHandler, firstNotConnectedInputOfNodeUnderPointerHandler) {
2639
+ this.fComponentsStore = fComponentsStore;
2640
+ this.inputsUnderPointerHandler = inputsUnderPointerHandler;
2641
+ this.firstNotConnectedInputOfNodeUnderPointerHandler = firstNotConnectedInputOfNodeUnderPointerHandler;
2642
+ }
2643
+ handle(payload) {
2644
+ const inputsUnderPointer = this.getInputsUnderPointer(payload);
2645
+ const output = this.fComponentsStore.fOutputs.find((x) => x.id === payload.dragHandler.connection.fOutputId);
2646
+ if (!output) {
2647
+ throw OutputNotFound(payload.dragHandler.connection.fOutputId);
2648
+ }
2649
+ return inputsUnderPointer.filter((x) => {
2650
+ const targetNode = this.fNodes.find((y) => y.isContains(x.hostElement));
2651
+ const sourceNode = this.fNodes.find((y) => y.isContains(output.hostElement));
2652
+ return sourceNode?.hostElement !== targetNode?.hostElement;
2653
+ });
2654
+ }
2655
+ getInputsUnderPointer(payload) {
2656
+ let inputs = this.inputsUnderPointerHandler.handle(payload.event);
2657
+ const input = this.firstNotConnectedInputOfNodeUnderPointerHandler.handle(payload.event);
2658
+ if (input) {
2659
+ inputs.push(input);
2660
+ }
2661
+ inputs = inputs.filter((x) => x.canBeConnected);
2662
+ return inputs;
2629
2663
  }
2664
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindInputsUnderPointerHandler, deps: [{ token: FComponentsStore }, { token: InputsUnderPointerHandler }, { token: FirstNotConnectedInputOfNodeUnderPointerHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2665
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindInputsUnderPointerHandler }); }
2630
2666
  }
2667
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindInputsUnderPointerHandler, decorators: [{
2668
+ type: Injectable
2669
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: InputsUnderPointerHandler }, { type: FirstNotConnectedInputOfNodeUnderPointerHandler }] });
2631
2670
 
2632
- const ALIGN_THRESHOLD = 10;
2633
- /**
2634
- * A class to find the nearest coordinate.
2635
- */
2636
- class NearestCoordinateFinder {
2637
- /**
2638
- * Constructor to initialize the NearestCoordinateFinder.
2639
- * @param elements - The array of IRect elements.
2640
- * @param target - The target IRect element.
2641
- */
2642
- constructor(elements, target) {
2643
- this.elements = elements;
2644
- this.target = target;
2671
+ class CreateConnectionOnPointerUp {
2672
+ constructor(fComponentsStore, fDraggableDataContext, findInputsUnderPointerHandler, findFirstCanBeConnectedOutputByOutletHandler) {
2673
+ this.fComponentsStore = fComponentsStore;
2674
+ this.fDraggableDataContext = fDraggableDataContext;
2675
+ this.findInputsUnderPointerHandler = findInputsUnderPointerHandler;
2676
+ this.findFirstCanBeConnectedOutputByOutletHandler = findFirstCanBeConnectedOutputByOutletHandler;
2645
2677
  }
2646
- /**
2647
- * Finds the nearest coordinate on a specified axis.
2648
- * @returns The nearest coordinate and its distance.
2649
- */
2650
- findNearestCoordinateByX() {
2651
- let nearest;
2652
- let minDistance;
2653
- for (const element of this.elements) {
2654
- const distanceLeftLeft = this.target.x - element.x;
2655
- const distanceLeftRight = this.target.x - (element.x + element.width);
2656
- const distanceCenterCenter = this.target.gravityCenter.x - element.gravityCenter.x;
2657
- const distanceRightLeft = (this.target.x + this.target.width) - element.x;
2658
- const distanceRightRight = (this.target.x + this.target.width) - (element.x + element.width);
2659
- if (Math.abs(distanceLeftLeft) <= ALIGN_THRESHOLD ||
2660
- Math.abs(distanceLeftRight) <= ALIGN_THRESHOLD ||
2661
- Math.abs(distanceCenterCenter) <= ALIGN_THRESHOLD ||
2662
- Math.abs(distanceRightLeft) <= ALIGN_THRESHOLD ||
2663
- Math.abs(distanceRightRight) <= ALIGN_THRESHOLD) {
2664
- if (minDistance === undefined || Math.abs(distanceCenterCenter) < Math.abs(minDistance)) {
2665
- minDistance = distanceCenterCenter;
2666
- nearest = element.gravityCenter.x;
2667
- }
2668
- if (Math.abs(distanceLeftLeft) < Math.abs(minDistance)) {
2669
- minDistance = distanceLeftLeft;
2670
- nearest = element.x;
2671
- }
2672
- if (Math.abs(distanceRightRight) < Math.abs(minDistance)) {
2673
- minDistance = distanceRightRight;
2674
- nearest = element.x + element.width;
2678
+ handle(event) {
2679
+ const isCreateConnection = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.CREATE_CONNECTION);
2680
+ if (isCreateConnection) {
2681
+ const handler = this.fDraggableDataContext.draggableItems[0];
2682
+ const inputsUnderPointer = this.findInputsUnderPointerHandler.handle(new FindInputsUnderPointerRequest(event, handler));
2683
+ if (inputsUnderPointer.length > 0) {
2684
+ let output = this.fComponentsStore.fOutputs.find((x) => x.id === handler.connection.fOutputId);
2685
+ if (!output) {
2686
+ output = this.fComponentsStore.fOutlets.find((x) => x.id === handler.connection.fOutputId);
2675
2687
  }
2676
- if (Math.abs(distanceLeftRight) < Math.abs(minDistance)) {
2677
- minDistance = distanceLeftRight;
2678
- nearest = element.x + element.width;
2688
+ if (!output) {
2689
+ throw OutputNotFound(handler.connection.fOutputId);
2679
2690
  }
2680
- if (Math.abs(distanceRightLeft) < Math.abs(minDistance)) {
2681
- minDistance = distanceRightLeft;
2682
- nearest = element.x;
2691
+ const isOutlet = isNodeOutlet(output.hostElement);
2692
+ if (isOutlet) {
2693
+ output = this.findFirstCanBeConnectedOutputByOutletHandler.handle(output);
2694
+ if (!output) {
2695
+ throw requiredOutput();
2696
+ }
2683
2697
  }
2698
+ this.fComponentsStore.fDraggable?.fCreateConnection.emit(new FCreateConnectionEvent(output.id, inputsUnderPointer[0]?.id));
2684
2699
  }
2700
+ handler.complete();
2685
2701
  }
2686
- return { value: nearest, distance: minDistance };
2687
2702
  }
2688
- /**
2689
- * Finds the nearest coordinate on a specified axis.
2690
- * @returns The nearest coordinate and its distance.
2691
- */
2692
- findNearestCoordinateByY() {
2693
- let nearest;
2694
- let minDistance;
2695
- for (const element of this.elements) {
2696
- const distanceTopTop = this.target.y - element.y;
2697
- const distanceTopBottom = this.target.y - (element.y + element.height);
2698
- const distanceCenterCenter = this.target.gravityCenter.y - element.gravityCenter.y;
2699
- const distanceBottomTop = (this.target.y + this.target.height) - element.y;
2700
- const distanceBottomBottom = (this.target.y + this.target.height) - (element.y + element.height);
2701
- if (Math.abs(distanceTopTop) <= ALIGN_THRESHOLD ||
2702
- Math.abs(distanceTopBottom) <= ALIGN_THRESHOLD ||
2703
- Math.abs(distanceCenterCenter) <= ALIGN_THRESHOLD ||
2704
- Math.abs(distanceBottomTop) <= ALIGN_THRESHOLD ||
2705
- Math.abs(distanceBottomBottom) <= ALIGN_THRESHOLD) {
2706
- if (minDistance === undefined || Math.abs(distanceCenterCenter) < Math.abs(minDistance)) {
2707
- minDistance = distanceCenterCenter;
2708
- nearest = element.gravityCenter.y;
2709
- }
2710
- if (Math.abs(distanceTopTop) < Math.abs(minDistance)) {
2711
- minDistance = distanceTopTop;
2712
- nearest = element.y;
2713
- }
2714
- if (Math.abs(distanceBottomBottom) < Math.abs(minDistance)) {
2715
- minDistance = distanceBottomBottom;
2716
- nearest = element.y + element.height;
2717
- }
2718
- if (Math.abs(distanceTopBottom) < Math.abs(minDistance)) {
2719
- minDistance = distanceTopBottom;
2720
- nearest = element.y + element.height;
2721
- }
2722
- if (Math.abs(distanceBottomTop) < Math.abs(minDistance)) {
2723
- minDistance = distanceBottomTop;
2724
- nearest = element.y;
2725
- }
2726
- }
2727
- }
2728
- return { value: nearest, distance: minDistance };
2729
- }
2730
- }
2731
-
2732
- const F_LINE_ALIGNMENT = new InjectionToken('F_LINE_ALIGNMENT');
2733
- class FLineAlignmentBase {
2734
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FLineAlignmentBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
2735
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FLineAlignmentBase, ngImport: i0 }); }
2703
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionOnPointerUp, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FindInputsUnderPointerHandler }, { token: FindFirstCanBeConnectedOutputByOutletHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2704
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionOnPointerUp }); }
2736
2705
  }
2737
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FLineAlignmentBase, decorators: [{
2738
- type: Directive
2739
- }] });
2706
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionOnPointerUp, decorators: [{
2707
+ type: Injectable
2708
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FindInputsUnderPointerHandler }, { type: FindFirstCanBeConnectedOutputByOutletHandler }] });
2740
2709
 
2741
- class FLineAlignmentComponent extends FLineAlignmentBase {
2742
- get hostElement() {
2743
- return this.elementReference.nativeElement;
2744
- }
2710
+ class CreateConnectionPrepareDragSequence {
2745
2711
  get transform() {
2746
2712
  return this.fComponentsStore.fCanvas.transform;
2747
2713
  }
2748
2714
  get flowHost() {
2749
2715
  return this.fComponentsStore.fFlow.hostElement;
2750
2716
  }
2751
- constructor(elementReference, fComponentsStore, fDraggableDataContext, getElementRectInFlowHandler) {
2752
- super();
2753
- this.elementReference = elementReference;
2717
+ constructor(fComponentsStore, fDraggableDataContext, getElementRectInFlowHandler, fMediator, findFirstCanBeConnectedOutputByOutletHandler) {
2754
2718
  this.fComponentsStore = fComponentsStore;
2755
2719
  this.fDraggableDataContext = fDraggableDataContext;
2756
2720
  this.getElementRectInFlowHandler = getElementRectInFlowHandler;
2757
- this.size = SizeExtensions.initialize();
2758
- this.draggedNodeRect = RectExtensions.initialize();
2759
- this.rects = [];
2760
- this.lineService = new LineService(this.hostElement);
2761
- }
2762
- ngOnInit() {
2763
- this.fDraggableDataContext.fLineAlignment = this;
2764
- }
2765
- initialize(allNodes, currentNodes) {
2766
- this.size = this.flowHost.getBoundingClientRect();
2767
- this.rects = [];
2768
- const draggedNodeRects = currentNodes.map((x) => {
2769
- return this.getElementRectInFlowHandler.handle(x.hostElement);
2770
- });
2771
- this.draggedNodeRect = RectExtensions.union(draggedNodeRects);
2772
- const allNodesExcludeCurrents = allNodes.filter((x) => {
2773
- return !currentNodes.includes(x);
2774
- });
2775
- this.rects = allNodesExcludeCurrents.map((x) => {
2776
- return this.getElementRectInFlowHandler.handle(x.hostElement);
2777
- });
2778
- }
2779
- handle(difference) {
2780
- this.drawIntersectingLines(difference);
2721
+ this.fMediator = fMediator;
2722
+ this.findFirstCanBeConnectedOutputByOutletHandler = findFirstCanBeConnectedOutputByOutletHandler;
2781
2723
  }
2782
- drawIntersectingLines(difference) {
2783
- const intersect = this.findNearestCoordinate(difference);
2784
- if (intersect.xResult.value !== undefined) {
2785
- this.lineService.drawVerticalLine(intersect.xResult.value, this.size, this.transform);
2786
- }
2787
- else {
2788
- this.lineService.hideVerticalLine();
2724
+ handle(event) {
2725
+ const node = this.fComponentsStore.findNode(event.targetElement);
2726
+ const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
2727
+ if (!node || this.fDraggableDataContext.draggableItems.length || !this.fComponentsStore.fTempConnection) {
2728
+ return;
2789
2729
  }
2790
- if (intersect.yResult.value !== undefined) {
2791
- this.lineService.drawHorizontalLine(intersect.yResult.value, this.size, this.transform);
2730
+ if (isNodeOutlet(event.targetElement)) {
2731
+ const outlet = this.fComponentsStore.fOutlets.find((x) => {
2732
+ return x.hostElement.contains(event.targetElement);
2733
+ });
2734
+ if (!outlet) {
2735
+ throw new Error('Outlet not found');
2736
+ }
2737
+ const nodeOutputs = this.fComponentsStore.fOutputs.filter((x) => node.isContains(x.hostElement));
2738
+ outlet.setOutputs(nodeOutputs);
2739
+ if (outlet.canBeConnected) {
2740
+ const outletCenter = this.getElementRectInFlowHandler.handle(outlet.hostElement).gravityCenter;
2741
+ if (outlet.isConnectionFromOutlet) {
2742
+ this.createConnectionHandler(pointerPositionInFlow, outlet, outletCenter);
2743
+ }
2744
+ else {
2745
+ const output = this.findFirstCanBeConnectedOutputByOutletHandler.handle(outlet);
2746
+ if (!output) {
2747
+ throw new Error('Output not found');
2748
+ }
2749
+ this.createConnectionHandler(pointerPositionInFlow, output, outletCenter);
2750
+ }
2751
+ }
2792
2752
  }
2793
- else {
2794
- this.lineService.hideHorizontalLine();
2753
+ else if (this.isNodeOutput(event.targetElement, node)) {
2754
+ const output = this.fComponentsStore.fOutputs.find((x) => {
2755
+ return x.hostElement.contains(event.targetElement);
2756
+ });
2757
+ if (!output) {
2758
+ throw new Error('Output not found');
2759
+ }
2760
+ if (output.canBeConnected) {
2761
+ const outputCenter = this.getElementRectInFlowHandler.handle(output.hostElement).gravityCenter;
2762
+ this.createConnectionHandler(pointerPositionInFlow, output, outputCenter);
2763
+ }
2795
2764
  }
2796
2765
  }
2797
- findNearestCoordinate(difference) {
2798
- const rect = RectExtensions.addPoint(this.draggedNodeRect, difference);
2799
- const finder = new NearestCoordinateFinder(this.rects, rect);
2800
- const xResult = finder.findNearestCoordinateByX();
2801
- const yResult = finder.findNearestCoordinateByY();
2802
- const result = { xResult, yResult };
2803
- return result;
2766
+ createConnectionHandler(pointerPositionInCanvas, output, outputCenter) {
2767
+ this.fComponentsStore.fTempConnection.fOutputId = output.id;
2768
+ this.fComponentsStore.fTempConnection.initialize();
2769
+ this.fDraggableDataContext.onPointerDownScale = this.transform.scale;
2770
+ this.fDraggableDataContext.onPointerDownPosition = pointerPositionInCanvas.div(this.transform.scale);
2771
+ this.fDraggableDataContext.draggableItems = [
2772
+ new CreateConnectionDragHandler(this.fMediator, this.fComponentsStore.fTempConnection, outputCenter)
2773
+ ];
2804
2774
  }
2805
- complete() {
2806
- this.lineService.hideVerticalLine();
2807
- this.lineService.hideHorizontalLine();
2775
+ isNodeOutput(targetElement, node) {
2776
+ const outlets = this.fComponentsStore.fOutlets.filter((x) => node.isContains(x.hostElement));
2777
+ return isNodeOutput(targetElement) && !outlets.length;
2808
2778
  }
2809
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FLineAlignmentComponent, deps: [{ token: i0.ElementRef }, { token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetElementRectInFlowHandler }], target: i0.ɵɵFactoryTarget.Component }); }
2810
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.1", type: FLineAlignmentComponent, selector: "f-line-alignment", host: { classAttribute: "f-line-alignment f-component" }, providers: [
2811
- { provide: F_LINE_ALIGNMENT, useExisting: FLineAlignmentComponent }
2812
- ], exportAs: ["fComponent"], usesInheritance: true, ngImport: i0, template: "", isInline: true, styles: [":host{display:block;position:absolute;left:0;top:0;width:100%;height:100%;overflow:hidden;pointer-events:none;-webkit-user-select:none;user-select:none}\n"] }); }
2813
- }
2814
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FLineAlignmentComponent, decorators: [{
2815
- type: Component,
2816
- args: [{ selector: "f-line-alignment", template: "", exportAs: "fComponent", host: {
2817
- 'class': 'f-line-alignment f-component'
2818
- }, providers: [
2819
- { provide: F_LINE_ALIGNMENT, useExisting: FLineAlignmentComponent }
2820
- ], styles: [":host{display:block;position:absolute;left:0;top:0;width:100%;height:100%;overflow:hidden;pointer-events:none;-webkit-user-select:none;user-select:none}\n"] }]
2821
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetElementRectInFlowHandler }] });
2822
-
2823
- const F_SELECTION_AREA = new InjectionToken('F_SELECTION_AREA');
2824
- class FSelectionAreaBase {
2825
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FSelectionAreaBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
2826
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FSelectionAreaBase, ngImport: i0 }); }
2779
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetElementRectInFlowHandler }, { token: FFlowMediator }, { token: FindFirstCanBeConnectedOutputByOutletHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2780
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionPrepareDragSequence }); }
2827
2781
  }
2828
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FSelectionAreaBase, decorators: [{
2829
- type: Directive
2830
- }] });
2782
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionPrepareDragSequence, decorators: [{
2783
+ type: Injectable
2784
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetElementRectInFlowHandler }, { type: FFlowMediator }, { type: FindFirstCanBeConnectedOutputByOutletHandler }] });
2831
2785
 
2832
- class FSelectionAreaComponent extends FSelectionAreaBase {
2833
- get hostElement() {
2834
- return this.elementReference.nativeElement;
2835
- }
2836
- constructor(elementReference, fDraggableDataContext) {
2837
- super();
2838
- this.elementReference = elementReference;
2839
- this.fDraggableDataContext = fDraggableDataContext;
2840
- }
2841
- ngOnInit() {
2842
- this.fDraggableDataContext.fSelectionArea = this;
2843
- this.hostElement.style.display = 'none';
2786
+ class ReassignConnectionDragHandler {
2787
+ constructor(getInputRectInFlowHandler, fMediator, connection) {
2788
+ this.getInputRectInFlowHandler = getInputRectInFlowHandler;
2789
+ this.fMediator = fMediator;
2790
+ this.connection = connection;
2791
+ this.type = EFDraggableType.REASSIGN_CONNECTION;
2792
+ this.onPointerDownFromConnectorRect = RectExtensions.initialize();
2793
+ this.onPointerDownToConnectorRect = RectExtensions.initialize();
2794
+ this.outputSide = EFConnectableSide.BOTTOM;
2795
+ this.inputSide = EFConnectableSide.TOP;
2844
2796
  }
2845
- hide() {
2846
- this.hostElement.style.display = 'none';
2797
+ initialize() {
2798
+ const fromConnector = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
2799
+ this.inputSide = this.getInputRectInFlowHandler.handle(this.connection.fInputId).fConnectableSide;
2800
+ this.outputSide = fromConnector.fConnectableSide;
2801
+ this.onPointerDownFromConnectorRect = fromConnector.rect;
2802
+ this.onPointerDownToConnectorRect = RectExtensions.initialize(this.connection.vector.point2.x, this.connection.vector.point2.y, 0, 0);
2847
2803
  }
2848
- show() {
2849
- this.hostElement.style.display = 'block';
2804
+ move(difference) {
2805
+ const toRect = RectExtensions.addPoint(this.onPointerDownToConnectorRect, difference);
2806
+ const vector = this.fMediator.send(new GetConnectionVectorRequest(this.onPointerDownFromConnectorRect, toRect, this.connection.fBehavior, this.outputSide, this.inputSide));
2807
+ this.connection.setVector(vector.point1, this.outputSide, vector.point2, this.inputSide);
2808
+ this.connection.redraw();
2850
2809
  }
2851
- draw(object) {
2852
- const style = this.hostElement.style;
2853
- style.left = object.left + 'px';
2854
- style.top = object.top + 'px';
2855
- style.width = object.width + 'px';
2856
- style.height = object.height + 'px';
2810
+ complete() {
2811
+ const fromConnector = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
2812
+ const toConnector = this.getInputRectInFlowHandler.handle(this.connection.fInputId);
2813
+ const vector = this.fMediator.send(new GetConnectionVectorRequest(fromConnector.rect, toConnector.rect, this.connection.fBehavior, fromConnector.fConnectableSide, toConnector.fConnectableSide));
2814
+ this.connection.setVector(vector.point1, fromConnector.fConnectableSide, vector.point2, toConnector.fConnectableSide);
2815
+ this.connection.redraw();
2857
2816
  }
2858
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FSelectionAreaComponent, deps: [{ token: i0.ElementRef }, { token: FDraggableDataContext }], target: i0.ɵɵFactoryTarget.Component }); }
2859
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.1", type: FSelectionAreaComponent, selector: "f-selection-area", host: { classAttribute: "f-selection-area f-component" }, providers: [
2860
- { provide: F_SELECTION_AREA, useExisting: FSelectionAreaComponent }
2861
- ], usesInheritance: true, ngImport: i0, template: ``, isInline: true, styles: [":host{position:absolute}\n"] }); }
2862
2817
  }
2863
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FSelectionAreaComponent, decorators: [{
2864
- type: Component,
2865
- args: [{ selector: "f-selection-area", template: ``, host: {
2866
- 'class': 'f-selection-area f-component'
2867
- }, providers: [
2868
- { provide: F_SELECTION_AREA, useExisting: FSelectionAreaComponent }
2869
- ], styles: [":host{position:absolute}\n"] }]
2870
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FDraggableDataContext }] });
2871
2818
 
2872
- class FindFirstCanBeConnectedOutputByOutletHandler {
2873
- get fNodes() {
2874
- return this.fComponentsStore.fNodes;
2819
+ class FReassignConnectionEvent {
2820
+ constructor(connectionId, fOutputId, oldFInputId, newFInputId) {
2821
+ this.connectionId = connectionId;
2822
+ this.fOutputId = fOutputId;
2823
+ this.oldFInputId = oldFInputId;
2824
+ this.newFInputId = newFInputId;
2875
2825
  }
2876
- get fOutputs() {
2877
- return this.fComponentsStore.fOutputs;
2826
+ }
2827
+
2828
+ class ReassignConnectionOnPointerUp {
2829
+ get fDraggable() {
2830
+ return this.fComponentsStore.fDraggable;
2878
2831
  }
2879
- constructor(fComponentsStore) {
2832
+ constructor(fComponentsStore, fDraggableDataContext, findInputsUnderPointerHandler) {
2880
2833
  this.fComponentsStore = fComponentsStore;
2834
+ this.fDraggableDataContext = fDraggableDataContext;
2835
+ this.findInputsUnderPointerHandler = findInputsUnderPointerHandler;
2881
2836
  }
2882
- handle(outlet) {
2883
- let result;
2884
- const node = this.fNodes.find((x) => x.isContains(outlet.hostElement));
2885
- if (!node) {
2886
- throw new Error('Node not found');
2887
- }
2888
- const outputsOfNode = this.fOutputs.filter((x) => {
2889
- return node.isContains(x.hostElement) && x.canBeConnected;
2890
- });
2891
- if (outputsOfNode.length > 0) {
2892
- result = outputsOfNode[0];
2837
+ handle(event) {
2838
+ const isReassignConnection = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.REASSIGN_CONNECTION);
2839
+ if (isReassignConnection) {
2840
+ const handler = this.fDraggableDataContext.draggableItems[0];
2841
+ const inputsUnderPointer = this.findInputsUnderPointerHandler.handle(new FindInputsUnderPointerRequest(event, handler));
2842
+ if (inputsUnderPointer.length > 0) {
2843
+ if (handler.connection.fInputId !== inputsUnderPointer[0]?.id) {
2844
+ this.fDraggable.fReassignConnection.emit(new FReassignConnectionEvent(handler.connection.fConnectionId, handler.connection.fOutputId, handler.connection.fInputId, inputsUnderPointer[0]?.id));
2845
+ }
2846
+ }
2847
+ handler.complete();
2893
2848
  }
2894
- return result;
2895
2849
  }
2896
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindFirstCanBeConnectedOutputByOutletHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2897
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindFirstCanBeConnectedOutputByOutletHandler }); }
2850
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionOnPointerUp, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FindInputsUnderPointerHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2851
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionOnPointerUp }); }
2898
2852
  }
2899
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindFirstCanBeConnectedOutputByOutletHandler, decorators: [{
2853
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionOnPointerUp, decorators: [{
2900
2854
  type: Injectable
2901
- }], ctorParameters: () => [{ type: FComponentsStore }] });
2855
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FindInputsUnderPointerHandler }] });
2902
2856
 
2903
- class CreateConnectionDragHandler {
2904
- constructor(getOutputRectInFlowHandler, getConnectionVectorHandler, connection, mouseDownPoint) {
2905
- this.getOutputRectInFlowHandler = getOutputRectInFlowHandler;
2906
- this.getConnectionVectorHandler = getConnectionVectorHandler;
2907
- this.connection = connection;
2908
- this.mouseDownPoint = mouseDownPoint;
2909
- this.type = EFDraggableType.CREATE_CONNECTION;
2910
- this.onPointerDownFromConnectorRect = RectExtensions.initialize();
2911
- this.onPointerDownToConnectorRect = RectExtensions.initialize();
2912
- this.outputSide = EFConnectableSide.BOTTOM;
2857
+ class ReassignConnectionPrepareDragSequence {
2858
+ get transform() {
2859
+ return this.fComponentsStore.fCanvas.transform;
2913
2860
  }
2914
- initialize() {
2915
- const outputRect = this.getOutputRectInFlowHandler.handle(this.connection.fOutputId);
2916
- this.outputSide = outputRect.fConnectableSide;
2917
- this.onPointerDownFromConnectorRect = outputRect.rect;
2918
- this.onPointerDownToConnectorRect = RectExtensions.initialize(this.mouseDownPoint.x, this.mouseDownPoint.y, 0, 0);
2919
- this.connection.show();
2920
- this.move(new Point(0, 0));
2861
+ get flowHost() {
2862
+ return this.fComponentsStore.fFlow.hostElement;
2921
2863
  }
2922
- move(difference) {
2923
- const toPoint = RectExtensions.addPoint(this.onPointerDownToConnectorRect, difference);
2924
- const vector = this.getConnectionVectorHandler.handle(new GetConnectionVectorRequest(this.onPointerDownFromConnectorRect, toPoint, this.connection.fBehavior, this.outputSide, EFConnectableSide.TOP));
2925
- this.connection.setVector(vector.point1, this.outputSide, vector.point2, EFConnectableSide.TOP);
2926
- this.connection.redraw();
2864
+ constructor(fComponentsStore, fDraggableDataContext, getConnectionHandler, getInputRectInFlowHandler, fMediator, updateConnectionLayerHandler) {
2865
+ this.fComponentsStore = fComponentsStore;
2866
+ this.fDraggableDataContext = fDraggableDataContext;
2867
+ this.getConnectionHandler = getConnectionHandler;
2868
+ this.getInputRectInFlowHandler = getInputRectInFlowHandler;
2869
+ this.fMediator = fMediator;
2870
+ this.updateConnectionLayerHandler = updateConnectionLayerHandler;
2927
2871
  }
2928
- complete() {
2929
- this.connection.redraw();
2930
- this.connection.hide();
2872
+ handle(event) {
2873
+ const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
2874
+ const position = event.getPosition();
2875
+ const allElements = document.elementsFromPoint(position.x, position.y);
2876
+ const dragHandlesOfConnections = allElements.filter((x) => {
2877
+ return !!this.getConnectionHandler.handle(x) && x.classList.contains(F_CONNECTION_DRAG_HANDLE_CLASS);
2878
+ });
2879
+ let connectionToReassign;
2880
+ if (dragHandlesOfConnections.length) {
2881
+ const connections = dragHandlesOfConnections.map((x) => this.getConnectionHandler.handle(x)).filter((x) => !x?.disabled);
2882
+ if (connections.length) {
2883
+ connectionToReassign = this.getConnectionHandler.handle(dragHandlesOfConnections[0]);
2884
+ }
2885
+ }
2886
+ if (connectionToReassign && !this.fDraggableDataContext.draggableItems.length) {
2887
+ this.updateConnectionLayerHandler.handle(connectionToReassign);
2888
+ this.fDraggableDataContext.onPointerDownScale = this.transform.scale;
2889
+ this.fDraggableDataContext.onPointerDownPosition = pointerPositionInFlow.div(this.transform.scale);
2890
+ this.fDraggableDataContext.draggableItems = [
2891
+ new ReassignConnectionDragHandler(this.getInputRectInFlowHandler, this.fMediator, connectionToReassign)
2892
+ ];
2893
+ }
2931
2894
  }
2895
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetConnectionHandler }, { token: GetInputRectInFlowHandler }, { token: FFlowMediator }, { token: UpdateConnectionLayerHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2896
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionPrepareDragSequence }); }
2932
2897
  }
2898
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionPrepareDragSequence, decorators: [{
2899
+ type: Injectable
2900
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetConnectionHandler }, { type: GetInputRectInFlowHandler }, { type: FFlowMediator }, { type: UpdateConnectionLayerHandler }] });
2933
2901
 
2934
- class CreateConnectionEvent {
2935
- constructor(outputId, inputId) {
2936
- this.outputId = outputId;
2937
- this.inputId = inputId;
2902
+ const CONNECTIONS_PROVIDERS = [
2903
+ FindFirstCanBeConnectedOutputByOutletHandler,
2904
+ CreateConnectionOnPointerUp,
2905
+ CreateConnectionPrepareDragSequence,
2906
+ FirstNotConnectedInputOfNodeUnderPointerHandler,
2907
+ InputsUnderPointerHandler,
2908
+ FindInputsUnderPointerHandler,
2909
+ ReassignConnectionOnPointerUp,
2910
+ ReassignConnectionPrepareDragSequence
2911
+ ];
2912
+
2913
+ class FCreateNodeEvent {
2914
+ constructor(rect, data) {
2915
+ this.rect = rect;
2916
+ this.data = data;
2938
2917
  }
2939
2918
  }
2940
2919
 
2941
- class FirstNotConnectedInputOfNodeUnderPointerHandler {
2942
- get fNodes() {
2943
- return this.fComponentsStore.fNodes;
2920
+ class ExternalItemDragHandler {
2921
+ constructor(externalItem) {
2922
+ this.externalItem = externalItem;
2923
+ this.type = EFDraggableType.PALETTE_ITEM;
2924
+ this.onPointerDownRect = RectExtensions.initialize();
2925
+ this.difference = PointExtensions.initialize();
2944
2926
  }
2945
- get fInputs() {
2946
- return this.fComponentsStore.fInputs;
2927
+ getStyle(position) {
2928
+ return `position: absolute; left: 0; top: 0; transform: translate(${position.x}px, ${position.y}px)`;
2947
2929
  }
2948
- constructor(fComponentsStore) {
2949
- this.fComponentsStore = fComponentsStore;
2930
+ initialize() {
2931
+ this.onPointerDownRect = this.getExternalItemRect();
2932
+ this.placeholder = DomElementExtensions.deepCloneNode(this.externalItem.hostElement);
2933
+ document.body.appendChild(this.placeholder);
2950
2934
  }
2951
- handle(event) {
2952
- const position = event.getPosition();
2953
- const elementsFromPoint = document.elementsFromPoint(position.x, position.y);
2954
- const nodes = elementsFromPoint.map((element) => {
2955
- return this.fNodes.find((x) => x.isContains(element));
2956
- }).filter((x) => !!x);
2957
- const inputs = nodes.map((x) => {
2958
- return this.fInputs.filter((i) => x.isContains(i.hostElement)).find((i) => {
2959
- return !i.isConnected && i.canBeConnected;
2960
- });
2961
- });
2962
- const result = inputs.find((x) => !!x);
2963
- return result;
2935
+ getExternalItemRect() {
2936
+ const rect = this.externalItem.hostElement.getBoundingClientRect();
2937
+ const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
2938
+ const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
2939
+ const offsetTop = rect.top + scrollTop;
2940
+ const offsetLeft = rect.left + scrollLeft;
2941
+ return RectExtensions.initialize(offsetLeft, offsetTop, rect.width, rect.height);
2964
2942
  }
2965
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FirstNotConnectedInputOfNodeUnderPointerHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2966
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FirstNotConnectedInputOfNodeUnderPointerHandler }); }
2967
- }
2968
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FirstNotConnectedInputOfNodeUnderPointerHandler, decorators: [{
2969
- type: Injectable
2970
- }], ctorParameters: () => [{ type: FComponentsStore }] });
2971
-
2972
- class InputsUnderPointerHandler {
2973
- get fInputs() {
2974
- return this.fComponentsStore.fInputs;
2943
+ move(difference) {
2944
+ this.difference = difference;
2945
+ const position = Point.fromPoint(this.onPointerDownRect).add(this.difference);
2946
+ this.placeholder.setAttribute('style', this.getStyle(position));
2975
2947
  }
2976
- constructor(fComponentsStore) {
2977
- this.fComponentsStore = fComponentsStore;
2948
+ getPlaceholderRect() {
2949
+ return RectExtensions.fromElement(this.placeholder);
2978
2950
  }
2979
- handle(event) {
2980
- const position = event.getPosition();
2981
- const elementsFromPoint = document.elementsFromPoint(position.x, position.y);
2982
- return elementsFromPoint.filter((x) => isNodeInput(x)).map((element) => {
2983
- return this.fInputs.find((x) => x.isContains(element));
2984
- }).filter((x) => !!x);
2951
+ complete() {
2952
+ document.body.removeChild(this.placeholder);
2985
2953
  }
2986
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: InputsUnderPointerHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2987
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: InputsUnderPointerHandler }); }
2988
2954
  }
2989
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: InputsUnderPointerHandler, decorators: [{
2990
- type: Injectable
2991
- }], ctorParameters: () => [{ type: FComponentsStore }] });
2992
2955
 
2993
- class FindInputsUnderPointerRequest {
2994
- constructor(event, dragHandler) {
2995
- this.event = event;
2996
- this.dragHandler = dragHandler;
2997
- }
2956
+ const F_EXTERNAL_ITEM = new InjectionToken('F_EXTERNAL_ITEM');
2957
+ class FExternalItemBase {
2958
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
2959
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FExternalItemBase, ngImport: i0 }); }
2960
+ }
2961
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemBase, decorators: [{
2962
+ type: Directive
2963
+ }] });
2964
+
2965
+ function isExternalItem(element) {
2966
+ return !!element.closest('[fExternalItem]');
2967
+ }
2968
+ function getExternalItem(element) {
2969
+ return element.closest('[fExternalItem]');
2998
2970
  }
2999
2971
 
3000
- class FindInputsUnderPointerHandler {
3001
- get fNodes() {
3002
- return this.fComponentsStore.fNodes;
2972
+ class FExternalItemService {
2973
+ constructor() {
2974
+ this.items = [];
3003
2975
  }
3004
- constructor(fComponentsStore, inputsUnderPointerHandler, firstNotConnectedInputOfNodeUnderPointerHandler) {
3005
- this.fComponentsStore = fComponentsStore;
3006
- this.inputsUnderPointerHandler = inputsUnderPointerHandler;
3007
- this.firstNotConnectedInputOfNodeUnderPointerHandler = firstNotConnectedInputOfNodeUnderPointerHandler;
2976
+ registerItem(item) {
2977
+ this.items.push(item);
3008
2978
  }
3009
- handle(payload) {
3010
- const inputsUnderPointer = this.getInputsUnderPointer(payload);
3011
- const output = this.fComponentsStore.fOutputs.find((x) => x.id === payload.dragHandler.connection.fOutputId);
3012
- if (!output) {
3013
- throw OutputNotFound(payload.dragHandler.connection.fOutputId);
3014
- }
3015
- return inputsUnderPointer.filter((x) => {
3016
- const targetNode = this.fNodes.find((y) => y.isContains(x.hostElement));
3017
- const sourceNode = this.fNodes.find((y) => y.isContains(output.hostElement));
3018
- return sourceNode?.hostElement !== targetNode?.hostElement;
3019
- });
2979
+ getItem(element) {
2980
+ return this.items.find(item => item.hostElement === element);
3020
2981
  }
3021
- getInputsUnderPointer(payload) {
3022
- let inputs = this.inputsUnderPointerHandler.handle(payload.event);
3023
- const input = this.firstNotConnectedInputOfNodeUnderPointerHandler.handle(payload.event);
3024
- if (input) {
3025
- inputs.push(input);
2982
+ removeItem(item) {
2983
+ const index = this.items.indexOf(item);
2984
+ if (index !== -1) {
2985
+ this.items.splice(index, 1);
3026
2986
  }
3027
- inputs = inputs.filter((x) => x.canBeConnected);
3028
- return inputs;
3029
2987
  }
3030
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindInputsUnderPointerHandler, deps: [{ token: FComponentsStore }, { token: InputsUnderPointerHandler }, { token: FirstNotConnectedInputOfNodeUnderPointerHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
3031
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindInputsUnderPointerHandler }); }
2988
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2989
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemService, providedIn: 'root' }); }
3032
2990
  }
3033
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindInputsUnderPointerHandler, decorators: [{
3034
- type: Injectable
3035
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: InputsUnderPointerHandler }, { type: FirstNotConnectedInputOfNodeUnderPointerHandler }] });
2991
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemService, decorators: [{
2992
+ type: Injectable,
2993
+ args: [{
2994
+ providedIn: 'root'
2995
+ }]
2996
+ }] });
3036
2997
 
3037
- class CreateConnectionOnPointerUp {
3038
- constructor(fComponentsStore, fDraggableDataContext, findInputsUnderPointerHandler, findFirstCanBeConnectedOutputByOutletHandler) {
3039
- this.fComponentsStore = fComponentsStore;
3040
- this.fDraggableDataContext = fDraggableDataContext;
3041
- this.findInputsUnderPointerHandler = findInputsUnderPointerHandler;
3042
- this.findFirstCanBeConnectedOutputByOutletHandler = findFirstCanBeConnectedOutputByOutletHandler;
2998
+ let uniqueId$1 = 0;
2999
+ class FExternalItemDirective extends FExternalItemBase {
3000
+ get hostElement() {
3001
+ return this.elementReference.nativeElement;
3043
3002
  }
3044
- handle(event) {
3045
- const isCreateConnection = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.CREATE_CONNECTION);
3046
- if (isCreateConnection) {
3047
- const handler = this.fDraggableDataContext.draggableItems[0];
3048
- const inputsUnderPointer = this.findInputsUnderPointerHandler.handle(new FindInputsUnderPointerRequest(event, handler));
3049
- if (inputsUnderPointer.length > 0) {
3050
- let output = this.fComponentsStore.fOutputs.find((x) => x.id === handler.connection.fOutputId);
3051
- if (!output) {
3052
- output = this.fComponentsStore.fOutlets.find((x) => x.id === handler.connection.fOutputId);
3053
- }
3054
- if (!output) {
3055
- throw OutputNotFound(handler.connection.fOutputId);
3056
- }
3057
- const isOutlet = isNodeOutlet(output.hostElement);
3058
- if (isOutlet) {
3059
- output = this.findFirstCanBeConnectedOutputByOutletHandler.handle(output);
3060
- if (!output) {
3061
- throw requiredOutput();
3062
- }
3063
- }
3064
- this.fComponentsStore.fDraggable?.fCreateConnection.emit(new CreateConnectionEvent(output.id, inputsUnderPointer[0]?.id));
3065
- }
3066
- handler.complete();
3067
- }
3003
+ constructor(elementReference, fExternalItemService) {
3004
+ super();
3005
+ this.elementReference = elementReference;
3006
+ this.fExternalItemService = fExternalItemService;
3007
+ this.id = `f-external-item-${uniqueId$1++}`;
3068
3008
  }
3069
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionOnPointerUp, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FindInputsUnderPointerHandler }, { token: FindFirstCanBeConnectedOutputByOutletHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
3070
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionOnPointerUp }); }
3009
+ ngOnInit() {
3010
+ this.fExternalItemService.registerItem(this);
3011
+ }
3012
+ ngOnDestroy() {
3013
+ this.fExternalItemService.removeItem(this);
3014
+ }
3015
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemDirective, deps: [{ token: i0.ElementRef }, { token: FExternalItemService }], target: i0.ɵɵFactoryTarget.Directive }); }
3016
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FExternalItemDirective, selector: "[fExternalItem]", inputs: { id: "id", data: "data" }, host: { properties: { "attr.id": "id" }, classAttribute: "f-component f-external-item" }, providers: [
3017
+ { provide: F_EXTERNAL_ITEM, useExisting: FExternalItemDirective }
3018
+ ], usesInheritance: true, ngImport: i0 }); }
3071
3019
  }
3072
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionOnPointerUp, decorators: [{
3073
- type: Injectable
3074
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FindInputsUnderPointerHandler }, { type: FindFirstCanBeConnectedOutputByOutletHandler }] });
3020
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemDirective, decorators: [{
3021
+ type: Directive,
3022
+ args: [{
3023
+ selector: "[fExternalItem]",
3024
+ host: {
3025
+ '[attr.id]': 'id',
3026
+ class: "f-component f-external-item",
3027
+ },
3028
+ providers: [
3029
+ { provide: F_EXTERNAL_ITEM, useExisting: FExternalItemDirective }
3030
+ ],
3031
+ }]
3032
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FExternalItemService }], propDecorators: { id: [{
3033
+ type: Input
3034
+ }], data: [{
3035
+ type: Input
3036
+ }] } });
3075
3037
 
3076
- class CreateConnectionPrepareDragSequence {
3038
+ class ExternalItemPrepareDragSequence {
3077
3039
  get transform() {
3078
3040
  return this.fComponentsStore.fCanvas.transform;
3079
3041
  }
3080
3042
  get flowHost() {
3081
3043
  return this.fComponentsStore.fFlow.hostElement;
3082
3044
  }
3083
- constructor(fComponentsStore, fDraggableDataContext, getElementRectInFlowHandler, getConnectionVectorHandler, findFirstCanBeConnectedOutputByOutletHandler, getOutputRectInFlowHandler) {
3045
+ constructor(fComponentsStore, fDraggableDataContext, fExternalItemService) {
3084
3046
  this.fComponentsStore = fComponentsStore;
3085
3047
  this.fDraggableDataContext = fDraggableDataContext;
3086
- this.getElementRectInFlowHandler = getElementRectInFlowHandler;
3087
- this.getConnectionVectorHandler = getConnectionVectorHandler;
3088
- this.findFirstCanBeConnectedOutputByOutletHandler = findFirstCanBeConnectedOutputByOutletHandler;
3089
- this.getOutputRectInFlowHandler = getOutputRectInFlowHandler;
3048
+ this.fExternalItemService = fExternalItemService;
3090
3049
  }
3091
3050
  handle(event) {
3092
- const node = this.fComponentsStore.findNode(event.targetElement);
3093
- const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
3094
- if (!node || this.fDraggableDataContext.draggableItems.length || !this.fComponentsStore.fTempConnection) {
3095
- return;
3096
- }
3097
- if (isNodeOutlet(event.targetElement)) {
3098
- const outlet = this.fComponentsStore.fOutlets.find((x) => {
3099
- return x.hostElement.contains(event.targetElement);
3100
- });
3101
- if (!outlet) {
3102
- throw new Error('Outlet not found');
3103
- }
3104
- const nodeOutputs = this.fComponentsStore.fOutputs.filter((x) => node.isContains(x.hostElement));
3105
- outlet.setOutputs(nodeOutputs);
3106
- if (outlet.canBeConnected) {
3107
- const outletCenter = this.getElementRectInFlowHandler.handle(outlet.hostElement).gravityCenter;
3108
- if (outlet.isConnectionFromOutlet) {
3109
- this.createConnectionHandler(pointerPositionInFlow, outlet, outletCenter);
3110
- }
3111
- else {
3112
- const output = this.findFirstCanBeConnectedOutputByOutletHandler.handle(outlet);
3113
- if (!output) {
3114
- throw new Error('Output not found');
3115
- }
3116
- this.createConnectionHandler(pointerPositionInFlow, output, outletCenter);
3117
- }
3118
- }
3119
- }
3120
- else if (this.isNodeOutput(event.targetElement, node)) {
3121
- const output = this.fComponentsStore.fOutputs.find((x) => {
3122
- return x.hostElement.contains(event.targetElement);
3123
- });
3124
- if (!output) {
3125
- throw new Error('Output not found');
3126
- }
3127
- if (output.canBeConnected) {
3128
- const outputCenter = this.getElementRectInFlowHandler.handle(output.hostElement).gravityCenter;
3129
- this.createConnectionHandler(pointerPositionInFlow, output, outputCenter);
3051
+ if (isExternalItem(event.targetElement)) {
3052
+ const item = this.fExternalItemService.getItem(getExternalItem(event.targetElement));
3053
+ if (!item) {
3054
+ throw new Error('External item not found');
3130
3055
  }
3056
+ const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
3057
+ this.fDraggableDataContext.onPointerDownScale = 1;
3058
+ this.fDraggableDataContext.onPointerDownPosition = pointerPositionInFlow.div(1);
3059
+ this.fDraggableDataContext.draggableItems = [
3060
+ new ExternalItemDragHandler(item)
3061
+ ];
3131
3062
  }
3132
3063
  }
3133
- createConnectionHandler(pointerPositionInCanvas, output, outputCenter) {
3134
- this.fComponentsStore.fTempConnection.fOutputId = output.id;
3135
- this.fComponentsStore.fTempConnection.initialize();
3136
- this.fDraggableDataContext.onPointerDownScale = this.transform.scale;
3137
- this.fDraggableDataContext.onPointerDownPosition = pointerPositionInCanvas.div(this.transform.scale);
3138
- this.fDraggableDataContext.draggableItems = [
3139
- new CreateConnectionDragHandler(this.getOutputRectInFlowHandler, this.getConnectionVectorHandler, this.fComponentsStore.fTempConnection, outputCenter)
3140
- ];
3141
- }
3142
- isNodeOutput(targetElement, node) {
3143
- const outlets = this.fComponentsStore.fOutlets.filter((x) => node.isContains(x.hostElement));
3144
- return isNodeOutput(targetElement) && !outlets.length;
3145
- }
3146
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetElementRectInFlowHandler }, { token: GetConnectionVectorHandler }, { token: FindFirstCanBeConnectedOutputByOutletHandler }, { token: GetOutputRectInFlowHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
3147
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionPrepareDragSequence }); }
3064
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FExternalItemService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3065
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemPrepareDragSequence }); }
3148
3066
  }
3149
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionPrepareDragSequence, decorators: [{
3067
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemPrepareDragSequence, decorators: [{
3150
3068
  type: Injectable
3151
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetElementRectInFlowHandler }, { type: GetConnectionVectorHandler }, { type: FindFirstCanBeConnectedOutputByOutletHandler }, { type: GetOutputRectInFlowHandler }] });
3152
-
3153
- class ReassignConnectionDragHandler {
3154
- constructor(getInputRectInFlowHandler, getOutputRectInFlowHandler, getConnectionVectorHandler, connection) {
3155
- this.getInputRectInFlowHandler = getInputRectInFlowHandler;
3156
- this.getOutputRectInFlowHandler = getOutputRectInFlowHandler;
3157
- this.getConnectionVectorHandler = getConnectionVectorHandler;
3158
- this.connection = connection;
3159
- this.type = EFDraggableType.REASSIGN_CONNECTION;
3160
- this.onPointerDownFromConnectorRect = RectExtensions.initialize();
3161
- this.onPointerDownToConnectorRect = RectExtensions.initialize();
3162
- this.outputSide = EFConnectableSide.BOTTOM;
3163
- this.inputSide = EFConnectableSide.TOP;
3164
- }
3165
- initialize() {
3166
- const fromConnector = this.getOutputRectInFlowHandler.handle(this.connection.fOutputId);
3167
- this.inputSide = this.getInputRectInFlowHandler.handle(this.connection.fInputId).fConnectableSide;
3168
- this.outputSide = fromConnector.fConnectableSide;
3169
- this.onPointerDownFromConnectorRect = fromConnector.rect;
3170
- this.onPointerDownToConnectorRect = RectExtensions.initialize(this.connection.vector.point2.x, this.connection.vector.point2.y, 0, 0);
3171
- }
3172
- move(difference) {
3173
- const toRect = RectExtensions.addPoint(this.onPointerDownToConnectorRect, difference);
3174
- const vector = this.getConnectionVectorHandler.handle(new GetConnectionVectorRequest(this.onPointerDownFromConnectorRect, toRect, this.connection.fBehavior, this.outputSide, this.inputSide));
3175
- this.connection.setVector(vector.point1, this.outputSide, vector.point2, this.inputSide);
3176
- this.connection.redraw();
3177
- }
3178
- complete() {
3179
- const fromConnector = this.getOutputRectInFlowHandler.handle(this.connection.fOutputId);
3180
- const toConnector = this.getInputRectInFlowHandler.handle(this.connection.fInputId);
3181
- const vector = this.getConnectionVectorHandler.handle(new GetConnectionVectorRequest(fromConnector.rect, toConnector.rect, this.connection.fBehavior, fromConnector.fConnectableSide, toConnector.fConnectableSide));
3182
- this.connection.setVector(vector.point1, fromConnector.fConnectableSide, vector.point2, toConnector.fConnectableSide);
3183
- this.connection.redraw();
3184
- }
3185
- }
3069
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FExternalItemService }] });
3186
3070
 
3187
- class ReassignConnectionEvent {
3188
- constructor(connectionId, outputId, oldInputId, newInputId) {
3189
- this.connectionId = connectionId;
3190
- this.outputId = outputId;
3191
- this.oldInputId = oldInputId;
3192
- this.newInputId = newInputId;
3071
+ class ExternalItemOnPointerUp {
3072
+ get flowHost() {
3073
+ return this.fComponentsStore.fFlow.hostElement;
3193
3074
  }
3194
- }
3195
-
3196
- class ReassignConnectionOnPointerUp {
3197
- get fDraggable() {
3198
- return this.fComponentsStore.fDraggable;
3075
+ get fCreateNode() {
3076
+ return this.fComponentsStore.fDraggable.fCreateNode;
3199
3077
  }
3200
- constructor(fComponentsStore, fDraggableDataContext, findInputsUnderPointerHandler) {
3078
+ constructor(fComponentsStore, fDraggableDataContext, getElementRectInFlowHandler) {
3201
3079
  this.fComponentsStore = fComponentsStore;
3202
3080
  this.fDraggableDataContext = fDraggableDataContext;
3203
- this.findInputsUnderPointerHandler = findInputsUnderPointerHandler;
3081
+ this.getElementRectInFlowHandler = getElementRectInFlowHandler;
3204
3082
  }
3205
3083
  handle(event) {
3206
- const isReassignConnection = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.REASSIGN_CONNECTION);
3207
- if (isReassignConnection) {
3208
- const handler = this.fDraggableDataContext.draggableItems[0];
3209
- const inputsUnderPointer = this.findInputsUnderPointerHandler.handle(new FindInputsUnderPointerRequest(event, handler));
3210
- if (inputsUnderPointer.length > 0) {
3211
- if (handler.connection.fInputId !== inputsUnderPointer[0]?.id) {
3212
- this.fDraggable.fReassignConnection.emit(new ReassignConnectionEvent(handler.connection.id, handler.connection.fOutputId, handler.connection.fInputId, inputsUnderPointer[0]?.id));
3213
- }
3084
+ const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
3085
+ let difference = pointerPositionInFlow.div(this.fDraggableDataContext.onPointerDownScale).sub(this.fDraggableDataContext.onPointerDownPosition);
3086
+ const isDragPaletteItem = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.PALETTE_ITEM);
3087
+ if (isDragPaletteItem) {
3088
+ const dragHandler = this.fDraggableDataContext.draggableItems[0];
3089
+ dragHandler.move(difference);
3090
+ const isPointerInCanvasRect = document.elementsFromPoint(event.getPosition().x, event.getPosition().y).some((x) => x === this.flowHost);
3091
+ if (isPointerInCanvasRect) {
3092
+ const rectInCanvas = this.getElementRectInFlowHandler.handle(dragHandler.placeholder);
3093
+ this.fCreateNode.emit(new FCreateNodeEvent(rectInCanvas, dragHandler.externalItem.data));
3214
3094
  }
3215
- handler.complete();
3095
+ dragHandler.complete();
3216
3096
  }
3217
3097
  }
3218
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionOnPointerUp, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FindInputsUnderPointerHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
3219
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionOnPointerUp }); }
3098
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemOnPointerUp, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetElementRectInFlowHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
3099
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemOnPointerUp }); }
3220
3100
  }
3221
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionOnPointerUp, decorators: [{
3101
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemOnPointerUp, decorators: [{
3222
3102
  type: Injectable
3223
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FindInputsUnderPointerHandler }] });
3103
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetElementRectInFlowHandler }] });
3224
3104
 
3225
- class ReassignConnectionPrepareDragSequence {
3105
+ const EXTERNAL_ITEM_PROVIDERS = [
3106
+ ExternalItemOnPointerUp,
3107
+ ExternalItemPrepareDragSequence
3108
+ ];
3109
+
3110
+ class IsConnectionUnderNodeHandler {
3226
3111
  get transform() {
3227
3112
  return this.fComponentsStore.fCanvas.transform;
3228
3113
  }
3229
3114
  get flowHost() {
3230
3115
  return this.fComponentsStore.fFlow.hostElement;
3231
3116
  }
3232
- constructor(fComponentsStore, fDraggableDataContext, getConnectionHandler, getInputRectInFlowHandler, getOutputRectInFlowHandler, getConnectionVectorHandler, updateConnectionLayerHandler) {
3117
+ constructor(fComponentsStore, fDraggableDataContext, getElementRectInFlowHandler, getOutgoingConnectionsHandler, getIncomingConnectionsHandler) {
3233
3118
  this.fComponentsStore = fComponentsStore;
3234
3119
  this.fDraggableDataContext = fDraggableDataContext;
3235
- this.getConnectionHandler = getConnectionHandler;
3236
- this.getInputRectInFlowHandler = getInputRectInFlowHandler;
3237
- this.getOutputRectInFlowHandler = getOutputRectInFlowHandler;
3238
- this.getConnectionVectorHandler = getConnectionVectorHandler;
3239
- this.updateConnectionLayerHandler = updateConnectionLayerHandler;
3120
+ this.getElementRectInFlowHandler = getElementRectInFlowHandler;
3121
+ this.getOutgoingConnectionsHandler = getOutgoingConnectionsHandler;
3122
+ this.getIncomingConnectionsHandler = getIncomingConnectionsHandler;
3240
3123
  }
3241
- handle(event) {
3242
- const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
3243
- const position = event.getPosition();
3244
- const allElements = document.elementsFromPoint(position.x, position.y);
3245
- const dragHandlesOfConnections = allElements.filter((x) => {
3246
- return !!this.getConnectionHandler.handle(x) && x.classList.contains(F_CONNECTION_DRAG_HANDLE_CLASS);
3124
+ handle() {
3125
+ const isValid = this.isValidRequest();
3126
+ if (!isValid) {
3127
+ return;
3128
+ }
3129
+ const fNode = this.fDraggableDataContext.draggableItems[0].fNode;
3130
+ const outputsOfNode = this.getOutputsForNode(fNode);
3131
+ const inputsOfNode = this.getInputsForNode(fNode);
3132
+ const isCantBeConnectedByOutput = outputsOfNode.some((x) => !x.canBeConnected);
3133
+ const isCantBeConnectedByInput = this.fComponentsStore.fConnections.some((x) => {
3134
+ return inputsOfNode.find((input) => input.id === x.fInputId);
3247
3135
  });
3248
- let connectionToReassign;
3249
- if (dragHandlesOfConnections.length) {
3250
- const connections = dragHandlesOfConnections.map((x) => this.getConnectionHandler.handle(x)).filter((x) => !x?.disabled);
3251
- if (connections.length) {
3252
- connectionToReassign = this.getConnectionHandler.handle(dragHandlesOfConnections[0]);
3253
- }
3254
- }
3255
- if (connectionToReassign && !this.fDraggableDataContext.draggableItems.length) {
3256
- this.updateConnectionLayerHandler.handle(connectionToReassign);
3257
- this.fDraggableDataContext.onPointerDownScale = this.transform.scale;
3258
- this.fDraggableDataContext.onPointerDownPosition = pointerPositionInFlow.div(this.transform.scale);
3259
- this.fDraggableDataContext.draggableItems = [
3260
- new ReassignConnectionDragHandler(this.getInputRectInFlowHandler, this.getOutputRectInFlowHandler, this.getConnectionVectorHandler, connectionToReassign)
3261
- ];
3262
- }
3263
- }
3264
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetConnectionHandler }, { token: GetInputRectInFlowHandler }, { token: GetOutputRectInFlowHandler }, { token: GetConnectionVectorHandler }, { token: UpdateConnectionLayerHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
3265
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionPrepareDragSequence }); }
3266
- }
3267
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionPrepareDragSequence, decorators: [{
3268
- type: Injectable
3269
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetConnectionHandler }, { type: GetInputRectInFlowHandler }, { type: GetOutputRectInFlowHandler }, { type: GetConnectionVectorHandler }, { type: UpdateConnectionLayerHandler }] });
3270
-
3271
- const CONNECTIONS_PROVIDERS = [
3272
- FindFirstCanBeConnectedOutputByOutletHandler,
3273
- CreateConnectionOnPointerUp,
3274
- CreateConnectionPrepareDragSequence,
3275
- FirstNotConnectedInputOfNodeUnderPointerHandler,
3276
- InputsUnderPointerHandler,
3277
- FindInputsUnderPointerHandler,
3278
- ReassignConnectionOnPointerUp,
3279
- ReassignConnectionPrepareDragSequence
3280
- ];
3281
-
3282
- class CreateNodeEvent {
3283
- constructor(rect, data) {
3284
- this.rect = rect;
3285
- this.data = data;
3286
- }
3287
- }
3288
-
3289
- class ExternalItemDragHandler {
3290
- constructor(externalItem) {
3291
- this.externalItem = externalItem;
3292
- this.type = EFDraggableType.PALETTE_ITEM;
3293
- this.onPointerDownRect = RectExtensions.initialize();
3294
- this.difference = PointExtensions.initialize();
3295
- }
3296
- getStyle(position) {
3297
- return `position: absolute; left: 0; top: 0; transform: translate(${position.x}px, ${position.y}px)`;
3298
- }
3299
- initialize() {
3300
- this.onPointerDownRect = this.getExternalItemRect();
3301
- this.placeholder = DomElementExtensions.deepCloneNode(this.externalItem.hostElement);
3302
- document.body.appendChild(this.placeholder);
3303
- }
3304
- getExternalItemRect() {
3305
- const rect = this.externalItem.hostElement.getBoundingClientRect();
3306
- const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
3307
- const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
3308
- const offsetTop = rect.top + scrollTop;
3309
- const offsetLeft = rect.left + scrollLeft;
3310
- return RectExtensions.initialize(offsetLeft, offsetTop, rect.width, rect.height);
3311
- }
3312
- move(difference) {
3313
- this.difference = difference;
3314
- const position = Point.fromPoint(this.onPointerDownRect).add(this.difference);
3315
- this.placeholder.setAttribute('style', this.getStyle(position));
3316
- }
3317
- getPlaceholderRect() {
3318
- return RectExtensions.fromElement(this.placeholder);
3319
- }
3320
- complete() {
3321
- document.body.removeChild(this.placeholder);
3322
- }
3323
- }
3324
-
3325
- class ExternalItemPrepareDragSequence {
3326
- get transform() {
3327
- return this.fComponentsStore.fCanvas.transform;
3328
- }
3329
- get flowHost() {
3330
- return this.fComponentsStore.fFlow.hostElement;
3331
- }
3332
- constructor(fComponentsStore, fDraggableDataContext, fExternalItemService) {
3333
- this.fComponentsStore = fComponentsStore;
3334
- this.fDraggableDataContext = fDraggableDataContext;
3335
- this.fExternalItemService = fExternalItemService;
3336
- }
3337
- handle(event) {
3338
- if (isExternalItem(event.targetElement)) {
3339
- const item = this.fExternalItemService.getItem(getExternalItem(event.targetElement));
3340
- if (!item) {
3341
- throw new Error('External item not found');
3342
- }
3343
- const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
3344
- this.fDraggableDataContext.onPointerDownScale = 1;
3345
- this.fDraggableDataContext.onPointerDownPosition = pointerPositionInFlow.div(1);
3346
- this.fDraggableDataContext.draggableItems = [
3347
- new ExternalItemDragHandler(item)
3348
- ];
3349
- }
3350
- }
3351
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FExternalItemService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3352
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemPrepareDragSequence }); }
3353
- }
3354
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemPrepareDragSequence, decorators: [{
3355
- type: Injectable
3356
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FExternalItemService }] });
3357
-
3358
- class ExternalItemOnPointerUp {
3359
- get flowHost() {
3360
- return this.fComponentsStore.fFlow.hostElement;
3361
- }
3362
- get fCreateNode() {
3363
- return this.fComponentsStore.fDraggable.fCreateNode;
3364
- }
3365
- constructor(fComponentsStore, fDraggableDataContext, getElementRectInFlowHandler) {
3366
- this.fComponentsStore = fComponentsStore;
3367
- this.fDraggableDataContext = fDraggableDataContext;
3368
- this.getElementRectInFlowHandler = getElementRectInFlowHandler;
3369
- }
3370
- handle(event) {
3371
- const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
3372
- let difference = pointerPositionInFlow.div(this.fDraggableDataContext.onPointerDownScale).sub(this.fDraggableDataContext.onPointerDownPosition);
3373
- const isDragPaletteItem = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.PALETTE_ITEM);
3374
- if (isDragPaletteItem) {
3375
- const dragHandler = this.fDraggableDataContext.draggableItems[0];
3376
- dragHandler.move(difference);
3377
- const isPointerInCanvasRect = document.elementsFromPoint(event.getPosition().x, event.getPosition().y).some((x) => x === this.flowHost);
3378
- if (isPointerInCanvasRect) {
3379
- const rectInCanvas = this.getElementRectInFlowHandler.handle(dragHandler.placeholder);
3380
- this.fCreateNode.emit(new CreateNodeEvent(rectInCanvas, dragHandler.externalItem.data));
3381
- }
3382
- dragHandler.complete();
3383
- }
3384
- }
3385
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemOnPointerUp, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetElementRectInFlowHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
3386
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemOnPointerUp }); }
3387
- }
3388
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemOnPointerUp, decorators: [{
3389
- type: Injectable
3390
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetElementRectInFlowHandler }] });
3391
-
3392
- const EXTERNAL_ITEM_PROVIDERS = [
3393
- ExternalItemOnPointerUp,
3394
- ExternalItemPrepareDragSequence
3395
- ];
3396
-
3397
- class IsConnectionUnderNodeHandler {
3398
- get transform() {
3399
- return this.fComponentsStore.fCanvas.transform;
3400
- }
3401
- get flowHost() {
3402
- return this.fComponentsStore.fFlow.hostElement;
3403
- }
3404
- constructor(fComponentsStore, fDraggableDataContext, getElementRectInFlowHandler, getOutgoingConnectionsHandler, getIncomingConnectionsHandler) {
3405
- this.fComponentsStore = fComponentsStore;
3406
- this.fDraggableDataContext = fDraggableDataContext;
3407
- this.getElementRectInFlowHandler = getElementRectInFlowHandler;
3408
- this.getOutgoingConnectionsHandler = getOutgoingConnectionsHandler;
3409
- this.getIncomingConnectionsHandler = getIncomingConnectionsHandler;
3410
- }
3411
- handle() {
3412
- const isValid = this.isValidRequest();
3413
- if (!isValid) {
3414
- return;
3415
- }
3416
- const fNode = this.fDraggableDataContext.draggableItems[0].fNode;
3417
- const outputsOfNode = this.getOutputsForNode(fNode);
3418
- const inputsOfNode = this.getInputsForNode(fNode);
3419
- const isCantBeConnectedByOutput = outputsOfNode.some((x) => !x.canBeConnected);
3420
- const isCantBeConnectedByInput = this.fComponentsStore.fConnections.some((x) => {
3421
- return inputsOfNode.find((input) => input.id === x.fInputId);
3422
- });
3423
- if (!isCantBeConnectedByInput && outputsOfNode.length && !isCantBeConnectedByOutput && inputsOfNode.length) {
3424
- const output = outputsOfNode[0];
3425
- const input = inputsOfNode[0];
3426
- const outgoingConnections = this.getOutgoingConnectionsHandler.handle([output]);
3427
- const incomingConnections = this.getIncomingConnectionsHandler.handle([input]);
3428
- if (outgoingConnections.length === 0 && incomingConnections.length === 0) {
3429
- const connections = this.findConnectionsUnderNode(fNode);
3430
- if (connections.length) {
3431
- }
3136
+ if (!isCantBeConnectedByInput && outputsOfNode.length && !isCantBeConnectedByOutput && inputsOfNode.length) {
3137
+ const output = outputsOfNode[0];
3138
+ const input = inputsOfNode[0];
3139
+ const outgoingConnections = this.getOutgoingConnectionsHandler.handle([output]);
3140
+ const incomingConnections = this.getIncomingConnectionsHandler.handle([input]);
3141
+ if (outgoingConnections.length === 0 && incomingConnections.length === 0) {
3142
+ const connections = this.findConnectionsUnderNode(fNode);
3143
+ if (connections.length) {
3144
+ }
3432
3145
  }
3433
3146
  }
3434
3147
  }
@@ -3458,10 +3171,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
3458
3171
  }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetElementRectInFlowHandler }, { type: GetOutgoingConnectionsHandler }, { type: GetIncomingConnectionsHandler }] });
3459
3172
 
3460
3173
  class ConnectionDragHandler {
3461
- constructor(getInputRectInFlowHandler, getOutputRectInFlowHandler, getConnectionVectorHandler, connection) {
3174
+ constructor(getInputRectInFlowHandler, fMediator, connection) {
3462
3175
  this.getInputRectInFlowHandler = getInputRectInFlowHandler;
3463
- this.getOutputRectInFlowHandler = getOutputRectInFlowHandler;
3464
- this.getConnectionVectorHandler = getConnectionVectorHandler;
3176
+ this.fMediator = fMediator;
3465
3177
  this.connection = connection;
3466
3178
  this.type = EFDraggableType.CONNECTION;
3467
3179
  this.onPointerDownVector = VectorExtensions.initialize();
@@ -3469,11 +3181,11 @@ class ConnectionDragHandler {
3469
3181
  this.toConnectorSide = EFConnectableSide.TOP;
3470
3182
  }
3471
3183
  initialize() {
3472
- const fromConnector = this.getOutputRectInFlowHandler.handle(this.connection.fOutputId);
3184
+ const fromConnector = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
3473
3185
  this.fromConnectorSide = fromConnector.fConnectableSide;
3474
3186
  const toConnector = this.getInputRectInFlowHandler.handle(this.connection.fInputId);
3475
3187
  this.toConnectorSide = toConnector.fConnectableSide;
3476
- this.onPointerDownVector = this.getConnectionVectorHandler.handle(new GetConnectionVectorRequest(fromConnector.rect, toConnector.rect, this.connection.fBehavior, fromConnector.fConnectableSide, toConnector.fConnectableSide));
3188
+ this.onPointerDownVector = this.fMediator.send(new GetConnectionVectorRequest(fromConnector.rect, toConnector.rect, this.connection.fBehavior, fromConnector.fConnectableSide, toConnector.fConnectableSide));
3477
3189
  }
3478
3190
  move(difference) {
3479
3191
  const fromPoint = Point.fromPoint(this.onPointerDownVector.point1).add(difference);
@@ -3484,10 +3196,9 @@ class ConnectionDragHandler {
3484
3196
  }
3485
3197
 
3486
3198
  class ConnectionSourceDragHandler {
3487
- constructor(getInputRectInFlowHandler, getOutputRectInFlowHandler, getConnectionVectorHandler, connection) {
3199
+ constructor(getInputRectInFlowHandler, fMediator, connection) {
3488
3200
  this.getInputRectInFlowHandler = getInputRectInFlowHandler;
3489
- this.getOutputRectInFlowHandler = getOutputRectInFlowHandler;
3490
- this.getConnectionVectorHandler = getConnectionVectorHandler;
3201
+ this.fMediator = fMediator;
3491
3202
  this.connection = connection;
3492
3203
  this.type = EFDraggableType.CONNECTION;
3493
3204
  this.fromConnectorRect = RectExtensions.initialize();
@@ -3496,7 +3207,7 @@ class ConnectionSourceDragHandler {
3496
3207
  this.toConnectorSide = EFConnectableSide.TOP;
3497
3208
  }
3498
3209
  initialize() {
3499
- const fromConnector = this.getOutputRectInFlowHandler.handle(this.connection.fOutputId);
3210
+ const fromConnector = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
3500
3211
  this.fromConnectorRect = fromConnector.rect;
3501
3212
  this.fromConnectorSide = fromConnector.fConnectableSide;
3502
3213
  const toConnector = this.getInputRectInFlowHandler.handle(this.connection.fInputId);
@@ -3505,17 +3216,16 @@ class ConnectionSourceDragHandler {
3505
3216
  }
3506
3217
  move(difference) {
3507
3218
  const fromConnectorRect = RectExtensions.addPoint(this.fromConnectorRect, difference);
3508
- const vector = this.getConnectionVectorHandler.handle(new GetConnectionVectorRequest(fromConnectorRect, this.toConnectorRect, this.connection.fBehavior, this.fromConnectorSide, this.toConnectorSide));
3219
+ const vector = this.fMediator.send(new GetConnectionVectorRequest(fromConnectorRect, this.toConnectorRect, this.connection.fBehavior, this.fromConnectorSide, this.toConnectorSide));
3509
3220
  this.connection.setVector(vector.point1, this.fromConnectorSide, vector.point2, this.toConnectorSide);
3510
3221
  this.connection.redraw();
3511
3222
  }
3512
3223
  }
3513
3224
 
3514
3225
  class ConnectionTargetDragHandler {
3515
- constructor(getInputRectInFlowHandler, getOutputRectInFlowHandler, getConnectionVectorHandler, connection) {
3226
+ constructor(getInputRectInFlowHandler, fMediator, connection) {
3516
3227
  this.getInputRectInFlowHandler = getInputRectInFlowHandler;
3517
- this.getOutputRectInFlowHandler = getOutputRectInFlowHandler;
3518
- this.getConnectionVectorHandler = getConnectionVectorHandler;
3228
+ this.fMediator = fMediator;
3519
3229
  this.connection = connection;
3520
3230
  this.type = EFDraggableType.CONNECTION;
3521
3231
  this.fromConnectorRect = RectExtensions.initialize();
@@ -3524,7 +3234,7 @@ class ConnectionTargetDragHandler {
3524
3234
  this.toConnectorSide = EFConnectableSide.TOP;
3525
3235
  }
3526
3236
  initialize() {
3527
- const fromConnector = this.getOutputRectInFlowHandler.handle(this.connection.fOutputId);
3237
+ const fromConnector = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
3528
3238
  this.fromConnectorRect = fromConnector.rect;
3529
3239
  this.fromConnectorSide = fromConnector.fConnectableSide;
3530
3240
  const toConnector = this.getInputRectInFlowHandler.handle(this.connection.fInputId);
@@ -3533,7 +3243,7 @@ class ConnectionTargetDragHandler {
3533
3243
  }
3534
3244
  move(difference) {
3535
3245
  const toConnectorRect = RectExtensions.addPoint(this.toConnectorRect, difference);
3536
- const vector = this.getConnectionVectorHandler.handle(new GetConnectionVectorRequest(this.fromConnectorRect, toConnectorRect, this.connection.fBehavior, this.fromConnectorSide, this.toConnectorSide));
3246
+ const vector = this.fMediator.send(new GetConnectionVectorRequest(this.fromConnectorRect, toConnectorRect, this.connection.fBehavior, this.fromConnectorSide, this.toConnectorSide));
3537
3247
  this.connection.setVector(vector.point1, this.fromConnectorSide, vector.point2, this.toConnectorSide);
3538
3248
  this.connection.redraw();
3539
3249
  }
@@ -3602,15 +3312,14 @@ class NodePrepareDragSequence {
3602
3312
  get flowHost() {
3603
3313
  return this.fComponentsStore.fFlow.hostElement;
3604
3314
  }
3605
- constructor(fComponentsStore, fDraggableDataContext, updateNodeLayerHandler, getInputRectInFlowHandler, getOutputRectInFlowHandler, getOutgoingConnectionsHandler, getIncomingConnectionsHandler, getConnectionVectorHandler) {
3315
+ constructor(fComponentsStore, fDraggableDataContext, updateNodeLayerHandler, getInputRectInFlowHandler, getOutgoingConnectionsHandler, getIncomingConnectionsHandler, fMediator) {
3606
3316
  this.fComponentsStore = fComponentsStore;
3607
3317
  this.fDraggableDataContext = fDraggableDataContext;
3608
3318
  this.updateNodeLayerHandler = updateNodeLayerHandler;
3609
3319
  this.getInputRectInFlowHandler = getInputRectInFlowHandler;
3610
- this.getOutputRectInFlowHandler = getOutputRectInFlowHandler;
3611
3320
  this.getOutgoingConnectionsHandler = getOutgoingConnectionsHandler;
3612
3321
  this.getIncomingConnectionsHandler = getIncomingConnectionsHandler;
3613
- this.getConnectionVectorHandler = getConnectionVectorHandler;
3322
+ this.fMediator = fMediator;
3614
3323
  }
3615
3324
  handle(event) {
3616
3325
  const node = this.fComponentsStore.findNode(event.targetElement);
@@ -3651,22 +3360,22 @@ class NodePrepareDragSequence {
3651
3360
  const outputConnections = this.getOutgoingConnectionsHandler.handle(this.getOutputsForNode(nodeHandler.fNode));
3652
3361
  outputConnections.forEach((c) => {
3653
3362
  if (allInputIds.includes(c.fInputId)) {
3654
- itemsToDrag.push(new ConnectionDragHandler(this.getInputRectInFlowHandler, this.getOutputRectInFlowHandler, this.getConnectionVectorHandler, c));
3363
+ itemsToDrag.push(new ConnectionDragHandler(this.getInputRectInFlowHandler, this.fMediator, c));
3655
3364
  }
3656
3365
  else {
3657
- itemsToDrag.push(new ConnectionSourceDragHandler(this.getInputRectInFlowHandler, this.getOutputRectInFlowHandler, this.getConnectionVectorHandler, c));
3366
+ itemsToDrag.push(new ConnectionSourceDragHandler(this.getInputRectInFlowHandler, this.fMediator, c));
3658
3367
  }
3659
3368
  });
3660
3369
  const inputConnections = this.getIncomingConnectionsHandler.handle(this.getInputsForNode(nodeHandler.fNode));
3661
3370
  inputConnections.forEach((c) => {
3662
3371
  if (allOutputIds.includes(c.fOutputId)) {
3663
- const index = itemsToDrag.findIndex((x) => x.type === EFDraggableType.CONNECTION && x.connection.id === c.id);
3372
+ const index = itemsToDrag.findIndex((x) => x.type === EFDraggableType.CONNECTION && x.connection.fConnectionId === c.fConnectionId);
3664
3373
  if (index !== -1) {
3665
- itemsToDrag.push(new ConnectionDragHandler(this.getInputRectInFlowHandler, this.getOutputRectInFlowHandler, this.getConnectionVectorHandler, c));
3374
+ itemsToDrag.push(new ConnectionDragHandler(this.getInputRectInFlowHandler, this.fMediator, c));
3666
3375
  }
3667
3376
  }
3668
3377
  else {
3669
- itemsToDrag.push(new ConnectionTargetDragHandler(this.getInputRectInFlowHandler, this.getOutputRectInFlowHandler, this.getConnectionVectorHandler, c));
3378
+ itemsToDrag.push(new ConnectionTargetDragHandler(this.getInputRectInFlowHandler, this.fMediator, c));
3670
3379
  }
3671
3380
  });
3672
3381
  });
@@ -3678,12 +3387,12 @@ class NodePrepareDragSequence {
3678
3387
  getOutputsForNode(node) {
3679
3388
  return this.fComponentsStore.fOutputs.filter((x) => node.isContains(x.hostElement));
3680
3389
  }
3681
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodePrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: UpdateNodeLayerHandler }, { token: GetInputRectInFlowHandler }, { token: GetOutputRectInFlowHandler }, { token: GetOutgoingConnectionsHandler }, { token: GetIncomingConnectionsHandler }, { token: GetConnectionVectorHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
3390
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodePrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: UpdateNodeLayerHandler }, { token: GetInputRectInFlowHandler }, { token: GetOutgoingConnectionsHandler }, { token: GetIncomingConnectionsHandler }, { token: FFlowMediator }], target: i0.ɵɵFactoryTarget.Injectable }); }
3682
3391
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodePrepareDragSequence }); }
3683
3392
  }
3684
3393
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodePrepareDragSequence, decorators: [{
3685
3394
  type: Injectable
3686
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: UpdateNodeLayerHandler }, { type: GetInputRectInFlowHandler }, { type: GetOutputRectInFlowHandler }, { type: GetOutgoingConnectionsHandler }, { type: GetIncomingConnectionsHandler }, { type: GetConnectionVectorHandler }] });
3395
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: UpdateNodeLayerHandler }, { type: GetInputRectInFlowHandler }, { type: GetOutgoingConnectionsHandler }, { type: GetIncomingConnectionsHandler }, { type: FFlowMediator }] });
3687
3396
 
3688
3397
  const NODE_PROVIDERS = [
3689
3398
  NodeOnPointerUp,
@@ -3915,7 +3624,7 @@ const SINGLE_SELECT_PROVIDERS = [
3915
3624
  SingleSelectOnPointerDown
3916
3625
  ];
3917
3626
 
3918
- class SelectionChangeEvent {
3627
+ class FSelectionChangeEvent {
3919
3628
  constructor(nodes, connections) {
3920
3629
  this.nodes = nodes;
3921
3630
  this.connections = connections;
@@ -4068,176 +3777,429 @@ function isFakeTouchstartFromScreenReader(event) {
4068
3777
  (touch.radiusY == null || touch.radiusY === 1));
4069
3778
  }
4070
3779
 
4071
- const F_DRAGGABLE = new InjectionToken('F_DRAGGABLE');
4072
- class FDraggableBase extends IDragAndDropBase {
4073
- constructor(ngZone) {
4074
- super(ngZone);
4075
- }
4076
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableBase, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
4077
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FDraggableBase, usesInheritance: true, ngImport: i0 }); }
3780
+ const F_DRAGGABLE = new InjectionToken('F_DRAGGABLE');
3781
+ class FDraggableBase extends IDragAndDropBase {
3782
+ constructor(ngZone) {
3783
+ super(ngZone);
3784
+ }
3785
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableBase, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
3786
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FDraggableBase, usesInheritance: true, ngImport: i0 }); }
3787
+ }
3788
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableBase, decorators: [{
3789
+ type: Directive
3790
+ }], ctorParameters: () => [{ type: i0.NgZone }] });
3791
+
3792
+ class FDraggableDirective extends FDraggableBase {
3793
+ get hostElement() {
3794
+ return this.elementReference.nativeElement;
3795
+ }
3796
+ constructor(elementReference, fDraggableDataContext, ngZone, injector, fComponentsStore, document) {
3797
+ super(ngZone);
3798
+ this.elementReference = elementReference;
3799
+ this.fDraggableDataContext = fDraggableDataContext;
3800
+ this.injector = injector;
3801
+ this.fComponentsStore = fComponentsStore;
3802
+ this.subscriptions$ = new Subscription();
3803
+ this.disabled = false;
3804
+ this.fSelectionChange = new EventEmitter();
3805
+ // @Output()
3806
+ // public override fConnectionIntersectNode: EventEmitter<ConnectionIntersectNodeEvent> = new EventEmitter<ConnectionIntersectNodeEvent>();
3807
+ this.fCreateNode = new EventEmitter();
3808
+ this.fReassignConnection = new EventEmitter();
3809
+ this.fCreateConnection = new EventEmitter();
3810
+ this.selectedItemsOnPointerDown = 0;
3811
+ this.document = document;
3812
+ }
3813
+ ngOnInit() {
3814
+ this.fComponentsStore.fDraggable = this;
3815
+ }
3816
+ ngAfterViewInit() {
3817
+ super.subscribe(this.document);
3818
+ }
3819
+ onPointerDown(event) {
3820
+ this.fDraggableDataContext.reset();
3821
+ let result = event.isMouseLeftButton();
3822
+ this.selectedItemsOnPointerDown = this.fDraggableDataContext.selectedItems.length;
3823
+ this.injector.get(SingleSelectOnPointerDown).handle(event);
3824
+ this.injector.get(ReassignConnectionPrepareDragSequence).handle(event);
3825
+ this.injector.get(CreateConnectionPrepareDragSequence).handle(event);
3826
+ this.emitSelectionChangeEvent();
3827
+ return result;
3828
+ }
3829
+ prepareDragSequence(event) {
3830
+ this.injector.get(SelectionAreaPrepareDragSequence).handle(event);
3831
+ this.injector.get(NodePrepareDragSequence).handle(event);
3832
+ this.injector.get(CanvasPrepareDragSequence).handle(event);
3833
+ this.injector.get(ExternalItemPrepareDragSequence).handle(event);
3834
+ this.fDraggableDataContext.draggableItems.forEach((item) => {
3835
+ item.initialize?.();
3836
+ });
3837
+ if (this.fDraggableDataContext.draggableItems.length > 0) {
3838
+ this.hostElement.classList.add('f-dragging');
3839
+ }
3840
+ }
3841
+ onPointerMove(event) {
3842
+ const pointerPositionInCanvas = Point.fromPoint(event.getPosition()).elementTransform(this.hostElement);
3843
+ const difference = pointerPositionInCanvas.div(this.fDraggableDataContext.onPointerDownScale).sub(this.fDraggableDataContext.onPointerDownPosition);
3844
+ this.fDraggableDataContext.draggableItems.forEach((item) => {
3845
+ item.move(difference);
3846
+ });
3847
+ }
3848
+ onPointerUp(event) {
3849
+ this.injector.get(ReassignConnectionOnPointerUp).handle(event);
3850
+ this.injector.get(CreateConnectionOnPointerUp).handle(event);
3851
+ this.injector.get(SelectionAreaOnPointerUp).handle(event);
3852
+ this.injector.get(NodeOnPointerUp).handle(event);
3853
+ this.injector.get(CanvasOnPointerUp).handle(event);
3854
+ this.injector.get(ExternalItemOnPointerUp).handle(event);
3855
+ this.hostElement.classList.remove('f-dragging');
3856
+ this.emitSelectionChangeEvent();
3857
+ this.fDraggableDataContext.reset();
3858
+ }
3859
+ emitSelectionChangeEvent() {
3860
+ if (!this.fDraggableDataContext.isSelectedChanged
3861
+ && this.selectedItemsOnPointerDown === this.fDraggableDataContext.selectedItems.length) {
3862
+ return;
3863
+ }
3864
+ let selectedNodes = [];
3865
+ let selectedConnections = [];
3866
+ this.fDraggableDataContext.selectedItems.forEach((x) => {
3867
+ if (x.hostElement.classList.contains('f-node')) {
3868
+ selectedNodes.push(x.hostElement.id);
3869
+ }
3870
+ else {
3871
+ selectedConnections.push(x.hostElement.id);
3872
+ }
3873
+ });
3874
+ this.fSelectionChange.emit(new FSelectionChangeEvent(selectedNodes, selectedConnections));
3875
+ }
3876
+ ngOnDestroy() {
3877
+ super.unsubscribe();
3878
+ this.subscriptions$.unsubscribe();
3879
+ }
3880
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableDirective, deps: [{ token: i0.ElementRef }, { token: FDraggableDataContext }, { token: i0.NgZone }, { token: i0.Injector }, { token: FComponentsStore }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Directive }); }
3881
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FDraggableDirective, selector: "f-flow[fDraggable]", inputs: { disabled: ["fDraggableDisabled", "disabled"] }, outputs: { fSelectionChange: "fSelectionChange", fCreateNode: "fCreateNode", fReassignConnection: "fReassignConnection", fCreateConnection: "fCreateConnection" }, providers: [
3882
+ { provide: F_DRAGGABLE, useExisting: FDraggableDirective }
3883
+ ], exportAs: ["fDraggable"], usesInheritance: true, ngImport: i0 }); }
3884
+ }
3885
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableDirective, decorators: [{
3886
+ type: Directive,
3887
+ args: [{
3888
+ selector: "f-flow[fDraggable]",
3889
+ exportAs: 'fDraggable',
3890
+ providers: [
3891
+ { provide: F_DRAGGABLE, useExisting: FDraggableDirective }
3892
+ ]
3893
+ }]
3894
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FDraggableDataContext }, { type: i0.NgZone }, { type: i0.Injector }, { type: FComponentsStore }, { type: undefined, decorators: [{
3895
+ type: Inject,
3896
+ args: [DOCUMENT]
3897
+ }] }], propDecorators: { disabled: [{
3898
+ type: Input,
3899
+ args: ['fDraggableDisabled']
3900
+ }], fSelectionChange: [{
3901
+ type: Output
3902
+ }], fCreateNode: [{
3903
+ type: Output
3904
+ }], fReassignConnection: [{
3905
+ type: Output
3906
+ }], fCreateConnection: [{
3907
+ type: Output
3908
+ }] } });
3909
+
3910
+ class LineElement {
3911
+ constructor(hostElement) {
3912
+ this.hostElement = hostElement;
3913
+ this.element = DomElementExtensions.createHtmlElement('div');
3914
+ this.hostElement.appendChild(this.element);
3915
+ this.element.classList.add('f-line');
3916
+ }
3917
+ hide() {
3918
+ this.element.style.display = 'none';
3919
+ }
3920
+ show() {
3921
+ this.element.style.display = 'block';
3922
+ }
3923
+ draw(object) {
3924
+ this.element.style.position = 'absolute';
3925
+ Object.keys(object).forEach((key) => {
3926
+ // @ts-ignore
3927
+ this.element.style[key] = object[key] + 'px';
3928
+ });
3929
+ }
3930
+ }
3931
+
3932
+ class LineService {
3933
+ constructor(hostElement) {
3934
+ this.hostElement = hostElement;
3935
+ this.fHorizontalLine = new LineElement(this.hostElement);
3936
+ this.fVerticalLine = new LineElement(this.hostElement);
3937
+ }
3938
+ drawVerticalLine(x, size, transform) {
3939
+ this.fVerticalLine.show();
3940
+ this.fVerticalLine.draw({
3941
+ left: x * transform.scale + transform.position.x + transform.scaledPosition.x,
3942
+ top: 0,
3943
+ width: 1,
3944
+ height: size.height
3945
+ });
3946
+ }
3947
+ drawHorizontalLine(y, size, transform) {
3948
+ this.fHorizontalLine.show();
3949
+ this.fHorizontalLine.draw({
3950
+ left: 0,
3951
+ top: y * transform.scale + transform.position.y + transform.scaledPosition.y,
3952
+ width: size.width,
3953
+ height: 1
3954
+ });
3955
+ }
3956
+ hideVerticalLine() {
3957
+ this.fVerticalLine.hide();
3958
+ }
3959
+ hideHorizontalLine() {
3960
+ this.fHorizontalLine.hide();
3961
+ }
3962
+ }
3963
+
3964
+ const ALIGN_THRESHOLD = 10;
3965
+ /**
3966
+ * A class to find the nearest coordinate.
3967
+ */
3968
+ class NearestCoordinateFinder {
3969
+ /**
3970
+ * Constructor to initialize the NearestCoordinateFinder.
3971
+ * @param elements - The array of IRect elements.
3972
+ * @param target - The target IRect element.
3973
+ */
3974
+ constructor(elements, target) {
3975
+ this.elements = elements;
3976
+ this.target = target;
3977
+ }
3978
+ /**
3979
+ * Finds the nearest coordinate on a specified axis.
3980
+ * @returns The nearest coordinate and its distance.
3981
+ */
3982
+ findNearestCoordinateByX() {
3983
+ let nearest;
3984
+ let minDistance;
3985
+ for (const element of this.elements) {
3986
+ const distanceLeftLeft = this.target.x - element.x;
3987
+ const distanceLeftRight = this.target.x - (element.x + element.width);
3988
+ const distanceCenterCenter = this.target.gravityCenter.x - element.gravityCenter.x;
3989
+ const distanceRightLeft = (this.target.x + this.target.width) - element.x;
3990
+ const distanceRightRight = (this.target.x + this.target.width) - (element.x + element.width);
3991
+ if (Math.abs(distanceLeftLeft) <= ALIGN_THRESHOLD ||
3992
+ Math.abs(distanceLeftRight) <= ALIGN_THRESHOLD ||
3993
+ Math.abs(distanceCenterCenter) <= ALIGN_THRESHOLD ||
3994
+ Math.abs(distanceRightLeft) <= ALIGN_THRESHOLD ||
3995
+ Math.abs(distanceRightRight) <= ALIGN_THRESHOLD) {
3996
+ if (minDistance === undefined || Math.abs(distanceCenterCenter) < Math.abs(minDistance)) {
3997
+ minDistance = distanceCenterCenter;
3998
+ nearest = element.gravityCenter.x;
3999
+ }
4000
+ if (Math.abs(distanceLeftLeft) < Math.abs(minDistance)) {
4001
+ minDistance = distanceLeftLeft;
4002
+ nearest = element.x;
4003
+ }
4004
+ if (Math.abs(distanceRightRight) < Math.abs(minDistance)) {
4005
+ minDistance = distanceRightRight;
4006
+ nearest = element.x + element.width;
4007
+ }
4008
+ if (Math.abs(distanceLeftRight) < Math.abs(minDistance)) {
4009
+ minDistance = distanceLeftRight;
4010
+ nearest = element.x + element.width;
4011
+ }
4012
+ if (Math.abs(distanceRightLeft) < Math.abs(minDistance)) {
4013
+ minDistance = distanceRightLeft;
4014
+ nearest = element.x;
4015
+ }
4016
+ }
4017
+ }
4018
+ return { value: nearest, distance: minDistance };
4019
+ }
4020
+ /**
4021
+ * Finds the nearest coordinate on a specified axis.
4022
+ * @returns The nearest coordinate and its distance.
4023
+ */
4024
+ findNearestCoordinateByY() {
4025
+ let nearest;
4026
+ let minDistance;
4027
+ for (const element of this.elements) {
4028
+ const distanceTopTop = this.target.y - element.y;
4029
+ const distanceTopBottom = this.target.y - (element.y + element.height);
4030
+ const distanceCenterCenter = this.target.gravityCenter.y - element.gravityCenter.y;
4031
+ const distanceBottomTop = (this.target.y + this.target.height) - element.y;
4032
+ const distanceBottomBottom = (this.target.y + this.target.height) - (element.y + element.height);
4033
+ if (Math.abs(distanceTopTop) <= ALIGN_THRESHOLD ||
4034
+ Math.abs(distanceTopBottom) <= ALIGN_THRESHOLD ||
4035
+ Math.abs(distanceCenterCenter) <= ALIGN_THRESHOLD ||
4036
+ Math.abs(distanceBottomTop) <= ALIGN_THRESHOLD ||
4037
+ Math.abs(distanceBottomBottom) <= ALIGN_THRESHOLD) {
4038
+ if (minDistance === undefined || Math.abs(distanceCenterCenter) < Math.abs(minDistance)) {
4039
+ minDistance = distanceCenterCenter;
4040
+ nearest = element.gravityCenter.y;
4041
+ }
4042
+ if (Math.abs(distanceTopTop) < Math.abs(minDistance)) {
4043
+ minDistance = distanceTopTop;
4044
+ nearest = element.y;
4045
+ }
4046
+ if (Math.abs(distanceBottomBottom) < Math.abs(minDistance)) {
4047
+ minDistance = distanceBottomBottom;
4048
+ nearest = element.y + element.height;
4049
+ }
4050
+ if (Math.abs(distanceTopBottom) < Math.abs(minDistance)) {
4051
+ minDistance = distanceTopBottom;
4052
+ nearest = element.y + element.height;
4053
+ }
4054
+ if (Math.abs(distanceBottomTop) < Math.abs(minDistance)) {
4055
+ minDistance = distanceBottomTop;
4056
+ nearest = element.y;
4057
+ }
4058
+ }
4059
+ }
4060
+ return { value: nearest, distance: minDistance };
4061
+ }
4062
+ }
4063
+
4064
+ const F_LINE_ALIGNMENT = new InjectionToken('F_LINE_ALIGNMENT');
4065
+ class FLineAlignmentBase {
4066
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FLineAlignmentBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
4067
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FLineAlignmentBase, ngImport: i0 }); }
4078
4068
  }
4079
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableBase, decorators: [{
4069
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FLineAlignmentBase, decorators: [{
4080
4070
  type: Directive
4081
- }], ctorParameters: () => [{ type: i0.NgZone }] });
4071
+ }] });
4082
4072
 
4083
- class FDraggableDirective extends FDraggableBase {
4073
+ class FLineAlignmentComponent extends FLineAlignmentBase {
4084
4074
  get hostElement() {
4085
4075
  return this.elementReference.nativeElement;
4086
4076
  }
4087
- constructor(elementReference, fDraggableDataContext, ngZone, injector, fComponentsStore, document) {
4088
- super(ngZone);
4077
+ get transform() {
4078
+ return this.fComponentsStore.fCanvas.transform;
4079
+ }
4080
+ get flowHost() {
4081
+ return this.fComponentsStore.fFlow.hostElement;
4082
+ }
4083
+ constructor(elementReference, fComponentsStore, fDraggableDataContext, getElementRectInFlowHandler) {
4084
+ super();
4089
4085
  this.elementReference = elementReference;
4090
- this.fDraggableDataContext = fDraggableDataContext;
4091
- this.injector = injector;
4092
4086
  this.fComponentsStore = fComponentsStore;
4093
- this.subscriptions$ = new Subscription();
4094
- this.disabled = false;
4095
- this.fSelectionChange = new EventEmitter();
4096
- // @Output()
4097
- // public override fConnectionIntersectNode: EventEmitter<ConnectionIntersectNodeEvent> = new EventEmitter<ConnectionIntersectNodeEvent>();
4098
- this.fCreateNode = new EventEmitter();
4099
- this.fReassignConnection = new EventEmitter();
4100
- this.fCreateConnection = new EventEmitter();
4101
- this.selectedItemsOnPointerDown = 0;
4102
- this.document = document;
4087
+ this.fDraggableDataContext = fDraggableDataContext;
4088
+ this.getElementRectInFlowHandler = getElementRectInFlowHandler;
4089
+ this.size = SizeExtensions.initialize();
4090
+ this.draggedNodeRect = RectExtensions.initialize();
4091
+ this.rects = [];
4092
+ this.lineService = new LineService(this.hostElement);
4103
4093
  }
4104
4094
  ngOnInit() {
4105
- this.fComponentsStore.fDraggable = this;
4106
- }
4107
- ngAfterViewInit() {
4108
- super.subscribe(this.document);
4109
- }
4110
- onPointerDown(event) {
4111
- this.fDraggableDataContext.reset();
4112
- let result = event.isMouseLeftButton();
4113
- this.selectedItemsOnPointerDown = this.fDraggableDataContext.selectedItems.length;
4114
- this.injector.get(SingleSelectOnPointerDown).handle(event);
4115
- this.injector.get(ReassignConnectionPrepareDragSequence).handle(event);
4116
- this.injector.get(CreateConnectionPrepareDragSequence).handle(event);
4117
- this.emitSelectionChangeEvent();
4118
- return result;
4095
+ this.fDraggableDataContext.fLineAlignment = this;
4119
4096
  }
4120
- prepareDragSequence(event) {
4121
- this.injector.get(SelectionAreaPrepareDragSequence).handle(event);
4122
- this.injector.get(NodePrepareDragSequence).handle(event);
4123
- this.injector.get(CanvasPrepareDragSequence).handle(event);
4124
- this.injector.get(ExternalItemPrepareDragSequence).handle(event);
4125
- this.fDraggableDataContext.draggableItems.forEach((item) => {
4126
- item.initialize?.();
4097
+ initialize(allNodes, currentNodes) {
4098
+ this.size = this.flowHost.getBoundingClientRect();
4099
+ this.rects = [];
4100
+ const draggedNodeRects = currentNodes.map((x) => {
4101
+ return this.getElementRectInFlowHandler.handle(x.hostElement);
4127
4102
  });
4128
- if (this.fDraggableDataContext.draggableItems.length > 0) {
4129
- this.hostElement.classList.add('f-dragging');
4130
- }
4131
- }
4132
- onPointerMove(event) {
4133
- const pointerPositionInCanvas = Point.fromPoint(event.getPosition()).elementTransform(this.hostElement);
4134
- const difference = pointerPositionInCanvas.div(this.fDraggableDataContext.onPointerDownScale).sub(this.fDraggableDataContext.onPointerDownPosition);
4135
- this.fDraggableDataContext.draggableItems.forEach((item) => {
4136
- item.move(difference);
4103
+ this.draggedNodeRect = RectExtensions.union(draggedNodeRects);
4104
+ const allNodesExcludeCurrents = allNodes.filter((x) => {
4105
+ return !currentNodes.includes(x);
4106
+ });
4107
+ this.rects = allNodesExcludeCurrents.map((x) => {
4108
+ return this.getElementRectInFlowHandler.handle(x.hostElement);
4137
4109
  });
4138
4110
  }
4139
- onPointerUp(event) {
4140
- this.injector.get(ReassignConnectionOnPointerUp).handle(event);
4141
- this.injector.get(CreateConnectionOnPointerUp).handle(event);
4142
- this.injector.get(SelectionAreaOnPointerUp).handle(event);
4143
- this.injector.get(NodeOnPointerUp).handle(event);
4144
- this.injector.get(CanvasOnPointerUp).handle(event);
4145
- this.injector.get(ExternalItemOnPointerUp).handle(event);
4146
- this.hostElement.classList.remove('f-dragging');
4147
- this.emitSelectionChangeEvent();
4148
- this.fDraggableDataContext.reset();
4111
+ handle(difference) {
4112
+ this.drawIntersectingLines(difference);
4149
4113
  }
4150
- emitSelectionChangeEvent() {
4151
- if (!this.fDraggableDataContext.isSelectedChanged
4152
- && this.selectedItemsOnPointerDown === this.fDraggableDataContext.selectedItems.length) {
4153
- return;
4114
+ drawIntersectingLines(difference) {
4115
+ const intersect = this.findNearestCoordinate(difference);
4116
+ if (intersect.xResult.value !== undefined) {
4117
+ this.lineService.drawVerticalLine(intersect.xResult.value, this.size, this.transform);
4118
+ }
4119
+ else {
4120
+ this.lineService.hideVerticalLine();
4121
+ }
4122
+ if (intersect.yResult.value !== undefined) {
4123
+ this.lineService.drawHorizontalLine(intersect.yResult.value, this.size, this.transform);
4124
+ }
4125
+ else {
4126
+ this.lineService.hideHorizontalLine();
4154
4127
  }
4155
- let selectedNodes = [];
4156
- let selectedConnections = [];
4157
- this.fDraggableDataContext.selectedItems.forEach((x) => {
4158
- if (x.hostElement.classList.contains('f-node')) {
4159
- selectedNodes.push(x.hostElement.id);
4160
- }
4161
- else {
4162
- selectedConnections.push(x.hostElement.id);
4163
- }
4164
- });
4165
- this.fSelectionChange.emit(new SelectionChangeEvent(selectedNodes, selectedConnections));
4166
4128
  }
4167
- ngOnDestroy() {
4168
- super.unsubscribe();
4169
- this.subscriptions$.unsubscribe();
4129
+ findNearestCoordinate(difference) {
4130
+ const rect = RectExtensions.addPoint(this.draggedNodeRect, difference);
4131
+ const finder = new NearestCoordinateFinder(this.rects, rect);
4132
+ const xResult = finder.findNearestCoordinateByX();
4133
+ const yResult = finder.findNearestCoordinateByY();
4134
+ const result = { xResult, yResult };
4135
+ return result;
4170
4136
  }
4171
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableDirective, deps: [{ token: i0.ElementRef }, { token: FDraggableDataContext }, { token: i0.NgZone }, { token: i0.Injector }, { token: FComponentsStore }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Directive }); }
4172
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FDraggableDirective, selector: "f-flow[fDraggable]", inputs: { disabled: ["fDraggableDisabled", "disabled"] }, outputs: { fSelectionChange: "fSelectionChange", fCreateNode: "fCreateNode", fReassignConnection: "fReassignConnection", fCreateConnection: "fCreateConnection" }, providers: [
4173
- { provide: F_DRAGGABLE, useExisting: FDraggableDirective }
4174
- ], exportAs: ["fDraggable"], usesInheritance: true, ngImport: i0 }); }
4137
+ complete() {
4138
+ this.lineService.hideVerticalLine();
4139
+ this.lineService.hideHorizontalLine();
4140
+ }
4141
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FLineAlignmentComponent, deps: [{ token: i0.ElementRef }, { token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetElementRectInFlowHandler }], target: i0.ɵɵFactoryTarget.Component }); }
4142
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.1", type: FLineAlignmentComponent, selector: "f-line-alignment", host: { classAttribute: "f-line-alignment f-component" }, providers: [
4143
+ { provide: F_LINE_ALIGNMENT, useExisting: FLineAlignmentComponent }
4144
+ ], exportAs: ["fComponent"], usesInheritance: true, ngImport: i0, template: "", isInline: true, styles: [":host{display:block;position:absolute;left:0;top:0;width:100%;height:100%;overflow:hidden;pointer-events:none;-webkit-user-select:none;user-select:none}\n"] }); }
4175
4145
  }
4176
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableDirective, decorators: [{
4177
- type: Directive,
4178
- args: [{
4179
- selector: "f-flow[fDraggable]",
4180
- exportAs: 'fDraggable',
4181
- providers: [
4182
- { provide: F_DRAGGABLE, useExisting: FDraggableDirective }
4183
- ]
4184
- }]
4185
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FDraggableDataContext }, { type: i0.NgZone }, { type: i0.Injector }, { type: FComponentsStore }, { type: undefined, decorators: [{
4186
- type: Inject,
4187
- args: [DOCUMENT]
4188
- }] }], propDecorators: { disabled: [{
4189
- type: Input,
4190
- args: ['fDraggableDisabled']
4191
- }], fSelectionChange: [{
4192
- type: Output
4193
- }], fCreateNode: [{
4194
- type: Output
4195
- }], fReassignConnection: [{
4196
- type: Output
4197
- }], fCreateConnection: [{
4198
- type: Output
4199
- }] } });
4146
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FLineAlignmentComponent, decorators: [{
4147
+ type: Component,
4148
+ args: [{ selector: "f-line-alignment", template: "", exportAs: "fComponent", host: {
4149
+ 'class': 'f-line-alignment f-component'
4150
+ }, providers: [
4151
+ { provide: F_LINE_ALIGNMENT, useExisting: FLineAlignmentComponent }
4152
+ ], styles: [":host{display:block;position:absolute;left:0;top:0;width:100%;height:100%;overflow:hidden;pointer-events:none;-webkit-user-select:none;user-select:none}\n"] }]
4153
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetElementRectInFlowHandler }] });
4200
4154
 
4201
- class RedrawConnectionsHandler {
4202
- constructor(fComponentsStore, getElementRectInFlowHandler, getConnectionVectorHandler) {
4203
- this.fComponentsStore = fComponentsStore;
4204
- this.getElementRectInFlowHandler = getElementRectInFlowHandler;
4205
- this.getConnectionVectorHandler = getConnectionVectorHandler;
4155
+ const F_SELECTION_AREA = new InjectionToken('F_SELECTION_AREA');
4156
+ class FSelectionAreaBase {
4157
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FSelectionAreaBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
4158
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FSelectionAreaBase, ngImport: i0 }); }
4159
+ }
4160
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FSelectionAreaBase, decorators: [{
4161
+ type: Directive
4162
+ }] });
4163
+
4164
+ class FSelectionAreaComponent extends FSelectionAreaBase {
4165
+ get hostElement() {
4166
+ return this.elementReference.nativeElement;
4206
4167
  }
4207
- handle() {
4208
- this.resetConnectors();
4209
- this.fComponentsStore.fTempConnection?.setMarkers();
4210
- this.fComponentsStore.fConnections.forEach((connection) => {
4211
- const output = this.fComponentsStore.fOutputs.find((x) => x.id === connection.fOutputId);
4212
- const input = this.fComponentsStore.fInputs.find((x) => x.id === connection.fInputId);
4213
- if (output && input) {
4214
- this.setupConnection(output, input, connection);
4215
- }
4216
- });
4168
+ constructor(elementReference, fDraggableDataContext) {
4169
+ super();
4170
+ this.elementReference = elementReference;
4171
+ this.fDraggableDataContext = fDraggableDataContext;
4217
4172
  }
4218
- resetConnectors() {
4219
- this.fComponentsStore.fOutputs.forEach((output) => output.setConnected(false));
4220
- this.fComponentsStore.fInputs.forEach((input) => input.setConnected(false));
4173
+ ngOnInit() {
4174
+ this.fDraggableDataContext.fSelectionArea = this;
4175
+ this.hostElement.style.display = 'none';
4221
4176
  }
4222
- setupConnection(output, input, connection) {
4223
- output.setConnected(true);
4224
- input.setConnected(true);
4225
- const vector = this.getVector(output, input, connection);
4226
- connection.setVector(vector.point1, output.fConnectableSide, vector.point2, input.fConnectableSide);
4227
- connection.setMarkers();
4228
- connection.initialize();
4177
+ hide() {
4178
+ this.hostElement.style.display = 'none';
4229
4179
  }
4230
- getVector(output, input, connection) {
4231
- const outputRect = this.getElementRectInFlowHandler.handle(output.hostElement);
4232
- const inputRect = this.getElementRectInFlowHandler.handle(input.hostElement);
4233
- return this.getConnectionVectorHandler.handle(new GetConnectionVectorRequest(outputRect, inputRect, connection.fBehavior, output.fConnectableSide, input.fConnectableSide));
4180
+ show() {
4181
+ this.hostElement.style.display = 'block';
4234
4182
  }
4235
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: RedrawConnectionsHandler, deps: [{ token: FComponentsStore }, { token: GetElementRectInFlowHandler }, { token: GetConnectionVectorHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
4236
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: RedrawConnectionsHandler }); }
4183
+ draw(object) {
4184
+ const style = this.hostElement.style;
4185
+ style.left = object.left + 'px';
4186
+ style.top = object.top + 'px';
4187
+ style.width = object.width + 'px';
4188
+ style.height = object.height + 'px';
4189
+ }
4190
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FSelectionAreaComponent, deps: [{ token: i0.ElementRef }, { token: FDraggableDataContext }], target: i0.ɵɵFactoryTarget.Component }); }
4191
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.1", type: FSelectionAreaComponent, selector: "f-selection-area", host: { classAttribute: "f-selection-area f-component" }, providers: [
4192
+ { provide: F_SELECTION_AREA, useExisting: FSelectionAreaComponent }
4193
+ ], usesInheritance: true, ngImport: i0, template: ``, isInline: true, styles: [":host{position:absolute}\n"] }); }
4237
4194
  }
4238
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: RedrawConnectionsHandler, decorators: [{
4239
- type: Injectable
4240
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: GetElementRectInFlowHandler }, { type: GetConnectionVectorHandler }] });
4195
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FSelectionAreaComponent, decorators: [{
4196
+ type: Component,
4197
+ args: [{ selector: "f-selection-area", template: ``, host: {
4198
+ 'class': 'f-selection-area f-component'
4199
+ }, providers: [
4200
+ { provide: F_SELECTION_AREA, useExisting: FSelectionAreaComponent }
4201
+ ], styles: [":host{position:absolute}\n"] }]
4202
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FDraggableDataContext }] });
4241
4203
 
4242
4204
  const F_FLOW = new InjectionToken('F_FLOW');
4243
4205
  class FFlowBase {
@@ -4248,12 +4210,12 @@ class FFlowComponent extends FFlowBase {
4248
4210
  get hostElement() {
4249
4211
  return this.elementReference.nativeElement;
4250
4212
  }
4251
- constructor(elementReference, redrawConnectionsHandler, getAllNodesRectHandler, fComponentsStore) {
4213
+ constructor(elementReference, getAllNodesRectHandler, fComponentsStore, fMediator) {
4252
4214
  super();
4253
4215
  this.elementReference = elementReference;
4254
- this.redrawConnectionsHandler = redrawConnectionsHandler;
4255
4216
  this.getAllNodesRectHandler = getAllNodesRectHandler;
4256
4217
  this.fComponentsStore = fComponentsStore;
4218
+ this.fMediator = fMediator;
4257
4219
  this.subscription$ = new Subscription();
4258
4220
  this.fFlowId = `f-flow-${uniqueId++}`;
4259
4221
  this.fLoaded = new EventEmitter();
@@ -4268,7 +4230,7 @@ class FFlowComponent extends FFlowBase {
4268
4230
  }
4269
4231
  subscribeOnElementsChanges() {
4270
4232
  return this.fComponentsStore.changes.pipe(startWith(null), debounceTime(20)).subscribe(() => {
4271
- this.redrawConnectionsHandler.handle();
4233
+ this.fMediator.send(new RedrawConnectionsRequest());
4272
4234
  if (!this.isLoaded) {
4273
4235
  this.isLoaded = true;
4274
4236
  this.fLoaded.emit();
@@ -4281,8 +4243,9 @@ class FFlowComponent extends FFlowBase {
4281
4243
  ngOnDestroy() {
4282
4244
  this.subscription$.unsubscribe();
4283
4245
  }
4284
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FFlowComponent, deps: [{ token: i0.ElementRef }, { token: RedrawConnectionsHandler }, { token: GetAllNodesRectHandler }, { token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Component }); }
4246
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FFlowComponent, deps: [{ token: i0.ElementRef }, { token: GetAllNodesRectHandler }, { token: FComponentsStore }, { token: FFlowMediator }], target: i0.ɵɵFactoryTarget.Component }); }
4285
4247
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.1", type: FFlowComponent, selector: "f-flow", inputs: { fFlowId: "fFlowId" }, outputs: { fLoaded: "fLoaded" }, host: { properties: { "attr.id": "fFlowId" }, classAttribute: "f-component f-flow" }, providers: [
4248
+ FFlowMediator,
4286
4249
  FComponentsStore,
4287
4250
  FDraggableDataContext,
4288
4251
  ...SINGLE_SELECT_PROVIDERS,
@@ -4292,7 +4255,6 @@ class FFlowComponent extends FFlowBase {
4292
4255
  ...EXTERNAL_ITEM_PROVIDERS,
4293
4256
  ...CONNECTIONS_PROVIDERS,
4294
4257
  ...COMMON_PROVIDERS,
4295
- RedrawConnectionsHandler,
4296
4258
  { provide: F_FLOW, useExisting: FFlowComponent },
4297
4259
  ], usesInheritance: true, ngImport: i0, template: "<ng-container>\n <ng-content select=\"[fDefinitions]\"></ng-content>\n\n <ng-content select=\"f-background\"></ng-content>\n\n <ng-content select=\"f-line-alignment\"></ng-content>\n\n <ng-content select=\"f-canvas\"></ng-content>\n\n <ng-content select=\"f-selection-area\"></ng-content>\n</ng-container>\n", styles: [":host{display:block;position:relative;width:100%;height:100%;overflow:hidden;pointer-events:all;-webkit-user-select:none;user-select:none;touch-action:none}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
4298
4260
  }
@@ -4302,6 +4264,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
4302
4264
  '[attr.id]': 'fFlowId',
4303
4265
  class: "f-component f-flow",
4304
4266
  }, providers: [
4267
+ FFlowMediator,
4305
4268
  FComponentsStore,
4306
4269
  FDraggableDataContext,
4307
4270
  ...SINGLE_SELECT_PROVIDERS,
@@ -4311,10 +4274,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
4311
4274
  ...EXTERNAL_ITEM_PROVIDERS,
4312
4275
  ...CONNECTIONS_PROVIDERS,
4313
4276
  ...COMMON_PROVIDERS,
4314
- RedrawConnectionsHandler,
4315
4277
  { provide: F_FLOW, useExisting: FFlowComponent },
4316
4278
  ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container>\n <ng-content select=\"[fDefinitions]\"></ng-content>\n\n <ng-content select=\"f-background\"></ng-content>\n\n <ng-content select=\"f-line-alignment\"></ng-content>\n\n <ng-content select=\"f-canvas\"></ng-content>\n\n <ng-content select=\"f-selection-area\"></ng-content>\n</ng-container>\n", styles: [":host{display:block;position:relative;width:100%;height:100%;overflow:hidden;pointer-events:all;-webkit-user-select:none;user-select:none;touch-action:none}\n"] }]
4317
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: RedrawConnectionsHandler }, { type: GetAllNodesRectHandler }, { type: FComponentsStore }], propDecorators: { fFlowId: [{
4279
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: GetAllNodesRectHandler }, { type: FComponentsStore }, { type: FFlowMediator }], propDecorators: { fFlowId: [{
4318
4280
  type: Input
4319
4281
  }], fLoaded: [{
4320
4282
  type: Output
@@ -4413,5 +4375,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
4413
4375
  * Generated bundle index. Do not edit.
4414
4376
  */
4415
4377
 
4416
- export { CANVAS_PROVIDERS, COMMON_PROVIDERS, CONNECTIONS_PROVIDERS, CONNECTION_GRADIENT, CONNECTION_PATH, CONNECTION_TEXT, CalculateCenterBetweenPointsHandler, CalculateCenterBetweenPointsRequest, CalculateConnectionCenterHandler, CalculateConnectionCenterRequest, CalculateConnectorConnectableSideHandler, CalculateConnectorConnectableSideRequest, CanvasDragHandler, CanvasOnPointerUp, CanvasPrepareDragSequence, ConnectionDragHandler, ConnectionSourceDragHandler, ConnectionTargetDragHandler, CreateConnectionDragHandler, CreateConnectionEvent, CreateConnectionOnPointerUp, CreateConnectionPrepareDragSequence, CreateNodeEvent, EFConnectableSide, EFConnectionBehavior, EFConnectionType, EFDraggableType, EFMarkerType, EXTERNAL_ITEM_PROVIDERS, ExternalItemDragHandler, ExternalItemOnPointerUp, ExternalItemPrepareDragSequence, FBackgroundBase, FBackgroundComponent, FBezierPathBuilder, FCanvasBase, FCanvasChangeEvent, FCanvasComponent, FCellPatternComponent, FComponentsStore, FConnectionBase, FConnectionCenterDirective, FConnectionComponent, FConnectionDragHandleComponent, FConnectionForCreateComponent, FConnectionGradientComponent, FConnectionPathComponent, FConnectionSelectionComponent, FConnectionTextComponent, FConnectionTextPathDirective, FConnectorBase, FDragHandleDirective, FDraggableBase, FDraggableDataContext, FDraggableDirective, FExternalItemBase, FExternalItemDirective, FExternalItemService, FFlowBase, FFlowComponent, FFlowModule, FLOW, FLineAlignmentBase, FLineAlignmentComponent, FMarkerBase, FMarkerDirective, FNodeBase, FNodeDirective, FNodeInputBase, FNodeInputDirective, FNodeOutletBase, FNodeOutletDirective, FNodeOutputBase, FNodeOutputDirective, FPathBuilderBase, FPathBuilderSelector, FResizeObserver, FSegmentPathBuilder, FSelectionAreaBase, FSelectionAreaComponent, FStraightPathBuilder, FZoomBase, FZoomDirective, F_BACKGROUND, F_BACKGROUND_PATTERN, F_CANVAS, F_CONNECTION_DRAG_HANDLE_CLASS, F_CONNECTION_IDENTIFIERS, F_DRAGGABLE, F_DRAG_HANDLE, F_EXTERNAL_ITEM, F_FLOW, F_LINE_ALIGNMENT, F_MARKER, F_NODE, F_NODE_INPUT, F_NODE_OUTLET, F_NODE_OUTPUT, F_SELECTED_CLASS, F_SELECTION_AREA, F_ZOOM, FindFirstCanBeConnectedOutputByOutletHandler, FindInputsUnderPointerHandler, FindInputsUnderPointerRequest, FirstNotConnectedInputOfNodeUnderPointerHandler, GetAllNodesRectHandler, GetCanBeSelectedItemsHandler, GetConnectionHandler, GetConnectionVectorHandler, GetConnectionVectorRequest, GetElementRectInFlowHandler, GetIncomingConnectionsHandler, GetInputRectInFlowHandler, GetOutgoingConnectionsHandler, GetOutputRectInFlowHandler, IDragAndDropBase, InputNotFound, InputsUnderPointerHandler, IsConnectionUnderNodeHandler, LineElement, LineService, MOUSE_EVENT_IGNORE_TIME, NODE_PROVIDERS, NearestCoordinateFinder, NodeDragHandler, NodeOnPointerUp, NodePrepareDragSequence, OutputNotFound, ReassignConnectionDragHandler, ReassignConnectionEvent, ReassignConnectionOnPointerUp, ReassignConnectionPrepareDragSequence, RedrawConnectionsHandler, SELECTION_AREA_PROVIDERS, SINGLE_SELECT_PROVIDERS, SelectAllHandler, SelectionAreaDragHandle, SelectionAreaOnPointerUp, SelectionAreaPrepareDragSequence, SelectionChangeEvent, SingleSelectOnPointerDown, UpdateConnectionLayerHandler, UpdateNodeLayerHandler, castToConnectionBehavior, castToConnectionType, getExternalItem, getFlowUid, isExternalItem, isNode, isNodeDragHandle, isNodeInput, isNodeOutlet, isNodeOutput, mixinChangeConnectionSelection, mixinChangeConnectionVisibility, mixinChangePosition, mixinChangeZoom, mixinFitToParent, mixinOneToOneCentering, requiredOutput };
4378
+ export { CANVAS_PROVIDERS, COMMON_PROVIDERS, CONNECTIONS_PROVIDERS, CONNECTION_GRADIENT, CONNECTION_PATH, CONNECTION_TEXT, CalculateCenterBetweenPointsHandler, CalculateCenterBetweenPointsRequest, CalculateConnectionCenterHandler, CalculateConnectionCenterRequest, CalculateConnectorConnectableSideHandler, CalculateConnectorConnectableSideRequest, CanvasDragHandler, CanvasOnPointerUp, CanvasPrepareDragSequence, ConnectionDragHandler, ConnectionSourceDragHandler, ConnectionTargetDragHandler, CreateConnectionDragHandler, CreateConnectionOnPointerUp, CreateConnectionPrepareDragSequence, EFConnectableSide, EFConnectionBehavior, EFConnectionType, EFDraggableType, EFMarkerType, EXTERNAL_ITEM_PROVIDERS, ExternalItemDragHandler, ExternalItemOnPointerUp, ExternalItemPrepareDragSequence, FBackgroundBase, FBackgroundComponent, FBezierPathBuilder, FCanvasBase, FCanvasChangeEvent, FCanvasComponent, FCellPatternComponent, FComponentsStore, FConnectionBase, FConnectionCenterDirective, FConnectionComponent, FConnectionDragHandleComponent, FConnectionForCreateComponent, FConnectionGradientComponent, FConnectionPathComponent, FConnectionSelectionComponent, FConnectionTextComponent, FConnectionTextPathDirective, FConnectorBase, FCreateConnectionEvent, FCreateNodeEvent, FDragHandleDirective, FDraggableBase, FDraggableDataContext, FDraggableDirective, FExternalItemBase, FExternalItemDirective, FExternalItemService, FFlowBase, FFlowComponent, FFlowMediator, FFlowModule, FHandlerRegister, FLOW, FLineAlignmentBase, FLineAlignmentComponent, FMarkerBase, FMarkerDirective, FNodeBase, FNodeDirective, FNodeInputBase, FNodeInputDirective, FNodeOutletBase, FNodeOutletDirective, FNodeOutputBase, FNodeOutputDirective, FPathBuilderBase, FPathBuilderSelector, FReassignConnectionEvent, FResizeObserver, FSegmentPathBuilder, FSelectionAreaBase, FSelectionAreaComponent, FSelectionChangeEvent, FStraightPathBuilder, FZoomBase, FZoomDirective, F_BACKGROUND, F_BACKGROUND_PATTERN, F_CANVAS, F_CONNECTION_DRAG_HANDLE_CLASS, F_CONNECTION_IDENTIFIERS, F_DRAGGABLE, F_DRAG_HANDLE, F_EXTERNAL_ITEM, F_FLOW, F_LINE_ALIGNMENT, F_MARKER, F_NODE, F_NODE_INPUT, F_NODE_OUTLET, F_NODE_OUTPUT, F_SELECTED_CLASS, F_SELECTION_AREA, F_ZOOM, FindFirstCanBeConnectedOutputByOutletHandler, FindInputsUnderPointerHandler, FindInputsUnderPointerRequest, FirstNotConnectedInputOfNodeUnderPointerHandler, GetAllNodesRectHandler, GetCanBeSelectedItemsHandler, GetConnectionHandler, GetConnectionVectorHandler, GetConnectionVectorRequest, GetElementRectInFlowHandler, GetIncomingConnectionsHandler, GetInputRectInFlowHandler, GetOutgoingConnectionsHandler, GetOutputRectInFlowHandler, GetOutputRectInFlowRequest, GetOutputRectInFlowResponse, IDragAndDropBase, InputNotFound, InputsUnderPointerHandler, IsConnectionUnderNodeHandler, LineElement, LineService, MOUSE_EVENT_IGNORE_TIME, NODE_PROVIDERS, NearestCoordinateFinder, NodeDragHandler, NodeOnPointerUp, NodePrepareDragSequence, OutputNotFound, ReassignConnectionDragHandler, ReassignConnectionOnPointerUp, ReassignConnectionPrepareDragSequence, RedrawConnectionsHandler, RedrawConnectionsRequest, SELECTION_AREA_PROVIDERS, SINGLE_SELECT_PROVIDERS, SelectAllHandler, SelectionAreaDragHandle, SelectionAreaOnPointerUp, SelectionAreaPrepareDragSequence, SingleSelectOnPointerDown, UpdateConnectionLayerHandler, UpdateNodeLayerHandler, castToConnectionBehavior, castToConnectionType, getExternalItem, getFlowUid, isExternalItem, isNode, isNodeDragHandle, isNodeInput, isNodeOutlet, isNodeOutput, mixinChangeConnectionSelection, mixinChangeConnectionVisibility, requiredOutput };
4417
4379
  //# sourceMappingURL=foblex-flow.mjs.map