@foblex/flow 12.6.9 → 12.7.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 (20) hide show
  1. package/README.md +23 -18
  2. package/bundles/foblex-flow.umd.js +96 -58
  3. package/bundles/foblex-flow.umd.js.map +1 -1
  4. package/esm2015/f-canvas/f-canvas.component.js +12 -5
  5. package/esm2015/f-connection/common/f-connection-text/f-connection-text-path.directive.js +2 -2
  6. package/esm2015/f-draggable/connections/reassign-connection/f-reassign-connection.event.js +3 -2
  7. package/esm2015/f-draggable/connections/reassign-connection/reassign-connection-finalize/reassign-connection-finalize.execution.js +3 -3
  8. package/esm2015/f-draggable/node/connection-base-drag-handler.js +14 -3
  9. package/esm2015/f-draggable/node/create-move-nodes-drag-model-from-selection/create-move-nodes-drag-model-from-selection.execution.js +8 -4
  10. package/esm2015/f-draggable/node/create-move-nodes-drag-model-from-selection/create-move-nodes-drag-model-from-selection.request.js +4 -1
  11. package/esm2015/f-draggable/node/node-move-preparation/node-move-preparation.execution.js +17 -7
  12. package/esm2015/f-draggable/single-select/single-select.execution.js +4 -1
  13. package/esm2015/f-zoom/f-zoom-base.js +39 -39
  14. package/f-canvas/f-canvas.component.d.ts +1 -0
  15. package/f-draggable/connections/reassign-connection/f-reassign-connection.event.d.ts +3 -1
  16. package/f-draggable/node/connection-base-drag-handler.d.ts +1 -0
  17. package/f-draggable/node/create-move-nodes-drag-model-from-selection/create-move-nodes-drag-model-from-selection.request.d.ts +3 -0
  18. package/fesm2015/foblex-flow.js +96 -57
  19. package/fesm2015/foblex-flow.js.map +1 -1
  20. package/package.json +2 -2
