@pyreon/flow 0.9.0 → 0.11.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/analysis/index.js.html +1 -1
- package/lib/{elk.bundled-B9dPTHTZ.js → elk.bundled-wgxWJMYd.js} +2 -2
- package/lib/elk.bundled-wgxWJMYd.js.map +1 -0
- package/lib/index.js +13 -13
- package/lib/index.js.map +1 -1
- package/lib/types/index.d.ts +13 -13
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +14 -7
- package/src/components/background.tsx +9 -14
- package/src/components/controls.tsx +11 -18
- package/src/components/flow-component.tsx +67 -117
- package/src/components/handle.tsx +8 -8
- package/src/components/minimap.tsx +10 -27
- package/src/components/node-resizer.tsx +28 -28
- package/src/components/node-toolbar.tsx +12 -21
- package/src/components/panel.tsx +9 -9
- package/src/edges.ts +16 -47
- package/src/flow.ts +32 -88
- package/src/index.ts +17 -17
- package/src/layout.ts +23 -31
- package/src/tests/flow-advanced.test.ts +191 -200
- package/src/tests/flow.test.ts +418 -468
- package/src/types.ts +28 -42
- package/lib/elk.bundled-B9dPTHTZ.js.map +0 -1
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { VNodeChild } from
|
|
2
|
-
import type { Computed, Signal } from
|
|
1
|
+
import type { VNodeChild } from "@pyreon/core"
|
|
2
|
+
import type { Computed, Signal } from "@pyreon/reactivity"
|
|
3
3
|
|
|
4
4
|
// ─── Position & Geometry ─────────────────────────────────────────────────────
|
|
5
5
|
|
|
@@ -25,13 +25,13 @@ export interface Viewport {
|
|
|
25
25
|
|
|
26
26
|
// ─── Handle ──────────────────────────────────────────────────────────────────
|
|
27
27
|
|
|
28
|
-
export type HandleType =
|
|
28
|
+
export type HandleType = "source" | "target"
|
|
29
29
|
|
|
30
30
|
export enum Position {
|
|
31
|
-
Top =
|
|
32
|
-
Right =
|
|
33
|
-
Bottom =
|
|
34
|
-
Left =
|
|
31
|
+
Top = "top",
|
|
32
|
+
Right = "right",
|
|
33
|
+
Bottom = "bottom",
|
|
34
|
+
Left = "left",
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export interface HandleConfig {
|
|
@@ -71,7 +71,7 @@ export interface FlowNode<TData = Record<string, unknown>> {
|
|
|
71
71
|
|
|
72
72
|
// ─── Edge ────────────────────────────────────────────────────────────────────
|
|
73
73
|
|
|
74
|
-
export type EdgeType =
|
|
74
|
+
export type EdgeType = "bezier" | "smoothstep" | "straight" | "step"
|
|
75
75
|
|
|
76
76
|
export interface FlowEdge {
|
|
77
77
|
id?: string
|
|
@@ -104,10 +104,10 @@ export type ConnectionRule = Record<string, { outputs: string[] }>
|
|
|
104
104
|
// ─── Node Change Events ──────────────────────────────────────────────────────
|
|
105
105
|
|
|
106
106
|
export type NodeChange =
|
|
107
|
-
| { type:
|
|
108
|
-
| { type:
|
|
109
|
-
| { type:
|
|
110
|
-
| { type:
|
|
107
|
+
| { type: "position"; id: string; position: XYPosition }
|
|
108
|
+
| { type: "dimensions"; id: string; dimensions: Dimensions }
|
|
109
|
+
| { type: "select"; id: string; selected: boolean }
|
|
110
|
+
| { type: "remove"; id: string }
|
|
111
111
|
|
|
112
112
|
// ─── Edge path result ────────────────────────────────────────────────────────
|
|
113
113
|
|
|
@@ -231,10 +231,7 @@ export interface FlowInstance {
|
|
|
231
231
|
// ── Layout ───────────────────────────────────────────────────────────────
|
|
232
232
|
|
|
233
233
|
/** Apply auto-layout using elkjs */
|
|
234
|
-
layout: (
|
|
235
|
-
algorithm?: LayoutAlgorithm,
|
|
236
|
-
options?: LayoutOptions,
|
|
237
|
-
) => Promise<void>
|
|
234
|
+
layout: (algorithm?: LayoutAlgorithm, options?: LayoutOptions) => Promise<void>
|
|
238
235
|
|
|
239
236
|
// ── Batch ────────────────────────────────────────────────────────────────
|
|
240
237
|
|
|
@@ -331,10 +328,7 @@ export interface FlowInstance {
|
|
|
331
328
|
// ── Proximity connect ────────────────────────────────────────────────────
|
|
332
329
|
|
|
333
330
|
/** Find the nearest unconnected node within threshold distance */
|
|
334
|
-
getProximityConnection: (
|
|
335
|
-
nodeId: string,
|
|
336
|
-
threshold?: number,
|
|
337
|
-
) => Connection | null
|
|
331
|
+
getProximityConnection: (nodeId: string, threshold?: number) => Connection | null
|
|
338
332
|
|
|
339
333
|
// ── Collision detection ─────────────────────────────────────────────────
|
|
340
334
|
|
|
@@ -348,11 +342,7 @@ export interface FlowInstance {
|
|
|
348
342
|
/** Set drag boundaries for all nodes — [[minX, minY], [maxX, maxY]] or null to remove */
|
|
349
343
|
setNodeExtent: (extent: [[number, number], [number, number]] | null) => void
|
|
350
344
|
/** Clamp a position to the current node extent */
|
|
351
|
-
clampToExtent: (
|
|
352
|
-
position: XYPosition,
|
|
353
|
-
nodeWidth?: number,
|
|
354
|
-
nodeHeight?: number,
|
|
355
|
-
) => XYPosition
|
|
345
|
+
clampToExtent: (position: XYPosition, nodeWidth?: number, nodeHeight?: number) => XYPosition
|
|
356
346
|
|
|
357
347
|
// ── Search / Filter ─────────────────────────────────────────────────────
|
|
358
348
|
|
|
@@ -368,11 +358,7 @@ export interface FlowInstance {
|
|
|
368
358
|
/** Export the flow as a JSON-serializable object */
|
|
369
359
|
toJSON: () => { nodes: FlowNode[]; edges: FlowEdge[]; viewport: Viewport }
|
|
370
360
|
/** Import flow state from a JSON object */
|
|
371
|
-
fromJSON: (data: {
|
|
372
|
-
nodes: FlowNode[]
|
|
373
|
-
edges: FlowEdge[]
|
|
374
|
-
viewport?: Viewport
|
|
375
|
-
}) => void
|
|
361
|
+
fromJSON: (data: { nodes: FlowNode[]; edges: FlowEdge[]; viewport?: Viewport }) => void
|
|
376
362
|
|
|
377
363
|
// ── Viewport animation ─────────────────────────────────────────────────
|
|
378
364
|
|
|
@@ -404,23 +390,23 @@ export interface FlowInstance {
|
|
|
404
390
|
// ─── Layout ──────────────────────────────────────────────────────────────────
|
|
405
391
|
|
|
406
392
|
export type LayoutAlgorithm =
|
|
407
|
-
|
|
|
408
|
-
|
|
|
409
|
-
|
|
|
410
|
-
|
|
|
411
|
-
|
|
|
412
|
-
|
|
|
413
|
-
|
|
|
393
|
+
| "layered"
|
|
394
|
+
| "force"
|
|
395
|
+
| "stress"
|
|
396
|
+
| "tree"
|
|
397
|
+
| "radial"
|
|
398
|
+
| "box"
|
|
399
|
+
| "rectpacking"
|
|
414
400
|
|
|
415
401
|
export interface LayoutOptions {
|
|
416
402
|
/** Layout direction — default: 'DOWN' */
|
|
417
|
-
direction?:
|
|
403
|
+
direction?: "UP" | "DOWN" | "LEFT" | "RIGHT"
|
|
418
404
|
/** Spacing between nodes — default: 50 */
|
|
419
405
|
nodeSpacing?: number
|
|
420
406
|
/** Spacing between layers — default: 80 */
|
|
421
407
|
layerSpacing?: number
|
|
422
408
|
/** Edge routing — default: 'orthogonal' */
|
|
423
|
-
edgeRouting?:
|
|
409
|
+
edgeRouting?: "orthogonal" | "splines" | "polyline"
|
|
424
410
|
/** Whether to animate the layout transition — default: true */
|
|
425
411
|
animate?: boolean
|
|
426
412
|
/** Animation duration in ms — default: 300 */
|
|
@@ -437,7 +423,7 @@ export interface FlowProps {
|
|
|
437
423
|
}
|
|
438
424
|
|
|
439
425
|
export interface BackgroundProps {
|
|
440
|
-
variant?:
|
|
426
|
+
variant?: "dots" | "lines" | "cross"
|
|
441
427
|
gap?: number
|
|
442
428
|
size?: number
|
|
443
429
|
color?: string
|
|
@@ -457,11 +443,11 @@ export interface ControlsProps {
|
|
|
457
443
|
showZoomOut?: boolean
|
|
458
444
|
showFitView?: boolean
|
|
459
445
|
showLock?: boolean
|
|
460
|
-
position?:
|
|
446
|
+
position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"
|
|
461
447
|
}
|
|
462
448
|
|
|
463
449
|
export interface PanelProps {
|
|
464
|
-
position?:
|
|
450
|
+
position?: "top-left" | "top-right" | "bottom-left" | "bottom-right"
|
|
465
451
|
style?: string
|
|
466
452
|
class?: string
|
|
467
453
|
children?: VNodeChild
|