@theclearsky/react-blender-nodes 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +186 -0
- package/dist/index.d.ts +501 -0
- package/dist/react-blender-nodes.css +1 -0
- package/dist/react-blender-nodes.es.js +11527 -0
- package/dist/react-blender-nodes.es.js.map +1 -0
- package/dist/react-blender-nodes.umd.js +107 -0
- package/dist/react-blender-nodes.umd.js.map +1 -0
- package/package.json +93 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
import { ActionDispatch } from 'react';
|
|
2
|
+
import { ClassProp } from 'class-variance-authority/types';
|
|
3
|
+
import { ClassValue } from 'clsx';
|
|
4
|
+
import { ComponentProps } from 'react';
|
|
5
|
+
import { Connection } from '@xyflow/react';
|
|
6
|
+
import { ControlLinePosition } from '@xyflow/react';
|
|
7
|
+
import { ControlPosition } from '@xyflow/react';
|
|
8
|
+
import { Edge } from '@xyflow/react';
|
|
9
|
+
import { EdgeChange } from '@xyflow/react';
|
|
10
|
+
import { EdgeLabelOptions } from '@xyflow/react';
|
|
11
|
+
import { EdgePosition } from '@xyflow/system';
|
|
12
|
+
import { EdgeProps } from '@xyflow/react';
|
|
13
|
+
import { ForwardRefExoticComponent } from 'react';
|
|
14
|
+
import { HandleType } from '@xyflow/react';
|
|
15
|
+
import { HTMLAttributes } from 'react';
|
|
16
|
+
import { JSX } from 'react/jsx-runtime';
|
|
17
|
+
import { Node as Node_2 } from '@xyflow/react';
|
|
18
|
+
import { NodeChange } from '@xyflow/react';
|
|
19
|
+
import { NodeProps } from '@xyflow/react';
|
|
20
|
+
import { NodeResizerProps } from '@xyflow/react';
|
|
21
|
+
import { Position } from '@xyflow/react';
|
|
22
|
+
import { ReactNode } from 'react';
|
|
23
|
+
import { RefAttributes } from 'react';
|
|
24
|
+
import { RefObject } from 'react';
|
|
25
|
+
import { ResizeControlDirection } from '@xyflow/system';
|
|
26
|
+
import { VariantProps } from 'class-variance-authority';
|
|
27
|
+
import { XYPosition } from '@xyflow/react';
|
|
28
|
+
import { z } from 'zod';
|
|
29
|
+
|
|
30
|
+
declare type Action<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never> = {
|
|
31
|
+
type: typeof actionTypesMap.ADD_NODE;
|
|
32
|
+
payload: {
|
|
33
|
+
type: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['nodeIdToNodeType'][string];
|
|
34
|
+
position: XYPosition;
|
|
35
|
+
};
|
|
36
|
+
} | {
|
|
37
|
+
type: typeof actionTypesMap.UPDATE_NODE_BY_REACT_FLOW;
|
|
38
|
+
payload: {
|
|
39
|
+
changes: NodeChanges;
|
|
40
|
+
};
|
|
41
|
+
} | {
|
|
42
|
+
type: typeof actionTypesMap.UPDATE_EDGES_BY_REACT_FLOW;
|
|
43
|
+
payload: {
|
|
44
|
+
changes: EdgeChanges;
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
type: typeof actionTypesMap.ADD_EDGE_BY_REACT_FLOW;
|
|
48
|
+
payload: {
|
|
49
|
+
edge: Connection;
|
|
50
|
+
};
|
|
51
|
+
} | {
|
|
52
|
+
type: typeof actionTypesMap.UPDATE_INPUT_VALUE;
|
|
53
|
+
payload: {
|
|
54
|
+
nodeId: string;
|
|
55
|
+
inputId: string;
|
|
56
|
+
value: string | number;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
declare const actionTypesMap: {
|
|
61
|
+
readonly ADD_NODE: "ADD_NODE";
|
|
62
|
+
readonly UPDATE_NODE_BY_REACT_FLOW: "UPDATE_NODE_BY_REACT_FLOW";
|
|
63
|
+
readonly UPDATE_EDGES_BY_REACT_FLOW: "UPDATE_EDGES_BY_REACT_FLOW";
|
|
64
|
+
readonly ADD_EDGE_BY_REACT_FLOW: "ADD_EDGE_BY_REACT_FLOW";
|
|
65
|
+
readonly UPDATE_INPUT_VALUE: "UPDATE_INPUT_VALUE";
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export declare type Box = {
|
|
69
|
+
top: number;
|
|
70
|
+
left: number;
|
|
71
|
+
right: number;
|
|
72
|
+
bottom: number;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export declare const Button: ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & RefAttributes<HTMLButtonElement>>;
|
|
76
|
+
|
|
77
|
+
export declare type ButtonProps = ComponentProps<'button'> & VariantProps<typeof buttonVariants> & {
|
|
78
|
+
asChild?: boolean;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
declare const buttonVariants: (props?: ({
|
|
82
|
+
color?: "dark" | "lightNonPriority" | "lightPriority" | "lightParentGroupBasedHover" | null | undefined;
|
|
83
|
+
applyHoverStyles?: boolean | null | undefined;
|
|
84
|
+
} & ClassProp) | undefined) => string;
|
|
85
|
+
|
|
86
|
+
export declare function cn(...inputs: ClassValue[]): string;
|
|
87
|
+
|
|
88
|
+
export declare const ConfigurableEdge: ForwardRefExoticComponent<Pick<ConfigurableEdgeState, "data" | "source" | "style" | "id" | "target" | "selectable" | "deletable" | "selected" | "animated"> & EdgePosition & EdgeLabelOptions & {
|
|
89
|
+
sourceHandleId?: string | null;
|
|
90
|
+
targetHandleId?: string | null;
|
|
91
|
+
markerStart?: string;
|
|
92
|
+
markerEnd?: string;
|
|
93
|
+
pathOptions?: any;
|
|
94
|
+
interactionWidth?: number;
|
|
95
|
+
} & RefAttributes<HTMLDivElement>>;
|
|
96
|
+
|
|
97
|
+
export declare type ConfigurableEdgeProps = EdgeProps<ConfigurableEdgeState>;
|
|
98
|
+
|
|
99
|
+
export declare type ConfigurableEdgeState = Edge<{}, 'configurableEdge'>;
|
|
100
|
+
|
|
101
|
+
export declare const ConfigurableNode: ForwardRefExoticComponent< {
|
|
102
|
+
name?: string;
|
|
103
|
+
headerColor?: string;
|
|
104
|
+
inputs?: (ConfigurableNodeInput | ConfigurableNodeInputPanel)[];
|
|
105
|
+
outputs?: ConfigurableNodeOutput[];
|
|
106
|
+
isCurrentlyInsideReactFlow?: boolean;
|
|
107
|
+
nodeResizerProps?: NodeResizerWithMoreControlsProps;
|
|
108
|
+
} & HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement>>;
|
|
109
|
+
|
|
110
|
+
export declare type ConfigurableNodeInput = {
|
|
111
|
+
id: string;
|
|
112
|
+
name: string;
|
|
113
|
+
handleColor?: string;
|
|
114
|
+
handleShape?: HandleShape;
|
|
115
|
+
allowInput?: boolean;
|
|
116
|
+
} & ({
|
|
117
|
+
type: 'string';
|
|
118
|
+
value?: string;
|
|
119
|
+
onChange?: (value: string) => void;
|
|
120
|
+
} | {
|
|
121
|
+
type: 'number';
|
|
122
|
+
value?: number;
|
|
123
|
+
onChange?: (value: number) => void;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
export declare type ConfigurableNodeInputPanel = {
|
|
127
|
+
id: string;
|
|
128
|
+
name: string;
|
|
129
|
+
inputs: ConfigurableNodeInput[];
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export declare type ConfigurableNodeOutput = {
|
|
133
|
+
id: string;
|
|
134
|
+
name: string;
|
|
135
|
+
handleColor?: string;
|
|
136
|
+
handleShape?: HandleShape;
|
|
137
|
+
} & ({
|
|
138
|
+
type: 'string';
|
|
139
|
+
} | {
|
|
140
|
+
type: 'number';
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
export declare type ConfigurableNodeProps = {
|
|
144
|
+
name?: string;
|
|
145
|
+
headerColor?: string;
|
|
146
|
+
inputs?: (ConfigurableNodeInput | ConfigurableNodeInputPanel)[];
|
|
147
|
+
outputs?: ConfigurableNodeOutput[];
|
|
148
|
+
isCurrentlyInsideReactFlow?: boolean;
|
|
149
|
+
nodeResizerProps?: NodeResizerWithMoreControlsProps;
|
|
150
|
+
} & HTMLAttributes<HTMLDivElement>;
|
|
151
|
+
|
|
152
|
+
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">> & {
|
|
153
|
+
isConnectable: boolean;
|
|
154
|
+
positionAbsoluteX: number;
|
|
155
|
+
positionAbsoluteY: number;
|
|
156
|
+
} & RefAttributes<HTMLDivElement>>;
|
|
157
|
+
|
|
158
|
+
export declare type ConfigurableNodeReactFlowWrapperProps = NodeProps<ConfigurableNodeState>;
|
|
159
|
+
|
|
160
|
+
export declare type ConfigurableNodeState = Node_2<Omit<ConfigurableNodeProps, 'isCurrentlyInsideReactFlow'>, 'configurableNode'>;
|
|
161
|
+
|
|
162
|
+
export declare const ContextAwareHandle: ForwardRefExoticComponent< {
|
|
163
|
+
type: HandleType;
|
|
164
|
+
position: Position;
|
|
165
|
+
id: string;
|
|
166
|
+
color?: string;
|
|
167
|
+
shape?: HandleShape;
|
|
168
|
+
isCurrentlyInsideReactFlow?: boolean;
|
|
169
|
+
} & HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement>>;
|
|
170
|
+
|
|
171
|
+
export declare type ContextAwareHandleProps = {
|
|
172
|
+
type: HandleType;
|
|
173
|
+
position: Position;
|
|
174
|
+
id: string;
|
|
175
|
+
color?: string;
|
|
176
|
+
shape?: HandleShape;
|
|
177
|
+
isCurrentlyInsideReactFlow?: boolean;
|
|
178
|
+
} & HTMLAttributes<HTMLDivElement>;
|
|
179
|
+
|
|
180
|
+
export declare const ContextAwareInput: ({ input, isCurrentlyInsideReactFlow, }: ContextAwareInputProps) => JSX.Element;
|
|
181
|
+
|
|
182
|
+
export declare type ContextAwareInputProps = {
|
|
183
|
+
input: ConfigurableNodeInput;
|
|
184
|
+
isCurrentlyInsideReactFlow: boolean;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export declare const ContextMenu: ({ subItems, className, onItemClick, }: ContextMenuProps) => JSX.Element;
|
|
188
|
+
|
|
189
|
+
export declare type ContextMenuItem = {
|
|
190
|
+
id: string;
|
|
191
|
+
label: string;
|
|
192
|
+
icon?: ReactNode;
|
|
193
|
+
subItems?: ContextMenuItem[];
|
|
194
|
+
onClick?: () => void;
|
|
195
|
+
shortcut?: string;
|
|
196
|
+
separator?: boolean;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export declare type ContextMenuProps = {
|
|
200
|
+
subItems: ContextMenuItem[];
|
|
201
|
+
className?: string;
|
|
202
|
+
onItemClick?: (item: ContextMenuItem) => void;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Converts a string to a number, handling the case where the string contains a decimal point
|
|
207
|
+
* - Can handle numbers with decimals and negative numbers
|
|
208
|
+
* - Incase of multiple decimal points, the first one is used and the rest are ignored
|
|
209
|
+
* - Incase of multiple negative signs, the first one is used and the rest are ignored
|
|
210
|
+
* @param inputNumberAsString - The string to convert to a number
|
|
211
|
+
* @returns The number
|
|
212
|
+
*/
|
|
213
|
+
export declare function convertStringToNumber(inputNumberAsString: string): number;
|
|
214
|
+
|
|
215
|
+
export declare type Coordinate = {
|
|
216
|
+
x: number;
|
|
217
|
+
y: number;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Creates a context menu tree for adding nodes
|
|
222
|
+
* @param typeOfNodes - The available node types
|
|
223
|
+
* @param dispatch - The dispatch function for state management
|
|
224
|
+
* @param setContextMenu - Function to close the context menu
|
|
225
|
+
* @param contextMenuPosition - The position where the context menu was opened
|
|
226
|
+
* @returns ContextMenuItem array for the context menu
|
|
227
|
+
*/
|
|
228
|
+
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[];
|
|
229
|
+
|
|
230
|
+
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> = {
|
|
231
|
+
typeOfNodes: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>['typeOfNodes'];
|
|
232
|
+
dispatch: ActionDispatch<[
|
|
233
|
+
action: Action<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>
|
|
234
|
+
]>;
|
|
235
|
+
setContextMenu: (menu: {
|
|
236
|
+
isOpen: boolean;
|
|
237
|
+
position: XYPosition;
|
|
238
|
+
}) => void;
|
|
239
|
+
contextMenuPosition: XYPosition;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
declare type DataType<UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never> = UnderlyingType extends 'complex' ? {
|
|
243
|
+
name: string;
|
|
244
|
+
underlyingType: UnderlyingType;
|
|
245
|
+
complexSchema: ComplexSchemaType;
|
|
246
|
+
color: string;
|
|
247
|
+
} : {
|
|
248
|
+
name: string;
|
|
249
|
+
underlyingType: UnderlyingType;
|
|
250
|
+
complexSchema?: undefined;
|
|
251
|
+
color: string;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export declare type EdgeChanges = EdgeChange<ConfigurableEdgeState>[];
|
|
255
|
+
|
|
256
|
+
export declare type Edges = ConfigurableEdgeState[];
|
|
257
|
+
|
|
258
|
+
export declare function FullGraph<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>({ state, dispatch, }: FullGraphProps<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>): JSX.Element;
|
|
259
|
+
|
|
260
|
+
export declare type FullGraphProps<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never> = {
|
|
261
|
+
state: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>;
|
|
262
|
+
dispatch: ActionDispatch<[
|
|
263
|
+
action: Action<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>
|
|
264
|
+
]>;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export declare type HandleShape = (typeof handleShapesMap)[keyof typeof handleShapesMap];
|
|
268
|
+
|
|
269
|
+
export declare const handleShapesMap: {
|
|
270
|
+
readonly circle: "circle";
|
|
271
|
+
readonly square: "square";
|
|
272
|
+
readonly rectangle: "rectangle";
|
|
273
|
+
readonly list: "list";
|
|
274
|
+
readonly grid: "grid";
|
|
275
|
+
readonly diamond: "diamond";
|
|
276
|
+
readonly trapezium: "trapezium";
|
|
277
|
+
readonly hexagon: "hexagon";
|
|
278
|
+
readonly star: "star";
|
|
279
|
+
readonly cross: "cross";
|
|
280
|
+
readonly zigzag: "zigzag";
|
|
281
|
+
readonly sparkle: "sparkle";
|
|
282
|
+
readonly parallelogram: "parallelogram";
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* The Input component
|
|
287
|
+
* - Allows the user to input a string or a number, with the ability to only allow numbers
|
|
288
|
+
* - Temporarily internally manages the value when focused, only sets the value when the user clicks outside the input
|
|
289
|
+
* - Can cancel the change for numbers by clearing the input and clicking outside the input
|
|
290
|
+
*/
|
|
291
|
+
export declare const Input: ForwardRefExoticComponent<InputProps & RefAttributes<HTMLInputElement>>;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Props for the Input component
|
|
295
|
+
*/
|
|
296
|
+
export declare type InputProps = {
|
|
297
|
+
/**
|
|
298
|
+
* The placeholder for the input
|
|
299
|
+
*/
|
|
300
|
+
placeholder?: string;
|
|
301
|
+
/**
|
|
302
|
+
* The class name for the input, overrides the default styles
|
|
303
|
+
*/
|
|
304
|
+
className?: string;
|
|
305
|
+
} & ({
|
|
306
|
+
/**
|
|
307
|
+
* The value of the input, should be a number when allowOnlyNumbers is true
|
|
308
|
+
*/
|
|
309
|
+
value?: number;
|
|
310
|
+
/**
|
|
311
|
+
* Whether the input should only allow numbers, influences the type of the value and the onChange function
|
|
312
|
+
* - If true, the value should be a number and the onChange function should accept a number
|
|
313
|
+
* - If false, the value should be a string and the onChange function should accept a string
|
|
314
|
+
* @default false
|
|
315
|
+
*/
|
|
316
|
+
allowOnlyNumbers: true;
|
|
317
|
+
/**
|
|
318
|
+
* The onChange function, should accept a number when allowOnlyNumbers is true
|
|
319
|
+
*/
|
|
320
|
+
onChange?: (value: number) => void;
|
|
321
|
+
/**
|
|
322
|
+
* The number of decimals to show for the number, only used when allowOnlyNumbers is true
|
|
323
|
+
* @default 5
|
|
324
|
+
*/
|
|
325
|
+
numberOfDecimals?: number;
|
|
326
|
+
} | {
|
|
327
|
+
/**
|
|
328
|
+
* The value of the input, should be a string when allowOnlyNumbers is false
|
|
329
|
+
*/
|
|
330
|
+
value?: string;
|
|
331
|
+
/**
|
|
332
|
+
* Whether the input should only allow numbers, influences the type of the value and the onChange function
|
|
333
|
+
* - If true, the value should be a number and the onChange function should accept a number
|
|
334
|
+
* - If false, the value should be a string and the onChange function should accept a string
|
|
335
|
+
* @default false
|
|
336
|
+
*/
|
|
337
|
+
allowOnlyNumbers?: false;
|
|
338
|
+
/**
|
|
339
|
+
* The onChange function, should accept a string when allowOnlyNumbers is false
|
|
340
|
+
*/
|
|
341
|
+
onChange?: (value: string) => void;
|
|
342
|
+
/**
|
|
343
|
+
* When type is string, this prop is not used and shouldn't be provided
|
|
344
|
+
*/
|
|
345
|
+
numberOfDecimals?: never;
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
export declare function isCoordinateInBox(coordinate: Coordinate, box: Box, xAxisInclusive?: boolean, yAxisInclusive?: boolean): boolean;
|
|
349
|
+
|
|
350
|
+
export declare function isNumberInRange(number: number, min: number, max: number, minInclusive?: boolean, maxInclusive?: boolean): boolean;
|
|
351
|
+
|
|
352
|
+
export declare type NodeChanges = NodeChange<ConfigurableNodeState>[];
|
|
353
|
+
|
|
354
|
+
declare type NodeIdToNodeType<NodeTypeUniqueId extends string = string> = Record<string, NodeTypeUniqueId>;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* The `<NodeResizer />` component can be used to add a resize functionality to your
|
|
358
|
+
* nodes. It renders draggable controls around the node to resize in all directions.
|
|
359
|
+
* @public
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
*```jsx
|
|
363
|
+
*import { memo } from 'react';
|
|
364
|
+
*import { Handle, Position, NodeResizer } from '@xyflow/react';
|
|
365
|
+
*
|
|
366
|
+
*function ResizableNode({ data }) {
|
|
367
|
+
* return (
|
|
368
|
+
* <>
|
|
369
|
+
* <NodeResizer minWidth={100} minHeight={30} />
|
|
370
|
+
* <Handle type="target" position={Position.Left} />
|
|
371
|
+
* <div style={{ padding: 10 }}>{data.label}</div>
|
|
372
|
+
* <Handle type="source" position={Position.Right} />
|
|
373
|
+
* </>
|
|
374
|
+
* );
|
|
375
|
+
*};
|
|
376
|
+
*
|
|
377
|
+
*export default memo(ResizableNode);
|
|
378
|
+
*```
|
|
379
|
+
*/
|
|
380
|
+
export declare function NodeResizerWithMoreControls({ nodeId, isVisible, handleClassName, handleStyle, lineClassName, lineStyle, color, minWidth, minHeight, maxWidth, maxHeight, keepAspectRatio, autoScale, shouldResize, onResizeStart, onResize, onResizeEnd, linePosition, handlePosition, resizeDirection, }: NodeResizerWithMoreControlsProps): JSX.Element | null;
|
|
381
|
+
|
|
382
|
+
export declare type NodeResizerWithMoreControlsProps = NodeResizerProps & {
|
|
383
|
+
linePosition?: ControlLinePosition[];
|
|
384
|
+
handlePosition?: ControlPosition[];
|
|
385
|
+
resizeDirection?: ResizeControlDirection;
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
export declare type Nodes = ConfigurableNodeState[];
|
|
389
|
+
|
|
390
|
+
export declare const ReactFlowAwareInput: ({ input }: ReactFlowAwareInputProps) => JSX.Element;
|
|
391
|
+
|
|
392
|
+
export declare type ReactFlowAwareInputProps = {
|
|
393
|
+
input: ConfigurableNodeInput;
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Sanitizes a number to be shown as a text, removing the trailing zeros after the decimal point if the number is an integer
|
|
398
|
+
* @param value - The number to sanitize
|
|
399
|
+
* @param numberOfDecimals - The number of decimals to show for the number
|
|
400
|
+
* @returns The sanitized number as a string
|
|
401
|
+
*/
|
|
402
|
+
export declare function sanitizeNumberToShowAsText(value: number, numberOfDecimals: number): string;
|
|
403
|
+
|
|
404
|
+
export declare const SliderNumberInput: ForwardRefExoticComponent<SliderNumberInputProps & RefAttributes<HTMLInputElement & HTMLDivElement>>;
|
|
405
|
+
|
|
406
|
+
export declare type SliderNumberInputProps = {
|
|
407
|
+
name?: string;
|
|
408
|
+
value?: number;
|
|
409
|
+
onChange?: (value: number) => void;
|
|
410
|
+
className?: string;
|
|
411
|
+
min?: number;
|
|
412
|
+
max?: number;
|
|
413
|
+
step?: number;
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
declare type State<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never> = {
|
|
417
|
+
dataTypes: Record<DataTypeUniqueId, DataType<UnderlyingType, ComplexSchemaType>>;
|
|
418
|
+
typeOfNodes: Record<NodeTypeUniqueId, TypeOfNode<DataTypeUniqueId>>;
|
|
419
|
+
nodes: Nodes;
|
|
420
|
+
nodeIdToNodeType: NodeIdToNodeType<NodeTypeUniqueId>;
|
|
421
|
+
edges: Edges;
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
declare type SupportedUnderlyingTypes = (typeof supportedUnderlyingTypes)[number];
|
|
425
|
+
|
|
426
|
+
declare const supportedUnderlyingTypes: readonly ["string", "number", "complex", "noEquivalent", "inferFromConnection"];
|
|
427
|
+
|
|
428
|
+
declare type TypeOfInput<DataTypeUniqueId extends string = string> = {
|
|
429
|
+
name: string;
|
|
430
|
+
dataType: DataTypeUniqueId;
|
|
431
|
+
allowInput?: boolean;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
declare type TypeOfInputPanel<DataTypeUniqueId extends string = string> = {
|
|
435
|
+
name: string;
|
|
436
|
+
inputs: TypeOfInput<DataTypeUniqueId>[];
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
declare type TypeOfNode<DataTypeUniqueId extends string = string> = {
|
|
440
|
+
name: string;
|
|
441
|
+
headerColor?: string;
|
|
442
|
+
inputs: (TypeOfInput<DataTypeUniqueId> | TypeOfInputPanel<DataTypeUniqueId>)[];
|
|
443
|
+
outputs: TypeOfInput<DataTypeUniqueId>[];
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
export declare function useClickedOutside<T extends HTMLElement>(ref: RefObject<T | null> | T | null, callback: () => void, checkDescendants?: boolean, checkCoordinates?: boolean): void;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Custom hook for handling drag functionality
|
|
450
|
+
*
|
|
451
|
+
* @param options - Configuration options for the drag behavior
|
|
452
|
+
* @returns Object containing drag state and ref for the draggable element
|
|
453
|
+
*/
|
|
454
|
+
export declare function useDrag({ onMove, onClick, clickThreshold, enabled, preventDefaultAndStopPropagation, }?: UseDragOptions): UseDragReturn;
|
|
455
|
+
|
|
456
|
+
export declare type UseDragOptions = {
|
|
457
|
+
/**
|
|
458
|
+
* Callback when dragging occurs
|
|
459
|
+
* @param movementX - The horizontal movement in pixels
|
|
460
|
+
* @param movementY - The vertical movement in pixels
|
|
461
|
+
* @param deltaX - The horizontal movement ratio (movementX / elementWidth)
|
|
462
|
+
* @param deltaY - The vertical movement ratio (movementY / elementHeight)
|
|
463
|
+
* @param width - The width of the element
|
|
464
|
+
* @param height - The height of the element
|
|
465
|
+
*/
|
|
466
|
+
onMove?: (movementX: number, movementY: number, deltaX: number, deltaY: number, width: number, height: number) => void;
|
|
467
|
+
/**
|
|
468
|
+
* Callback when a click is detected (small drag distance)
|
|
469
|
+
*/
|
|
470
|
+
onClick?: () => void;
|
|
471
|
+
/**
|
|
472
|
+
* The maximum distance in pixels to consider as a click (default: 2)
|
|
473
|
+
*/
|
|
474
|
+
clickThreshold?: number;
|
|
475
|
+
/**
|
|
476
|
+
* Whether dragging is enabled (default: true)
|
|
477
|
+
*/
|
|
478
|
+
enabled?: boolean;
|
|
479
|
+
/**
|
|
480
|
+
* Whether to prevent the default behavior of the drag event and stop propagation
|
|
481
|
+
*/
|
|
482
|
+
preventDefaultAndStopPropagation?: boolean;
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
export declare type UseDragReturn = {
|
|
486
|
+
/**
|
|
487
|
+
* Whether the user is currently dragging
|
|
488
|
+
*/
|
|
489
|
+
isDragging: boolean;
|
|
490
|
+
/**
|
|
491
|
+
* Ref to attach to the draggable element
|
|
492
|
+
*/
|
|
493
|
+
dragRef: (element: HTMLElement | null) => void;
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
export declare function useFullGraph<DataTypeUniqueId extends string = string, NodeTypeUniqueId extends string = string, UnderlyingType extends SupportedUnderlyingTypes = SupportedUnderlyingTypes, ComplexSchemaType extends UnderlyingType extends 'complex' ? z.ZodType : never = never>(initialState: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>): {
|
|
497
|
+
state: State<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>;
|
|
498
|
+
dispatch: ActionDispatch<[action: Action<DataTypeUniqueId, NodeTypeUniqueId, UnderlyingType, ComplexSchemaType>]>;
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
export { }
|