@rxflow/workflow 0.0.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/cjs/components/CanvasLoading/index.d.ts +14 -0
- package/cjs/components/CanvasLoading/index.d.ts.map +1 -0
- package/cjs/components/CanvasLoading/index.js +51 -0
- package/cjs/components/CanvasLoading/index.less +69 -0
- package/cjs/components/CodeEditor/DebugPanel/index.d.ts +16 -0
- package/cjs/components/CodeEditor/DebugPanel/index.d.ts.map +1 -0
- package/cjs/components/CodeEditor/DebugPanel/index.js +156 -0
- package/cjs/components/CodeEditor/DebugPanel/index.less +56 -0
- package/cjs/components/CodeEditor/FileTree/LibraryIcon.d.ts +11 -0
- package/cjs/components/CodeEditor/FileTree/LibraryIcon.d.ts.map +1 -0
- package/cjs/components/CodeEditor/FileTree/LibraryIcon.js +33 -0
- package/cjs/components/CodeEditor/FileTree/icons/Javascript.d.ts +11 -0
- package/cjs/components/CodeEditor/FileTree/icons/Javascript.d.ts.map +1 -0
- package/cjs/components/CodeEditor/FileTree/icons/Javascript.js +37 -0
- package/cjs/components/CodeEditor/FileTree/icons/Python.d.ts +11 -0
- package/cjs/components/CodeEditor/FileTree/icons/Python.d.ts.map +1 -0
- package/cjs/components/CodeEditor/FileTree/icons/Python.js +37 -0
- package/cjs/components/CodeEditor/FileTree/index.d.ts +9 -0
- package/cjs/components/CodeEditor/FileTree/index.d.ts.map +1 -0
- package/cjs/components/CodeEditor/FileTree/index.js +73 -0
- package/cjs/components/CodeEditor/FileTree/index.less +83 -0
- package/cjs/components/CodeEditor/FileTree/useFileIcon.d.ts +11 -0
- package/cjs/components/CodeEditor/FileTree/useFileIcon.d.ts.map +1 -0
- package/cjs/components/CodeEditor/FileTree/useFileIcon.js +44 -0
- package/cjs/components/CodeEditor/Header/index.d.ts +15 -0
- package/cjs/components/CodeEditor/Header/index.d.ts.map +1 -0
- package/cjs/components/CodeEditor/Header/index.js +51 -0
- package/cjs/components/CodeEditor/Header/style.less +23 -0
- package/cjs/components/CodeEditor/Terminal/XTerm.d.ts +5 -0
- package/cjs/components/CodeEditor/Terminal/XTerm.d.ts.map +1 -0
- package/cjs/components/CodeEditor/Terminal/XTerm.js +54 -0
- package/cjs/components/CodeEditor/Terminal/index.d.ts +15 -0
- package/cjs/components/CodeEditor/Terminal/index.d.ts.map +1 -0
- package/cjs/components/CodeEditor/Terminal/index.js +30 -0
- package/cjs/components/CodeEditor/Terminal/index.less +28 -0
- package/cjs/components/CodeEditor/Terminal/types.d.ts +13 -0
- package/cjs/components/CodeEditor/editors/JSON.d.ts +12 -0
- package/cjs/components/CodeEditor/editors/JSON.d.ts.map +1 -0
- package/cjs/components/CodeEditor/editors/JSON.js +43 -0
- package/cjs/components/CodeEditor/editors/Python.d.ts +4 -0
- package/cjs/components/CodeEditor/editors/Python.d.ts.map +1 -0
- package/cjs/components/CodeEditor/editors/Python.js +43 -0
- package/cjs/components/CodeEditor/editors/index.less +11 -0
- package/cjs/components/CodeEditor/editors/types.d.ts +24 -0
- package/cjs/components/CodeEditor/index.d.ts +7 -0
- package/cjs/components/CodeEditor/index.d.ts.map +1 -0
- package/cjs/components/CodeEditor/index.js +230 -0
- package/cjs/components/CodeEditor/style.less +49 -0
- package/cjs/components/CodeEditor/types.d.ts +46 -0
- package/cjs/components/Handle/NodePopover.d.ts +15 -0
- package/cjs/components/Handle/NodePopover.d.ts.map +1 -0
- package/cjs/components/Handle/NodePopover.js +169 -0
- package/cjs/components/Handle/index.d.ts +24 -0
- package/cjs/components/Handle/index.d.ts.map +1 -0
- package/cjs/components/Handle/index.js +165 -0
- package/cjs/components/Handle/index.less +111 -0
- package/cjs/components/InlineCodeEditor/index.d.ts +11 -0
- package/cjs/components/InlineCodeEditor/index.d.ts.map +1 -0
- package/cjs/components/InlineCodeEditor/index.js +31 -0
- package/cjs/components/InlineCodeEditor/index.module.less +0 -0
- package/cjs/components/InlineCodeEditor/types.d.ts +22 -0
- package/cjs/components/Layout/index.d.ts +14 -0
- package/cjs/components/Layout/index.d.ts.map +1 -0
- package/cjs/components/Layout/index.js +49 -0
- package/cjs/components/Layout/index.less +14 -0
- package/cjs/components/LoadingButton.d.ts +16 -0
- package/cjs/components/LoadingButton.d.ts.map +1 -0
- package/cjs/components/LoadingButton.js +86 -0
- package/cjs/components/Sider/index.d.ts +15 -0
- package/cjs/components/Sider/index.d.ts.map +1 -0
- package/cjs/components/Sider/index.js +142 -0
- package/cjs/components/Sider/index.less +68 -0
- package/cjs/constants/RunningStatus.d.ts +14 -0
- package/cjs/constants/RunningStatus.d.ts.map +1 -0
- package/cjs/constants/RunningStatus.js +20 -0
- package/cjs/hooks/run/useActiveEdge.d.ts +15 -0
- package/cjs/hooks/run/useActiveEdge.d.ts.map +1 -0
- package/cjs/hooks/run/useActiveEdge.js +36 -0
- package/cjs/hooks/run/useCleanRunState.d.ts +9 -0
- package/cjs/hooks/run/useCleanRunState.d.ts.map +1 -0
- package/cjs/hooks/run/useCleanRunState.js +33 -0
- package/cjs/hooks/run/useNodeRunningState.d.ts +8 -0
- package/cjs/hooks/run/useNodeRunningState.d.ts.map +1 -0
- package/cjs/hooks/run/useNodeRunningState.js +30 -0
- package/cjs/hooks/run/useRunState.d.ts +21 -0
- package/cjs/hooks/run/useRunState.d.ts.map +1 -0
- package/cjs/hooks/run/useRunState.js +39 -0
- package/cjs/hooks/run/useSetRunState.d.ts +18 -0
- package/cjs/hooks/run/useSetRunState.d.ts.map +1 -0
- package/cjs/hooks/run/useSetRunState.js +39 -0
- package/cjs/hooks/state.d.ts +7 -0
- package/cjs/hooks/state.d.ts.map +1 -0
- package/cjs/hooks/state.js +13 -0
- package/cjs/hooks/useDeleteNode.d.ts +2 -0
- package/cjs/hooks/useDeleteNode.d.ts.map +1 -0
- package/cjs/hooks/useDeleteNode.js +32 -0
- package/cjs/hooks/useEdgeIsHover.d.ts +2 -0
- package/cjs/hooks/useEdgeIsHover.d.ts.map +1 -0
- package/cjs/hooks/useEdgeIsHover.js +20 -0
- package/cjs/hooks/useGetSelection.d.ts +13 -0
- package/cjs/hooks/useGetSelection.d.ts.map +1 -0
- package/cjs/hooks/useGetSelection.js +28 -0
- package/cjs/hooks/useGetUpstreamNodes.d.ts +14 -0
- package/cjs/hooks/useGetUpstreamNodes.d.ts.map +1 -0
- package/cjs/hooks/useGetUpstreamNodes.js +81 -0
- package/cjs/hooks/useGetWillDropTarget.d.ts +5 -0
- package/cjs/hooks/useGetWillDropTarget.d.ts.map +1 -0
- package/cjs/hooks/useGetWillDropTarget.js +27 -0
- package/cjs/hooks/useGroupIsWillDrop.d.ts +2 -0
- package/cjs/hooks/useGroupIsWillDrop.d.ts.map +1 -0
- package/cjs/hooks/useGroupIsWillDrop.js +20 -0
- package/cjs/hooks/useIsValidConnection.d.ts +12 -0
- package/cjs/hooks/useIsValidConnection.d.ts.map +1 -0
- package/cjs/hooks/useIsValidConnection.js +83 -0
- package/cjs/hooks/useMouseEvents.d.ts +19 -0
- package/cjs/hooks/useMouseEvents.d.ts.map +1 -0
- package/cjs/hooks/useMouseEvents.js +49 -0
- package/cjs/hooks/useNodeDragHandles.d.ts +10 -0
- package/cjs/hooks/useNodeDragHandles.d.ts.map +1 -0
- package/cjs/hooks/useNodeDragHandles.js +273 -0
- package/cjs/hooks/useNodes.d.ts +9 -0
- package/cjs/hooks/useNodes.d.ts.map +1 -0
- package/cjs/hooks/useNodes.js +19 -0
- package/cjs/hooks/useOnBeforeDelete.d.ts +19 -0
- package/cjs/hooks/useOnBeforeDelete.d.ts.map +1 -0
- package/cjs/hooks/useOnBeforeDelete.js +104 -0
- package/cjs/hooks/useOnConnect.d.ts +12 -0
- package/cjs/hooks/useOnConnect.d.ts.map +1 -0
- package/cjs/hooks/useOnConnect.js +36 -0
- package/cjs/hooks/useOnEdgeMouseEnter.d.ts +13 -0
- package/cjs/hooks/useOnEdgeMouseEnter.d.ts.map +1 -0
- package/cjs/hooks/useOnEdgeMouseEnter.js +27 -0
- package/cjs/hooks/useOnEdgeMouseLeave.d.ts +13 -0
- package/cjs/hooks/useOnEdgeMouseLeave.d.ts.map +1 -0
- package/cjs/hooks/useOnEdgeMouseLeave.js +27 -0
- package/cjs/hooks/useOnNodesChange.d.ts +4 -0
- package/cjs/hooks/useOnNodesChange.d.ts.map +1 -0
- package/cjs/hooks/useOnNodesChange.js +102 -0
- package/cjs/hooks/useOnSelectionChange.d.ts +13 -0
- package/cjs/hooks/useOnSelectionChange.d.ts.map +1 -0
- package/cjs/hooks/useOnSelectionChange.js +130 -0
- package/cjs/hooks/useSetEdges.d.ts +12 -0
- package/cjs/hooks/useSetEdges.d.ts.map +1 -0
- package/cjs/hooks/useSetEdges.js +29 -0
- package/cjs/hooks/useSetSelection.d.ts +3 -0
- package/cjs/hooks/useSetSelection.d.ts.map +1 -0
- package/cjs/hooks/useSetSelection.js +40 -0
- package/cjs/hooks/useSetWillDropTargets.d.ts +2 -0
- package/cjs/hooks/useSetWillDropTargets.d.ts.map +1 -0
- package/cjs/hooks/useSetWillDropTargets.js +26 -0
- package/cjs/hooks/useUpstream.d.ts +3 -0
- package/cjs/hooks/useUpstream.d.ts.map +1 -0
- package/cjs/hooks/useUpstream.js +105 -0
- package/cjs/hooks/useWatchSelectionNodes.d.ts +2 -0
- package/cjs/hooks/useWatchSelectionNodes.d.ts.map +1 -0
- package/cjs/hooks/useWatchSelectionNodes.js +22 -0
- package/cjs/hooks/useWorkFlow.d.ts +12 -0
- package/cjs/hooks/useWorkFlow.d.ts.map +1 -0
- package/cjs/hooks/useWorkFlow.js +93 -0
- package/cjs/hooks/useWorkFlowProps.d.ts +485 -0
- package/cjs/hooks/useWorkFlowProps.d.ts.map +1 -0
- package/cjs/hooks/useWorkFlowProps.js +98 -0
- package/cjs/index.d.ts +23 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +77 -0
- package/cjs/types.d.ts +103 -0
- package/cjs/types.d.ts.map +1 -0
- package/cjs/types.js +8 -0
- package/cjs/utils/arrayUtils.d.ts +2 -0
- package/cjs/utils/arrayUtils.d.ts.map +1 -0
- package/cjs/utils/arrayUtils.js +23 -0
- package/cjs/utils/checkChildren.d.ts +11 -0
- package/cjs/utils/checkChildren.d.ts.map +1 -0
- package/cjs/utils/checkChildren.js +27 -0
- package/cjs/utils/dimensions.d.ts +12 -0
- package/cjs/utils/dimensions.d.ts.map +1 -0
- package/cjs/utils/dimensions.js +23 -0
- package/cjs/utils/dragDataTransfer.d.ts +19 -0
- package/cjs/utils/dragDataTransfer.d.ts.map +1 -0
- package/cjs/utils/dragDataTransfer.js +29 -0
- package/cjs/utils/dropTargetsCheck.d.ts +20 -0
- package/cjs/utils/dropTargetsCheck.d.ts.map +1 -0
- package/cjs/utils/dropTargetsCheck.js +105 -0
- package/cjs/utils/edgeEqualConnect.d.ts +11 -0
- package/cjs/utils/edgeEqualConnect.d.ts.map +1 -0
- package/cjs/utils/edgeEqualConnect.js +19 -0
- package/cjs/utils/events.d.ts +11 -0
- package/cjs/utils/events.d.ts.map +1 -0
- package/cjs/utils/events.js +19 -0
- package/cjs/utils/getEdgeId.d.ts +12 -0
- package/cjs/utils/getEdgeId.d.ts.map +1 -0
- package/cjs/utils/getEdgeId.js +22 -0
- package/cjs/utils/getParentFlow.d.ts +5 -0
- package/cjs/utils/getParentFlow.d.ts.map +1 -0
- package/cjs/utils/getParentFlow.js +36 -0
- package/cjs/utils/graph.d.ts +12 -0
- package/cjs/utils/graph.d.ts.map +1 -0
- package/cjs/utils/graph.js +55 -0
- package/cjs/utils/index.d.ts +18 -0
- package/cjs/utils/index.d.ts.map +1 -0
- package/cjs/utils/index.js +104 -0
- package/cjs/utils/isInSameParent.d.ts +11 -0
- package/cjs/utils/isInSameParent.d.ts.map +1 -0
- package/cjs/utils/isInSameParent.js +19 -0
- package/cjs/utils/parent.d.ts +23 -0
- package/cjs/utils/parent.d.ts.map +1 -0
- package/cjs/utils/parent.js +166 -0
- package/cjs/utils/position.d.ts +29 -0
- package/cjs/utils/position.d.ts.map +1 -0
- package/cjs/utils/position.js +67 -0
- package/cjs/utils/prepareInnerLookup.d.ts +16 -0
- package/cjs/utils/prepareInnerLookup.d.ts.map +1 -0
- package/cjs/utils/prepareInnerLookup.js +93 -0
- package/cjs/utils/scheduleCallback.d.ts +2 -0
- package/cjs/utils/scheduleCallback.d.ts.map +1 -0
- package/cjs/utils/scheduleCallback.js +38 -0
- package/cjs/utils/serialize.d.ts +31 -0
- package/cjs/utils/serialize.d.ts.map +1 -0
- package/cjs/utils/serialize.js +60 -0
- package/cjs/utils/triggerConnect.d.ts +12 -0
- package/cjs/utils/triggerConnect.d.ts.map +1 -0
- package/cjs/utils/triggerConnect.js +50 -0
- package/esm/components/CanvasLoading/index.d.ts +14 -0
- package/esm/components/CanvasLoading/index.d.ts.map +1 -0
- package/esm/components/CanvasLoading/index.js +45 -0
- package/esm/components/CanvasLoading/index.less +69 -0
- package/esm/components/CodeEditor/DebugPanel/index.d.ts +16 -0
- package/esm/components/CodeEditor/DebugPanel/index.d.ts.map +1 -0
- package/esm/components/CodeEditor/DebugPanel/index.js +199 -0
- package/esm/components/CodeEditor/DebugPanel/index.less +56 -0
- package/esm/components/CodeEditor/FileTree/LibraryIcon.d.ts +11 -0
- package/esm/components/CodeEditor/FileTree/LibraryIcon.d.ts.map +1 -0
- package/esm/components/CodeEditor/FileTree/LibraryIcon.js +27 -0
- package/esm/components/CodeEditor/FileTree/icons/Javascript.d.ts +11 -0
- package/esm/components/CodeEditor/FileTree/icons/Javascript.d.ts.map +1 -0
- package/esm/components/CodeEditor/FileTree/icons/Javascript.js +32 -0
- package/esm/components/CodeEditor/FileTree/icons/Python.d.ts +11 -0
- package/esm/components/CodeEditor/FileTree/icons/Python.d.ts.map +1 -0
- package/esm/components/CodeEditor/FileTree/icons/Python.js +32 -0
- package/esm/components/CodeEditor/FileTree/index.d.ts +9 -0
- package/esm/components/CodeEditor/FileTree/index.d.ts.map +1 -0
- package/esm/components/CodeEditor/FileTree/index.js +62 -0
- package/esm/components/CodeEditor/FileTree/index.less +83 -0
- package/esm/components/CodeEditor/FileTree/useFileIcon.d.ts +11 -0
- package/esm/components/CodeEditor/FileTree/useFileIcon.d.ts.map +1 -0
- package/esm/components/CodeEditor/FileTree/useFileIcon.js +39 -0
- package/esm/components/CodeEditor/Header/index.d.ts +15 -0
- package/esm/components/CodeEditor/Header/index.d.ts.map +1 -0
- package/esm/components/CodeEditor/Header/index.js +43 -0
- package/esm/components/CodeEditor/Header/style.less +23 -0
- package/esm/components/CodeEditor/Terminal/XTerm.d.ts +5 -0
- package/esm/components/CodeEditor/Terminal/XTerm.d.ts.map +1 -0
- package/esm/components/CodeEditor/Terminal/XTerm.js +59 -0
- package/esm/components/CodeEditor/Terminal/index.d.ts +15 -0
- package/esm/components/CodeEditor/Terminal/index.d.ts.map +1 -0
- package/esm/components/CodeEditor/Terminal/index.js +23 -0
- package/esm/components/CodeEditor/Terminal/index.less +28 -0
- package/esm/components/CodeEditor/Terminal/types.d.ts +13 -0
- package/esm/components/CodeEditor/editors/JSON.d.ts +12 -0
- package/esm/components/CodeEditor/editors/JSON.d.ts.map +1 -0
- package/esm/components/CodeEditor/editors/JSON.js +35 -0
- package/esm/components/CodeEditor/editors/Python.d.ts +4 -0
- package/esm/components/CodeEditor/editors/Python.d.ts.map +1 -0
- package/esm/components/CodeEditor/editors/Python.js +34 -0
- package/esm/components/CodeEditor/editors/index.less +11 -0
- package/esm/components/CodeEditor/editors/types.d.ts +24 -0
- package/esm/components/CodeEditor/index.d.ts +7 -0
- package/esm/components/CodeEditor/index.d.ts.map +1 -0
- package/esm/components/CodeEditor/index.js +233 -0
- package/esm/components/CodeEditor/style.less +49 -0
- package/esm/components/CodeEditor/types.d.ts +46 -0
- package/esm/components/Handle/NodePopover.d.ts +15 -0
- package/esm/components/Handle/NodePopover.d.ts.map +1 -0
- package/esm/components/Handle/NodePopover.js +165 -0
- package/esm/components/Handle/index.d.ts +24 -0
- package/esm/components/Handle/index.d.ts.map +1 -0
- package/esm/components/Handle/index.js +190 -0
- package/esm/components/Handle/index.less +111 -0
- package/esm/components/InlineCodeEditor/index.d.ts +11 -0
- package/esm/components/InlineCodeEditor/index.d.ts.map +1 -0
- package/esm/components/InlineCodeEditor/index.js +24 -0
- package/esm/components/InlineCodeEditor/index.module.less +0 -0
- package/esm/components/InlineCodeEditor/types.d.ts +22 -0
- package/esm/components/Layout/index.d.ts +14 -0
- package/esm/components/Layout/index.d.ts.map +1 -0
- package/esm/components/Layout/index.js +43 -0
- package/esm/components/Layout/index.less +14 -0
- package/esm/components/LoadingButton.d.ts +16 -0
- package/esm/components/LoadingButton.d.ts.map +1 -0
- package/esm/components/LoadingButton.js +112 -0
- package/esm/components/Sider/index.d.ts +15 -0
- package/esm/components/Sider/index.d.ts.map +1 -0
- package/esm/components/Sider/index.js +142 -0
- package/esm/components/Sider/index.less +68 -0
- package/esm/constants/RunningStatus.d.ts +14 -0
- package/esm/constants/RunningStatus.d.ts.map +1 -0
- package/esm/constants/RunningStatus.js +15 -0
- package/esm/hooks/run/useActiveEdge.d.ts +15 -0
- package/esm/hooks/run/useActiveEdge.d.ts.map +1 -0
- package/esm/hooks/run/useActiveEdge.js +30 -0
- package/esm/hooks/run/useCleanRunState.d.ts +9 -0
- package/esm/hooks/run/useCleanRunState.d.ts.map +1 -0
- package/esm/hooks/run/useCleanRunState.js +26 -0
- package/esm/hooks/run/useNodeRunningState.d.ts +8 -0
- package/esm/hooks/run/useNodeRunningState.d.ts.map +1 -0
- package/esm/hooks/run/useNodeRunningState.js +26 -0
- package/esm/hooks/run/useRunState.d.ts +21 -0
- package/esm/hooks/run/useRunState.d.ts.map +1 -0
- package/esm/hooks/run/useRunState.js +35 -0
- package/esm/hooks/run/useSetRunState.d.ts +18 -0
- package/esm/hooks/run/useSetRunState.d.ts.map +1 -0
- package/esm/hooks/run/useSetRunState.js +35 -0
- package/esm/hooks/state.d.ts +7 -0
- package/esm/hooks/state.d.ts.map +1 -0
- package/esm/hooks/state.js +6 -0
- package/esm/hooks/useDeleteNode.d.ts +2 -0
- package/esm/hooks/useDeleteNode.d.ts.map +1 -0
- package/esm/hooks/useDeleteNode.js +44 -0
- package/esm/hooks/useEdgeIsHover.d.ts +2 -0
- package/esm/hooks/useEdgeIsHover.d.ts.map +1 -0
- package/esm/hooks/useEdgeIsHover.js +14 -0
- package/esm/hooks/useGetSelection.d.ts +13 -0
- package/esm/hooks/useGetSelection.d.ts.map +1 -0
- package/esm/hooks/useGetSelection.js +21 -0
- package/esm/hooks/useGetUpstreamNodes.d.ts +14 -0
- package/esm/hooks/useGetUpstreamNodes.d.ts.map +1 -0
- package/esm/hooks/useGetUpstreamNodes.js +71 -0
- package/esm/hooks/useGetWillDropTarget.d.ts +5 -0
- package/esm/hooks/useGetWillDropTarget.d.ts.map +1 -0
- package/esm/hooks/useGetWillDropTarget.js +21 -0
- package/esm/hooks/useGroupIsWillDrop.d.ts +2 -0
- package/esm/hooks/useGroupIsWillDrop.d.ts.map +1 -0
- package/esm/hooks/useGroupIsWillDrop.js +14 -0
- package/esm/hooks/useIsValidConnection.d.ts +12 -0
- package/esm/hooks/useIsValidConnection.d.ts.map +1 -0
- package/esm/hooks/useIsValidConnection.js +82 -0
- package/esm/hooks/useMouseEvents.d.ts +19 -0
- package/esm/hooks/useMouseEvents.d.ts.map +1 -0
- package/esm/hooks/useMouseEvents.js +40 -0
- package/esm/hooks/useNodeDragHandles.d.ts +10 -0
- package/esm/hooks/useNodeDragHandles.d.ts.map +1 -0
- package/esm/hooks/useNodeDragHandles.js +311 -0
- package/esm/hooks/useNodes.d.ts +9 -0
- package/esm/hooks/useNodes.d.ts.map +1 -0
- package/esm/hooks/useNodes.js +14 -0
- package/esm/hooks/useOnBeforeDelete.d.ts +19 -0
- package/esm/hooks/useOnBeforeDelete.d.ts.map +1 -0
- package/esm/hooks/useOnBeforeDelete.js +138 -0
- package/esm/hooks/useOnConnect.d.ts +12 -0
- package/esm/hooks/useOnConnect.d.ts.map +1 -0
- package/esm/hooks/useOnConnect.js +26 -0
- package/esm/hooks/useOnEdgeMouseEnter.d.ts +13 -0
- package/esm/hooks/useOnEdgeMouseEnter.d.ts.map +1 -0
- package/esm/hooks/useOnEdgeMouseEnter.js +20 -0
- package/esm/hooks/useOnEdgeMouseLeave.d.ts +13 -0
- package/esm/hooks/useOnEdgeMouseLeave.d.ts.map +1 -0
- package/esm/hooks/useOnEdgeMouseLeave.js +20 -0
- package/esm/hooks/useOnNodesChange.d.ts +4 -0
- package/esm/hooks/useOnNodesChange.d.ts.map +1 -0
- package/esm/hooks/useOnNodesChange.js +107 -0
- package/esm/hooks/useOnSelectionChange.d.ts +13 -0
- package/esm/hooks/useOnSelectionChange.d.ts.map +1 -0
- package/esm/hooks/useOnSelectionChange.js +171 -0
- package/esm/hooks/useSetEdges.d.ts +12 -0
- package/esm/hooks/useSetEdges.d.ts.map +1 -0
- package/esm/hooks/useSetEdges.js +22 -0
- package/esm/hooks/useSetSelection.d.ts +3 -0
- package/esm/hooks/useSetSelection.d.ts.map +1 -0
- package/esm/hooks/useSetSelection.js +33 -0
- package/esm/hooks/useSetWillDropTargets.d.ts +2 -0
- package/esm/hooks/useSetWillDropTargets.d.ts.map +1 -0
- package/esm/hooks/useSetWillDropTargets.js +18 -0
- package/esm/hooks/useUpstream.d.ts +3 -0
- package/esm/hooks/useUpstream.d.ts.map +1 -0
- package/esm/hooks/useUpstream.js +101 -0
- package/esm/hooks/useWatchSelectionNodes.d.ts +2 -0
- package/esm/hooks/useWatchSelectionNodes.d.ts.map +1 -0
- package/esm/hooks/useWatchSelectionNodes.js +14 -0
- package/esm/hooks/useWorkFlow.d.ts +12 -0
- package/esm/hooks/useWorkFlow.d.ts.map +1 -0
- package/esm/hooks/useWorkFlow.js +92 -0
- package/esm/hooks/useWorkFlowProps.d.ts +485 -0
- package/esm/hooks/useWorkFlowProps.d.ts.map +1 -0
- package/esm/hooks/useWorkFlowProps.js +102 -0
- package/esm/index.d.ts +23 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +28 -0
- package/esm/types.d.ts +103 -0
- package/esm/types.d.ts.map +1 -0
- package/esm/types.js +4 -0
- package/esm/utils/arrayUtils.d.ts +2 -0
- package/esm/utils/arrayUtils.d.ts.map +1 -0
- package/esm/utils/arrayUtils.js +16 -0
- package/esm/utils/checkChildren.d.ts +11 -0
- package/esm/utils/checkChildren.d.ts.map +1 -0
- package/esm/utils/checkChildren.js +16 -0
- package/esm/utils/dimensions.d.ts +12 -0
- package/esm/utils/dimensions.d.ts.map +1 -0
- package/esm/utils/dimensions.js +17 -0
- package/esm/utils/dragDataTransfer.d.ts +19 -0
- package/esm/utils/dragDataTransfer.d.ts.map +1 -0
- package/esm/utils/dragDataTransfer.js +21 -0
- package/esm/utils/dropTargetsCheck.d.ts +20 -0
- package/esm/utils/dropTargetsCheck.d.ts.map +1 -0
- package/esm/utils/dropTargetsCheck.js +116 -0
- package/esm/utils/edgeEqualConnect.d.ts +11 -0
- package/esm/utils/edgeEqualConnect.d.ts.map +1 -0
- package/esm/utils/edgeEqualConnect.js +12 -0
- package/esm/utils/events.d.ts +11 -0
- package/esm/utils/events.d.ts.map +1 -0
- package/esm/utils/events.js +12 -0
- package/esm/utils/getEdgeId.d.ts +12 -0
- package/esm/utils/getEdgeId.d.ts.map +1 -0
- package/esm/utils/getEdgeId.js +16 -0
- package/esm/utils/getParentFlow.d.ts +5 -0
- package/esm/utils/getParentFlow.d.ts.map +1 -0
- package/esm/utils/getParentFlow.js +28 -0
- package/esm/utils/graph.d.ts +12 -0
- package/esm/utils/graph.d.ts.map +1 -0
- package/esm/utils/graph.js +51 -0
- package/esm/utils/index.d.ts +18 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +18 -0
- package/esm/utils/isInSameParent.d.ts +11 -0
- package/esm/utils/isInSameParent.d.ts.map +1 -0
- package/esm/utils/isInSameParent.js +12 -0
- package/esm/utils/parent.d.ts +23 -0
- package/esm/utils/parent.d.ts.map +1 -0
- package/esm/utils/parent.js +186 -0
- package/esm/utils/position.d.ts +29 -0
- package/esm/utils/position.d.ts.map +1 -0
- package/esm/utils/position.js +61 -0
- package/esm/utils/prepareInnerLookup.d.ts +16 -0
- package/esm/utils/prepareInnerLookup.d.ts.map +1 -0
- package/esm/utils/prepareInnerLookup.js +79 -0
- package/esm/utils/scheduleCallback.d.ts +2 -0
- package/esm/utils/scheduleCallback.d.ts.map +1 -0
- package/esm/utils/scheduleCallback.js +36 -0
- package/esm/utils/serialize.d.ts +31 -0
- package/esm/utils/serialize.d.ts.map +1 -0
- package/esm/utils/serialize.js +64 -0
- package/esm/utils/triggerConnect.d.ts +12 -0
- package/esm/utils/triggerConnect.d.ts.map +1 -0
- package/esm/utils/triggerConnect.js +59 -0
- package/package.json +70 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useGetSelection = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _state = require("./state");
|
|
9
|
+
/**
|
|
10
|
+
* @author: yanxianliang
|
|
11
|
+
* @date: 2025-08-11 14:18
|
|
12
|
+
* @modified:2025/8/11 14:18 by yanxianliang
|
|
13
|
+
* @desc: 获取选中的节点和边列表
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const useGetSelection = () => {
|
|
19
|
+
const getState = (0, _state.useGetState)();
|
|
20
|
+
return (0, _react.useCallback)(() => {
|
|
21
|
+
const state = getState();
|
|
22
|
+
return {
|
|
23
|
+
selectedNodes: state.selectedNodes,
|
|
24
|
+
selectedEdges: state.selectedEdges
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
};
|
|
28
|
+
exports.useGetSelection = useGetSelection;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author: yanxianliang
|
|
3
|
+
* @date: 2025-08-20 21:46
|
|
4
|
+
* @modified:2025/8/20 21:46 by yanxianliang
|
|
5
|
+
* @desc: 提供一个函数获取当前节点的所有上游节点
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
8
|
+
*/
|
|
9
|
+
import { Node } from "@xyflow/react";
|
|
10
|
+
export declare const useGetUpstreamNodes: <NodeType extends Node = Node>() => (nodeId?: string, allowParentFlow?: boolean) => {
|
|
11
|
+
upstreams: NodeType[];
|
|
12
|
+
parents: NodeType[];
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useGetUpstreamNodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetUpstreamNodes.d.ts","sourceRoot":"","sources":["useGetUpstreamNodes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAC,IAAI,EAAe,MAAM,eAAe,CAAC;AAGjD,eAAO,MAAM,mBAAmB,gDAKD,MAAM;;;CAgDpC,CAAA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useGetUpstreamNodes = void 0;
|
|
7
|
+
var _react = require("@xyflow/react");
|
|
8
|
+
var _react2 = require("react");
|
|
9
|
+
/**
|
|
10
|
+
* @author: yanxianliang
|
|
11
|
+
* @date: 2025-08-20 21:46
|
|
12
|
+
* @modified:2025/8/20 21:46 by yanxianliang
|
|
13
|
+
* @desc: 提供一个函数获取当前节点的所有上游节点
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const useGetUpstreamNodes = () => {
|
|
19
|
+
const {
|
|
20
|
+
getNodeConnections,
|
|
21
|
+
getNode
|
|
22
|
+
} = (0, _react.useReactFlow)();
|
|
23
|
+
/**
|
|
24
|
+
* 获取对应节点的上游节点和父节点
|
|
25
|
+
*/
|
|
26
|
+
return (0, _react2.useCallback)((nodeId, allowParentFlow = true) => {
|
|
27
|
+
if (!nodeId) {
|
|
28
|
+
return {
|
|
29
|
+
upstreams: [],
|
|
30
|
+
parents: []
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 上游节点计算规则
|
|
35
|
+
* 1. 通过 connections 进行判断,自动查找 target = 下游节点,且 source 不在列表中的节点。
|
|
36
|
+
* 2. 支持环型检测,防止出现死循环
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
const upstreams = [];
|
|
40
|
+
const parents = []; // 父节点
|
|
41
|
+
const upstreamIdSet = new Set(nodeId); // 禁止循环搭配节点自己
|
|
42
|
+
|
|
43
|
+
const parentIdSet = new Set();
|
|
44
|
+
function getUpstreams(nodeId) {
|
|
45
|
+
const connections = getNodeConnections({
|
|
46
|
+
nodeId: nodeId
|
|
47
|
+
}); // 当前节点所有的链接线
|
|
48
|
+
connections.forEach(connection => {
|
|
49
|
+
const {
|
|
50
|
+
source,
|
|
51
|
+
target
|
|
52
|
+
} = connection;
|
|
53
|
+
const targetNode = getNode(target);
|
|
54
|
+
if (!upstreamIdSet.has(source) && target === nodeId && source !== targetNode?.parentId) {
|
|
55
|
+
const node = getNode(source);
|
|
56
|
+
node && upstreams.push(node);
|
|
57
|
+
upstreamIdSet.add(source);
|
|
58
|
+
getUpstreams(source);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const node = getNode(nodeId);
|
|
62
|
+
if (node?.parentId) {
|
|
63
|
+
const parentNode = getNode(node.parentId);
|
|
64
|
+
if (parentNode && !parentIdSet.has(node.parentId)) {
|
|
65
|
+
parents.push(parentNode); // 父节点,父节点也需要
|
|
66
|
+
parentIdSet.add(parentNode.id);
|
|
67
|
+
upstreamIdSet.add(parentNode.id);
|
|
68
|
+
if (allowParentFlow) {
|
|
69
|
+
getUpstreams(parentNode.id);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
getUpstreams(nodeId);
|
|
75
|
+
return {
|
|
76
|
+
upstreams,
|
|
77
|
+
parents
|
|
78
|
+
};
|
|
79
|
+
}, []);
|
|
80
|
+
};
|
|
81
|
+
exports.useGetUpstreamNodes = useGetUpstreamNodes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetWillDropTarget.d.ts","sourceRoot":"","sources":["useGetWillDropTarget.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,eAAO,MAAM,oBAAoB,gCAKhC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useGetWillDropTarget = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _state = require("./state");
|
|
9
|
+
/**
|
|
10
|
+
* @author: yanxianliang
|
|
11
|
+
* @date: 2025-08-13 17:17
|
|
12
|
+
* @modified:2025/8/13 17:17 by yanxianliang
|
|
13
|
+
* @desc: 获取目标节点列表
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 返回第一个 dropTarget 作为目标
|
|
20
|
+
*/
|
|
21
|
+
const useGetWillDropTarget = () => {
|
|
22
|
+
const getState = (0, _state.useGetState)();
|
|
23
|
+
return (0, _react.useCallback)(() => {
|
|
24
|
+
return getState().dropTargetIds?.[0];
|
|
25
|
+
}, []);
|
|
26
|
+
};
|
|
27
|
+
exports.useGetWillDropTarget = useGetWillDropTarget;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGroupIsWillDrop.d.ts","sourceRoot":"","sources":["useGroupIsWillDrop.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,kBAAkB,OAAQ,MAAM,YAE5C,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useGroupIsWillDrop = void 0;
|
|
7
|
+
var _state = require("./state");
|
|
8
|
+
/**
|
|
9
|
+
* @author: yanxianliang
|
|
10
|
+
* @date: 2025-08-13 17:05
|
|
11
|
+
* @modified:2025/8/13 17:05 by yanxianliang
|
|
12
|
+
* @desc: 当前节点是否作为目标节点高亮
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const useGroupIsWillDrop = id => {
|
|
18
|
+
return (0, _state.useSelector)(state => new Set(state.dropTargetIds).has(id));
|
|
19
|
+
};
|
|
20
|
+
exports.useGroupIsWillDrop = useGroupIsWillDrop;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author: yanxianliang
|
|
3
|
+
* @date: 2025-08-16 02:36
|
|
4
|
+
* @modified:2025/8/16 02:36 by yanxianliang
|
|
5
|
+
* @desc: 链接检查
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
8
|
+
*/
|
|
9
|
+
import { IWorkflowProps } from "..";
|
|
10
|
+
import { Connection, Edge, Node } from "@xyflow/react";
|
|
11
|
+
export declare const useIsValidConnection: <NodeType extends Node = Node, EdgeType extends Edge = Edge>(props: IWorkflowProps<NodeType, EdgeType>) => <EdgeType_1 extends Edge = Edge>(connection: Connection | EdgeType_1) => boolean;
|
|
12
|
+
//# sourceMappingURL=useIsValidConnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsValidConnection.d.ts","sourceRoot":"","sources":["useIsValidConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAmB,cAAc,EAAC,WAAyB;AAClE,OAAO,EAAC,UAAU,EAAE,IAAI,EAAe,IAAI,EAA4B,MAAM,eAAe,CAAC;AAG7F,eAAO,MAAM,oBAAoB,sEAIxB,eAAe,QAAQ,EAAE,QAAQ,CAAC,qFAuD1C,CAAA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useIsValidConnection = void 0;
|
|
7
|
+
var _react = require("@xyflow/react");
|
|
8
|
+
var _ahooks = require("ahooks");
|
|
9
|
+
/**
|
|
10
|
+
* @author: yanxianliang
|
|
11
|
+
* @date: 2025-08-16 02:36
|
|
12
|
+
* @modified:2025/8/16 02:36 by yanxianliang
|
|
13
|
+
* @desc: 链接检查
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const useIsValidConnection = props => {
|
|
19
|
+
const {
|
|
20
|
+
getNodes,
|
|
21
|
+
getEdges,
|
|
22
|
+
getNode
|
|
23
|
+
} = (0, _react.useReactFlow)();
|
|
24
|
+
const {
|
|
25
|
+
getState
|
|
26
|
+
} = (0, _react.useStoreApi)();
|
|
27
|
+
return (0, _ahooks.useMemoizedFn)(connection => {
|
|
28
|
+
const {
|
|
29
|
+
connectionLimit,
|
|
30
|
+
isValidConnection
|
|
31
|
+
} = props;
|
|
32
|
+
const target = getNode(connection.target);
|
|
33
|
+
const nodes = getNodes();
|
|
34
|
+
const edges = getEdges();
|
|
35
|
+
if (connectionLimit) {
|
|
36
|
+
const {
|
|
37
|
+
preventCycle,
|
|
38
|
+
preventCrossSubFlow
|
|
39
|
+
} = connectionLimit;
|
|
40
|
+
if (preventCycle) {
|
|
41
|
+
if (connection.target === connection.source) return false; // 禁止自己连自己
|
|
42
|
+
|
|
43
|
+
const hasCycle = (node, visited = new Set()) => {
|
|
44
|
+
if (visited.has(node.id)) return false;
|
|
45
|
+
visited.add(node.id);
|
|
46
|
+
for (const outgoer of (0, _react.getOutgoers)(node, nodes, edges)) {
|
|
47
|
+
if (outgoer.id === connection.source) return true;
|
|
48
|
+
if (hasCycle(outgoer, visited)) return true;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
if (target && hasCycle(target)) return false;
|
|
52
|
+
}
|
|
53
|
+
if (preventCrossSubFlow) {
|
|
54
|
+
const sourceNode = getNode(connection.source);
|
|
55
|
+
const targetNode = getNode(connection.target);
|
|
56
|
+
if (sourceNode && targetNode && sourceNode.parentId !== targetNode.parentId && !(!sourceNode.parentId && !targetNode.parentId)) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const {
|
|
62
|
+
connectionLookup
|
|
63
|
+
} = getState(); // 检测是否已经存在
|
|
64
|
+
|
|
65
|
+
const sourceConnectionMap = connectionLookup.get(connection.source);
|
|
66
|
+
const {
|
|
67
|
+
source: sourceNode,
|
|
68
|
+
target: targetNode,
|
|
69
|
+
sourceHandle = null,
|
|
70
|
+
targetHandle = null
|
|
71
|
+
} = connection;
|
|
72
|
+
const targetKey = `${targetNode}-${targetHandle}--${sourceNode}-${sourceHandle}`;
|
|
73
|
+
if (sourceConnectionMap && sourceConnectionMap.has(targetKey)) {
|
|
74
|
+
// 已经存在同样的边,不允许再次连接
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (isValidConnection) {
|
|
78
|
+
return isValidConnection(connection);
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
exports.useIsValidConnection = useIsValidConnection;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author: yanxianliang
|
|
3
|
+
* @date: 2025-08-16 21:38
|
|
4
|
+
* @modified:2025/8/16 21:38 by yanxianliang
|
|
5
|
+
* @desc: mouse 位置获取
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
8
|
+
*/
|
|
9
|
+
import { type MouseEvent } from "react";
|
|
10
|
+
export declare const useMouseEvents: (_onMouseEnter?: ((e: MouseEvent<HTMLDivElement>) => void) | undefined, _onMouseLeave?: ((e: MouseEvent<HTMLDivElement>) => void) | undefined, _onMouseMove?: ((e: MouseEvent<HTMLDivElement>) => void) | undefined) => {
|
|
11
|
+
onMouseMove: (e: MouseEvent<HTMLDivElement>) => void;
|
|
12
|
+
onMouseEnter: (e: MouseEvent<HTMLDivElement>) => void;
|
|
13
|
+
onMouseLeave: (e: MouseEvent<HTMLDivElement>) => void;
|
|
14
|
+
};
|
|
15
|
+
export declare const useGetMousePosition: () => () => {
|
|
16
|
+
clientX: number;
|
|
17
|
+
clientY: number;
|
|
18
|
+
} | null;
|
|
19
|
+
//# sourceMappingURL=useMouseEvents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMouseEvents.d.ts","sourceRoot":"","sources":["useMouseEvents.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAc,KAAK,UAAU,EAAC,MAAM,OAAO,CAAC;AASnD,eAAO,MAAM,cAAc,wBACL,WAAW,cAAc,CAAC,KAAK,IAAI,oCACnC,WAAW,cAAc,CAAC,KAAK,IAAI,mCACpC,WAAW,cAAc,CAAC,KAAK,IAAI;qBAYlB,WAAW,cAAc,CAAC;sBAVzB,WAAW,cAAc,CAAC;sBAK1B,WAAW,cAAc,CAAC;CAWhE,CAAA;AAED,eAAO,MAAM,mBAAmB;aA5BrB,MAAM;aACN,MAAM;QA+BhB,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useMouseEvents = exports.useGetMousePosition = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/**
|
|
9
|
+
* @author: yanxianliang
|
|
10
|
+
* @date: 2025-08-16 21:38
|
|
11
|
+
* @modified:2025/8/16 21:38 by yanxianliang
|
|
12
|
+
* @desc: mouse 位置获取
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
let mousePosition = null;
|
|
18
|
+
const useMouseEvents = (_onMouseEnter, _onMouseLeave, _onMouseMove) => {
|
|
19
|
+
const onMouseEnter = (0, _react.useCallback)(e => {
|
|
20
|
+
mousePosition = {
|
|
21
|
+
clientX: e.clientX,
|
|
22
|
+
clientY: e.clientY
|
|
23
|
+
};
|
|
24
|
+
_onMouseEnter?.(e);
|
|
25
|
+
}, []);
|
|
26
|
+
const onMouseLeave = (0, _react.useCallback)(e => {
|
|
27
|
+
mousePosition = null;
|
|
28
|
+
_onMouseLeave?.(e);
|
|
29
|
+
}, []);
|
|
30
|
+
const onMouseMove = (0, _react.useCallback)(e => {
|
|
31
|
+
mousePosition = {
|
|
32
|
+
clientX: e.clientX,
|
|
33
|
+
clientY: e.clientY
|
|
34
|
+
};
|
|
35
|
+
_onMouseMove?.(e);
|
|
36
|
+
}, []);
|
|
37
|
+
return {
|
|
38
|
+
onMouseMove,
|
|
39
|
+
onMouseEnter,
|
|
40
|
+
onMouseLeave
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
exports.useMouseEvents = useMouseEvents;
|
|
44
|
+
const useGetMousePosition = () => {
|
|
45
|
+
return (0, _react.useCallback)(() => {
|
|
46
|
+
return mousePosition;
|
|
47
|
+
}, []);
|
|
48
|
+
};
|
|
49
|
+
exports.useGetMousePosition = useGetMousePosition;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IWorkflowProps, WorkflowNode } from "..";
|
|
2
|
+
import { type DragEvent, type MouseEvent as ReactMouseEvent } from 'react';
|
|
3
|
+
export declare const useNodeDragHandles: <NodeType extends WorkflowNode = WorkflowNode>(_onNodeDragStart?: IWorkflowProps<NodeType>['onNodeDragStart'], _onNodeDrag?: IWorkflowProps<NodeType>['onNodeDrag'], _onNodeDragStop?: IWorkflowProps<NodeType>['onNodeDragStop'], _onDragOver?: IWorkflowProps<NodeType>['onDragOver'], _onDrop?: IWorkflowProps<NodeType>['onDrop'], _onNodeTypeDrop?: IWorkflowProps<NodeType>['onNodeTypeDrop']) => {
|
|
4
|
+
onNodeDragStart: (event: ReactMouseEvent, node: NodeType, nodes: NodeType[]) => void;
|
|
5
|
+
onNodeDrag: (event: ReactMouseEvent, node: NodeType, nodes: NodeType[]) => void;
|
|
6
|
+
onNodeDragStop: (event: ReactMouseEvent, node: NodeType, nodes: NodeType[]) => void;
|
|
7
|
+
onDragOver: (event: DragEvent<HTMLDivElement>) => void;
|
|
8
|
+
onDrop: (event: DragEvent<HTMLDivElement>) => Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=useNodeDragHandles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNodeDragHandles.d.ts","sourceRoot":"","sources":["useNodeDragHandles.ts"],"names":[],"mappings":"AASA,OAAO,EAML,cAAc,EACd,YAAY,EAEb,WAAyB;AAM1B,OAAO,EAAC,KAAK,SAAS,EAAE,KAAK,UAAU,IAAI,eAAe,EAAE,MAAM,OAAO,CAAC;AAQ1E,eAAO,MAAM,kBAAkB,oEACV,eAAe,QAAQ,CAAC,CAAC,iBAAiB,CAAC,gBAChD,eAAe,QAAQ,CAAC,CAAC,YAAY,CAAC,oBAClC,eAAe,QAAQ,CAAC,CAAC,gBAAgB,CAAC,gBAC9C,eAAe,QAAQ,CAAC,CAAC,YAAY,CAAC,YAC1C,eAAe,QAAQ,CAAC,CAAC,QAAQ,CAAC,oBAC1B,eAAe,QAAQ,CAAC,CAAC,gBAAgB,CAAC;6BAkBd,eAAe,QAAQ,QAAQ,SAAS,QAAQ,EAAE;wBAiCvD,eAAe,QAAQ,QAAQ,SAAS,QAAQ,EAAE;4BAc9C,eAAe,QAAQ,QAAQ,SAAS,QAAQ,EAAE;wBA2EtD,UAAU,cAAc,CAAC;oBA8CvB,UAAU,cAAc,CAAC;CAoDrE,CAAA"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useNodeDragHandles = void 0;
|
|
7
|
+
var _base = require("@rxflow/base");
|
|
8
|
+
var _ = require("./..");
|
|
9
|
+
var _react = require("@xyflow/react");
|
|
10
|
+
var _system = require("@xyflow/system");
|
|
11
|
+
var _ahooks = require("ahooks");
|
|
12
|
+
var _antd = require("antd");
|
|
13
|
+
var _dragDataTransfer = require("../utils/dragDataTransfer");
|
|
14
|
+
var _dropTargetsCheck = require("../utils/dropTargetsCheck");
|
|
15
|
+
var _graph = require("../utils/graph");
|
|
16
|
+
var _useGetWillDropTarget = require("./useGetWillDropTarget");
|
|
17
|
+
var _useSetWillDropTargets = require("./useSetWillDropTargets");
|
|
18
|
+
var _useWorkFlow = require("./useWorkFlow");
|
|
19
|
+
/**
|
|
20
|
+
* @author: yanxianliang
|
|
21
|
+
* @date: 2025-08-18 21:28
|
|
22
|
+
* @modified:2025/8/18 21:28 by yanxianliang
|
|
23
|
+
* @desc: 节点拖动逻辑处理
|
|
24
|
+
*
|
|
25
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const useNodeDragHandles = (_onNodeDragStart, _onNodeDrag, _onNodeDragStop, _onDragOver, _onDrop, _onNodeTypeDrop) => {
|
|
29
|
+
const {
|
|
30
|
+
getIntersectingNodes,
|
|
31
|
+
getNodeConnections,
|
|
32
|
+
deleteElements,
|
|
33
|
+
getEdge,
|
|
34
|
+
screenToFlowPosition,
|
|
35
|
+
getViewport,
|
|
36
|
+
setNodes
|
|
37
|
+
} = (0, _react.useReactFlow)();
|
|
38
|
+
const {
|
|
39
|
+
getState
|
|
40
|
+
} = (0, _react.useStoreApi)();
|
|
41
|
+
const {
|
|
42
|
+
getInternalNode,
|
|
43
|
+
getNode
|
|
44
|
+
} = (0, _useWorkFlow.useWorkFlow)(); // 获取内置节点实例
|
|
45
|
+
const setWillDropTargets = (0, _useSetWillDropTargets.useSetWillDropTargets)();
|
|
46
|
+
const getWillDropTarget = (0, _useGetWillDropTarget.useGetWillDropTarget)();
|
|
47
|
+
const nodeTypeMap = (0, _base.useNodeTypeMap)();
|
|
48
|
+
const onNodeDragStart = (0, _ahooks.useMemoizedFn)((event, node, nodes) => {
|
|
49
|
+
const {
|
|
50
|
+
nodeLookup,
|
|
51
|
+
nodeOrigin,
|
|
52
|
+
parentLookup
|
|
53
|
+
} = getState();
|
|
54
|
+
const {
|
|
55
|
+
ctrlKey,
|
|
56
|
+
altKey
|
|
57
|
+
} = event; // mac is metaKey,windows is Ctrl
|
|
58
|
+
const isMetaKeyDown = (0, _system.isMacOs)() ? altKey : ctrlKey;
|
|
59
|
+
if (isMetaKeyDown) {
|
|
60
|
+
// 需要修改 dragItems 属性
|
|
61
|
+
// meta key is down 找出有父节点的 node
|
|
62
|
+
if (nodes.length > 0) {
|
|
63
|
+
for (const node of nodes) {
|
|
64
|
+
if (node.parentId) {
|
|
65
|
+
const parentNode = getNode(node.parentId);
|
|
66
|
+
if (parentNode) {
|
|
67
|
+
// 将内置节点属性直接修改为脱离父节点
|
|
68
|
+
// 更新 nodeLookUp
|
|
69
|
+
const innerNode = nodeLookup.get(node.id);
|
|
70
|
+
if (innerNode) {
|
|
71
|
+
const newPosition = (0, _.evaluatePositionOutParent)(innerNode, nodeOrigin);
|
|
72
|
+
delete innerNode.extent;
|
|
73
|
+
delete innerNode.internals.userNode.extent;
|
|
74
|
+
delete innerNode.parentId; // 删除父节点引用
|
|
75
|
+
delete innerNode.internals.userNode.parentId;
|
|
76
|
+
innerNode.internals.userNode.position = newPosition; // 更新 position 属性
|
|
77
|
+
innerNode.position = newPosition; // 更新 position 属性,绝对为只不需要更新,绝对位置是和父节点不相关的
|
|
78
|
+
parentLookup.get(node.parentId)?.delete(node.id); // 清除父节点中的引用关系
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
_onNodeDragStart?.(event, node, nodes);
|
|
86
|
+
});
|
|
87
|
+
const onNodeDrag = (0, _ahooks.useMemoizedFn)((event, node, nodes) => {
|
|
88
|
+
// 节点拖动,需要计算当前节点对应的释放节点或节点列表
|
|
89
|
+
const {
|
|
90
|
+
nodeLookup
|
|
91
|
+
} = getState();
|
|
92
|
+
const internalNode = nodeLookup.get(node.id);
|
|
93
|
+
if (internalNode) {
|
|
94
|
+
const intersections = (0, _dropTargetsCheck.getAllowedIntersections)(nodeLookup, getIntersectingNodes(internalNode), nodes, nodeTypeMap);
|
|
95
|
+
// 被当前节点覆盖的节点列表
|
|
96
|
+
setWillDropTargets(intersections);
|
|
97
|
+
} else {
|
|
98
|
+
setWillDropTargets([]);
|
|
99
|
+
}
|
|
100
|
+
_onNodeDrag?.(event, node, nodes);
|
|
101
|
+
});
|
|
102
|
+
const onNodeDragStop = (0, _ahooks.useMemoizedFn)((event, node, nodes) => {
|
|
103
|
+
const willDrop = getWillDropTarget(); // 获取目标容器元素
|
|
104
|
+
let replaceNodeMap = new Map();
|
|
105
|
+
const {
|
|
106
|
+
nodeOrigin
|
|
107
|
+
} = getState();
|
|
108
|
+
// 是否是容器节点
|
|
109
|
+
if (willDrop) {
|
|
110
|
+
const parentNode = getInternalNode(willDrop);
|
|
111
|
+
const targetNodeDefinition = parentNode?.type ? nodeTypeMap.get(parentNode.type) : undefined;
|
|
112
|
+
if (targetNodeDefinition) {
|
|
113
|
+
const {
|
|
114
|
+
nodeRoleType
|
|
115
|
+
} = targetNodeDefinition;
|
|
116
|
+
if (nodeRoleType === _base.NodeRoleType.SubFlow && !node.parentId) {
|
|
117
|
+
// 检测不通过的时候强制不执行变更
|
|
118
|
+
let allowDrop = true;
|
|
119
|
+
let i = 0;
|
|
120
|
+
while (allowDrop && i < nodes.length) {
|
|
121
|
+
const node = nodes[i];
|
|
122
|
+
const nodeDefinition = nodeTypeMap.get(node.type);
|
|
123
|
+
if (parentNode && nodeDefinition && (0, _.checkChildren)(targetNodeDefinition, nodeDefinition)) {
|
|
124
|
+
const newPosition = (0, _.evaluatePositionInParent)(node.position, parentNode);
|
|
125
|
+
// position 需要修正
|
|
126
|
+
const nextPosition = (0, _graph.calcPositionInSubFlow)(targetNodeDefinition, parentNode, node, nodeOrigin, newPosition);
|
|
127
|
+
replaceNodeMap.set(node.id, {
|
|
128
|
+
...node,
|
|
129
|
+
parentId: willDrop,
|
|
130
|
+
position: nextPosition
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
i++;
|
|
134
|
+
}
|
|
135
|
+
if (allowDrop && replaceNodeMap.size > 0) {
|
|
136
|
+
setNodes(prevNodes => prevNodes.map(node => {
|
|
137
|
+
return replaceNodeMap.get(node.id) || node;
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
setWillDropTargets([]);
|
|
144
|
+
|
|
145
|
+
// 位置移动结束,如果节点从 Group中移动到了 Group之外,需要自动删除对应的连线
|
|
146
|
+
let willRemoveEdges = [];
|
|
147
|
+
for (const node of nodes) {
|
|
148
|
+
const connections = getNodeConnections({
|
|
149
|
+
nodeId: node.id
|
|
150
|
+
}); // 获取所有连线,剔除 parentId 不一致的
|
|
151
|
+
for (const connection of connections) {
|
|
152
|
+
const {
|
|
153
|
+
edgeId,
|
|
154
|
+
source,
|
|
155
|
+
target
|
|
156
|
+
} = connection;
|
|
157
|
+
if (source !== node.id) {
|
|
158
|
+
const sourceNode = getNode(source);
|
|
159
|
+
if (!sourceNode || !(0, _.isInSameParent)(replaceNodeMap.get(source) || sourceNode, replaceNodeMap.get(node.id) || node)) {
|
|
160
|
+
// 需要删除当前连线
|
|
161
|
+
const edge = getEdge(edgeId);
|
|
162
|
+
edge && willRemoveEdges.push(edge);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (target !== node.id) {
|
|
166
|
+
const targetNode = getNode(target);
|
|
167
|
+
if (!targetNode || !(0, _.isInSameParent)(replaceNodeMap.get(target) || targetNode, replaceNodeMap.get(node.id) || node)) {
|
|
168
|
+
// 需要删除当前连线
|
|
169
|
+
const edge = getEdge(edgeId);
|
|
170
|
+
edge && willRemoveEdges.push(edge);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (willRemoveEdges.length > 0) {
|
|
176
|
+
deleteElements({
|
|
177
|
+
edges: willRemoveEdges
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
_onNodeDragStop?.(event, node, nodes);
|
|
181
|
+
});
|
|
182
|
+
const onDragOver = (0, _ahooks.useMemoizedFn)(event => {
|
|
183
|
+
_onDragOver?.(event);
|
|
184
|
+
if (!_onDragOver) {
|
|
185
|
+
event.preventDefault();
|
|
186
|
+
event.dataTransfer.dropEffect = 'move';
|
|
187
|
+
}
|
|
188
|
+
const dataTransfer = (0, _dragDataTransfer.getDragDataTransfer)();
|
|
189
|
+
const offsetX = dataTransfer.offsetX ?? 0;
|
|
190
|
+
const offsetY = dataTransfer?.offsetY ?? 0;
|
|
191
|
+
const width = dataTransfer?.width ?? 0;
|
|
192
|
+
const height = dataTransfer?.height ?? 0;
|
|
193
|
+
const targetLeft = event.clientX - offsetX;
|
|
194
|
+
const targetTop = event.clientY - offsetY;
|
|
195
|
+
const targetWidth = width;
|
|
196
|
+
const targetHeight = height;
|
|
197
|
+
const zoom = getViewport().zoom;
|
|
198
|
+
const nodeType = dataTransfer.type;
|
|
199
|
+
const {
|
|
200
|
+
target
|
|
201
|
+
} = event;
|
|
202
|
+
if (target) {
|
|
203
|
+
// 获取兴趣节点
|
|
204
|
+
const position = screenToFlowPosition({
|
|
205
|
+
x: targetLeft,
|
|
206
|
+
y: targetTop
|
|
207
|
+
}); // 拖动节点对应的clientX, clientY
|
|
208
|
+
|
|
209
|
+
// 碰撞检测 宽、高
|
|
210
|
+
const width = Math.ceil(targetWidth / zoom);
|
|
211
|
+
const height = Math.ceil(targetHeight / zoom);
|
|
212
|
+
const {
|
|
213
|
+
nodeLookup
|
|
214
|
+
} = getState();
|
|
215
|
+
// 执行碰撞检测
|
|
216
|
+
const intersections = (0, _dropTargetsCheck.getAllowedIntersections)(nodeLookup, getIntersectingNodes({
|
|
217
|
+
x: position.x,
|
|
218
|
+
y: position.y,
|
|
219
|
+
width,
|
|
220
|
+
height
|
|
221
|
+
}), nodeType ? [nodeType] : undefined, nodeTypeMap);
|
|
222
|
+
// 被当前节点覆盖的节点列表
|
|
223
|
+
setWillDropTargets(intersections);
|
|
224
|
+
} else {
|
|
225
|
+
setWillDropTargets([]);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
const onDrop = (0, _ahooks.useMemoizedFn)(async event => {
|
|
229
|
+
if (_onDrop) {
|
|
230
|
+
await _onDrop(event); // 执行默认的 drop 处理
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// 内部处理好对应的新增逻辑,如新增元素的父级,新增元素的位置。业务系统在事件中创建节点即可
|
|
234
|
+
if (_onNodeTypeDrop) {
|
|
235
|
+
// 内部处理对应的逻辑
|
|
236
|
+
event.preventDefault(); // onDrop
|
|
237
|
+
const type = event.dataTransfer.getData('node@drag');
|
|
238
|
+
// 基础检测
|
|
239
|
+
if (typeof type === 'undefined' || !type) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const {
|
|
243
|
+
nodeLookup
|
|
244
|
+
} = getState();
|
|
245
|
+
const dropTarget = getWillDropTarget();
|
|
246
|
+
|
|
247
|
+
// 部分节点不允许在全局使用
|
|
248
|
+
if (!dropTarget && !(0, _dropTargetsCheck.canAddInNode)(nodeLookup, undefined, [type], nodeTypeMap)) {
|
|
249
|
+
// 当前节点不允许在全局使用
|
|
250
|
+
_antd.message.error('当前节点不允许在全局使用');
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const parentFlow = (0, _.getParentFlow)(nodeLookup, nodeTypeMap, dropTarget);
|
|
254
|
+
const absolutePosition = screenToFlowPosition({
|
|
255
|
+
x: event.clientX,
|
|
256
|
+
y: event.clientY
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// 节点 position 属性
|
|
260
|
+
const positionInFlow = parentFlow ? (0, _.evaluatePositionInParent)(absolutePosition, parentFlow) : absolutePosition;
|
|
261
|
+
await _onNodeTypeDrop(parentFlow, positionInFlow, type);
|
|
262
|
+
}
|
|
263
|
+
setWillDropTargets([]);
|
|
264
|
+
});
|
|
265
|
+
return {
|
|
266
|
+
onNodeDragStart,
|
|
267
|
+
onNodeDrag,
|
|
268
|
+
onNodeDragStop,
|
|
269
|
+
onDragOver,
|
|
270
|
+
onDrop
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
exports.useNodeDragHandles = useNodeDragHandles;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNodes.d.ts","sourceRoot":"","sources":["useNodes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,eAAO,MAAM,QAAQ,mCAEpB,CAAC"}
|