@flowgram.ai/free-layout-core 0.5.3 → 0.5.5

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/esm/index.js CHANGED
@@ -183,6 +183,27 @@ import {
183
183
  PlaygroundConfigEntity,
184
184
  TransformData as TransformData3
185
185
  } from "@flowgram.ai/core";
186
+
187
+ // src/utils/location-config-to-point.ts
188
+ function locationConfigToPoint(bounds, config, _offset = { x: 0, y: 0 }) {
189
+ const offset = { ..._offset };
190
+ if (config.left !== void 0) {
191
+ offset.x += typeof config.left === "string" ? parseFloat(config.left) * 0.01 * bounds.width : config.left;
192
+ } else if (config.right !== void 0) {
193
+ offset.x += bounds.width - (typeof config.right === "string" ? parseFloat(config.right) * 0.01 * bounds.width : config.right);
194
+ }
195
+ if (config.top !== void 0) {
196
+ offset.y += typeof config.top === "string" ? parseFloat(config.top) * 0.01 * bounds.height : config.top;
197
+ } else if (config.bottom !== void 0) {
198
+ offset.y += bounds.height - (typeof config.bottom === "string" ? parseFloat(config.bottom) * 0.01 * bounds.height : config.bottom);
199
+ }
200
+ return {
201
+ x: bounds.x + offset.x,
202
+ y: bounds.y + offset.y
203
+ };
204
+ }
205
+
206
+ // src/entities/workflow-port-entity.ts
186
207
  var PORT_SIZE = 24;
187
208
  var WorkflowPortEntity = class extends Entity {
188
209
  constructor(opts) {
@@ -195,6 +216,7 @@ var WorkflowPortEntity = class extends Entity {
195
216
  this.portType = opts.type;
196
217
  this._disabled = opts.disabled;
197
218
  this._offset = opts.offset;
219
+ this._locationConfig = opts.locationConfig;
198
220
  this._location = opts.location;
199
221
  this._size = opts.size;
200
222
  this.node = opts.node;
@@ -242,7 +264,7 @@ var WorkflowPortEntity = class extends Entity {
242
264
  return "right";
243
265
  }
244
266
  get point() {
245
- const { targetElement } = this;
267
+ const { targetElement, _locationConfig } = this;
246
268
  const { bounds } = this.node.getData(FlowNodeTransformData);
247
269
  const location2 = this.location;
248
270
  if (targetElement) {
@@ -257,8 +279,14 @@ var WorkflowPortEntity = class extends Entity {
257
279
  location: location2
258
280
  };
259
281
  }
260
- let point = { x: 0, y: 0 };
282
+ if (_locationConfig) {
283
+ return {
284
+ ...locationConfigToPoint(bounds, _locationConfig, this._offset),
285
+ location: location2
286
+ };
287
+ }
261
288
  const offset = this._offset || { x: 0, y: 0 };
289
+ let point = { x: 0, y: 0 };
262
290
  switch (location2) {
263
291
  case "left":
264
292
  point = bounds.leftCenter;
@@ -371,6 +399,10 @@ var WorkflowPortEntity = class extends Entity {
371
399
  this._offset = data.offset;
372
400
  changed = true;
373
401
  }
402
+ if (Compare.isChanged(data.locationConfig, this._locationConfig)) {
403
+ this._locationConfig = data.locationConfig;
404
+ changed = true;
405
+ }
374
406
  if (Compare.isChanged(data.size, this._size)) {
375
407
  this._size = data.size;
376
408
  changed = true;