treege 3.0.0-beta.38 → 3.0.0-beta.39

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.
@@ -18,3 +18,16 @@ export declare const AI_HORIZONTAL_SPACING = 350;
18
18
  * Position tolerance for detecting nodes at the same Y position (in pixels)
19
19
  */
20
20
  export declare const POSITION_TOLERANCE = 20;
21
+ /**
22
+ * Default direction for the auto-layout algorithm.
23
+ * "TB" = top to bottom, "LR" = left to right.
24
+ */
25
+ export declare const LAYOUT_DIRECTION = "TB";
26
+ /**
27
+ * Vertical gap between ranks (parent → child) used by the auto-layout (in pixels).
28
+ */
29
+ export declare const LAYOUT_VERTICAL_SPACING = 80;
30
+ /**
31
+ * Horizontal gap between siblings used by the auto-layout (in pixels).
32
+ */
33
+ export declare const LAYOUT_HORIZONTAL_SPACING = 60;
@@ -0,0 +1,15 @@
1
+ import { LayoutOptions } from '../utils/dagreLayout';
2
+ /**
3
+ * Keeps the flow laid out automatically using Dagre.
4
+ *
5
+ * Runs once all nodes have been measured, then re-runs whenever any node's
6
+ * measured size changes. Positions computed by Dagre replace the current
7
+ * `position` of each node — manual repositioning is therefore overridden,
8
+ * which is the expected behavior for a decision-tree editor where topology
9
+ * drives layout.
10
+ *
11
+ * Group children are laid out independently within their parent, preserving
12
+ * React Flow's parent-relative coordinate system.
13
+ */
14
+ declare const useAutoLayout: ({ direction, horizontalSpacing, verticalSpacing }?: LayoutOptions) => void;
15
+ export default useAutoLayout;
@@ -0,0 +1,17 @@
1
+ import { Edge, Node } from '@xyflow/react';
2
+ export type LayoutDirection = "TB" | "LR";
3
+ export interface LayoutOptions {
4
+ direction?: LayoutDirection;
5
+ horizontalSpacing?: number;
6
+ verticalSpacing?: number;
7
+ }
8
+ /**
9
+ * Runs Dagre to compute positions for the given nodes and returns a new
10
+ * `nodes` array with updated `position` fields. Nodes not yet measured by
11
+ * React Flow keep their current position.
12
+ *
13
+ * Respects group hierarchy: top-level nodes are laid out together, and
14
+ * each group's children are laid out independently using parent-relative
15
+ * coordinates.
16
+ */
17
+ export declare const getLayoutedElements: (nodes: Node[], edges: Edge[], options?: LayoutOptions) => Node[];