@theclearsky/react-blender-nodes 0.0.3 → 0.0.4

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/README.md CHANGED
@@ -5,53 +5,25 @@ a flexible and customizable node-based graph editor for web applications.
5
5
 
6
6
  ![React Blender Nodes Banner](./docs/screenshots/banner.png)
7
7
 
8
- ## 🎯 Overview
8
+ ## Quick Links
9
+
10
+ - [![Storybook](https://img.shields.io/badge/Storybook-FF4785?style=for-the-badge&logo=storybook&logoColor=white)](https://theclearsky.github.io/react-blender-nodes/?path=/story/components-organisms-fullgraph--playground) -
11
+ Interactive examples and component playground
12
+ - [![NPM](https://img.shields.io/badge/NPM-%23CB3837.svg?style=for-the-badge&logo=npm&logoColor=white)](https://www.npmjs.com/package/@theclearsky/react-blender-nodes) -
13
+ Install and use in your project
14
+ - [![GitHub Issues](https://img.shields.io/badge/GitHub-Issues-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/TheClearSky/react-blender-nodes/issues) -
15
+ Report bugs and issues
16
+ - [![GitHub Discussions](https://img.shields.io/badge/GitHub-Discussions-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/TheClearSky/react-blender-nodes/discussions) -
17
+ Request features and discuss ideas
18
+
19
+ ## Overview
9
20
 
10
21
  React Blender Nodes recreates the iconic Blender node editor experience on the
11
22
  web. Built with modern React patterns and TypeScript, it offers a complete
12
23
  solution for creating interactive node-based interfaces with support for custom
13
24
  nodes, connections, and real-time manipulation.
14
25
 
15
- ## Features
16
-
17
- ### 🎨 Blender-Inspired Interface
18
-
19
- ![Blender Interface](./docs/screenshots/blender-interface.png)
20
-
21
- - Authentic dark theme matching Blender's node editor
22
- - Familiar interactions and visual design
23
- - Smooth animations and transitions
24
-
25
- ### 🔧 Customizable Nodes
26
-
27
- ![Customizable Nodes](./docs/screenshots/customizable-nodes.png)
28
-
29
- - Dynamic inputs and outputs with custom shapes
30
- - Collapsible input panels for complex configurations
31
- - Interactive input components (text, number sliders)
32
- - Custom handle shapes (circle, square, diamond, star, etc.)
33
-
34
- ### 🎮 Interactive Graph Editor
35
-
36
- ![Interactive Graph](./docs/screenshots/interactive-graph.png)
37
-
38
- - Pan, zoom, and select nodes with intuitive controls
39
- - Drag and drop node connections
40
- - Context menu for adding new nodes
41
- - Real-time node manipulation
42
-
43
- ### 🎯 Advanced Features
44
-
45
- ![Advanced Features](./docs/screenshots/advanced-features.png)
46
-
47
- - **Handle Shapes**: 13+ custom handle shapes including geometric and artistic
48
- designs
49
- - **Input Components**: Built-in text and number inputs with validation
50
- - **Panel System**: Collapsible panels for organizing complex node inputs
51
- - **State Management**: Integrated reducer for managing graph state
52
- - **TypeScript Support**: Full type safety with comprehensive definitions
53
-
54
- ## 🚀 Quick Start
26
+ ## Quick Start
55
27
 
56
28
  ### Installation
57
29
 
@@ -122,7 +94,7 @@ function MyNodeEditor() {
122
94
  }
123
95
  ```
124
96
 
125
- ### 🔒 Type Safety with Auto-Infer Helpers
97
+ ### Type Safety with Auto-Infer Helpers
126
98
 
127
99
  The auto-infer helper functions are **essential** for type safety in React
128
100
  Blender Nodes. They ensure TypeScript can properly validate type references
@@ -164,7 +136,46 @@ const dataTypes = {
164
136
  };
165
137
  ```
166
138
 
167
- ## 📖 Usage Examples
139
+ ## Features
140
+
141
+ ### 🎨 Blender-Inspired Interface
142
+
143
+ ![Blender Interface](./docs/screenshots/blender-interface.png)
144
+
145
+ - Authentic dark theme matching Blender's node editor
146
+ - Familiar interactions and visual design
147
+ - Smooth animations and transitions
148
+
149
+ ### 🔧 Customizable Nodes
150
+
151
+ ![Customizable Nodes](./docs/screenshots/customizable-nodes.png)
152
+
153
+ - Dynamic inputs and outputs with custom shapes
154
+ - Collapsible input panels for complex configurations
155
+ - Interactive input components (text, number sliders)
156
+ - Custom handle shapes (circle, square, diamond, star, etc.)
157
+
158
+ ### 🎮 Interactive Graph Editor
159
+
160
+ ![Interactive Graph](./docs/screenshots/interactive-graph.png)
161
+
162
+ - Pan, zoom, and select nodes with intuitive controls
163
+ - Drag and drop node connections
164
+ - Context menu for adding new nodes
165
+ - Real-time node manipulation
166
+
167
+ ### 🎯 Advanced Features
168
+
169
+ ![Advanced Features](./docs/screenshots/advanced-features.png)
170
+
171
+ - **Handle Shapes**: 13+ custom handle shapes including geometric and artistic
172
+ designs
173
+ - **Input Components**: Built-in text and number inputs with validation
174
+ - **Panel System**: Collapsible panels for organizing complex node inputs
175
+ - **State Management**: Integrated reducer for managing graph state
176
+ - **TypeScript Support**: Full type safety with comprehensive definitions
177
+
178
+ ## Usage Examples
168
179
 
169
180
  ### Custom Node with Panels
170
181
 
package/dist/index.d.ts CHANGED
@@ -44,12 +44,21 @@ export declare type Action<DataTypeUniqueId extends string = string, NodeTypeUni
44
44
  /** Position where to place the node */
45
45
  position: XYPosition;
46
46
  };
47
+ } | {
48
+ /** Add a new node to the graph and select it */
49
+ type: typeof actionTypesMap.ADD_NODE_AND_SELECT;
50
+ payload: {
51
+ /** Type of node to add */
52
+ type: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['nodeIdToNodeType'][string];
53
+ /** Position where to place the node */
54
+ position: XYPosition;
55
+ };
47
56
  } | {
48
57
  /** Update nodes based on ReactFlow changes */
49
58
  type: typeof actionTypesMap.UPDATE_NODE_BY_REACT_FLOW;
50
59
  payload: {
51
60
  /** Array of node changes from ReactFlow */
52
- changes: NodeChanges;
61
+ changes: NodeChanges<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>;
53
62
  };
54
63
  } | {
55
64
  /** Update edges based on ReactFlow changes */
@@ -81,12 +90,49 @@ export declare type Action<DataTypeUniqueId extends string = string, NodeTypeUni
81
90
  /** Map of action types for type-safe action dispatching */
82
91
  export declare const actionTypesMap: {
83
92
  readonly ADD_NODE: "ADD_NODE";
93
+ readonly ADD_NODE_AND_SELECT: "ADD_NODE_AND_SELECT";
84
94
  readonly UPDATE_NODE_BY_REACT_FLOW: "UPDATE_NODE_BY_REACT_FLOW";
85
95
  readonly UPDATE_EDGES_BY_REACT_FLOW: "UPDATE_EDGES_BY_REACT_FLOW";
86
96
  readonly ADD_EDGE_BY_REACT_FLOW: "ADD_EDGE_BY_REACT_FLOW";
87
97
  readonly UPDATE_INPUT_VALUE: "UPDATE_INPUT_VALUE";
88
98
  };
89
99
 
100
+ /**
101
+ * Adds a new edge between two handles with type checking and inference
102
+ *
103
+ * This function validates that a connection is allowed between two handles based on
104
+ * their data types, handles type inference for 'inferFromConnection' types, and
105
+ * validates Zod schema compatibility for complex types.
106
+ *
107
+ * @template DataTypeUniqueId - Unique identifier type for data types
108
+ * @template NodeTypeUniqueId - Unique identifier type for node types
109
+ * @template UnderlyingType - Supported underlying data types
110
+ * @template ComplexSchemaType - Zod schema type for complex data types
111
+ * @param nodes - Array of nodes in the graph
112
+ * @param edges - Array of edges in the graph
113
+ * @param newEdgeSourceNodeId - ID of the source node
114
+ * @param newEdgeSourceHandleId - ID of the source handle
115
+ * @param newEdgeTargetNodeId - ID of the target node
116
+ * @param newEdgeTargetHandleId - ID of the target handle
117
+ * @param state - The current graph state
118
+ * @param allowedConversionsBetweenDataTypes - Optional mapping of allowed conversions
119
+ * @param enableTypeInference - Whether to enable type inference
120
+ * @param enableComplexTypeChecking - Whether to enable complex type checking
121
+ * @returns Object containing updated nodes, edges, and validation result
122
+ */
123
+ export declare function addEdgeWithTypeChecking<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(newEdgeSourceNodeId: string, newEdgeSourceHandleId: string, newEdgeTargetNodeId: string, newEdgeTargetHandleId: string, state: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>): {
124
+ updatedNodes: Nodes<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>;
125
+ updatedEdges: Edges;
126
+ validation: ConnectionValidationResult;
127
+ };
128
+
129
+ /**
130
+ * Mapping of allowed conversions between data types
131
+ *
132
+ * @template DataTypeUniqueId - Unique identifier type for data types
133
+ */
134
+ declare type AllowedConversionsBetweenDataTypes<DataTypeUniqueId extends string = string> = Partial<Record<DataTypeUniqueId, Partial<Record<DataTypeUniqueId, boolean>>>>;
135
+
90
136
  /**
91
137
  * Represents a rectangular bounding box
92
138
  */
@@ -227,7 +273,7 @@ export declare function cn(...inputs: ClassValue[]): string;
227
273
  * />
228
274
  * ```
229
275
  */
230
- export declare const ConfigurableEdge: ForwardRefExoticComponent<Pick<ConfigurableEdgeState, "data" | "source" | "style" | "id" | "selectable" | "deletable" | "selected" | "target" | "animated"> & EdgePosition & EdgeLabelOptions & {
276
+ export declare const ConfigurableEdge: ForwardRefExoticComponent<Pick<ConfigurableEdgeState, "data" | "source" | "style" | "id" | "target" | "selectable" | "deletable" | "selected" | "animated"> & EdgePosition & EdgeLabelOptions & {
231
277
  sourceHandleId?: string | null;
232
278
  targetHandleId?: string | null;
233
279
  markerStart?: string;
@@ -322,9 +368,9 @@ name?: string;
322
368
  /** Background color of the node header */
323
369
  headerColor?: string;
324
370
  /** Array of inputs and input panels */
325
- inputs?: (ConfigurableNodeInput | ConfigurableNodeInputPanel)[];
371
+ inputs?: (ConfigurableNodeInput<"string" | "number" | "complex" | "noEquivalent" | "inferFromConnection", never, string> | ConfigurableNodeInputPanel<"string" | "number" | "complex" | "noEquivalent" | "inferFromConnection", never, string>)[] | undefined;
326
372
  /** Array of output sockets */
327
- outputs?: ConfigurableNodeOutput[];
373
+ outputs?: ConfigurableNodeOutput<"string" | "number" | "complex" | "noEquivalent" | "inferFromConnection", never, string>[] | undefined;
328
374
  /** Whether the node is currently inside a ReactFlow context */
329
375
  isCurrentlyInsideReactFlow?: boolean;
330
376
  /** Props for the node resizer component */
@@ -337,7 +383,7 @@ nodeResizerProps?: NodeResizerWithMoreControlsProps;
337
383
  * Defines an input socket on a node with optional interactive input component.
338
384
  * Supports both string and number types with type-specific onChange handlers.
339
385
  */
340
- export declare type ConfigurableNodeInput = {
386
+ export declare type ConfigurableNodeInput<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = {
341
387
  /** Unique identifier for the input */
342
388
  id: string;
343
389
  /** Display name for the input */
@@ -348,6 +394,16 @@ export declare type ConfigurableNodeInput = {
348
394
  handleShape?: HandleShape;
349
395
  /** Whether to show an interactive input component when not connected */
350
396
  allowInput?: boolean;
397
+ /** Data type of the input, used by full graph */
398
+ dataType?: {
399
+ dataTypeObject: DataType<UnderlyingType, ComplexSchemaType>;
400
+ dataTypeUniqueId: DataTypeUniqueId;
401
+ };
402
+ /** Inferred data type of the input (only when type inference is enabled and datatype is inferredFromConnection and connected), used by full graph */
403
+ inferredDataType?: {
404
+ dataTypeObject: DataType<UnderlyingType, ComplexSchemaType>;
405
+ dataTypeUniqueId: DataTypeUniqueId;
406
+ } | null;
351
407
  } & ({
352
408
  /** String input type */
353
409
  type: 'string';
@@ -369,13 +425,13 @@ export declare type ConfigurableNodeInput = {
369
425
  *
370
426
  * Groups multiple inputs together in a collapsible panel for better organization.
371
427
  */
372
- export declare type ConfigurableNodeInputPanel = {
428
+ export declare type ConfigurableNodeInputPanel<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = {
373
429
  /** Unique identifier for the panel */
374
430
  id: string;
375
431
  /** Display name for the panel */
376
432
  name: string;
377
433
  /** Array of inputs contained in this panel */
378
- inputs: ConfigurableNodeInput[];
434
+ inputs: ConfigurableNodeInput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>[];
379
435
  };
380
436
 
381
437
  /**
@@ -383,7 +439,7 @@ export declare type ConfigurableNodeInputPanel = {
383
439
  *
384
440
  * Defines an output socket on a node that can be connected to inputs.
385
441
  */
386
- export declare type ConfigurableNodeOutput = {
442
+ export declare type ConfigurableNodeOutput<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = {
387
443
  /** Unique identifier for the output */
388
444
  id: string;
389
445
  /** Display name for the output */
@@ -392,6 +448,16 @@ export declare type ConfigurableNodeOutput = {
392
448
  handleColor?: string;
393
449
  /** Shape of the output handle (circle, square, diamond, etc.) */
394
450
  handleShape?: HandleShape;
451
+ /** Data type of the output, used by full graph */
452
+ dataType?: {
453
+ dataTypeObject: DataType<UnderlyingType, ComplexSchemaType>;
454
+ dataTypeUniqueId: DataTypeUniqueId;
455
+ };
456
+ /** Inferred data type of the output (only when type inference is enabled and datatype is inferredFromConnection and connected), used by full graph */
457
+ inferredDataType?: {
458
+ dataTypeObject: DataType<UnderlyingType, ComplexSchemaType>;
459
+ dataTypeUniqueId: DataTypeUniqueId;
460
+ } | null;
395
461
  } & ({
396
462
  /** String output type */
397
463
  type: 'string';
@@ -406,15 +472,15 @@ export declare type ConfigurableNodeOutput = {
406
472
  * Defines the complete configuration for a customizable node with inputs, outputs,
407
473
  * and optional panels. Supports both standalone usage and ReactFlow integration.
408
474
  */
409
- export declare type ConfigurableNodeProps = {
475
+ export declare type ConfigurableNodeProps<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = {
410
476
  /** Display name of the node */
411
477
  name?: string;
412
478
  /** Background color of the node header */
413
479
  headerColor?: string;
414
480
  /** Array of inputs and input panels */
415
- inputs?: (ConfigurableNodeInput | ConfigurableNodeInputPanel)[];
481
+ inputs?: (ConfigurableNodeInput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId> | ConfigurableNodeInputPanel<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>)[];
416
482
  /** Array of output sockets */
417
- outputs?: ConfigurableNodeOutput[];
483
+ outputs?: ConfigurableNodeOutput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>[];
418
484
  /** Whether the node is currently inside a ReactFlow context */
419
485
  isCurrentlyInsideReactFlow?: boolean;
420
486
  /** Props for the node resizer component */
@@ -464,17 +530,23 @@ export declare type ConfigurableNodeProps = {
464
530
  * />
465
531
  * ```
466
532
  */
467
- export declare const ConfigurableNodeReactFlowWrapper: ForwardRefExoticComponent<Pick<ConfigurableNodeState, "data" | "id" | "width" | "height" | "sourcePosition" | "targetPosition" | "dragHandle" | "parentId"> & Required<Pick<ConfigurableNodeState, "type" | "draggable" | "dragging" | "zIndex" | "selectable" | "deletable" | "selected">> & {
468
- isConnectable: boolean;
469
- positionAbsoluteX: number;
470
- positionAbsoluteY: number;
471
- } & RefAttributes<HTMLDivElement>>;
533
+ export declare const ConfigurableNodeReactFlowWrapper: ForwardRefExoticComponent<Omit<ConfigurableNodeReactFlowWrapperProps<"string" | "number" | "complex" | "noEquivalent" | "inferFromConnection", never, string>, "position"> & RefAttributes<HTMLDivElement>>;
472
534
 
473
535
  /** Props for the ConfigurableNodeReactFlowWrapper component */
474
- export declare type ConfigurableNodeReactFlowWrapperProps = NodeProps<ConfigurableNodeState>;
536
+ export declare type ConfigurableNodeReactFlowWrapperProps<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = NodeProps<ConfigurableNodeState<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>> & {
537
+ position: XYPosition;
538
+ };
475
539
 
476
540
  /** State type for configurable nodes in ReactFlow */
477
- export declare type ConfigurableNodeState = Node_2<Omit<ConfigurableNodeProps, 'isCurrentlyInsideReactFlow'>, 'configurableNode'>;
541
+ export declare type ConfigurableNodeState<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = Node_2<Omit<ConfigurableNodeProps<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>, 'isCurrentlyInsideReactFlow'>, 'configurableNode'>;
542
+
543
+ /**
544
+ * Type for connection validation result
545
+ */
546
+ declare type ConnectionValidationResult = {
547
+ isValid: boolean;
548
+ reason?: string;
549
+ };
478
550
 
479
551
  /**
480
552
  * Constructs a ConfigurableNodeInput or ConfigurableNodeOutput from a type definition
@@ -514,7 +586,7 @@ export declare type ConfigurableNodeState = Node_2<Omit<ConfigurableNodeProps, '
514
586
  * );
515
587
  * ```
516
588
  */
517
- export declare function constructInputOrOutputOfType<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(typeOfDataType: TypeOfInput<DataTypeUniqueId> | TypeOfNode<DataTypeUniqueId>['outputs'][number], dataTypes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['dataTypes']): ConfigurableNodeInput | ConfigurableNodeOutput;
589
+ export declare function constructInputOrOutputOfType<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(typeOfDataTypeInNode: TypeOfInput<DataTypeUniqueId> | TypeOfNode<DataTypeUniqueId>['outputs'][number], allDataTypes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['dataTypes']): ConfigurableNodeInput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId> | ConfigurableNodeOutput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>;
518
590
 
519
591
  /**
520
592
  * Constructs a ConfigurableNodeInputPanel from a type definition
@@ -560,13 +632,13 @@ export declare function constructInputOrOutputOfType<DataTypeUniqueId extends st
560
632
  * );
561
633
  * ```
562
634
  */
563
- export declare function constructInputPanelOfType<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(typeOfPanel: {
635
+ export declare function constructInputPanelOfType<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(typeOfPanelInNode: {
564
636
  name: string;
565
637
  inputs: {
566
638
  name: string;
567
639
  dataType: DataTypeUniqueId;
568
640
  }[];
569
- }, dataTypes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['dataTypes']): ConfigurableNodeInputPanel;
641
+ }, allDataTypes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['dataTypes']): ConfigurableNodeInputPanel<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>;
570
642
 
571
643
  /**
572
644
  * Constructs a complete node from a node type definition
@@ -625,7 +697,20 @@ export declare function constructInputPanelOfType<DataTypeUniqueId extends strin
625
697
  * );
626
698
  * ```
627
699
  */
628
- export declare function constructNodeOfType<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(dataTypes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['dataTypes'], nodeType: NodeTypeUniqueId, typeOfNodes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['typeOfNodes'], nodeId: string, position: XYPosition): State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['nodes'][number];
700
+ export declare function constructNodeOfType<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(allDataTypes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['dataTypes'], nodeType: NodeTypeUniqueId, typeOfNodes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['typeOfNodes'], nodeId: string, position: XYPosition): State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['nodes'][number];
701
+
702
+ /**
703
+ * Constructs the type of a handle from indices
704
+ *
705
+ * This function constructs the type of a handle from indices, handling both regular inputs and inputs within panels.
706
+ *
707
+ * @param allDataTypes - The all data types
708
+ * @param nodeType - The node type
709
+ * @param typeOfNodes - The type of nodes
710
+ * @param indices - The indices of the handle
711
+ * @returns The type of the handle
712
+ */
713
+ export declare function constructTypeOfHandleFromIndices<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(allDataTypes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['dataTypes'], nodeType: NodeTypeUniqueId, typeOfNodes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['typeOfNodes'], indices: HandleIndices | undefined): ConfigurableNodeInput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId> | ConfigurableNodeOutput<UnderlyingType, ComplexSchemaType, DataTypeUniqueId> | undefined;
629
714
 
630
715
  /**
631
716
  * A context-aware handle component for node inputs and outputs
@@ -890,9 +975,9 @@ export declare type Coordinate = {
890
975
  * @param contextMenuPosition - The position where the context menu was opened
891
976
  * @returns ContextMenuItem array for the context menu
892
977
  */
893
- export declare function createNodeContextMenu<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends 'string' | 'number' | 'complex' = 'string' | 'number' | 'complex', ComplexSchemaType extends UnderlyingType extends 'complex' ? any : never = never>({ typeOfNodes, dispatch, setContextMenu, contextMenuPosition, }: CreateNodeContextMenuProps<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>): ContextMenuItem[];
978
+ export declare function createNodeContextMenu<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>({ typeOfNodes, dispatch, setContextMenu, contextMenuPosition, }: CreateNodeContextMenuProps<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>): ContextMenuItem[];
894
979
 
895
- export declare type CreateNodeContextMenuProps<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends 'string' | 'number' | 'complex' = 'string' | 'number' | 'complex', ComplexSchemaType extends UnderlyingType extends 'complex' ? any : never = never> = {
980
+ export declare type CreateNodeContextMenuProps<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? any : never = never> = {
896
981
  typeOfNodes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['typeOfNodes'];
897
982
  dispatch: ActionDispatch<[
898
983
  action: Action<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>
@@ -919,6 +1004,10 @@ export declare type DataType<UnderlyingType extends SupportedUnderlyingTypes = S
919
1004
  complexSchema: ComplexSchemaType;
920
1005
  /** Color used for visual representation */
921
1006
  color: string;
1007
+ /** Shape of the handle */
1008
+ shape?: HandleShape;
1009
+ /** Whether this input allows direct user input */
1010
+ allowInput?: boolean;
922
1011
  } : {
923
1012
  /** Display name of the data type */
924
1013
  name: string;
@@ -928,6 +1017,10 @@ export declare type DataType<UnderlyingType extends SupportedUnderlyingTypes = S
928
1017
  complexSchema?: undefined;
929
1018
  /** Color used for visual representation */
930
1019
  color: string;
1020
+ /** Shape of the handle */
1021
+ shape?: HandleShape;
1022
+ /** Whether this input allows direct user input */
1023
+ allowInput?: boolean;
931
1024
  };
932
1025
 
933
1026
  /**
@@ -1053,6 +1146,16 @@ export declare type FullGraphProps<DataTypeUniqueId extends string = string, Nod
1053
1146
  ]>;
1054
1147
  };
1055
1148
 
1149
+ declare type HandleIndices = {
1150
+ type: 'input';
1151
+ index1: number;
1152
+ index2: number | undefined;
1153
+ } | {
1154
+ type: 'output';
1155
+ index1: number;
1156
+ index2: undefined;
1157
+ };
1158
+
1056
1159
  /** Type representing all available handle shapes */
1057
1160
  export declare type HandleShape = (typeof handleShapesMap)[keyof typeof handleShapesMap];
1058
1161
 
@@ -1192,6 +1295,16 @@ export declare function isNumberInRange(number: number, min: number, max: number
1192
1295
  */
1193
1296
  export declare function isSupportedUnderlyingType(type: string): type is SupportedUnderlyingTypes;
1194
1297
 
1298
+ /**
1299
+ * Type guard to check if a string is a valid DataTypeUniqueId
1300
+ */
1301
+ export declare function isValidDataTypeId<DataTypeUniqueId extends string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(id: string, dataTypes: Record<DataTypeUniqueId, DataType<UnderlyingType, ComplexSchemaType>>): id is DataTypeUniqueId;
1302
+
1303
+ /**
1304
+ * Type guard to check if a string is a valid NodeTypeUniqueId
1305
+ */
1306
+ export declare function isValidNodeTypeUniqueId<NodeTypeUniqueId extends string>(id: string, nodeIdToNodeType: Record<string, NodeTypeUniqueId>): id is NodeTypeUniqueId;
1307
+
1195
1308
  /**
1196
1309
  * Main reducer function for managing graph state
1197
1310
  *
@@ -1269,6 +1382,36 @@ export declare function isSupportedUnderlyingType(type: string): type is Support
1269
1382
  */
1270
1383
  export declare function mainReducer<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(oldState: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>, action: Action<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>): State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>;
1271
1384
 
1385
+ /**
1386
+ * Helper function to create a mapping of allowed conversions between data types with automatic type inference
1387
+ *
1388
+ * This function is essential for type safety when creating a mapping of allowed conversions between data types.
1389
+ * It ensures that TypeScript can properly infer and validate the types throughout your graph system,
1390
+ * preventing runtime errors and providing better IDE support.
1391
+ *
1392
+ * @template DataTypeUniqueId - Unique identifier type for data types
1393
+ * @param input - The mapping of allowed conversions between data types
1394
+ * @returns The mapping with proper typing
1395
+ *
1396
+ * @example
1397
+ * ```tsx
1398
+ * // ✅ Type-safe - TypeScript will validate node type references
1399
+ * const allowedConversionsBetweenDataTypes = makeAllowedConversionsBetweenDataTypesWithAutoInfer({
1400
+ * 'inputDataType': {
1401
+ * 'outputDataType': true,
1402
+ * },
1403
+ * });
1404
+ *
1405
+ * // ❌ Without auto-infer - TypeScript can't validate node type references
1406
+ * const allowedConversionsBetweenDataTypes = {
1407
+ * 'inputDataType': {
1408
+ * 'outputDataType': true,
1409
+ * },
1410
+ * };
1411
+ * ```
1412
+ */
1413
+ export declare function makeAllowedConversionsBetweenDataTypesWithAutoInfer<DataTypeUniqueId extends string = string>(input: AllowedConversionsBetweenDataTypes<DataTypeUniqueId>): Partial<Record<DataTypeUniqueId, Partial<Record<DataTypeUniqueId, boolean>>>>;
1414
+
1272
1415
  /**
1273
1416
  * Helper function to create a data type with automatic type inference
1274
1417
  *
@@ -1412,7 +1555,7 @@ export declare function makeTypeOfNodeWithAutoInfer<DataTypeUniqueId extends str
1412
1555
  /**
1413
1556
  * Array of node changes for ReactFlow
1414
1557
  */
1415
- export declare type NodeChanges = NodeChange<ConfigurableNodeState>[];
1558
+ export declare type NodeChanges<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = NodeChange<Optional<ConfigurableNodeReactFlowWrapperProps<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>, NodeOptionalKeys>>[];
1416
1559
 
1417
1560
  /**
1418
1561
  * Mapping from node IDs to their node types
@@ -1421,6 +1564,8 @@ export declare type NodeChanges = NodeChange<ConfigurableNodeState>[];
1421
1564
  */
1422
1565
  export declare type NodeIdToNodeType<NodeTypeUniqueId extends string = string> = Record<string, NodeTypeUniqueId>;
1423
1566
 
1567
+ declare type NodeOptionalKeys = 'draggable' | 'zIndex' | 'selectable' | 'deletable' | 'dragging' | 'selected' | 'isConnectable' | 'positionAbsoluteX' | 'positionAbsoluteY';
1568
+
1424
1569
  /**
1425
1570
  * Enhanced node resizer component with customizable controls
1426
1571
  *
@@ -1489,7 +1634,9 @@ export declare type NodeResizerWithMoreControlsProps = NodeResizerProps & {
1489
1634
  /**
1490
1635
  * Array of configurable nodes in the graph
1491
1636
  */
1492
- export declare type Nodes = ConfigurableNodeState[];
1637
+ export declare type Nodes<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never, DataTypeUniqueId extends string = string> = Optional<ConfigurableNodeReactFlowWrapperProps<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>, NodeOptionalKeys>[];
1638
+
1639
+ declare type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
1493
1640
 
1494
1641
  /**
1495
1642
  * ReactFlow-aware input component that automatically updates node data
@@ -1511,6 +1658,35 @@ export declare type ReactFlowAwareInputProps = {
1511
1658
  input: ConfigurableNodeInput;
1512
1659
  };
1513
1660
 
1661
+ /**
1662
+ * Removes an edge between two handles with type checking and inference
1663
+ *
1664
+ * This function validates that a connection is removed between two handles based on
1665
+ * their data types, handles type inference for 'inferFromConnection' types, and
1666
+ * validates Zod schema compatibility for complex types.
1667
+ *
1668
+ * @template DataTypeUniqueId - Unique identifier type for data types
1669
+ * @template NodeTypeUniqueId - Unique identifier type for node types
1670
+ * @template UnderlyingType - Supported underlying data types
1671
+ * @template ComplexSchemaType - Zod schema type for complex data types
1672
+ * @param nodes - Array of nodes in the graph
1673
+ * @param edges - Array of edges in the graph
1674
+ * @param removedEdgeSourceNodeId - ID of the source node
1675
+ * @param removedEdgeSourceHandleId - ID of the source handle
1676
+ * @param removedEdgeTargetNodeId - ID of the target node
1677
+ * @param removedEdgeTargetHandleId - ID of the target handle
1678
+ * @param state - The current graph state
1679
+ * @param allowedConversionsBetweenDataTypes - Optional mapping of allowed conversions
1680
+ * @param enableTypeInference - Whether to enable type inference
1681
+ * @param enableComplexTypeChecking - Whether to enable complex type checking
1682
+ * @returns Object containing updated nodes, edges, and validation result
1683
+ */
1684
+ export declare function removeEdgeWithTypeChecking<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(removedEdge: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['edges'][number], state: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>, removedEdgeChange: EdgeChange<ConfigurableEdgeState>): {
1685
+ updatedNodes: Nodes<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>;
1686
+ updatedEdges: Edges;
1687
+ validation: ConnectionValidationResult;
1688
+ };
1689
+
1514
1690
  /**
1515
1691
  * Sanitizes a number to be shown as a text, removing the trailing zeros after the decimal point if the number is an integer
1516
1692
  * @param value - The number to sanitize
@@ -1604,11 +1780,17 @@ export declare type State<DataTypeUniqueId extends string = string, NodeTypeUniq
1604
1780
  /** Map of node type definitions */
1605
1781
  typeOfNodes: Record<NodeTypeUniqueId, TypeOfNode<DataTypeUniqueId>>;
1606
1782
  /** Array of nodes in the graph */
1607
- nodes: Nodes;
1783
+ nodes: Nodes<UnderlyingType, ComplexSchemaType, DataTypeUniqueId>;
1608
1784
  /** Mapping from node IDs to their types */
1609
1785
  nodeIdToNodeType: NodeIdToNodeType<NodeTypeUniqueId>;
1610
1786
  /** Array of edges in the graph */
1611
1787
  edges: Edges;
1788
+ /** Optional mapping of allowed conversions between data types */
1789
+ allowedConversionsBetweenDataTypes?: AllowedConversionsBetweenDataTypes<DataTypeUniqueId>;
1790
+ /** Whether to enable type inference */
1791
+ enableTypeInference?: boolean;
1792
+ /** Whether to enable complex type checking */
1793
+ enableComplexTypeChecking?: boolean;
1612
1794
  };
1613
1795
 
1614
1796
  /**