@squeed/flow-sdk 2.0.1 → 2.0.3

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