@squeed/flow-sdk 0.1.16 → 2.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/README.md +241 -127
- package/THIRD_PARTY_NOTICES.txt +120 -0
- package/dist/index.cjs +2 -357
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +551 -0
- package/dist/index.d.ts +77 -10
- package/dist/index.js +8911 -31371
- package/dist/index.js.map +1 -1
- package/package.json +28 -16
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
2
|
+
import { MutableRefObject } from 'react';
|
|
3
|
+
|
|
4
|
+
/** Add a child under `parentAddress`. Returns the new node's address. */
|
|
5
|
+
export declare function addChild(json: SqueedJson, parentAddress: string, child: any, key?: string): {
|
|
6
|
+
json: SqueedJson;
|
|
7
|
+
address: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export declare function addConnection(json: SqueedJson, sourceAddress: string, connection: SqueedConnection): SqueedJson;
|
|
11
|
+
|
|
12
|
+
/** "root.a.b.#" → ["a", "b"] */
|
|
13
|
+
export declare function addressToPath(address: string): string[];
|
|
14
|
+
|
|
15
|
+
/** `$target` cross-link (the compiler supports one per node; an existing one is replaced) */
|
|
16
|
+
export declare const addTargetEdge: (json: SqueedJson, sourceAddress: string, targetAddress: string, label?: string) => SqueedJson;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* For hand-built graphs (no Squeed JSON): hide everything downstream of a node whose
|
|
20
|
+
* `data.config.collapsed` is true, plus the edges touching hidden nodes.
|
|
21
|
+
*/
|
|
22
|
+
export declare function applyCollapsed(nodes: FlowDiagramNode[], edges: FlowDiagramEdge[]): {
|
|
23
|
+
nodes: FlowDiagramNode[];
|
|
24
|
+
edges: FlowDiagramEdge[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export declare type BackgroundPattern = "dot" | "steel" | "grid" | "none";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Wrap consumer callbacks so every toolbar/edit event is applied to `json`
|
|
31
|
+
* with Squeed `$` keys and delivered via `onJsonChange`. Granular callbacks
|
|
32
|
+
* still fire first (for logging/analytics) — consumers must not also mutate.
|
|
33
|
+
*/
|
|
34
|
+
export declare function bindSqueedCallbacks(json: SqueedJson, compiledEdges: FlowDiagramEdge[], callbacks: FlowDiagramCallbacks, onJsonChange?: (json: SqueedJson, change: SqueedChange) => void): FlowDiagramCallbacks;
|
|
35
|
+
|
|
36
|
+
/** Props passed to custom bottom bar renderer */
|
|
37
|
+
export declare interface BottomBarRenderProps {
|
|
38
|
+
zoomIn: () => void;
|
|
39
|
+
zoomOut: () => void;
|
|
40
|
+
resetZoom: () => void;
|
|
41
|
+
direction: FlowDirection;
|
|
42
|
+
isZoomMode: boolean;
|
|
43
|
+
setIsZoomMode: (v: boolean) => void;
|
|
44
|
+
isMultiSelectMode: boolean;
|
|
45
|
+
setIsMultiSelectMode: (v: boolean) => void;
|
|
46
|
+
isDragMode: boolean;
|
|
47
|
+
setIsDragMode: (v: boolean) => void;
|
|
48
|
+
isEdgeHandlesEnabled: boolean;
|
|
49
|
+
setIsEdgeHandlesEnabled: (v: boolean) => void;
|
|
50
|
+
isArrayNodeMode: boolean;
|
|
51
|
+
setIsArrayNodeMode: (v: boolean) => void;
|
|
52
|
+
selectedNodeIds: string[];
|
|
53
|
+
selectedNodeData: any[];
|
|
54
|
+
selectedEdgeId: string | null;
|
|
55
|
+
selectedEdgeData: any;
|
|
56
|
+
onNodeDeselect: () => void;
|
|
57
|
+
onEdgeDeselect: () => void;
|
|
58
|
+
callbacks: FlowDiagramCallbacks;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Centre + size, model units (matches cytoscape's node position/width/height) */
|
|
62
|
+
declare interface Box {
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
w: number;
|
|
66
|
+
h: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export declare interface CompileOptions {
|
|
70
|
+
title?: string;
|
|
71
|
+
/** Root in the middle, children fan out both ways (direction "C") */
|
|
72
|
+
isCenter?: boolean;
|
|
73
|
+
hideDefaultObject?: boolean;
|
|
74
|
+
separateObjectKeys?: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* `createFlowDiagram` + post-pass:
|
|
79
|
+
* - deterministic edge ids (`source->target[#n]`) so selection survives regeneration
|
|
80
|
+
* - honors `$isEdgeDashed` / `$edgeColor`, which the compiler doesn't read
|
|
81
|
+
* - `$label` wins over the compiler's shared-config `headerTitle` (it leaks the previous node's title)
|
|
82
|
+
*/
|
|
83
|
+
export declare function compileSqueed(json: SqueedJson, opts?: CompileOptions): {
|
|
84
|
+
nodes: FlowDiagramNode[];
|
|
85
|
+
edges: FlowDiagramEdge[];
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export declare const contentObjTheme: (color: any) => {
|
|
89
|
+
background: any;
|
|
90
|
+
highlight: string;
|
|
91
|
+
border: string;
|
|
92
|
+
property: string;
|
|
93
|
+
boolean: string;
|
|
94
|
+
string: string;
|
|
95
|
+
number: string;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export declare function createFlowDiagram(jsnObjct: any, path?: string, nodes?: any[], edges?: any[], activeLabel?: string, flowConfig?: any, nodeConfig?: any): {
|
|
99
|
+
nodes: any[];
|
|
100
|
+
edges: any[];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export declare const DynamicIcon: ({ name, ...props }: {
|
|
104
|
+
[x: string]: any;
|
|
105
|
+
name: any;
|
|
106
|
+
}) => JSX_2.Element;
|
|
107
|
+
|
|
108
|
+
export declare type EdgeMode = "workflow" | "properties";
|
|
109
|
+
|
|
110
|
+
export declare function FlowDiagram({ title, json, nodes, edges, config, callbacks, className, style, showBottomBar, }: FlowDiagramProps): JSX_2.Element;
|
|
111
|
+
|
|
112
|
+
/** Event callbacks for the flow diagram */
|
|
113
|
+
export declare interface FlowDiagramCallbacks {
|
|
114
|
+
/** Fires when a node is clicked/selected */
|
|
115
|
+
onNodeSelect?: (nodeId: string, nodeData: any) => void;
|
|
116
|
+
/** Fires when selection is cleared */
|
|
117
|
+
onNodeDeselect?: () => void;
|
|
118
|
+
/** Fires on double-click of a node */
|
|
119
|
+
onNodeDoubleClick?: (nodeId: string, nodeData: any) => void;
|
|
120
|
+
/** Fires when a node is created via edge drawing into empty space */
|
|
121
|
+
onNodeCreate?: (params: {
|
|
122
|
+
type: string;
|
|
123
|
+
position: any;
|
|
124
|
+
sourceNodeId?: string;
|
|
125
|
+
isArrayMode?: boolean;
|
|
126
|
+
}) => void;
|
|
127
|
+
/** Fires when a node is deleted */
|
|
128
|
+
onNodeDelete?: (nodeId: string, nodeData: any) => void;
|
|
129
|
+
/** Fires when a node label is edited inline */
|
|
130
|
+
onNodeLabelChange?: (nodeId: string, newLabel: string) => void;
|
|
131
|
+
/** Fires when a node's collapse toggle is clicked */
|
|
132
|
+
onNodeCollapse?: (nodeId: string, collapsed: boolean) => void;
|
|
133
|
+
/** Fires when a node's color is changed via the toolbar */
|
|
134
|
+
onNodeColorChange?: (nodeId: string, colorType: "text" | "bg", color: string) => void;
|
|
135
|
+
/** Fires when a node's icon is changed via the toolbar */
|
|
136
|
+
onNodeIconChange?: (nodeId: string, iconName: string) => void;
|
|
137
|
+
/** Fires when a hover overlay action is clicked */
|
|
138
|
+
onNodeHoverAction?: (actionId: string, nodeId: string, nodeData: any) => void;
|
|
139
|
+
/** Fires when a new edge is drawn between two nodes */
|
|
140
|
+
onEdgeCreate?: (sourceId: string, targetId: string, properties?: FlowEdgeProperties) => void;
|
|
141
|
+
/** Fires when an edge is clicked/selected */
|
|
142
|
+
onEdgeSelect?: (edgeId: string, edgeData: any) => void;
|
|
143
|
+
/** Fires when edge selection is cleared */
|
|
144
|
+
onEdgeDeselect?: () => void;
|
|
145
|
+
/** Fires when an edge is removed */
|
|
146
|
+
onEdgeRemove?: (edgeId: string, edgeData: any) => void;
|
|
147
|
+
/** Fires when the user deletes an edge from the selection toolbar */
|
|
148
|
+
onEdgeDelete?: (edgeId: string, edgeData: any) => void;
|
|
149
|
+
/** Fires when an edge's color is changed */
|
|
150
|
+
onEdgeColorChange?: (edgeId: string, color: string) => void;
|
|
151
|
+
/** Fires when an edge's label is changed */
|
|
152
|
+
onEdgeLabelChange?: (edgeId: string, newLabel: string) => void;
|
|
153
|
+
/** Fires when an edge's style is changed (solid, dashed, animated) */
|
|
154
|
+
onEdgeStyleChange?: (edgeId: string, style: "solid" | "dashed" | "animated") => void;
|
|
155
|
+
/** Fires when the viewport (pan/zoom) changes */
|
|
156
|
+
onViewportChange?: (viewport: {
|
|
157
|
+
pan: {
|
|
158
|
+
x: number;
|
|
159
|
+
y: number;
|
|
160
|
+
};
|
|
161
|
+
zoom: number;
|
|
162
|
+
}) => void;
|
|
163
|
+
/** Fires when the flow direction changes via bottom bar */
|
|
164
|
+
onDirectionChange?: (direction: FlowDirection) => void;
|
|
165
|
+
/** Fires when array/set mode toggles in bottom bar */
|
|
166
|
+
onArrayModeChange?: (isArrayMode: boolean) => void;
|
|
167
|
+
/** Fires once the renderer is ready with the engine handle (zoom/pan/fit/coordinate helpers) */
|
|
168
|
+
onInit?: (engine: FlowEngine) => void;
|
|
169
|
+
/**
|
|
170
|
+
* Fires with the updated Squeed JSON after any toolbar/inline edit. The SDK applies the
|
|
171
|
+
* edit with `$` schema keys; store the result and pass it back as `json`.
|
|
172
|
+
*/
|
|
173
|
+
onJsonChange?: (json: Record<string, any> | any[], change: SqueedChangeInfo) => void;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Configuration for the flow diagram appearance and behavior */
|
|
177
|
+
export declare interface FlowDiagramConfig {
|
|
178
|
+
/** Layout direction: "LR", "RL", "TB", "BT" */
|
|
179
|
+
direction?: FlowDirection;
|
|
180
|
+
nodeAlignment?: NodeAlignment;
|
|
181
|
+
edgeMode?: EdgeMode;
|
|
182
|
+
/** Layout algorithm */
|
|
183
|
+
layout?: LayoutAlgorithm;
|
|
184
|
+
/** Theme accent color (Chakra token e.g. "blue.500") */
|
|
185
|
+
themeColor?: string;
|
|
186
|
+
/** Light or dark mode */
|
|
187
|
+
colorMode?: "light" | "dark";
|
|
188
|
+
/** Background pattern style */
|
|
189
|
+
backgroundPattern?: BackgroundPattern;
|
|
190
|
+
/** Background color override */
|
|
191
|
+
backgroundColor?: string;
|
|
192
|
+
/** Edge/line color override */
|
|
193
|
+
edgeColor?: string;
|
|
194
|
+
/** Default style for all compound/container nodes (per-node `viewProps` override it) */
|
|
195
|
+
parentNodeStyle?: ParentNodeStyle;
|
|
196
|
+
/** Min zoom level (default: 0.01) */
|
|
197
|
+
minZoom?: number;
|
|
198
|
+
/** Max zoom level (default: 1.5) */
|
|
199
|
+
maxZoom?: number;
|
|
200
|
+
/** Initial viewport position and zoom */
|
|
201
|
+
initialViewport?: {
|
|
202
|
+
pan: {
|
|
203
|
+
x: number;
|
|
204
|
+
y: number;
|
|
205
|
+
};
|
|
206
|
+
zoom: number;
|
|
207
|
+
};
|
|
208
|
+
/** Enable edge drawing handles (default: true) */
|
|
209
|
+
edgeHandles?: boolean;
|
|
210
|
+
/** Disable all interactions */
|
|
211
|
+
readOnly?: boolean;
|
|
212
|
+
/** Enable inline node label editing */
|
|
213
|
+
editable?: boolean;
|
|
214
|
+
/** Actions rendered in the node hover overlay */
|
|
215
|
+
nodeOverlayActions?: NodeOverlayAction[];
|
|
216
|
+
/** Custom render function for node hover overlay */
|
|
217
|
+
renderNodeOverlay?: (props: NodeOverlayProps) => React.ReactNode;
|
|
218
|
+
/** Custom render function for multi-select toolbar */
|
|
219
|
+
renderSelectedNodeToolbar?: (props: SelectedNodeToolbarProps) => React.ReactNode;
|
|
220
|
+
/** Custom render function for edge selection toolbar */
|
|
221
|
+
renderSelectedEdgeToolbar?: (props: SelectedEdgeToolbarProps) => React.ReactNode;
|
|
222
|
+
/** Custom render function to replace the entire built-in bottom bar */
|
|
223
|
+
renderBottomBar?: (props: BottomBarRenderProps) => React.ReactNode;
|
|
224
|
+
/** Built-in node/edge selection toolbars (bottom bar swaps to them on select). `false` disables. */
|
|
225
|
+
selectionToolbar?: SelectionToolbarConfig | false;
|
|
226
|
+
/** Custom node view components to override SDK defaults. Keys: objectView, arrayView, text, parentContainer */
|
|
227
|
+
customViews?: Record<string, React.ComponentType<any>>;
|
|
228
|
+
/** Disable built-in keyboard shortcuts (Z/M/D) when the consumer handles its own */
|
|
229
|
+
disableKeyboardShortcuts?: boolean;
|
|
230
|
+
/** Externally controlled zoom mode (overrides internal state when provided) */
|
|
231
|
+
isZoomMode?: boolean;
|
|
232
|
+
/** Externally controlled multi-select mode (overrides internal state when provided) */
|
|
233
|
+
isMultiSelectMode?: boolean;
|
|
234
|
+
/** Externally controlled edge draw mode (overrides internal state when provided) */
|
|
235
|
+
isEdgeHandlesEnabled?: boolean;
|
|
236
|
+
/** Externally controlled drag/pan mode (overrides internal state when provided) */
|
|
237
|
+
isDragMode?: boolean;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export declare interface FlowDiagramEdge {
|
|
241
|
+
data: {
|
|
242
|
+
id: string;
|
|
243
|
+
source: string;
|
|
244
|
+
target: string;
|
|
245
|
+
sourceProperty?: string;
|
|
246
|
+
targetProperty?: string;
|
|
247
|
+
connection?: SqueedConnectionRef;
|
|
248
|
+
label?: string;
|
|
249
|
+
/** Chakra token or hex; overrides the theme/edgeColor line color for this edge */
|
|
250
|
+
color?: string;
|
|
251
|
+
isInverted?: boolean;
|
|
252
|
+
isEdgeAnimated?: boolean;
|
|
253
|
+
isEdgeDashed?: boolean;
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export declare interface FlowDiagramNode {
|
|
258
|
+
data: {
|
|
259
|
+
id: string;
|
|
260
|
+
label?: string;
|
|
261
|
+
text?: string;
|
|
262
|
+
code?: string;
|
|
263
|
+
type: string;
|
|
264
|
+
parent?: string;
|
|
265
|
+
headerTitle?: string;
|
|
266
|
+
description?: Record<string, any>;
|
|
267
|
+
viewProps?: any;
|
|
268
|
+
config?: Record<string, any>;
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Top-level props for the FlowDiagram component */
|
|
273
|
+
export declare interface FlowDiagramProps {
|
|
274
|
+
/** Title shown on the root node */
|
|
275
|
+
title?: string;
|
|
276
|
+
/**
|
|
277
|
+
* Squeed JSON document. When provided, nodes/edges are compiled from it and every
|
|
278
|
+
* edit is reported through `callbacks.onJsonChange`. Takes precedence over nodes/edges.
|
|
279
|
+
*/
|
|
280
|
+
json?: Record<string, any> | any[];
|
|
281
|
+
/** Pre-computed nodes */
|
|
282
|
+
nodes?: FlowDiagramNode[];
|
|
283
|
+
/** Pre-computed edges */
|
|
284
|
+
edges?: FlowDiagramEdge[];
|
|
285
|
+
/** Diagram configuration */
|
|
286
|
+
config?: FlowDiagramConfig;
|
|
287
|
+
/** Event callbacks */
|
|
288
|
+
callbacks?: FlowDiagramCallbacks;
|
|
289
|
+
showBottomBar?: boolean;
|
|
290
|
+
/** CSS class name */
|
|
291
|
+
className?: string;
|
|
292
|
+
/** Inline styles */
|
|
293
|
+
style?: React.CSSProperties;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** "C" = center: root in the middle, children fan out both ways (generate with `isCntr: true`); laid out as LR */
|
|
297
|
+
export declare type FlowDirection = "LR" | "RL" | "TB" | "BT" | "C";
|
|
298
|
+
|
|
299
|
+
export declare interface FlowEdgeProperties {
|
|
300
|
+
sourceProperty?: string;
|
|
301
|
+
targetProperty?: string;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** Handle passed to `callbacks.onInit`. */
|
|
305
|
+
export declare interface FlowEngine {
|
|
306
|
+
zoom(): number;
|
|
307
|
+
/** Set zoom keeping the current pan (like cytoscape `cy.zoom(level)`) */
|
|
308
|
+
zoom(level: number): void;
|
|
309
|
+
pan(): Point;
|
|
310
|
+
pan(p: Point): void;
|
|
311
|
+
/** Zoom keeping the model point under `renderedPoint` (container px) fixed */
|
|
312
|
+
zoomAt(level: number, renderedPoint: Point): void;
|
|
313
|
+
/** Fit all elements into the container with `padding` rendered px */
|
|
314
|
+
fit(padding?: number): void;
|
|
315
|
+
/** Centre all elements at the current zoom */
|
|
316
|
+
center(): void;
|
|
317
|
+
clientToModel(clientX: number, clientY: number): Point;
|
|
318
|
+
modelToClient(p: Point): Point;
|
|
319
|
+
getNodeBox(id: string): Box | undefined;
|
|
320
|
+
onViewportChange(fn: (vp: ViewportState) => void): () => void;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export declare const getChakraColorHex: (color?: any, opacity?: any) => any;
|
|
324
|
+
|
|
325
|
+
export declare const getColorVariant: (color: string) => {
|
|
326
|
+
secondary: string;
|
|
327
|
+
primary?: undefined;
|
|
328
|
+
light?: undefined;
|
|
329
|
+
} | {
|
|
330
|
+
primary: string;
|
|
331
|
+
secondary: string;
|
|
332
|
+
light: string;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export declare function getDarkerHexColor(hex: string, factor?: number): string;
|
|
336
|
+
|
|
337
|
+
export declare function getNode(json: SqueedJson, address: string): any;
|
|
338
|
+
|
|
339
|
+
export declare type LayoutAlgorithm = "dagre" | "elk" | "tidytree" | "concentric" | "cose";
|
|
340
|
+
|
|
341
|
+
export declare type NodeAlignment = "leading" | "center" | "trailing";
|
|
342
|
+
|
|
343
|
+
/** Actions shown in the hover overlay above nodes */
|
|
344
|
+
export declare interface NodeOverlayAction {
|
|
345
|
+
id: string;
|
|
346
|
+
icon: any;
|
|
347
|
+
label: string;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/** Props passed to custom node overlay renderer */
|
|
351
|
+
export declare interface NodeOverlayProps {
|
|
352
|
+
nodeId: string;
|
|
353
|
+
nodeData: any;
|
|
354
|
+
isRoot: boolean;
|
|
355
|
+
isParent: boolean;
|
|
356
|
+
isHovered: boolean;
|
|
357
|
+
setIsHovered: (v: boolean) => void;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Style for compound (container) nodes. Set per node via `data.viewProps`,
|
|
362
|
+
* or for all containers via `config.parentNodeStyle` (per-node wins).
|
|
363
|
+
* Colors accept Chakra tokens ("purple.500") or hex.
|
|
364
|
+
*/
|
|
365
|
+
export declare interface ParentNodeStyle {
|
|
366
|
+
/** Fill color; also the default border/label color (default: themeColor) */
|
|
367
|
+
bgColor?: string;
|
|
368
|
+
/** Fill opacity 0–1 (default 0.4) */
|
|
369
|
+
bgOpacity?: number;
|
|
370
|
+
borderColor?: string;
|
|
371
|
+
/** px (default 6) */
|
|
372
|
+
borderWidth?: number;
|
|
373
|
+
borderStyle?: "solid" | "dashed" | "dotted" | "double";
|
|
374
|
+
/** Corner radius px (default 50) */
|
|
375
|
+
borderRadius?: number;
|
|
376
|
+
/** Label color (default: bgColor) */
|
|
377
|
+
textColor?: string;
|
|
378
|
+
/** Label size px (default 70) */
|
|
379
|
+
fontSize?: number;
|
|
380
|
+
/** Inner padding px (default 120) */
|
|
381
|
+
padding?: number;
|
|
382
|
+
/** Label placement (default "top") */
|
|
383
|
+
labelPosition?: "top" | "center" | "bottom";
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
declare interface Point {
|
|
387
|
+
x: number;
|
|
388
|
+
y: number;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** Removes a `$target` edge; hierarchy edges cannot be removed without removing the child (returns json unchanged). */
|
|
392
|
+
export declare function removeEdge(json: SqueedJson, edge: RenderedEdgeRef): {
|
|
393
|
+
json: SqueedJson;
|
|
394
|
+
removed: boolean;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
export declare function removeNode(json: SqueedJson, address: string): SqueedJson;
|
|
398
|
+
|
|
399
|
+
export declare interface RenderedEdgeRef extends FlowEdgeProperties {
|
|
400
|
+
source: string;
|
|
401
|
+
target: string;
|
|
402
|
+
isInverted?: boolean | null;
|
|
403
|
+
connection?: SqueedConnectionRef;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Resolve which JSON node carries an edge's keys.
|
|
408
|
+
* parent→child edges (implicit hierarchy) are configured on the child;
|
|
409
|
+
* `$target` cross-links are configured on the source node.
|
|
410
|
+
*/
|
|
411
|
+
export declare function resolveEdgeOwner(edge: RenderedEdgeRef): {
|
|
412
|
+
address: string;
|
|
413
|
+
kind: "hierarchy" | "target" | "connection";
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
/** Props passed to custom edge selection toolbar renderer */
|
|
417
|
+
export declare interface SelectedEdgeToolbarProps {
|
|
418
|
+
edgeId: string;
|
|
419
|
+
edgeData: any;
|
|
420
|
+
onDeselect: () => void;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** Props passed to custom node selection toolbar renderer */
|
|
424
|
+
export declare interface SelectedNodeToolbarProps {
|
|
425
|
+
selectedNodeIds: string[];
|
|
426
|
+
selectedNodeData: any[];
|
|
427
|
+
onDeselect: () => void;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/** Built-in selection toolbars (shown in the bottom bar when a node/edge is selected) */
|
|
431
|
+
export declare interface SelectionToolbarConfig {
|
|
432
|
+
/** Swatches offered for node/edge colors (Chakra tokens or hex). Default: 9 Chakra 500s */
|
|
433
|
+
palette?: string[];
|
|
434
|
+
/** Hide individual controls */
|
|
435
|
+
hide?: Array<"label" | "color" | "textColor" | "style" | "icon" | "collapse" | "delete">;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export declare const setCollapsed: (json: SqueedJson, address: string, collapsed: boolean) => SqueedJson;
|
|
439
|
+
|
|
440
|
+
export declare function setEdgeProp(json: SqueedJson, edge: RenderedEdgeRef, key: SqueedEdgeKey, value: any): SqueedJson;
|
|
441
|
+
|
|
442
|
+
export declare const setEdgeStyle: (json: SqueedJson, edge: RenderedEdgeRef, style: "solid" | "dashed" | "animated") => SqueedJson;
|
|
443
|
+
|
|
444
|
+
export declare function setNodeProp(json: SqueedJson, address: string, key: SqueedNodeKey, value: any): SqueedJson;
|
|
445
|
+
|
|
446
|
+
/** What changed in the Squeed document (delivered alongside the new JSON) */
|
|
447
|
+
export declare interface SqueedChange {
|
|
448
|
+
type: "nodeLabel" | "nodeColor" | "nodeIcon" | "nodeCollapse" | "nodeCreate" | "nodeDelete" | "edgeLabel" | "edgeStyle" | "edgeColor" | "edgeCreate" | "edgeDelete";
|
|
449
|
+
/** Node address affected (new node's address for nodeCreate) */
|
|
450
|
+
address?: string;
|
|
451
|
+
edge?: RenderedEdgeRef;
|
|
452
|
+
/** `$` key written, when a single key changed */
|
|
453
|
+
key?: string;
|
|
454
|
+
value?: unknown;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/** Describes the edit behind an `onJsonChange` */
|
|
458
|
+
export declare interface SqueedChangeInfo {
|
|
459
|
+
type: "nodeLabel" | "nodeColor" | "nodeIcon" | "nodeCollapse" | "nodeCreate" | "nodeDelete" | "edgeLabel" | "edgeStyle" | "edgeColor" | "edgeCreate" | "edgeDelete";
|
|
460
|
+
address?: string;
|
|
461
|
+
edge?: FlowEdgeProperties & {
|
|
462
|
+
source: string;
|
|
463
|
+
target: string;
|
|
464
|
+
isInverted?: boolean | null;
|
|
465
|
+
connection?: SqueedConnectionRef;
|
|
466
|
+
};
|
|
467
|
+
key?: string;
|
|
468
|
+
value?: unknown;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export declare interface SqueedConnection extends FlowEdgeProperties {
|
|
472
|
+
target: string;
|
|
473
|
+
id?: string;
|
|
474
|
+
label?: string;
|
|
475
|
+
color?: string;
|
|
476
|
+
style?: "solid" | "dashed" | "animated";
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export declare interface SqueedConnectionRef {
|
|
480
|
+
address: string;
|
|
481
|
+
key: string;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/** Schema keys that describe the edge *into* a node (parent → child) */
|
|
485
|
+
export declare type SqueedEdgeKey = "$sourceLabel" | "$isEdgeAnimated" | "$isEdgeDashed" | "$edgeColor";
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Squeed JSON = the source document `createFlowDiagram` compiles into nodes/edges.
|
|
489
|
+
* Node ids are JSON addresses ("root.a.b"); these helpers translate toolbar edits
|
|
490
|
+
* back into `$`-prefixed schema keys at that address. All functions are immutable.
|
|
491
|
+
*/
|
|
492
|
+
export declare type SqueedJson = Record<string, any> | any[];
|
|
493
|
+
|
|
494
|
+
/** Schema keys that live on a node */
|
|
495
|
+
export declare type SqueedNodeKey = "$label" | "$bgColor" | "$textColor" | "$borderColor" | "$borderRadius" | "$fontSize" | "$icon" | "$content" | "$media" | "$collapsed" | "$parent" | "$connections";
|
|
496
|
+
|
|
497
|
+
/** Immutable update of the node at `address` (root address updates the document itself) */
|
|
498
|
+
export declare function updateNode(json: SqueedJson, address: string, fn: (node: any) => any): SqueedJson;
|
|
499
|
+
|
|
500
|
+
export declare function useCustomColors(theme?: any): {
|
|
501
|
+
canvas: string;
|
|
502
|
+
background: string;
|
|
503
|
+
backgroundSecondary: string;
|
|
504
|
+
darkBackgroundSecondary: string;
|
|
505
|
+
border: string;
|
|
506
|
+
darkColor: string;
|
|
507
|
+
backgroundWhiteColor: string;
|
|
508
|
+
borderSecondary: string;
|
|
509
|
+
colorActive: string;
|
|
510
|
+
colorInactive: string;
|
|
511
|
+
iconColor: string;
|
|
512
|
+
moreIconColor: string;
|
|
513
|
+
colorText: string;
|
|
514
|
+
themedColorText: string;
|
|
515
|
+
logoColor: any;
|
|
516
|
+
logoColorSecondary: any;
|
|
517
|
+
darkColorActive: string;
|
|
518
|
+
greenColor: string;
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Hook that stops all event propagation on a DOM element.
|
|
523
|
+
* Use this on any interactive element inside a node (inputs, textareas, forms)
|
|
524
|
+
* to prevent cytoscape from intercepting mouse/keyboard events.
|
|
525
|
+
*
|
|
526
|
+
* @param active - Only attach listeners when true (e.g. when editing)
|
|
527
|
+
* @returns ref to attach to the wrapper element
|
|
528
|
+
*
|
|
529
|
+
* @example
|
|
530
|
+
* const inputRef = useStopPropagation<HTMLDivElement>(isEditing);
|
|
531
|
+
* return <div ref={inputRef}><input /></div>;
|
|
532
|
+
*/
|
|
533
|
+
export declare function useStopPropagation<T extends HTMLElement>(active?: boolean): MutableRefObject<T>;
|
|
534
|
+
|
|
535
|
+
export declare function useThemeContentColors(color: any): {
|
|
536
|
+
bgColor: any;
|
|
537
|
+
highlightColor: string;
|
|
538
|
+
borderColor: string;
|
|
539
|
+
textColor: string;
|
|
540
|
+
propertyColor: string;
|
|
541
|
+
secondary: string;
|
|
542
|
+
bgColorFaint: any;
|
|
543
|
+
highlightColorFaint: string;
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
declare interface ViewportState {
|
|
547
|
+
pan: Point;
|
|
548
|
+
zoom: number;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
export { }
|