@flowgram.ai/free-auto-layout-plugin 0.1.25 → 0.1.27

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
@@ -2085,6 +2085,7 @@ import {
2085
2085
  WorkflowDocument,
2086
2086
  WorkflowNodeLinesData
2087
2087
  } from "@flowgram.ai/free-layout-core";
2088
+ import { FlowNodeBaseType } from "@flowgram.ai/document";
2088
2089
 
2089
2090
  // src/layout/store.ts
2090
2091
  import { FlowNodeTransformData } from "@flowgram.ai/document";
@@ -2228,7 +2229,6 @@ var LayoutStore = class {
2228
2229
  };
2229
2230
 
2230
2231
  // src/layout/position.ts
2231
- import { FlowNodeTransformData as FlowNodeTransformData2 } from "@flowgram.ai/document";
2232
2232
  import { startTween, TransformData } from "@flowgram.ai/core";
2233
2233
  var LayoutPosition = class {
2234
2234
  constructor(store) {
@@ -2260,23 +2260,19 @@ var LayoutPosition = class {
2260
2260
  };
2261
2261
  const deltaX = (position2.x - transform.position.x) * step / 100;
2262
2262
  const deltaY = (position2.y - transform.bounds.height / 2 - transform.position.y) * step / 100;
2263
- if (layoutNode.hasChildren) {
2264
- layoutNode.entity.collapsedChildren.forEach((childNode) => {
2265
- const childNodeTransformData = childNode.getData(FlowNodeTransformData2);
2266
- childNodeTransformData.fireChange();
2267
- });
2268
- }
2269
2263
  transform.update({
2270
2264
  position: {
2271
2265
  x: transform.position.x + deltaX,
2272
2266
  y: transform.position.y + deltaY
2273
2267
  }
2274
2268
  });
2269
+ const document = layoutNode.entity.document;
2270
+ document.layout.updateAffectedTransform(layoutNode.entity);
2275
2271
  }
2276
2272
  };
2277
2273
 
2278
2274
  // src/layout/dagre.ts
2279
- import { FlowNodeTransformData as FlowNodeTransformData3 } from "@flowgram.ai/document";
2275
+ import { FlowNodeTransformData as FlowNodeTransformData2 } from "@flowgram.ai/document";
2280
2276
  import { Graph as DagreGraph } from "@dagrejs/graphlib";
2281
2277
 
2282
2278
  // src/layout/constant.ts
@@ -2388,7 +2384,7 @@ var DagreLayout = class {
2388
2384
  if (!layoutNode.hasChildren) {
2389
2385
  return 0;
2390
2386
  }
2391
- const nodeTransform = layoutNode.entity.getData(FlowNodeTransformData3);
2387
+ const nodeTransform = layoutNode.entity.getData(FlowNodeTransformData2);
2392
2388
  const { bounds, padding } = nodeTransform;
2393
2389
  const leftOffset = -bounds.width / 2 + padding.left;
2394
2390
  return leftOffset;
@@ -2502,11 +2498,11 @@ var AutoLayoutService = class {
2502
2498
  await this.layoutNode(this.document.root, options);
2503
2499
  }
2504
2500
  async layoutNode(node, options) {
2505
- const nodes = node.collapsedChildren;
2501
+ const nodes = this.getAvailableBlocks(node);
2506
2502
  if (!nodes || !Array.isArray(nodes) || !nodes.length) {
2507
2503
  return;
2508
2504
  }
2509
- const edges = node.collapsedChildren.map((child) => {
2505
+ const edges = node.blocks.map((child) => {
2510
2506
  const childLinesData = child.getData(WorkflowNodeLinesData);
2511
2507
  return childLinesData.outputLines.filter(Boolean);
2512
2508
  }).flat();
@@ -2516,6 +2512,14 @@ var AutoLayoutService = class {
2516
2512
  layout2.layout();
2517
2513
  await layout2.position();
2518
2514
  }
2515
+ getAvailableBlocks(node) {
2516
+ const commonNodes = node.blocks.filter((n) => !this.shouldFlatNode(n));
2517
+ const flatNodes = node.blocks.filter((n) => this.shouldFlatNode(n)).map((flatNode) => flatNode.blocks).flat();
2518
+ return [...commonNodes, ...flatNodes];
2519
+ }
2520
+ shouldFlatNode(node) {
2521
+ return node.flowNodeType === FlowNodeBaseType.GROUP;
2522
+ }
2519
2523
  };
2520
2524
  __decorateClass([
2521
2525
  inject(WorkflowDocument)