@squeed/flow-sdk 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +47 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +157 -11
- package/dist/index.js +14290 -13343
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,44 @@
|
|
|
1
1
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
2
|
+
import { MutableRefObject } from 'react';
|
|
3
|
+
|
|
4
|
+
export declare function applyAutoCollapse(data: any, collapseEveryN: number): any;
|
|
5
|
+
|
|
6
|
+
export declare interface AutoCollapseConfig {
|
|
7
|
+
/** Min lines threshold to trigger (default: 800) */
|
|
8
|
+
minLines?: number;
|
|
9
|
+
/** Min depth threshold to trigger (default: 5) */
|
|
10
|
+
minDepth?: number;
|
|
11
|
+
/** Collapse every Nth depth level (default: 3) */
|
|
12
|
+
collapseEveryNLevels?: number;
|
|
13
|
+
}
|
|
2
14
|
|
|
3
15
|
export declare type BackgroundPattern = "dot" | "steel" | "grid" | "none";
|
|
4
16
|
|
|
17
|
+
/** Props passed to custom bottom bar renderer */
|
|
18
|
+
export declare interface BottomBarRenderProps {
|
|
19
|
+
zoomIn: () => void;
|
|
20
|
+
zoomOut: () => void;
|
|
21
|
+
resetZoom: () => void;
|
|
22
|
+
direction: FlowDirection;
|
|
23
|
+
isZoomMode: boolean;
|
|
24
|
+
setIsZoomMode: (v: boolean) => void;
|
|
25
|
+
isMultiSelectMode: boolean;
|
|
26
|
+
setIsMultiSelectMode: (v: boolean) => void;
|
|
27
|
+
isDragMode: boolean;
|
|
28
|
+
setIsDragMode: (v: boolean) => void;
|
|
29
|
+
isEdgeHandlesEnabled: boolean;
|
|
30
|
+
setIsEdgeHandlesEnabled: (v: boolean) => void;
|
|
31
|
+
isArrayNodeMode: boolean;
|
|
32
|
+
setIsArrayNodeMode: (v: boolean) => void;
|
|
33
|
+
selectedNodeIds: string[];
|
|
34
|
+
selectedNodeData: any[];
|
|
35
|
+
selectedEdgeId: string | null;
|
|
36
|
+
selectedEdgeData: any;
|
|
37
|
+
onNodeDeselect: () => void;
|
|
38
|
+
onEdgeDeselect: () => void;
|
|
39
|
+
callbacks: FlowDiagramCallbacks;
|
|
40
|
+
}
|
|
41
|
+
|
|
5
42
|
export declare const contentObjTheme: (color: any) => {
|
|
6
43
|
background: any;
|
|
7
44
|
highlight: string;
|
|
@@ -25,19 +62,57 @@ declare interface DiagramContext {
|
|
|
25
62
|
} | null;
|
|
26
63
|
}
|
|
27
64
|
|
|
65
|
+
export declare const DynamicIcon: ({ name, ...props }: {
|
|
66
|
+
[x: string]: any;
|
|
67
|
+
name: any;
|
|
68
|
+
}) => JSX_2.Element;
|
|
69
|
+
|
|
28
70
|
export declare function FlowDiagram({ json, title, nodes: externalNodes, edges: externalEdges, config, callbacks, className, style, showBottomBar, }: FlowDiagramProps & {
|
|
29
71
|
showBottomBar?: boolean;
|
|
30
72
|
}): JSX_2.Element;
|
|
31
73
|
|
|
74
|
+
/** Event callbacks for the flow diagram */
|
|
32
75
|
export declare interface FlowDiagramCallbacks {
|
|
76
|
+
/** Fires when a node is clicked/selected */
|
|
33
77
|
onNodeSelect?: (nodeId: string, nodeData: any) => void;
|
|
78
|
+
/** Fires when selection is cleared */
|
|
34
79
|
onNodeDeselect?: () => void;
|
|
80
|
+
/** Fires on double-click of a node */
|
|
35
81
|
onNodeDoubleClick?: (nodeId: string, nodeData: any) => void;
|
|
82
|
+
/** Fires when a node is created via edge drawing into empty space */
|
|
83
|
+
onNodeCreate?: (params: {
|
|
84
|
+
type: string;
|
|
85
|
+
position: any;
|
|
86
|
+
sourceNodeId?: string;
|
|
87
|
+
isArrayMode?: boolean;
|
|
88
|
+
}) => void;
|
|
89
|
+
/** Fires when a node is deleted */
|
|
90
|
+
onNodeDelete?: (nodeId: string, nodeData: any) => void;
|
|
91
|
+
/** Fires when a node label is edited inline */
|
|
92
|
+
onNodeLabelChange?: (nodeId: string, newLabel: string) => void;
|
|
93
|
+
/** Fires when a node's collapse toggle is clicked */
|
|
94
|
+
onNodeCollapse?: (nodeId: string, collapsed: boolean) => void;
|
|
95
|
+
/** Fires when a node's color is changed via the toolbar */
|
|
96
|
+
onNodeColorChange?: (nodeId: string, colorType: "text" | "bg", color: string) => void;
|
|
97
|
+
/** Fires when a node's icon is changed via the toolbar */
|
|
98
|
+
onNodeIconChange?: (nodeId: string, iconName: string) => void;
|
|
99
|
+
/** Fires when a hover overlay action is clicked */
|
|
36
100
|
onNodeHoverAction?: (actionId: string, nodeId: string, nodeData: any) => void;
|
|
101
|
+
/** Fires when a new edge is drawn between two nodes */
|
|
37
102
|
onEdgeCreate?: (sourceId: string, targetId: string) => void;
|
|
103
|
+
/** Fires when an edge is clicked/selected */
|
|
38
104
|
onEdgeSelect?: (edgeId: string, edgeData: any) => void;
|
|
105
|
+
/** Fires when edge selection is cleared */
|
|
39
106
|
onEdgeDeselect?: () => void;
|
|
107
|
+
/** Fires when an edge is removed */
|
|
40
108
|
onEdgeRemove?: (edgeId: string, edgeData: any) => void;
|
|
109
|
+
/** Fires when an edge's color is changed */
|
|
110
|
+
onEdgeColorChange?: (edgeId: string, color: string) => void;
|
|
111
|
+
/** Fires when an edge's label is changed */
|
|
112
|
+
onEdgeLabelChange?: (edgeId: string, newLabel: string) => void;
|
|
113
|
+
/** Fires when an edge's style is changed (solid, dashed, animated) */
|
|
114
|
+
onEdgeStyleChange?: (edgeId: string, style: "solid" | "dashed" | "animated") => void;
|
|
115
|
+
/** Fires when the viewport (pan/zoom) changes */
|
|
41
116
|
onViewportChange?: (viewport: {
|
|
42
117
|
pan: {
|
|
43
118
|
x: number;
|
|
@@ -45,27 +120,35 @@ export declare interface FlowDiagramCallbacks {
|
|
|
45
120
|
};
|
|
46
121
|
zoom: number;
|
|
47
122
|
}) => void;
|
|
48
|
-
|
|
49
|
-
type: string;
|
|
50
|
-
position: any;
|
|
51
|
-
sourceNodeId?: string;
|
|
52
|
-
}) => void;
|
|
53
|
-
onCyInit?: (cy: any) => void;
|
|
123
|
+
/** Fires when the flow direction changes via bottom bar */
|
|
54
124
|
onDirectionChange?: (direction: FlowDirection) => void;
|
|
55
|
-
|
|
56
|
-
onEdgeColorChange?: (edgeId: string, color: string) => void;
|
|
125
|
+
/** Fires when array/set mode toggles in bottom bar */
|
|
57
126
|
onArrayModeChange?: (isArrayMode: boolean) => void;
|
|
58
|
-
|
|
127
|
+
/** Fires when Cytoscape instance is initialized (for advanced use) */
|
|
128
|
+
onCyInit?: (cy: any) => void;
|
|
59
129
|
}
|
|
60
130
|
|
|
131
|
+
/** Configuration for the flow diagram appearance and behavior */
|
|
61
132
|
export declare interface FlowDiagramConfig {
|
|
133
|
+
/** Layout direction: "LR", "RL", "TB", "BT" */
|
|
62
134
|
direction?: FlowDirection;
|
|
135
|
+
/** Layout algorithm */
|
|
63
136
|
layout?: LayoutAlgorithm;
|
|
137
|
+
/** Theme accent color (Chakra token e.g. "blue.500") */
|
|
64
138
|
themeColor?: string;
|
|
139
|
+
/** Light or dark mode */
|
|
65
140
|
colorMode?: "light" | "dark";
|
|
141
|
+
/** Background pattern style */
|
|
66
142
|
backgroundPattern?: BackgroundPattern;
|
|
143
|
+
/** Background color override */
|
|
144
|
+
backgroundColor?: string;
|
|
145
|
+
/** Edge/line color override */
|
|
146
|
+
edgeColor?: string;
|
|
147
|
+
/** Min zoom level (default: 0.01) */
|
|
67
148
|
minZoom?: number;
|
|
149
|
+
/** Max zoom level (default: 1.5) */
|
|
68
150
|
maxZoom?: number;
|
|
151
|
+
/** Initial viewport position and zoom */
|
|
69
152
|
initialViewport?: {
|
|
70
153
|
pan: {
|
|
71
154
|
x: number;
|
|
@@ -73,12 +156,36 @@ export declare interface FlowDiagramConfig {
|
|
|
73
156
|
};
|
|
74
157
|
zoom: number;
|
|
75
158
|
};
|
|
159
|
+
/** Enable edge drawing handles (default: true) */
|
|
76
160
|
edgeHandles?: boolean;
|
|
161
|
+
/** Disable all interactions */
|
|
77
162
|
readOnly?: boolean;
|
|
78
|
-
|
|
163
|
+
/** Enable inline node label editing */
|
|
164
|
+
editable?: boolean;
|
|
165
|
+
/** Actions rendered in the node hover overlay */
|
|
79
166
|
nodeOverlayActions?: NodeOverlayAction[];
|
|
167
|
+
/** Custom render function for node hover overlay */
|
|
80
168
|
renderNodeOverlay?: (props: NodeOverlayProps) => React.ReactNode;
|
|
169
|
+
/** Custom render function for multi-select toolbar */
|
|
81
170
|
renderSelectedNodeToolbar?: (props: SelectedNodeToolbarProps) => React.ReactNode;
|
|
171
|
+
/** Custom render function for edge selection toolbar */
|
|
172
|
+
renderSelectedEdgeToolbar?: (props: SelectedEdgeToolbarProps) => React.ReactNode;
|
|
173
|
+
/** Custom render function to replace the entire built-in bottom bar */
|
|
174
|
+
renderBottomBar?: (props: BottomBarRenderProps) => React.ReactNode;
|
|
175
|
+
/** Auto-collapse deep nodes for large data. `true` uses defaults, or pass config for custom thresholds */
|
|
176
|
+
autoCollapse?: AutoCollapseConfig | boolean;
|
|
177
|
+
/** Custom node view components to override SDK defaults. Keys: objectView, arrayView, text, parentContainer */
|
|
178
|
+
customViews?: Record<string, React.ComponentType<any>>;
|
|
179
|
+
/** Disable built-in keyboard shortcuts (Z/M/D) when the consumer handles its own */
|
|
180
|
+
disableKeyboardShortcuts?: boolean;
|
|
181
|
+
/** Externally controlled zoom mode (overrides internal state when provided) */
|
|
182
|
+
isZoomMode?: boolean;
|
|
183
|
+
/** Externally controlled multi-select mode (overrides internal state when provided) */
|
|
184
|
+
isMultiSelectMode?: boolean;
|
|
185
|
+
/** Externally controlled edge draw mode (overrides internal state when provided) */
|
|
186
|
+
isEdgeHandlesEnabled?: boolean;
|
|
187
|
+
/** Externally controlled drag/pan mode (overrides internal state when provided) */
|
|
188
|
+
isDragMode?: boolean;
|
|
82
189
|
}
|
|
83
190
|
|
|
84
191
|
export declare interface FlowDiagramEdge {
|
|
@@ -108,14 +215,23 @@ export declare interface FlowDiagramNode {
|
|
|
108
215
|
};
|
|
109
216
|
}
|
|
110
217
|
|
|
218
|
+
/** Top-level props for the FlowDiagram component */
|
|
111
219
|
export declare interface FlowDiagramProps {
|
|
220
|
+
/** JSON object to render as a flow diagram */
|
|
112
221
|
json?: any;
|
|
222
|
+
/** Title shown on the root node */
|
|
113
223
|
title?: string;
|
|
224
|
+
/** Pre-computed nodes (alternative to json) */
|
|
114
225
|
nodes?: FlowDiagramNode[];
|
|
226
|
+
/** Pre-computed edges (alternative to json) */
|
|
115
227
|
edges?: FlowDiagramEdge[];
|
|
228
|
+
/** Diagram configuration */
|
|
116
229
|
config?: FlowDiagramConfig;
|
|
230
|
+
/** Event callbacks */
|
|
117
231
|
callbacks?: FlowDiagramCallbacks;
|
|
232
|
+
/** CSS class name */
|
|
118
233
|
className?: string;
|
|
234
|
+
/** Inline styles */
|
|
119
235
|
style?: React.CSSProperties;
|
|
120
236
|
}
|
|
121
237
|
|
|
@@ -135,14 +251,22 @@ export declare const getColorVariant: (color: string) => {
|
|
|
135
251
|
|
|
136
252
|
export declare function getDarkerHexColor(hex: string, factor?: number): string;
|
|
137
253
|
|
|
254
|
+
export declare function getJsonSize(data: any): {
|
|
255
|
+
lines: number;
|
|
256
|
+
depth: number;
|
|
257
|
+
nodes: number;
|
|
258
|
+
};
|
|
259
|
+
|
|
138
260
|
export declare type LayoutAlgorithm = "dagre" | "elk" | "tidytree" | "concentric" | "cose";
|
|
139
261
|
|
|
262
|
+
/** Actions shown in the hover overlay above nodes */
|
|
140
263
|
export declare interface NodeOverlayAction {
|
|
264
|
+
id: string;
|
|
141
265
|
icon: any;
|
|
142
266
|
label: string;
|
|
143
|
-
id: string;
|
|
144
267
|
}
|
|
145
268
|
|
|
269
|
+
/** Props passed to custom node overlay renderer */
|
|
146
270
|
export declare interface NodeOverlayProps {
|
|
147
271
|
nodeId: string;
|
|
148
272
|
nodeData: any;
|
|
@@ -152,6 +276,14 @@ export declare interface NodeOverlayProps {
|
|
|
152
276
|
setIsHovered: (v: boolean) => void;
|
|
153
277
|
}
|
|
154
278
|
|
|
279
|
+
/** Props passed to custom edge selection toolbar renderer */
|
|
280
|
+
export declare interface SelectedEdgeToolbarProps {
|
|
281
|
+
edgeId: string;
|
|
282
|
+
edgeData: any;
|
|
283
|
+
onDeselect: () => void;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** Props passed to custom node selection toolbar renderer */
|
|
155
287
|
export declare interface SelectedNodeToolbarProps {
|
|
156
288
|
selectedNodeIds: string[];
|
|
157
289
|
selectedNodeData: any[];
|
|
@@ -178,6 +310,20 @@ export declare function useCustomColors(theme?: any): {
|
|
|
178
310
|
greenColor: string;
|
|
179
311
|
};
|
|
180
312
|
|
|
313
|
+
/**
|
|
314
|
+
* Hook that stops all event propagation on a DOM element.
|
|
315
|
+
* Use this on any interactive element inside a node (inputs, textareas, forms)
|
|
316
|
+
* to prevent cytoscape from intercepting mouse/keyboard events.
|
|
317
|
+
*
|
|
318
|
+
* @param active - Only attach listeners when true (e.g. when editing)
|
|
319
|
+
* @returns ref to attach to the wrapper element
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* const inputRef = useStopPropagation<HTMLDivElement>(isEditing);
|
|
323
|
+
* return <div ref={inputRef}><input /></div>;
|
|
324
|
+
*/
|
|
325
|
+
export declare function useStopPropagation<T extends HTMLElement>(active?: boolean): MutableRefObject<T>;
|
|
326
|
+
|
|
181
327
|
export declare function useThemeContentColors(color: any): {
|
|
182
328
|
bgColor: any;
|
|
183
329
|
highlightColor: string;
|