@yh-ui/flow 0.1.21
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/LICENSE +21 -0
- package/README.md +234 -0
- package/dist/Flow.d.vue.ts +306 -0
- package/dist/Flow.vue +959 -0
- package/dist/Flow.vue.d.ts +306 -0
- package/dist/__tests__/ai-workflow.ssr.test.cjs +352 -0
- package/dist/__tests__/ai-workflow.ssr.test.d.ts +1 -0
- package/dist/__tests__/ai-workflow.ssr.test.mjs +283 -0
- package/dist/__tests__/ai-workflow.test.cjs +109 -0
- package/dist/__tests__/ai-workflow.test.d.ts +1 -0
- package/dist/__tests__/ai-workflow.test.mjs +112 -0
- package/dist/__tests__/bpmn.ssr.test.cjs +278 -0
- package/dist/__tests__/bpmn.ssr.test.d.ts +1 -0
- package/dist/__tests__/bpmn.ssr.test.mjs +237 -0
- package/dist/__tests__/bpmn.test.cjs +103 -0
- package/dist/__tests__/bpmn.test.d.ts +1 -0
- package/dist/__tests__/bpmn.test.mjs +106 -0
- package/dist/__tests__/custom-types.test.cjs +300 -0
- package/dist/__tests__/custom-types.test.d.ts +1 -0
- package/dist/__tests__/custom-types.test.mjs +248 -0
- package/dist/__tests__/edge.test.cjs +56 -0
- package/dist/__tests__/edge.test.d.ts +1 -0
- package/dist/__tests__/edge.test.mjs +69 -0
- package/dist/__tests__/event-bus.test.cjs +80 -0
- package/dist/__tests__/event-bus.test.d.ts +1 -0
- package/dist/__tests__/event-bus.test.mjs +51 -0
- package/dist/__tests__/flow.ssr.test.cjs +156 -0
- package/dist/__tests__/flow.ssr.test.d.ts +1 -0
- package/dist/__tests__/flow.ssr.test.mjs +112 -0
- package/dist/__tests__/geometry.test.cjs +191 -0
- package/dist/__tests__/geometry.test.d.ts +1 -0
- package/dist/__tests__/geometry.test.mjs +105 -0
- package/dist/__tests__/graph.test.cjs +115 -0
- package/dist/__tests__/graph.test.d.ts +1 -0
- package/dist/__tests__/graph.test.mjs +85 -0
- package/dist/__tests__/history-plugin.test.cjs +191 -0
- package/dist/__tests__/history-plugin.test.d.ts +1 -0
- package/dist/__tests__/history-plugin.test.mjs +161 -0
- package/dist/__tests__/history.test.cjs +81 -0
- package/dist/__tests__/history.test.d.ts +1 -0
- package/dist/__tests__/history.test.mjs +43 -0
- package/dist/__tests__/layout.test.cjs +213 -0
- package/dist/__tests__/layout.test.d.ts +1 -0
- package/dist/__tests__/layout.test.mjs +170 -0
- package/dist/__tests__/node-edit-panel.ssr.test.cjs +168 -0
- package/dist/__tests__/node-edit-panel.ssr.test.d.ts +1 -0
- package/dist/__tests__/node-edit-panel.ssr.test.mjs +118 -0
- package/dist/__tests__/node-group-plugin.test.cjs +235 -0
- package/dist/__tests__/node-group-plugin.test.d.ts +1 -0
- package/dist/__tests__/node-group-plugin.test.mjs +187 -0
- package/dist/__tests__/node-handles.test.cjs +340 -0
- package/dist/__tests__/node-handles.test.d.ts +1 -0
- package/dist/__tests__/node-handles.test.mjs +230 -0
- package/dist/__tests__/plugin.test.cjs +151 -0
- package/dist/__tests__/plugin.test.d.ts +1 -0
- package/dist/__tests__/plugin.test.mjs +116 -0
- package/dist/__tests__/transform.test.cjs +58 -0
- package/dist/__tests__/transform.test.d.ts +1 -0
- package/dist/__tests__/transform.test.mjs +38 -0
- package/dist/__tests__/useAlignment.test.cjs +91 -0
- package/dist/__tests__/useAlignment.test.d.ts +1 -0
- package/dist/__tests__/useAlignment.test.mjs +52 -0
- package/dist/__tests__/useEdges.test.cjs +117 -0
- package/dist/__tests__/useEdges.test.d.ts +1 -0
- package/dist/__tests__/useEdges.test.mjs +80 -0
- package/dist/__tests__/useKeyboard.test.cjs +88 -0
- package/dist/__tests__/useKeyboard.test.d.ts +1 -0
- package/dist/__tests__/useKeyboard.test.mjs +56 -0
- package/dist/__tests__/useNodes.test.cjs +150 -0
- package/dist/__tests__/useNodes.test.d.ts +1 -0
- package/dist/__tests__/useNodes.test.mjs +80 -0
- package/dist/__tests__/useSelection.test.cjs +112 -0
- package/dist/__tests__/useSelection.test.d.ts +1 -0
- package/dist/__tests__/useSelection.test.mjs +76 -0
- package/dist/__tests__/useViewport.test.cjs +171 -0
- package/dist/__tests__/useViewport.test.d.ts +1 -0
- package/dist/__tests__/useViewport.test.mjs +82 -0
- package/dist/__tests__/utils/ssr.cjs +124 -0
- package/dist/__tests__/utils/ssr.d.ts +33 -0
- package/dist/__tests__/utils/ssr.mjs +129 -0
- package/dist/__tests__/validation.test.cjs +95 -0
- package/dist/__tests__/validation.test.d.ts +1 -0
- package/dist/__tests__/validation.test.mjs +36 -0
- package/dist/components/AiNodeEditPanel.d.vue.ts +13 -0
- package/dist/components/AiNodeEditPanel.vue +413 -0
- package/dist/components/AiNodeEditPanel.vue.d.ts +13 -0
- package/dist/components/EdgeEditPanel.d.vue.ts +14 -0
- package/dist/components/EdgeEditPanel.vue +205 -0
- package/dist/components/EdgeEditPanel.vue.d.ts +14 -0
- package/dist/components/NodeEditPanel.d.vue.ts +13 -0
- package/dist/components/NodeEditPanel.vue +214 -0
- package/dist/components/NodeEditPanel.vue.d.ts +13 -0
- package/dist/components/edges/BaseEdge.d.vue.ts +23 -0
- package/dist/components/edges/BaseEdge.vue +55 -0
- package/dist/components/edges/BaseEdge.vue.d.ts +23 -0
- package/dist/components/edges/BezierEdge.d.vue.ts +22 -0
- package/dist/components/edges/BezierEdge.vue +57 -0
- package/dist/components/edges/BezierEdge.vue.d.ts +22 -0
- package/dist/components/edges/DataFlowEdge.d.vue.ts +41 -0
- package/dist/components/edges/DataFlowEdge.vue +211 -0
- package/dist/components/edges/DataFlowEdge.vue.d.ts +41 -0
- package/dist/components/edges/SmoothEdge.d.vue.ts +22 -0
- package/dist/components/edges/SmoothEdge.vue +53 -0
- package/dist/components/edges/SmoothEdge.vue.d.ts +22 -0
- package/dist/components/edges/StepEdge.d.vue.ts +22 -0
- package/dist/components/edges/StepEdge.vue +42 -0
- package/dist/components/edges/StepEdge.vue.d.ts +22 -0
- package/dist/components/edges/index.cjs +41 -0
- package/dist/components/edges/index.d.ts +5 -0
- package/dist/components/edges/index.mjs +5 -0
- package/dist/components/nodes/BaseNode.d.vue.ts +25 -0
- package/dist/components/nodes/BaseNode.vue +93 -0
- package/dist/components/nodes/BaseNode.vue.d.ts +25 -0
- package/dist/components/nodes/CustomNode.d.vue.ts +36 -0
- package/dist/components/nodes/CustomNode.vue +44 -0
- package/dist/components/nodes/CustomNode.vue.d.ts +36 -0
- package/dist/components/nodes/DatabaseNode.d.vue.ts +19 -0
- package/dist/components/nodes/DatabaseNode.vue +62 -0
- package/dist/components/nodes/DatabaseNode.vue.d.ts +19 -0
- package/dist/components/nodes/DiamondNode.d.vue.ts +19 -0
- package/dist/components/nodes/DiamondNode.vue +62 -0
- package/dist/components/nodes/DiamondNode.vue.d.ts +19 -0
- package/dist/components/nodes/GroupNode.d.vue.ts +31 -0
- package/dist/components/nodes/GroupNode.vue +48 -0
- package/dist/components/nodes/GroupNode.vue.d.ts +31 -0
- package/dist/components/nodes/InputNode.d.vue.ts +23 -0
- package/dist/components/nodes/InputNode.vue +63 -0
- package/dist/components/nodes/InputNode.vue.d.ts +23 -0
- package/dist/components/nodes/NodeResizer.d.vue.ts +27 -0
- package/dist/components/nodes/NodeResizer.vue +89 -0
- package/dist/components/nodes/NodeResizer.vue.d.ts +27 -0
- package/dist/components/nodes/NodeToolbar.d.vue.ts +32 -0
- package/dist/components/nodes/NodeToolbar.vue +101 -0
- package/dist/components/nodes/NodeToolbar.vue.d.ts +32 -0
- package/dist/components/nodes/OutputNode.d.vue.ts +21 -0
- package/dist/components/nodes/OutputNode.vue +53 -0
- package/dist/components/nodes/OutputNode.vue.d.ts +21 -0
- package/dist/components/nodes/ai-workflow/AiAgentNode.d.vue.ts +20 -0
- package/dist/components/nodes/ai-workflow/AiAgentNode.vue +59 -0
- package/dist/components/nodes/ai-workflow/AiAgentNode.vue.d.ts +20 -0
- package/dist/components/nodes/ai-workflow/AiConditionNode.d.vue.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiConditionNode.vue +65 -0
- package/dist/components/nodes/ai-workflow/AiConditionNode.vue.d.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiEndNode.d.vue.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiEndNode.vue +47 -0
- package/dist/components/nodes/ai-workflow/AiEndNode.vue.d.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiLlmNode.d.vue.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiLlmNode.vue +64 -0
- package/dist/components/nodes/ai-workflow/AiLlmNode.vue.d.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiMemoryNode.d.vue.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiMemoryNode.vue +59 -0
- package/dist/components/nodes/ai-workflow/AiMemoryNode.vue.d.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiPromptNode.d.vue.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiPromptNode.vue +61 -0
- package/dist/components/nodes/ai-workflow/AiPromptNode.vue.d.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiStartNode.d.vue.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiStartNode.vue +47 -0
- package/dist/components/nodes/ai-workflow/AiStartNode.vue.d.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiToolNode.d.vue.ts +19 -0
- package/dist/components/nodes/ai-workflow/AiToolNode.vue +59 -0
- package/dist/components/nodes/ai-workflow/AiToolNode.vue.d.ts +19 -0
- package/dist/components/nodes/ai-workflow/index.cjs +109 -0
- package/dist/components/nodes/ai-workflow/index.d.ts +23 -0
- package/dist/components/nodes/ai-workflow/index.mjs +37 -0
- package/dist/components/nodes/bpmn/BpmnEndEvent.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnEndEvent.vue +50 -0
- package/dist/components/nodes/bpmn/BpmnEndEvent.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnExclusiveGateway.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnExclusiveGateway.vue +60 -0
- package/dist/components/nodes/bpmn/BpmnExclusiveGateway.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnInclusiveGateway.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnInclusiveGateway.vue +60 -0
- package/dist/components/nodes/bpmn/BpmnInclusiveGateway.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnParallelGateway.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnParallelGateway.vue +60 -0
- package/dist/components/nodes/bpmn/BpmnParallelGateway.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnServiceTask.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnServiceTask.vue +55 -0
- package/dist/components/nodes/bpmn/BpmnServiceTask.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnStartEvent.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnStartEvent.vue +50 -0
- package/dist/components/nodes/bpmn/BpmnStartEvent.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnTask.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnTask.vue +54 -0
- package/dist/components/nodes/bpmn/BpmnTask.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnUserTask.d.vue.ts +19 -0
- package/dist/components/nodes/bpmn/BpmnUserTask.vue +55 -0
- package/dist/components/nodes/bpmn/BpmnUserTask.vue.d.ts +19 -0
- package/dist/components/nodes/bpmn/index.cjs +109 -0
- package/dist/components/nodes/bpmn/index.d.ts +23 -0
- package/dist/components/nodes/bpmn/index.mjs +37 -0
- package/dist/components/nodes/index.cjs +246 -0
- package/dist/components/nodes/index.d.ts +13 -0
- package/dist/components/nodes/index.mjs +44 -0
- package/dist/core/FlowContext.cjs +21 -0
- package/dist/core/FlowContext.d.ts +10 -0
- package/dist/core/FlowContext.mjs +13 -0
- package/dist/core/index.cjs +104 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.mjs +9 -0
- package/dist/core/useAlignment.cjs +81 -0
- package/dist/core/useAlignment.d.ts +33 -0
- package/dist/core/useAlignment.mjs +71 -0
- package/dist/core/useEdges.cjs +132 -0
- package/dist/core/useEdges.d.ts +29 -0
- package/dist/core/useEdges.mjs +89 -0
- package/dist/core/useFlow.cjs +40 -0
- package/dist/core/useFlow.d.ts +31 -0
- package/dist/core/useFlow.mjs +32 -0
- package/dist/core/useHistory.cjs +63 -0
- package/dist/core/useHistory.d.ts +15 -0
- package/dist/core/useHistory.mjs +54 -0
- package/dist/core/useKeyboard.cjs +54 -0
- package/dist/core/useKeyboard.d.ts +18 -0
- package/dist/core/useKeyboard.mjs +45 -0
- package/dist/core/useNodeDistribution.cjs +171 -0
- package/dist/core/useNodeDistribution.d.ts +12 -0
- package/dist/core/useNodeDistribution.mjs +145 -0
- package/dist/core/useNodes.cjs +146 -0
- package/dist/core/useNodes.d.ts +26 -0
- package/dist/core/useNodes.mjs +101 -0
- package/dist/core/useSelection.cjs +83 -0
- package/dist/core/useSelection.d.ts +18 -0
- package/dist/core/useSelection.mjs +53 -0
- package/dist/core/useViewport.cjs +157 -0
- package/dist/core/useViewport.d.ts +65 -0
- package/dist/core/useViewport.mjs +125 -0
- package/dist/flow.cjs +240 -0
- package/dist/flow.d.ts +276 -0
- package/dist/flow.mjs +230 -0
- package/dist/index.cjs +378 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.mjs +50 -0
- package/dist/plugins/index.cjs +96 -0
- package/dist/plugins/index.d.ts +34 -0
- package/dist/plugins/index.mjs +47 -0
- package/dist/plugins/plugin.cjs +117 -0
- package/dist/plugins/plugin.d.ts +72 -0
- package/dist/plugins/plugin.mjs +110 -0
- package/dist/plugins/plugins/controls.cjs +38 -0
- package/dist/plugins/plugins/controls.d.ts +12 -0
- package/dist/plugins/plugins/controls.mjs +28 -0
- package/dist/plugins/plugins/export.cjs +102 -0
- package/dist/plugins/plugins/export.d.ts +12 -0
- package/dist/plugins/plugins/export.mjs +89 -0
- package/dist/plugins/plugins/grid.cjs +36 -0
- package/dist/plugins/plugins/grid.d.ts +11 -0
- package/dist/plugins/plugins/grid.mjs +26 -0
- package/dist/plugins/plugins/history.cjs +140 -0
- package/dist/plugins/plugins/history.d.ts +53 -0
- package/dist/plugins/plugins/history.mjs +132 -0
- package/dist/plugins/plugins/index.cjs +104 -0
- package/dist/plugins/plugins/index.d.ts +9 -0
- package/dist/plugins/plugins/index.mjs +9 -0
- package/dist/plugins/plugins/keyboard.cjs +27 -0
- package/dist/plugins/plugins/keyboard.d.ts +10 -0
- package/dist/plugins/plugins/keyboard.mjs +18 -0
- package/dist/plugins/plugins/layout.cjs +275 -0
- package/dist/plugins/plugins/layout.d.ts +34 -0
- package/dist/plugins/plugins/layout.mjs +246 -0
- package/dist/plugins/plugins/minimap.cjs +60 -0
- package/dist/plugins/plugins/minimap.d.ts +25 -0
- package/dist/plugins/plugins/minimap.mjs +50 -0
- package/dist/plugins/plugins/node-group.cjs +209 -0
- package/dist/plugins/plugins/node-group.d.ts +26 -0
- package/dist/plugins/plugins/node-group.mjs +178 -0
- package/dist/plugins/plugins/snap.cjs +36 -0
- package/dist/plugins/plugins/snap.d.ts +12 -0
- package/dist/plugins/plugins/snap.mjs +26 -0
- package/dist/renderer/AlignmentLines.d.vue.ts +5 -0
- package/dist/renderer/AlignmentLines.vue +113 -0
- package/dist/renderer/AlignmentLines.vue.d.ts +5 -0
- package/dist/renderer/Background.d.vue.ts +7 -0
- package/dist/renderer/Background.vue +86 -0
- package/dist/renderer/Background.vue.d.ts +7 -0
- package/dist/renderer/Controls.d.vue.ts +13 -0
- package/dist/renderer/Controls.vue +82 -0
- package/dist/renderer/Controls.vue.d.ts +13 -0
- package/dist/renderer/EdgeHandlesRenderer.d.vue.ts +11 -0
- package/dist/renderer/EdgeHandlesRenderer.vue +75 -0
- package/dist/renderer/EdgeHandlesRenderer.vue.d.ts +11 -0
- package/dist/renderer/EdgeRenderer.d.vue.ts +39 -0
- package/dist/renderer/EdgeRenderer.vue +204 -0
- package/dist/renderer/EdgeRenderer.vue.d.ts +39 -0
- package/dist/renderer/FlowBackground.d.vue.ts +11 -0
- package/dist/renderer/FlowBackground.vue +82 -0
- package/dist/renderer/FlowBackground.vue.d.ts +11 -0
- package/dist/renderer/Minimap.d.vue.ts +30 -0
- package/dist/renderer/Minimap.vue +290 -0
- package/dist/renderer/Minimap.vue.d.ts +30 -0
- package/dist/renderer/NodeRenderer.d.vue.ts +56 -0
- package/dist/renderer/NodeRenderer.vue +328 -0
- package/dist/renderer/NodeRenderer.vue.d.ts +56 -0
- package/dist/renderer/SelectionBox.d.vue.ts +11 -0
- package/dist/renderer/SelectionBox.vue +28 -0
- package/dist/renderer/SelectionBox.vue.d.ts +11 -0
- package/dist/types/edge.cjs +13 -0
- package/dist/types/edge.d.ts +65 -0
- package/dist/types/edge.mjs +6 -0
- package/dist/types/events.cjs +1 -0
- package/dist/types/events.d.ts +115 -0
- package/dist/types/events.mjs +0 -0
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.ts +366 -0
- package/dist/types/index.mjs +0 -0
- package/dist/types/node.cjs +9 -0
- package/dist/types/node.d.ts +90 -0
- package/dist/types/node.mjs +3 -0
- package/dist/types/viewport.cjs +42 -0
- package/dist/types/viewport.d.ts +62 -0
- package/dist/types/viewport.mjs +36 -0
- package/dist/utils/bpmn-engine.cjs +390 -0
- package/dist/utils/bpmn-engine.d.ts +164 -0
- package/dist/utils/bpmn-engine.mjs +378 -0
- package/dist/utils/bpmn.cjs +492 -0
- package/dist/utils/bpmn.d.ts +53 -0
- package/dist/utils/bpmn.mjs +430 -0
- package/dist/utils/collaboration.cjs +537 -0
- package/dist/utils/collaboration.d.ts +189 -0
- package/dist/utils/collaboration.mjs +521 -0
- package/dist/utils/custom-types.cjs +138 -0
- package/dist/utils/custom-types.d.ts +78 -0
- package/dist/utils/custom-types.mjs +108 -0
- package/dist/utils/edge.cjs +235 -0
- package/dist/utils/edge.d.ts +79 -0
- package/dist/utils/edge.mjs +172 -0
- package/dist/utils/event-bus.cjs +91 -0
- package/dist/utils/event-bus.d.ts +39 -0
- package/dist/utils/event-bus.mjs +82 -0
- package/dist/utils/geometry.cjs +178 -0
- package/dist/utils/geometry.d.ts +186 -0
- package/dist/utils/geometry.mjs +144 -0
- package/dist/utils/graph.cjs +158 -0
- package/dist/utils/graph.d.ts +40 -0
- package/dist/utils/graph.mjs +147 -0
- package/dist/utils/index.cjs +137 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.mjs +12 -0
- package/dist/utils/performance.cjs +94 -0
- package/dist/utils/performance.d.ts +18 -0
- package/dist/utils/performance.mjs +82 -0
- package/dist/utils/screenshot.cjs +87 -0
- package/dist/utils/screenshot.d.ts +22 -0
- package/dist/utils/screenshot.mjs +66 -0
- package/dist/utils/theme.cjs +228 -0
- package/dist/utils/theme.d.ts +92 -0
- package/dist/utils/theme.mjs +217 -0
- package/dist/utils/transform.cjs +76 -0
- package/dist/utils/transform.d.ts +45 -0
- package/dist/utils/transform.mjs +57 -0
- package/dist/utils/validation.cjs +107 -0
- package/dist/utils/validation.d.ts +29 -0
- package/dist/utils/validation.mjs +85 -0
- package/package.json +61 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
export const flowTheme = {
|
|
2
|
+
// 节点样式
|
|
3
|
+
"flow-node-background": "#ffffff",
|
|
4
|
+
"flow-node-border": "#dcdfe6",
|
|
5
|
+
"flow-node-border-radius": "8px",
|
|
6
|
+
"flow-node-padding": "10px",
|
|
7
|
+
"flow-node-shadow": "0 2px 4px rgba(0, 0, 0, 0.1)",
|
|
8
|
+
"flow-node-selected-border": "#409eff",
|
|
9
|
+
"flow-node-selected-shadow": "0 0 8px rgba(64, 158, 255, 0.4)",
|
|
10
|
+
"flow-node-dragging-opacity": "0.8",
|
|
11
|
+
// 节点文字
|
|
12
|
+
"flow-node-label-color": "#303133",
|
|
13
|
+
"flow-node-label-font-size": "14px",
|
|
14
|
+
"flow-node-label-font-weight": "500",
|
|
15
|
+
"flow-node-description-color": "#909399",
|
|
16
|
+
"flow-node-description-font-size": "12px",
|
|
17
|
+
// 连接点(Handle)
|
|
18
|
+
"flow-handle-background": "#ffffff",
|
|
19
|
+
"flow-handle-border": "#409eff",
|
|
20
|
+
"flow-handle-border-radius": "50%",
|
|
21
|
+
"flow-handle-size": "12px",
|
|
22
|
+
"flow-handle-hover-background": "#409eff",
|
|
23
|
+
"flow-handle-connected-background": "#67c23a",
|
|
24
|
+
// 连线样式
|
|
25
|
+
"flow-edge-stroke": "#b1b3b8",
|
|
26
|
+
"flow-edge-stroke-width": "2",
|
|
27
|
+
"flow-edge-selected-stroke": "#409eff",
|
|
28
|
+
"flow-edge-animated-stroke": "#409eff",
|
|
29
|
+
"flow-edge-label-background": "#ffffff",
|
|
30
|
+
"flow-edge-label-color": "#606266",
|
|
31
|
+
// BPMN 节点
|
|
32
|
+
"flow-bpmn-start-fill": "#e6f7ed",
|
|
33
|
+
"flow-bpmn-start-stroke": "#67c23a",
|
|
34
|
+
"flow-bpmn-end-fill": "#fef0f0",
|
|
35
|
+
"flow-bpmn-end-stroke": "#f56c6c",
|
|
36
|
+
"flow-bpmn-task-fill": "#ecf5ff",
|
|
37
|
+
"flow-bpmn-task-stroke": "#409eff",
|
|
38
|
+
"flow-bpmn-gateway-fill": "#fdf6ec",
|
|
39
|
+
"flow-bpmn-gateway-stroke": "#e6a23c",
|
|
40
|
+
"flow-bpmn-gateway-color": "#e6a23c",
|
|
41
|
+
// AI 节点
|
|
42
|
+
"flow-ai-node-background": "#f0f9ff",
|
|
43
|
+
"flow-ai-node-border": "#0ea5e9",
|
|
44
|
+
"flow-ai-node-accent": "#0284c7",
|
|
45
|
+
// 背景
|
|
46
|
+
"flow-background-color": "#fafafa",
|
|
47
|
+
"flow-grid-color": "#e4e7ed",
|
|
48
|
+
"flow-grid-size": "20",
|
|
49
|
+
// 辅助线
|
|
50
|
+
"flow-alignment-line-color": "#c0c4cc",
|
|
51
|
+
"flow-alignment-line-active-color": "#409eff",
|
|
52
|
+
// 选框
|
|
53
|
+
"flow-selection-box-border": "#409eff",
|
|
54
|
+
"flow-selection-box-background": "rgba(64, 158, 255, 0.1)",
|
|
55
|
+
// 控制按钮
|
|
56
|
+
"flow-control-background": "#ffffff",
|
|
57
|
+
"flow-control-border": "#dcdfe6",
|
|
58
|
+
"flow-control-icon-color": "#606266",
|
|
59
|
+
"flow-control-hover-background": "#f5f7fa",
|
|
60
|
+
"flow-control-active-background": "#ecf5ff",
|
|
61
|
+
// 小地图
|
|
62
|
+
"flow-minimap-background": "#f5f7fa",
|
|
63
|
+
"flow-minimap-mask-background": "rgba(255, 255, 255, 0.8)",
|
|
64
|
+
"flow-minimap-node-color": "#c0c4cc",
|
|
65
|
+
"flow-minimap-viewport-border": "#409eff",
|
|
66
|
+
// 编辑面板
|
|
67
|
+
"flow-panel-background": "#ffffff",
|
|
68
|
+
"flow-panel-border": "#e4e7ed",
|
|
69
|
+
"flow-panel-shadow": "0 4px 12px rgba(0, 0, 0, 0.15)",
|
|
70
|
+
"flow-panel-header-background": "#fafafa",
|
|
71
|
+
"flow-panel-title-color": "#303133",
|
|
72
|
+
// 工具栏
|
|
73
|
+
"flow-toolbar-background": "#ffffff",
|
|
74
|
+
"flow-toolbar-border": "#e4e7ed",
|
|
75
|
+
"flow-toolbar-icon-color": "#606266",
|
|
76
|
+
"flow-toolbar-hover-background": "#f5f7fa",
|
|
77
|
+
"flow-toolbar-active-background": "#ecf5ff"
|
|
78
|
+
};
|
|
79
|
+
export const flowThemeDark = {
|
|
80
|
+
// 节点样式
|
|
81
|
+
"flow-node-background": "#1f1f1f",
|
|
82
|
+
"flow-node-border": "#3a3a3a",
|
|
83
|
+
"flow-node-border-radius": "8px",
|
|
84
|
+
"flow-node-padding": "10px",
|
|
85
|
+
"flow-node-shadow": "0 2px 8px rgba(0, 0, 0, 0.3)",
|
|
86
|
+
"flow-node-selected-border": "#409eff",
|
|
87
|
+
"flow-node-selected-shadow": "0 0 8px rgba(64, 158, 255, 0.5)",
|
|
88
|
+
"flow-node-dragging-opacity": "0.7",
|
|
89
|
+
// 节点文字
|
|
90
|
+
"flow-node-label-color": "#e5e5e5",
|
|
91
|
+
"flow-node-label-font-size": "14px",
|
|
92
|
+
"flow-node-label-font-weight": "500",
|
|
93
|
+
"flow-node-description-color": "#8c8c8c",
|
|
94
|
+
"flow-node-description-font-size": "12px",
|
|
95
|
+
// 连接点(Handle)
|
|
96
|
+
"flow-handle-background": "#262626",
|
|
97
|
+
"flow-handle-border": "#409eff",
|
|
98
|
+
"flow-handle-border-radius": "50%",
|
|
99
|
+
"flow-handle-size": "12px",
|
|
100
|
+
"flow-handle-hover-background": "#409eff",
|
|
101
|
+
"flow-handle-connected-background": "#67c23a",
|
|
102
|
+
// 连线样式
|
|
103
|
+
"flow-edge-stroke": "#5c5c5c",
|
|
104
|
+
"flow-edge-stroke-width": "2",
|
|
105
|
+
"flow-edge-selected-stroke": "#409eff",
|
|
106
|
+
"flow-edge-animated-stroke": "#409eff",
|
|
107
|
+
"flow-edge-label-background": "#1f1f1f",
|
|
108
|
+
"flow-edge-label-color": "#e5e5e5",
|
|
109
|
+
// BPMN 节点
|
|
110
|
+
"flow-bpmn-start-fill": "#1a2e1a",
|
|
111
|
+
"flow-bpmn-start-stroke": "#67c23a",
|
|
112
|
+
"flow-bpmn-end-fill": "#2e1a1a",
|
|
113
|
+
"flow-bpmn-end-stroke": "#f56c6c",
|
|
114
|
+
"flow-bpmn-task-fill": "#1a2a33",
|
|
115
|
+
"flow-bpmn-task-stroke": "#409eff",
|
|
116
|
+
"flow-bpmn-gateway-fill": "#2e2a1a",
|
|
117
|
+
"flow-bpmn-gateway-stroke": "#e6a23c",
|
|
118
|
+
"flow-bpmn-gateway-color": "#e6a23c",
|
|
119
|
+
// AI 节点
|
|
120
|
+
"flow-ai-node-background": "#1a1a2e",
|
|
121
|
+
"flow-ai-node-border": "#0ea5e9",
|
|
122
|
+
"flow-ai-node-accent": "#38bdf8",
|
|
123
|
+
// 背景
|
|
124
|
+
"flow-background-color": "#141414",
|
|
125
|
+
"flow-grid-color": "#2a2a2a",
|
|
126
|
+
"flow-grid-size": "20",
|
|
127
|
+
// 辅助线
|
|
128
|
+
"flow-alignment-line-color": "#404040",
|
|
129
|
+
"flow-alignment-line-active-color": "#409eff",
|
|
130
|
+
// 选框
|
|
131
|
+
"flow-selection-box-border": "#409eff",
|
|
132
|
+
"flow-selection-box-background": "rgba(64, 158, 255, 0.2)",
|
|
133
|
+
// 控制按钮
|
|
134
|
+
"flow-control-background": "#1f1f1f",
|
|
135
|
+
"flow-control-border": "#3a3a3a",
|
|
136
|
+
"flow-control-icon-color": "#8c8c8c",
|
|
137
|
+
"flow-control-hover-background": "#2a2a2a",
|
|
138
|
+
"flow-control-active-background": "#1a2a33",
|
|
139
|
+
// 小地图
|
|
140
|
+
"flow-minimap-background": "#1a1a1a",
|
|
141
|
+
"flow-minimap-mask-background": "rgba(0, 0, 0, 0.7)",
|
|
142
|
+
"flow-minimap-node-color": "#404040",
|
|
143
|
+
"flow-minimap-viewport-border": "#409eff",
|
|
144
|
+
// 编辑面板
|
|
145
|
+
"flow-panel-background": "#1f1f1f",
|
|
146
|
+
"flow-panel-border": "#3a3a3a",
|
|
147
|
+
"flow-panel-shadow": "0 4px 12px rgba(0, 0, 0, 0.5)",
|
|
148
|
+
"flow-panel-header-background": "#262626",
|
|
149
|
+
"flow-panel-title-color": "#e5e5e5",
|
|
150
|
+
// 工具栏
|
|
151
|
+
"flow-toolbar-background": "#1f1f1f",
|
|
152
|
+
"flow-toolbar-border": "#3a3a3a",
|
|
153
|
+
"flow-toolbar-icon-color": "#8c8c8c",
|
|
154
|
+
"flow-toolbar-hover-background": "#2a2a2a",
|
|
155
|
+
"flow-toolbar-active-background": "#1a2a33"
|
|
156
|
+
};
|
|
157
|
+
export function applyFlowTheme(theme, target = document) {
|
|
158
|
+
const root = target instanceof Document ? target.documentElement : target;
|
|
159
|
+
for (const [key, value] of Object.entries(theme)) {
|
|
160
|
+
root.style.setProperty(`--${key}`, value);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
export function createCustomTheme(overrides) {
|
|
164
|
+
return { ...flowTheme, ...overrides };
|
|
165
|
+
}
|
|
166
|
+
export const flowThemePresets = {
|
|
167
|
+
default: flowTheme,
|
|
168
|
+
dark: flowThemeDark,
|
|
169
|
+
blue: createCustomTheme({
|
|
170
|
+
"flow-node-background": "#e6f7ff",
|
|
171
|
+
"flow-node-border": "#91d5ff",
|
|
172
|
+
"flow-node-selected-border": "#1890ff",
|
|
173
|
+
"flow-node-selected-shadow": "0 0 8px rgba(24, 144, 255, 0.4)",
|
|
174
|
+
"flow-handle-border": "#1890ff",
|
|
175
|
+
"flow-edge-selected-stroke": "#1890ff",
|
|
176
|
+
"flow-edge-animated-stroke": "#1890ff",
|
|
177
|
+
"flow-background-color": "#f0f7ff",
|
|
178
|
+
"flow-grid-color": "#d0e6ff",
|
|
179
|
+
"flow-bpmn-start-stroke": "#52c41a",
|
|
180
|
+
"flow-bpmn-task-stroke": "#1890ff",
|
|
181
|
+
"flow-bpmn-gateway-stroke": "#faad14",
|
|
182
|
+
"flow-ai-node-border": "#722ed1",
|
|
183
|
+
"flow-ai-node-accent": "#b37feb"
|
|
184
|
+
}),
|
|
185
|
+
green: createCustomTheme({
|
|
186
|
+
"flow-node-background": "#f6ffed",
|
|
187
|
+
"flow-node-border": "#b7eb8f",
|
|
188
|
+
"flow-node-selected-border": "#52c41a",
|
|
189
|
+
"flow-node-selected-shadow": "0 0 8px rgba(82, 196, 26, 0.4)",
|
|
190
|
+
"flow-handle-border": "#52c41a",
|
|
191
|
+
"flow-edge-selected-stroke": "#52c41a",
|
|
192
|
+
"flow-edge-animated-stroke": "#52c41a",
|
|
193
|
+
"flow-background-color": "#f6ffed",
|
|
194
|
+
"flow-grid-color": "#d9f7be",
|
|
195
|
+
"flow-bpmn-start-stroke": "#52c41a",
|
|
196
|
+
"flow-bpmn-task-stroke": "#1890ff",
|
|
197
|
+
"flow-bpmn-gateway-stroke": "#faad14",
|
|
198
|
+
"flow-ai-node-border": "#13c2c2",
|
|
199
|
+
"flow-ai-node-accent": "#36cfc9"
|
|
200
|
+
}),
|
|
201
|
+
purple: createCustomTheme({
|
|
202
|
+
"flow-node-background": "#f9f0ff",
|
|
203
|
+
"flow-node-border": "#d3adf7",
|
|
204
|
+
"flow-node-selected-border": "#722ed1",
|
|
205
|
+
"flow-node-selected-shadow": "0 0 8px rgba(114, 46, 209, 0.4)",
|
|
206
|
+
"flow-handle-border": "#722ed1",
|
|
207
|
+
"flow-edge-selected-stroke": "#722ed1",
|
|
208
|
+
"flow-edge-animated-stroke": "#722ed1",
|
|
209
|
+
"flow-background-color": "#f9f0ff",
|
|
210
|
+
"flow-grid-color": "#efdbff",
|
|
211
|
+
"flow-bpmn-start-stroke": "#52c41a",
|
|
212
|
+
"flow-bpmn-task-stroke": "#1890ff",
|
|
213
|
+
"flow-bpmn-gateway-stroke": "#faad14",
|
|
214
|
+
"flow-ai-node-border": "#722ed1",
|
|
215
|
+
"flow-ai-node-accent": "#b37feb"
|
|
216
|
+
})
|
|
217
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.canvasToScreen = canvasToScreen;
|
|
7
|
+
exports.distanceBetweenPoints = distanceBetweenPoints;
|
|
8
|
+
exports.getElementCanvasPosition = getElementCanvasPosition;
|
|
9
|
+
exports.getElementPosition = getElementPosition;
|
|
10
|
+
exports.getVector = getVector;
|
|
11
|
+
exports.getVectorMagnitude = getVectorMagnitude;
|
|
12
|
+
exports.normalizeVector = normalizeVector;
|
|
13
|
+
exports.projectNodePosition = projectNodePosition;
|
|
14
|
+
exports.screenToCanvas = screenToCanvas;
|
|
15
|
+
exports.snapPositionToGrid = snapPositionToGrid;
|
|
16
|
+
exports.snapToGrid = snapToGrid;
|
|
17
|
+
function screenToCanvas(screenX, screenY, transform) {
|
|
18
|
+
return {
|
|
19
|
+
x: (screenX - transform.x) / transform.zoom,
|
|
20
|
+
y: (screenY - transform.y) / transform.zoom
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function canvasToScreen(canvasX, canvasY, transform) {
|
|
24
|
+
return {
|
|
25
|
+
x: canvasX * transform.zoom + transform.x,
|
|
26
|
+
y: canvasY * transform.zoom + transform.y
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function projectNodePosition(position, fromTransform, toTransform) {
|
|
30
|
+
const canvasPos = screenToCanvas(position.x, position.y, fromTransform);
|
|
31
|
+
return canvasToScreen(canvasPos.x, canvasPos.y, toTransform);
|
|
32
|
+
}
|
|
33
|
+
function getElementPosition(element, container) {
|
|
34
|
+
const containerRect = container.getBoundingClientRect();
|
|
35
|
+
const elementRect = element.getBoundingClientRect();
|
|
36
|
+
return {
|
|
37
|
+
x: elementRect.left - containerRect.left,
|
|
38
|
+
y: elementRect.top - containerRect.top
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function getElementCanvasPosition(element, container, transform) {
|
|
42
|
+
const screenPos = getElementPosition(element, container);
|
|
43
|
+
return screenToCanvas(screenPos.x, screenPos.y, transform);
|
|
44
|
+
}
|
|
45
|
+
function distanceBetweenPoints(p1, p2) {
|
|
46
|
+
return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
|
|
47
|
+
}
|
|
48
|
+
function getVector(source, target) {
|
|
49
|
+
return {
|
|
50
|
+
x: target.x - source.x,
|
|
51
|
+
y: target.y - source.y
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function getVectorMagnitude(vector) {
|
|
55
|
+
return Math.sqrt(vector.x * vector.x + vector.y * vector.y);
|
|
56
|
+
}
|
|
57
|
+
function normalizeVector(vector) {
|
|
58
|
+
const magnitude = getVectorMagnitude(vector);
|
|
59
|
+
if (magnitude === 0) return {
|
|
60
|
+
x: 0,
|
|
61
|
+
y: 0
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
x: vector.x / magnitude,
|
|
65
|
+
y: vector.y / magnitude
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function snapToGrid(value, grid) {
|
|
69
|
+
return Math.round(value / grid) * grid;
|
|
70
|
+
}
|
|
71
|
+
function snapPositionToGrid(position, grid) {
|
|
72
|
+
return {
|
|
73
|
+
x: snapToGrid(position.x, grid[0]),
|
|
74
|
+
y: snapToGrid(position.y, grid[1])
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Coordinate, ViewportTransform } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 屏幕坐标转换为画布坐标
|
|
4
|
+
*/
|
|
5
|
+
export declare function screenToCanvas(screenX: number, screenY: number, transform: ViewportTransform): Coordinate;
|
|
6
|
+
/**
|
|
7
|
+
* 画布坐标转换为屏幕坐标
|
|
8
|
+
*/
|
|
9
|
+
export declare function canvasToScreen(canvasX: number, canvasY: number, transform: ViewportTransform): Coordinate;
|
|
10
|
+
/**
|
|
11
|
+
* 将节点坐标从一个视口转换到另一个视口
|
|
12
|
+
*/
|
|
13
|
+
export declare function projectNodePosition(position: Coordinate, fromTransform: ViewportTransform, toTransform: ViewportTransform): Coordinate;
|
|
14
|
+
/**
|
|
15
|
+
* 获取元素在屏幕上的位置
|
|
16
|
+
*/
|
|
17
|
+
export declare function getElementPosition(element: HTMLElement, container: HTMLElement): Coordinate;
|
|
18
|
+
/**
|
|
19
|
+
* 获取元素在画布上的位置
|
|
20
|
+
*/
|
|
21
|
+
export declare function getElementCanvasPosition(element: HTMLElement, container: HTMLElement, transform: ViewportTransform): Coordinate;
|
|
22
|
+
/**
|
|
23
|
+
* 计算两个位置之间的距离
|
|
24
|
+
*/
|
|
25
|
+
export declare function distanceBetweenPoints(p1: Coordinate, p2: Coordinate): number;
|
|
26
|
+
/**
|
|
27
|
+
* 计算从源位置到目标位置的向量
|
|
28
|
+
*/
|
|
29
|
+
export declare function getVector(source: Coordinate, target: Coordinate): Coordinate;
|
|
30
|
+
/**
|
|
31
|
+
* 获取向量的模(长度)
|
|
32
|
+
*/
|
|
33
|
+
export declare function getVectorMagnitude(vector: Coordinate): number;
|
|
34
|
+
/**
|
|
35
|
+
* 归一化向量
|
|
36
|
+
*/
|
|
37
|
+
export declare function normalizeVector(vector: Coordinate): Coordinate;
|
|
38
|
+
/**
|
|
39
|
+
* 将值吸附到网格
|
|
40
|
+
*/
|
|
41
|
+
export declare function snapToGrid(value: number, grid: number): number;
|
|
42
|
+
/**
|
|
43
|
+
* 将坐标吸附到网格
|
|
44
|
+
*/
|
|
45
|
+
export declare function snapPositionToGrid(position: Coordinate, grid: [number, number]): Coordinate;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export function screenToCanvas(screenX, screenY, transform) {
|
|
2
|
+
return {
|
|
3
|
+
x: (screenX - transform.x) / transform.zoom,
|
|
4
|
+
y: (screenY - transform.y) / transform.zoom
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function canvasToScreen(canvasX, canvasY, transform) {
|
|
8
|
+
return {
|
|
9
|
+
x: canvasX * transform.zoom + transform.x,
|
|
10
|
+
y: canvasY * transform.zoom + transform.y
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function projectNodePosition(position, fromTransform, toTransform) {
|
|
14
|
+
const canvasPos = screenToCanvas(position.x, position.y, fromTransform);
|
|
15
|
+
return canvasToScreen(canvasPos.x, canvasPos.y, toTransform);
|
|
16
|
+
}
|
|
17
|
+
export function getElementPosition(element, container) {
|
|
18
|
+
const containerRect = container.getBoundingClientRect();
|
|
19
|
+
const elementRect = element.getBoundingClientRect();
|
|
20
|
+
return {
|
|
21
|
+
x: elementRect.left - containerRect.left,
|
|
22
|
+
y: elementRect.top - containerRect.top
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function getElementCanvasPosition(element, container, transform) {
|
|
26
|
+
const screenPos = getElementPosition(element, container);
|
|
27
|
+
return screenToCanvas(screenPos.x, screenPos.y, transform);
|
|
28
|
+
}
|
|
29
|
+
export function distanceBetweenPoints(p1, p2) {
|
|
30
|
+
return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
|
|
31
|
+
}
|
|
32
|
+
export function getVector(source, target) {
|
|
33
|
+
return {
|
|
34
|
+
x: target.x - source.x,
|
|
35
|
+
y: target.y - source.y
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function getVectorMagnitude(vector) {
|
|
39
|
+
return Math.sqrt(vector.x * vector.x + vector.y * vector.y);
|
|
40
|
+
}
|
|
41
|
+
export function normalizeVector(vector) {
|
|
42
|
+
const magnitude = getVectorMagnitude(vector);
|
|
43
|
+
if (magnitude === 0) return { x: 0, y: 0 };
|
|
44
|
+
return {
|
|
45
|
+
x: vector.x / magnitude,
|
|
46
|
+
y: vector.y / magnitude
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function snapToGrid(value, grid) {
|
|
50
|
+
return Math.round(value / grid) * grid;
|
|
51
|
+
}
|
|
52
|
+
export function snapPositionToGrid(position, grid) {
|
|
53
|
+
return {
|
|
54
|
+
x: snapToGrid(position.x, grid[0]),
|
|
55
|
+
y: snapToGrid(position.y, grid[1])
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createConnectionValidator = createConnectionValidator;
|
|
7
|
+
exports.detectCycles = detectCycles;
|
|
8
|
+
exports.isValidConnection = isValidConnection;
|
|
9
|
+
function createConnectionValidator(rules) {
|
|
10
|
+
return connection => {
|
|
11
|
+
if (!rules || rules.length === 0) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
for (const rule of rules) {
|
|
15
|
+
const sourceMatches = matchesRule(connection.source, rule.source);
|
|
16
|
+
const targetMatches = matchesRule(connection.target, rule.target);
|
|
17
|
+
const sourceHandleMatches = matchesHandleRule(connection.sourceHandle, rule.sourceHandle);
|
|
18
|
+
const targetHandleMatches = matchesHandleRule(connection.targetHandle, rule.targetHandle);
|
|
19
|
+
if (sourceMatches && targetMatches && sourceHandleMatches && targetHandleMatches) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function matchesRule(value, pattern) {
|
|
27
|
+
if (!pattern) return true;
|
|
28
|
+
if (Array.isArray(pattern)) {
|
|
29
|
+
return pattern.includes(value);
|
|
30
|
+
}
|
|
31
|
+
if (pattern === "*") return true;
|
|
32
|
+
try {
|
|
33
|
+
const regex = new RegExp(pattern);
|
|
34
|
+
return regex.test(value);
|
|
35
|
+
} catch {
|
|
36
|
+
return value === pattern;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function matchesHandleRule(handle, pattern) {
|
|
40
|
+
if (pattern === null || pattern === void 0) return true;
|
|
41
|
+
if (!handle && pattern) return false;
|
|
42
|
+
return matchesRule(handle, pattern);
|
|
43
|
+
}
|
|
44
|
+
function isValidConnection(sourceNode, targetNode, connection) {
|
|
45
|
+
if (!sourceNode) {
|
|
46
|
+
return {
|
|
47
|
+
isValid: false,
|
|
48
|
+
message: "Source node not found"
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (!targetNode) {
|
|
52
|
+
return {
|
|
53
|
+
isValid: false,
|
|
54
|
+
message: "Target node not found"
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (connection.source === connection.target) {
|
|
58
|
+
return {
|
|
59
|
+
isValid: false,
|
|
60
|
+
message: "Cannot connect to the same node"
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (connection.target === connection.source) {
|
|
64
|
+
return {
|
|
65
|
+
isValid: false,
|
|
66
|
+
message: "Cannot create self-loop"
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
isValid: true
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function detectCycles(edges, newEdge) {
|
|
74
|
+
const adjacencyList = /* @__PURE__ */new Map();
|
|
75
|
+
for (const edge of edges) {
|
|
76
|
+
if (!adjacencyList.has(edge.source)) {
|
|
77
|
+
adjacencyList.set(edge.source, []);
|
|
78
|
+
}
|
|
79
|
+
adjacencyList.get(edge.source).push(edge.target);
|
|
80
|
+
}
|
|
81
|
+
if (!adjacencyList.has(newEdge.source)) {
|
|
82
|
+
adjacencyList.set(newEdge.source, []);
|
|
83
|
+
}
|
|
84
|
+
adjacencyList.get(newEdge.source).push(newEdge.target);
|
|
85
|
+
const visited = /* @__PURE__ */new Set();
|
|
86
|
+
const recursionStack = /* @__PURE__ */new Set();
|
|
87
|
+
function hasCycle(node) {
|
|
88
|
+
visited.add(node);
|
|
89
|
+
recursionStack.add(node);
|
|
90
|
+
const neighbors = adjacencyList.get(node) || [];
|
|
91
|
+
for (const neighbor of neighbors) {
|
|
92
|
+
if (!visited.has(neighbor)) {
|
|
93
|
+
if (hasCycle(neighbor)) return true;
|
|
94
|
+
} else if (recursionStack.has(neighbor)) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
recursionStack.delete(node);
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
for (const node of adjacencyList.keys()) {
|
|
102
|
+
if (!visited.has(node)) {
|
|
103
|
+
if (hasCycle(node)) return true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Node, Edge } from '../types';
|
|
2
|
+
export type ConnectionType = 'default' | 'loop' | 'step' | 'custom';
|
|
3
|
+
export interface ConnectionRule {
|
|
4
|
+
source: string | string[];
|
|
5
|
+
target: string | string[];
|
|
6
|
+
sourceHandle?: string | string[] | null;
|
|
7
|
+
targetHandle?: string | string[] | null;
|
|
8
|
+
}
|
|
9
|
+
export interface ValidationResult {
|
|
10
|
+
isValid: boolean;
|
|
11
|
+
message?: string;
|
|
12
|
+
}
|
|
13
|
+
export type IsValidConnectionFn = (connection: {
|
|
14
|
+
source: string;
|
|
15
|
+
target: string;
|
|
16
|
+
sourceHandle?: string | null;
|
|
17
|
+
targetHandle?: string | null;
|
|
18
|
+
}) => boolean;
|
|
19
|
+
export declare function createConnectionValidator(rules?: ConnectionRule[]): IsValidConnectionFn;
|
|
20
|
+
export declare function isValidConnection(sourceNode: Node | undefined, targetNode: Node | undefined, connection: {
|
|
21
|
+
source: string;
|
|
22
|
+
target: string;
|
|
23
|
+
sourceHandle?: string | null;
|
|
24
|
+
targetHandle?: string | null;
|
|
25
|
+
}): ValidationResult;
|
|
26
|
+
export declare function detectCycles(edges: Edge[], newEdge: {
|
|
27
|
+
source: string;
|
|
28
|
+
target: string;
|
|
29
|
+
}): boolean;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export function createConnectionValidator(rules) {
|
|
2
|
+
return (connection) => {
|
|
3
|
+
if (!rules || rules.length === 0) {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
for (const rule of rules) {
|
|
7
|
+
const sourceMatches = matchesRule(connection.source, rule.source);
|
|
8
|
+
const targetMatches = matchesRule(connection.target, rule.target);
|
|
9
|
+
const sourceHandleMatches = matchesHandleRule(connection.sourceHandle, rule.sourceHandle);
|
|
10
|
+
const targetHandleMatches = matchesHandleRule(connection.targetHandle, rule.targetHandle);
|
|
11
|
+
if (sourceMatches && targetMatches && sourceHandleMatches && targetHandleMatches) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function matchesRule(value, pattern) {
|
|
19
|
+
if (!pattern) return true;
|
|
20
|
+
if (Array.isArray(pattern)) {
|
|
21
|
+
return pattern.includes(value);
|
|
22
|
+
}
|
|
23
|
+
if (pattern === "*") return true;
|
|
24
|
+
try {
|
|
25
|
+
const regex = new RegExp(pattern);
|
|
26
|
+
return regex.test(value);
|
|
27
|
+
} catch {
|
|
28
|
+
return value === pattern;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function matchesHandleRule(handle, pattern) {
|
|
32
|
+
if (pattern === null || pattern === void 0) return true;
|
|
33
|
+
if (!handle && pattern) return false;
|
|
34
|
+
return matchesRule(handle, pattern);
|
|
35
|
+
}
|
|
36
|
+
export function isValidConnection(sourceNode, targetNode, connection) {
|
|
37
|
+
if (!sourceNode) {
|
|
38
|
+
return { isValid: false, message: "Source node not found" };
|
|
39
|
+
}
|
|
40
|
+
if (!targetNode) {
|
|
41
|
+
return { isValid: false, message: "Target node not found" };
|
|
42
|
+
}
|
|
43
|
+
if (connection.source === connection.target) {
|
|
44
|
+
return { isValid: false, message: "Cannot connect to the same node" };
|
|
45
|
+
}
|
|
46
|
+
if (connection.target === connection.source) {
|
|
47
|
+
return { isValid: false, message: "Cannot create self-loop" };
|
|
48
|
+
}
|
|
49
|
+
return { isValid: true };
|
|
50
|
+
}
|
|
51
|
+
export function detectCycles(edges, newEdge) {
|
|
52
|
+
const adjacencyList = /* @__PURE__ */ new Map();
|
|
53
|
+
for (const edge of edges) {
|
|
54
|
+
if (!adjacencyList.has(edge.source)) {
|
|
55
|
+
adjacencyList.set(edge.source, []);
|
|
56
|
+
}
|
|
57
|
+
adjacencyList.get(edge.source).push(edge.target);
|
|
58
|
+
}
|
|
59
|
+
if (!adjacencyList.has(newEdge.source)) {
|
|
60
|
+
adjacencyList.set(newEdge.source, []);
|
|
61
|
+
}
|
|
62
|
+
adjacencyList.get(newEdge.source).push(newEdge.target);
|
|
63
|
+
const visited = /* @__PURE__ */ new Set();
|
|
64
|
+
const recursionStack = /* @__PURE__ */ new Set();
|
|
65
|
+
function hasCycle(node) {
|
|
66
|
+
visited.add(node);
|
|
67
|
+
recursionStack.add(node);
|
|
68
|
+
const neighbors = adjacencyList.get(node) || [];
|
|
69
|
+
for (const neighbor of neighbors) {
|
|
70
|
+
if (!visited.has(neighbor)) {
|
|
71
|
+
if (hasCycle(neighbor)) return true;
|
|
72
|
+
} else if (recursionStack.has(neighbor)) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
recursionStack.delete(node);
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
for (const node of adjacencyList.keys()) {
|
|
80
|
+
if (!visited.has(node)) {
|
|
81
|
+
if (hasCycle(node)) return true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yh-ui/flow",
|
|
3
|
+
"version": "0.1.21",
|
|
4
|
+
"description": "YH-UI High-performance Flow Chart Component",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./*": {
|
|
17
|
+
"types": "./dist/*.d.ts",
|
|
18
|
+
"import": "./dist/*.mjs",
|
|
19
|
+
"require": "./dist/*.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@yh-ui/utils": "0.1.21",
|
|
27
|
+
"@yh-ui/hooks": "0.1.21"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"vue": "^3.5.27",
|
|
31
|
+
"vue-tsc": "^2.2.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"vue": "^3.5.27"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/1079161148/yh-ui.git",
|
|
42
|
+
"directory": "packages/flow"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"yh-ui",
|
|
46
|
+
"flow",
|
|
47
|
+
"flow-chart",
|
|
48
|
+
"node-editor",
|
|
49
|
+
"vue-flow",
|
|
50
|
+
"diagram"
|
|
51
|
+
],
|
|
52
|
+
"homepage": "https://1079161148.github.io/yh-ui/",
|
|
53
|
+
"author": "YH-UI Team",
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "unbuild",
|
|
57
|
+
"dev": "unbuild --stub",
|
|
58
|
+
"typecheck": "vue-tsc --noEmit",
|
|
59
|
+
"lint": "eslint ."
|
|
60
|
+
}
|
|
61
|
+
}
|