@squeed/flow-sdk 2.0.1 → 2.0.2

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.cts CHANGED
@@ -1,5 +1,17 @@
1
+ import { Context } from 'react';
2
+ import { CSSProperties } from 'react';
3
+ import { DetailedHTMLProps } from 'react';
4
+ import { ForwardRefExoticComponent } from 'react';
5
+ import { IconButtonProps } from '@chakra-ui/react';
6
+ import { InputHTMLAttributes } from 'react';
1
7
  import { JSX as JSX_2 } from 'react/jsx-runtime';
8
+ import { MemoExoticComponent } from 'react';
2
9
  import { MutableRefObject } from 'react';
10
+ import { ReactNode } from 'react';
11
+ import { ReactPortal } from 'react';
12
+ import { RefAttributes } from 'react';
13
+ import { StyledComponent } from '@emotion/styled';
14
+ import { Theme } from '@emotion/react';
3
15
 
4
16
  /** Add a child under `parentAddress`. Returns the new node's address. */
5
17
  export declare function addChild(json: SqueedJson, parentAddress: string, child: any, key?: string): {
@@ -24,14 +36,25 @@ export declare function applyCollapsed(nodes: FlowDiagramNode[], edges: FlowDiag
24
36
  edges: FlowDiagramEdge[];
25
37
  };
26
38
 
39
+ export declare function applyFormChange(data: SqueedJson, request: Omit<FormChange, "data" | "previousValue">, handler?: (event: FormChange) => FormEdit[] | void): SqueedJson;
40
+
41
+ export declare function applyStateEdits(state: SqueedJson, edits: readonly FormEdit[]): SqueedJson;
42
+
27
43
  export declare type BackgroundPattern = "dot" | "steel" | "grid" | "none";
28
44
 
45
+ export declare type BackgroundVariant = BackgroundPattern | "transparent";
46
+
29
47
  /**
30
48
  * Wrap consumer callbacks so every toolbar/edit event is applied to `json`
31
49
  * with Squeed `$` keys and delivered via `onJsonChange`. Granular callbacks
32
50
  * still fire first (for logging/analytics) — consumers must not also mutate.
33
51
  */
34
- export declare function bindSqueedCallbacks(json: SqueedJson, compiledEdges: FlowDiagramEdge[], callbacks: FlowDiagramCallbacks, onJsonChange?: (json: SqueedJson, change: SqueedChange) => void): FlowDiagramCallbacks;
52
+ export declare function bindSqueedCallbacks(json: SqueedJson, compiledEdges: FlowDiagramEdge[], callbacks: FlowDiagramCallbacks, onJsonChange?: (json: SqueedJson, change: SqueedChange) => void, formSchema?: FormSchema): FlowDiagramCallbacks;
53
+
54
+ export declare const BottomBar: MemoExoticComponent< {
55
+ (): JSX_2.Element;
56
+ displayName: string;
57
+ }>;
35
58
 
36
59
  /** Props passed to custom bottom bar renderer */
37
60
  export declare interface BottomBarRenderProps {
@@ -64,8 +87,15 @@ declare interface Box {
64
87
  y: number;
65
88
  w: number;
66
89
  h: number;
90
+ outline?: Point[];
67
91
  }
68
92
 
93
+ export declare type BuiltInEdgeType = "straight" | "bezier" | "orthogonal" | "rounded-orthogonal";
94
+
95
+ export declare function CompactPropertyLayoutToggle({ label, }?: {
96
+ label?: string;
97
+ }): JSX_2.Element;
98
+
69
99
  export declare interface CompileOptions {
70
100
  title?: string;
71
101
  /** Root in the middle, children fan out both ways (direction "C") */
@@ -85,6 +115,17 @@ export declare function compileSqueed(json: SqueedJson, opts?: CompileOptions):
85
115
  edges: FlowDiagramEdge[];
86
116
  };
87
117
 
118
+ export declare function connectionIssue(contract: WorkflowContract, edge: FlowDiagramEdge["data"]): string | undefined;
119
+
120
+ export declare function ConnectionsOnlyToggle({ checked, onChange, disabled, label, }: ConnectionsOnlyToggleProps): JSX_2.Element;
121
+
122
+ export declare interface ConnectionsOnlyToggleProps {
123
+ checked: boolean;
124
+ onChange: (checked: boolean) => void;
125
+ disabled?: boolean;
126
+ label?: string;
127
+ }
128
+
88
129
  export declare const contentObjTheme: (color: any) => {
89
130
  background: any;
90
131
  highlight: string;
@@ -95,28 +136,164 @@ export declare const contentObjTheme: (color: any) => {
95
136
  number: string;
96
137
  };
97
138
 
139
+ declare interface ContractPort {
140
+ kind: "input" | "config" | "output" | "error";
141
+ resourceType?: string;
142
+ multiple?: boolean;
143
+ }
144
+
145
+ export declare interface ContractProperty {
146
+ type: ContractType;
147
+ optional: boolean;
148
+ }
149
+
150
+ export declare type ContractType = {
151
+ kind: "json";
152
+ } | {
153
+ kind: "string" | "number" | "integer" | "boolean" | "null";
154
+ } | {
155
+ kind: "literal";
156
+ value: string | number | boolean | null;
157
+ } | {
158
+ kind: "union";
159
+ types: ContractType[];
160
+ } | {
161
+ kind: "array";
162
+ items: ContractType;
163
+ } | {
164
+ kind: "object";
165
+ properties: Record<string, ContractProperty>;
166
+ additionalProperties?: ContractType;
167
+ ports?: Record<string, ContractPort>;
168
+ };
169
+
98
170
  export declare function createFlowDiagram(jsnObjct: any, path?: string, nodes?: any[], edges?: any[], activeLabel?: string, flowConfig?: any, nodeConfig?: any): {
99
171
  nodes: any[];
100
172
  edges: any[];
101
173
  };
102
174
 
103
- export declare const DynamicIcon: ({ name, ...props }: {
175
+ export declare function createFlowDocumentActions(options: FlowDocumentActionOptions): {
176
+ replaceJson(value: unknown): SqueedJson;
177
+ replaceState(value: unknown): SqueedJson;
178
+ };
179
+
180
+ export declare function createFormNode(document: SqueedJson, source: string, schema?: FormSchema): {
181
+ address: string;
182
+ json: SqueedJson;
183
+ };
184
+
185
+ export declare function createJsonPlayback<Document>(options: JsonStreamOptions<Document> & {
186
+ source: string;
187
+ durationMs?: number;
188
+ tickMs?: number;
189
+ onChange: (state: JsonPlaybackState) => void;
190
+ onError: (error: unknown) => void;
191
+ }): {
192
+ play(): void;
193
+ pause(): void;
194
+ seek(next: number): void;
195
+ dispose(): void;
196
+ };
197
+
198
+ export declare function createJsonStream<Document>(options: JsonStreamOptions<Document>): {
199
+ snapshot: (text: string) => void;
200
+ append(chunk: string): void;
201
+ flush: () => void;
202
+ finish(): Document;
203
+ cancel(): void;
204
+ };
205
+
206
+ export declare interface CustomEdgeContext {
207
+ edge: FlowDiagramEdge["data"];
208
+ source: Box;
209
+ target: Box;
210
+ sourcePoint: Point;
211
+ targetPoint: Point;
212
+ direction: FlowDirection;
213
+ sourceY?: number;
214
+ targetY?: number;
215
+ inverted: boolean;
216
+ defaultGeometry: CustomEdgeGeometry;
217
+ }
218
+
219
+ export declare type CustomEdgeFactory = (context: CustomEdgeContext) => CustomEdgeGeometry | null;
220
+
221
+ export declare interface CustomEdgeGeometry {
222
+ d: string;
223
+ arrow?: string;
224
+ label: {
225
+ x: number;
226
+ y: number;
227
+ angle: number;
228
+ };
229
+ }
230
+
231
+ export declare const DEFAULT_PALETTE: string[];
232
+
233
+ export declare function DiagramAppearanceControls(): JSX_2.Element;
234
+
235
+ export declare function downloadSvg(canvas: HTMLElement, filename?: string): Promise<void>;
236
+
237
+ export declare const DynamicIcon: ({ name, svg, ...props }: {
104
238
  [x: string]: any;
105
239
  name: any;
240
+ svg?: boolean;
106
241
  }) => JSX_2.Element;
107
242
 
108
- export declare type EdgeMode = "workflow" | "properties";
243
+ export declare type EdgeAnimationVariant = "dashed" | "traveling";
244
+
245
+ export declare type EdgeMode = "auto" | "nodes" | "properties" | "workflow";
246
+
247
+ /** Bottom-bar contents while an edge is selected */
248
+ export declare function EdgeTools({ edgeId, onClose, }: {
249
+ edgeId: string;
250
+ onClose: () => void;
251
+ }): JSX_2.Element;
252
+
253
+ export declare const EditableLabel: ({ nodeId, label, color, fontWeight, fontSize, wrap, isEditing, onEditStart, onEditEnd, }: EditableLabelProps) => JSX_2.Element;
254
+
255
+ declare interface EditableLabelProps {
256
+ nodeId: string;
257
+ label: string;
258
+ color: string;
259
+ fontWeight?: string;
260
+ fontSize?: string;
261
+ wrap?: boolean;
262
+ isEditing: boolean;
263
+ onEditStart: () => void;
264
+ onEditEnd: () => void;
265
+ }
266
+
267
+ export declare function ErrorToast({ message, onDismiss, }: {
268
+ message: string;
269
+ onDismiss: () => void;
270
+ }): ReactPortal;
109
271
 
110
- export declare function FlowDiagram({ title, json, nodes, edges, config, callbacks, className, style, showBottomBar, }: FlowDiagramProps): JSX_2.Element;
272
+ export declare function exportSvg(canvas: HTMLElement): Promise<string>;
273
+
274
+ export declare function FlowDiagram({ loading, loader, ...props }: FlowDiagramProps): JSX_2.Element;
111
275
 
112
276
  /** Event callbacks for the flow diagram */
113
277
  export declare interface FlowDiagramCallbacks {
278
+ onAllNodesIconLabelChange?: (enabled: boolean) => void;
279
+ onNodeCreateRequest?: (request: FlowNodeCreationRequest) => boolean;
280
+ onFormSchemaChange?: (schema: FormSchema | undefined) => void;
281
+ onFormChange?: (event: FormChange) => FormEdit[] | void;
282
+ resolveFormOptions?: (request: FormOptionsRequest) => Promise<FormOption[]> | FormOption[];
283
+ onSpacingChange?: (spacing: NodeSpacing) => void;
284
+ onEdgeRadiusChange?: (radius: number) => void;
285
+ onCompactPropertyLayoutChange?: (enabled: boolean) => void;
286
+ onBackgroundVariantChange?: (variant: BackgroundVariant) => void;
114
287
  /** Fires when a node is clicked/selected */
115
- onNodeSelect?: (nodeId: string, nodeData: any) => void;
288
+ onNodeSelect?: (nodeId: string, nodeData: any, modifiers?: NodeSelectionModifiers) => void;
289
+ onBackgroundClick?: () => void;
116
290
  /** Fires when selection is cleared */
117
291
  onNodeDeselect?: () => void;
118
292
  /** Fires on double-click of a node */
119
293
  onNodeDoubleClick?: (nodeId: string, nodeData: any) => void;
294
+ onNodeViewModeChange?: (nodeId: string, mode: NodeViewMode) => void;
295
+ onNodeViewToggle?: (nodeId: string) => void;
296
+ onNodeTypeViewChange?: (nodeId: string, view: NodeTypeView | undefined) => void;
120
297
  /** Fires when a node is created via edge drawing into empty space */
121
298
  onNodeCreate?: (params: {
122
299
  type: string;
@@ -128,12 +305,21 @@ export declare interface FlowDiagramCallbacks {
128
305
  onNodeDelete?: (nodeId: string, nodeData: any) => void;
129
306
  /** Fires when a node label is edited inline */
130
307
  onNodeLabelChange?: (nodeId: string, newLabel: string) => void;
308
+ onNodeContentChange?: (nodeId: string, content: string) => void;
131
309
  /** Fires when a node's collapse toggle is clicked */
132
310
  onNodeCollapse?: (nodeId: string, collapsed: boolean) => void;
133
311
  /** Fires when a node's color is changed via the toolbar */
134
312
  onNodeColorChange?: (nodeId: string, colorType: "text" | "bg", color: string) => void;
135
313
  /** Fires when a node's icon is changed via the toolbar */
136
314
  onNodeIconChange?: (nodeId: string, iconName: string) => void;
315
+ onNodeOutlineChange?: (nodeId: string, outline: boolean) => void;
316
+ onNodeBorderColorChange?: (nodeId: string, color: string) => void;
317
+ onNodeBorderStyleChange?: (nodeId: string, style: "solid" | "dashed") => void;
318
+ onNodeBorderWidthChange?: (nodeId: string, width: number | undefined) => void;
319
+ onNodeBorderRadiusChange?: (nodeId: string, radius: number | undefined) => void;
320
+ onNodeAnimationChange?: (nodeId: string, animated: boolean) => void;
321
+ onNodeAnimationVariantChange?: (nodeId: string, variant: NodeAnimationVariant) => void;
322
+ onEdgeAnimationVariantChange?: (edgeId: string, variant: EdgeAnimationVariant) => void;
137
323
  /** Fires when a hover overlay action is clicked */
138
324
  onNodeHoverAction?: (actionId: string, nodeId: string, nodeData: any) => void;
139
325
  /** Fires when a new edge is drawn between two nodes */
@@ -148,6 +334,8 @@ export declare interface FlowDiagramCallbacks {
148
334
  onEdgeDelete?: (edgeId: string, edgeData: any) => void;
149
335
  /** Fires when an edge's color is changed */
150
336
  onEdgeColorChange?: (edgeId: string, color: string) => void;
337
+ onEdgeTypeChange?: (edgeId: string, type: string | undefined) => void;
338
+ onEdgeIconChange?: (edgeId: string, icon: string) => void;
151
339
  /** Fires when an edge's label is changed */
152
340
  onEdgeLabelChange?: (edgeId: string, newLabel: string) => void;
153
341
  /** Fires when an edge's style is changed (solid, dashed, animated) */
@@ -162,10 +350,15 @@ export declare interface FlowDiagramCallbacks {
162
350
  }) => void;
163
351
  /** Fires when the flow direction changes via bottom bar */
164
352
  onDirectionChange?: (direction: FlowDirection) => void;
353
+ onThemeColorChange?: (color: string) => void;
354
+ onEdgeModeChange?: (mode: EdgeMode) => void;
355
+ onWorkflowContractChange?: (contract: WorkflowContract | undefined) => void;
165
356
  /** Fires when array/set mode toggles in bottom bar */
166
357
  onArrayModeChange?: (isArrayMode: boolean) => void;
167
358
  /** Fires once the renderer is ready with the engine handle (zoom/pan/fit/coordinate helpers) */
168
359
  onInit?: (engine: FlowEngine) => void;
360
+ /** Fires after layout and measurement settle; viewport-only changes do not trigger it. */
361
+ onLayoutComplete?: (engine: FlowEngine) => void;
169
362
  /**
170
363
  * Fires with the updated Squeed JSON after any toolbar/inline edit. The SDK applies the
171
364
  * edit with `$` schema keys; store the result and pass it back as `json`.
@@ -175,10 +368,22 @@ export declare interface FlowDiagramCallbacks {
175
368
 
176
369
  /** Configuration for the flow diagram appearance and behavior */
177
370
  export declare interface FlowDiagramConfig {
371
+ bottomBarExtra?: React.ReactNode;
372
+ /** Animate fit/center/focus actions for 300ms by default. Per-action flags override this; reduced motion stays instant. */
373
+ animateViewport?: boolean;
374
+ formSchema?: FormSchema;
375
+ spacing?: NodeSpacing;
376
+ edgeRadius?: number;
377
+ backgroundVariant?: BackgroundVariant;
378
+ edgeType?: BuiltInEdgeType | (string & {});
379
+ customEdgeTypes?: Record<string, CustomEdgeFactory>;
178
380
  /** Layout direction: "LR", "RL", "TB", "BT" */
179
381
  direction?: FlowDirection;
180
382
  nodeAlignment?: NodeAlignment;
181
383
  edgeMode?: EdgeMode;
384
+ compactPropertyLayout?: boolean;
385
+ nodeViewModes?: Record<string, NodeViewMode>;
386
+ workflowContract?: WorkflowContract;
182
387
  /** Layout algorithm */
183
388
  layout?: LayoutAlgorithm;
184
389
  /** Theme accent color (Chakra token e.g. "blue.500") */
@@ -237,19 +442,76 @@ export declare interface FlowDiagramConfig {
237
442
  isDragMode?: boolean;
238
443
  }
239
444
 
445
+ export declare interface FlowDiagramContextValue {
446
+ allNodesIconLabel: boolean;
447
+ setAllNodesIconLabel: (enabled: boolean) => void;
448
+ nodeViewModes: Record<string, NodeViewMode>;
449
+ setNodeViewMode: (nodeId: string, mode: NodeViewMode) => void;
450
+ spacing: number;
451
+ edgeRadius: number | undefined;
452
+ setEdgeRadius: (radius: number) => void;
453
+ setSpacing: (spacing: NodeSpacing) => void;
454
+ backgroundVariant: BackgroundVariant;
455
+ setBackgroundVariant: (variant: BackgroundVariant) => void;
456
+ setEdgeMode: (mode: EdgeMode) => void;
457
+ compactPropertyLayout: boolean;
458
+ setCompactPropertyLayout: (enabled: boolean) => void;
459
+ workflowContract?: WorkflowContract;
460
+ setWorkflowContract: (contract: WorkflowContract | undefined) => void;
461
+ themeColor: string;
462
+ setThemeColor: (color: string) => void;
463
+ backgroundSelected: boolean;
464
+ setBackgroundSelected: (selected: boolean) => void;
465
+ edgeColor: string;
466
+ colorMode: "light" | "dark";
467
+ direction: string;
468
+ nodeAlignment: NodeAlignment;
469
+ edgeMode: EdgeMode;
470
+ parentNodeStyle?: ParentNodeStyle;
471
+ selectedNodeIds: string[];
472
+ setSelectedNodeIds: (ids: string[]) => void;
473
+ selectedEdgeId: string | null;
474
+ setSelectedEdgeId: (id: string | null) => void;
475
+ isZoomMode: boolean;
476
+ setIsZoomMode: (v: boolean) => void;
477
+ isMultiSelectMode: boolean;
478
+ setIsMultiSelectMode: (v: boolean) => void;
479
+ isDragMode: boolean;
480
+ setIsDragMode: (v: boolean) => void;
481
+ isEdgeHandlesEnabled: boolean;
482
+ setIsEdgeHandlesEnabled: (v: boolean) => void;
483
+ isArrayNodeMode: boolean;
484
+ setIsArrayNodeMode: (v: boolean) => void;
485
+ isPinned: boolean;
486
+ setIsPinned: (v: boolean) => void;
487
+ isPerformanceMode: boolean;
488
+ setIsPerformanceMode: (v: boolean) => void;
489
+ engineRef: React.MutableRefObject<FlowEngine | null>;
490
+ callbacks: FlowDiagramCallbacks;
491
+ config: FlowDiagramConfig;
492
+ readOnly: boolean;
493
+ }
494
+
240
495
  export declare interface FlowDiagramEdge {
241
496
  data: {
242
497
  id: string;
498
+ type?: BuiltInEdgeType | (string & {});
243
499
  source: string;
244
500
  target: string;
245
501
  sourceProperty?: string;
246
502
  targetProperty?: string;
247
503
  connection?: SqueedConnectionRef;
504
+ collapsedEndpoints?: {
505
+ source: string;
506
+ target: string;
507
+ };
248
508
  label?: string;
509
+ icon?: string;
249
510
  /** Chakra token or hex; overrides the theme/edgeColor line color for this edge */
250
511
  color?: string;
251
512
  isInverted?: boolean;
252
513
  isEdgeAnimated?: boolean;
514
+ edgeAnimationVariant?: EdgeAnimationVariant;
253
515
  isEdgeDashed?: boolean;
254
516
  };
255
517
  }
@@ -266,11 +528,17 @@ export declare interface FlowDiagramNode {
266
528
  description?: Record<string, any>;
267
529
  viewProps?: any;
268
530
  config?: Record<string, any>;
531
+ isNodeAnimated?: boolean;
532
+ nodeAnimationVariant?: NodeAnimationVariant;
269
533
  };
270
534
  }
271
535
 
272
536
  /** Top-level props for the FlowDiagram component */
273
537
  export declare interface FlowDiagramProps {
538
+ /** Show the loader while the host fetches data; initial compilation waits until false. */
539
+ loading?: boolean;
540
+ /** Custom loading content. Defaults to an accessible status message. Also shown while new JSON is prepared. */
541
+ loader?: React.ReactNode;
274
542
  /** Title shown on the root node */
275
543
  title?: string;
276
544
  /**
@@ -278,6 +546,7 @@ export declare interface FlowDiagramProps {
278
546
  * edit is reported through `callbacks.onJsonChange`. Takes precedence over nodes/edges.
279
547
  */
280
548
  json?: Record<string, any> | any[];
549
+ forms?: StateForms;
281
550
  /** Pre-computed nodes */
282
551
  nodes?: FlowDiagramNode[];
283
552
  /** Pre-computed edges */
@@ -287,15 +556,33 @@ export declare interface FlowDiagramProps {
287
556
  /** Event callbacks */
288
557
  callbacks?: FlowDiagramCallbacks;
289
558
  showBottomBar?: boolean;
559
+ /** Custom controls rendered inside the diagram and form providers, even when showBottomBar is false. */
560
+ children?: React.ReactNode;
290
561
  /** CSS class name */
291
562
  className?: string;
292
563
  /** Inline styles */
293
564
  style?: React.CSSProperties;
294
565
  }
295
566
 
567
+ export declare function FlowDiagramProvider({ config, callbacks, nodes, edges, children, }: {
568
+ config: FlowDiagramConfig;
569
+ callbacks: FlowDiagramCallbacks;
570
+ nodes?: FlowDiagramNode[];
571
+ edges?: FlowDiagramEdge[];
572
+ children: React.ReactNode;
573
+ }): JSX_2.Element;
574
+
296
575
  /** "C" = center: root in the middle, children fan out both ways (generate with `isCntr: true`); laid out as LR */
297
576
  export declare type FlowDirection = "LR" | "RL" | "TB" | "BT" | "C";
298
577
 
578
+ export declare interface FlowDocumentActionOptions {
579
+ json?: SqueedJson;
580
+ state?: SqueedJson;
581
+ readOnly?: boolean;
582
+ onJsonChange?: (json: SqueedJson, change: SqueedChange) => void;
583
+ onStateChange?: StateForms["onChange"];
584
+ }
585
+
299
586
  export declare interface FlowEdgeProperties {
300
587
  sourceProperty?: string;
301
588
  targetProperty?: string;
@@ -311,35 +598,217 @@ export declare interface FlowEngine {
311
598
  /** Zoom keeping the model point under `renderedPoint` (container px) fixed */
312
599
  zoomAt(level: number, renderedPoint: Point): void;
313
600
  /** Fit all elements into the container with `padding` rendered px */
314
- fit(padding?: number): void;
601
+ fit(padding?: number, animate?: boolean): void;
602
+ /** Explicit alias for fit: fit and centre all elements with screen-pixel padding. */
603
+ centerAndFit(padding?: number, animate?: boolean): void;
315
604
  /** Centre all elements at the current zoom */
316
- center(): void;
605
+ center(animate?: boolean): void;
606
+ /** Fit one currently laid-out node; padding is in screen pixels (default 50). */
607
+ focusNode(id: string, padding?: number, animate?: boolean): void;
608
+ /** Fit laid-out hierarchy descendants and outgoing reachable nodes. Does not expand collapsed nodes. Animate overrides config.animateViewport. */
609
+ focusBranch(id: string, padding?: number, animate?: boolean): void;
610
+ focusConnections(id: string, padding?: number, animate?: boolean): void;
611
+ isolateConnections(id: string, padding?: number, animate?: boolean): void;
612
+ /** Temporarily show only this branch and fit it, preserving graph data. */
613
+ isolateBranch(id: string, padding?: number, animate?: boolean): void;
614
+ /** End isolation and restore the viewport saved when isolation began. */
615
+ restoreView(animate?: boolean): void;
616
+ /** Hide/show edge paths, labels and hit targets without changing graph data. */
617
+ setEdgesVisible(visible: boolean): void;
317
618
  clientToModel(clientX: number, clientY: number): Point;
318
619
  modelToClient(p: Point): Point;
319
620
  getNodeBox(id: string): Box | undefined;
621
+ setNodePosition(id: string, position: Point | undefined, options?: {
622
+ persist?: boolean;
623
+ }): boolean;
320
624
  onViewportChange(fn: (vp: ViewportState) => void): () => void;
321
625
  }
322
626
 
627
+ export declare interface FlowNodeCreationRequest {
628
+ sourceNodeId: string;
629
+ sourceProperty?: string;
630
+ reverse: boolean;
631
+ position: {
632
+ x: number;
633
+ y: number;
634
+ };
635
+ }
636
+
637
+ export declare function FlowPort({ id, role, side, position, placement, children, style, }: FlowPortProps): JSX_2.Element;
638
+
639
+ export declare interface FlowPortProps {
640
+ id: string;
641
+ role: "source" | "target";
642
+ side?: PortSide;
643
+ position?: number;
644
+ placement?: "config";
645
+ children?: ReactNode;
646
+ style?: CSSProperties;
647
+ }
648
+
649
+ export declare const FlowView: MemoExoticComponent<({ nodes, edges }: FlowViewProps) => JSX_2.Element>;
650
+
651
+ declare interface FlowViewProps {
652
+ nodes: FlowDiagramNode[];
653
+ edges: FlowDiagramEdge[];
654
+ }
655
+
656
+ export declare interface FormBinding {
657
+ $type: string;
658
+ $fields?: Record<string, FormFieldConfig>;
659
+ $create?: FormCreation;
660
+ }
661
+
662
+ export declare interface FormChange extends FormRequest {
663
+ previousValue: unknown;
664
+ value: unknown;
665
+ }
666
+
667
+ export declare type FormCondition = {
668
+ $address: string;
669
+ } & ({
670
+ $equals: FormValue;
671
+ } | {
672
+ $in: FormValue[];
673
+ });
674
+
675
+ export declare interface FormCreation {
676
+ $address: string;
677
+ $type: string;
678
+ $label?: string;
679
+ $icon?: string;
680
+ $edgeLabel?: string;
681
+ $defaults?: Record<string, unknown>;
682
+ }
683
+
684
+ export declare const FormDocumentContext: Context< {
685
+ setSchema?: (schema: FormSchema | undefined) => void;
686
+ data?: SqueedJson;
687
+ viewData?: SqueedJson;
688
+ bindings?: StateForms["bindings"];
689
+ editable?: boolean;
690
+ schema?: FormSchema;
691
+ renderForm?: StateForms["renderForm"];
692
+ structured?: StructuredForms;
693
+ references?: StateForms["references"];
694
+ callbacks: FlowDiagramCallbacks;
695
+ }>;
696
+
697
+ export declare type FormEdit = {
698
+ op: "set";
699
+ address: string;
700
+ value: unknown;
701
+ } | {
702
+ op: "remove";
703
+ address: string;
704
+ };
705
+
706
+ export declare interface FormFieldConfig {
707
+ $label?: string;
708
+ $section?: string;
709
+ $control?: "input" | "textarea" | "select" | "pills" | "checkbox";
710
+ $visibleWhen?: FormCondition;
711
+ $requiredWhen?: FormCondition;
712
+ $options?: {
713
+ $source: "callback";
714
+ $dependsOn?: string[];
715
+ };
716
+ }
717
+
718
+ export declare interface FormOption {
719
+ label: string;
720
+ value: FormValue;
721
+ }
722
+
723
+ export declare interface FormOptionsRequest extends FormRequest {
724
+ signal: AbortSignal;
725
+ }
726
+
727
+ export declare interface FormRequest {
728
+ address: string;
729
+ nodeAddress: string;
730
+ nodeId?: string;
731
+ data: SqueedJson;
732
+ }
733
+
734
+ export declare type FormSchema = Record<string, Extract<ContractType, {
735
+ kind: "object";
736
+ }>>;
737
+
738
+ export declare type FormValue = string | number | boolean | null;
739
+
740
+ export declare function formValueError(type: ContractType, value: unknown, required: boolean): string | undefined;
741
+
323
742
  export declare const getChakraColorHex: (color?: any, opacity?: any) => any;
324
743
 
325
744
  export declare const getColorVariant: (color: string) => {
326
- secondary: string;
327
- primary?: undefined;
328
- light?: undefined;
329
- } | {
330
745
  primary: string;
331
746
  secondary: string;
332
747
  light: string;
748
+ } | {
749
+ secondary: string;
750
+ primary?: undefined;
751
+ light?: undefined;
333
752
  };
334
753
 
335
754
  export declare function getDarkerHexColor(hex: string, factor?: number): string;
336
755
 
337
756
  export declare function getNode(json: SqueedJson, address: string): any;
338
757
 
758
+ export declare interface JsonPlaybackState {
759
+ position: number;
760
+ total: number;
761
+ playing: boolean;
762
+ }
763
+
764
+ export declare interface JsonStreamOptions<Document> {
765
+ parse: (source: string) => Document;
766
+ repair: (source: string) => string;
767
+ preview: (document: Document) => void;
768
+ commit: (document: Document) => void;
769
+ intervalMs?: number;
770
+ maxBytes?: number;
771
+ }
772
+
339
773
  export declare type LayoutAlgorithm = "dagre" | "elk" | "tidytree" | "concentric" | "cose";
340
774
 
775
+ export declare const NODE_TYPE_VIEWS: readonly ["", "icon-label", "object", "text"];
776
+
341
777
  export declare type NodeAlignment = "leading" | "center" | "trailing";
342
778
 
779
+ export declare type NodeAnimationVariant = "traveling" | "pulse";
780
+
781
+ export declare function NodeBorderRadiusControl({ ids, showDivider, }: {
782
+ ids: string[];
783
+ showDivider?: boolean;
784
+ }): JSX_2.Element;
785
+
786
+ export declare function NodeConfigSummary({ nodeAddress, expanded, }: {
787
+ nodeAddress: string;
788
+ expanded?: boolean;
789
+ }): JSX_2.Element;
790
+
791
+ export declare function NodeForm({ nodeAddress }: {
792
+ nodeAddress: string;
793
+ }): JSX_2.Element;
794
+
795
+ export declare function NodeFormPopover({ nodeAddress, active, label, open, onClose, children, filter, height, }: {
796
+ nodeAddress: string;
797
+ active: boolean;
798
+ label: string;
799
+ open?: boolean;
800
+ onClose?: () => void;
801
+ children?: ReactNode;
802
+ filter?: ReactNode;
803
+ height?: number;
804
+ }): JSX_2.Element;
805
+
806
+ export declare function NodeIconPicker({ nodeId, edgeId, value, }: {
807
+ nodeId?: string;
808
+ edgeId?: string;
809
+ value?: string;
810
+ }): JSX_2.Element;
811
+
343
812
  /** Actions shown in the hover overlay above nodes */
344
813
  export declare interface NodeOverlayAction {
345
814
  id: string;
@@ -357,12 +826,51 @@ export declare interface NodeOverlayProps {
357
826
  setIsHovered: (v: boolean) => void;
358
827
  }
359
828
 
829
+ export declare interface NodeSelectionModifiers {
830
+ shiftKey: boolean;
831
+ ctrlKey: boolean;
832
+ metaKey: boolean;
833
+ altKey: boolean;
834
+ }
835
+
836
+ export declare type NodeSpacing = number | "compact" | "normal" | "spacious";
837
+
838
+ /** Bottom-bar contents while one or more nodes are selected */
839
+ export declare function NodeTools({ ids, onClose, }: {
840
+ ids: string[];
841
+ onClose: () => void;
842
+ }): JSX_2.Element;
843
+
844
+ export declare type NodeTypeView = Exclude<(typeof NODE_TYPE_VIEWS)[number], "">;
845
+
846
+ export declare const NodeView: MemoExoticComponent<({ data: nodeData, children, isInverted, isParent, }: NodeViewProps) => JSX_2.Element>;
847
+
848
+ declare interface NodeViewChildArgs {
849
+ id: string;
850
+ data: any;
851
+ isActive: boolean;
852
+ isLowZoom: boolean;
853
+ isEditing: boolean;
854
+ onEditStart: () => void;
855
+ onEditEnd: () => void;
856
+ }
857
+
858
+ declare type NodeViewMode = "default" | "properties" | "icon-label";
859
+
860
+ declare interface NodeViewProps {
861
+ data: any;
862
+ isInverted?: boolean;
863
+ isParent?: boolean;
864
+ children: (args: NodeViewChildArgs) => React.ReactNode;
865
+ }
866
+
360
867
  /**
361
868
  * Style for compound (container) nodes. Set per node via `data.viewProps`,
362
869
  * or for all containers via `config.parentNodeStyle` (per-node wins).
363
870
  * Colors accept Chakra tokens ("purple.500") or hex.
364
871
  */
365
872
  export declare interface ParentNodeStyle {
873
+ outline?: boolean;
366
874
  /** Fill color; also the default border/label color (default: themeColor) */
367
875
  bgColor?: string;
368
876
  /** Fill opacity 0–1 (default 0.4) */
@@ -383,12 +891,32 @@ export declare interface ParentNodeStyle {
383
891
  labelPosition?: "top" | "center" | "bottom";
384
892
  }
385
893
 
894
+ export declare function parseFlowDocument(source: string): SqueedJson;
895
+
896
+ export declare function parseJsonContract(source: string, name: string): WorkflowContract;
897
+
898
+ export declare function parseTypeScriptContract(source: string, name: string): Promise<WorkflowContract>;
899
+
900
+ export declare function parseTypeScriptForm(source: string, name: string, typeName?: string, options?: {
901
+ allowJson?: boolean;
902
+ }): Promise<Extract<ContractType, {
903
+ kind: "object";
904
+ }>>;
905
+
386
906
  declare interface Point {
387
907
  x: number;
388
908
  y: number;
389
909
  }
390
910
 
391
- /** Removes a `$target` edge; hierarchy edges cannot be removed without removing the child (returns json unchanged). */
911
+ declare type PortSide = "top" | "right" | "bottom" | "left";
912
+
913
+ export declare function projectJsonPlaybackPreview(partial: SqueedJson, document: SqueedJson): SqueedJson;
914
+
915
+ export declare function readFormSchema(file: Pick<File, "name" | "size" | "text">, typeNames: string[]): Promise<FormSchema>;
916
+
917
+ export declare function readWorkflowContract(file: File): Promise<WorkflowContract>;
918
+
919
+ /** Removes explicit edges or suppresses a hierarchy edge without deleting its child. */
392
920
  export declare function removeEdge(json: SqueedJson, edge: RenderedEdgeRef): {
393
921
  json: SqueedJson;
394
922
  removed: boolean;
@@ -401,6 +929,10 @@ export declare interface RenderedEdgeRef extends FlowEdgeProperties {
401
929
  target: string;
402
930
  isInverted?: boolean | null;
403
931
  connection?: SqueedConnectionRef;
932
+ collapsedEndpoints?: {
933
+ source: string;
934
+ target: string;
935
+ };
404
936
  }
405
937
 
406
938
  /**
@@ -413,6 +945,13 @@ export declare function resolveEdgeOwner(edge: RenderedEdgeRef): {
413
945
  kind: "hierarchy" | "target" | "connection";
414
946
  };
415
947
 
948
+ export declare function resolveStateView(view: SqueedJson, state: SqueedJson): SqueedJson;
949
+
950
+ declare interface RuntimeReference {
951
+ path: string;
952
+ label: string;
953
+ }
954
+
416
955
  /** Props passed to custom edge selection toolbar renderer */
417
956
  export declare interface SelectedEdgeToolbarProps {
418
957
  edgeId: string;
@@ -432,7 +971,7 @@ export declare interface SelectionToolbarConfig {
432
971
  /** Swatches offered for node/edge colors (Chakra tokens or hex). Default: 9 Chakra 500s */
433
972
  palette?: string[];
434
973
  /** Hide individual controls */
435
- hide?: Array<"label" | "color" | "textColor" | "style" | "icon" | "collapse" | "delete">;
974
+ hide?: Array<"label" | "typeView" | "color" | "textColor" | "borderColor" | "style" | "outline" | "animation" | "icon" | "collapse" | "delete">;
436
975
  }
437
976
 
438
977
  export declare const setCollapsed: (json: SqueedJson, address: string, collapsed: boolean) => SqueedJson;
@@ -445,7 +984,7 @@ export declare function setNodeProp(json: SqueedJson, address: string, key: Sque
445
984
 
446
985
  /** What changed in the Squeed document (delivered alongside the new JSON) */
447
986
  export declare interface SqueedChange {
448
- type: "nodeLabel" | "nodeColor" | "nodeIcon" | "nodeCollapse" | "nodeCreate" | "nodeDelete" | "edgeLabel" | "edgeStyle" | "edgeColor" | "edgeCreate" | "edgeDelete";
987
+ type: "documentReplace" | "form" | "nodeLabel" | "nodeContent" | "nodeColor" | "nodeStyle" | "nodeIcon" | "nodeOutline" | "nodeAnimation" | "nodeCollapse" | "nodeCreate" | "nodeDelete" | "edgeLabel" | "edgeStyle" | "edgeColor" | "edgeCreate" | "edgeDelete";
449
988
  /** Node address affected (new node's address for nodeCreate) */
450
989
  address?: string;
451
990
  edge?: RenderedEdgeRef;
@@ -456,7 +995,7 @@ export declare interface SqueedChange {
456
995
 
457
996
  /** Describes the edit behind an `onJsonChange` */
458
997
  export declare interface SqueedChangeInfo {
459
- type: "nodeLabel" | "nodeColor" | "nodeIcon" | "nodeCollapse" | "nodeCreate" | "nodeDelete" | "edgeLabel" | "edgeStyle" | "edgeColor" | "edgeCreate" | "edgeDelete";
998
+ type: "nodeLabel" | "nodeContent" | "nodeColor" | "nodeStyle" | "nodeIcon" | "nodeOutline" | "nodeAnimation" | "nodeCollapse" | "nodeCreate" | "nodeDelete" | "edgeLabel" | "edgeStyle" | "edgeColor" | "edgeCreate" | "edgeDelete";
460
999
  address?: string;
461
1000
  edge?: FlowEdgeProperties & {
462
1001
  source: string;
@@ -469,7 +1008,10 @@ export declare interface SqueedChangeInfo {
469
1008
  }
470
1009
 
471
1010
  export declare interface SqueedConnection extends FlowEdgeProperties {
1011
+ animationVariant?: EdgeAnimationVariant;
1012
+ icon?: string;
472
1013
  target: string;
1014
+ type?: string;
473
1015
  id?: string;
474
1016
  label?: string;
475
1017
  color?: string;
@@ -482,7 +1024,7 @@ export declare interface SqueedConnectionRef {
482
1024
  }
483
1025
 
484
1026
  /** Schema keys that describe the edge *into* a node (parent → child) */
485
- export declare type SqueedEdgeKey = "$sourceLabel" | "$isEdgeAnimated" | "$isEdgeDashed" | "$edgeColor";
1027
+ export declare type SqueedEdgeKey = "$edgeIcon" | "$edgeType" | "$sourceLabel" | "$isEdgeAnimated" | "$edgeAnimationVariant" | "$isEdgeDashed" | "$edgeColor";
486
1028
 
487
1029
  /**
488
1030
  * Squeed JSON = the source document `createFlowDiagram` compiles into nodes/edges.
@@ -492,7 +1034,126 @@ export declare type SqueedEdgeKey = "$sourceLabel" | "$isEdgeAnimated" | "$isEdg
492
1034
  export declare type SqueedJson = Record<string, any> | any[];
493
1035
 
494
1036
  /** Schema keys that live on a node */
495
- export declare type SqueedNodeKey = "$label" | "$bgColor" | "$textColor" | "$borderColor" | "$borderRadius" | "$fontSize" | "$icon" | "$content" | "$media" | "$collapsed" | "$parent" | "$connections";
1037
+ export declare type SqueedNodeKey = "$view" | "$label" | "$subtitle" | "$form" | "$bgColor" | "$textColor" | "$borderColor" | "$borderStyle" | "$borderWidth" | "$borderRadius" | "$fontSize" | "$icon" | "$content" | "$media" | "$collapsed" | "$parent" | "$outline" | "$isNodeAnimated" | "$nodeAnimationVariant" | "$connections" | "$ports";
1038
+
1039
+ export declare interface StateFormBinding {
1040
+ address: string;
1041
+ type: string;
1042
+ schemaType?: string;
1043
+ portResources?: Record<string, string>;
1044
+ resourceType?: string;
1045
+ fields?: Record<string, FormFieldConfig>;
1046
+ }
1047
+
1048
+ export declare interface StateForms {
1049
+ structured?: boolean;
1050
+ references?: RuntimeReference[];
1051
+ /** Controlled resource data. Replace immutably to update forms, summaries and view references. */
1052
+ state: SqueedJson;
1053
+ bindings: Record<string, StateFormBinding>;
1054
+ renderForm?: (nodeAddress: string) => ReactNode | undefined;
1055
+ /** Receives user form edits after dependent edits. External state replacements do not echo here. */
1056
+ onStateChange?: (state: SqueedJson, change: FormChange) => void;
1057
+ /** Compatibility alias; onStateChange takes precedence when both are supplied. */
1058
+ onChange?: (state: SqueedJson, change: FormChange) => void;
1059
+ }
1060
+
1061
+ declare interface StructuredForms {
1062
+ sourceSchema: FormSchema;
1063
+ sourceBindings: Record<string, StateFormBinding>;
1064
+ nodes: FlowDiagramNode[];
1065
+ edges: FlowDiagramEdge[];
1066
+ schema: FormSchema;
1067
+ bindings: Record<string, StateFormBinding>;
1068
+ slots: Map<string, StructuredSlot>;
1069
+ containers: Map<string, StructuredNode>;
1070
+ }
1071
+
1072
+ declare interface StructuredNode {
1073
+ address: string;
1074
+ type: ContractType;
1075
+ declared: ContractType;
1076
+ scalar: boolean;
1077
+ }
1078
+
1079
+ declare interface StructuredSlot {
1080
+ address: string;
1081
+ owner: string;
1082
+ field: string;
1083
+ type: ContractType;
1084
+ label: string;
1085
+ nodeId: string;
1086
+ present: boolean;
1087
+ }
1088
+
1089
+ export declare function SvgExportButton(): JSX_2.Element;
1090
+
1091
+ export declare function Swatches({ colors, value, label, onPick, onReset, includeTransparent, }: {
1092
+ colors: string[];
1093
+ value?: string;
1094
+ label: string;
1095
+ onPick: (c: string) => void;
1096
+ onReset?: () => void;
1097
+ includeTransparent?: boolean;
1098
+ }): JSX_2.Element;
1099
+
1100
+ export declare const TEXT_PALETTE: string[];
1101
+
1102
+ export declare const ToolbarCloseButton: ForwardRefExoticComponent<Omit<Omit<IconButtonProps & RefAttributes<HTMLButtonElement>, "children">, "ref"> & RefAttributes<HTMLButtonElement>>;
1103
+
1104
+ export declare function ToolbarCommitInput({ value, placeholder, ariaLabel, width, type, min, onCommit, }: {
1105
+ value: string;
1106
+ placeholder: string;
1107
+ ariaLabel: string;
1108
+ width?: string;
1109
+ type?: "text" | "number";
1110
+ min?: number;
1111
+ onCommit: (v: string) => void;
1112
+ }): JSX_2.Element;
1113
+
1114
+ export declare function ToolbarDivider(): JSX_2.Element;
1115
+
1116
+ export declare const ToolbarIconButton: ForwardRefExoticComponent<Omit<IconButtonProps & RefAttributes<HTMLButtonElement> & {
1117
+ icon: React.ReactElement;
1118
+ }, "ref"> & RefAttributes<HTMLButtonElement>>;
1119
+
1120
+ export declare const ToolbarRangeInput: StyledComponent< {
1121
+ theme?: Theme;
1122
+ as?: React.ElementType;
1123
+ }, DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {}>;
1124
+
1125
+ export declare function ToolbarScrollContainer({ children, background, border, }: {
1126
+ children: ReactNode;
1127
+ background: string;
1128
+ border: string;
1129
+ }): JSX_2.Element;
1130
+
1131
+ export declare function ToolbarSelect({ children, value, onValueChange, disabled, style, title, icon, popupContent, labelCase, "aria-label": label, }: {
1132
+ children: ReactNode;
1133
+ value: string;
1134
+ onValueChange: (value: string) => void;
1135
+ disabled?: boolean;
1136
+ style?: CSSProperties;
1137
+ title?: string;
1138
+ icon?: ReactNode;
1139
+ popupContent?: ReactNode;
1140
+ labelCase?: "title" | "preserve";
1141
+ "aria-label": string;
1142
+ }): JSX_2.Element;
1143
+
1144
+ export declare function ToolbarTooltip({ label, children, }: {
1145
+ label: string;
1146
+ children: React.ReactElement;
1147
+ }): JSX_2.Element;
1148
+
1149
+ export declare const TooltipIconButton: ({ icon, label, onClick, color, boxSize, ...props }: {
1150
+ [x: string]: any;
1151
+ icon: any;
1152
+ label: any;
1153
+ onClick: any;
1154
+ color: any;
1155
+ boxSize?: number;
1156
+ }) => JSX_2.Element;
496
1157
 
497
1158
  /** Immutable update of the node at `address` (root address updates the document itself) */
498
1159
  export declare function updateNode(json: SqueedJson, address: string, fn: (node: any) => any): SqueedJson;
@@ -518,6 +1179,24 @@ export declare function useCustomColors(theme?: any): {
518
1179
  greenColor: string;
519
1180
  };
520
1181
 
1182
+ export declare function useFlowData(): {
1183
+ nodeById: Map<string, FlowDiagramNode>;
1184
+ edgeById: Map<string, FlowDiagramEdge>;
1185
+ parentIds: Set<string>;
1186
+ };
1187
+
1188
+ export declare function useFlowDiagramContext(): FlowDiagramContextValue;
1189
+
1190
+ export declare function useNodeViewActions(): {
1191
+ allNodesIconLabel: boolean;
1192
+ setAllNodesIconLabel: (enabled: boolean) => void;
1193
+ getNodeViewMode: (nodeId: string) => NodeViewMode;
1194
+ showNodeProperties: (nodeId: string) => void;
1195
+ restoreNodeView: (nodeId: string) => void;
1196
+ toggleNodeView: (nodeId: string) => void;
1197
+ setNodeViewMode: (nodeId: string, mode: NodeViewMode) => void;
1198
+ };
1199
+
521
1200
  /**
522
1201
  * Hook that stops all event propagation on a DOM element.
523
1202
  * Use this on any interactive element inside a node (inputs, textareas, forms)
@@ -548,4 +1227,14 @@ declare interface ViewportState {
548
1227
  zoom: number;
549
1228
  }
550
1229
 
1230
+ export declare interface WorkflowContract {
1231
+ name: string;
1232
+ nodes: Record<string, ContractProperty>;
1233
+ }
1234
+
1235
+ export declare function WorkflowControls({ showDivider, compact, }?: {
1236
+ showDivider?: boolean;
1237
+ compact?: boolean;
1238
+ }): JSX_2.Element;
1239
+
551
1240
  export { }