@octaviaflow/core 3.0.18-beta.6 → 3.0.18-beta.9
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/chunk-2NGC7AI3.js +2637 -0
- package/dist/chunk-2NGC7AI3.js.map +1 -0
- package/dist/chunk-2O6K5PLY.js +2637 -0
- package/dist/chunk-2O6K5PLY.js.map +1 -0
- package/dist/chunk-C3UD2AZ5.js +2637 -0
- package/dist/chunk-C3UD2AZ5.js.map +1 -0
- package/dist/chunk-CEUP4NK2.js +2850 -0
- package/dist/chunk-CEUP4NK2.js.map +1 -0
- package/dist/chunk-EERNYLFL.js +2860 -0
- package/dist/chunk-EERNYLFL.js.map +1 -0
- package/dist/chunk-EKFDJX4G.js +2872 -0
- package/dist/chunk-EKFDJX4G.js.map +1 -0
- package/dist/chunk-GJA3GJUZ.js +2844 -0
- package/dist/chunk-GJA3GJUZ.js.map +1 -0
- package/dist/chunk-IOKUV7FD.js +2658 -0
- package/dist/chunk-IOKUV7FD.js.map +1 -0
- package/dist/chunk-J7YASALS.js +2859 -0
- package/dist/chunk-J7YASALS.js.map +1 -0
- package/dist/chunk-JIEUYBQT.js +2658 -0
- package/dist/chunk-JIEUYBQT.js.map +1 -0
- package/dist/chunk-KYMYNYFV.js +2656 -0
- package/dist/chunk-KYMYNYFV.js.map +1 -0
- package/dist/chunk-PVJXX6GP.js +2640 -0
- package/dist/chunk-PVJXX6GP.js.map +1 -0
- package/dist/chunk-S2SSBMWJ.js +2658 -0
- package/dist/chunk-S2SSBMWJ.js.map +1 -0
- package/dist/chunk-WEPTBLWX.js +2847 -0
- package/dist/chunk-WEPTBLWX.js.map +1 -0
- package/dist/chunk-WG4ZQMPS.js +2844 -0
- package/dist/chunk-WG4ZQMPS.js.map +1 -0
- package/dist/chunk-XEPEBHAW.js +2808 -0
- package/dist/chunk-XEPEBHAW.js.map +1 -0
- package/dist/chunk-XG2OYFX6.js +2925 -0
- package/dist/chunk-XG2OYFX6.js.map +1 -0
- package/dist/components/CsvViewer/CsvViewer.d.ts +51 -0
- package/dist/components/CsvViewer/CsvViewer.d.ts.map +1 -0
- package/dist/components/CsvViewer/index.d.ts +2 -0
- package/dist/components/CsvViewer/index.d.ts.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +4 -1
- package/dist/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/components/ExecutionConsole/ExecutionConsole.d.ts +8 -2
- package/dist/components/ExecutionConsole/ExecutionConsole.d.ts.map +1 -1
- package/dist/components/FlowMinimap/FlowMinimap.d.ts +17 -1
- package/dist/components/FlowMinimap/FlowMinimap.d.ts.map +1 -1
- package/dist/components/FlowToolbar/FlowToolbar.d.ts +16 -10
- package/dist/components/FlowToolbar/FlowToolbar.d.ts.map +1 -1
- package/dist/components/JsonViewer/JsonViewer.d.ts +42 -7
- package/dist/components/JsonViewer/JsonViewer.d.ts.map +1 -1
- package/dist/components/JsonViewer/index.d.ts +1 -1
- package/dist/components/JsonViewer/index.d.ts.map +1 -1
- package/dist/components/WorkflowHeader/WorkflowHeader.d.ts +130 -0
- package/dist/components/WorkflowHeader/WorkflowHeader.d.ts.map +1 -0
- package/dist/components/WorkflowHeader/WorkflowHeaderExpanded.d.ts +69 -0
- package/dist/components/WorkflowHeader/WorkflowHeaderExpanded.d.ts.map +1 -0
- package/dist/components/WorkflowHeader/index.d.ts +3 -0
- package/dist/components/WorkflowHeader/index.d.ts.map +1 -0
- package/dist/components/WorkflowHeader/misc/WorkflowHeaderCentered.d.ts +40 -0
- package/dist/components/WorkflowHeader/misc/WorkflowHeaderCentered.d.ts.map +1 -0
- package/dist/components/WorkflowHeader/misc/WorkflowHeaderCommand.d.ts +39 -0
- package/dist/components/WorkflowHeader/misc/WorkflowHeaderCommand.d.ts.map +1 -0
- package/dist/components/WorkflowHeader/misc/WorkflowHeaderMinimal.d.ts +44 -0
- package/dist/components/WorkflowHeader/misc/WorkflowHeaderMinimal.d.ts.map +1 -0
- package/dist/components/WorkflowHeader/misc/WorkflowHeaderRail.d.ts +45 -0
- package/dist/components/WorkflowHeader/misc/WorkflowHeaderRail.d.ts.map +1 -0
- package/dist/components/WorkflowHeader/misc/WorkflowHeaderStudio.d.ts +48 -0
- package/dist/components/WorkflowHeader/misc/WorkflowHeaderStudio.d.ts.map +1 -0
- package/dist/components/WorkflowHeader/misc/WorkflowHeaderTiered.d.ts +52 -0
- package/dist/components/WorkflowHeader/misc/WorkflowHeaderTiered.d.ts.map +1 -0
- package/dist/components/XmlViewer/XmlViewer.d.ts +26 -1
- package/dist/components/XmlViewer/XmlViewer.d.ts.map +1 -1
- package/dist/components/XmlViewer/index.d.ts +1 -1
- package/dist/components/XmlViewer/index.d.ts.map +1 -1
- package/dist/components/YamlViewer/YamlViewer.d.ts +26 -1
- package/dist/components/YamlViewer/YamlViewer.d.ts.map +1 -1
- package/dist/components/YamlViewer/index.d.ts +1 -1
- package/dist/components/YamlViewer/index.d.ts.map +1 -1
- package/dist/hooks/useRelativeTime.d.ts +28 -0
- package/dist/hooks/useRelativeTime.d.ts.map +1 -0
- package/dist/hooks/useWorkflowRuntime.d.ts +20 -0
- package/dist/hooks/useWorkflowRuntime.d.ts.map +1 -0
- package/dist/index.cjs +4715 -3408
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4244 -3230
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/workflow/components/FlowCanvas/FlowCanvas.d.ts +41 -1
- package/dist/workflow/components/FlowCanvas/FlowCanvas.d.ts.map +1 -1
- package/dist/workflow/components/kinds/index.d.ts +4 -0
- package/dist/workflow/components/kinds/index.d.ts.map +1 -1
- package/dist/workflow/index.d.ts +1 -1
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/store/selectors.d.ts +12 -0
- package/dist/workflow/store/selectors.d.ts.map +1 -1
- package/dist/workflow.cjs +515 -356
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.js +19 -205
- package/dist/workflow.js.map +1 -1
- package/package.json +7 -3
package/dist/workflow.cjs
CHANGED
|
@@ -77,7 +77,8 @@ __export(workflow_exports, {
|
|
|
77
77
|
useNodeData: () => useNodeData,
|
|
78
78
|
useNodes: () => useNodes,
|
|
79
79
|
useSelection: () => useSelection,
|
|
80
|
-
useViewport: () => useViewport
|
|
80
|
+
useViewport: () => useViewport,
|
|
81
|
+
useViewportOrNull: () => useViewportOrNull
|
|
81
82
|
});
|
|
82
83
|
module.exports = __toCommonJS(workflow_exports);
|
|
83
84
|
|
|
@@ -646,6 +647,23 @@ function useEdges() {
|
|
|
646
647
|
function useViewport() {
|
|
647
648
|
return useFlowSelector((s) => s.viewport);
|
|
648
649
|
}
|
|
650
|
+
var VIEWPORT_OR_NULL_NO_STORE_SUBSCRIBE = (_cb) => () => {
|
|
651
|
+
};
|
|
652
|
+
var VIEWPORT_OR_NULL_NO_STORE_SNAPSHOT = () => null;
|
|
653
|
+
function useViewportOrNull() {
|
|
654
|
+
const store = (0, import_react5.useContext)(FlowStoreContext);
|
|
655
|
+
const { sub, snap } = (0, import_react5.useMemo)(
|
|
656
|
+
() => store ? {
|
|
657
|
+
sub: store.subscribe,
|
|
658
|
+
snap: () => store.getSnapshot().viewport
|
|
659
|
+
} : {
|
|
660
|
+
sub: VIEWPORT_OR_NULL_NO_STORE_SUBSCRIBE,
|
|
661
|
+
snap: VIEWPORT_OR_NULL_NO_STORE_SNAPSHOT
|
|
662
|
+
},
|
|
663
|
+
[store]
|
|
664
|
+
);
|
|
665
|
+
return (0, import_react5.useSyncExternalStore)(sub, snap, snap);
|
|
666
|
+
}
|
|
649
667
|
function useNodeById(id) {
|
|
650
668
|
return useFlowSelector((s) => s.nodes.find((n) => n.id === id));
|
|
651
669
|
}
|
|
@@ -943,7 +961,7 @@ function ConfigPanel({
|
|
|
943
961
|
}
|
|
944
962
|
|
|
945
963
|
// src/workflow/components/FlowCanvas/FlowCanvas.tsx
|
|
946
|
-
var
|
|
964
|
+
var import_react15 = require("react");
|
|
947
965
|
|
|
948
966
|
// src/workflow/store/createFlowStore.ts
|
|
949
967
|
var DEFAULT_VIEWPORT = { x: 0, y: 0, zoom: 1 };
|
|
@@ -1791,10 +1809,155 @@ function handleSideStyle(side, index, total) {
|
|
|
1791
1809
|
}
|
|
1792
1810
|
}
|
|
1793
1811
|
|
|
1794
|
-
// src/workflow/components/
|
|
1795
|
-
var import_icons = require("@octaviaflow/icons");
|
|
1812
|
+
// src/workflow/components/NodeResizer/NodeResizer.tsx
|
|
1796
1813
|
var import_react13 = require("react");
|
|
1797
1814
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1815
|
+
function NodeResizer({
|
|
1816
|
+
isVisible,
|
|
1817
|
+
minWidth = 80,
|
|
1818
|
+
minHeight = 60,
|
|
1819
|
+
maxWidth,
|
|
1820
|
+
maxHeight,
|
|
1821
|
+
keepAspectRatio = false,
|
|
1822
|
+
onResize,
|
|
1823
|
+
onResizeEnd,
|
|
1824
|
+
color
|
|
1825
|
+
}) {
|
|
1826
|
+
const { node, selected } = useFlowNodeContext();
|
|
1827
|
+
const viewport = useViewport();
|
|
1828
|
+
const flow = useFlow();
|
|
1829
|
+
const dragRef = (0, import_react13.useRef)(null);
|
|
1830
|
+
const show = isVisible ?? selected;
|
|
1831
|
+
if (!show) return null;
|
|
1832
|
+
const beginResize = (e, corner) => {
|
|
1833
|
+
e.preventDefault();
|
|
1834
|
+
e.stopPropagation();
|
|
1835
|
+
e.target.setPointerCapture(e.pointerId);
|
|
1836
|
+
const w = node.width ?? DEFAULT_NODE_WIDTH;
|
|
1837
|
+
const h = node.height ?? DEFAULT_NODE_HEIGHT;
|
|
1838
|
+
dragRef.current = {
|
|
1839
|
+
pointerId: e.pointerId,
|
|
1840
|
+
corner,
|
|
1841
|
+
startClientX: e.clientX,
|
|
1842
|
+
startClientY: e.clientY,
|
|
1843
|
+
startWidth: w,
|
|
1844
|
+
startHeight: h,
|
|
1845
|
+
startX: node.position.x,
|
|
1846
|
+
startY: node.position.y,
|
|
1847
|
+
aspect: w / Math.max(1, h)
|
|
1848
|
+
};
|
|
1849
|
+
};
|
|
1850
|
+
const onMove = (e) => {
|
|
1851
|
+
const drag = dragRef.current;
|
|
1852
|
+
if (!drag || drag.pointerId !== e.pointerId) return;
|
|
1853
|
+
const dx = (e.clientX - drag.startClientX) / viewport.zoom;
|
|
1854
|
+
const dy = (e.clientY - drag.startClientY) / viewport.zoom;
|
|
1855
|
+
let nextW = drag.startWidth;
|
|
1856
|
+
let nextH = drag.startHeight;
|
|
1857
|
+
let nextX = drag.startX;
|
|
1858
|
+
let nextY = drag.startY;
|
|
1859
|
+
switch (drag.corner) {
|
|
1860
|
+
case "se":
|
|
1861
|
+
nextW = drag.startWidth + dx;
|
|
1862
|
+
nextH = drag.startHeight + dy;
|
|
1863
|
+
break;
|
|
1864
|
+
case "sw":
|
|
1865
|
+
nextW = drag.startWidth - dx;
|
|
1866
|
+
nextH = drag.startHeight + dy;
|
|
1867
|
+
nextX = drag.startX + dx;
|
|
1868
|
+
break;
|
|
1869
|
+
case "ne":
|
|
1870
|
+
nextW = drag.startWidth + dx;
|
|
1871
|
+
nextH = drag.startHeight - dy;
|
|
1872
|
+
nextY = drag.startY + dy;
|
|
1873
|
+
break;
|
|
1874
|
+
case "nw":
|
|
1875
|
+
nextW = drag.startWidth - dx;
|
|
1876
|
+
nextH = drag.startHeight - dy;
|
|
1877
|
+
nextX = drag.startX + dx;
|
|
1878
|
+
nextY = drag.startY + dy;
|
|
1879
|
+
break;
|
|
1880
|
+
}
|
|
1881
|
+
if (keepAspectRatio) {
|
|
1882
|
+
nextH = nextW / drag.aspect;
|
|
1883
|
+
if (drag.corner === "nw" || drag.corner === "ne") {
|
|
1884
|
+
nextY = drag.startY + (drag.startHeight - nextH);
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
nextW = Math.max(minWidth, maxWidth ? Math.min(maxWidth, nextW) : nextW);
|
|
1888
|
+
nextH = Math.max(minHeight, maxHeight ? Math.min(maxHeight, nextH) : nextH);
|
|
1889
|
+
flow.updateNode(node.id, {
|
|
1890
|
+
width: nextW,
|
|
1891
|
+
height: nextH,
|
|
1892
|
+
position: { x: nextX, y: nextY }
|
|
1893
|
+
});
|
|
1894
|
+
onResize?.({ width: nextW, height: nextH });
|
|
1895
|
+
};
|
|
1896
|
+
const onUp = (e) => {
|
|
1897
|
+
if (dragRef.current?.pointerId === e.pointerId) {
|
|
1898
|
+
const cur = flow.getNode(node.id);
|
|
1899
|
+
if (cur) {
|
|
1900
|
+
onResizeEnd?.({
|
|
1901
|
+
width: cur.width ?? DEFAULT_NODE_WIDTH,
|
|
1902
|
+
height: cur.height ?? DEFAULT_NODE_HEIGHT
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
dragRef.current = null;
|
|
1906
|
+
}
|
|
1907
|
+
};
|
|
1908
|
+
const handleColor = color ?? "var(--ods-accent)";
|
|
1909
|
+
const handleStyle = (corner) => {
|
|
1910
|
+
const base = {
|
|
1911
|
+
position: "absolute",
|
|
1912
|
+
width: 12,
|
|
1913
|
+
height: 12,
|
|
1914
|
+
background: "var(--ods-surface-canvas)",
|
|
1915
|
+
border: `2px solid ${handleColor}`,
|
|
1916
|
+
borderRadius: 2,
|
|
1917
|
+
cursor: cursorFor(corner),
|
|
1918
|
+
touchAction: "none",
|
|
1919
|
+
// Place each handle so its CENTRE sits on the corresponding corner.
|
|
1920
|
+
transform: "translate(-50%, -50%)"
|
|
1921
|
+
};
|
|
1922
|
+
switch (corner) {
|
|
1923
|
+
case "nw":
|
|
1924
|
+
return { ...base, top: 0, left: 0 };
|
|
1925
|
+
case "ne":
|
|
1926
|
+
return { ...base, top: 0, left: "100%" };
|
|
1927
|
+
case "sw":
|
|
1928
|
+
return { ...base, top: "100%", left: 0 };
|
|
1929
|
+
case "se":
|
|
1930
|
+
return { ...base, top: "100%", left: "100%" };
|
|
1931
|
+
}
|
|
1932
|
+
};
|
|
1933
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: cn("ods-node-resizer"), "data-flow-no-drag": "true", children: ["nw", "ne", "sw", "se"].map((corner) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1934
|
+
"div",
|
|
1935
|
+
{
|
|
1936
|
+
style: handleStyle(corner),
|
|
1937
|
+
onPointerDown: (e) => beginResize(e, corner),
|
|
1938
|
+
onPointerMove: onMove,
|
|
1939
|
+
onPointerUp: onUp,
|
|
1940
|
+
onPointerCancel: onUp,
|
|
1941
|
+
"aria-label": `Resize ${corner}`
|
|
1942
|
+
},
|
|
1943
|
+
corner
|
|
1944
|
+
)) });
|
|
1945
|
+
}
|
|
1946
|
+
function cursorFor(corner) {
|
|
1947
|
+
switch (corner) {
|
|
1948
|
+
case "nw":
|
|
1949
|
+
case "se":
|
|
1950
|
+
return "nwse-resize";
|
|
1951
|
+
case "ne":
|
|
1952
|
+
case "sw":
|
|
1953
|
+
return "nesw-resize";
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
|
|
1957
|
+
// src/workflow/components/kinds/BaseNode.tsx
|
|
1958
|
+
var import_icons = require("@octaviaflow/icons");
|
|
1959
|
+
var import_react14 = require("react");
|
|
1960
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1798
1961
|
function BaseNode({
|
|
1799
1962
|
kind,
|
|
1800
1963
|
kindIcon,
|
|
@@ -1810,10 +1973,10 @@ function BaseNode({
|
|
|
1810
1973
|
className,
|
|
1811
1974
|
children
|
|
1812
1975
|
}) {
|
|
1813
|
-
const ctx = (0,
|
|
1814
|
-
const bridge = (0,
|
|
1976
|
+
const ctx = (0, import_react14.useContext)(FlowNodeContext);
|
|
1977
|
+
const bridge = (0, import_react14.useContext)(FlowNodeBridgeContext);
|
|
1815
1978
|
const deleteHandler = onDelete === false ? void 0 : onDelete ?? (ctx && bridge ? () => bridge.deleteNode(ctx.id) : void 0);
|
|
1816
|
-
return /* @__PURE__ */ (0,
|
|
1979
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1817
1980
|
"div",
|
|
1818
1981
|
{
|
|
1819
1982
|
className: cn(
|
|
@@ -1823,31 +1986,31 @@ function BaseNode({
|
|
|
1823
1986
|
className
|
|
1824
1987
|
),
|
|
1825
1988
|
children: [
|
|
1826
|
-
/* @__PURE__ */ (0,
|
|
1827
|
-
kindIcon && /* @__PURE__ */ (0,
|
|
1828
|
-
/* @__PURE__ */ (0,
|
|
1989
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ods-flow-base-node__pill", children: [
|
|
1990
|
+
kindIcon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ods-flow-base-node__pill-icon", "aria-hidden": "true", children: kindIcon }),
|
|
1991
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ods-flow-base-node__pill-label", children: kind })
|
|
1829
1992
|
] }),
|
|
1830
|
-
status && status !== "idle" && /* @__PURE__ */ (0,
|
|
1993
|
+
status && status !== "idle" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1831
1994
|
"span",
|
|
1832
1995
|
{
|
|
1833
1996
|
className: cn("ods-flow-base-node__status", `ods-flow-base-node__status--${status}`),
|
|
1834
1997
|
"aria-hidden": "true"
|
|
1835
1998
|
}
|
|
1836
1999
|
),
|
|
1837
|
-
/* @__PURE__ */ (0,
|
|
1838
|
-
/* @__PURE__ */ (0,
|
|
1839
|
-
/* @__PURE__ */ (0,
|
|
1840
|
-
/* @__PURE__ */ (0,
|
|
1841
|
-
/* @__PURE__ */ (0,
|
|
1842
|
-
(chip !== void 0 || description !== void 0 || valueChip !== void 0) && /* @__PURE__ */ (0,
|
|
1843
|
-
chip !== void 0 && /* @__PURE__ */ (0,
|
|
1844
|
-
description !== void 0 && /* @__PURE__ */ (0,
|
|
1845
|
-
valueChip !== void 0 && /* @__PURE__ */ (0,
|
|
2000
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ods-flow-base-node__body", children: [
|
|
2001
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ods-flow-base-node__content", children: [
|
|
2002
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ods-flow-base-node__bubble", "aria-hidden": "true", children: icon }),
|
|
2003
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ods-flow-base-node__content-text", children: [
|
|
2004
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ods-flow-base-node__content-title", children: title }),
|
|
2005
|
+
(chip !== void 0 || description !== void 0 || valueChip !== void 0) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "ods-flow-base-node__content-info", children: [
|
|
2006
|
+
chip !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ods-flow-base-node__chip", children: chip }),
|
|
2007
|
+
description !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ods-flow-base-node__description", children: description }),
|
|
2008
|
+
valueChip !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "ods-flow-base-node__value-chip", children: valueChip })
|
|
1846
2009
|
] })
|
|
1847
2010
|
] })
|
|
1848
2011
|
] }),
|
|
1849
|
-
footer && /* @__PURE__ */ (0,
|
|
1850
|
-
deleteHandler && /* @__PURE__ */ (0,
|
|
2012
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ods-flow-base-node__footer", children: footer }),
|
|
2013
|
+
deleteHandler && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1851
2014
|
"button",
|
|
1852
2015
|
{
|
|
1853
2016
|
type: "button",
|
|
@@ -1859,7 +2022,7 @@ function BaseNode({
|
|
|
1859
2022
|
"aria-label": "Delete node",
|
|
1860
2023
|
"data-flow-no-drag": "true",
|
|
1861
2024
|
title: "Delete node",
|
|
1862
|
-
children: /* @__PURE__ */ (0,
|
|
2025
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons.TrashCanIcon, { size: 16, "aria-hidden": true })
|
|
1863
2026
|
}
|
|
1864
2027
|
)
|
|
1865
2028
|
] }),
|
|
@@ -1870,12 +2033,12 @@ function BaseNode({
|
|
|
1870
2033
|
}
|
|
1871
2034
|
|
|
1872
2035
|
// src/workflow/components/kinds/index.tsx
|
|
1873
|
-
var
|
|
2036
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1874
2037
|
var ActionNode = ({
|
|
1875
2038
|
node
|
|
1876
2039
|
}) => {
|
|
1877
2040
|
const d = node.data ?? {};
|
|
1878
|
-
return /* @__PURE__ */ (0,
|
|
2041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1879
2042
|
BaseNode,
|
|
1880
2043
|
{
|
|
1881
2044
|
kind: d.kind ?? "ACTION",
|
|
@@ -1887,8 +2050,8 @@ var ActionNode = ({
|
|
|
1887
2050
|
status: d.status,
|
|
1888
2051
|
accent: "green",
|
|
1889
2052
|
children: [
|
|
1890
|
-
/* @__PURE__ */ (0,
|
|
1891
|
-
/* @__PURE__ */ (0,
|
|
2053
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "target", position: "top" }),
|
|
2054
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "source", position: "bottom" })
|
|
1892
2055
|
]
|
|
1893
2056
|
}
|
|
1894
2057
|
);
|
|
@@ -1897,7 +2060,7 @@ var TriggerNode = ({
|
|
|
1897
2060
|
node
|
|
1898
2061
|
}) => {
|
|
1899
2062
|
const d = node.data ?? {};
|
|
1900
|
-
return /* @__PURE__ */ (0,
|
|
2063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1901
2064
|
BaseNode,
|
|
1902
2065
|
{
|
|
1903
2066
|
kind: d.kind ?? "TRIGGER",
|
|
@@ -1908,7 +2071,7 @@ var TriggerNode = ({
|
|
|
1908
2071
|
valueChip: d.valueChip,
|
|
1909
2072
|
status: d.status,
|
|
1910
2073
|
accent: "green",
|
|
1911
|
-
children: /* @__PURE__ */ (0,
|
|
2074
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "source", position: "bottom" })
|
|
1912
2075
|
}
|
|
1913
2076
|
);
|
|
1914
2077
|
};
|
|
@@ -1920,7 +2083,7 @@ var ConditionNode = ({
|
|
|
1920
2083
|
{ id: "true", label: "true" },
|
|
1921
2084
|
{ id: "false", label: "false" }
|
|
1922
2085
|
];
|
|
1923
|
-
return /* @__PURE__ */ (0,
|
|
2086
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1924
2087
|
BaseNode,
|
|
1925
2088
|
{
|
|
1926
2089
|
kind: d.kind ?? "CONDITION",
|
|
@@ -1932,8 +2095,8 @@ var ConditionNode = ({
|
|
|
1932
2095
|
status: d.status,
|
|
1933
2096
|
accent: "amber",
|
|
1934
2097
|
children: [
|
|
1935
|
-
/* @__PURE__ */ (0,
|
|
1936
|
-
branches.map((b, i) => /* @__PURE__ */ (0,
|
|
2098
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "target", position: "top" }),
|
|
2099
|
+
branches.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1937
2100
|
Handle,
|
|
1938
2101
|
{
|
|
1939
2102
|
type: "source",
|
|
@@ -1954,24 +2117,27 @@ var GroupNode = ({
|
|
|
1954
2117
|
}) => {
|
|
1955
2118
|
const d = node.data ?? {};
|
|
1956
2119
|
const collapsed = !!d.collapsed;
|
|
2120
|
+
const disabled = !!d.disabled;
|
|
1957
2121
|
const hiddenCount = d.hiddenCount;
|
|
1958
2122
|
const bridge = useFlowNodeBridge();
|
|
1959
2123
|
const onChevronClick = (e) => {
|
|
1960
2124
|
e.stopPropagation();
|
|
1961
2125
|
bridge.toggleNodeCollapse(node.id);
|
|
1962
2126
|
};
|
|
1963
|
-
return /* @__PURE__ */ (0,
|
|
2127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1964
2128
|
"div",
|
|
1965
2129
|
{
|
|
1966
2130
|
className: "ods-flow-group",
|
|
1967
2131
|
"data-collapsed": collapsed ? "true" : "false",
|
|
2132
|
+
"data-disabled": disabled ? "true" : void 0,
|
|
1968
2133
|
style: {
|
|
1969
2134
|
width: node.width ?? 360,
|
|
1970
2135
|
height: collapsed ? 36 : node.height ?? 200
|
|
1971
2136
|
},
|
|
1972
2137
|
children: [
|
|
1973
|
-
/* @__PURE__ */ (0,
|
|
1974
|
-
|
|
2138
|
+
!collapsed && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(NodeResizer, { minWidth: 240, minHeight: 120 }),
|
|
2139
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "ods-flow-group__header", "data-flow-no-drag": "false", children: [
|
|
2140
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1975
2141
|
"button",
|
|
1976
2142
|
{
|
|
1977
2143
|
type: "button",
|
|
@@ -1984,15 +2150,16 @@ var GroupNode = ({
|
|
|
1984
2150
|
children: collapsed ? "\u25B8" : "\u25BE"
|
|
1985
2151
|
}
|
|
1986
2152
|
),
|
|
1987
|
-
/* @__PURE__ */ (0,
|
|
1988
|
-
d.subtitle && /* @__PURE__ */ (0,
|
|
1989
|
-
|
|
2153
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ods-flow-group__title", children: d.title ?? "Group" }),
|
|
2154
|
+
d.subtitle && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ods-flow-group__subtitle", children: d.subtitle }),
|
|
2155
|
+
disabled && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ods-flow-group__disabled-badge", "aria-label": "Disabled subflow", children: "Disabled" }),
|
|
2156
|
+
collapsed && hiddenCount !== void 0 && hiddenCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "ods-flow-group__count", "aria-label": `${hiddenCount} hidden steps`, children: [
|
|
1990
2157
|
hiddenCount,
|
|
1991
2158
|
" steps"
|
|
1992
2159
|
] })
|
|
1993
2160
|
] }),
|
|
1994
|
-
/* @__PURE__ */ (0,
|
|
1995
|
-
/* @__PURE__ */ (0,
|
|
2161
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "target", position: "top", id: "__group_in" }),
|
|
2162
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "source", position: "bottom", id: "__group_out" })
|
|
1996
2163
|
]
|
|
1997
2164
|
}
|
|
1998
2165
|
);
|
|
@@ -2003,24 +2170,27 @@ var ForEachNode = ({
|
|
|
2003
2170
|
const d = node.data ?? {};
|
|
2004
2171
|
const iteratorExpr = d.iterator ?? d.description ?? "items[]";
|
|
2005
2172
|
const collapsed = !!d.collapsed;
|
|
2173
|
+
const disabled = !!d.disabled;
|
|
2006
2174
|
const hiddenCount = d.hiddenCount;
|
|
2007
2175
|
const bridge = useFlowNodeBridge();
|
|
2008
2176
|
const onChevronClick = (e) => {
|
|
2009
2177
|
e.stopPropagation();
|
|
2010
2178
|
bridge.toggleNodeCollapse(node.id);
|
|
2011
2179
|
};
|
|
2012
|
-
return /* @__PURE__ */ (0,
|
|
2180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2013
2181
|
"div",
|
|
2014
2182
|
{
|
|
2015
2183
|
className: "ods-flow-foreach",
|
|
2016
2184
|
"data-collapsed": collapsed ? "true" : "false",
|
|
2185
|
+
"data-disabled": disabled ? "true" : void 0,
|
|
2017
2186
|
style: {
|
|
2018
2187
|
width: node.width ?? 420,
|
|
2019
2188
|
height: collapsed ? 40 : node.height ?? 260
|
|
2020
2189
|
},
|
|
2021
2190
|
children: [
|
|
2022
|
-
/* @__PURE__ */ (0,
|
|
2023
|
-
|
|
2191
|
+
!collapsed && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(NodeResizer, { minWidth: 240, minHeight: 120 }),
|
|
2192
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "ods-flow-foreach__header", children: [
|
|
2193
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2024
2194
|
"button",
|
|
2025
2195
|
{
|
|
2026
2196
|
type: "button",
|
|
@@ -2033,24 +2203,57 @@ var ForEachNode = ({
|
|
|
2033
2203
|
children: collapsed ? "\u25B8" : "\u25BE"
|
|
2034
2204
|
}
|
|
2035
2205
|
),
|
|
2036
|
-
/* @__PURE__ */ (0,
|
|
2037
|
-
/* @__PURE__ */ (0,
|
|
2038
|
-
/* @__PURE__ */ (0,
|
|
2039
|
-
|
|
2206
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ods-flow-foreach__icon", "aria-hidden": "true", children: "\u21BB" }),
|
|
2207
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ods-flow-foreach__title", children: d.title ?? "For each" }),
|
|
2208
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { className: "ods-flow-foreach__iterator", children: iteratorExpr }),
|
|
2209
|
+
disabled && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2210
|
+
"span",
|
|
2211
|
+
{
|
|
2212
|
+
className: "ods-flow-foreach__disabled-badge",
|
|
2213
|
+
"aria-label": "Disabled subflow",
|
|
2214
|
+
children: "Disabled"
|
|
2215
|
+
}
|
|
2216
|
+
),
|
|
2217
|
+
collapsed && hiddenCount !== void 0 && hiddenCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "ods-flow-foreach__count", "aria-label": `${hiddenCount} hidden steps`, children: [
|
|
2040
2218
|
hiddenCount,
|
|
2041
2219
|
" steps"
|
|
2042
2220
|
] })
|
|
2043
2221
|
] }),
|
|
2044
|
-
/* @__PURE__ */ (0,
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2222
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "target", position: "top", id: "__group_in", label: !collapsed ? "in" : void 0 }),
|
|
2223
|
+
collapsed ? (
|
|
2224
|
+
// Collapsed: single bottom exit so the container behaves like a
|
|
2225
|
+
// regular action in the chain.
|
|
2226
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "source", position: "bottom", id: "__group_out" })
|
|
2227
|
+
) : (
|
|
2228
|
+
// Expanded: two bottom outputs spread across the bottom edge.
|
|
2229
|
+
// Index/total tell the Handle to position them at 33% and 66%
|
|
2230
|
+
// along the edge (per `handleSideStyle`). `each` is left of
|
|
2231
|
+
// centre, `__group_out` (labelled "done") is right of centre.
|
|
2232
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
2233
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2234
|
+
Handle,
|
|
2235
|
+
{
|
|
2236
|
+
type: "source",
|
|
2237
|
+
position: "bottom",
|
|
2238
|
+
id: "each",
|
|
2239
|
+
label: "each",
|
|
2240
|
+
index: 0,
|
|
2241
|
+
total: 2
|
|
2242
|
+
}
|
|
2243
|
+
),
|
|
2244
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2245
|
+
Handle,
|
|
2246
|
+
{
|
|
2247
|
+
type: "source",
|
|
2248
|
+
position: "bottom",
|
|
2249
|
+
id: "__group_out",
|
|
2250
|
+
label: "done",
|
|
2251
|
+
index: 1,
|
|
2252
|
+
total: 2
|
|
2253
|
+
}
|
|
2254
|
+
)
|
|
2255
|
+
] })
|
|
2256
|
+
)
|
|
2054
2257
|
]
|
|
2055
2258
|
}
|
|
2056
2259
|
);
|
|
@@ -2059,7 +2262,7 @@ var OutputNode = ({
|
|
|
2059
2262
|
node
|
|
2060
2263
|
}) => {
|
|
2061
2264
|
const d = node.data ?? {};
|
|
2062
|
-
return /* @__PURE__ */ (0,
|
|
2265
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2063
2266
|
BaseNode,
|
|
2064
2267
|
{
|
|
2065
2268
|
kind: d.kind ?? "OUTPUT",
|
|
@@ -2069,7 +2272,7 @@ var OutputNode = ({
|
|
|
2069
2272
|
description: d.description ?? d.subtitle,
|
|
2070
2273
|
status: d.status,
|
|
2071
2274
|
accent: "green",
|
|
2072
|
-
children: /* @__PURE__ */ (0,
|
|
2275
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "target", position: "top" })
|
|
2073
2276
|
}
|
|
2074
2277
|
);
|
|
2075
2278
|
};
|
|
@@ -2077,7 +2280,7 @@ var ErrorNode = ({
|
|
|
2077
2280
|
node
|
|
2078
2281
|
}) => {
|
|
2079
2282
|
const d = node.data ?? {};
|
|
2080
|
-
return /* @__PURE__ */ (0,
|
|
2283
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2081
2284
|
BaseNode,
|
|
2082
2285
|
{
|
|
2083
2286
|
kind: d.kind ?? "ERROR",
|
|
@@ -2088,8 +2291,8 @@ var ErrorNode = ({
|
|
|
2088
2291
|
status: d.status ?? "error",
|
|
2089
2292
|
accent: "red",
|
|
2090
2293
|
children: [
|
|
2091
|
-
/* @__PURE__ */ (0,
|
|
2092
|
-
/* @__PURE__ */ (0,
|
|
2294
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "target", position: "top" }),
|
|
2295
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "source", position: "bottom" })
|
|
2093
2296
|
]
|
|
2094
2297
|
}
|
|
2095
2298
|
);
|
|
@@ -2100,7 +2303,7 @@ var WaitNode = ({
|
|
|
2100
2303
|
const d = node.data ?? {};
|
|
2101
2304
|
const waitMs = d.waitMs;
|
|
2102
2305
|
const durationChip = waitMs ? `${Math.round(waitMs / 100) / 10}s` : void 0;
|
|
2103
|
-
return /* @__PURE__ */ (0,
|
|
2306
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2104
2307
|
BaseNode,
|
|
2105
2308
|
{
|
|
2106
2309
|
kind: d.kind ?? "WAIT",
|
|
@@ -2111,8 +2314,8 @@ var WaitNode = ({
|
|
|
2111
2314
|
status: d.status,
|
|
2112
2315
|
accent: "violet",
|
|
2113
2316
|
children: [
|
|
2114
|
-
/* @__PURE__ */ (0,
|
|
2115
|
-
/* @__PURE__ */ (0,
|
|
2317
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "target", position: "top" }),
|
|
2318
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "source", position: "bottom" })
|
|
2116
2319
|
]
|
|
2117
2320
|
}
|
|
2118
2321
|
);
|
|
@@ -2125,7 +2328,7 @@ var ParallelNode = ({
|
|
|
2125
2328
|
{ id: "a", label: "a" },
|
|
2126
2329
|
{ id: "b", label: "b" }
|
|
2127
2330
|
];
|
|
2128
|
-
return /* @__PURE__ */ (0,
|
|
2331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2129
2332
|
BaseNode,
|
|
2130
2333
|
{
|
|
2131
2334
|
kind: d.kind ?? "PARALLEL",
|
|
@@ -2136,8 +2339,8 @@ var ParallelNode = ({
|
|
|
2136
2339
|
status: d.status,
|
|
2137
2340
|
accent: "blue",
|
|
2138
2341
|
children: [
|
|
2139
|
-
/* @__PURE__ */ (0,
|
|
2140
|
-
branches.map((b, i) => /* @__PURE__ */ (0,
|
|
2342
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "target", position: "top" }),
|
|
2343
|
+
branches.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2141
2344
|
Handle,
|
|
2142
2345
|
{
|
|
2143
2346
|
type: "source",
|
|
@@ -2157,7 +2360,7 @@ var StickyNode = ({
|
|
|
2157
2360
|
node
|
|
2158
2361
|
}) => {
|
|
2159
2362
|
const d = node.data ?? {};
|
|
2160
|
-
return /* @__PURE__ */ (0,
|
|
2363
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2161
2364
|
"div",
|
|
2162
2365
|
{
|
|
2163
2366
|
className: "ods-flow-sticky",
|
|
@@ -2166,8 +2369,8 @@ var StickyNode = ({
|
|
|
2166
2369
|
minHeight: node.height ?? 120
|
|
2167
2370
|
},
|
|
2168
2371
|
children: [
|
|
2169
|
-
d.title && /* @__PURE__ */ (0,
|
|
2170
|
-
d.description && /* @__PURE__ */ (0,
|
|
2372
|
+
d.title && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "ods-flow-sticky__title", children: d.title }),
|
|
2373
|
+
d.description && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "ods-flow-sticky__body", children: d.description })
|
|
2171
2374
|
]
|
|
2172
2375
|
}
|
|
2173
2376
|
);
|
|
@@ -2176,7 +2379,7 @@ var WebhookNode = ({
|
|
|
2176
2379
|
node
|
|
2177
2380
|
}) => {
|
|
2178
2381
|
const d = node.data ?? {};
|
|
2179
|
-
return /* @__PURE__ */ (0,
|
|
2382
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2180
2383
|
BaseNode,
|
|
2181
2384
|
{
|
|
2182
2385
|
kind: d.kind ?? "WEBHOOK",
|
|
@@ -2187,7 +2390,7 @@ var WebhookNode = ({
|
|
|
2187
2390
|
valueChip: d.valueChip,
|
|
2188
2391
|
status: d.status,
|
|
2189
2392
|
accent: "blue",
|
|
2190
|
-
children: /* @__PURE__ */ (0,
|
|
2393
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "source", position: "bottom" })
|
|
2191
2394
|
}
|
|
2192
2395
|
);
|
|
2193
2396
|
};
|
|
@@ -2195,7 +2398,7 @@ var HttpRequestNode = ({
|
|
|
2195
2398
|
node
|
|
2196
2399
|
}) => {
|
|
2197
2400
|
const d = node.data ?? {};
|
|
2198
|
-
return /* @__PURE__ */ (0,
|
|
2401
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2199
2402
|
BaseNode,
|
|
2200
2403
|
{
|
|
2201
2404
|
kind: d.kind ?? "HTTP",
|
|
@@ -2207,8 +2410,8 @@ var HttpRequestNode = ({
|
|
|
2207
2410
|
status: d.status,
|
|
2208
2411
|
accent: "blue",
|
|
2209
2412
|
children: [
|
|
2210
|
-
/* @__PURE__ */ (0,
|
|
2211
|
-
/* @__PURE__ */ (0,
|
|
2413
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "target", position: "top" }),
|
|
2414
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Handle, { type: "source", position: "bottom" })
|
|
2212
2415
|
]
|
|
2213
2416
|
}
|
|
2214
2417
|
);
|
|
@@ -2229,52 +2432,58 @@ var DEFAULT_NODE_KINDS = {
|
|
|
2229
2432
|
};
|
|
2230
2433
|
|
|
2231
2434
|
// src/workflow/components/FlowCanvas/FlowCanvas.tsx
|
|
2232
|
-
var
|
|
2435
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2233
2436
|
var DEFAULT_VIEWPORT2 = { x: 0, y: 0, zoom: 1 };
|
|
2234
|
-
function FlowCanvas({
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2437
|
+
function FlowCanvas(props) {
|
|
2438
|
+
const viewportPropProvided = props.viewport !== void 0 || props.defaultViewport !== void 0;
|
|
2439
|
+
const {
|
|
2440
|
+
nodes,
|
|
2441
|
+
edges,
|
|
2442
|
+
onNodesChange,
|
|
2443
|
+
onEdgesChange,
|
|
2444
|
+
viewport: controlledViewport,
|
|
2445
|
+
defaultViewport = DEFAULT_VIEWPORT2,
|
|
2446
|
+
onViewportChange,
|
|
2447
|
+
minZoom = 0.25,
|
|
2448
|
+
maxZoom = 2,
|
|
2449
|
+
fitViewOnInit,
|
|
2450
|
+
nodeKinds,
|
|
2451
|
+
onConnect,
|
|
2452
|
+
onConnectStart,
|
|
2453
|
+
onConnectEnd,
|
|
2454
|
+
isValidConnection,
|
|
2455
|
+
onSelectionChange,
|
|
2456
|
+
onPaneClick,
|
|
2457
|
+
onNodeClick,
|
|
2458
|
+
onEdgeClick,
|
|
2459
|
+
onEdgeLabelChange,
|
|
2460
|
+
onInit,
|
|
2461
|
+
onBeforeDelete,
|
|
2462
|
+
onNodeContextMenu,
|
|
2463
|
+
onEdgeContextMenu,
|
|
2464
|
+
onPaneContextMenu,
|
|
2465
|
+
nodesDraggable = true,
|
|
2466
|
+
nodesConnectable = true,
|
|
2467
|
+
panOnDrag: panOnDragProp,
|
|
2468
|
+
zoomOnScroll: zoomOnScrollProp,
|
|
2469
|
+
preset = "mouse",
|
|
2470
|
+
paneClickDistance = 4,
|
|
2471
|
+
paneClickClearsSelection = true,
|
|
2472
|
+
background = "dots",
|
|
2473
|
+
gridSize = 20,
|
|
2474
|
+
snapToGrid = false,
|
|
2475
|
+
nodeCollisionGap = -1,
|
|
2476
|
+
subflowCollisionGap,
|
|
2477
|
+
reparentOnDrag = false,
|
|
2478
|
+
autoResizeContainers = false,
|
|
2479
|
+
containerAutoResizePadding = 32,
|
|
2480
|
+
height = "100%",
|
|
2481
|
+
width = "100%",
|
|
2482
|
+
className,
|
|
2483
|
+
style,
|
|
2484
|
+
children,
|
|
2485
|
+
emptyState
|
|
2486
|
+
} = props;
|
|
2278
2487
|
const presetDefaults = {
|
|
2279
2488
|
mouse: { panOnDrag: true, zoomOnScroll: true },
|
|
2280
2489
|
trackpad: { panOnDrag: true, zoomOnScroll: true },
|
|
@@ -2282,46 +2491,46 @@ function FlowCanvas({
|
|
|
2282
2491
|
};
|
|
2283
2492
|
const panOnDrag = panOnDragProp ?? presetDefaults[preset].panOnDrag;
|
|
2284
2493
|
const zoomOnScroll = zoomOnScrollProp ?? presetDefaults[preset].zoomOnScroll;
|
|
2285
|
-
const store = (0,
|
|
2494
|
+
const store = (0, import_react15.useState)(
|
|
2286
2495
|
() => createFlowStore({
|
|
2287
2496
|
initialNodes: nodes,
|
|
2288
2497
|
initialEdges: edges,
|
|
2289
2498
|
initialViewport: controlledViewport ?? defaultViewport
|
|
2290
2499
|
})
|
|
2291
2500
|
)[0];
|
|
2292
|
-
const handleRegistry = (0,
|
|
2293
|
-
const [handleVersion, setHandleVersion] = (0,
|
|
2294
|
-
(0,
|
|
2501
|
+
const handleRegistry = (0, import_react15.useState)(() => createHandleRegistry())[0];
|
|
2502
|
+
const [handleVersion, setHandleVersion] = (0, import_react15.useState)(0);
|
|
2503
|
+
(0, import_react15.useEffect)(() => {
|
|
2295
2504
|
const unsub = handleRegistry.subscribe(() => {
|
|
2296
2505
|
setHandleVersion((v) => v + 1);
|
|
2297
2506
|
});
|
|
2298
2507
|
return unsub;
|
|
2299
2508
|
}, [handleRegistry]);
|
|
2300
|
-
const kinds = (0,
|
|
2301
|
-
const containerRef = (0,
|
|
2302
|
-
(0,
|
|
2303
|
-
(0,
|
|
2304
|
-
const [uncontrolledVp, setUncontrolledVp] = (0,
|
|
2509
|
+
const kinds = (0, import_react15.useMemo)(() => buildNodeKindRegistry(DEFAULT_NODE_KINDS, nodeKinds), [nodeKinds]);
|
|
2510
|
+
const containerRef = (0, import_react15.useRef)(null);
|
|
2511
|
+
(0, import_react15.useEffect)(() => store.setNodes(nodes), [store, nodes]);
|
|
2512
|
+
(0, import_react15.useEffect)(() => store.setEdges(edges), [store, edges]);
|
|
2513
|
+
const [uncontrolledVp, setUncontrolledVp] = (0, import_react15.useState)(controlledViewport ?? defaultViewport);
|
|
2305
2514
|
const viewport = controlledViewport ?? uncontrolledVp;
|
|
2306
|
-
(0,
|
|
2307
|
-
const setViewport = (0,
|
|
2515
|
+
(0, import_react15.useEffect)(() => store.setViewport(viewport), [store, viewport]);
|
|
2516
|
+
const setViewport = (0, import_react15.useCallback)(
|
|
2308
2517
|
(next) => {
|
|
2309
2518
|
if (controlledViewport === void 0) setUncontrolledVp(next);
|
|
2310
2519
|
onViewportChange?.(next);
|
|
2311
2520
|
},
|
|
2312
2521
|
[controlledViewport, onViewportChange]
|
|
2313
2522
|
);
|
|
2314
|
-
const selectedNodeIds = (0,
|
|
2523
|
+
const selectedNodeIds = (0, import_react15.useMemo)(() => {
|
|
2315
2524
|
const s = /* @__PURE__ */ new Set();
|
|
2316
2525
|
for (const n of nodes) if (n.selected) s.add(n.id);
|
|
2317
2526
|
return s;
|
|
2318
2527
|
}, [nodes]);
|
|
2319
|
-
const selectedEdgeIds = (0,
|
|
2528
|
+
const selectedEdgeIds = (0, import_react15.useMemo)(() => {
|
|
2320
2529
|
const s = /* @__PURE__ */ new Set();
|
|
2321
2530
|
for (const e of edges) if (e.selected) s.add(e.id);
|
|
2322
2531
|
return s;
|
|
2323
2532
|
}, [edges]);
|
|
2324
|
-
(0,
|
|
2533
|
+
(0, import_react15.useEffect)(() => {
|
|
2325
2534
|
store.setSelection(selectedNodeIds, selectedEdgeIds);
|
|
2326
2535
|
if (onSelectionChange) {
|
|
2327
2536
|
onSelectionChange({
|
|
@@ -2330,7 +2539,7 @@ function FlowCanvas({
|
|
|
2330
2539
|
});
|
|
2331
2540
|
}
|
|
2332
2541
|
}, [store, selectedNodeIds, selectedEdgeIds, nodes, edges, onSelectionChange]);
|
|
2333
|
-
const selectNode = (0,
|
|
2542
|
+
const selectNode = (0, import_react15.useCallback)(
|
|
2334
2543
|
(id, additive) => {
|
|
2335
2544
|
const next = [];
|
|
2336
2545
|
const nextEdges = [];
|
|
@@ -2353,14 +2562,14 @@ function FlowCanvas({
|
|
|
2353
2562
|
},
|
|
2354
2563
|
[nodes, edges, selectedNodeIds, onNodesChange, onEdgesChange]
|
|
2355
2564
|
);
|
|
2356
|
-
const notifyNodeClick = (0,
|
|
2565
|
+
const notifyNodeClick = (0, import_react15.useCallback)(
|
|
2357
2566
|
(id) => {
|
|
2358
2567
|
const node = nodes.find((n) => n.id === id);
|
|
2359
2568
|
if (node) onNodeClick?.(node);
|
|
2360
2569
|
},
|
|
2361
2570
|
[nodes, onNodeClick]
|
|
2362
2571
|
);
|
|
2363
|
-
const selectEdge = (0,
|
|
2572
|
+
const selectEdge = (0, import_react15.useCallback)(
|
|
2364
2573
|
(id, additive) => {
|
|
2365
2574
|
const next = [];
|
|
2366
2575
|
const nextNodes = [];
|
|
@@ -2385,7 +2594,7 @@ function FlowCanvas({
|
|
|
2385
2594
|
},
|
|
2386
2595
|
[nodes, edges, selectedEdgeIds, onEdgesChange, onNodesChange, onEdgeClick]
|
|
2387
2596
|
);
|
|
2388
|
-
const clearSelection = (0,
|
|
2597
|
+
const clearSelection = (0, import_react15.useCallback)(() => {
|
|
2389
2598
|
const ns = [];
|
|
2390
2599
|
const es = [];
|
|
2391
2600
|
for (const n of nodes) if (n.selected) ns.push(change.node.select(n.id, false));
|
|
@@ -2393,9 +2602,9 @@ function FlowCanvas({
|
|
|
2393
2602
|
if (ns.length) onNodesChange?.(ns);
|
|
2394
2603
|
if (es.length) onEdgesChange?.(es);
|
|
2395
2604
|
}, [nodes, edges, onNodesChange, onEdgesChange]);
|
|
2396
|
-
const dragRef = (0,
|
|
2397
|
-
const [draggingId, setDraggingId] = (0,
|
|
2398
|
-
const beginNodeDrag = (0,
|
|
2605
|
+
const dragRef = (0, import_react15.useRef)(null);
|
|
2606
|
+
const [draggingId, setDraggingId] = (0, import_react15.useState)(null);
|
|
2607
|
+
const beginNodeDrag = (0, import_react15.useCallback)(
|
|
2399
2608
|
(nodeId, pointerId, clientX, clientY, altKey = false) => {
|
|
2400
2609
|
if (!nodesDraggable) return;
|
|
2401
2610
|
const node = nodes.find((n) => n.id === nodeId);
|
|
@@ -2404,6 +2613,7 @@ function FlowCanvas({
|
|
|
2404
2613
|
id: d.id,
|
|
2405
2614
|
startPosition: d.position
|
|
2406
2615
|
}));
|
|
2616
|
+
const wantsReparent = altKey || reparentOnDragRef.current;
|
|
2407
2617
|
dragRef.current = {
|
|
2408
2618
|
pointerId,
|
|
2409
2619
|
nodeId,
|
|
@@ -2411,7 +2621,7 @@ function FlowCanvas({
|
|
|
2411
2621
|
startClientY: clientY,
|
|
2412
2622
|
startPosition: node.position,
|
|
2413
2623
|
descendants: kids,
|
|
2414
|
-
altDetach:
|
|
2624
|
+
altDetach: wantsReparent,
|
|
2415
2625
|
rafScheduled: false,
|
|
2416
2626
|
nextDelta: null
|
|
2417
2627
|
};
|
|
@@ -2420,12 +2630,12 @@ function FlowCanvas({
|
|
|
2420
2630
|
},
|
|
2421
2631
|
[nodes, nodesDraggable, selectNode]
|
|
2422
2632
|
);
|
|
2423
|
-
const [conn, setConn] = (0,
|
|
2424
|
-
const connRef = (0,
|
|
2425
|
-
(0,
|
|
2633
|
+
const [conn, setConn] = (0, import_react15.useState)(null);
|
|
2634
|
+
const connRef = (0, import_react15.useRef)(null);
|
|
2635
|
+
(0, import_react15.useEffect)(() => {
|
|
2426
2636
|
connRef.current = conn;
|
|
2427
2637
|
}, [conn]);
|
|
2428
|
-
const beginConnection = (0,
|
|
2638
|
+
const beginConnection = (0, import_react15.useCallback)(
|
|
2429
2639
|
(nodeId, handleId, handleType, pointerId, clientX, clientY) => {
|
|
2430
2640
|
if (!nodesConnectable) return;
|
|
2431
2641
|
const node = nodes.find((n) => n.id === nodeId);
|
|
@@ -2458,63 +2668,75 @@ function FlowCanvas({
|
|
|
2458
2668
|
},
|
|
2459
2669
|
[nodes, nodesConnectable, handleRegistry, viewport, store, onConnectStart]
|
|
2460
2670
|
);
|
|
2461
|
-
const viewportRef = (0,
|
|
2462
|
-
const nodesRef = (0,
|
|
2463
|
-
const edgesRef = (0,
|
|
2464
|
-
const onNodesChangeRefForInstance = (0,
|
|
2465
|
-
const onEdgesChangeRefForInstance = (0,
|
|
2466
|
-
const onBeforeDeleteRef = (0,
|
|
2467
|
-
const snapToGridRef = (0,
|
|
2468
|
-
const gridSizeRef = (0,
|
|
2469
|
-
const nodeCollisionGapRef = (0,
|
|
2470
|
-
const subflowCollisionGapRef = (0,
|
|
2471
|
-
(0,
|
|
2671
|
+
const viewportRef = (0, import_react15.useRef)(viewport);
|
|
2672
|
+
const nodesRef = (0, import_react15.useRef)(nodes);
|
|
2673
|
+
const edgesRef = (0, import_react15.useRef)(edges);
|
|
2674
|
+
const onNodesChangeRefForInstance = (0, import_react15.useRef)(onNodesChange);
|
|
2675
|
+
const onEdgesChangeRefForInstance = (0, import_react15.useRef)(onEdgesChange);
|
|
2676
|
+
const onBeforeDeleteRef = (0, import_react15.useRef)(onBeforeDelete);
|
|
2677
|
+
const snapToGridRef = (0, import_react15.useRef)(snapToGrid);
|
|
2678
|
+
const gridSizeRef = (0, import_react15.useRef)(gridSize);
|
|
2679
|
+
const nodeCollisionGapRef = (0, import_react15.useRef)(nodeCollisionGap);
|
|
2680
|
+
const subflowCollisionGapRef = (0, import_react15.useRef)(subflowCollisionGap ?? nodeCollisionGap);
|
|
2681
|
+
const reparentOnDragRef = (0, import_react15.useRef)(reparentOnDrag);
|
|
2682
|
+
const autoResizeContainersRef = (0, import_react15.useRef)(autoResizeContainers);
|
|
2683
|
+
const containerAutoResizePaddingRef = (0, import_react15.useRef)(containerAutoResizePadding);
|
|
2684
|
+
(0, import_react15.useEffect)(() => {
|
|
2472
2685
|
edgesRef.current = edges;
|
|
2473
2686
|
}, [edges]);
|
|
2474
|
-
(0,
|
|
2687
|
+
(0, import_react15.useEffect)(() => {
|
|
2475
2688
|
onNodesChangeRefForInstance.current = onNodesChange;
|
|
2476
2689
|
}, [onNodesChange]);
|
|
2477
|
-
(0,
|
|
2690
|
+
(0, import_react15.useEffect)(() => {
|
|
2478
2691
|
onEdgesChangeRefForInstance.current = onEdgesChange;
|
|
2479
2692
|
}, [onEdgesChange]);
|
|
2480
|
-
(0,
|
|
2693
|
+
(0, import_react15.useEffect)(() => {
|
|
2481
2694
|
onBeforeDeleteRef.current = onBeforeDelete;
|
|
2482
2695
|
}, [onBeforeDelete]);
|
|
2483
|
-
(0,
|
|
2696
|
+
(0, import_react15.useEffect)(() => {
|
|
2484
2697
|
snapToGridRef.current = snapToGrid;
|
|
2485
2698
|
}, [snapToGrid]);
|
|
2486
|
-
(0,
|
|
2699
|
+
(0, import_react15.useEffect)(() => {
|
|
2487
2700
|
gridSizeRef.current = gridSize;
|
|
2488
2701
|
}, [gridSize]);
|
|
2489
|
-
(0,
|
|
2702
|
+
(0, import_react15.useEffect)(() => {
|
|
2490
2703
|
nodeCollisionGapRef.current = nodeCollisionGap;
|
|
2491
2704
|
}, [nodeCollisionGap]);
|
|
2492
|
-
(0,
|
|
2705
|
+
(0, import_react15.useEffect)(() => {
|
|
2493
2706
|
subflowCollisionGapRef.current = subflowCollisionGap ?? nodeCollisionGap;
|
|
2494
2707
|
}, [subflowCollisionGap, nodeCollisionGap]);
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2708
|
+
(0, import_react15.useEffect)(() => {
|
|
2709
|
+
reparentOnDragRef.current = reparentOnDrag;
|
|
2710
|
+
}, [reparentOnDrag]);
|
|
2711
|
+
(0, import_react15.useEffect)(() => {
|
|
2712
|
+
autoResizeContainersRef.current = autoResizeContainers;
|
|
2713
|
+
}, [autoResizeContainers]);
|
|
2714
|
+
(0, import_react15.useEffect)(() => {
|
|
2715
|
+
containerAutoResizePaddingRef.current = containerAutoResizePadding;
|
|
2716
|
+
}, [containerAutoResizePadding]);
|
|
2717
|
+
const onNodesChangeRef = (0, import_react15.useRef)(onNodesChange);
|
|
2718
|
+
const onConnectRef = (0, import_react15.useRef)(onConnect);
|
|
2719
|
+
const onConnectEndRef = (0, import_react15.useRef)(onConnectEnd);
|
|
2720
|
+
const isValidConnectionRef = (0, import_react15.useRef)(isValidConnection);
|
|
2721
|
+
(0, import_react15.useEffect)(() => {
|
|
2500
2722
|
viewportRef.current = viewport;
|
|
2501
2723
|
}, [viewport]);
|
|
2502
|
-
(0,
|
|
2724
|
+
(0, import_react15.useEffect)(() => {
|
|
2503
2725
|
nodesRef.current = nodes;
|
|
2504
2726
|
}, [nodes]);
|
|
2505
|
-
(0,
|
|
2727
|
+
(0, import_react15.useEffect)(() => {
|
|
2506
2728
|
onNodesChangeRef.current = onNodesChange;
|
|
2507
2729
|
}, [onNodesChange]);
|
|
2508
|
-
(0,
|
|
2730
|
+
(0, import_react15.useEffect)(() => {
|
|
2509
2731
|
onConnectRef.current = onConnect;
|
|
2510
2732
|
}, [onConnect]);
|
|
2511
|
-
(0,
|
|
2733
|
+
(0, import_react15.useEffect)(() => {
|
|
2512
2734
|
onConnectEndRef.current = onConnectEnd;
|
|
2513
2735
|
}, [onConnectEnd]);
|
|
2514
|
-
(0,
|
|
2736
|
+
(0, import_react15.useEffect)(() => {
|
|
2515
2737
|
isValidConnectionRef.current = isValidConnection;
|
|
2516
2738
|
}, [isValidConnection]);
|
|
2517
|
-
(0,
|
|
2739
|
+
(0, import_react15.useEffect)(() => {
|
|
2518
2740
|
const onPointerMove = (e) => {
|
|
2519
2741
|
const vp = viewportRef.current;
|
|
2520
2742
|
const drag = dragRef.current;
|
|
@@ -2611,7 +2833,7 @@ function FlowCanvas({
|
|
|
2611
2833
|
)
|
|
2612
2834
|
);
|
|
2613
2835
|
}
|
|
2614
|
-
if (drag.altDetach
|
|
2836
|
+
if (drag.altDetach) {
|
|
2615
2837
|
const targetGroup = findContainingGroup(
|
|
2616
2838
|
{
|
|
2617
2839
|
x: finalPos.x + (dragNode.width ?? 0) / 2,
|
|
@@ -2621,14 +2843,26 @@ function FlowCanvas({
|
|
|
2621
2843
|
[drag.nodeId, ...drag.descendants.map((d) => d.id)]
|
|
2622
2844
|
);
|
|
2623
2845
|
const nextParentId = targetGroup?.id;
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2846
|
+
if (nextParentId !== dragNode.parentId) {
|
|
2847
|
+
const updated = {
|
|
2848
|
+
...dragNode,
|
|
2849
|
+
position: finalPos,
|
|
2850
|
+
parentId: nextParentId,
|
|
2851
|
+
// Preserve extent only when staying in a group.
|
|
2852
|
+
extent: nextParentId ? dragNode.extent : void 0
|
|
2853
|
+
};
|
|
2854
|
+
changes.push(change.node.replace(drag.nodeId, updated));
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
if (autoResizeContainersRef.current) {
|
|
2858
|
+
const containerChanges = computeContainerAutoResize(
|
|
2859
|
+
nodesRef.current,
|
|
2860
|
+
// Projected children: apply the position + reparent
|
|
2861
|
+
// changes we just built before measuring bboxes.
|
|
2862
|
+
changes,
|
|
2863
|
+
containerAutoResizePaddingRef.current
|
|
2864
|
+
);
|
|
2865
|
+
for (const c2 of containerChanges) changes.push(c2);
|
|
2632
2866
|
}
|
|
2633
2867
|
onNodesChangeRef.current?.(changes);
|
|
2634
2868
|
}
|
|
@@ -2701,7 +2935,7 @@ function FlowCanvas({
|
|
|
2701
2935
|
window.removeEventListener("pointercancel", onPointerCancel);
|
|
2702
2936
|
};
|
|
2703
2937
|
}, [store]);
|
|
2704
|
-
const panRef = (0,
|
|
2938
|
+
const panRef = (0, import_react15.useRef)(null);
|
|
2705
2939
|
const onCanvasPointerDown = (e) => {
|
|
2706
2940
|
if (e.button !== 0) return;
|
|
2707
2941
|
const t = e.target;
|
|
@@ -2726,7 +2960,7 @@ function FlowCanvas({
|
|
|
2726
2960
|
moved: false
|
|
2727
2961
|
};
|
|
2728
2962
|
};
|
|
2729
|
-
(0,
|
|
2963
|
+
(0, import_react15.useEffect)(() => {
|
|
2730
2964
|
const onMove = (e) => {
|
|
2731
2965
|
const pan = panRef.current;
|
|
2732
2966
|
if (!pan || pan.pointerId !== e.pointerId) return;
|
|
@@ -2782,7 +3016,7 @@ function FlowCanvas({
|
|
|
2782
3016
|
y: py - (py - viewport.y) * k
|
|
2783
3017
|
});
|
|
2784
3018
|
};
|
|
2785
|
-
const dispatch = (0,
|
|
3019
|
+
const dispatch = (0, import_react15.useCallback)(
|
|
2786
3020
|
(a) => {
|
|
2787
3021
|
if (a.type === "connection/start") {
|
|
2788
3022
|
beginConnection(a.nodeId, a.handleId, a.handleType, a.pointerId, a.clientX, a.clientY);
|
|
@@ -2790,7 +3024,7 @@ function FlowCanvas({
|
|
|
2790
3024
|
},
|
|
2791
3025
|
[beginConnection]
|
|
2792
3026
|
);
|
|
2793
|
-
const reportDimensions = (0,
|
|
3027
|
+
const reportDimensions = (0, import_react15.useCallback)(
|
|
2794
3028
|
(nodeId, width2, height2) => {
|
|
2795
3029
|
const node = nodes.find((n) => n.id === nodeId);
|
|
2796
3030
|
if (!node) return;
|
|
@@ -2799,7 +3033,7 @@ function FlowCanvas({
|
|
|
2799
3033
|
},
|
|
2800
3034
|
[nodes, onNodesChange]
|
|
2801
3035
|
);
|
|
2802
|
-
const toggleNodeCollapseImpl = (0,
|
|
3036
|
+
const toggleNodeCollapseImpl = (0, import_react15.useCallback)(
|
|
2803
3037
|
(nodeId) => {
|
|
2804
3038
|
const node = nodes.find((n) => n.id === nodeId);
|
|
2805
3039
|
if (!node) return;
|
|
@@ -2812,7 +3046,7 @@ function FlowCanvas({
|
|
|
2812
3046
|
},
|
|
2813
3047
|
[nodes, onNodesChange]
|
|
2814
3048
|
);
|
|
2815
|
-
const deleteNodeImpl = (0,
|
|
3049
|
+
const deleteNodeImpl = (0, import_react15.useCallback)(
|
|
2816
3050
|
(nodeId) => {
|
|
2817
3051
|
const incidentEdgeIds = edgesRef.current.filter((e) => e.source === nodeId || e.target === nodeId).map((e) => e.id);
|
|
2818
3052
|
if (incidentEdgeIds.length > 0) {
|
|
@@ -2822,7 +3056,7 @@ function FlowCanvas({
|
|
|
2822
3056
|
},
|
|
2823
3057
|
[onNodesChange, onEdgesChange]
|
|
2824
3058
|
);
|
|
2825
|
-
const instance = (0,
|
|
3059
|
+
const instance = (0, import_react15.useMemo)(
|
|
2826
3060
|
() => ({
|
|
2827
3061
|
// viewport
|
|
2828
3062
|
getViewport: () => viewportRef.current,
|
|
@@ -2963,13 +3197,29 @@ function FlowCanvas({
|
|
|
2963
3197
|
}),
|
|
2964
3198
|
[setViewport, minZoom, maxZoom]
|
|
2965
3199
|
);
|
|
2966
|
-
const initFiredRef = (0,
|
|
2967
|
-
(0,
|
|
3200
|
+
const initFiredRef = (0, import_react15.useRef)(false);
|
|
3201
|
+
(0, import_react15.useEffect)(() => {
|
|
2968
3202
|
if (initFiredRef.current) return;
|
|
2969
3203
|
initFiredRef.current = true;
|
|
2970
3204
|
onInit?.(instance);
|
|
2971
3205
|
}, [instance, onInit]);
|
|
2972
|
-
(0,
|
|
3206
|
+
const fitOnInitFiredRef = (0, import_react15.useRef)(false);
|
|
3207
|
+
(0, import_react15.useEffect)(() => {
|
|
3208
|
+
if (fitOnInitFiredRef.current) return;
|
|
3209
|
+
const opt = fitViewOnInit;
|
|
3210
|
+
const shouldFit = opt === false ? false : opt !== void 0 ? true : !viewportPropProvided;
|
|
3211
|
+
if (!shouldFit) return;
|
|
3212
|
+
if (nodes.length === 0) return;
|
|
3213
|
+
const rect = containerRef.current?.getBoundingClientRect();
|
|
3214
|
+
if (!rect || rect.width === 0 || rect.height === 0) return;
|
|
3215
|
+
fitOnInitFiredRef.current = true;
|
|
3216
|
+
const fitOpts = typeof opt === "object" && opt !== null ? opt : void 0;
|
|
3217
|
+
const raf = requestAnimationFrame(() => {
|
|
3218
|
+
void instance.fitView(fitOpts);
|
|
3219
|
+
});
|
|
3220
|
+
return () => cancelAnimationFrame(raf);
|
|
3221
|
+
}, [fitViewOnInit, viewportPropProvided, nodes.length, instance]);
|
|
3222
|
+
(0, import_react15.useEffect)(() => {
|
|
2973
3223
|
const onKey = (e) => {
|
|
2974
3224
|
if (e.key !== "Backspace" && e.key !== "Delete") return;
|
|
2975
3225
|
const target = e.target;
|
|
@@ -2990,7 +3240,7 @@ function FlowCanvas({
|
|
|
2990
3240
|
window.addEventListener("keydown", onKey);
|
|
2991
3241
|
return () => window.removeEventListener("keydown", onKey);
|
|
2992
3242
|
}, [instance, store]);
|
|
2993
|
-
const bridge = (0,
|
|
3243
|
+
const bridge = (0, import_react15.useMemo)(
|
|
2994
3244
|
() => ({
|
|
2995
3245
|
beginNodeDrag,
|
|
2996
3246
|
selectNode,
|
|
@@ -3010,16 +3260,16 @@ function FlowCanvas({
|
|
|
3010
3260
|
toggleNodeCollapseImpl
|
|
3011
3261
|
]
|
|
3012
3262
|
);
|
|
3013
|
-
const [panGesture, setPanGesture] = (0,
|
|
3263
|
+
const [panGesture, setPanGesture] = (0, import_react15.useState)(false);
|
|
3014
3264
|
const isEmpty = nodes.length === 0 && edges.length === 0;
|
|
3015
3265
|
const isConnecting = conn !== null;
|
|
3016
|
-
const visibleNodes = (0,
|
|
3017
|
-
const visibleEdges = (0,
|
|
3266
|
+
const visibleNodes = (0, import_react15.useMemo)(() => nodes.filter((n) => !n.hidden), [nodes]);
|
|
3267
|
+
const visibleEdges = (0, import_react15.useMemo)(() => {
|
|
3018
3268
|
if (visibleNodes.length === nodes.length) return edges;
|
|
3019
3269
|
const visibleIds = new Set(visibleNodes.map((n) => n.id));
|
|
3020
3270
|
return edges.filter((e) => visibleIds.has(e.source) && visibleIds.has(e.target));
|
|
3021
3271
|
}, [edges, nodes, visibleNodes]);
|
|
3022
|
-
const orderedNodes = (0,
|
|
3272
|
+
const orderedNodes = (0, import_react15.useMemo)(() => {
|
|
3023
3273
|
const isContainer = (n) => n.type === "group" || n.type === "forEach";
|
|
3024
3274
|
const depth = (n) => {
|
|
3025
3275
|
let d = 0;
|
|
@@ -3038,7 +3288,7 @@ function FlowCanvas({
|
|
|
3038
3288
|
containers.sort((a, b) => depth(a) - depth(b));
|
|
3039
3289
|
return [...containers, ...others];
|
|
3040
3290
|
}, [visibleNodes]);
|
|
3041
|
-
return /* @__PURE__ */ (0,
|
|
3291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FlowStoreContext.Provider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FlowInstanceContext.Provider, { value: instance, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HandleRegistryContext.Provider, { value: handleRegistry, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FlowDispatchContext.Provider, { value: dispatch, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FlowNodeBridgeContext.Provider, { value: bridge, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3042
3292
|
"div",
|
|
3043
3293
|
{
|
|
3044
3294
|
ref: containerRef,
|
|
@@ -3083,7 +3333,7 @@ function FlowCanvas({
|
|
|
3083
3333
|
},
|
|
3084
3334
|
"data-empty": isEmpty ? "true" : void 0,
|
|
3085
3335
|
children: [
|
|
3086
|
-
background !== "none" && /* @__PURE__ */ (0,
|
|
3336
|
+
background !== "none" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3087
3337
|
"div",
|
|
3088
3338
|
{
|
|
3089
3339
|
className: cn(
|
|
@@ -3097,7 +3347,7 @@ function FlowCanvas({
|
|
|
3097
3347
|
}
|
|
3098
3348
|
}
|
|
3099
3349
|
),
|
|
3100
|
-
/* @__PURE__ */ (0,
|
|
3350
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3101
3351
|
"div",
|
|
3102
3352
|
{
|
|
3103
3353
|
className: "ods-flow-canvas-v2__viewport",
|
|
@@ -3108,7 +3358,7 @@ function FlowCanvas({
|
|
|
3108
3358
|
transformOrigin: "0 0"
|
|
3109
3359
|
},
|
|
3110
3360
|
children: [
|
|
3111
|
-
/* @__PURE__ */ (0,
|
|
3361
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3112
3362
|
EdgesLayer,
|
|
3113
3363
|
{
|
|
3114
3364
|
edges: visibleEdges,
|
|
@@ -3123,7 +3373,7 @@ function FlowCanvas({
|
|
|
3123
3373
|
orderedNodes.map((node) => {
|
|
3124
3374
|
const Kind = kinds[node.type] ?? kinds.action;
|
|
3125
3375
|
if (!Kind) return null;
|
|
3126
|
-
return /* @__PURE__ */ (0,
|
|
3376
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3127
3377
|
FlowNode,
|
|
3128
3378
|
{
|
|
3129
3379
|
node,
|
|
@@ -3138,7 +3388,7 @@ function FlowCanvas({
|
|
|
3138
3388
|
]
|
|
3139
3389
|
}
|
|
3140
3390
|
),
|
|
3141
|
-
isEmpty && emptyState && /* @__PURE__ */ (0,
|
|
3391
|
+
isEmpty && emptyState && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "ods-flow-canvas-v2__empty", children: emptyState }),
|
|
3142
3392
|
children
|
|
3143
3393
|
]
|
|
3144
3394
|
}
|
|
@@ -3147,7 +3397,60 @@ function FlowCanvas({
|
|
|
3147
3397
|
function onEdgesChangeRef(id, cb) {
|
|
3148
3398
|
cb?.([change.edge.remove(id)]);
|
|
3149
3399
|
}
|
|
3150
|
-
|
|
3400
|
+
function computeContainerAutoResize(nodes, pending, padding) {
|
|
3401
|
+
const projected = /* @__PURE__ */ new Map();
|
|
3402
|
+
for (const n of nodes) projected.set(n.id, n);
|
|
3403
|
+
for (const c of pending) {
|
|
3404
|
+
if (c.type === "position" && c.position) {
|
|
3405
|
+
const cur = projected.get(c.id);
|
|
3406
|
+
if (cur) projected.set(c.id, { ...cur, position: c.position });
|
|
3407
|
+
} else if (c.type === "replace" && c.item) {
|
|
3408
|
+
projected.set(c.id, { ...projected.get(c.id), ...c.item });
|
|
3409
|
+
} else if (c.type === "add" && c.item) {
|
|
3410
|
+
projected.set(c.item.id, c.item);
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
const HEADER = 56;
|
|
3414
|
+
const out = [];
|
|
3415
|
+
for (const parent of projected.values()) {
|
|
3416
|
+
if (parent.type !== "group" && parent.type !== "forEach") continue;
|
|
3417
|
+
const children = [];
|
|
3418
|
+
for (const n of projected.values()) {
|
|
3419
|
+
if (n.parentId === parent.id) children.push(n);
|
|
3420
|
+
}
|
|
3421
|
+
if (children.length === 0) continue;
|
|
3422
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
3423
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
3424
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
3425
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
3426
|
+
for (const c of children) {
|
|
3427
|
+
const cw = c.width ?? 240;
|
|
3428
|
+
const ch = c.height ?? 96;
|
|
3429
|
+
if (c.position.x < minX) minX = c.position.x;
|
|
3430
|
+
if (c.position.y < minY) minY = c.position.y;
|
|
3431
|
+
if (c.position.x + cw > maxX) maxX = c.position.x + cw;
|
|
3432
|
+
if (c.position.y + ch > maxY) maxY = c.position.y + ch;
|
|
3433
|
+
}
|
|
3434
|
+
const targetX = minX - padding;
|
|
3435
|
+
const targetY = minY - padding - HEADER;
|
|
3436
|
+
const targetW = maxX - minX + padding * 2;
|
|
3437
|
+
const targetH = maxY - minY + padding * 2 + HEADER;
|
|
3438
|
+
const curW = parent.width ?? 480;
|
|
3439
|
+
const curH = parent.height ?? 240;
|
|
3440
|
+
const nextW = Math.max(curW, targetW);
|
|
3441
|
+
const nextH = Math.max(curH, targetH);
|
|
3442
|
+
const positionDirty = parent.position.x !== targetX || parent.position.y !== targetY;
|
|
3443
|
+
const sizeDirty = curW !== nextW || curH !== nextH;
|
|
3444
|
+
if (positionDirty) {
|
|
3445
|
+
out.push(change.node.position(parent.id, { x: targetX, y: targetY }, false));
|
|
3446
|
+
}
|
|
3447
|
+
if (sizeDirty) {
|
|
3448
|
+
out.push(change.node.dimensions(parent.id, { width: nextW, height: nextH }));
|
|
3449
|
+
}
|
|
3450
|
+
}
|
|
3451
|
+
return out;
|
|
3452
|
+
}
|
|
3453
|
+
var EdgesLayer = (0, import_react15.memo)(function EdgesLayer2({
|
|
3151
3454
|
edges,
|
|
3152
3455
|
nodes,
|
|
3153
3456
|
onSelect,
|
|
@@ -3156,7 +3459,7 @@ var EdgesLayer = (0, import_react14.memo)(function EdgesLayer2({
|
|
|
3156
3459
|
ghost,
|
|
3157
3460
|
handleVersion: _handleVersion
|
|
3158
3461
|
}) {
|
|
3159
|
-
return /* @__PURE__ */ (0,
|
|
3462
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3160
3463
|
"svg",
|
|
3161
3464
|
{
|
|
3162
3465
|
className: "ods-flow-canvas-v2__edges",
|
|
@@ -3164,7 +3467,7 @@ var EdgesLayer = (0, import_react14.memo)(function EdgesLayer2({
|
|
|
3164
3467
|
width: "100%",
|
|
3165
3468
|
height: "100%",
|
|
3166
3469
|
children: [
|
|
3167
|
-
/* @__PURE__ */ (0,
|
|
3470
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("g", { style: { pointerEvents: "auto" }, children: edges.map((edge) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3168
3471
|
FlowEdge,
|
|
3169
3472
|
{
|
|
3170
3473
|
edge,
|
|
@@ -3176,7 +3479,7 @@ var EdgesLayer = (0, import_react14.memo)(function EdgesLayer2({
|
|
|
3176
3479
|
},
|
|
3177
3480
|
edge.id
|
|
3178
3481
|
)) }),
|
|
3179
|
-
ghost && /* @__PURE__ */ (0,
|
|
3482
|
+
ghost && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3180
3483
|
"path",
|
|
3181
3484
|
{
|
|
3182
3485
|
d: `M ${ghost.start.x} ${ghost.start.y} L ${ghost.end.x} ${ghost.end.y}`,
|
|
@@ -3191,151 +3494,6 @@ var EdgesLayer = (0, import_react14.memo)(function EdgesLayer2({
|
|
|
3191
3494
|
);
|
|
3192
3495
|
});
|
|
3193
3496
|
|
|
3194
|
-
// src/workflow/components/NodeResizer/NodeResizer.tsx
|
|
3195
|
-
var import_react15 = require("react");
|
|
3196
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3197
|
-
function NodeResizer({
|
|
3198
|
-
isVisible,
|
|
3199
|
-
minWidth = 80,
|
|
3200
|
-
minHeight = 60,
|
|
3201
|
-
maxWidth,
|
|
3202
|
-
maxHeight,
|
|
3203
|
-
keepAspectRatio = false,
|
|
3204
|
-
onResize,
|
|
3205
|
-
onResizeEnd,
|
|
3206
|
-
color
|
|
3207
|
-
}) {
|
|
3208
|
-
const { node, selected } = useFlowNodeContext();
|
|
3209
|
-
const viewport = useViewport();
|
|
3210
|
-
const flow = useFlow();
|
|
3211
|
-
const dragRef = (0, import_react15.useRef)(null);
|
|
3212
|
-
const show = isVisible ?? selected;
|
|
3213
|
-
if (!show) return null;
|
|
3214
|
-
const beginResize = (e, corner) => {
|
|
3215
|
-
e.preventDefault();
|
|
3216
|
-
e.stopPropagation();
|
|
3217
|
-
e.target.setPointerCapture(e.pointerId);
|
|
3218
|
-
const w = node.width ?? DEFAULT_NODE_WIDTH;
|
|
3219
|
-
const h = node.height ?? DEFAULT_NODE_HEIGHT;
|
|
3220
|
-
dragRef.current = {
|
|
3221
|
-
pointerId: e.pointerId,
|
|
3222
|
-
corner,
|
|
3223
|
-
startClientX: e.clientX,
|
|
3224
|
-
startClientY: e.clientY,
|
|
3225
|
-
startWidth: w,
|
|
3226
|
-
startHeight: h,
|
|
3227
|
-
startX: node.position.x,
|
|
3228
|
-
startY: node.position.y,
|
|
3229
|
-
aspect: w / Math.max(1, h)
|
|
3230
|
-
};
|
|
3231
|
-
};
|
|
3232
|
-
const onMove = (e) => {
|
|
3233
|
-
const drag = dragRef.current;
|
|
3234
|
-
if (!drag || drag.pointerId !== e.pointerId) return;
|
|
3235
|
-
const dx = (e.clientX - drag.startClientX) / viewport.zoom;
|
|
3236
|
-
const dy = (e.clientY - drag.startClientY) / viewport.zoom;
|
|
3237
|
-
let nextW = drag.startWidth;
|
|
3238
|
-
let nextH = drag.startHeight;
|
|
3239
|
-
let nextX = drag.startX;
|
|
3240
|
-
let nextY = drag.startY;
|
|
3241
|
-
switch (drag.corner) {
|
|
3242
|
-
case "se":
|
|
3243
|
-
nextW = drag.startWidth + dx;
|
|
3244
|
-
nextH = drag.startHeight + dy;
|
|
3245
|
-
break;
|
|
3246
|
-
case "sw":
|
|
3247
|
-
nextW = drag.startWidth - dx;
|
|
3248
|
-
nextH = drag.startHeight + dy;
|
|
3249
|
-
nextX = drag.startX + dx;
|
|
3250
|
-
break;
|
|
3251
|
-
case "ne":
|
|
3252
|
-
nextW = drag.startWidth + dx;
|
|
3253
|
-
nextH = drag.startHeight - dy;
|
|
3254
|
-
nextY = drag.startY + dy;
|
|
3255
|
-
break;
|
|
3256
|
-
case "nw":
|
|
3257
|
-
nextW = drag.startWidth - dx;
|
|
3258
|
-
nextH = drag.startHeight - dy;
|
|
3259
|
-
nextX = drag.startX + dx;
|
|
3260
|
-
nextY = drag.startY + dy;
|
|
3261
|
-
break;
|
|
3262
|
-
}
|
|
3263
|
-
if (keepAspectRatio) {
|
|
3264
|
-
nextH = nextW / drag.aspect;
|
|
3265
|
-
if (drag.corner === "nw" || drag.corner === "ne") {
|
|
3266
|
-
nextY = drag.startY + (drag.startHeight - nextH);
|
|
3267
|
-
}
|
|
3268
|
-
}
|
|
3269
|
-
nextW = Math.max(minWidth, maxWidth ? Math.min(maxWidth, nextW) : nextW);
|
|
3270
|
-
nextH = Math.max(minHeight, maxHeight ? Math.min(maxHeight, nextH) : nextH);
|
|
3271
|
-
flow.updateNode(node.id, {
|
|
3272
|
-
width: nextW,
|
|
3273
|
-
height: nextH,
|
|
3274
|
-
position: { x: nextX, y: nextY }
|
|
3275
|
-
});
|
|
3276
|
-
onResize?.({ width: nextW, height: nextH });
|
|
3277
|
-
};
|
|
3278
|
-
const onUp = (e) => {
|
|
3279
|
-
if (dragRef.current?.pointerId === e.pointerId) {
|
|
3280
|
-
const cur = flow.getNode(node.id);
|
|
3281
|
-
if (cur) {
|
|
3282
|
-
onResizeEnd?.({
|
|
3283
|
-
width: cur.width ?? DEFAULT_NODE_WIDTH,
|
|
3284
|
-
height: cur.height ?? DEFAULT_NODE_HEIGHT
|
|
3285
|
-
});
|
|
3286
|
-
}
|
|
3287
|
-
dragRef.current = null;
|
|
3288
|
-
}
|
|
3289
|
-
};
|
|
3290
|
-
const handleColor = color ?? "var(--ods-accent)";
|
|
3291
|
-
const handleStyle = (corner) => {
|
|
3292
|
-
const base = {
|
|
3293
|
-
position: "absolute",
|
|
3294
|
-
width: 12,
|
|
3295
|
-
height: 12,
|
|
3296
|
-
background: "var(--ods-surface-canvas)",
|
|
3297
|
-
border: `2px solid ${handleColor}`,
|
|
3298
|
-
borderRadius: 2,
|
|
3299
|
-
cursor: cursorFor(corner),
|
|
3300
|
-
touchAction: "none",
|
|
3301
|
-
// Place each handle so its CENTRE sits on the corresponding corner.
|
|
3302
|
-
transform: "translate(-50%, -50%)"
|
|
3303
|
-
};
|
|
3304
|
-
switch (corner) {
|
|
3305
|
-
case "nw":
|
|
3306
|
-
return { ...base, top: 0, left: 0 };
|
|
3307
|
-
case "ne":
|
|
3308
|
-
return { ...base, top: 0, left: "100%" };
|
|
3309
|
-
case "sw":
|
|
3310
|
-
return { ...base, top: "100%", left: 0 };
|
|
3311
|
-
case "se":
|
|
3312
|
-
return { ...base, top: "100%", left: "100%" };
|
|
3313
|
-
}
|
|
3314
|
-
};
|
|
3315
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: cn("ods-node-resizer"), "data-flow-no-drag": "true", children: ["nw", "ne", "sw", "se"].map((corner) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3316
|
-
"div",
|
|
3317
|
-
{
|
|
3318
|
-
style: handleStyle(corner),
|
|
3319
|
-
onPointerDown: (e) => beginResize(e, corner),
|
|
3320
|
-
onPointerMove: onMove,
|
|
3321
|
-
onPointerUp: onUp,
|
|
3322
|
-
onPointerCancel: onUp,
|
|
3323
|
-
"aria-label": `Resize ${corner}`
|
|
3324
|
-
},
|
|
3325
|
-
corner
|
|
3326
|
-
)) });
|
|
3327
|
-
}
|
|
3328
|
-
function cursorFor(corner) {
|
|
3329
|
-
switch (corner) {
|
|
3330
|
-
case "nw":
|
|
3331
|
-
case "se":
|
|
3332
|
-
return "nwse-resize";
|
|
3333
|
-
case "ne":
|
|
3334
|
-
case "sw":
|
|
3335
|
-
return "nesw-resize";
|
|
3336
|
-
}
|
|
3337
|
-
}
|
|
3338
|
-
|
|
3339
3497
|
// src/workflow/components/NodeToolbar/NodeToolbar.tsx
|
|
3340
3498
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3341
3499
|
function NodeToolbar({
|
|
@@ -3564,6 +3722,7 @@ function toggleGroupCollapse(groupId, nodes) {
|
|
|
3564
3722
|
useNodeData,
|
|
3565
3723
|
useNodes,
|
|
3566
3724
|
useSelection,
|
|
3567
|
-
useViewport
|
|
3725
|
+
useViewport,
|
|
3726
|
+
useViewportOrNull
|
|
3568
3727
|
});
|
|
3569
3728
|
//# sourceMappingURL=workflow.cjs.map
|