@pyreon/flow 0.6.0 → 0.7.0
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/lib/types/index.d.ts +666 -2300
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/lib/types/chunk.d.ts +0 -2
- package/lib/types/elk.bundled.d.ts +0 -7
- package/lib/types/elk.bundled.d.ts.map +0 -1
- package/lib/types/index2.d.ts +0 -708
- package/lib/types/index2.d.ts.map +0 -1
package/lib/types/index2.d.ts
DELETED
|
@@ -1,708 +0,0 @@
|
|
|
1
|
-
import { Computed, Signal } from "@pyreon/reactivity";
|
|
2
|
-
import { VNodeChild } from "@pyreon/core";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
|
-
interface XYPosition {
|
|
6
|
-
x: number;
|
|
7
|
-
y: number;
|
|
8
|
-
}
|
|
9
|
-
interface Dimensions {
|
|
10
|
-
width: number;
|
|
11
|
-
height: number;
|
|
12
|
-
}
|
|
13
|
-
interface Rect extends XYPosition, Dimensions {}
|
|
14
|
-
interface Viewport {
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
zoom: number;
|
|
18
|
-
}
|
|
19
|
-
type HandleType = 'source' | 'target';
|
|
20
|
-
declare enum Position {
|
|
21
|
-
Top = "top",
|
|
22
|
-
Right = "right",
|
|
23
|
-
Bottom = "bottom",
|
|
24
|
-
Left = "left"
|
|
25
|
-
}
|
|
26
|
-
interface HandleConfig {
|
|
27
|
-
id?: string;
|
|
28
|
-
type: HandleType;
|
|
29
|
-
position: Position;
|
|
30
|
-
}
|
|
31
|
-
interface FlowNode<TData = Record<string, unknown>> {
|
|
32
|
-
id: string;
|
|
33
|
-
type?: string;
|
|
34
|
-
position: XYPosition;
|
|
35
|
-
data: TData;
|
|
36
|
-
width?: number;
|
|
37
|
-
height?: number;
|
|
38
|
-
/** Whether the node can be dragged */
|
|
39
|
-
draggable?: boolean;
|
|
40
|
-
/** Whether the node can be selected */
|
|
41
|
-
selectable?: boolean;
|
|
42
|
-
/** Whether the node can be connected to */
|
|
43
|
-
connectable?: boolean;
|
|
44
|
-
/** Custom class name */
|
|
45
|
-
class?: string;
|
|
46
|
-
/** Custom style */
|
|
47
|
-
style?: string;
|
|
48
|
-
/** Source handles */
|
|
49
|
-
sourceHandles?: HandleConfig[];
|
|
50
|
-
/** Target handles */
|
|
51
|
-
targetHandles?: HandleConfig[];
|
|
52
|
-
/** Parent node id for grouping */
|
|
53
|
-
parentId?: string;
|
|
54
|
-
/** Whether this node is a group */
|
|
55
|
-
group?: boolean;
|
|
56
|
-
}
|
|
57
|
-
type EdgeType = 'bezier' | 'smoothstep' | 'straight' | 'step';
|
|
58
|
-
interface FlowEdge {
|
|
59
|
-
id?: string;
|
|
60
|
-
source: string;
|
|
61
|
-
target: string;
|
|
62
|
-
sourceHandle?: string;
|
|
63
|
-
targetHandle?: string;
|
|
64
|
-
type?: EdgeType;
|
|
65
|
-
label?: string;
|
|
66
|
-
animated?: boolean;
|
|
67
|
-
class?: string;
|
|
68
|
-
style?: string;
|
|
69
|
-
/** Custom data attached to the edge */
|
|
70
|
-
data?: Record<string, unknown>;
|
|
71
|
-
/** Waypoints — intermediate points the edge passes through */
|
|
72
|
-
waypoints?: XYPosition[];
|
|
73
|
-
}
|
|
74
|
-
interface Connection {
|
|
75
|
-
source: string;
|
|
76
|
-
target: string;
|
|
77
|
-
sourceHandle?: string;
|
|
78
|
-
targetHandle?: string;
|
|
79
|
-
}
|
|
80
|
-
type ConnectionRule = Record<string, {
|
|
81
|
-
outputs: string[];
|
|
82
|
-
}>;
|
|
83
|
-
type NodeChange = {
|
|
84
|
-
type: 'position';
|
|
85
|
-
id: string;
|
|
86
|
-
position: XYPosition;
|
|
87
|
-
} | {
|
|
88
|
-
type: 'dimensions';
|
|
89
|
-
id: string;
|
|
90
|
-
dimensions: Dimensions;
|
|
91
|
-
} | {
|
|
92
|
-
type: 'select';
|
|
93
|
-
id: string;
|
|
94
|
-
selected: boolean;
|
|
95
|
-
} | {
|
|
96
|
-
type: 'remove';
|
|
97
|
-
id: string;
|
|
98
|
-
};
|
|
99
|
-
interface EdgePathResult {
|
|
100
|
-
path: string;
|
|
101
|
-
labelX: number;
|
|
102
|
-
labelY: number;
|
|
103
|
-
}
|
|
104
|
-
interface FlowConfig {
|
|
105
|
-
nodes?: FlowNode[];
|
|
106
|
-
edges?: FlowEdge[];
|
|
107
|
-
/** Default edge type */
|
|
108
|
-
defaultEdgeType?: EdgeType;
|
|
109
|
-
/** Min zoom level — default: 0.1 */
|
|
110
|
-
minZoom?: number;
|
|
111
|
-
/** Max zoom level — default: 4 */
|
|
112
|
-
maxZoom?: number;
|
|
113
|
-
/** Snap to grid */
|
|
114
|
-
snapToGrid?: boolean;
|
|
115
|
-
/** Grid size for snapping — default: 15 */
|
|
116
|
-
snapGrid?: number;
|
|
117
|
-
/** Connection rules — which node types can connect */
|
|
118
|
-
connectionRules?: ConnectionRule;
|
|
119
|
-
/** Whether nodes are draggable by default — default: true */
|
|
120
|
-
nodesDraggable?: boolean;
|
|
121
|
-
/** Whether nodes are connectable by default — default: true */
|
|
122
|
-
nodesConnectable?: boolean;
|
|
123
|
-
/** Whether nodes are selectable by default — default: true */
|
|
124
|
-
nodesSelectable?: boolean;
|
|
125
|
-
/** Whether to allow multi-selection — default: true */
|
|
126
|
-
multiSelect?: boolean;
|
|
127
|
-
/** Drag boundaries for nodes — [[minX, minY], [maxX, maxY]] */
|
|
128
|
-
nodeExtent?: [[number, number], [number, number]];
|
|
129
|
-
/** Whether panning is enabled — default: true */
|
|
130
|
-
pannable?: boolean;
|
|
131
|
-
/** Whether zooming is enabled — default: true */
|
|
132
|
-
zoomable?: boolean;
|
|
133
|
-
/** Fit view on initial render — default: false */
|
|
134
|
-
fitView?: boolean;
|
|
135
|
-
/** Padding for fitView — default: 0.1 */
|
|
136
|
-
fitViewPadding?: number;
|
|
137
|
-
}
|
|
138
|
-
interface FlowInstance {
|
|
139
|
-
/** All nodes — reactive */
|
|
140
|
-
nodes: Signal<FlowNode[]>;
|
|
141
|
-
/** All edges — reactive */
|
|
142
|
-
edges: Signal<FlowEdge[]>;
|
|
143
|
-
/** Viewport state — reactive */
|
|
144
|
-
viewport: Signal<Viewport>;
|
|
145
|
-
/** Current zoom level — computed */
|
|
146
|
-
zoom: Computed<number>;
|
|
147
|
-
/** Selected node ids — computed */
|
|
148
|
-
selectedNodes: Computed<string[]>;
|
|
149
|
-
/** Selected edge ids — computed */
|
|
150
|
-
selectedEdges: Computed<string[]>;
|
|
151
|
-
/** Container dimensions — updated by the Flow component via ResizeObserver */
|
|
152
|
-
containerSize: Signal<{
|
|
153
|
-
width: number;
|
|
154
|
-
height: number;
|
|
155
|
-
}>;
|
|
156
|
-
/** Get a single node by id */
|
|
157
|
-
getNode: (id: string) => FlowNode | undefined;
|
|
158
|
-
/** Add a node */
|
|
159
|
-
addNode: (node: FlowNode) => void;
|
|
160
|
-
/** Remove a node and its connected edges */
|
|
161
|
-
removeNode: (id: string) => void;
|
|
162
|
-
/** Update a node's properties */
|
|
163
|
-
updateNode: (id: string, update: Partial<FlowNode>) => void;
|
|
164
|
-
/** Update a node's position */
|
|
165
|
-
updateNodePosition: (id: string, position: XYPosition) => void;
|
|
166
|
-
/** Get a single edge by id */
|
|
167
|
-
getEdge: (id: string) => FlowEdge | undefined;
|
|
168
|
-
/** Add an edge */
|
|
169
|
-
addEdge: (edge: FlowEdge) => void;
|
|
170
|
-
/** Remove an edge */
|
|
171
|
-
removeEdge: (id: string) => void;
|
|
172
|
-
/** Check if a connection is valid (based on rules) */
|
|
173
|
-
isValidConnection: (connection: Connection) => boolean;
|
|
174
|
-
/** Select a node */
|
|
175
|
-
selectNode: (id: string, additive?: boolean) => void;
|
|
176
|
-
/** Deselect a node */
|
|
177
|
-
deselectNode: (id: string) => void;
|
|
178
|
-
/** Select an edge */
|
|
179
|
-
selectEdge: (id: string, additive?: boolean) => void;
|
|
180
|
-
/** Clear all selection */
|
|
181
|
-
clearSelection: () => void;
|
|
182
|
-
/** Select all nodes */
|
|
183
|
-
selectAll: () => void;
|
|
184
|
-
/** Delete selected nodes/edges */
|
|
185
|
-
deleteSelected: () => void;
|
|
186
|
-
/** Fit view to show all nodes */
|
|
187
|
-
fitView: (nodeIds?: string[], padding?: number) => void;
|
|
188
|
-
/** Set zoom level */
|
|
189
|
-
zoomTo: (zoom: number) => void;
|
|
190
|
-
/** Zoom in */
|
|
191
|
-
zoomIn: () => void;
|
|
192
|
-
/** Zoom out */
|
|
193
|
-
zoomOut: () => void;
|
|
194
|
-
/** Pan to position */
|
|
195
|
-
panTo: (position: XYPosition) => void;
|
|
196
|
-
/** Check if a node is visible in the current viewport */
|
|
197
|
-
isNodeVisible: (id: string) => boolean;
|
|
198
|
-
/** Apply auto-layout using elkjs */
|
|
199
|
-
layout: (algorithm?: LayoutAlgorithm, options?: LayoutOptions) => Promise<void>;
|
|
200
|
-
/** Batch multiple operations */
|
|
201
|
-
batch: (fn: () => void) => void;
|
|
202
|
-
/** Get edges connected to a node */
|
|
203
|
-
getConnectedEdges: (nodeId: string) => FlowEdge[];
|
|
204
|
-
/** Get incoming edges for a node */
|
|
205
|
-
getIncomers: (nodeId: string) => FlowNode[];
|
|
206
|
-
/** Get outgoing edges from a node */
|
|
207
|
-
getOutgoers: (nodeId: string) => FlowNode[];
|
|
208
|
-
/** Called when a connection is made */
|
|
209
|
-
onConnect: (callback: (connection: Connection) => void) => () => void;
|
|
210
|
-
/** Called when nodes change */
|
|
211
|
-
onNodesChange: (callback: (changes: NodeChange[]) => void) => () => void;
|
|
212
|
-
/** Called when a node is clicked */
|
|
213
|
-
onNodeClick: (callback: (node: FlowNode) => void) => () => void;
|
|
214
|
-
/** Called when an edge is clicked */
|
|
215
|
-
onEdgeClick: (callback: (edge: FlowEdge) => void) => () => void;
|
|
216
|
-
/** Called when a node starts being dragged */
|
|
217
|
-
onNodeDragStart: (callback: (node: FlowNode) => void) => () => void;
|
|
218
|
-
/** Called when a node stops being dragged */
|
|
219
|
-
onNodeDragEnd: (callback: (node: FlowNode) => void) => () => void;
|
|
220
|
-
/** Called when a node is double-clicked */
|
|
221
|
-
onNodeDoubleClick: (callback: (node: FlowNode) => void) => () => void;
|
|
222
|
-
/** Copy selected nodes and their edges to clipboard */
|
|
223
|
-
copySelected: () => void;
|
|
224
|
-
/** Paste clipboard contents with offset */
|
|
225
|
-
paste: (offset?: XYPosition) => void;
|
|
226
|
-
/** Save current state to undo history */
|
|
227
|
-
pushHistory: () => void;
|
|
228
|
-
/** Undo last change */
|
|
229
|
-
undo: () => void;
|
|
230
|
-
/** Redo last undone change */
|
|
231
|
-
redo: () => void;
|
|
232
|
-
/** Move all selected nodes by dx/dy */
|
|
233
|
-
moveSelectedNodes: (dx: number, dy: number) => void;
|
|
234
|
-
/** Get snap guide lines for a dragged node */
|
|
235
|
-
getSnapLines: (dragNodeId: string, position: XYPosition, threshold?: number) => {
|
|
236
|
-
x: number | null;
|
|
237
|
-
y: number | null;
|
|
238
|
-
snappedPosition: XYPosition;
|
|
239
|
-
};
|
|
240
|
-
/** Get child nodes of a group node */
|
|
241
|
-
getChildNodes: (parentId: string) => FlowNode[];
|
|
242
|
-
/** Get absolute position of a node (accounting for parent offsets) */
|
|
243
|
-
getAbsolutePosition: (nodeId: string) => XYPosition;
|
|
244
|
-
/** Add a waypoint (bend point) to an edge */
|
|
245
|
-
addEdgeWaypoint: (edgeId: string, point: XYPosition, index?: number) => void;
|
|
246
|
-
/** Remove a waypoint from an edge */
|
|
247
|
-
removeEdgeWaypoint: (edgeId: string, index: number) => void;
|
|
248
|
-
/** Update a waypoint position */
|
|
249
|
-
updateEdgeWaypoint: (edgeId: string, index: number, point: XYPosition) => void;
|
|
250
|
-
/** Reconnect an edge to a new source/target */
|
|
251
|
-
reconnectEdge: (edgeId: string, newConnection: {
|
|
252
|
-
source?: string;
|
|
253
|
-
target?: string;
|
|
254
|
-
sourceHandle?: string;
|
|
255
|
-
targetHandle?: string;
|
|
256
|
-
}) => void;
|
|
257
|
-
/** Find the nearest unconnected node within threshold distance */
|
|
258
|
-
getProximityConnection: (nodeId: string, threshold?: number) => Connection | null;
|
|
259
|
-
/** Get nodes that overlap with the given node */
|
|
260
|
-
getOverlappingNodes: (nodeId: string) => FlowNode[];
|
|
261
|
-
/** Push overlapping nodes apart */
|
|
262
|
-
resolveCollisions: (nodeId: string, spacing?: number) => void;
|
|
263
|
-
/** Set drag boundaries for all nodes — [[minX, minY], [maxX, maxY]] or null to remove */
|
|
264
|
-
setNodeExtent: (extent: [[number, number], [number, number]] | null) => void;
|
|
265
|
-
/** Clamp a position to the current node extent */
|
|
266
|
-
clampToExtent: (position: XYPosition, nodeWidth?: number, nodeHeight?: number) => XYPosition;
|
|
267
|
-
/** Find nodes matching a predicate */
|
|
268
|
-
findNodes: (predicate: (node: FlowNode) => boolean) => FlowNode[];
|
|
269
|
-
/** Find nodes by label text (case-insensitive) */
|
|
270
|
-
searchNodes: (query: string) => FlowNode[];
|
|
271
|
-
/** Focus viewport on a specific node (pan + optional zoom) */
|
|
272
|
-
focusNode: (nodeId: string, zoom?: number) => void;
|
|
273
|
-
/** Export the flow as a JSON-serializable object */
|
|
274
|
-
toJSON: () => {
|
|
275
|
-
nodes: FlowNode[];
|
|
276
|
-
edges: FlowEdge[];
|
|
277
|
-
viewport: Viewport;
|
|
278
|
-
};
|
|
279
|
-
/** Import flow state from a JSON object */
|
|
280
|
-
fromJSON: (data: {
|
|
281
|
-
nodes: FlowNode[];
|
|
282
|
-
edges: FlowEdge[];
|
|
283
|
-
viewport?: Viewport;
|
|
284
|
-
}) => void;
|
|
285
|
-
/** Animate viewport to a new position/zoom */
|
|
286
|
-
animateViewport: (target: Partial<Viewport>, duration?: number) => void;
|
|
287
|
-
/** @internal */
|
|
288
|
-
_emit: {
|
|
289
|
-
nodeDragStart: (node: FlowNode) => void;
|
|
290
|
-
nodeDragEnd: (node: FlowNode) => void;
|
|
291
|
-
nodeDoubleClick: (node: FlowNode) => void;
|
|
292
|
-
nodeClick: (node: FlowNode) => void;
|
|
293
|
-
edgeClick: (edge: FlowEdge) => void;
|
|
294
|
-
};
|
|
295
|
-
/** The flow configuration */
|
|
296
|
-
config: FlowConfig;
|
|
297
|
-
/** Dispose all listeners and clean up */
|
|
298
|
-
dispose: () => void;
|
|
299
|
-
}
|
|
300
|
-
type LayoutAlgorithm = 'layered' | 'force' | 'stress' | 'tree' | 'radial' | 'box' | 'rectpacking';
|
|
301
|
-
interface LayoutOptions {
|
|
302
|
-
/** Layout direction — default: 'DOWN' */
|
|
303
|
-
direction?: 'UP' | 'DOWN' | 'LEFT' | 'RIGHT';
|
|
304
|
-
/** Spacing between nodes — default: 50 */
|
|
305
|
-
nodeSpacing?: number;
|
|
306
|
-
/** Spacing between layers — default: 80 */
|
|
307
|
-
layerSpacing?: number;
|
|
308
|
-
/** Edge routing — default: 'orthogonal' */
|
|
309
|
-
edgeRouting?: 'orthogonal' | 'splines' | 'polyline';
|
|
310
|
-
/** Whether to animate the layout transition — default: true */
|
|
311
|
-
animate?: boolean;
|
|
312
|
-
/** Animation duration in ms — default: 300 */
|
|
313
|
-
animationDuration?: number;
|
|
314
|
-
}
|
|
315
|
-
interface FlowProps {
|
|
316
|
-
instance: FlowInstance;
|
|
317
|
-
style?: string;
|
|
318
|
-
class?: string;
|
|
319
|
-
children?: VNodeChild;
|
|
320
|
-
}
|
|
321
|
-
interface BackgroundProps {
|
|
322
|
-
variant?: 'dots' | 'lines' | 'cross';
|
|
323
|
-
gap?: number;
|
|
324
|
-
size?: number;
|
|
325
|
-
color?: string;
|
|
326
|
-
}
|
|
327
|
-
interface MiniMapProps {
|
|
328
|
-
style?: string;
|
|
329
|
-
class?: string;
|
|
330
|
-
nodeColor?: string | ((node: FlowNode) => string);
|
|
331
|
-
maskColor?: string;
|
|
332
|
-
width?: number;
|
|
333
|
-
height?: number;
|
|
334
|
-
}
|
|
335
|
-
interface ControlsProps {
|
|
336
|
-
showZoomIn?: boolean;
|
|
337
|
-
showZoomOut?: boolean;
|
|
338
|
-
showFitView?: boolean;
|
|
339
|
-
showLock?: boolean;
|
|
340
|
-
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
341
|
-
}
|
|
342
|
-
interface PanelProps {
|
|
343
|
-
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
344
|
-
style?: string;
|
|
345
|
-
class?: string;
|
|
346
|
-
children?: VNodeChild;
|
|
347
|
-
}
|
|
348
|
-
interface HandleProps {
|
|
349
|
-
type: HandleType;
|
|
350
|
-
position: Position;
|
|
351
|
-
id?: string;
|
|
352
|
-
style?: string;
|
|
353
|
-
class?: string;
|
|
354
|
-
}
|
|
355
|
-
type NodeComponentProps<TData = Record<string, unknown>> = {
|
|
356
|
-
id: string;
|
|
357
|
-
data: TData;
|
|
358
|
-
selected: boolean;
|
|
359
|
-
dragging: boolean;
|
|
360
|
-
};
|
|
361
|
-
//#endregion
|
|
362
|
-
//#region src/components/background.d.ts
|
|
363
|
-
/**
|
|
364
|
-
* Background pattern for the flow canvas.
|
|
365
|
-
* Renders dots, lines, or cross patterns that move with the viewport.
|
|
366
|
-
*
|
|
367
|
-
* @example
|
|
368
|
-
* ```tsx
|
|
369
|
-
* <Flow instance={flow}>
|
|
370
|
-
* <Background variant="dots" gap={20} />
|
|
371
|
-
* </Flow>
|
|
372
|
-
* ```
|
|
373
|
-
*/
|
|
374
|
-
declare function Background(props: BackgroundProps): VNodeChild;
|
|
375
|
-
//#endregion
|
|
376
|
-
//#region src/components/controls.d.ts
|
|
377
|
-
/**
|
|
378
|
-
* Zoom and viewport controls for the flow canvas.
|
|
379
|
-
* Shows zoom in, zoom out, fit view, and optional lock button.
|
|
380
|
-
*
|
|
381
|
-
* @example
|
|
382
|
-
* ```tsx
|
|
383
|
-
* <Flow instance={flow}>
|
|
384
|
-
* <Controls />
|
|
385
|
-
* </Flow>
|
|
386
|
-
* ```
|
|
387
|
-
*/
|
|
388
|
-
declare function Controls(props: ControlsProps & {
|
|
389
|
-
instance?: FlowInstance;
|
|
390
|
-
}): VNodeChild;
|
|
391
|
-
//#endregion
|
|
392
|
-
//#region src/components/flow-component.d.ts
|
|
393
|
-
type NodeTypeMap = Record<string, (props: NodeComponentProps<any>) => VNodeChild>;
|
|
394
|
-
type EdgeTypeMap = Record<string, (props: {
|
|
395
|
-
edge: FlowEdge;
|
|
396
|
-
sourceX: number;
|
|
397
|
-
sourceY: number;
|
|
398
|
-
targetX: number;
|
|
399
|
-
targetY: number;
|
|
400
|
-
selected: boolean;
|
|
401
|
-
}) => VNodeChild>;
|
|
402
|
-
interface FlowComponentProps {
|
|
403
|
-
instance: FlowInstance;
|
|
404
|
-
/** Custom node type renderers */
|
|
405
|
-
nodeTypes?: NodeTypeMap;
|
|
406
|
-
/** Custom edge type renderers */
|
|
407
|
-
edgeTypes?: EdgeTypeMap;
|
|
408
|
-
style?: string;
|
|
409
|
-
class?: string;
|
|
410
|
-
children?: VNodeChild;
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* The main Flow component — renders the interactive flow diagram.
|
|
414
|
-
*
|
|
415
|
-
* Supports node dragging, connection drawing, custom node types,
|
|
416
|
-
* pan/zoom, and all standard flow interactions.
|
|
417
|
-
*
|
|
418
|
-
* @example
|
|
419
|
-
* ```tsx
|
|
420
|
-
* const flow = createFlow({
|
|
421
|
-
* nodes: [...],
|
|
422
|
-
* edges: [...],
|
|
423
|
-
* })
|
|
424
|
-
*
|
|
425
|
-
* <Flow instance={flow} nodeTypes={{ custom: CustomNode }}>
|
|
426
|
-
* <Background />
|
|
427
|
-
* <MiniMap />
|
|
428
|
-
* <Controls />
|
|
429
|
-
* </Flow>
|
|
430
|
-
* ```
|
|
431
|
-
*/
|
|
432
|
-
declare function Flow(props: FlowComponentProps): VNodeChild;
|
|
433
|
-
//#endregion
|
|
434
|
-
//#region src/components/handle.d.ts
|
|
435
|
-
/**
|
|
436
|
-
* Connection handle — attachment point on a node where edges connect.
|
|
437
|
-
* Place inside custom node components.
|
|
438
|
-
*
|
|
439
|
-
* @example
|
|
440
|
-
* ```tsx
|
|
441
|
-
* function CustomNode({ data }: NodeComponentProps) {
|
|
442
|
-
* return (
|
|
443
|
-
* <div class="custom-node">
|
|
444
|
-
* <Handle type="target" position={Position.Left} />
|
|
445
|
-
* <span>{data.label}</span>
|
|
446
|
-
* <Handle type="source" position={Position.Right} />
|
|
447
|
-
* </div>
|
|
448
|
-
* )
|
|
449
|
-
* }
|
|
450
|
-
* ```
|
|
451
|
-
*/
|
|
452
|
-
declare function Handle(props: HandleProps): VNodeChild;
|
|
453
|
-
//#endregion
|
|
454
|
-
//#region src/components/minimap.d.ts
|
|
455
|
-
/**
|
|
456
|
-
* Miniature overview of the flow diagram showing all nodes
|
|
457
|
-
* and the current viewport position. Click to navigate.
|
|
458
|
-
*
|
|
459
|
-
* @example
|
|
460
|
-
* ```tsx
|
|
461
|
-
* <Flow instance={flow}>
|
|
462
|
-
* <MiniMap nodeColor={(n) => n.type === 'error' ? 'red' : '#ddd'} />
|
|
463
|
-
* </Flow>
|
|
464
|
-
* ```
|
|
465
|
-
*/
|
|
466
|
-
declare function MiniMap(props: MiniMapProps & {
|
|
467
|
-
instance?: FlowInstance;
|
|
468
|
-
}): VNodeChild;
|
|
469
|
-
//#endregion
|
|
470
|
-
//#region src/components/node-resizer.d.ts
|
|
471
|
-
interface NodeResizerProps {
|
|
472
|
-
nodeId: string;
|
|
473
|
-
instance: FlowInstance;
|
|
474
|
-
/** Minimum width — default: 50 */
|
|
475
|
-
minWidth?: number;
|
|
476
|
-
/** Minimum height — default: 30 */
|
|
477
|
-
minHeight?: number;
|
|
478
|
-
/** Handle size in px — default: 8 */
|
|
479
|
-
handleSize?: number;
|
|
480
|
-
/** Also show edge (non-corner) resize handles — default: false */
|
|
481
|
-
showEdgeHandles?: boolean;
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Node resize handles. Place inside a custom node component
|
|
485
|
-
* to allow users to resize the node by dragging corners or edges.
|
|
486
|
-
*
|
|
487
|
-
* Uses pointer capture for clean event handling — no document listener leaks.
|
|
488
|
-
*
|
|
489
|
-
* @example
|
|
490
|
-
* ```tsx
|
|
491
|
-
* function ResizableNode({ id, data, selected }: NodeComponentProps) {
|
|
492
|
-
* return (
|
|
493
|
-
* <div style="min-width: 100px; min-height: 50px; position: relative;">
|
|
494
|
-
* {data.label}
|
|
495
|
-
* <NodeResizer nodeId={id} instance={flow} />
|
|
496
|
-
* </div>
|
|
497
|
-
* )
|
|
498
|
-
* }
|
|
499
|
-
* ```
|
|
500
|
-
*/
|
|
501
|
-
declare function NodeResizer(props: NodeResizerProps): VNodeChild;
|
|
502
|
-
//#endregion
|
|
503
|
-
//#region src/components/node-toolbar.d.ts
|
|
504
|
-
interface NodeToolbarProps {
|
|
505
|
-
/** Position relative to node — default: 'top' */
|
|
506
|
-
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
507
|
-
/** Offset from node in px — default: 8 */
|
|
508
|
-
offset?: number;
|
|
509
|
-
/** Only show when node is selected — default: true */
|
|
510
|
-
showOnSelect?: boolean;
|
|
511
|
-
/** Whether the node is currently selected */
|
|
512
|
-
selected?: boolean;
|
|
513
|
-
style?: string;
|
|
514
|
-
class?: string;
|
|
515
|
-
children?: VNodeChild;
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* Floating toolbar that appears near a node, typically when selected.
|
|
519
|
-
* Place inside a custom node component.
|
|
520
|
-
*
|
|
521
|
-
* @example
|
|
522
|
-
* ```tsx
|
|
523
|
-
* function EditableNode({ id, data, selected }: NodeComponentProps) {
|
|
524
|
-
* return (
|
|
525
|
-
* <div class="node">
|
|
526
|
-
* {data.label}
|
|
527
|
-
* <NodeToolbar selected={selected}>
|
|
528
|
-
* <button onClick={() => duplicate(id)}>Duplicate</button>
|
|
529
|
-
* <button onClick={() => remove(id)}>Delete</button>
|
|
530
|
-
* </NodeToolbar>
|
|
531
|
-
* </div>
|
|
532
|
-
* )
|
|
533
|
-
* }
|
|
534
|
-
* ```
|
|
535
|
-
*/
|
|
536
|
-
declare function NodeToolbar(props: NodeToolbarProps): VNodeChild;
|
|
537
|
-
//#endregion
|
|
538
|
-
//#region src/components/panel.d.ts
|
|
539
|
-
/**
|
|
540
|
-
* Positioned overlay panel for custom content inside the flow canvas.
|
|
541
|
-
*
|
|
542
|
-
* @example
|
|
543
|
-
* ```tsx
|
|
544
|
-
* <Flow instance={flow}>
|
|
545
|
-
* <Panel position="top-right">
|
|
546
|
-
* <SearchBar />
|
|
547
|
-
* </Panel>
|
|
548
|
-
* </Flow>
|
|
549
|
-
* ```
|
|
550
|
-
*/
|
|
551
|
-
declare function Panel(props: PanelProps): VNodeChild;
|
|
552
|
-
//#endregion
|
|
553
|
-
//#region src/edges.d.ts
|
|
554
|
-
/**
|
|
555
|
-
* Auto-detect the best handle position based on relative node positions.
|
|
556
|
-
* If the node has configured handles, uses those. Otherwise picks the
|
|
557
|
-
* closest edge (top/right/bottom/left) based on direction to the other node.
|
|
558
|
-
*/
|
|
559
|
-
declare function getSmartHandlePositions(sourceNode: FlowNode, targetNode: FlowNode): {
|
|
560
|
-
sourcePosition: Position;
|
|
561
|
-
targetPosition: Position;
|
|
562
|
-
};
|
|
563
|
-
/**
|
|
564
|
-
* Get the handle position offset for a given position (top/right/bottom/left).
|
|
565
|
-
*/
|
|
566
|
-
declare function getHandlePosition(position: Position, nodeX: number, nodeY: number, nodeWidth: number, nodeHeight: number, _handleId?: string): XYPosition;
|
|
567
|
-
/**
|
|
568
|
-
* Calculate a cubic bezier edge path between two points.
|
|
569
|
-
*
|
|
570
|
-
* @example
|
|
571
|
-
* ```ts
|
|
572
|
-
* const { path, labelX, labelY } = getBezierPath({
|
|
573
|
-
* sourceX: 0, sourceY: 0, sourcePosition: Position.Right,
|
|
574
|
-
* targetX: 200, targetY: 100, targetPosition: Position.Left,
|
|
575
|
-
* })
|
|
576
|
-
* // path = "M0,0 C100,0 100,100 200,100"
|
|
577
|
-
* ```
|
|
578
|
-
*/
|
|
579
|
-
declare function getBezierPath(params: {
|
|
580
|
-
sourceX: number;
|
|
581
|
-
sourceY: number;
|
|
582
|
-
sourcePosition?: Position;
|
|
583
|
-
targetX: number;
|
|
584
|
-
targetY: number;
|
|
585
|
-
targetPosition?: Position;
|
|
586
|
-
curvature?: number;
|
|
587
|
-
}): EdgePathResult;
|
|
588
|
-
/**
|
|
589
|
-
* Calculate a smoothstep edge path — horizontal/vertical segments with rounded corners.
|
|
590
|
-
*/
|
|
591
|
-
declare function getSmoothStepPath(params: {
|
|
592
|
-
sourceX: number;
|
|
593
|
-
sourceY: number;
|
|
594
|
-
sourcePosition?: Position;
|
|
595
|
-
targetX: number;
|
|
596
|
-
targetY: number;
|
|
597
|
-
targetPosition?: Position;
|
|
598
|
-
borderRadius?: number;
|
|
599
|
-
offset?: number;
|
|
600
|
-
}): EdgePathResult;
|
|
601
|
-
/**
|
|
602
|
-
* Calculate a straight edge path — direct line between two points.
|
|
603
|
-
*/
|
|
604
|
-
declare function getStraightPath(params: {
|
|
605
|
-
sourceX: number;
|
|
606
|
-
sourceY: number;
|
|
607
|
-
targetX: number;
|
|
608
|
-
targetY: number;
|
|
609
|
-
}): EdgePathResult;
|
|
610
|
-
/**
|
|
611
|
-
* Calculate a step edge path — right-angle segments with no rounding.
|
|
612
|
-
*/
|
|
613
|
-
declare function getStepPath(params: {
|
|
614
|
-
sourceX: number;
|
|
615
|
-
sourceY: number;
|
|
616
|
-
sourcePosition?: Position;
|
|
617
|
-
targetX: number;
|
|
618
|
-
targetY: number;
|
|
619
|
-
targetPosition?: Position;
|
|
620
|
-
}): EdgePathResult;
|
|
621
|
-
/**
|
|
622
|
-
* Calculate an edge path that passes through waypoints.
|
|
623
|
-
* Uses line segments with optional smoothing.
|
|
624
|
-
*/
|
|
625
|
-
declare function getWaypointPath(params: {
|
|
626
|
-
sourceX: number;
|
|
627
|
-
sourceY: number;
|
|
628
|
-
targetX: number;
|
|
629
|
-
targetY: number;
|
|
630
|
-
waypoints: XYPosition[];
|
|
631
|
-
}): EdgePathResult;
|
|
632
|
-
/**
|
|
633
|
-
* Get the edge path for a given edge type.
|
|
634
|
-
*/
|
|
635
|
-
declare function getEdgePath(type: string, sourceX: number, sourceY: number, sourcePosition: Position, targetX: number, targetY: number, targetPosition: Position): EdgePathResult;
|
|
636
|
-
//#endregion
|
|
637
|
-
//#region src/flow.d.ts
|
|
638
|
-
/**
|
|
639
|
-
* Create a reactive flow instance — the core state manager for flow diagrams.
|
|
640
|
-
*
|
|
641
|
-
* All state is signal-based. Nodes, edges, viewport, and selection are
|
|
642
|
-
* reactive and update the UI automatically when modified.
|
|
643
|
-
*
|
|
644
|
-
* @param config - Initial configuration with nodes, edges, and options
|
|
645
|
-
* @returns A FlowInstance with signals and methods for managing the diagram
|
|
646
|
-
*
|
|
647
|
-
* @example
|
|
648
|
-
* ```tsx
|
|
649
|
-
* const flow = createFlow({
|
|
650
|
-
* nodes: [
|
|
651
|
-
* { id: '1', position: { x: 0, y: 0 }, data: { label: 'Start' } },
|
|
652
|
-
* { id: '2', position: { x: 200, y: 100 }, data: { label: 'End' } },
|
|
653
|
-
* ],
|
|
654
|
-
* edges: [{ source: '1', target: '2' }],
|
|
655
|
-
* })
|
|
656
|
-
*
|
|
657
|
-
* flow.nodes() // reactive node list
|
|
658
|
-
* flow.viewport() // { x: 0, y: 0, zoom: 1 }
|
|
659
|
-
* flow.addNode({ id: '3', position: { x: 400, y: 0 }, data: { label: 'New' } })
|
|
660
|
-
* flow.layout('layered', { direction: 'RIGHT' })
|
|
661
|
-
* ```
|
|
662
|
-
*/
|
|
663
|
-
declare function createFlow(config?: FlowConfig): FlowInstance;
|
|
664
|
-
//#endregion
|
|
665
|
-
//#region src/layout.d.ts
|
|
666
|
-
/**
|
|
667
|
-
* Compute a layout for the given nodes and edges using elkjs.
|
|
668
|
-
* Returns an array of { id, position } for each node.
|
|
669
|
-
*
|
|
670
|
-
* elkjs is lazy-loaded — zero bundle cost until this function is called.
|
|
671
|
-
*
|
|
672
|
-
* @example
|
|
673
|
-
* ```ts
|
|
674
|
-
* const positions = await computeLayout(nodes, edges, 'layered', {
|
|
675
|
-
* direction: 'RIGHT',
|
|
676
|
-
* nodeSpacing: 50,
|
|
677
|
-
* layerSpacing: 100,
|
|
678
|
-
* })
|
|
679
|
-
* // positions: [{ id: '1', position: { x: 0, y: 0 } }, ...]
|
|
680
|
-
* ```
|
|
681
|
-
*/
|
|
682
|
-
declare function computeLayout(nodes: FlowNode[], edges: FlowEdge[], algorithm?: LayoutAlgorithm, options?: LayoutOptions): Promise<Array<{
|
|
683
|
-
id: string;
|
|
684
|
-
position: {
|
|
685
|
-
x: number;
|
|
686
|
-
y: number;
|
|
687
|
-
};
|
|
688
|
-
}>>;
|
|
689
|
-
//#endregion
|
|
690
|
-
//#region src/styles.d.ts
|
|
691
|
-
/**
|
|
692
|
-
* Default CSS styles for the flow diagram.
|
|
693
|
-
* Inject via `<style>` tag or import in your CSS.
|
|
694
|
-
*
|
|
695
|
-
* @example
|
|
696
|
-
* ```tsx
|
|
697
|
-
* import { flowStyles } from '@pyreon/flow'
|
|
698
|
-
*
|
|
699
|
-
* // Inject once at app root
|
|
700
|
-
* const style = document.createElement('style')
|
|
701
|
-
* style.textContent = flowStyles
|
|
702
|
-
* document.head.appendChild(style)
|
|
703
|
-
* ```
|
|
704
|
-
*/
|
|
705
|
-
declare const flowStyles = "\n/* \u2500\u2500 Animated edges \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.pyreon-flow-edge-animated {\n stroke-dasharray: 5;\n animation: pyreon-flow-edge-dash 0.5s linear infinite;\n}\n\n@keyframes pyreon-flow-edge-dash {\n to {\n stroke-dashoffset: -10;\n }\n}\n\n/* \u2500\u2500 Node states \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.pyreon-flow-node {\n transition: box-shadow 0.15s ease;\n}\n\n.pyreon-flow-node.dragging {\n opacity: 0.9;\n filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));\n cursor: grabbing;\n}\n\n.pyreon-flow-node.selected {\n filter: drop-shadow(0 0 0 2px rgba(59, 130, 246, 0.3));\n}\n\n/* \u2500\u2500 Handles \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.pyreon-flow-handle {\n transition: transform 0.1s ease, background 0.1s ease;\n}\n\n.pyreon-flow-handle:hover {\n transform: scale(1.4);\n background: #3b82f6 !important;\n}\n\n.pyreon-flow-handle-target:hover {\n background: #22c55e !important;\n border-color: #22c55e !important;\n}\n\n/* \u2500\u2500 Resizer \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.pyreon-flow-resizer {\n transition: background 0.1s ease, transform 0.1s ease;\n}\n\n.pyreon-flow-resizer:hover {\n background: #3b82f6 !important;\n transform: scale(1.2);\n}\n\n/* \u2500\u2500 Selection box \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.pyreon-flow-selection-box {\n pointer-events: none;\n border-radius: 2px;\n}\n\n/* \u2500\u2500 MiniMap \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.pyreon-flow-minimap {\n transition: opacity 0.2s ease;\n}\n\n.pyreon-flow-minimap:hover {\n opacity: 1 !important;\n}\n\n/* \u2500\u2500 Node toolbar \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.pyreon-flow-node-toolbar {\n animation: pyreon-flow-toolbar-enter 0.15s ease;\n}\n\n@keyframes pyreon-flow-toolbar-enter {\n from {\n opacity: 0;\n transform: translateX(-50%) translateY(4px);\n }\n to {\n opacity: 1;\n transform: translateX(-50%) translateY(0);\n }\n}\n\n/* \u2500\u2500 Controls \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.pyreon-flow-controls button:hover {\n background: #f3f4f6 !important;\n}\n\n.pyreon-flow-controls button:active {\n background: #e5e7eb !important;\n}\n";
|
|
706
|
-
//#endregion
|
|
707
|
-
export { Background, type BackgroundProps, type Connection, type ConnectionRule, Controls, type ControlsProps, type Dimensions, type EdgePathResult, type EdgeType, Flow, type FlowComponentProps, type FlowConfig, type FlowEdge, type FlowInstance, type FlowNode, type FlowProps, Handle, type HandleConfig, type HandleProps, type HandleType, type LayoutAlgorithm, type LayoutOptions, MiniMap, type MiniMapProps, type NodeChange, type NodeComponentProps, NodeResizer, type NodeResizerProps, NodeToolbar, type NodeToolbarProps, Panel, type PanelProps, Position, type Rect, type Viewport, type XYPosition, computeLayout, createFlow, flowStyles, getBezierPath, getEdgePath, getHandlePosition, getSmartHandlePositions, getSmoothStepPath, getStepPath, getStraightPath, getWaypointPath };
|
|
708
|
-
//# sourceMappingURL=index2.d.ts.map
|