@@ -22,6 +22,7 @@ export declare class FCanvasComponent extends FCanvasBase implements OnInit {
22
22
  ngOnInit(): void;
23
23
  redraw(): void;
24
24
  redrawWithAnimation(): void;
25
+ private isMobile;
25
26
  centerGroupOrNode(id: string, animated?: boolean): void;
26
27
  fitToScreen(toCenter?: IPoint, animated?: boolean): void;
27
28
  resetScaleAndCenter(animated?: boolean): void;
@@ -1,7 +1,9 @@
1
+ import { IPoint } from '@foblex/2d';
1
2
  export declare class FReassignConnectionEvent {
2
3
  fConnectionId: string;
3
4
  fOutputId: string;
4
5
  oldFInputId: string;
5
6
  newFInputId: string | undefined;
6
- constructor(fConnectionId: string, fOutputId: string, oldFInputId: string, newFInputId: string | undefined);
7
+ fDropPosition: IPoint;
8
+ constructor(fConnectionId: string, fOutputId: string, oldFInputId: string, newFInputId: string | undefined, fDropPosition: IPoint);
7
9
  }
@@ -16,6 +16,7 @@ export declare abstract class ConnectionBaseDragHandler implements IDraggableIte
16
16
  initialize(): void;
17
17
  private getOutput;
18
18
  private getInput;
19
+ private connectorNotFoundPrefix;
19
20
  abstract move(difference: IPoint): void;
20
21
  protected getDifference(difference: IPoint, restrictions: INodeMoveRestrictions): IPoint;
21
22
  protected redrawConnection(line: ILine): void;
@@ -1,2 +1,5 @@
1
+ import { FNodeBase } from '../../../f-node';
1
2
  export declare class CreateMoveNodesDragModelFromSelectionRequest {
3
+ nodeWithDisabledSelection?: FNodeBase | undefined;
4
+ constructor(nodeWithDisabledSelection?: FNodeBase | undefined);
2
5
  }
@@ -2286,11 +2286,12 @@ class ReassignConnectionFinalizeRequest {
2286
2286
  }
2287
2287
 
2288
2288
  class FReassignConnectionEvent {
2289
- constructor(fConnectionId, fOutputId, oldFInputId, newFInputId) {
2289
+ constructor(fConnectionId, fOutputId, oldFInputId, newFInputId, fDropPosition) {
2290
2290
  this.fConnectionId = fConnectionId;
2291
2291
  this.fOutputId = fOutputId;
2292
2292
  this.oldFInputId = oldFInputId;
2293
2293
  this.newFInputId = newFInputId;
2294
+ this.fDropPosition = fDropPosition;
2294
2295
  }
2295
2296
  }
2296
2297
 
@@ -2312,10 +2313,10 @@ let ReassignConnectionFinalizeExecution = class ReassignConnectionFinalizeExecut
2312
2313
  }
2313
2314
  emitEvent(event) {
2314
2315
  const input = this.getInputUnderPointer(event);
2315
- if (!input || !this.isReassignToDifferentInput(input)) {
2316
+ if (!!input && !this.isReassignToDifferentInput(input)) {
2316
2317
  return;
2317
2318
  }
2318
- this.fDraggable.fReassignConnection.emit(new FReassignConnectionEvent(this.dragHandler.fConnection.fId, this.dragHandler.fConnection.fOutputId, this.dragHandler.fConnection.fInputId, input.id));
2319
+ this.fDraggable.fReassignConnection.emit(new FReassignConnectionEvent(this.dragHandler.fConnection.fId, this.dragHandler.fConnection.fOutputId, this.dragHandler.fConnection.fInputId, input === null || input === void 0 ? void 0 : input.id, event.getPosition()));
2319
2320
  }
2320
2321
  getInputUnderPointer(event) {
2321
2322
  return this.fMediator.send(new GetInputUnderPointerRequest(event, this.dragHandler));
@@ -2718,7 +2719,7 @@ class FConnectionTextPathDirective {
2718
2719
  getSymbolWidth(name) {
2719
2720
  const text = name || 'connection';
2720
2721
  const { fontFamily, fontSize } = this.getFontStyles(this.hostElement);
2721
- this.fontSize = fontSize;
2722
+ this.fontSize = fontSize || '12px';
2722
2723
  const canvas = this.fBrowser.document.createElement('canvas');
2723
2724
  let context;
2724
2725
  try {
@@ -3932,10 +3933,21 @@ class ConnectionBaseDragHandler {
3932
3933
  this.fInputWithRect = this.fMediator.send(new GetConnectorWithRectRequest(this.getInput()));
3933
3934
  }
3934
3935
  getOutput() {
3935
- return this.fComponentsStore.fOutputs.find((x) => x.id === this.connection.fOutputId);
3936
+ const result = this.fComponentsStore.fOutputs.find((x) => x.id === this.connection.fOutputId);
3937
+ if (!result) {
3938
+ throw new Error(this.connectorNotFoundPrefix(`fOutput with id ${this.connection.fOutputId} not found`));
3939
+ }
3940
+ return result;
3936
3941
  }
3937
3942
  getInput() {
3938
- return this.fComponentsStore.fInputs.find((x) => x.id === this.connection.fInputId);
3943
+ const result = this.fComponentsStore.fInputs.find((x) => x.id === this.connection.fInputId);
3944
+ if (!result) {
3945
+ throw new Error(this.connectorNotFoundPrefix(`fInput with id ${this.connection.fInputId} not found`));
3946
+ }
3947
+ return result;
3948
+ }
3949
+ connectorNotFoundPrefix(message) {
3950
+ return `ConnectionDragHandler Error: Connection From (fOutput)${this.connection.fOutputId} To (fInput)${this.connection.fInputId}. ${message}. Please ensure that all f-connections are associated with existing connectors`;
3939
3951
  }
3940
3952
  getDifference(difference, restrictions) {
3941
3953
  return {
@@ -4171,6 +4183,9 @@ const DEFAULT_RESTRICTIONS = {
4171
4183
  };
4172
4184
 
4173
4185
  class CreateMoveNodesDragModelFromSelectionRequest {
4186
+ constructor(nodeWithDisabledSelection) {
4187
+ this.nodeWithDisabledSelection = nodeWithDisabledSelection;
4188
+ }
4174
4189
  }
4175
4190
 
4176
4191
  class NodeDragHandler {
@@ -4225,13 +4240,17 @@ let CreateMoveNodesDragModelFromSelectionExecution = class CreateMoveNodesDragMo
4225
4240
  this.fMediator = fMediator;
4226
4241
  }
4227
4242
  handle(request) {
4228
- const itemsToDrag = this.getNodesWithRestrictions(this.getSelectedNodes());
4243
+ const itemsToDrag = this.getNodesWithRestrictions(this.getSelectedNodes(request.nodeWithDisabledSelection));
4229
4244
  return this.getDragHandlersWithConnections(this.getDragHandlersFromNodes(itemsToDrag), this.getAllOutputIds(itemsToDrag), this.getAllInputIds(itemsToDrag));
4230
4245
  }
4231
- getSelectedNodes() {
4232
- return this.fDraggableDataContext.selectedItems
4246
+ getSelectedNodes(nodeWithDisabledSelection) {
4247
+ const result = this.fDraggableDataContext.selectedItems
4233
4248
  .map((x) => this.fComponentsStore.findNode(x.hostElement))
4234
4249
  .filter((x) => !!x);
4250
+ if (nodeWithDisabledSelection) {
4251
+ result.push(nodeWithDisabledSelection);
4252
+ }
4253
+ return result;
4235
4254
  }
4236
4255
  getNodesWithRestrictions(selectedNodes) {
4237
4256
  const result = [];
@@ -4312,22 +4331,32 @@ let NodeMovePreparationExecution = class NodeMovePreparationExecution {
4312
4331
  return this.fComponentsStore.fFlow.hostElement;
4313
4332
  }
4314
4333
  handle(request) {
4315
- this.selectAndUpdateNodeLayer(request.event.targetElement);
4316
- const itemsToDrag = this.createDragModelFromSelection();
4334
+ const node = this.getNode(request.event.targetElement);
4335
+ if (!node) {
4336
+ throw new Error('Node not found');
4337
+ }
4338
+ let itemsToDrag = [];
4339
+ if (!node.fSelectionDisabled) {
4340
+ this.selectAndUpdateNodeLayer(node);
4341
+ itemsToDrag = this.createDragModelFromSelection();
4342
+ }
4343
+ else {
4344
+ itemsToDrag = this.createDragModelFromSelection(node);
4345
+ }
4317
4346
  this.initializeLineAlignment(this.filterNodesFromDraggableItems(itemsToDrag));
4318
4347
  this.fDraggableDataContext.onPointerDownScale = this.transform.scale;
4319
4348
  this.fDraggableDataContext.onPointerDownPosition = Point.fromPoint(request.event.getPosition())
4320
4349
  .elementTransform(this.flowHost).div(this.transform.scale);
4321
4350
  this.fDraggableDataContext.draggableItems = itemsToDrag;
4322
4351
  }
4323
- selectAndUpdateNodeLayer(targetElement) {
4324
- this.fMediator.send(new SelectAndUpdateNodeLayerRequest(this.getNode(targetElement)));
4352
+ selectAndUpdateNodeLayer(node) {
4353
+ this.fMediator.send(new SelectAndUpdateNodeLayerRequest(node));
4325
4354
  }
4326
4355
  getNode(targetElement) {
4327
4356
  return this.fComponentsStore.findNode(targetElement);
4328
4357
  }
4329
- createDragModelFromSelection() {
4330
- return this.fMediator.send(new CreateMoveNodesDragModelFromSelectionRequest());
4358
+ createDragModelFromSelection(nodeWithDisabledSelection) {
4359
+ return this.fMediator.send(new CreateMoveNodesDragModelFromSelectionRequest(nodeWithDisabledSelection));
4331
4360
  }
4332
4361
  initializeLineAlignment(nodesToDrag) {
4333
4362
  var _a;
@@ -4926,6 +4955,9 @@ let SingleSelectExecution = class SingleSelectExecution {
4926
4955
  this.clearSelection();
4927
4956
  this.selectItem(item);
4928
4957
  }
4958
+ else if (item.fSelectionDisabled) {
4959
+ this.clearSelection();
4960
+ }
4929
4961
  }
4930
4962
  else {
4931
4963
  this.clearSelection();
@@ -7183,11 +7215,18 @@ class FCanvasComponent extends FCanvasBase {
7183
7215
  }
7184
7216
  redrawWithAnimation() {
7185
7217
  var _a;
7218
+ let duration = F_CANVAS_ANIMATION_DURATION;
7219
+ if (this.isMobile()) {
7220
+ duration = 80;
7221
+ }
7186
7222
  (_a = this.fComponentsStore.fBackground) === null || _a === void 0 ? void 0 : _a.setTransform(this.transform);
7187
- this.hostElement.setAttribute("style", `transition: transform ${F_CANVAS_ANIMATION_DURATION}ms ease-in-out; transform: ${TransformModelExtensions.toString(this.transform)}`);
7188
- setTimeout(() => {
7189
- this.redraw();
7190
- }, F_CANVAS_ANIMATION_DURATION);
7223
+ this.hostElement.setAttribute("style", `transition: transform ${duration}ms ease-in-out; transform: ${TransformModelExtensions.toString(this.transform)}`);
7224
+ setTimeout(() => this.redraw(), F_CANVAS_ANIMATION_DURATION);
7225
+ }
7226
+ isMobile() {
7227
+ // @ts-ignore
7228
+ const userAgent = navigator.userAgent || navigator.vendor || window['opera'];
7229
+ return /android|iPad|iPhone|iPod/i.test(userAgent);
7191
7230
  }
7192
7231
  centerGroupOrNode(id, animated = true) {
7193
7232
  this.fMediator.send(new CenterGroupOrNodeRequest(id, animated));
@@ -7859,6 +7898,40 @@ class FZoomBase {
7859
7898
  this.fComponentsStore = fComponentsStore;
7860
7899
  this.isEnabled = false;
7861
7900
  this.listeners = EventExtensions.emptyListener();
7901
+ this.onWheel = (event) => {
7902
+ var _a;
7903
+ event.preventDefault();
7904
+ const targetElement = event.target;
7905
+ if (((_a = this.fComponentsStore.fDraggable) === null || _a === void 0 ? void 0 : _a.isDragStarted) || (targetElement === null || targetElement === void 0 ? void 0 : targetElement.closest('[fLockedContext]'))) {
7906
+ return;
7907
+ }
7908
+ let result = this.getScale();
7909
+ const direction = event.deltaY > 0 ? -1 : 1;
7910
+ const step = this.step;
7911
+ result = result + step * direction;
7912
+ result = Math.max(this.minimum, Math.min(result, this.maximum));
7913
+ const pointerPositionInFlow = new Point(event.clientX, event.clientY).elementTransform(this.flowHost);
7914
+ this.fCanvas.setZoom(result, pointerPositionInFlow);
7915
+ this.fCanvas.redraw();
7916
+ this.fCanvas.emitCanvasChangeEvent();
7917
+ };
7918
+ this.onDoubleClick = (event) => {
7919
+ var _a;
7920
+ event.preventDefault();
7921
+ const targetElement = event.target;
7922
+ if (((_a = this.fComponentsStore.fDraggable) === null || _a === void 0 ? void 0 : _a.isDragStarted) || isNode(targetElement) || (targetElement === null || targetElement === void 0 ? void 0 : targetElement.closest('[fLockedContext]'))) {
7923
+ return;
7924
+ }
7925
+ let result = this.getScale();
7926
+ const direction = 1;
7927
+ const step = this.dblClickStep;
7928
+ result = result + step * direction;
7929
+ result = Math.max(this.minimum, Math.min(result, this.maximum));
7930
+ const pointerPositionInFlow = new Point(event.clientX, event.clientY).elementTransform(this.flowHost);
7931
+ this.fCanvas.setZoom(result, pointerPositionInFlow);
7932
+ this.fCanvas.redrawWithAnimation();
7933
+ this.fCanvas.emitCanvasChangeEvent();
7934
+ };
7862
7935
  }
7863
7936
  get flowHost() {
7864
7937
  return this.fComponentsStore.flowHost;
@@ -7879,50 +7952,16 @@ class FZoomBase {
7879
7952
  if (!this.flowHost) {
7880
7953
  return;
7881
7954
  }
7882
- this.flowHost.addEventListener('wheel', this.onWheel.bind(this));
7883
- this.flowHost.addEventListener('dblclick', this.onDoubleClick.bind(this));
7955
+ this.flowHost.addEventListener('wheel', this.onWheel);
7956
+ this.flowHost.addEventListener('dblclick', this.onDoubleClick);
7884
7957
  this.listeners = () => {
7885
- this.flowHost.removeEventListener('wheel', this.onWheel.bind(this));
7886
- this.flowHost.removeEventListener('dblclick', this.onDoubleClick.bind(this));
7958
+ this.flowHost.removeEventListener('wheel', this.onWheel);
7959
+ this.flowHost.removeEventListener('dblclick', this.onDoubleClick);
7887
7960
  };
7888
7961
  }
7889
7962
  getScale() {
7890
7963
  return this.fCanvas.transform.scale || 1;
7891
7964
  }
7892
- onWheel(event) {
7893
- var _a;
7894
- event.preventDefault();
7895
- const targetElement = event.target;
7896
- if (((_a = this.fComponentsStore.fDraggable) === null || _a === void 0 ? void 0 : _a.isDragStarted) || (targetElement === null || targetElement === void 0 ? void 0 : targetElement.closest('[fLockedContext]'))) {
7897
- return;
7898
- }
7899
- let result = this.getScale();
7900
- const direction = event.deltaY > 0 ? -1 : 1;
7901
- const step = this.step;
7902
- result = result + step * direction;
7903
- result = Math.max(this.minimum, Math.min(result, this.maximum));
7904
- const pointerPositionInFlow = new Point(event.clientX, event.clientY).elementTransform(this.flowHost);
7905
- this.fCanvas.setZoom(result, pointerPositionInFlow);
7906
- this.fCanvas.redraw();
7907
- this.fCanvas.emitCanvasChangeEvent();
7908
- }
7909
- onDoubleClick(event) {
7910
- var _a;
7911
- event.preventDefault();
7912
- const targetElement = event.target;
7913
- if (((_a = this.fComponentsStore.fDraggable) === null || _a === void 0 ? void 0 : _a.isDragStarted) || isNode(targetElement) || (targetElement === null || targetElement === void 0 ? void 0 : targetElement.closest('[fLockedContext]'))) {
7914
- return;
7915
- }
7916
- let result = this.getScale();
7917
- const direction = 1;
7918
- const step = this.dblClickStep;
7919
- result = result + step * direction;
7920
- result = Math.max(this.minimum, Math.min(result, this.maximum));
7921
- const pointerPositionInFlow = new Point(event.clientX, event.clientY).elementTransform(this.flowHost);
7922
- this.fCanvas.setZoom(result, pointerPositionInFlow);
7923
- this.fCanvas.redrawWithAnimation();
7924
- this.fCanvas.emitCanvasChangeEvent();
7925
- }
7926
7965
  onZoomToCenter(deltaY, position) {
7927
7966
  const preventDefault = () => {
7928
7967
  };