@mindlogic-ai/logician-ui 4.0.0-alpha.36 → 4.0.0-alpha.37
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/components/Form/FormSection/CollapsibleFormSection.js +1 -0
- package/dist/components/Form/FormSection/CollapsibleFormSection.js.map +1 -1
- package/dist/components/Form/FormSection/CollapsibleFormSection.mjs +1 -0
- package/dist/components/Form/FormSection/CollapsibleFormSection.mjs.map +1 -1
- package/dist/components/Workflow/Workflow.d.ts +1 -1
- package/dist/components/Workflow/Workflow.d.ts.map +1 -1
- package/dist/components/Workflow/Workflow.js +2 -2
- package/dist/components/Workflow/Workflow.js.map +1 -1
- package/dist/components/Workflow/Workflow.mjs +2 -2
- package/dist/components/Workflow/Workflow.mjs.map +1 -1
- package/dist/components/Workflow/Workflow.types.d.ts +9 -0
- package/dist/components/Workflow/Workflow.types.d.ts.map +1 -1
- package/dist/components/Workflow/Workflow.types.js.map +1 -1
- package/dist/components/Workflow/Workflow.types.mjs.map +1 -1
- package/dist/components/Workflow/canvas/Canvas/Canvas.d.ts +6 -2
- package/dist/components/Workflow/canvas/Canvas/Canvas.d.ts.map +1 -1
- package/dist/components/Workflow/canvas/Canvas/Canvas.js +29 -23
- package/dist/components/Workflow/canvas/Canvas/Canvas.js.map +1 -1
- package/dist/components/Workflow/canvas/Canvas/Canvas.mjs +31 -25
- package/dist/components/Workflow/canvas/Canvas/Canvas.mjs.map +1 -1
- package/dist/components/Workflow/createNode.d.ts +25 -1
- package/dist/components/Workflow/createNode.d.ts.map +1 -1
- package/dist/components/Workflow/createNode.js +39 -1
- package/dist/components/Workflow/createNode.js.map +1 -1
- package/dist/components/Workflow/createNode.mjs +38 -2
- package/dist/components/Workflow/createNode.mjs.map +1 -1
- package/dist/components/Workflow/index.d.ts +2 -0
- package/dist/components/Workflow/index.d.ts.map +1 -1
- package/dist/components/Workflow/layout/autoLayout.d.ts +10 -0
- package/dist/components/Workflow/layout/autoLayout.d.ts.map +1 -1
- package/dist/components/Workflow/layout/autoLayout.js +4 -0
- package/dist/components/Workflow/layout/autoLayout.js.map +1 -1
- package/dist/components/Workflow/layout/autoLayout.mjs +1 -1
- package/dist/components/Workflow/layout/autoLayout.mjs.map +1 -1
- package/dist/components/Workflow/placement.d.ts +65 -0
- package/dist/components/Workflow/placement.d.ts.map +1 -0
- package/dist/components/Workflow/placement.js +100 -0
- package/dist/components/Workflow/placement.js.map +1 -0
- package/dist/components/Workflow/placement.mjs +96 -0
- package/dist/components/Workflow/placement.mjs.map +1 -0
- package/dist/components/Workflow/useWorkflowActions.d.ts +54 -0
- package/dist/components/Workflow/useWorkflowActions.d.ts.map +1 -0
- package/dist/components/Workflow/useWorkflowActions.js +105 -0
- package/dist/components/Workflow/useWorkflowActions.js.map +1 -0
- package/dist/components/Workflow/useWorkflowActions.mjs +103 -0
- package/dist/components/Workflow/useWorkflowActions.mjs.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/Workflow/README.md +64 -0
- package/src/components/Workflow/Workflow.tsx +2 -0
- package/src/components/Workflow/Workflow.types.ts +10 -0
- package/src/components/Workflow/canvas/Canvas/Canvas.tsx +57 -53
- package/src/components/Workflow/createNode.test.ts +40 -2
- package/src/components/Workflow/createNode.ts +70 -2
- package/src/components/Workflow/index.ts +8 -0
- package/src/components/Workflow/layout/autoLayout.ts +4 -4
- package/src/components/Workflow/placement.test.ts +156 -0
- package/src/components/Workflow/placement.ts +172 -0
- package/src/components/Workflow/stories/Workflow.stories.tsx +79 -0
- package/src/components/Workflow/useWorkflowActions.test.tsx +345 -0
- package/src/components/Workflow/useWorkflowActions.ts +196 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GraphNode } from './Workflow.types';
|
|
1
|
+
import type { GraphNode, NodeTypeDef, Position, WorkflowTranslate } from './Workflow.types';
|
|
2
2
|
/**
|
|
3
3
|
* Unique id for edges and other internal graph elements that aren't referenced
|
|
4
4
|
* by name in user content. Node IDs use `nextNodeId` for memorable
|
|
@@ -24,4 +24,28 @@ export declare function nextNodeId(kind: string, nodes: ReadonlyArray<GraphNode>
|
|
|
24
24
|
* — one missing duplicate, no corrupt state.
|
|
25
25
|
*/
|
|
26
26
|
export declare function cloneNode(node: GraphNode, nodes: ReadonlyArray<GraphNode>): GraphNode;
|
|
27
|
+
/** String-only translator handed to `NodeTypeDef.localizeDefaults`. */
|
|
28
|
+
export type DefaultsTranslate = (key: string, params?: Record<string, string>) => string;
|
|
29
|
+
/**
|
|
30
|
+
* Tear the string lookup off the host translator so `localizeDefaults` doesn't
|
|
31
|
+
* depend on the React-fragment interpolation path.
|
|
32
|
+
*/
|
|
33
|
+
export declare function toDefaultsTranslate(translate: WorkflowTranslate): DefaultsTranslate;
|
|
34
|
+
/**
|
|
35
|
+
* Build a fresh node of `def`'s kind — the ONE place a node is created from a
|
|
36
|
+
* node type, shared by the palette drop and `useWorkflowActions().addNode`, so
|
|
37
|
+
* both paths produce the same id and starting config:
|
|
38
|
+
*
|
|
39
|
+
* - id: `nextNodeId` (`{kind}_{N}`), so authors can type it into `{{...}}`
|
|
40
|
+
* references — the same scheme duplicate/paste use;
|
|
41
|
+
* - config: `defaultConfig`, then `localizeDefaults(translate)`, then
|
|
42
|
+
* `hostDefaults(hostBridge)`, each shallow-merged over the previous.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createNodeFromType(def: NodeTypeDef, { position, nodes, translate, hostBridge, }: {
|
|
45
|
+
position: Position;
|
|
46
|
+
/** Current node list — continues the per-kind id counter. */
|
|
47
|
+
nodes: ReadonlyArray<GraphNode>;
|
|
48
|
+
translate: DefaultsTranslate;
|
|
49
|
+
hostBridge?: unknown;
|
|
50
|
+
}): GraphNode;
|
|
27
51
|
//# sourceMappingURL=createNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNode.d.ts","sourceRoot":"","sources":["../../../src/components/Workflow/createNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"createNode.d.ts","sourceRoot":"","sources":["../../../src/components/Workflow/createNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,QAAQ,EACR,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAG1B;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAO5C;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,GAC9B,MAAM,CAeR;AAKD;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,GAC9B,SAAS,CAUX;AAED,uEAAuE;AACvE,MAAM,MAAM,iBAAiB,GAAG,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC5B,MAAM,CAAC;AAEZ;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,iBAAiB,GAC3B,iBAAiB,CAEnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,WAAW,EAChB,EACE,QAAQ,EACR,KAAK,EACL,SAAS,EACT,UAAU,GACX,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,6DAA6D;IAC7D,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAChC,SAAS,EAAE,iBAAiB,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GACA,SAAS,CAiBX"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
var Workflow_types = require('./Workflow.types.js');
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Unique id for edges and other internal graph elements that aren't referenced
|
|
6
8
|
* by name in user content. Node IDs use `nextNodeId` for memorable
|
|
@@ -27,7 +29,10 @@ function genId(prefix) {
|
|
|
27
29
|
function nextNodeId(kind, nodes) {
|
|
28
30
|
if (kind === 'start')
|
|
29
31
|
return 'start';
|
|
30
|
-
|
|
32
|
+
// Escape the kind: namespaced kinds (`math.add`) would otherwise read `.` as
|
|
33
|
+
// a wildcard and count unrelated ids toward the counter.
|
|
34
|
+
const escaped = kind.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
35
|
+
const re = new RegExp(`^${escaped}_(\\d+)$`);
|
|
31
36
|
let max = 0;
|
|
32
37
|
for (const n of nodes) {
|
|
33
38
|
const m = re.exec(n.id);
|
|
@@ -59,8 +64,41 @@ function cloneNode(node, nodes) {
|
|
|
59
64
|
config: structuredClone(node.config),
|
|
60
65
|
};
|
|
61
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Tear the string lookup off the host translator so `localizeDefaults` doesn't
|
|
69
|
+
* depend on the React-fragment interpolation path.
|
|
70
|
+
*/
|
|
71
|
+
function toDefaultsTranslate(translate) {
|
|
72
|
+
return (key, params) => translate(key, params);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Build a fresh node of `def`'s kind — the ONE place a node is created from a
|
|
76
|
+
* node type, shared by the palette drop and `useWorkflowActions().addNode`, so
|
|
77
|
+
* both paths produce the same id and starting config:
|
|
78
|
+
*
|
|
79
|
+
* - id: `nextNodeId` (`{kind}_{N}`), so authors can type it into `{{...}}`
|
|
80
|
+
* references — the same scheme duplicate/paste use;
|
|
81
|
+
* - config: `defaultConfig`, then `localizeDefaults(translate)`, then
|
|
82
|
+
* `hostDefaults(hostBridge)`, each shallow-merged over the previous.
|
|
83
|
+
*/
|
|
84
|
+
function createNodeFromType(def, { position, nodes, translate, hostBridge, }) {
|
|
85
|
+
const base = Workflow_types.resolveDefaultConfig(def);
|
|
86
|
+
const overlay = def.localizeDefaults?.(translate);
|
|
87
|
+
// Host-data overlay (e.g. a starting LLM picked from the tenant's live model
|
|
88
|
+
// list) — applied last so it wins over any static placeholder in
|
|
89
|
+
// `defaultConfig`. Absent on a generic host, leaving the static defaults.
|
|
90
|
+
const bridged = def.hostDefaults?.(hostBridge);
|
|
91
|
+
return {
|
|
92
|
+
id: nextNodeId(def.kind, nodes),
|
|
93
|
+
kind: def.kind,
|
|
94
|
+
position,
|
|
95
|
+
config: { ...base, ...overlay, ...bridged },
|
|
96
|
+
};
|
|
97
|
+
}
|
|
62
98
|
|
|
63
99
|
exports.cloneNode = cloneNode;
|
|
100
|
+
exports.createNodeFromType = createNodeFromType;
|
|
64
101
|
exports.genId = genId;
|
|
65
102
|
exports.nextNodeId = nextNodeId;
|
|
103
|
+
exports.toDefaultsTranslate = toDefaultsTranslate;
|
|
66
104
|
//# sourceMappingURL=createNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNode.js","sources":["../../../src/components/Workflow/createNode.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createNode.js","sources":["../../../src/components/Workflow/createNode.ts"],"sourcesContent":[null],"names":["resolveDefaultConfig"],"mappings":";;;;;AAQA;;;;AAIG;AACG,SAAU,KAAK,CAAC,MAAc,EAAA;IAClC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,YAAY,IAAI,MAAM,EAAE;QAC3D,OAAO,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,MAAM,CAAC,UAAU,EAAE,EAAE;IAC3C;AACA,IAAA,OAAO,GAAG,MAAM,CAAA,CAAA,EAAI,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA,CAAA,EAAI,IAAI,CAAC,MAAM;SACvD,QAAQ,CAAC,EAAE;AACX,SAAA,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAA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AAGG;AACG,SAAU,mBAAmB,CACjC,SAA4B,EAAA;AAE5B,IAAA,OAAO,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,CAAC,GAAG,EAAE,MAAM,CAAW;AAC1D;AAEA;;;;;;;;;AASG;AACG,SAAU,kBAAkB,CAChC,GAAgB,EAChB,EACE,QAAQ,EACR,KAAK,EACL,SAAS,EACT,UAAU,GAOX,EAAA;AAED,IAAA,MAAM,IAAI,GAAGA,mCAAoB,CAAC,GAAG,CAA4B;IACjE,MAAM,OAAO,GAAG,GAAG,CAAC,gBAAgB,GAAG,SAAS,CAEnC;;;;IAIb,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,GAAG,UAAU,CAEhC;IACb,OAAO;QACL,EAAE,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC;QAC/B,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,QAAQ;QACR,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,EAAE,GAAG,OAAO,EAAE;KAC5C;AACH;;;;;;;;"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { resolveDefaultConfig } from './Workflow.types.mjs';
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
5
|
* Unique id for edges and other internal graph elements that aren't referenced
|
|
4
6
|
* by name in user content. Node IDs use `nextNodeId` for memorable
|
|
@@ -25,7 +27,10 @@ function genId(prefix) {
|
|
|
25
27
|
function nextNodeId(kind, nodes) {
|
|
26
28
|
if (kind === 'start')
|
|
27
29
|
return 'start';
|
|
28
|
-
|
|
30
|
+
// Escape the kind: namespaced kinds (`math.add`) would otherwise read `.` as
|
|
31
|
+
// a wildcard and count unrelated ids toward the counter.
|
|
32
|
+
const escaped = kind.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
33
|
+
const re = new RegExp(`^${escaped}_(\\d+)$`);
|
|
29
34
|
let max = 0;
|
|
30
35
|
for (const n of nodes) {
|
|
31
36
|
const m = re.exec(n.id);
|
|
@@ -57,6 +62,37 @@ function cloneNode(node, nodes) {
|
|
|
57
62
|
config: structuredClone(node.config),
|
|
58
63
|
};
|
|
59
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Tear the string lookup off the host translator so `localizeDefaults` doesn't
|
|
67
|
+
* depend on the React-fragment interpolation path.
|
|
68
|
+
*/
|
|
69
|
+
function toDefaultsTranslate(translate) {
|
|
70
|
+
return (key, params) => translate(key, params);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Build a fresh node of `def`'s kind — the ONE place a node is created from a
|
|
74
|
+
* node type, shared by the palette drop and `useWorkflowActions().addNode`, so
|
|
75
|
+
* both paths produce the same id and starting config:
|
|
76
|
+
*
|
|
77
|
+
* - id: `nextNodeId` (`{kind}_{N}`), so authors can type it into `{{...}}`
|
|
78
|
+
* references — the same scheme duplicate/paste use;
|
|
79
|
+
* - config: `defaultConfig`, then `localizeDefaults(translate)`, then
|
|
80
|
+
* `hostDefaults(hostBridge)`, each shallow-merged over the previous.
|
|
81
|
+
*/
|
|
82
|
+
function createNodeFromType(def, { position, nodes, translate, hostBridge, }) {
|
|
83
|
+
const base = resolveDefaultConfig(def);
|
|
84
|
+
const overlay = def.localizeDefaults?.(translate);
|
|
85
|
+
// Host-data overlay (e.g. a starting LLM picked from the tenant's live model
|
|
86
|
+
// list) — applied last so it wins over any static placeholder in
|
|
87
|
+
// `defaultConfig`. Absent on a generic host, leaving the static defaults.
|
|
88
|
+
const bridged = def.hostDefaults?.(hostBridge);
|
|
89
|
+
return {
|
|
90
|
+
id: nextNodeId(def.kind, nodes),
|
|
91
|
+
kind: def.kind,
|
|
92
|
+
position,
|
|
93
|
+
config: { ...base, ...overlay, ...bridged },
|
|
94
|
+
};
|
|
95
|
+
}
|
|
60
96
|
|
|
61
|
-
export { cloneNode, genId, nextNodeId };
|
|
97
|
+
export { cloneNode, createNodeFromType, genId, nextNodeId, toDefaultsTranslate };
|
|
62
98
|
//# sourceMappingURL=createNode.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNode.mjs","sources":["../../../src/components/Workflow/createNode.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createNode.mjs","sources":["../../../src/components/Workflow/createNode.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAQA;;;;AAIG;AACG,SAAU,KAAK,CAAC,MAAc,EAAA;IAClC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,YAAY,IAAI,MAAM,EAAE;QAC3D,OAAO,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,MAAM,CAAC,UAAU,EAAE,EAAE;IAC3C;AACA,IAAA,OAAO,GAAG,MAAM,CAAA,CAAA,EAAI,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA,CAAA,EAAI,IAAI,CAAC,MAAM;SACvD,QAAQ,CAAC,EAAE;AACX,SAAA,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;AAClB;AAEA;;;;;;;;;AASG;AACG,SAAU,UAAU,CACxB,IAAY,EACZ,KAA+B,EAAA;IAE/B,IAAI,IAAI,KAAK,OAAO;AAAE,QAAA,OAAO,OAAO;;;IAGpC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC;IAC3D,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,CAAA,CAAA,EAAI,OAAO,CAAA,QAAA,CAAU,CAAC;IAC5C,IAAI,GAAG,GAAG,CAAC;AACX,IAAA,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;QACrB,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACvB,IAAI,CAAC,EAAE;AACL,YAAA,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YACnC,IAAI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E,GAAG,IAAI,EAAE,GAAG,OAAO,EAAE,GAAG,OAAO,EAAE;KAC5C;AACH;;;;"}
|
|
@@ -14,6 +14,8 @@ export type { WorkflowGraphObserver } from './graphObserver';
|
|
|
14
14
|
export { useWorkflowGraphObserver, WorkflowGraphObserverContext, } from './graphObserver';
|
|
15
15
|
export type { GraphAction } from './graphReducer';
|
|
16
16
|
export { emptyGraph, graphReducer } from './graphReducer';
|
|
17
|
+
export type { AddAfterSource, AddNodeOptions, AddNodeResult, AddNodeTarget, WorkflowActions, } from './useWorkflowActions';
|
|
18
|
+
export { useWorkflowActions } from './useWorkflowActions';
|
|
17
19
|
export { Workflow } from './Workflow';
|
|
18
20
|
export type { ConnectionCtx, DockSide, DrawerRenderProps, EdgeDrawerRenderProps, Graph, GraphEdge, GraphNode, HandleDef, Issue, IssueSeverity, JSONSchema, MetaChipSpec, MetaChipTone, NodeCategory, NodeRenderProps, NodeTypeDef, NodeTypeRegistry, PlacementRule, Position, RunState, WorkflowProps, WorkflowSelection, WorkflowTranslate, } from './Workflow.types';
|
|
19
21
|
export { defineNodeType, resolveDefaultConfig } from './Workflow.types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Workflow/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,YAAY,EACV,SAAS,EACT,cAAc,EACd,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1E,YAAY,EACV,gBAA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C;AACtC,YAAY,EACV,aAAa,EACb,QAAQ,EACR,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,KAAK,EACL,aAAa,EACb,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxE,YAAY,EACV,WAAW,EACX,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC"}
|
|
@@ -35,6 +35,16 @@ export type AutoLayoutOptions = {
|
|
|
35
35
|
*/
|
|
36
36
|
outputOrder?: Record<string, readonly string[]>;
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Footprint assumed for a node we have no measured size for — e.g. one added
|
|
40
|
+
* but not yet rendered. Width tracks the fixed node-card width (`CARD_WIDTH`);
|
|
41
|
+
* height is a typical two-row card. Callers should pass real measured sizes
|
|
42
|
+
* when available so ranks pack tightly.
|
|
43
|
+
*/
|
|
44
|
+
export declare const FALLBACK_WIDTH: number;
|
|
45
|
+
export declare const FALLBACK_HEIGHT = 76;
|
|
46
|
+
export declare const DEFAULT_RANK_GAP = 80;
|
|
47
|
+
export declare const DEFAULT_NODE_GAP = 40;
|
|
38
48
|
/**
|
|
39
49
|
* Compute a tidy, hierarchical layout for a workflow graph and return a new
|
|
40
50
|
* `Graph` with every node's `position` recomputed (edges untouched). Pure and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoLayout.d.ts","sourceRoot":"","sources":["../../../../src/components/Workflow/layout/autoLayout.ts"],"names":[],"mappings":"A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AC;IACjB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;CACjD,CAAC;AA8DF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAA2B,CAAC;AACvD,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,KAAK,EACZ,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAM,EAC/C,OAAO,GAAE,iBAAsB,GAC9B,KAAK,CAuDP"}
|
|
@@ -144,6 +144,10 @@ function autoLayout(graph, dimensions = {}, options = {}) {
|
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
exports.DEFAULT_NODE_GAP = DEFAULT_NODE_GAP;
|
|
148
|
+
exports.DEFAULT_RANK_GAP = DEFAULT_RANK_GAP;
|
|
149
|
+
exports.FALLBACK_HEIGHT = FALLBACK_HEIGHT;
|
|
150
|
+
exports.FALLBACK_WIDTH = FALLBACK_WIDTH;
|
|
147
151
|
exports.autoLayout = autoLayout;
|
|
148
152
|
exports.estimateLabelOverhang = estimateLabelOverhang;
|
|
149
153
|
//# sourceMappingURL=autoLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoLayout.js","sources":["../../../../src/components/Workflow/layout/autoLayout.ts"],"sourcesContent":[null],"names":["CARD_WIDTH","graphlib","layout"],"mappings":";;;;;;AA0BA;;;;;;AAMG;AACH,MAAM,cAAc,GAAG,CAAC;AACxB,MAAM,cAAc,GAAG,EAAE;AAEnB,SAAU,qBAAqB,CAAC,MAAgB,EAAA;IACpD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,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,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;IAC7E;;AAGA,IAAA,IAAI,cAAc,CAAC,IAAI,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK;;;AAI3C,IAAA,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB;AACxC,IAAA,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;QACxB,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;AAC7C,QAAA,IAAI,CAAC,KAAK;AAAE,YAAA,OAAO,IAAI;AACvB,QAAA,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QACtC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;AAC9B,QAAA,OAAO,KAAK,CAAC,CAAC,CAAC;AACjB,IAAA,CAAC,CAAC;AACJ;AAEA;;;;;AAKG;
|
|
1
|
+
{"version":3,"file":"autoLayout.js","sources":["../../../../src/components/Workflow/layout/autoLayout.ts"],"sourcesContent":[null],"names":["CARD_WIDTH","graphlib","layout"],"mappings":";;;;;;AA0BA;;;;;;AAMG;AACH,MAAM,cAAc,GAAG,CAAC;AACxB,MAAM,cAAc,GAAG,EAAE;AAEnB,SAAU,qBAAqB,CAAC,MAAgB,EAAA;IACpD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC7E,IAAA,OAAO,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,cAAc,GAAG,OAAO,GAAG,cAAc;AACtE;AAmBA;;;;;;;;;;;;;;;;AAgBG;AACH,SAAS,kBAAkB,CACzB,KAAqB,EACrB,WAA8C,EAAA;;AAG9C,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
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
export { autoLayout, estimateLabelOverhang };
|
|
145
|
+
export { DEFAULT_NODE_GAP, DEFAULT_RANK_GAP, FALLBACK_HEIGHT, FALLBACK_WIDTH, autoLayout, estimateLabelOverhang };
|
|
146
146
|
//# sourceMappingURL=autoLayout.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoLayout.mjs","sources":["../../../../src/components/Workflow/layout/autoLayout.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AA0BA;;;;;;AAMG;AACH,MAAM,cAAc,GAAG,CAAC;AACxB,MAAM,cAAc,GAAG,EAAE;AAEnB,SAAU,qBAAqB,CAAC,MAAgB,EAAA;IACpD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC7E,IAAA,OAAO,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,cAAc,GAAG,OAAO,GAAG,cAAc;AACtE;AAmBA;;;;;;;;;;;;;;;;AAgBG;AACH,SAAS,kBAAkB,CACzB,KAAqB,EACrB,WAA8C,EAAA;;AAG9C,IAAA,MAAM,cAAc,GAAG,IAAI,GAAG,EAA0B;AACxD,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;AACxB,QAAA,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;YAAE;QAC/B,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;AAC7C,QAAA,IAAI,KAAK;AAAE,YAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;;YACtB,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;IAC9C;IACA,KAAK,MAAM,CAAC,MAAM,EAAE,KA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CAAC;AAC/B,YAAA,IAAI,CAAC,OAAO;AAAE,gBAAA,OAAO,IAAI;AACzB,YAAA,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;;;;;AAK9C,YAAA,MAAM,QAAQ,GAAa;AACzB,gBAAA,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC;AACxB,gBAAA,CAAC,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC;aAC1B;AACD,YAAA,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE;AAC9B,QAAA,CAAC,CAAC;KACH;AACH;;;;"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Graph, GraphEdge, GraphNode, NodeTypeDef, Position } from './Workflow.types';
|
|
2
|
+
type GetNodeType = (kind: string) => NodeTypeDef | undefined;
|
|
3
|
+
export type NodeSize = {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Size assumed for a node React Flow has not measured yet — including the node
|
|
9
|
+
* being added. Same fallback auto-arrange uses.
|
|
10
|
+
*/
|
|
11
|
+
export declare const FALLBACK_NODE_SIZE: NodeSize;
|
|
12
|
+
/**
|
|
13
|
+
* Where `addNode` puts a new node.
|
|
14
|
+
*
|
|
15
|
+
* - `{ after: nodeId }` — to the right of that node, wired from its first free
|
|
16
|
+
* exit. Falls back to `{ at: 'viewportCenter' }` when the node is unknown or
|
|
17
|
+
* has no free exit (End, Note, every exit already holds its one edge).
|
|
18
|
+
* - `{ at: 'viewportCenter' }` — unconnected, centred in the visible canvas.
|
|
19
|
+
*/
|
|
20
|
+
export type AddNodeTarget = {
|
|
21
|
+
after: string;
|
|
22
|
+
} | {
|
|
23
|
+
at: 'viewportCenter';
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A node's first exit with no outbound edge, or `null` when the node is
|
|
27
|
+
* unknown, has no exits (End, Note) or every exit already holds its one edge.
|
|
28
|
+
* An edge without a `sourceHandle` sits on the first exit (see
|
|
29
|
+
* `existingEdgeFromHandle`).
|
|
30
|
+
*/
|
|
31
|
+
export declare function findFreeExit(graph: Graph, getNodeType: GetNodeType, nodeId: string | null | undefined): {
|
|
32
|
+
node: GraphNode;
|
|
33
|
+
sourceHandle: string;
|
|
34
|
+
} | null;
|
|
35
|
+
export type PlanNodePlacementArgs = {
|
|
36
|
+
graph: Graph;
|
|
37
|
+
getNodeType: GetNodeType;
|
|
38
|
+
/** The node being added; its `position` is ignored and replaced. */
|
|
39
|
+
node: GraphNode;
|
|
40
|
+
target: AddNodeTarget;
|
|
41
|
+
/** Flow coordinates of the visible canvas centre. */
|
|
42
|
+
viewportCenter: Position;
|
|
43
|
+
/** Id for the auto-connect edge, used only when one is created. */
|
|
44
|
+
edgeId: string;
|
|
45
|
+
/** Measured size of an existing node, when React Flow has one. */
|
|
46
|
+
getNodeSize?: (id: string) => NodeSize | undefined;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Where an added node goes and which edge, if any, wires it in. Pure — the
|
|
50
|
+
* `addNode` action feeds it the live graph, viewport and measured sizes.
|
|
51
|
+
*
|
|
52
|
+
* With `{ after }` on a node that has a free exit, the new node goes to that
|
|
53
|
+
* node's right and an edge runs from the exit into the new node's first entry.
|
|
54
|
+
* The edge is dropped (the node still goes to the right) when the new kind has
|
|
55
|
+
* no entry (Note) or the connection fails `isValidConnection` — which runs both
|
|
56
|
+
* node types' `canConnect` hooks, the same rules a manual drag obeys. Every
|
|
57
|
+
* other case lands unconnected at the viewport centre. Either way the node
|
|
58
|
+
* moves down past any node already in that spot.
|
|
59
|
+
*/
|
|
60
|
+
export declare function planNodePlacement({ graph, getNodeType, node, target, viewportCenter, edgeId, getNodeSize, }: PlanNodePlacementArgs): {
|
|
61
|
+
position: Position;
|
|
62
|
+
edge: GraphEdge | null;
|
|
63
|
+
};
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=placement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placement.d.ts","sourceRoot":"","sources":["../../../src/components/Workflow/placement.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,KAAK,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAE1B,KAAK,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;AAE7D,MAAM,MAAM,QAAQ,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAGhC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAEzE;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAChC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAclD;AAiCD,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,WAAW,CAAC;IACzB,oEAAoE;IACpE,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,aAAa,CAAC;IACtB,qDAAqD;IACrD,cAAc,EAAE,QAAQ,CAAC;IACzB,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,QAAQ,GAAG,SAAS,CAAC;CACpD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,WAAW,EACX,IAAI,EACJ,MAAM,EACN,cAAc,EACd,MAAM,EACN,WAA6B,GAC9B,EAAE,qBAAqB,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAA;CAAE,CA0CxE"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var connectionRules = require('./connectionRules.js');
|
|
5
|
+
var autoLayout = require('./layout/autoLayout.js');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Size assumed for a node React Flow has not measured yet — including the node
|
|
9
|
+
* being added. Same fallback auto-arrange uses.
|
|
10
|
+
*/
|
|
11
|
+
const FALLBACK_NODE_SIZE = {
|
|
12
|
+
width: autoLayout.FALLBACK_WIDTH,
|
|
13
|
+
height: autoLayout.FALLBACK_HEIGHT,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A node's first exit with no outbound edge, or `null` when the node is
|
|
17
|
+
* unknown, has no exits (End, Note) or every exit already holds its one edge.
|
|
18
|
+
* An edge without a `sourceHandle` sits on the first exit (see
|
|
19
|
+
* `existingEdgeFromHandle`).
|
|
20
|
+
*/
|
|
21
|
+
function findFreeExit(graph, getNodeType, nodeId) {
|
|
22
|
+
if (!nodeId)
|
|
23
|
+
return null;
|
|
24
|
+
const node = graph.nodes.find((n) => n.id === nodeId);
|
|
25
|
+
if (!node)
|
|
26
|
+
return null;
|
|
27
|
+
const outputs = getNodeType(node.kind)?.handles(node.config).outputs ?? [];
|
|
28
|
+
const free = outputs.find((handle) => !graph.edges.some((edge) => edge.source === node.id &&
|
|
29
|
+
(edge.sourceHandle ?? outputs[0].id) === handle.id));
|
|
30
|
+
return free ? { node, sourceHandle: free.id } : null;
|
|
31
|
+
}
|
|
32
|
+
const overlaps = (a, aSize, b, bSize) => a.x < b.x + bSize.width &&
|
|
33
|
+
a.x + aSize.width > b.x &&
|
|
34
|
+
a.y < b.y + bSize.height &&
|
|
35
|
+
a.y + aSize.height > b.y;
|
|
36
|
+
/** Moves `start` down until a fallback-sized card there covers no node. */
|
|
37
|
+
function nudgeToFreeSpot(start, nodes, getNodeSize) {
|
|
38
|
+
const position = { ...start };
|
|
39
|
+
// Each pass clears at least one node, so this ends within nodes.length passes.
|
|
40
|
+
for (let pass = 0; pass <= nodes.length; pass += 1) {
|
|
41
|
+
const blocker = nodes.find((n) => overlaps(position, FALLBACK_NODE_SIZE, n.position, getNodeSize(n.id) ?? FALLBACK_NODE_SIZE));
|
|
42
|
+
if (!blocker)
|
|
43
|
+
break;
|
|
44
|
+
const blockerHeight = (getNodeSize(blocker.id) ?? FALLBACK_NODE_SIZE)
|
|
45
|
+
.height;
|
|
46
|
+
position.y = blocker.position.y + blockerHeight + autoLayout.DEFAULT_NODE_GAP;
|
|
47
|
+
}
|
|
48
|
+
return position;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Where an added node goes and which edge, if any, wires it in. Pure — the
|
|
52
|
+
* `addNode` action feeds it the live graph, viewport and measured sizes.
|
|
53
|
+
*
|
|
54
|
+
* With `{ after }` on a node that has a free exit, the new node goes to that
|
|
55
|
+
* node's right and an edge runs from the exit into the new node's first entry.
|
|
56
|
+
* The edge is dropped (the node still goes to the right) when the new kind has
|
|
57
|
+
* no entry (Note) or the connection fails `isValidConnection` — which runs both
|
|
58
|
+
* node types' `canConnect` hooks, the same rules a manual drag obeys. Every
|
|
59
|
+
* other case lands unconnected at the viewport centre. Either way the node
|
|
60
|
+
* moves down past any node already in that spot.
|
|
61
|
+
*/
|
|
62
|
+
function planNodePlacement({ graph, getNodeType, node, target, viewportCenter, edgeId, getNodeSize = () => undefined, }) {
|
|
63
|
+
const source = 'after' in target ? findFreeExit(graph, getNodeType, target.after) : null;
|
|
64
|
+
if (!source) {
|
|
65
|
+
const centered = {
|
|
66
|
+
x: viewportCenter.x - FALLBACK_NODE_SIZE.width / 2,
|
|
67
|
+
y: viewportCenter.y - FALLBACK_NODE_SIZE.height / 2,
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
position: nudgeToFreeSpot(centered, graph.nodes, getNodeSize),
|
|
71
|
+
edge: null,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const sourceSize = getNodeSize(source.node.id) ?? FALLBACK_NODE_SIZE;
|
|
75
|
+
const position = nudgeToFreeSpot({
|
|
76
|
+
x: source.node.position.x + sourceSize.width + autoLayout.DEFAULT_RANK_GAP,
|
|
77
|
+
y: source.node.position.y,
|
|
78
|
+
}, graph.nodes, getNodeSize);
|
|
79
|
+
const placed = { ...node, position };
|
|
80
|
+
const targetHandle = getNodeType(node.kind)?.handles(node.config).inputs[0]
|
|
81
|
+
?.id;
|
|
82
|
+
if (!targetHandle)
|
|
83
|
+
return { position, edge: null };
|
|
84
|
+
const connection = {
|
|
85
|
+
source: source.node.id,
|
|
86
|
+
target: node.id,
|
|
87
|
+
sourceHandle: source.sourceHandle,
|
|
88
|
+
targetHandle,
|
|
89
|
+
};
|
|
90
|
+
const withNode = { ...graph, nodes: [...graph.nodes, placed] };
|
|
91
|
+
if (!connectionRules.isValidConnection(connection, withNode, getNodeType)) {
|
|
92
|
+
return { position, edge: null };
|
|
93
|
+
}
|
|
94
|
+
return { position, edge: { id: edgeId, ...connection } };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
exports.FALLBACK_NODE_SIZE = FALLBACK_NODE_SIZE;
|
|
98
|
+
exports.findFreeExit = findFreeExit;
|
|
99
|
+
exports.planNodePlacement = planNodePlacement;
|
|
100
|
+
//# sourceMappingURL=placement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placement.js","sources":["../../../src/components/Workflow/placement.ts"],"sourcesContent":[null],"names":["FALLBACK_WIDTH","FALLBACK_HEIGHT","DEFAULT_NODE_GAP","DEFAULT_RANK_GAP","isValidConn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,IAAI,EAAE,IAAI,EAAE;IACjC;AAEA,IAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,EAAE;AAC1D;;;;;;"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { isValidConnection } from './connectionRules.mjs';
|
|
3
|
+
import { FALLBACK_WIDTH, FALLBACK_HEIGHT, DEFAULT_RANK_GAP, DEFAULT_NODE_GAP } from './layout/autoLayout.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Size assumed for a node React Flow has not measured yet — including the node
|
|
7
|
+
* being added. Same fallback auto-arrange uses.
|
|
8
|
+
*/
|
|
9
|
+
const FALLBACK_NODE_SIZE = {
|
|
10
|
+
width: FALLBACK_WIDTH,
|
|
11
|
+
height: FALLBACK_HEIGHT,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A node's first exit with no outbound edge, or `null` when the node is
|
|
15
|
+
* unknown, has no exits (End, Note) or every exit already holds its one edge.
|
|
16
|
+
* An edge without a `sourceHandle` sits on the first exit (see
|
|
17
|
+
* `existingEdgeFromHandle`).
|
|
18
|
+
*/
|
|
19
|
+
function findFreeExit(graph, getNodeType, nodeId) {
|
|
20
|
+
if (!nodeId)
|
|
21
|
+
return null;
|
|
22
|
+
const node = graph.nodes.find((n) => n.id === nodeId);
|
|
23
|
+
if (!node)
|
|
24
|
+
return null;
|
|
25
|
+
const outputs = getNodeType(node.kind)?.handles(node.config).outputs ?? [];
|
|
26
|
+
const free = outputs.find((handle) => !graph.edges.some((edge) => edge.source === node.id &&
|
|
27
|
+
(edge.sourceHandle ?? outputs[0].id) === handle.id));
|
|
28
|
+
return free ? { node, sourceHandle: free.id } : null;
|
|
29
|
+
}
|
|
30
|
+
const overlaps = (a, aSize, b, bSize) => a.x < b.x + bSize.width &&
|
|
31
|
+
a.x + aSize.width > b.x &&
|
|
32
|
+
a.y < b.y + bSize.height &&
|
|
33
|
+
a.y + aSize.height > b.y;
|
|
34
|
+
/** Moves `start` down until a fallback-sized card there covers no node. */
|
|
35
|
+
function nudgeToFreeSpot(start, nodes, getNodeSize) {
|
|
36
|
+
const position = { ...start };
|
|
37
|
+
// Each pass clears at least one node, so this ends within nodes.length passes.
|
|
38
|
+
for (let pass = 0; pass <= nodes.length; pass += 1) {
|
|
39
|
+
const blocker = nodes.find((n) => overlaps(position, FALLBACK_NODE_SIZE, n.position, getNodeSize(n.id) ?? FALLBACK_NODE_SIZE));
|
|
40
|
+
if (!blocker)
|
|
41
|
+
break;
|
|
42
|
+
const blockerHeight = (getNodeSize(blocker.id) ?? FALLBACK_NODE_SIZE)
|
|
43
|
+
.height;
|
|
44
|
+
position.y = blocker.position.y + blockerHeight + DEFAULT_NODE_GAP;
|
|
45
|
+
}
|
|
46
|
+
return position;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Where an added node goes and which edge, if any, wires it in. Pure — the
|
|
50
|
+
* `addNode` action feeds it the live graph, viewport and measured sizes.
|
|
51
|
+
*
|
|
52
|
+
* With `{ after }` on a node that has a free exit, the new node goes to that
|
|
53
|
+
* node's right and an edge runs from the exit into the new node's first entry.
|
|
54
|
+
* The edge is dropped (the node still goes to the right) when the new kind has
|
|
55
|
+
* no entry (Note) or the connection fails `isValidConnection` — which runs both
|
|
56
|
+
* node types' `canConnect` hooks, the same rules a manual drag obeys. Every
|
|
57
|
+
* other case lands unconnected at the viewport centre. Either way the node
|
|
58
|
+
* moves down past any node already in that spot.
|
|
59
|
+
*/
|
|
60
|
+
function planNodePlacement({ graph, getNodeType, node, target, viewportCenter, edgeId, getNodeSize = () => undefined, }) {
|
|
61
|
+
const source = 'after' in target ? findFreeExit(graph, getNodeType, target.after) : null;
|
|
62
|
+
if (!source) {
|
|
63
|
+
const centered = {
|
|
64
|
+
x: viewportCenter.x - FALLBACK_NODE_SIZE.width / 2,
|
|
65
|
+
y: viewportCenter.y - FALLBACK_NODE_SIZE.height / 2,
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
position: nudgeToFreeSpot(centered, graph.nodes, getNodeSize),
|
|
69
|
+
edge: null,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const sourceSize = getNodeSize(source.node.id) ?? FALLBACK_NODE_SIZE;
|
|
73
|
+
const position = nudgeToFreeSpot({
|
|
74
|
+
x: source.node.position.x + sourceSize.width + DEFAULT_RANK_GAP,
|
|
75
|
+
y: source.node.position.y,
|
|
76
|
+
}, graph.nodes, getNodeSize);
|
|
77
|
+
const placed = { ...node, position };
|
|
78
|
+
const targetHandle = getNodeType(node.kind)?.handles(node.config).inputs[0]
|
|
79
|
+
?.id;
|
|
80
|
+
if (!targetHandle)
|
|
81
|
+
return { position, edge: null };
|
|
82
|
+
const connection = {
|
|
83
|
+
source: source.node.id,
|
|
84
|
+
target: node.id,
|
|
85
|
+
sourceHandle: source.sourceHandle,
|
|
86
|
+
targetHandle,
|
|
87
|
+
};
|
|
88
|
+
const withNode = { ...graph, nodes: [...graph.nodes, placed] };
|
|
89
|
+
if (!isValidConnection(connection, withNode, getNodeType)) {
|
|
90
|
+
return { position, edge: null };
|
|
91
|
+
}
|
|
92
|
+
return { position, edge: { id: edgeId, ...connection } };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { FALLBACK_NODE_SIZE, findFreeExit, planNodePlacement };
|
|
96
|
+
//# sourceMappingURL=placement.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placement.mjs","sources":["../../../src/components/Workflow/placement.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAmBA;;;AAGG;AACI,MAAM,kBAAkB,GAAa;AAC1C,IAAA,KAAK,EAAE,cAAc;AACrB,IAAA,MAAM,EAAE,eAAe;;AAazB;;;;;AAKG;SACa,YAAY,CAC1B,KAAY,EACZ,WAAwB,EACxB,MAAiC,EAAA;AAEjC,IAAA,IAAI,CAAC,MAAM;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arget } from './placement';
|
|
3
|
+
/** What `addNode` did: the new node's id and the auto-connect edge's, if any. */
|
|
4
|
+
export type AddNodeResult = {
|
|
5
|
+
nodeId: string;
|
|
6
|
+
edgeId: string | null;
|
|
7
|
+
};
|
|
8
|
+
export type AddNodeOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* What the inspector does once the new node is selected.
|
|
11
|
+
* - `'follow'` (default): an open inspector moves to the new node, a closed
|
|
12
|
+
* one stays closed — the same rule drag-select follows.
|
|
13
|
+
* - `'open'`: open it on the new node (what a click does).
|
|
14
|
+
* - `'close'`: close it, e.g. on a phone where it would cover the canvas.
|
|
15
|
+
*/
|
|
16
|
+
inspector?: 'follow' | 'open' | 'close';
|
|
17
|
+
};
|
|
18
|
+
/** The exit a node added `{ after: nodeId }` would be wired from. */
|
|
19
|
+
export type AddAfterSource = {
|
|
20
|
+
nodeId: string;
|
|
21
|
+
sourceHandle: string;
|
|
22
|
+
/** Display name: the node's instance title, else its type label. */
|
|
23
|
+
label: string;
|
|
24
|
+
};
|
|
25
|
+
export type WorkflowActions = {
|
|
26
|
+
/**
|
|
27
|
+
* Add a node of `kind` with the same id and starting config a palette drop
|
|
28
|
+
* produces, place it per `target` (see `AddNodeTarget`), select it and pan
|
|
29
|
+
* to it. Node + auto-edge land as one history step, so one undo reverts
|
|
30
|
+
* both. Returns `null` (and changes nothing) when the editor is read-only,
|
|
31
|
+
* `kind` is not registered, or the kind's id is taken (a singleton `start`).
|
|
32
|
+
*/
|
|
33
|
+
addNode: (kind: string, target: AddNodeTarget, options?: AddNodeOptions) => AddNodeResult | null;
|
|
34
|
+
/**
|
|
35
|
+
* The exit `addNode(kind, { after: nodeId })` would wire from, or `null` when
|
|
36
|
+
* the node has none free — the add would land unconnected at the viewport
|
|
37
|
+
* centre. Use it to label the action ("Add after ‹label›" vs "Add at
|
|
38
|
+
* centre"). Whether a given kind then accepts the edge is still up to its
|
|
39
|
+
* handles and `canConnect`; `addNode`'s `edgeId` reports the outcome.
|
|
40
|
+
*/
|
|
41
|
+
getAddAfterSource: (nodeId: string | null | undefined) => AddAfterSource | null;
|
|
42
|
+
/** `getAddAfterSource(nodeId) !== null`. */
|
|
43
|
+
canAddAfter: (nodeId: string | null | undefined) => boolean;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Imperative editor actions for content rendered inside `<Workflow>` (its
|
|
47
|
+
* `children` and render slots sit inside the canvas's React Flow provider).
|
|
48
|
+
* Hosts use this instead of re-implementing node creation and placement — the
|
|
49
|
+
* tap-to-add palette on touch devices being the first caller.
|
|
50
|
+
*
|
|
51
|
+
* Must be called from a component rendered inside `<Workflow>`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function useWorkflowActions(): WorkflowActions;
|
|
54
|
+
//# sourceMappingURL=useWorkflowActions.d.ts.map
|