@squeed/flow-sdk 0.1.16 → 2.0.1

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/index.d.ts CHANGED
@@ -7,6 +7,8 @@ export declare function addChild(json: SqueedJson, parentAddress: string, child:
7
7
  address: string;
8
8
  };
9
9
 
10
+ export declare function addConnection(json: SqueedJson, sourceAddress: string, connection: SqueedConnection): SqueedJson;
11
+
10
12
  /** "root.a.b.#" → ["a", "b"] */
11
13
  export declare function addressToPath(address: string): string[];
12
14
 
@@ -56,6 +58,14 @@ export declare interface BottomBarRenderProps {
56
58
  callbacks: FlowDiagramCallbacks;
57
59
  }
58
60
 
61
+ /** Centre + size, model units (matches cytoscape's node position/width/height) */
62
+ declare interface Box {
63
+ x: number;
64
+ y: number;
65
+ w: number;
66
+ h: number;
67
+ }
68
+
59
69
  export declare interface CompileOptions {
60
70
  title?: string;
61
71
  /** Root in the middle, children fan out both ways (direction "C") */
@@ -95,9 +105,9 @@ export declare const DynamicIcon: ({ name, ...props }: {
95
105
  name: any;
96
106
  }) => JSX_2.Element;
97
107
 
98
- export declare function FlowDiagram({ title, json, nodes, edges, config, callbacks, className, style, showBottomBar, }: FlowDiagramProps & {
99
- showBottomBar?: boolean;
100
- }): JSX_2.Element;
108
+ export declare type EdgeMode = "workflow" | "properties";
109
+
110
+ export declare function FlowDiagram({ title, json, nodes, edges, config, callbacks, className, style, showBottomBar, }: FlowDiagramProps): JSX_2.Element;
101
111
 
102
112
  /** Event callbacks for the flow diagram */
103
113
  export declare interface FlowDiagramCallbacks {
@@ -127,7 +137,7 @@ export declare interface FlowDiagramCallbacks {
127
137
  /** Fires when a hover overlay action is clicked */
128
138
  onNodeHoverAction?: (actionId: string, nodeId: string, nodeData: any) => void;
129
139
  /** Fires when a new edge is drawn between two nodes */
130
- onEdgeCreate?: (sourceId: string, targetId: string) => void;
140
+ onEdgeCreate?: (sourceId: string, targetId: string, properties?: FlowEdgeProperties) => void;
131
141
  /** Fires when an edge is clicked/selected */
132
142
  onEdgeSelect?: (edgeId: string, edgeData: any) => void;
133
143
  /** Fires when edge selection is cleared */
@@ -154,8 +164,8 @@ export declare interface FlowDiagramCallbacks {
154
164
  onDirectionChange?: (direction: FlowDirection) => void;
155
165
  /** Fires when array/set mode toggles in bottom bar */
156
166
  onArrayModeChange?: (isArrayMode: boolean) => void;
157
- /** Fires when Cytoscape instance is initialized (for advanced use) */
158
- onCyInit?: (cy: any) => void;
167
+ /** Fires once the renderer is ready with the engine handle (zoom/pan/fit/coordinate helpers) */
168
+ onInit?: (engine: FlowEngine) => void;
159
169
  /**
160
170
  * Fires with the updated Squeed JSON after any toolbar/inline edit. The SDK applies the
161
171
  * edit with `$` schema keys; store the result and pass it back as `json`.
@@ -167,6 +177,8 @@ export declare interface FlowDiagramCallbacks {
167
177
  export declare interface FlowDiagramConfig {
168
178
  /** Layout direction: "LR", "RL", "TB", "BT" */
169
179
  direction?: FlowDirection;
180
+ nodeAlignment?: NodeAlignment;
181
+ edgeMode?: EdgeMode;
170
182
  /** Layout algorithm */
171
183
  layout?: LayoutAlgorithm;
172
184
  /** Theme accent color (Chakra token e.g. "blue.500") */
@@ -230,6 +242,9 @@ export declare interface FlowDiagramEdge {
230
242
  id: string;
231
243
  source: string;
232
244
  target: string;
245
+ sourceProperty?: string;
246
+ targetProperty?: string;
247
+ connection?: SqueedConnectionRef;
233
248
  label?: string;
234
249
  /** Chakra token or hex; overrides the theme/edgeColor line color for this edge */
235
250
  color?: string;
@@ -271,6 +286,7 @@ export declare interface FlowDiagramProps {
271
286
  config?: FlowDiagramConfig;
272
287
  /** Event callbacks */
273
288
  callbacks?: FlowDiagramCallbacks;
289
+ showBottomBar?: boolean;
274
290
  /** CSS class name */
275
291
  className?: string;
276
292
  /** Inline styles */
@@ -280,6 +296,30 @@ export declare interface FlowDiagramProps {
280
296
  /** "C" = center: root in the middle, children fan out both ways (generate with `isCntr: true`); laid out as LR */
281
297
  export declare type FlowDirection = "LR" | "RL" | "TB" | "BT" | "C";
282
298
 
299
+ export declare interface FlowEdgeProperties {
300
+ sourceProperty?: string;
301
+ targetProperty?: string;
302
+ }
303
+
304
+ /** Handle passed to `callbacks.onInit`. */
305
+ export declare interface FlowEngine {
306
+ zoom(): number;
307
+ /** Set zoom keeping the current pan (like cytoscape `cy.zoom(level)`) */
308
+ zoom(level: number): void;
309
+ pan(): Point;
310
+ pan(p: Point): void;
311
+ /** Zoom keeping the model point under `renderedPoint` (container px) fixed */
312
+ zoomAt(level: number, renderedPoint: Point): void;
313
+ /** Fit all elements into the container with `padding` rendered px */
314
+ fit(padding?: number): void;
315
+ /** Centre all elements at the current zoom */
316
+ center(): void;
317
+ clientToModel(clientX: number, clientY: number): Point;
318
+ modelToClient(p: Point): Point;
319
+ getNodeBox(id: string): Box | undefined;
320
+ onViewportChange(fn: (vp: ViewportState) => void): () => void;
321
+ }
322
+
283
323
  export declare const getChakraColorHex: (color?: any, opacity?: any) => any;
284
324
 
285
325
  export declare const getColorVariant: (color: string) => {
@@ -298,6 +338,8 @@ export declare function getNode(json: SqueedJson, address: string): any;
298
338
 
299
339
  export declare type LayoutAlgorithm = "dagre" | "elk" | "tidytree" | "concentric" | "cose";
300
340
 
341
+ export declare type NodeAlignment = "leading" | "center" | "trailing";
342
+
301
343
  /** Actions shown in the hover overlay above nodes */
302
344
  export declare interface NodeOverlayAction {
303
345
  id: string;
@@ -341,6 +383,11 @@ export declare interface ParentNodeStyle {
341
383
  labelPosition?: "top" | "center" | "bottom";
342
384
  }
343
385
 
386
+ declare interface Point {
387
+ x: number;
388
+ y: number;
389
+ }
390
+
344
391
  /** Removes a `$target` edge; hierarchy edges cannot be removed without removing the child (returns json unchanged). */
345
392
  export declare function removeEdge(json: SqueedJson, edge: RenderedEdgeRef): {
346
393
  json: SqueedJson;
@@ -349,10 +396,11 @@ export declare function removeEdge(json: SqueedJson, edge: RenderedEdgeRef): {
349
396
 
350
397
  export declare function removeNode(json: SqueedJson, address: string): SqueedJson;
351
398
 
352
- export declare interface RenderedEdgeRef {
399
+ export declare interface RenderedEdgeRef extends FlowEdgeProperties {
353
400
  source: string;
354
401
  target: string;
355
402
  isInverted?: boolean | null;
403
+ connection?: SqueedConnectionRef;
356
404
  }
357
405
 
358
406
  /**
@@ -362,7 +410,7 @@ export declare interface RenderedEdgeRef {
362
410
  */
363
411
  export declare function resolveEdgeOwner(edge: RenderedEdgeRef): {
364
412
  address: string;
365
- kind: "hierarchy" | "target";
413
+ kind: "hierarchy" | "target" | "connection";
366
414
  };
367
415
 
368
416
  /** Props passed to custom edge selection toolbar renderer */
@@ -410,15 +458,29 @@ export declare interface SqueedChange {
410
458
  export declare interface SqueedChangeInfo {
411
459
  type: "nodeLabel" | "nodeColor" | "nodeIcon" | "nodeCollapse" | "nodeCreate" | "nodeDelete" | "edgeLabel" | "edgeStyle" | "edgeColor" | "edgeCreate" | "edgeDelete";
412
460
  address?: string;
413
- edge?: {
461
+ edge?: FlowEdgeProperties & {
414
462
  source: string;
415
463
  target: string;
416
464
  isInverted?: boolean | null;
465
+ connection?: SqueedConnectionRef;
417
466
  };
418
467
  key?: string;
419
468
  value?: unknown;
420
469
  }
421
470
 
471
+ export declare interface SqueedConnection extends FlowEdgeProperties {
472
+ target: string;
473
+ id?: string;
474
+ label?: string;
475
+ color?: string;
476
+ style?: "solid" | "dashed" | "animated";
477
+ }
478
+
479
+ export declare interface SqueedConnectionRef {
480
+ address: string;
481
+ key: string;
482
+ }
483
+
422
484
  /** Schema keys that describe the edge *into* a node (parent → child) */
423
485
  export declare type SqueedEdgeKey = "$sourceLabel" | "$isEdgeAnimated" | "$isEdgeDashed" | "$edgeColor";
424
486
 
@@ -430,7 +492,7 @@ export declare type SqueedEdgeKey = "$sourceLabel" | "$isEdgeAnimated" | "$isEdg
430
492
  export declare type SqueedJson = Record<string, any> | any[];
431
493
 
432
494
  /** Schema keys that live on a node */
433
- export declare type SqueedNodeKey = "$label" | "$bgColor" | "$textColor" | "$borderColor" | "$borderRadius" | "$fontSize" | "$icon" | "$content" | "$media" | "$collapsed" | "$parent";
495
+ export declare type SqueedNodeKey = "$label" | "$bgColor" | "$textColor" | "$borderColor" | "$borderRadius" | "$fontSize" | "$icon" | "$content" | "$media" | "$collapsed" | "$parent" | "$connections";
434
496
 
435
497
  /** Immutable update of the node at `address` (root address updates the document itself) */
436
498
  export declare function updateNode(json: SqueedJson, address: string, fn: (node: any) => any): SqueedJson;
@@ -481,4 +543,9 @@ export declare function useThemeContentColors(color: any): {
481
543
  highlightColorFaint: string;
482
544
  };
483
545
 
546
+ declare interface ViewportState {
547
+ pan: Point;
548
+ zoom: number;
549
+ }
550
+
484
551
  export { }