@knotx/plugins-connection-line 0.3.0 → 0.3.2

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.
package/dist/index.cjs CHANGED
@@ -76,14 +76,14 @@ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use
76
76
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
77
77
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
78
78
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
79
- var _destroy_dec, _init_dec, _createEdges_dec, _createNodeAndEdge_dec, _containerRender_dec, _registerCreator_dec, _getConnectHandleAttributes_dec, _selectedNodeIds_dec, _canInteract_dec, _endInteraction_dec, _startInteraction_dec, _dispatchEdgeOperation_dec, _dispatchNodeOperation_dec, _getNode_dec, _a, _init;
79
+ var _destroy_dec, _init_dec, _createEdges_dec, _createNodeAndEdge_dec, _containerRender_dec, _registerCreator_dec, _getConnectHandleAttributes_dec, _selected_dec, _interaction_dec, _dispatchEdgeOperation_dec, _dispatchNodeOperation_dec, _getNode_dec, _a, _init;
80
80
  const DEFAULT_CONFIG = {
81
81
  allowCreateNodeOnBlankArea: true,
82
82
  edgeType: "bezier",
83
83
  connectionLineClassName: core.bem("connection-line", "line"),
84
84
  allowMultiDrag: true
85
85
  };
86
- class ConnectionLine extends (_a = core.BasePlugin, _getNode_dec = [decorators.inject.getNode()], _dispatchNodeOperation_dec = [decorators.inject.dispatchNodeOperation()], _dispatchEdgeOperation_dec = [decorators.inject.dispatchEdgeOperation()], _startInteraction_dec = [decorators.inject.startInteraction()], _endInteraction_dec = [decorators.inject.endInteraction()], _canInteract_dec = [decorators.inject.canInteract()], _selectedNodeIds_dec = [decorators.inject.selection.selectedNodeIds()], _getConnectHandleAttributes_dec = [decorators.register("getConnectHandleAttributes")], _registerCreator_dec = [decorators.register("registerCreator")], _containerRender_dec = [decorators.layer(core.Layer.Nodes, 10)], _createNodeAndEdge_dec = [decorators.edgeOperator()], _createEdges_dec = [decorators.edgeOperator()], _init_dec = [decorators.OnInit], _destroy_dec = [decorators.OnDestroy], _a) {
86
+ class ConnectionLine extends (_a = core.BasePlugin, _getNode_dec = [decorators.inject.getNode()], _dispatchNodeOperation_dec = [decorators.inject.dispatchNodeOperation()], _dispatchEdgeOperation_dec = [decorators.inject.dispatchEdgeOperation()], _interaction_dec = [decorators.inject.interaction()], _selected_dec = [decorators.inject.selection.selected()], _getConnectHandleAttributes_dec = [decorators.register("getConnectHandleAttributes")], _registerCreator_dec = [decorators.register("registerCreator")], _containerRender_dec = [decorators.layer(core.Layer.Nodes, 10)], _createNodeAndEdge_dec = [decorators.edgeOperator()], _createEdges_dec = [decorators.edgeOperator()], _init_dec = [decorators.OnInit], _destroy_dec = [decorators.OnDestroy], _a) {
87
87
  constructor() {
88
88
  super(...arguments);
89
89
  __runInitializers(_init, 5, this);
@@ -91,11 +91,9 @@ class ConnectionLine extends (_a = core.BasePlugin, _getNode_dec = [decorators.i
91
91
  __publicField(this, "getNode", __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
92
92
  __publicField(this, "dispatchNodeOperation", __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
93
93
  __publicField(this, "dispatchEdgeOperation", __runInitializers(_init, 16, this)), __runInitializers(_init, 19, this);
94
- __publicField(this, "startInteraction", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this);
95
- __publicField(this, "endInteraction", __runInitializers(_init, 24, this)), __runInitializers(_init, 27, this);
96
- __publicField(this, "canInteract", __runInitializers(_init, 28, this)), __runInitializers(_init, 31, this);
97
- __publicField(this, "selectedNodeIds", __runInitializers(_init, 32, this, [])), __runInitializers(_init, 35, this);
98
- __publicField(this, "getConnectHandleAttributes", __runInitializers(_init, 36, this, ({ nodeId, type, index = 0, className = "" }) => {
94
+ __publicField(this, "interaction", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this);
95
+ __publicField(this, "selected", __runInitializers(_init, 24, this, [])), __runInitializers(_init, 27, this);
96
+ __publicField(this, "getConnectHandleAttributes", __runInitializers(_init, 28, this, ({ nodeId, type, index = 0, className = "" }) => {
99
97
  return {
100
98
  "className": `${className} ${this.classNames.connector} ${this.classNames[type]}`,
101
99
  "data-plugin-id": this.pluginId,
@@ -103,7 +101,7 @@ class ConnectionLine extends (_a = core.BasePlugin, _getNode_dec = [decorators.i
103
101
  "data-connector-id": String(index),
104
102
  "data-connector-type": type
105
103
  };
106
- })), __runInitializers(_init, 39, this);
104
+ })), __runInitializers(_init, 31, this);
107
105
  __publicField(this, "classNames", {
108
106
  connector: core.bem("connection-line", "connector"),
109
107
  source: core.bem("connection-line", "connector", "source"),
@@ -122,7 +120,7 @@ class ConnectionLine extends (_a = core.BasePlugin, _getNode_dec = [decorators.i
122
120
  // 新节点创建器列表
123
121
  __publicField(this, "creators$", new rxjs.BehaviorSubject([]));
124
122
  __publicField(this, "config", DEFAULT_CONFIG);
125
- __publicField(this, "registerCreator", __runInitializers(_init, 40, this, (creator) => {
123
+ __publicField(this, "registerCreator", __runInitializers(_init, 32, this, (creator) => {
126
124
  const creators = this.creators$.value;
127
125
  creators.push(creator);
128
126
  this.creators$.next(creators);
@@ -134,7 +132,7 @@ class ConnectionLine extends (_a = core.BasePlugin, _getNode_dec = [decorators.i
134
132
  this.creators$.next(currentCreators);
135
133
  }
136
134
  };
137
- })), __runInitializers(_init, 43, this);
135
+ })), __runInitializers(_init, 35, this);
138
136
  }
139
137
  containerRender() {
140
138
  const size = this.getContainerSize();
@@ -169,10 +167,10 @@ class ConnectionLine extends (_a = core.BasePlugin, _getNode_dec = [decorators.i
169
167
  * 根据当前拖拽的节点和选中的节点决定
170
168
  */
171
169
  getSourceNodeIdsForDrag(currentNodeId) {
172
- if (!this.config.allowMultiDrag || !this.selectedNodeIds.includes(currentNodeId)) {
170
+ if (!this.config.allowMultiDrag || !this.selected.some((item) => item.id === currentNodeId)) {
173
171
  return [currentNodeId];
174
172
  }
175
- return [...this.selectedNodeIds];
173
+ return this.selected.filter((item) => item.type === "node").map((item) => item.id);
176
174
  }
177
175
  /**
178
176
  * 创建临时连接线
@@ -357,18 +355,18 @@ class ConnectionLine extends (_a = core.BasePlugin, _getNode_dec = [decorators.i
357
355
  }
358
356
  const state = this.createConnectionLine(sourceNodeId, nodeStartPosition);
359
357
  this.connectionLines.set(sourceNodeId, state);
360
- this.startInteraction(this.pluginId, "connect", core.InteractionPriority.EntityConnectDrag);
358
+ this.interaction.start(this.pluginId, "connect", core.InteractionPriority.EntityConnectDrag);
361
359
  });
362
360
  },
363
361
  move: (event) => {
364
- if (this.connectionLines.size === 0 || !this.currentDragNodeId || !this.canInteract(this.pluginId, "connect"))
362
+ if (this.connectionLines.size === 0 || !this.currentDragNodeId || !this.interaction.canInteract(core.InteractionPriority.EntityConnectDrag))
365
363
  return;
366
364
  this.updateAllConnectionLines(event.dx, event.dy);
367
365
  },
368
366
  end: () => {
369
367
  this.clearAllConnectionLines();
370
368
  this.currentDragNodeId = null;
371
- this.endInteraction(this.pluginId, "connect");
369
+ this.interaction.end(this.pluginId, "connect");
372
370
  }
373
371
  }
374
372
  });
@@ -429,10 +427,8 @@ __decorateElement(_init, 1, "destroy", _destroy_dec, ConnectionLine);
429
427
  __decorateElement(_init, 5, "getNode", _getNode_dec, ConnectionLine);
430
428
  __decorateElement(_init, 5, "dispatchNodeOperation", _dispatchNodeOperation_dec, ConnectionLine);
431
429
  __decorateElement(_init, 5, "dispatchEdgeOperation", _dispatchEdgeOperation_dec, ConnectionLine);
432
- __decorateElement(_init, 5, "startInteraction", _startInteraction_dec, ConnectionLine);
433
- __decorateElement(_init, 5, "endInteraction", _endInteraction_dec, ConnectionLine);
434
- __decorateElement(_init, 5, "canInteract", _canInteract_dec, ConnectionLine);
435
- __decorateElement(_init, 5, "selectedNodeIds", _selectedNodeIds_dec, ConnectionLine);
430
+ __decorateElement(_init, 5, "interaction", _interaction_dec, ConnectionLine);
431
+ __decorateElement(_init, 5, "selected", _selected_dec, ConnectionLine);
436
432
  __decorateElement(_init, 5, "getConnectHandleAttributes", _getConnectHandleAttributes_dec, ConnectionLine);
437
433
  __decorateElement(_init, 5, "registerCreator", _registerCreator_dec, ConnectionLine);
438
434
  __decoratorMetadata(_init, ConnectionLine);
package/dist/index.d.cts CHANGED
@@ -65,10 +65,8 @@ declare class ConnectionLine extends BasePlugin<'connectionLine', ConnectionLine
65
65
  getNode: Engine['getNode'];
66
66
  dispatchNodeOperation: Engine['dispatchNodeOperation'];
67
67
  dispatchEdgeOperation: Engine['dispatchEdgeOperation'];
68
- startInteraction: Engine['startInteraction'];
69
- endInteraction: Engine['endInteraction'];
70
- canInteract: Engine['canInteract'];
71
- selectedNodeIds: string[];
68
+ interaction: Engine['interaction'];
69
+ selected: PluginData['selection']['selected'];
72
70
  getConnectHandleAttributes: PluginData['connectionLine']['getConnectHandleAttributes'];
73
71
  private classNames;
74
72
  private connectionLines;
package/dist/index.d.mts CHANGED
@@ -65,10 +65,8 @@ declare class ConnectionLine extends BasePlugin<'connectionLine', ConnectionLine
65
65
  getNode: Engine['getNode'];
66
66
  dispatchNodeOperation: Engine['dispatchNodeOperation'];
67
67
  dispatchEdgeOperation: Engine['dispatchEdgeOperation'];
68
- startInteraction: Engine['startInteraction'];
69
- endInteraction: Engine['endInteraction'];
70
- canInteract: Engine['canInteract'];
71
- selectedNodeIds: string[];
68
+ interaction: Engine['interaction'];
69
+ selected: PluginData['selection']['selected'];
72
70
  getConnectHandleAttributes: PluginData['connectionLine']['getConnectHandleAttributes'];
73
71
  private classNames;
74
72
  private connectionLines;
package/dist/index.d.ts CHANGED
@@ -65,10 +65,8 @@ declare class ConnectionLine extends BasePlugin<'connectionLine', ConnectionLine
65
65
  getNode: Engine['getNode'];
66
66
  dispatchNodeOperation: Engine['dispatchNodeOperation'];
67
67
  dispatchEdgeOperation: Engine['dispatchEdgeOperation'];
68
- startInteraction: Engine['startInteraction'];
69
- endInteraction: Engine['endInteraction'];
70
- canInteract: Engine['canInteract'];
71
- selectedNodeIds: string[];
68
+ interaction: Engine['interaction'];
69
+ selected: PluginData['selection']['selected'];
72
70
  getConnectHandleAttributes: PluginData['connectionLine']['getConnectHandleAttributes'];
73
71
  private classNames;
74
72
  private connectionLines;
package/dist/index.js CHANGED
@@ -70,14 +70,14 @@ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use
70
70
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
71
71
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
72
72
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
73
- var _destroy_dec, _init_dec, _createEdges_dec, _createNodeAndEdge_dec, _containerRender_dec, _registerCreator_dec, _getConnectHandleAttributes_dec, _selectedNodeIds_dec, _canInteract_dec, _endInteraction_dec, _startInteraction_dec, _dispatchEdgeOperation_dec, _dispatchNodeOperation_dec, _getNode_dec, _a, _init;
73
+ var _destroy_dec, _init_dec, _createEdges_dec, _createNodeAndEdge_dec, _containerRender_dec, _registerCreator_dec, _getConnectHandleAttributes_dec, _selected_dec, _interaction_dec, _dispatchEdgeOperation_dec, _dispatchNodeOperation_dec, _getNode_dec, _a, _init;
74
74
  const DEFAULT_CONFIG = {
75
75
  allowCreateNodeOnBlankArea: true,
76
76
  edgeType: "bezier",
77
77
  connectionLineClassName: bem("connection-line", "line"),
78
78
  allowMultiDrag: true
79
79
  };
80
- class ConnectionLine extends (_a = BasePlugin, _getNode_dec = [inject.getNode()], _dispatchNodeOperation_dec = [inject.dispatchNodeOperation()], _dispatchEdgeOperation_dec = [inject.dispatchEdgeOperation()], _startInteraction_dec = [inject.startInteraction()], _endInteraction_dec = [inject.endInteraction()], _canInteract_dec = [inject.canInteract()], _selectedNodeIds_dec = [inject.selection.selectedNodeIds()], _getConnectHandleAttributes_dec = [register("getConnectHandleAttributes")], _registerCreator_dec = [register("registerCreator")], _containerRender_dec = [layer(Layer.Nodes, 10)], _createNodeAndEdge_dec = [edgeOperator()], _createEdges_dec = [edgeOperator()], _init_dec = [OnInit], _destroy_dec = [OnDestroy], _a) {
80
+ class ConnectionLine extends (_a = BasePlugin, _getNode_dec = [inject.getNode()], _dispatchNodeOperation_dec = [inject.dispatchNodeOperation()], _dispatchEdgeOperation_dec = [inject.dispatchEdgeOperation()], _interaction_dec = [inject.interaction()], _selected_dec = [inject.selection.selected()], _getConnectHandleAttributes_dec = [register("getConnectHandleAttributes")], _registerCreator_dec = [register("registerCreator")], _containerRender_dec = [layer(Layer.Nodes, 10)], _createNodeAndEdge_dec = [edgeOperator()], _createEdges_dec = [edgeOperator()], _init_dec = [OnInit], _destroy_dec = [OnDestroy], _a) {
81
81
  constructor() {
82
82
  super(...arguments);
83
83
  __runInitializers(_init, 5, this);
@@ -85,11 +85,9 @@ class ConnectionLine extends (_a = BasePlugin, _getNode_dec = [inject.getNode()]
85
85
  __publicField(this, "getNode", __runInitializers(_init, 8, this)), __runInitializers(_init, 11, this);
86
86
  __publicField(this, "dispatchNodeOperation", __runInitializers(_init, 12, this)), __runInitializers(_init, 15, this);
87
87
  __publicField(this, "dispatchEdgeOperation", __runInitializers(_init, 16, this)), __runInitializers(_init, 19, this);
88
- __publicField(this, "startInteraction", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this);
89
- __publicField(this, "endInteraction", __runInitializers(_init, 24, this)), __runInitializers(_init, 27, this);
90
- __publicField(this, "canInteract", __runInitializers(_init, 28, this)), __runInitializers(_init, 31, this);
91
- __publicField(this, "selectedNodeIds", __runInitializers(_init, 32, this, [])), __runInitializers(_init, 35, this);
92
- __publicField(this, "getConnectHandleAttributes", __runInitializers(_init, 36, this, ({ nodeId, type, index = 0, className = "" }) => {
88
+ __publicField(this, "interaction", __runInitializers(_init, 20, this)), __runInitializers(_init, 23, this);
89
+ __publicField(this, "selected", __runInitializers(_init, 24, this, [])), __runInitializers(_init, 27, this);
90
+ __publicField(this, "getConnectHandleAttributes", __runInitializers(_init, 28, this, ({ nodeId, type, index = 0, className = "" }) => {
93
91
  return {
94
92
  "className": `${className} ${this.classNames.connector} ${this.classNames[type]}`,
95
93
  "data-plugin-id": this.pluginId,
@@ -97,7 +95,7 @@ class ConnectionLine extends (_a = BasePlugin, _getNode_dec = [inject.getNode()]
97
95
  "data-connector-id": String(index),
98
96
  "data-connector-type": type
99
97
  };
100
- })), __runInitializers(_init, 39, this);
98
+ })), __runInitializers(_init, 31, this);
101
99
  __publicField(this, "classNames", {
102
100
  connector: bem("connection-line", "connector"),
103
101
  source: bem("connection-line", "connector", "source"),
@@ -116,7 +114,7 @@ class ConnectionLine extends (_a = BasePlugin, _getNode_dec = [inject.getNode()]
116
114
  // 新节点创建器列表
117
115
  __publicField(this, "creators$", new BehaviorSubject([]));
118
116
  __publicField(this, "config", DEFAULT_CONFIG);
119
- __publicField(this, "registerCreator", __runInitializers(_init, 40, this, (creator) => {
117
+ __publicField(this, "registerCreator", __runInitializers(_init, 32, this, (creator) => {
120
118
  const creators = this.creators$.value;
121
119
  creators.push(creator);
122
120
  this.creators$.next(creators);
@@ -128,7 +126,7 @@ class ConnectionLine extends (_a = BasePlugin, _getNode_dec = [inject.getNode()]
128
126
  this.creators$.next(currentCreators);
129
127
  }
130
128
  };
131
- })), __runInitializers(_init, 43, this);
129
+ })), __runInitializers(_init, 35, this);
132
130
  }
133
131
  containerRender() {
134
132
  const size = this.getContainerSize();
@@ -163,10 +161,10 @@ class ConnectionLine extends (_a = BasePlugin, _getNode_dec = [inject.getNode()]
163
161
  * 根据当前拖拽的节点和选中的节点决定
164
162
  */
165
163
  getSourceNodeIdsForDrag(currentNodeId) {
166
- if (!this.config.allowMultiDrag || !this.selectedNodeIds.includes(currentNodeId)) {
164
+ if (!this.config.allowMultiDrag || !this.selected.some((item) => item.id === currentNodeId)) {
167
165
  return [currentNodeId];
168
166
  }
169
- return [...this.selectedNodeIds];
167
+ return this.selected.filter((item) => item.type === "node").map((item) => item.id);
170
168
  }
171
169
  /**
172
170
  * 创建临时连接线
@@ -351,18 +349,18 @@ class ConnectionLine extends (_a = BasePlugin, _getNode_dec = [inject.getNode()]
351
349
  }
352
350
  const state = this.createConnectionLine(sourceNodeId, nodeStartPosition);
353
351
  this.connectionLines.set(sourceNodeId, state);
354
- this.startInteraction(this.pluginId, "connect", InteractionPriority.EntityConnectDrag);
352
+ this.interaction.start(this.pluginId, "connect", InteractionPriority.EntityConnectDrag);
355
353
  });
356
354
  },
357
355
  move: (event) => {
358
- if (this.connectionLines.size === 0 || !this.currentDragNodeId || !this.canInteract(this.pluginId, "connect"))
356
+ if (this.connectionLines.size === 0 || !this.currentDragNodeId || !this.interaction.canInteract(InteractionPriority.EntityConnectDrag))
359
357
  return;
360
358
  this.updateAllConnectionLines(event.dx, event.dy);
361
359
  },
362
360
  end: () => {
363
361
  this.clearAllConnectionLines();
364
362
  this.currentDragNodeId = null;
365
- this.endInteraction(this.pluginId, "connect");
363
+ this.interaction.end(this.pluginId, "connect");
366
364
  }
367
365
  }
368
366
  });
@@ -423,10 +421,8 @@ __decorateElement(_init, 1, "destroy", _destroy_dec, ConnectionLine);
423
421
  __decorateElement(_init, 5, "getNode", _getNode_dec, ConnectionLine);
424
422
  __decorateElement(_init, 5, "dispatchNodeOperation", _dispatchNodeOperation_dec, ConnectionLine);
425
423
  __decorateElement(_init, 5, "dispatchEdgeOperation", _dispatchEdgeOperation_dec, ConnectionLine);
426
- __decorateElement(_init, 5, "startInteraction", _startInteraction_dec, ConnectionLine);
427
- __decorateElement(_init, 5, "endInteraction", _endInteraction_dec, ConnectionLine);
428
- __decorateElement(_init, 5, "canInteract", _canInteract_dec, ConnectionLine);
429
- __decorateElement(_init, 5, "selectedNodeIds", _selectedNodeIds_dec, ConnectionLine);
424
+ __decorateElement(_init, 5, "interaction", _interaction_dec, ConnectionLine);
425
+ __decorateElement(_init, 5, "selected", _selected_dec, ConnectionLine);
430
426
  __decorateElement(_init, 5, "getConnectHandleAttributes", _getConnectHandleAttributes_dec, ConnectionLine);
431
427
  __decorateElement(_init, 5, "registerCreator", _registerCreator_dec, ConnectionLine);
432
428
  __decoratorMetadata(_init, ConnectionLine);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knotx/plugins-connection-line",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Connectionline Plugin for Knotx",
5
5
  "author": "boenfu",
6
6
  "license": "MIT",
@@ -33,14 +33,14 @@
33
33
  "@interactjs/modifiers": "^1.10.27",
34
34
  "@interactjs/types": "^1.10.27",
35
35
  "interactjs": "^1.10.27",
36
- "@knotx/jsx": "0.3.0",
37
- "@knotx/plugins-selection": "0.3.0"
36
+ "@knotx/jsx": "0.3.2",
37
+ "@knotx/plugins-selection": "0.3.2"
38
38
  },
39
39
  "dependencies": {
40
40
  "lodash-es": "^4.17.21",
41
41
  "rxjs": "^7.8.1",
42
- "@knotx/core": "0.3.0",
43
- "@knotx/decorators": "0.3.0"
42
+ "@knotx/core": "0.3.2",
43
+ "@knotx/decorators": "0.3.2"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@interactjs/actions": "^1.10.27",
@@ -49,11 +49,11 @@
49
49
  "@interactjs/types": "^1.10.27",
50
50
  "@types/lodash-es": "^4.17.12",
51
51
  "interactjs": "^1.10.27",
52
- "@knotx/build-config": "0.3.0",
53
- "@knotx/eslint-config": "0.3.0",
54
- "@knotx/jsx": "0.3.0",
55
- "@knotx/plugins-selection": "0.3.0",
56
- "@knotx/typescript-config": "0.3.0"
52
+ "@knotx/build-config": "0.3.2",
53
+ "@knotx/eslint-config": "0.3.2",
54
+ "@knotx/jsx": "0.3.2",
55
+ "@knotx/plugins-selection": "0.3.2",
56
+ "@knotx/typescript-config": "0.3.2"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "unbuild",