@agentscope-ai/flow 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.zh-CN.md +67 -0
- package/dist/components/base-node/index.d.ts +27 -0
- package/dist/components/base-node/index.js +320 -0
- package/dist/components/base-node/index.less +258 -0
- package/dist/components/branch-title-header/index.d.ts +12 -0
- package/dist/components/branch-title-header/index.js +176 -0
- package/dist/components/branch-title-header/index.less +28 -0
- package/dist/components/check-list-btn/index.d.ts +4 -0
- package/dist/components/check-list-btn/index.js +144 -0
- package/dist/components/check-list-btn/index.less +113 -0
- package/dist/components/code-input/index.d.ts +24 -0
- package/dist/components/code-input/index.js +356 -0
- package/dist/components/code-input/index.less +87 -0
- package/dist/components/condition-item/index.d.ts +13 -0
- package/dist/components/condition-item/index.js +185 -0
- package/dist/components/condition-item/index.less +23 -0
- package/dist/components/custom-connection-line/index.d.ts +4 -0
- package/dist/components/custom-connection-line/index.js +28 -0
- package/dist/components/custom-handle/source-handle.d.ts +10 -0
- package/dist/components/custom-handle/source-handle.js +45 -0
- package/dist/components/custom-handle/target-handle.d.ts +6 -0
- package/dist/components/custom-handle/target-handle.js +21 -0
- package/dist/components/custom-inputs-control/index.d.ts +56 -0
- package/dist/components/custom-inputs-control/index.js +366 -0
- package/dist/components/custom-inputs-control/index.less +28 -0
- package/dist/components/custom-outputs-form/index.d.ts +24 -0
- package/dist/components/custom-outputs-form/index.js +346 -0
- package/dist/components/custom-outputs-form/index.less +51 -0
- package/dist/components/drag-panel/index.d.ts +10 -0
- package/dist/components/drag-panel/index.js +79 -0
- package/dist/components/drag-panel/index.less +23 -0
- package/dist/components/draggable-with-handle/index.d.ts +13 -0
- package/dist/components/draggable-with-handle/index.js +81 -0
- package/dist/components/draggable-with-handle/index.less +23 -0
- package/dist/components/flow-aside/index.d.ts +4 -0
- package/dist/components/flow-aside/index.js +62 -0
- package/dist/components/flow-aside/index.less +84 -0
- package/dist/components/flow-base-edge/index.d.ts +5 -0
- package/dist/components/flow-base-edge/index.js +226 -0
- package/dist/components/flow-base-edge/index.less +28 -0
- package/dist/components/flow-base-edge/linear-gradient-svg.d.ts +21 -0
- package/dist/components/flow-base-edge/linear-gradient-svg.js +32 -0
- package/dist/components/flow-icon/index.d.ts +9 -0
- package/dist/components/flow-icon/index.js +30 -0
- package/dist/components/flow-icon/index.less +20 -0
- package/dist/components/flow-mini-map/index.d.ts +4 -0
- package/dist/components/flow-mini-map/index.js +26 -0
- package/dist/components/flow-mini-map/index.less +22 -0
- package/dist/components/flow-panel/config-panel.d.ts +15 -0
- package/dist/components/flow-panel/config-panel.js +303 -0
- package/dist/components/flow-panel/index.d.ts +7 -0
- package/dist/components/flow-panel/index.js +7 -0
- package/dist/components/flow-panel/index.less +85 -0
- package/dist/components/flow-panel/panel-container.d.ts +12 -0
- package/dist/components/flow-panel/panel-container.js +25 -0
- package/dist/components/flow-tools/add-node-btn.d.ts +3 -0
- package/dist/components/flow-tools/add-node-btn.js +26 -0
- package/dist/components/flow-tools/history-btn.d.ts +3 -0
- package/dist/components/flow-tools/history-btn.js +59 -0
- package/dist/components/flow-tools/index.d.ts +4 -0
- package/dist/components/flow-tools/index.js +29 -0
- package/dist/components/flow-tools/index.less +82 -0
- package/dist/components/flow-tools/layout-btn.d.ts +3 -0
- package/dist/components/flow-tools/layout-btn.js +27 -0
- package/dist/components/flow-tools/mini-map-btn.d.ts +3 -0
- package/dist/components/flow-tools/mini-map-btn.js +32 -0
- package/dist/components/flow-tools/scale-btn.d.ts +3 -0
- package/dist/components/flow-tools/scale-btn.js +101 -0
- package/dist/components/flow-tools/short-key-btn.d.ts +3 -0
- package/dist/components/flow-tools/short-key-btn.js +38 -0
- package/dist/components/flow-tools/short-key-content.d.ts +4 -0
- package/dist/components/flow-tools/short-key-content.js +153 -0
- package/dist/components/flow-tools/short-key-content.less +38 -0
- package/dist/components/flow-tools/touch-mode-btn.d.ts +3 -0
- package/dist/components/flow-tools/touch-mode-btn.js +89 -0
- package/dist/components/input-text-area/index.d.ts +16 -0
- package/dist/components/input-text-area/index.js +74 -0
- package/dist/components/input-text-area/index.less +30 -0
- package/dist/components/judge-form/index.d.ts +13 -0
- package/dist/components/judge-form/index.js +182 -0
- package/dist/components/judge-form/index.less +11 -0
- package/dist/components/node-menu/index.d.ts +35 -0
- package/dist/components/node-menu/index.js +266 -0
- package/dist/components/node-menu/index.less +79 -0
- package/dist/components/node-resizer/index.d.ts +11 -0
- package/dist/components/node-resizer/index.js +46 -0
- package/dist/components/node-resizer/index.less +12 -0
- package/dist/components/node-result-panel/index.d.ts +9 -0
- package/dist/components/node-result-panel/index.js +155 -0
- package/dist/components/node-result-panel/index.less +132 -0
- package/dist/components/node-tree/index.d.ts +4 -0
- package/dist/components/node-tree/index.js +213 -0
- package/dist/components/node-tree/index.less +51 -0
- package/dist/components/output-params-tree/index.d.ts +10 -0
- package/dist/components/output-params-tree/index.js +34 -0
- package/dist/components/output-params-tree/index.less +27 -0
- package/dist/components/script-code-mirror/index.d.ts +14 -0
- package/dist/components/script-code-mirror/index.js +162 -0
- package/dist/components/script-code-mirror/index.less +11 -0
- package/dist/components/script-edit-modal/index.d.ts +30 -0
- package/dist/components/script-edit-modal/index.js +84 -0
- package/dist/components/script-edit-modal/index.less +24 -0
- package/dist/components/select-with-desc/index.d.ts +5 -0
- package/dist/components/select-with-desc/index.js +20 -0
- package/dist/components/select-with-desc/index.less +11 -0
- package/dist/components/task-status/index.d.ts +4 -0
- package/dist/components/task-status/index.js +209 -0
- package/dist/components/task-status/index.less +65 -0
- package/dist/components/var-input-text-area/index.d.ts +17 -0
- package/dist/components/var-input-text-area/index.js +211 -0
- package/dist/components/var-input-text-area/index.less +64 -0
- package/dist/components/var-type-prefix/index.d.ts +17 -0
- package/dist/components/var-type-prefix/index.js +21 -0
- package/dist/components/variable-input/index.d.ts +24 -0
- package/dist/components/variable-input/index.js +163 -0
- package/dist/components/variable-input/index.less +13 -0
- package/dist/components/variable-tree-select/index.d.ts +33 -0
- package/dist/components/variable-tree-select/index.js +160 -0
- package/dist/components/variable-tree-select/index.less +61 -0
- package/dist/constant/index.d.ts +61 -0
- package/dist/constant/index.js +515 -0
- package/dist/flow/animate.css +5 -0
- package/dist/flow/context.d.ts +12 -0
- package/dist/flow/context.js +44 -0
- package/dist/flow/index.d.ts +13 -0
- package/dist/flow/index.js +162 -0
- package/dist/flow/index.less +72 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.js +10 -0
- package/dist/hooks/use-edges-interaction.d.ts +11 -0
- package/dist/hooks/use-edges-interaction.js +125 -0
- package/dist/hooks/use-flow-debug-interaction.d.ts +5 -0
- package/dist/hooks/use-flow-debug-interaction.js +23 -0
- package/dist/hooks/use-flow-interaction.d.ts +12 -0
- package/dist/hooks/use-flow-interaction.js +173 -0
- package/dist/hooks/use-flow-key-press.d.ts +1 -0
- package/dist/hooks/use-flow-key-press.js +32 -0
- package/dist/hooks/use-flow-save.d.ts +5 -0
- package/dist/hooks/use-flow-save.js +47 -0
- package/dist/hooks/use-flow-view-port.d.ts +7 -0
- package/dist/hooks/use-flow-view-port.js +46 -0
- package/dist/hooks/use-history.d.ts +21 -0
- package/dist/hooks/use-history.js +80 -0
- package/dist/hooks/use-nodes-interaction.d.ts +34 -0
- package/dist/hooks/use-nodes-interaction.js +777 -0
- package/dist/hooks/use-nodes-output-params.d.ts +31 -0
- package/dist/hooks/use-nodes-output-params.js +300 -0
- package/dist/hooks/use-nodes-update.d.ts +9 -0
- package/dist/hooks/use-nodes-update.js +38 -0
- package/dist/hooks/use-work-flow.d.ts +4 -0
- package/dist/hooks/use-work-flow.js +21 -0
- package/dist/i18n/i18n.d.ts +62 -0
- package/dist/i18n/i18n.js +111 -0
- package/dist/i18n/index.d.ts +3 -0
- package/dist/i18n/index.js +12 -0
- package/dist/i18n/locales/en-us.json +327 -0
- package/dist/i18n/locales/ja-jp.json +300 -0
- package/dist/i18n/locales/zh-cn.json +327 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +47 -0
- package/dist/index.less +1 -0
- package/dist/store/index.d.ts +70 -0
- package/dist/store/index.js +146 -0
- package/dist/tailwind.css +28 -0
- package/dist/types/work-flow.d.ts +188 -0
- package/dist/types/work-flow.js +1 -0
- package/dist/utils/default-values.d.ts +2 -0
- package/dist/utils/default-values.js +16 -0
- package/dist/utils/index.d.ts +39 -0
- package/dist/utils/index.js +273 -0
- package/dist/utils/unique-id.d.ts +2 -0
- package/dist/utils/unique-id.js +39 -0
- package/dist/utils/work-flow.d.ts +17 -0
- package/dist/utils/work-flow.js +44 -0
- package/package.json +78 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isEventInInput, transformToMacKey } from "../utils";
|
|
2
|
+
import { useReactFlow } from '@xyflow/react';
|
|
3
|
+
import { useKeyPress } from 'ahooks';
|
|
4
|
+
import { useNodesReadOnly } from "./use-work-flow";
|
|
5
|
+
export default function useFlowKeyPress() {
|
|
6
|
+
var reactFlow = useReactFlow();
|
|
7
|
+
var _useNodesReadOnly = useNodesReadOnly(),
|
|
8
|
+
nodesReadOnly = _useNodesReadOnly.nodesReadOnly;
|
|
9
|
+
useKeyPress(["".concat(transformToMacKey('ctrl'), ".d"), 'delete'], function (event) {
|
|
10
|
+
event.preventDefault();
|
|
11
|
+
if (isEventInInput(event) || nodesReadOnly) return;
|
|
12
|
+
var needDeleteNodes = [];
|
|
13
|
+
var needDeleteEdges = [];
|
|
14
|
+
var nodes = reactFlow.getNodes();
|
|
15
|
+
var edges = reactFlow.getEdges();
|
|
16
|
+
nodes.forEach(function (item) {
|
|
17
|
+
if (item.selected) needDeleteNodes.push({
|
|
18
|
+
id: item.id
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
edges.forEach(function (item) {
|
|
22
|
+
if (item.selected) needDeleteEdges.push({
|
|
23
|
+
id: item.id
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
if (!needDeleteNodes.length && !needDeleteEdges) return;
|
|
27
|
+
reactFlow.deleteElements({
|
|
28
|
+
nodes: needDeleteNodes,
|
|
29
|
+
edges: needDeleteEdges
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useStore } from "../flow/context";
|
|
2
|
+
import { useStoreApi } from '@xyflow/react';
|
|
3
|
+
import { debounce } from 'lodash-es';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import { useHistory } from "./use-history";
|
|
6
|
+
export var useFlowSave = function useFlowSave() {
|
|
7
|
+
var store = useStoreApi();
|
|
8
|
+
var onFlowDataChange = useStore(function (state) {
|
|
9
|
+
return state.onChange;
|
|
10
|
+
});
|
|
11
|
+
var onFlowDataDebounceChange = useStore(function (state) {
|
|
12
|
+
return state.onDebounceChange;
|
|
13
|
+
});
|
|
14
|
+
var debounceChangeTimeout = useStore(function (state) {
|
|
15
|
+
return state.debounceChangeTimeout;
|
|
16
|
+
});
|
|
17
|
+
var _useHistory = useHistory(),
|
|
18
|
+
addHistoryStep = _useHistory.addHistoryStep;
|
|
19
|
+
var handleSaveFlowDraft = useCallback(debounce(function () {
|
|
20
|
+
var _store$getState = store.getState(),
|
|
21
|
+
nodes = _store$getState.nodes,
|
|
22
|
+
edges = _store$getState.edges;
|
|
23
|
+
addHistoryStep({
|
|
24
|
+
nodes: nodes,
|
|
25
|
+
edges: edges
|
|
26
|
+
});
|
|
27
|
+
if (!onFlowDataDebounceChange) return;
|
|
28
|
+
onFlowDataDebounceChange({
|
|
29
|
+
nodes: nodes,
|
|
30
|
+
edges: edges
|
|
31
|
+
});
|
|
32
|
+
}, debounceChangeTimeout), [store, addHistoryStep, onFlowDataDebounceChange]);
|
|
33
|
+
var onFlowChange = useCallback(function () {
|
|
34
|
+
var _store$getState2 = store.getState(),
|
|
35
|
+
nodes = _store$getState2.nodes,
|
|
36
|
+
edges = _store$getState2.edges;
|
|
37
|
+
onFlowDataChange({
|
|
38
|
+
nodes: nodes,
|
|
39
|
+
edges: edges
|
|
40
|
+
});
|
|
41
|
+
handleSaveFlowDraft();
|
|
42
|
+
}, [handleSaveFlowDraft, store, onFlowDataChange]);
|
|
43
|
+
return {
|
|
44
|
+
handleSaveFlowDraft: handleSaveFlowDraft,
|
|
45
|
+
onFlowChange: onFlowChange
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useStore } from "../flow/context";
|
|
8
|
+
import { useReactFlow, useViewport } from '@xyflow/react';
|
|
9
|
+
import { useCallback, useMemo } from 'react';
|
|
10
|
+
export var MIN_ZOOM = 0.1;
|
|
11
|
+
export var MAX_ZOOM = 2;
|
|
12
|
+
export var useFlowViewPort = function useFlowViewPort() {
|
|
13
|
+
var reactFlow = useReactFlow();
|
|
14
|
+
var handleSetScale = useCallback(function (scale) {
|
|
15
|
+
var _reactFlow$getViewpor = reactFlow.getViewport(),
|
|
16
|
+
x = _reactFlow$getViewpor.x,
|
|
17
|
+
y = _reactFlow$getViewpor.y;
|
|
18
|
+
reactFlow.setViewport({
|
|
19
|
+
zoom: scale,
|
|
20
|
+
x: x,
|
|
21
|
+
y: y
|
|
22
|
+
});
|
|
23
|
+
}, [reactFlow]);
|
|
24
|
+
var minMaxZoom = useStore(function (state) {
|
|
25
|
+
return state.minMaxZoom;
|
|
26
|
+
});
|
|
27
|
+
var handleScale = useCallback(function (options) {
|
|
28
|
+
var _reactFlow$getViewpor2 = reactFlow.getViewport(),
|
|
29
|
+
zoom = _reactFlow$getViewpor2.zoom;
|
|
30
|
+
var newZoom = parseFloat(zoom.toFixed(1)) + options * 0.2;
|
|
31
|
+
var _minMaxZoom = _slicedToArray(minMaxZoom, 2),
|
|
32
|
+
minZoom = _minMaxZoom[0],
|
|
33
|
+
maxZoom = _minMaxZoom[1];
|
|
34
|
+
handleSetScale(Math.max(minZoom, Math.min(newZoom, maxZoom)));
|
|
35
|
+
}, [reactFlow, handleSetScale]);
|
|
36
|
+
var _useViewport = useViewport(),
|
|
37
|
+
zoom = _useViewport.zoom;
|
|
38
|
+
var scaleRate = useMemo(function () {
|
|
39
|
+
return parseInt("".concat(zoom * 100));
|
|
40
|
+
}, [zoom]);
|
|
41
|
+
return {
|
|
42
|
+
handleScale: handleScale,
|
|
43
|
+
scaleRate: scaleRate,
|
|
44
|
+
handleSetScale: handleSetScale
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Edge } from '@xyflow/react';
|
|
2
|
+
import { IWorkFlowNode } from '../types/work-flow';
|
|
3
|
+
interface IHistoryStep {
|
|
4
|
+
edges: Edge[];
|
|
5
|
+
nodes: IWorkFlowNode[];
|
|
6
|
+
}
|
|
7
|
+
export declare const useHistory: () => {
|
|
8
|
+
canUndo: boolean;
|
|
9
|
+
canRedo: boolean;
|
|
10
|
+
addHistoryStep: (step: IHistoryStep) => void;
|
|
11
|
+
undo: () => {
|
|
12
|
+
edges: Edge[];
|
|
13
|
+
nodes: IWorkFlowNode[];
|
|
14
|
+
} | null;
|
|
15
|
+
redo: () => {
|
|
16
|
+
edges: Edge[];
|
|
17
|
+
nodes: IWorkFlowNode[];
|
|
18
|
+
} | null;
|
|
19
|
+
initHistoryStep: (step: IHistoryStep) => void;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
import { useStore } from "../flow/context";
|
|
8
|
+
import { useStoreApi } from '@xyflow/react';
|
|
9
|
+
import { useCallback } from 'react';
|
|
10
|
+
export var useHistory = function useHistory() {
|
|
11
|
+
var historySteps = useStore(function (state) {
|
|
12
|
+
return state.historySteps;
|
|
13
|
+
});
|
|
14
|
+
var setHistorySteps = useStore(function (state) {
|
|
15
|
+
return state.setHistorySteps;
|
|
16
|
+
});
|
|
17
|
+
var futureSteps = useStore(function (state) {
|
|
18
|
+
return state.futureSteps;
|
|
19
|
+
});
|
|
20
|
+
var setFutureSteps = useStore(function (state) {
|
|
21
|
+
return state.setFutureSteps;
|
|
22
|
+
});
|
|
23
|
+
var onDebounceChange = useStore(function (state) {
|
|
24
|
+
return state.onDebounceChange;
|
|
25
|
+
});
|
|
26
|
+
var store = useStoreApi();
|
|
27
|
+
var canUndo = historySteps.length > 1;
|
|
28
|
+
var canRedo = futureSteps.length > 0;
|
|
29
|
+
var initHistoryStep = useCallback(function (step) {
|
|
30
|
+
setHistorySteps([step]);
|
|
31
|
+
setFutureSteps([]);
|
|
32
|
+
}, [setHistorySteps, setFutureSteps]);
|
|
33
|
+
var addHistoryStep = useCallback(function (step) {
|
|
34
|
+
setHistorySteps([].concat(_toConsumableArray(historySteps), [step]));
|
|
35
|
+
setFutureSteps([]);
|
|
36
|
+
}, [historySteps, setHistorySteps, setFutureSteps]);
|
|
37
|
+
var undo = useCallback(function () {
|
|
38
|
+
if (!canUndo) return null;
|
|
39
|
+
var removedStep = historySteps[historySteps.length - 1];
|
|
40
|
+
var newHistorySteps = historySteps.slice(0, -1);
|
|
41
|
+
var currentStep = newHistorySteps[newHistorySteps.length - 1];
|
|
42
|
+
setHistorySteps(newHistorySteps);
|
|
43
|
+
setFutureSteps([removedStep].concat(_toConsumableArray(futureSteps)));
|
|
44
|
+
var _store$getState = store.getState(),
|
|
45
|
+
setNodes = _store$getState.setNodes,
|
|
46
|
+
setEdges = _store$getState.setEdges;
|
|
47
|
+
setNodes(currentStep.nodes);
|
|
48
|
+
setEdges(currentStep.edges);
|
|
49
|
+
onDebounceChange === null || onDebounceChange === void 0 || onDebounceChange({
|
|
50
|
+
nodes: currentStep.nodes,
|
|
51
|
+
edges: currentStep.edges
|
|
52
|
+
});
|
|
53
|
+
return currentStep;
|
|
54
|
+
}, [historySteps, futureSteps, setHistorySteps, setFutureSteps, canUndo]);
|
|
55
|
+
var redo = useCallback(function () {
|
|
56
|
+
if (!canRedo) return null;
|
|
57
|
+
var nextStep = futureSteps[0];
|
|
58
|
+
var newFutureSteps = futureSteps.slice(1);
|
|
59
|
+
setFutureSteps(newFutureSteps);
|
|
60
|
+
setHistorySteps([].concat(_toConsumableArray(historySteps), [nextStep]));
|
|
61
|
+
var _store$getState2 = store.getState(),
|
|
62
|
+
setNodes = _store$getState2.setNodes,
|
|
63
|
+
setEdges = _store$getState2.setEdges;
|
|
64
|
+
setNodes(nextStep.nodes);
|
|
65
|
+
setEdges(nextStep.edges);
|
|
66
|
+
onDebounceChange === null || onDebounceChange === void 0 || onDebounceChange({
|
|
67
|
+
nodes: nextStep.nodes,
|
|
68
|
+
edges: nextStep.edges
|
|
69
|
+
});
|
|
70
|
+
return nextStep;
|
|
71
|
+
}, [historySteps, futureSteps, setHistorySteps, setFutureSteps, canRedo]);
|
|
72
|
+
return {
|
|
73
|
+
canUndo: canUndo,
|
|
74
|
+
canRedo: canRedo,
|
|
75
|
+
addHistoryStep: addHistoryStep,
|
|
76
|
+
undo: undo,
|
|
77
|
+
redo: redo,
|
|
78
|
+
initHistoryStep: initHistoryStep
|
|
79
|
+
};
|
|
80
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IPointItem, IWorkFlowNode } from "../types/work-flow";
|
|
2
|
+
import type { Connection, NodeMouseHandler, OnNodeDrag, OnNodesChange } from '@xyflow/react';
|
|
3
|
+
export declare const useNodesInteraction: () => {
|
|
4
|
+
onConnect: (connection: Connection) => void;
|
|
5
|
+
onAddNewNode: ({ type, parentId, parentNodeType, }: {
|
|
6
|
+
type: string;
|
|
7
|
+
parentId?: string | undefined;
|
|
8
|
+
parentNodeType?: string | undefined;
|
|
9
|
+
}, position: {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
onNodeDrag: OnNodeDrag;
|
|
14
|
+
onAddNewNodeWithSource: ({ type, parentId }: {
|
|
15
|
+
type: string;
|
|
16
|
+
parentId?: string | undefined;
|
|
17
|
+
}, source: IPointItem, target?: IPointItem) => Promise<void>;
|
|
18
|
+
onNodesChange: OnNodesChange;
|
|
19
|
+
onNodeClick: NodeMouseHandler<IWorkFlowNode>;
|
|
20
|
+
handleNodeClick: (node: IWorkFlowNode) => void;
|
|
21
|
+
handleSelectNode: (nodeId: string) => void;
|
|
22
|
+
onNodeResize: (resizeBound: {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
}, nodeId: string) => void;
|
|
28
|
+
onNodeDelete: (nodeId: string) => void;
|
|
29
|
+
onNodeCopy: (nodeId: string) => void;
|
|
30
|
+
handleNodeClickByNodeId: (nodeId: string) => void;
|
|
31
|
+
updateParentNodeSize: (nodeId: string) => void;
|
|
32
|
+
onDrop: (event: React.DragEvent<HTMLDivElement>, parentId?: string) => void;
|
|
33
|
+
onDragOver: (event: React.DragEvent<HTMLDivElement>) => void;
|
|
34
|
+
};
|