@particle-academy/fancy-flow 0.22.0 → 0.23.0

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.d.cts CHANGED
@@ -7,6 +7,8 @@ import { a as FlowNode, F as FlowGraph, e as NodeRunStatus, E as ExecutorRegistr
7
7
  export { A as ActionNodeData, B as BaseNodeData, D as DecisionNodeData, b as FlowEdge, c as FlowNodeData, d as FlowNodeKind, N as NodeExecutor, f as NoteNodeData, O as OutputNodeData, P as PortDescriptor, R as RunEvent, S as SubgraphNodeData, T as TriggerNodeData } from './types-CMSrWVYM.cjs';
8
8
  import { WorkflowSchema, WorkflowMetadata } from './schema/index.cjs';
9
9
  export { ImportIssue, ImportOptions, ImportResult, WORKFLOW_SCHEMA_URL, WORKFLOW_SCHEMA_VERSION, WorkflowSchemaEdge, WorkflowSchemaNode, exportWorkflow, importWorkflow, migrateSchema, workflowToBlob } from './schema/index.cjs';
10
+ import { AutoLayoutOptions } from './layout/index.cjs';
11
+ export { AutoLayoutDirection } from './layout/index.cjs';
10
12
  import { N as NodeCategory, a as NodeKindDefinition, C as ConfigField } from './types-DneUoivl.cjs';
11
13
  export { D as DocumentConfigField, K as KeyValueConfigField, P as PortSpec, R as RenderBodyContext, d as RepeaterConfigField, e as RepeaterRowField } from './types-DneUoivl.cjs';
12
14
  import { FlowRunFeedEntry } from './runtime/index.cjs';
@@ -142,6 +144,10 @@ type FlowEditorApi = {
142
144
  assignToLane: (nodeId: string, laneId: string) => void;
143
145
  /** Remove a node from its lane (restores its absolute position). */
144
146
  removeFromLane: (nodeId: string) => void;
147
+ /** Auto-arrange the graph (or a lane's children) into a tidy DAG layout. */
148
+ autoLayout: (options?: AutoLayoutOptions) => void;
149
+ /** Tidy just one lane's children. */
150
+ tidyLane: (laneId: string) => void;
145
151
  /** Copy the current selection to the editor clipboard. */
146
152
  copy: () => void;
147
153
  /** Copy then delete the current selection. */
@@ -200,6 +206,8 @@ type FlowEditorBuiltins = {
200
206
  history?: boolean;
201
207
  /** "Add lane" toolbar button. Default true. */
202
208
  addLane?: boolean;
209
+ /** "Tidy" (auto-layout) toolbar button. Default true. */
210
+ autoLayout?: boolean;
203
211
  /** Right-click a node for Delete / Duplicate. Default true. */
204
212
  contextMenu?: boolean;
205
213
  /** Right-click a connection for Label / Delete. Default true. */
@@ -539,4 +547,4 @@ type FlowRunFeedProps = {
539
547
  /** FlowRunFeed — scrolling log panel. Auto-scrolls to bottom on new entries. */
540
548
  declare function FlowRunFeed({ entries, className, style }: FlowRunFeedProps): react.JSX.Element;
541
549
 
542
- export { ActionNode, type AlignEdge, ConfigField, ConfigFieldRenderer, type ConfigFieldRendererProps, ConnectionValidatorOptions, DecisionNode, ExecutorRegistry, FlowCanvas, type FlowCanvasProps, FlowEditor, type FlowEditorAction, type FlowEditorApi, type FlowEditorBuiltins, type FlowEditorProps, type FlowEditorSlots, FlowGraph, FlowNode, type FlowNodeRenderProps, FlowRunControls, type FlowRunControlsProps, FlowRunFeed, FlowRunFeedEntry, type FlowRunFeedProps, LaneNode, NodeCategory, NodeConfigPanel, type NodeConfigPanelProps, NodeKindDefinition, NodePalette, type NodePaletteProps, NodePort, type NodePortProps, type NodePortSide, type NodePortType, NodeRunStatus, NodeShell, type NodeShellProps, NoteNode, OutputNode, SubgraphNode, TriggerNode, WorkflowMetadata, WorkflowSchema, alignNodes, cloneSubgraph, defaultNodeTypes, defineNode, distributeNodes, paletteDropHandlers, reconnectEdge, useFlowEditor, useFlowEditorOptional };
550
+ export { ActionNode, type AlignEdge, AutoLayoutOptions, ConfigField, ConfigFieldRenderer, type ConfigFieldRendererProps, ConnectionValidatorOptions, DecisionNode, ExecutorRegistry, FlowCanvas, type FlowCanvasProps, FlowEditor, type FlowEditorAction, type FlowEditorApi, type FlowEditorBuiltins, type FlowEditorProps, type FlowEditorSlots, FlowGraph, FlowNode, type FlowNodeRenderProps, FlowRunControls, type FlowRunControlsProps, FlowRunFeed, FlowRunFeedEntry, type FlowRunFeedProps, LaneNode, NodeCategory, NodeConfigPanel, type NodeConfigPanelProps, NodeKindDefinition, NodePalette, type NodePaletteProps, NodePort, type NodePortProps, type NodePortSide, type NodePortType, NodeRunStatus, NodeShell, type NodeShellProps, NoteNode, OutputNode, SubgraphNode, TriggerNode, WorkflowMetadata, WorkflowSchema, alignNodes, cloneSubgraph, defaultNodeTypes, defineNode, distributeNodes, paletteDropHandlers, reconnectEdge, useFlowEditor, useFlowEditorOptional };
package/dist/index.d.ts CHANGED
@@ -7,6 +7,8 @@ import { a as FlowNode, F as FlowGraph, e as NodeRunStatus, E as ExecutorRegistr
7
7
  export { A as ActionNodeData, B as BaseNodeData, D as DecisionNodeData, b as FlowEdge, c as FlowNodeData, d as FlowNodeKind, N as NodeExecutor, f as NoteNodeData, O as OutputNodeData, P as PortDescriptor, R as RunEvent, S as SubgraphNodeData, T as TriggerNodeData } from './types-CMSrWVYM.js';
8
8
  import { WorkflowSchema, WorkflowMetadata } from './schema/index.js';
9
9
  export { ImportIssue, ImportOptions, ImportResult, WORKFLOW_SCHEMA_URL, WORKFLOW_SCHEMA_VERSION, WorkflowSchemaEdge, WorkflowSchemaNode, exportWorkflow, importWorkflow, migrateSchema, workflowToBlob } from './schema/index.js';
10
+ import { AutoLayoutOptions } from './layout/index.js';
11
+ export { AutoLayoutDirection } from './layout/index.js';
10
12
  import { N as NodeCategory, a as NodeKindDefinition, C as ConfigField } from './types-CFEtuRWJ.js';
11
13
  export { D as DocumentConfigField, K as KeyValueConfigField, P as PortSpec, R as RenderBodyContext, d as RepeaterConfigField, e as RepeaterRowField } from './types-CFEtuRWJ.js';
12
14
  import { FlowRunFeedEntry } from './runtime/index.js';
@@ -142,6 +144,10 @@ type FlowEditorApi = {
142
144
  assignToLane: (nodeId: string, laneId: string) => void;
143
145
  /** Remove a node from its lane (restores its absolute position). */
144
146
  removeFromLane: (nodeId: string) => void;
147
+ /** Auto-arrange the graph (or a lane's children) into a tidy DAG layout. */
148
+ autoLayout: (options?: AutoLayoutOptions) => void;
149
+ /** Tidy just one lane's children. */
150
+ tidyLane: (laneId: string) => void;
145
151
  /** Copy the current selection to the editor clipboard. */
146
152
  copy: () => void;
147
153
  /** Copy then delete the current selection. */
@@ -200,6 +206,8 @@ type FlowEditorBuiltins = {
200
206
  history?: boolean;
201
207
  /** "Add lane" toolbar button. Default true. */
202
208
  addLane?: boolean;
209
+ /** "Tidy" (auto-layout) toolbar button. Default true. */
210
+ autoLayout?: boolean;
203
211
  /** Right-click a node for Delete / Duplicate. Default true. */
204
212
  contextMenu?: boolean;
205
213
  /** Right-click a connection for Label / Delete. Default true. */
@@ -539,4 +547,4 @@ type FlowRunFeedProps = {
539
547
  /** FlowRunFeed — scrolling log panel. Auto-scrolls to bottom on new entries. */
540
548
  declare function FlowRunFeed({ entries, className, style }: FlowRunFeedProps): react.JSX.Element;
541
549
 
542
- export { ActionNode, type AlignEdge, ConfigField, ConfigFieldRenderer, type ConfigFieldRendererProps, ConnectionValidatorOptions, DecisionNode, ExecutorRegistry, FlowCanvas, type FlowCanvasProps, FlowEditor, type FlowEditorAction, type FlowEditorApi, type FlowEditorBuiltins, type FlowEditorProps, type FlowEditorSlots, FlowGraph, FlowNode, type FlowNodeRenderProps, FlowRunControls, type FlowRunControlsProps, FlowRunFeed, FlowRunFeedEntry, type FlowRunFeedProps, LaneNode, NodeCategory, NodeConfigPanel, type NodeConfigPanelProps, NodeKindDefinition, NodePalette, type NodePaletteProps, NodePort, type NodePortProps, type NodePortSide, type NodePortType, NodeRunStatus, NodeShell, type NodeShellProps, NoteNode, OutputNode, SubgraphNode, TriggerNode, WorkflowMetadata, WorkflowSchema, alignNodes, cloneSubgraph, defaultNodeTypes, defineNode, distributeNodes, paletteDropHandlers, reconnectEdge, useFlowEditor, useFlowEditorOptional };
550
+ export { ActionNode, type AlignEdge, AutoLayoutOptions, ConfigField, ConfigFieldRenderer, type ConfigFieldRendererProps, ConnectionValidatorOptions, DecisionNode, ExecutorRegistry, FlowCanvas, type FlowCanvasProps, FlowEditor, type FlowEditorAction, type FlowEditorApi, type FlowEditorBuiltins, type FlowEditorProps, type FlowEditorSlots, FlowGraph, FlowNode, type FlowNodeRenderProps, FlowRunControls, type FlowRunControlsProps, FlowRunFeed, FlowRunFeedEntry, type FlowRunFeedProps, LaneNode, NodeCategory, NodeConfigPanel, type NodeConfigPanelProps, NodeKindDefinition, NodePalette, type NodePaletteProps, NodePort, type NodePortProps, type NodePortSide, type NodePortType, NodeRunStatus, NodeShell, type NodeShellProps, NoteNode, OutputNode, SubgraphNode, TriggerNode, WorkflowMetadata, WorkflowSchema, alignNodes, cloneSubgraph, defaultNodeTypes, defineNode, distributeNodes, paletteDropHandlers, reconnectEdge, useFlowEditor, useFlowEditorOptional };
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { useFlowState, useFlowRun, useFlowHistory, applyStatusesToNodes } from './chunk-O7F6SGV4.js';
2
2
  export { applyStatusesToNodes, createHistory, useFlowHistory, useFlowRun, useFlowState } from './chunk-O7F6SGV4.js';
3
- import { buildNodeTypes, registerBuiltinKinds, createConnectionValidator } from './chunk-YZTBRXBZ.js';
4
- export { ANY_PORT_TYPE, BUILTIN_KINDS, LaneNode, RegistryNode, buildNodeTypes, createConnectionValidator, defaultPortCompatibility, registerBuiltinKinds } from './chunk-YZTBRXBZ.js';
3
+ import { buildNodeTypes, registerBuiltinKinds, createConnectionValidator } from './chunk-AUL4LU63.js';
4
+ export { ANY_PORT_TYPE, BUILTIN_KINDS, LaneNode, RegistryNode, buildNodeTypes, createConnectionValidator, defaultPortCompatibility, registerBuiltinKinds } from './chunk-AUL4LU63.js';
5
5
  import { ReactFlowProvider, useReactFlow, addEdge, applyEdgeChanges, applyNodeChanges, Position, Handle, reconnectEdge, index, BackgroundVariant, Background, Controls, MiniMap } from './chunk-ZB4HHQMR.js';
6
6
  export { LEGACY_PAUSE_PREFIXES, PAUSE_PREFIX, decodePause, encodePause, isPause, pauseForHuman } from './chunk-UEOE6B52.js';
7
+ import './chunk-USL4FMFU.js';
7
8
  export { runFlow } from './chunk-KDHLKBL2.js';
8
9
  import { workflowToBlob, importWorkflow, exportWorkflow } from './chunk-OHVSEHDC.js';
9
10
  export { WORKFLOW_SCHEMA_URL, WORKFLOW_SCHEMA_VERSION, exportWorkflow, importWorkflow, migrateSchema, workflowToBlob } from './chunk-OHVSEHDC.js';
@@ -12,7 +13,6 @@ import { onNodeKindsChanged, listNodeKinds, getNodeKind, defaultConfigFor, valid
12
13
  export { categoryAccent, defaultConfigFor, getNodeKind, listNodeKinds, onNodeKindsChanged, registerNodeKind, validateConfig } from './chunk-YXRLIV7A.js';
13
14
  import { getRichInputAdapter } from './chunk-F5RPRB7A.js';
14
15
  export { RichInputPreview, getRichInputAdapter, isRichInputEnabled, onRichInputAdapterChanged, registerRichInputAdapter } from './chunk-F5RPRB7A.js';
15
- import './chunk-USL4FMFU.js';
16
16
  import { memo, createContext, forwardRef, useState, useEffect, useMemo, useCallback, useRef, useImperativeHandle, useContext } from 'react';
17
17
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
18
18
 
@@ -1279,6 +1279,18 @@ function FlowEditorInner({
1279
1279
  addLane,
1280
1280
  assignToLane: (nodeId, laneId) => flow.setNodes((all) => assignToLane(all, nodeId, laneId)),
1281
1281
  removeFromLane: (nodeId) => flow.setNodes((all) => removeFromLane(all, nodeId)),
1282
+ // dagre is loaded lazily so it stays out of the eager bundle — consumers
1283
+ // who never tidy pay nothing for it.
1284
+ autoLayout: (opts) => {
1285
+ void import('./layout.js').then(
1286
+ ({ autoLayout }) => flow.setGraph({ nodes: autoLayout({ nodes: flow.nodes, edges: flow.edges }, opts), edges: flow.edges })
1287
+ );
1288
+ },
1289
+ tidyLane: (laneId) => {
1290
+ void import('./layout.js').then(
1291
+ ({ autoLayout }) => flow.setGraph({ nodes: autoLayout({ nodes: flow.nodes, edges: flow.edges }, { scope: laneId }), edges: flow.edges })
1292
+ );
1293
+ },
1282
1294
  run: () => runner.run({ nodes: flow.nodes, edges: flow.edges }, executors),
1283
1295
  cancel: runner.cancel,
1284
1296
  reset: runner.reset,
@@ -1331,6 +1343,7 @@ function FlowEditorInner({
1331
1343
  /* @__PURE__ */ jsx("span", { className: "ff-editor__sep" }),
1332
1344
  /* @__PURE__ */ jsx("button", { className: "ff-editor__btn", "data-action": "add-lane", title: "Add a swimlane", onClick: () => api.addLane(), children: "\u25A4 Lane" })
1333
1345
  ] }),
1346
+ builtins.autoLayout !== false && /* @__PURE__ */ jsx("button", { className: "ff-editor__btn", "data-action": "auto-layout", title: "Tidy \u2014 auto-arrange", onClick: () => api.autoLayout(), children: "\u2922 Tidy" }),
1334
1347
  (builtins.export !== false || builtins.import !== false) && /* @__PURE__ */ jsx("span", { className: "ff-editor__sep" }),
1335
1348
  builtins.export !== false && /* @__PURE__ */ jsx("button", { className: "ff-editor__btn", "data-action": "export", onClick: api.exportWorkflow, children: "\u2193 Export" }),
1336
1349
  builtins.import !== false && /* @__PURE__ */ jsx("button", { className: "ff-editor__btn", "data-action": "import", onClick: api.importWorkflow, children: "\u2191 Import" }),