@particle-academy/fancy-flow 0.2.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.
@@ -0,0 +1,226 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import { ReactNode, CSSProperties } from 'react';
4
+ import { ReactFlowProps, Edge, BackgroundVariant, NodeProps, NodeTypes } from '@xyflow/react';
5
+ import { F as FlowNode, a as FlowGraph, E as ExecutorRegistry } from './types-TemTtb04.js';
6
+ export { A as ActionNodeData, B as BaseNodeData, D as DecisionNodeData, b as FlowEdge, c as FlowNodeData, d as FlowNodeKind, N as NodeExecutor, e as NodeRunStatus, f as NoteNodeData, O as OutputNodeData, P as PortDescriptor, R as RunEvent, S as SubgraphNodeData, T as TriggerNodeData } from './types-TemTtb04.js';
7
+ import { WorkflowMetadata } from './schema/index.js';
8
+ export { ImportIssue, ImportOptions, ImportResult, WORKFLOW_SCHEMA_URL, WORKFLOW_SCHEMA_VERSION, WorkflowSchema, WorkflowSchemaEdge, WorkflowSchemaNode, exportWorkflow, importWorkflow, workflowToBlob } from './schema/index.js';
9
+ import { NodeCategory, NodeKindDefinition, ConfigField } from './registry/index.js';
10
+ export { BUILTIN_KINDS, RegistryNode, RenderBodyContext, buildNodeTypes, categoryAccent, defaultConfigFor, getNodeKind, listNodeKinds, onNodeKindsChanged, registerBuiltinKinds, registerNodeKind, validateConfig } from './registry/index.js';
11
+ import { FlowRunFeedEntry } from './runtime/index.js';
12
+ export { RunOptions, RunResult, UseFlowRunOptions, UseFlowRunReturn, UseFlowStateReturn, applyStatusesToNodes, runFlow, useFlowRun, useFlowState } from './runtime/index.js';
13
+
14
+ type FlowCanvasProps = Omit<ReactFlowProps<FlowNode, Edge>, "nodes" | "edges" | "height"> & {
15
+ nodes: FlowNode[];
16
+ edges: Edge[];
17
+ /** Background variant. Default: "dots". */
18
+ background?: BackgroundVariant | "none";
19
+ /** Show pan/zoom/fit controls. Default true. */
20
+ showControls?: boolean;
21
+ /** Show minimap. Default false (turn on for big graphs). */
22
+ showMinimap?: boolean;
23
+ /** Pixel height; FlowCanvas expects a sized container. Default 600. */
24
+ height?: number | string;
25
+ /** Optional toolbar / palette etc. rendered above the canvas. */
26
+ toolbar?: ReactNode;
27
+ className?: string;
28
+ style?: CSSProperties;
29
+ };
30
+ /**
31
+ * FlowCanvas — themed React Flow surface with the kit's nodes registered
32
+ * by default. Pass your own `nodeTypes` to extend; the kit's defaults are
33
+ * merged behind yours.
34
+ *
35
+ * Hosts wire `onNodesChange` / `onEdgesChange` / `onConnect` themselves
36
+ * (xyflow's standard pattern). The surrounding `useFlowState` hook in
37
+ * `runtime/use-flow-state.ts` is a convenience that wires those for you.
38
+ */
39
+ declare function FlowCanvas({ nodes, edges, background, showControls, showMinimap, height, toolbar, nodeTypes, edgeTypes, className, style, ...rest }: FlowCanvasProps): react_jsx_runtime.JSX.Element;
40
+
41
+ type FlowEditorProps = {
42
+ initial?: FlowGraph;
43
+ /** Controlled mode — host owns the graph state. When set, takes precedence
44
+ * over `initial`. Pair with `onChange` to receive edits. */
45
+ value?: FlowGraph;
46
+ /** Executor registry passed to runFlow. Each kind name maps to an executor. */
47
+ executors?: ExecutorRegistry;
48
+ /** Saved metadata for export. */
49
+ metadata?: WorkflowMetadata;
50
+ /** Show the palette sidebar. Default true. */
51
+ showPalette?: boolean;
52
+ /** Show the config panel sidebar. Default true. */
53
+ showPanel?: boolean;
54
+ /** Show run feed below the canvas. Default true. */
55
+ showFeed?: boolean;
56
+ /** Total editor height. Default 720. */
57
+ height?: number;
58
+ /** Optional toolbar content rendered next to the run controls. */
59
+ extraToolbar?: ReactNode;
60
+ /** Called whenever the graph changes — host can persist. */
61
+ onChange?: (graph: FlowGraph) => void;
62
+ className?: string;
63
+ style?: CSSProperties;
64
+ };
65
+ /**
66
+ * FlowEditor — opinionated, batteries-included workflow editor. Composes
67
+ * NodePalette + FlowCanvas + NodeConfigPanel + run controls + run feed
68
+ * with sensible defaults. Hosts that want à la carte can use the
69
+ * primitives directly.
70
+ */
71
+ declare function FlowEditor(props: FlowEditorProps): react_jsx_runtime.JSX.Element;
72
+
73
+ type NodePaletteProps = {
74
+ /** Filter to only these categories. */
75
+ categories?: NodeCategory[];
76
+ /** Called when the user clicks a kind (in addition to drag). Optional. */
77
+ onPick?: (kind: NodeKindDefinition) => void;
78
+ className?: string;
79
+ style?: CSSProperties;
80
+ };
81
+ /**
82
+ * NodePalette — sidebar listing every registered node kind, grouped by
83
+ * category. Drag a kind onto a `<FlowCanvas>` to add a new node — set
84
+ * `onDrop` on the canvas to handle the drop with the kind name from the
85
+ * `application/x-fancy-flow-kind` data type.
86
+ */
87
+ declare function NodePalette({ categories, onPick, className, style }: NodePaletteProps): react_jsx_runtime.JSX.Element;
88
+ /**
89
+ * useDropFromPalette — wires the canvas drop target. Returns the drop /
90
+ * dragOver handlers; they parse the dragged kind name and call `onDrop`
91
+ * with `(kindName, position)` in viewport coords.
92
+ */
93
+ declare function paletteDropHandlers(onDrop: (kindName: string, evt: React.DragEvent) => void): {
94
+ onDragOver: (e: React.DragEvent) => void;
95
+ onDrop: (e: React.DragEvent) => void;
96
+ };
97
+
98
+ type NodeConfigPanelProps = {
99
+ /** Currently-selected node — pass null to render the empty state. */
100
+ node: FlowNode | null;
101
+ /** Called when the user edits the node label, description, or config. */
102
+ onChange: (next: FlowNode) => void;
103
+ /** Optional header content (e.g. close button). */
104
+ header?: ReactNode;
105
+ /** Optional credential picker hook — host renders the picker. */
106
+ renderCredentialField?: (props: {
107
+ credentialType: string;
108
+ value: unknown;
109
+ onChange: (next: unknown) => void;
110
+ }) => ReactNode;
111
+ className?: string;
112
+ style?: React.CSSProperties;
113
+ };
114
+ /**
115
+ * NodeConfigPanel — schema-driven form for the selected node. Defers to
116
+ * `kind.renderPanel` if the kind opts out of the auto-form.
117
+ */
118
+ declare function NodeConfigPanel({ node, onChange, header, renderCredentialField, className, style, }: NodeConfigPanelProps): react_jsx_runtime.JSX.Element;
119
+
120
+ type ConfigFieldRendererProps = {
121
+ field: ConfigField;
122
+ value: unknown;
123
+ onChange: (value: unknown) => void;
124
+ renderCredentialField?: (props: {
125
+ credentialType: string;
126
+ value: unknown;
127
+ onChange: (next: unknown) => void;
128
+ }) => ReactNode;
129
+ };
130
+ /**
131
+ * ConfigFieldRenderer — dispatches to the right input element per field
132
+ * type. Plain HTML inputs styled via the package's CSS so the package
133
+ * stays standalone (no react-fancy import required).
134
+ *
135
+ * Hosts that want to use react-fancy form components can supply their
136
+ * own field renderers via the kind's `renderPanel`.
137
+ */
138
+ declare function ConfigFieldRenderer({ field, value, onChange, renderCredentialField }: ConfigFieldRendererProps): react_jsx_runtime.JSX.Element | null;
139
+
140
+ /** Entry-point node — outputs only, no inputs. */
141
+ declare function TriggerNodeInner(props: NodeProps<FlowNode>): react_jsx_runtime.JSX.Element;
142
+ declare const TriggerNode: react.MemoExoticComponent<typeof TriggerNodeInner>;
143
+
144
+ /** General-purpose work node — inputs and outputs. */
145
+ declare function ActionNodeInner(props: NodeProps<FlowNode>): react_jsx_runtime.JSX.Element;
146
+ declare const ActionNode: react.MemoExoticComponent<typeof ActionNodeInner>;
147
+
148
+ /** Branching node — multiple typed outputs, one input. */
149
+ declare function DecisionNodeInner(props: NodeProps<FlowNode>): react_jsx_runtime.JSX.Element;
150
+ declare const DecisionNode: react.MemoExoticComponent<typeof DecisionNodeInner>;
151
+
152
+ /** Terminal node — receives the workflow's final result; no outputs. */
153
+ declare function OutputNodeInner(props: NodeProps<FlowNode>): react_jsx_runtime.JSX.Element;
154
+ declare const OutputNode: react.MemoExoticComponent<typeof OutputNodeInner>;
155
+
156
+ /**
157
+ * NoteNode — annotation card with no ports. Useful for documenting graphs.
158
+ * Body is plain text; hosts can wire onChange via the editor's onNodesChange
159
+ * if they want it editable.
160
+ */
161
+ declare function NoteNodeInner({ data, selected }: NodeProps<FlowNode>): react_jsx_runtime.JSX.Element;
162
+ declare const NoteNode: react.MemoExoticComponent<typeof NoteNodeInner>;
163
+
164
+ /**
165
+ * SubgraphNode — collapses a group of nodes behind a single facade with
166
+ * inputs and outputs that map to the inner graph's boundary ports. The
167
+ * runtime treats it like an action node: when running, it dispatches to
168
+ * the registered "subgraph" executor (host decides expand vs inline).
169
+ *
170
+ * v0.1 just renders the facade. Expand/collapse interactions and inner-
171
+ * graph editing are deferred — host apps can implement those by toggling
172
+ * `data.collapsed` and rendering a nested <FlowCanvas> when expanded.
173
+ */
174
+ declare function SubgraphNodeInner(props: NodeProps<FlowNode>): react_jsx_runtime.JSX.Element;
175
+ declare const SubgraphNode: react.MemoExoticComponent<typeof SubgraphNodeInner>;
176
+
177
+ type NodeShellProps = {
178
+ /** Required: the xyflow node this is rendering. */
179
+ node: NodeProps<FlowNode>;
180
+ /** Accent color for the title bar / status ring. */
181
+ accent: string;
182
+ /** Tag/label shown to the left of the title (e.g. "TRIGGER", "ACTION"). */
183
+ tag: string;
184
+ /** Optional icon glyph (single-character string is fine). */
185
+ icon?: ReactNode;
186
+ /** Whether to show input handles on the left. Defaults true. */
187
+ showInputs?: boolean;
188
+ /** Whether to show output handles on the right. Defaults true. */
189
+ showOutputs?: boolean;
190
+ /** Body content under the title bar. */
191
+ children?: ReactNode;
192
+ };
193
+ /**
194
+ * Shared chrome for every kit node — title bar, accent border, status ring,
195
+ * port handles. Specific node kinds compose this with their body content.
196
+ */
197
+ declare function NodeShellInner({ node, accent, tag, icon, showInputs, showOutputs, children, }: NodeShellProps): react_jsx_runtime.JSX.Element;
198
+ declare const NodeShell: react.MemoExoticComponent<typeof NodeShellInner>;
199
+
200
+ /**
201
+ * Default xyflow `nodeTypes` map covering the kit. Spread into your own:
202
+ *
203
+ * <FlowCanvas nodeTypes={{ ...defaultNodeTypes, custom: MyNode }} ... />
204
+ */
205
+ declare const defaultNodeTypes: NodeTypes;
206
+
207
+ type FlowRunControlsProps = {
208
+ running: boolean;
209
+ onRun: () => void;
210
+ onCancel?: () => void;
211
+ onReset?: () => void;
212
+ className?: string;
213
+ style?: CSSProperties;
214
+ };
215
+ /** FlowRunControls — Run / Cancel / Reset buttons. Wire to a `useFlowRun`. */
216
+ declare function FlowRunControls({ running, onRun, onCancel, onReset, className, style }: FlowRunControlsProps): react_jsx_runtime.JSX.Element;
217
+
218
+ type FlowRunFeedProps = {
219
+ entries: FlowRunFeedEntry[];
220
+ className?: string;
221
+ style?: CSSProperties;
222
+ };
223
+ /** FlowRunFeed — scrolling log panel. Auto-scrolls to bottom on new entries. */
224
+ declare function FlowRunFeed({ entries, className, style }: FlowRunFeedProps): react_jsx_runtime.JSX.Element;
225
+
226
+ export { ActionNode, ConfigField, ConfigFieldRenderer, type ConfigFieldRendererProps, DecisionNode, ExecutorRegistry, FlowCanvas, type FlowCanvasProps, FlowEditor, type FlowEditorProps, FlowGraph, FlowNode, FlowRunControls, type FlowRunControlsProps, FlowRunFeed, FlowRunFeedEntry, type FlowRunFeedProps, NodeCategory, NodeConfigPanel, type NodeConfigPanelProps, NodeKindDefinition, NodePalette, type NodePaletteProps, NodeShell, type NodeShellProps, NoteNode, OutputNode, SubgraphNode, TriggerNode, WorkflowMetadata, defaultNodeTypes, paletteDropHandlers };