@xyflow/system 0.0.54 → 0.0.55
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 +64 -57
- package/dist/esm/index.mjs +64 -57
- package/dist/esm/utils/edges/bezier-edge.d.ts +25 -8
- package/dist/esm/utils/edges/bezier-edge.d.ts.map +1 -1
- package/dist/esm/utils/edges/general.d.ts +11 -8
- package/dist/esm/utils/edges/general.d.ts.map +1 -1
- package/dist/esm/utils/edges/smoothstep-edge.d.ts +26 -9
- package/dist/esm/utils/edges/smoothstep-edge.d.ts.map +1 -1
- package/dist/esm/utils/edges/straight-edge.d.ts +14 -5
- package/dist/esm/utils/edges/straight-edge.d.ts.map +1 -1
- package/dist/esm/utils/general.d.ts +8 -8
- package/dist/esm/utils/graph.d.ts +19 -16
- package/dist/esm/utils/graph.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/utils/edges/bezier-edge.d.ts +25 -8
- package/dist/umd/utils/edges/bezier-edge.d.ts.map +1 -1
- package/dist/umd/utils/edges/general.d.ts +11 -8
- package/dist/umd/utils/edges/general.d.ts.map +1 -1
- package/dist/umd/utils/edges/smoothstep-edge.d.ts +26 -9
- package/dist/umd/utils/edges/smoothstep-edge.d.ts.map +1 -1
- package/dist/umd/utils/edges/straight-edge.d.ts +14 -5
- package/dist/umd/utils/edges/straight-edge.d.ts.map +1 -1
- package/dist/umd/utils/general.d.ts +8 -8
- package/dist/umd/utils/graph.d.ts +19 -16
- package/dist/umd/utils/graph.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
export type GetStraightPathParams = {
|
|
2
|
+
/** The `x` position of the source handle. */
|
|
2
3
|
sourceX: number;
|
|
4
|
+
/** The `y` position of the source handle. */
|
|
3
5
|
sourceY: number;
|
|
6
|
+
/** The `x` position of the target handle. */
|
|
4
7
|
targetX: number;
|
|
8
|
+
/** The `y` position of the target handle. */
|
|
5
9
|
targetY: number;
|
|
6
10
|
};
|
|
7
11
|
/**
|
|
8
12
|
* Calculates the straight line path between two points.
|
|
9
13
|
* @public
|
|
10
|
-
* @
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
14
|
+
* @returns A path string you can use in an SVG, the `labelX` and `labelY` position (center of path)
|
|
15
|
+
* and `offsetX`, `offsetY` between source handle and label.
|
|
16
|
+
*
|
|
17
|
+
* - `path`: the path to use in an SVG `<path>` element.
|
|
18
|
+
* - `labelX`: the `x` position you can use to render a label for this edge.
|
|
19
|
+
* - `labelY`: the `y` position you can use to render a label for this edge.
|
|
20
|
+
* - `offsetX`: the absolute difference between the source `x` position and the `x` position of the
|
|
21
|
+
* middle of this path.
|
|
22
|
+
* - `offsetY`: the absolute difference between the source `y` position and the `y` position of the
|
|
23
|
+
* middle of this path.
|
|
15
24
|
* @example
|
|
16
25
|
* ```js
|
|
17
26
|
* const source = { x: 0, y: 20 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"straight-edge.d.ts","sourceRoot":"","sources":["../../../src/utils/edges/straight-edge.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"straight-edge.d.ts","sourceRoot":"","sources":["../../../src/utils/edges/straight-edge.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,qBAAqB,GAAG;IAClC,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,GACR,EAAE,qBAAqB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAS1G"}
|
|
@@ -24,16 +24,16 @@ export declare const snapPosition: (position: XYPosition, snapGrid?: SnapGrid) =
|
|
|
24
24
|
export declare const pointToRendererPoint: ({ x, y }: XYPosition, [tx, ty, tScale]: Transform, snapToGrid?: boolean, snapGrid?: SnapGrid) => XYPosition;
|
|
25
25
|
export declare const rendererPointToPoint: ({ x, y }: XYPosition, [tx, ty, tScale]: Transform) => XYPosition;
|
|
26
26
|
/**
|
|
27
|
-
* Returns a viewport that encloses the given bounds with
|
|
27
|
+
* Returns a viewport that encloses the given bounds with padding.
|
|
28
28
|
* @public
|
|
29
29
|
* @remarks You can determine bounds of nodes with {@link getNodesBounds} and {@link getBoundsOfRects}
|
|
30
|
-
* @param bounds - Bounds to fit inside viewport
|
|
31
|
-
* @param width - Width of the viewport
|
|
32
|
-
* @param height - Height of the viewport
|
|
33
|
-
* @param minZoom - Minimum zoom level of the resulting viewport
|
|
34
|
-
* @param maxZoom - Maximum zoom level of the resulting viewport
|
|
35
|
-
* @param padding -
|
|
36
|
-
* @returns A
|
|
30
|
+
* @param bounds - Bounds to fit inside viewport.
|
|
31
|
+
* @param width - Width of the viewport.
|
|
32
|
+
* @param height - Height of the viewport.
|
|
33
|
+
* @param minZoom - Minimum zoom level of the resulting viewport.
|
|
34
|
+
* @param maxZoom - Maximum zoom level of the resulting viewport.
|
|
35
|
+
* @param padding - Padding around the bounds.
|
|
36
|
+
* @returns A transformed {@link Viewport} that encloses the given bounds which you can pass to e.g. {@link setViewport}.
|
|
37
37
|
* @example
|
|
38
38
|
* const { x, y, zoom } = getViewportForBounds(
|
|
39
39
|
* { x: 0, y: 0, width: 100, height: 100},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Transform, type XYPosition, type Rect, type NodeOrigin, type NodeBase, type EdgeBase, type FitViewParamsBase, type FitViewOptionsBase, CoordinateExtent, OnError, OnBeforeDeleteBase, NodeLookup, InternalNodeBase, NodeDragItem } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
* Test whether an object is
|
|
3
|
+
* Test whether an object is usable as an Edge
|
|
4
4
|
* @public
|
|
5
5
|
* @remarks In TypeScript this is a type guard that will narrow the type of whatever you pass in to Edge if it returns true
|
|
6
6
|
* @param element - The element to test
|
|
@@ -8,7 +8,7 @@ import { type Transform, type XYPosition, type Rect, type NodeOrigin, type NodeB
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const isEdgeBase: <EdgeType extends EdgeBase = EdgeBase>(element: any) => element is EdgeType;
|
|
10
10
|
/**
|
|
11
|
-
* Test whether an object is
|
|
11
|
+
* Test whether an object is usable as a Node
|
|
12
12
|
* @public
|
|
13
13
|
* @remarks In TypeScript this is a type guard that will narrow the type of whatever you pass in to Node if it returns true
|
|
14
14
|
* @param element - The element to test
|
|
@@ -20,10 +20,10 @@ export declare const isInternalNodeBase: <NodeType extends InternalNodeBase = In
|
|
|
20
20
|
* This util is used to tell you what nodes, if any, are connected to the given node
|
|
21
21
|
* as the _target_ of an edge.
|
|
22
22
|
* @public
|
|
23
|
-
* @param node - The node to get the connected nodes from
|
|
24
|
-
* @param nodes - The array of all nodes
|
|
25
|
-
* @param edges - The array of all edges
|
|
26
|
-
* @returns An array of nodes that are connected over
|
|
23
|
+
* @param node - The node to get the connected nodes from.
|
|
24
|
+
* @param nodes - The array of all nodes.
|
|
25
|
+
* @param edges - The array of all edges.
|
|
26
|
+
* @returns An array of nodes that are connected over edges where the source is the given node.
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
29
29
|
* ```ts
|
|
@@ -46,10 +46,10 @@ export declare const getOutgoers: <NodeType extends NodeBase = NodeBase, EdgeTyp
|
|
|
46
46
|
* This util is used to tell you what nodes, if any, are connected to the given node
|
|
47
47
|
* as the _source_ of an edge.
|
|
48
48
|
* @public
|
|
49
|
-
* @param node - The node to get the connected nodes from
|
|
50
|
-
* @param nodes - The array of all nodes
|
|
51
|
-
* @param edges - The array of all edges
|
|
52
|
-
* @returns An array of nodes that are connected over
|
|
49
|
+
* @param node - The node to get the connected nodes from.
|
|
50
|
+
* @param nodes - The array of all nodes.
|
|
51
|
+
* @param edges - The array of all edges.
|
|
52
|
+
* @returns An array of nodes that are connected over edges where the target is the given node.
|
|
53
53
|
*
|
|
54
54
|
* @example
|
|
55
55
|
* ```ts
|
|
@@ -70,6 +70,10 @@ export declare const getIncomers: <NodeType extends NodeBase = NodeBase, EdgeTyp
|
|
|
70
70
|
}, nodes: NodeType[], edges: EdgeType[]) => NodeType[];
|
|
71
71
|
export declare const getNodePositionWithOrigin: (node: NodeBase, nodeOrigin?: NodeOrigin) => XYPosition;
|
|
72
72
|
export type GetNodesBoundsParams<NodeType extends NodeBase = NodeBase> = {
|
|
73
|
+
/**
|
|
74
|
+
* Origin of the nodes: `[0, 0]` for top-left, `[0.5, 0.5]` for center.
|
|
75
|
+
* @default [0, 0]
|
|
76
|
+
*/
|
|
73
77
|
nodeOrigin?: NodeOrigin;
|
|
74
78
|
nodeLookup?: NodeLookup<InternalNodeBase<NodeType>>;
|
|
75
79
|
};
|
|
@@ -79,9 +83,8 @@ export type GetNodesBoundsParams<NodeType extends NodeBase = NodeBase> = {
|
|
|
79
83
|
* to calculate the correct transform to fit the given nodes in a viewport.
|
|
80
84
|
* @public
|
|
81
85
|
* @remarks Useful when combined with {@link getViewportForBounds} to calculate the correct transform to fit the given nodes in a viewport.
|
|
82
|
-
* @param nodes - Nodes to calculate the bounds for
|
|
83
|
-
* @
|
|
84
|
-
* @returns Bounding box enclosing all nodes
|
|
86
|
+
* @param nodes - Nodes to calculate the bounds for.
|
|
87
|
+
* @returns Bounding box enclosing all nodes.
|
|
85
88
|
*
|
|
86
89
|
* @remarks This function was previously called `getRectOfNodes`
|
|
87
90
|
*
|
|
@@ -124,9 +127,9 @@ export declare const getNodesInside: <NodeType extends NodeBase = NodeBase>(node
|
|
|
124
127
|
* This utility filters an array of edges, keeping only those where either the source or target
|
|
125
128
|
* node is present in the given array of nodes.
|
|
126
129
|
* @public
|
|
127
|
-
* @param nodes - Nodes you want to get the connected edges for
|
|
128
|
-
* @param edges - All edges
|
|
129
|
-
* @returns Array of edges that connect any of the given nodes with each other
|
|
130
|
+
* @param nodes - Nodes you want to get the connected edges for.
|
|
131
|
+
* @param edges - All edges.
|
|
132
|
+
* @returns Array of edges that connect any of the given nodes with each other.
|
|
130
133
|
*
|
|
131
134
|
* @example
|
|
132
135
|
* ```js
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/utils/graph.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,gBAAgB,EAChB,OAAO,EACP,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,UAAU,CAAC;AAGlB;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,kDAAmD,GAAG,wBACd,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,kDAAmD,GAAG,wBACiB,CAAC;AAE/F,eAAO,MAAM,kBAAkB,kEACpB,GAAG,wBACyG,CAAC;AAExH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,WAAW,qFAChB,QAAQ,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,SACxB,QAAQ,EAAE,SACV,QAAQ,EAAE,KAChB,QAAQ,EAaV,CAAC;AAEF;;;;;;;;;;;;;;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