@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.
Files changed (354) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +234 -0
  3. package/dist/Flow.d.vue.ts +306 -0
  4. package/dist/Flow.vue +959 -0
  5. package/dist/Flow.vue.d.ts +306 -0
  6. package/dist/__tests__/ai-workflow.ssr.test.cjs +352 -0
  7. package/dist/__tests__/ai-workflow.ssr.test.d.ts +1 -0
  8. package/dist/__tests__/ai-workflow.ssr.test.mjs +283 -0
  9. package/dist/__tests__/ai-workflow.test.cjs +109 -0
  10. package/dist/__tests__/ai-workflow.test.d.ts +1 -0
  11. package/dist/__tests__/ai-workflow.test.mjs +112 -0
  12. package/dist/__tests__/bpmn.ssr.test.cjs +278 -0
  13. package/dist/__tests__/bpmn.ssr.test.d.ts +1 -0
  14. package/dist/__tests__/bpmn.ssr.test.mjs +237 -0
  15. package/dist/__tests__/bpmn.test.cjs +103 -0
  16. package/dist/__tests__/bpmn.test.d.ts +1 -0
  17. package/dist/__tests__/bpmn.test.mjs +106 -0
  18. package/dist/__tests__/custom-types.test.cjs +300 -0
  19. package/dist/__tests__/custom-types.test.d.ts +1 -0
  20. package/dist/__tests__/custom-types.test.mjs +248 -0
  21. package/dist/__tests__/edge.test.cjs +56 -0
  22. package/dist/__tests__/edge.test.d.ts +1 -0
  23. package/dist/__tests__/edge.test.mjs +69 -0
  24. package/dist/__tests__/event-bus.test.cjs +80 -0
  25. package/dist/__tests__/event-bus.test.d.ts +1 -0
  26. package/dist/__tests__/event-bus.test.mjs +51 -0
  27. package/dist/__tests__/flow.ssr.test.cjs +156 -0
  28. package/dist/__tests__/flow.ssr.test.d.ts +1 -0
  29. package/dist/__tests__/flow.ssr.test.mjs +112 -0
  30. package/dist/__tests__/geometry.test.cjs +191 -0
  31. package/dist/__tests__/geometry.test.d.ts +1 -0
  32. package/dist/__tests__/geometry.test.mjs +105 -0
  33. package/dist/__tests__/graph.test.cjs +115 -0
  34. package/dist/__tests__/graph.test.d.ts +1 -0
  35. package/dist/__tests__/graph.test.mjs +85 -0
  36. package/dist/__tests__/history-plugin.test.cjs +191 -0
  37. package/dist/__tests__/history-plugin.test.d.ts +1 -0
  38. package/dist/__tests__/history-plugin.test.mjs +161 -0
  39. package/dist/__tests__/history.test.cjs +81 -0
  40. package/dist/__tests__/history.test.d.ts +1 -0
  41. package/dist/__tests__/history.test.mjs +43 -0
  42. package/dist/__tests__/layout.test.cjs +213 -0
  43. package/dist/__tests__/layout.test.d.ts +1 -0
  44. package/dist/__tests__/layout.test.mjs +170 -0
  45. package/dist/__tests__/node-edit-panel.ssr.test.cjs +168 -0
  46. package/dist/__tests__/node-edit-panel.ssr.test.d.ts +1 -0
  47. package/dist/__tests__/node-edit-panel.ssr.test.mjs +118 -0
  48. package/dist/__tests__/node-group-plugin.test.cjs +235 -0
  49. package/dist/__tests__/node-group-plugin.test.d.ts +1 -0
  50. package/dist/__tests__/node-group-plugin.test.mjs +187 -0
  51. package/dist/__tests__/node-handles.test.cjs +340 -0
  52. package/dist/__tests__/node-handles.test.d.ts +1 -0
  53. package/dist/__tests__/node-handles.test.mjs +230 -0
  54. package/dist/__tests__/plugin.test.cjs +151 -0
  55. package/dist/__tests__/plugin.test.d.ts +1 -0
  56. package/dist/__tests__/plugin.test.mjs +116 -0
  57. package/dist/__tests__/transform.test.cjs +58 -0
  58. package/dist/__tests__/transform.test.d.ts +1 -0
  59. package/dist/__tests__/transform.test.mjs +38 -0
  60. package/dist/__tests__/useAlignment.test.cjs +91 -0
  61. package/dist/__tests__/useAlignment.test.d.ts +1 -0
  62. package/dist/__tests__/useAlignment.test.mjs +52 -0
  63. package/dist/__tests__/useEdges.test.cjs +117 -0
  64. package/dist/__tests__/useEdges.test.d.ts +1 -0
  65. package/dist/__tests__/useEdges.test.mjs +80 -0
  66. package/dist/__tests__/useKeyboard.test.cjs +88 -0
  67. package/dist/__tests__/useKeyboard.test.d.ts +1 -0
  68. package/dist/__tests__/useKeyboard.test.mjs +56 -0
  69. package/dist/__tests__/useNodes.test.cjs +150 -0
  70. package/dist/__tests__/useNodes.test.d.ts +1 -0
  71. package/dist/__tests__/useNodes.test.mjs +80 -0
  72. package/dist/__tests__/useSelection.test.cjs +112 -0
  73. package/dist/__tests__/useSelection.test.d.ts +1 -0
  74. package/dist/__tests__/useSelection.test.mjs +76 -0
  75. package/dist/__tests__/useViewport.test.cjs +171 -0
  76. package/dist/__tests__/useViewport.test.d.ts +1 -0
  77. package/dist/__tests__/useViewport.test.mjs +82 -0
  78. package/dist/__tests__/utils/ssr.cjs +124 -0
  79. package/dist/__tests__/utils/ssr.d.ts +33 -0
  80. package/dist/__tests__/utils/ssr.mjs +129 -0
  81. package/dist/__tests__/validation.test.cjs +95 -0
  82. package/dist/__tests__/validation.test.d.ts +1 -0
  83. package/dist/__tests__/validation.test.mjs +36 -0
  84. package/dist/components/AiNodeEditPanel.d.vue.ts +13 -0
  85. package/dist/components/AiNodeEditPanel.vue +413 -0
  86. package/dist/components/AiNodeEditPanel.vue.d.ts +13 -0
  87. package/dist/components/EdgeEditPanel.d.vue.ts +14 -0
  88. package/dist/components/EdgeEditPanel.vue +205 -0
  89. package/dist/components/EdgeEditPanel.vue.d.ts +14 -0
  90. package/dist/components/NodeEditPanel.d.vue.ts +13 -0
  91. package/dist/components/NodeEditPanel.vue +214 -0
  92. package/dist/components/NodeEditPanel.vue.d.ts +13 -0
  93. package/dist/components/edges/BaseEdge.d.vue.ts +23 -0
  94. package/dist/components/edges/BaseEdge.vue +55 -0
  95. package/dist/components/edges/BaseEdge.vue.d.ts +23 -0
  96. package/dist/components/edges/BezierEdge.d.vue.ts +22 -0
  97. package/dist/components/edges/BezierEdge.vue +57 -0
  98. package/dist/components/edges/BezierEdge.vue.d.ts +22 -0
  99. package/dist/components/edges/DataFlowEdge.d.vue.ts +41 -0
  100. package/dist/components/edges/DataFlowEdge.vue +211 -0
  101. package/dist/components/edges/DataFlowEdge.vue.d.ts +41 -0
  102. package/dist/components/edges/SmoothEdge.d.vue.ts +22 -0
  103. package/dist/components/edges/SmoothEdge.vue +53 -0
  104. package/dist/components/edges/SmoothEdge.vue.d.ts +22 -0
  105. package/dist/components/edges/StepEdge.d.vue.ts +22 -0
  106. package/dist/components/edges/StepEdge.vue +42 -0
  107. package/dist/components/edges/StepEdge.vue.d.ts +22 -0
  108. package/dist/components/edges/index.cjs +41 -0
  109. package/dist/components/edges/index.d.ts +5 -0
  110. package/dist/components/edges/index.mjs +5 -0
  111. package/dist/components/nodes/BaseNode.d.vue.ts +25 -0
  112. package/dist/components/nodes/BaseNode.vue +93 -0
  113. package/dist/components/nodes/BaseNode.vue.d.ts +25 -0
  114. package/dist/components/nodes/CustomNode.d.vue.ts +36 -0
  115. package/dist/components/nodes/CustomNode.vue +44 -0
  116. package/dist/components/nodes/CustomNode.vue.d.ts +36 -0
  117. package/dist/components/nodes/DatabaseNode.d.vue.ts +19 -0
  118. package/dist/components/nodes/DatabaseNode.vue +62 -0
  119. package/dist/components/nodes/DatabaseNode.vue.d.ts +19 -0
  120. package/dist/components/nodes/DiamondNode.d.vue.ts +19 -0
  121. package/dist/components/nodes/DiamondNode.vue +62 -0
  122. package/dist/components/nodes/DiamondNode.vue.d.ts +19 -0
  123. package/dist/components/nodes/GroupNode.d.vue.ts +31 -0
  124. package/dist/components/nodes/GroupNode.vue +48 -0
  125. package/dist/components/nodes/GroupNode.vue.d.ts +31 -0
  126. package/dist/components/nodes/InputNode.d.vue.ts +23 -0
  127. package/dist/components/nodes/InputNode.vue +63 -0
  128. package/dist/components/nodes/InputNode.vue.d.ts +23 -0
  129. package/dist/components/nodes/NodeResizer.d.vue.ts +27 -0
  130. package/dist/components/nodes/NodeResizer.vue +89 -0
  131. package/dist/components/nodes/NodeResizer.vue.d.ts +27 -0
  132. package/dist/components/nodes/NodeToolbar.d.vue.ts +32 -0
  133. package/dist/components/nodes/NodeToolbar.vue +101 -0
  134. package/dist/components/nodes/NodeToolbar.vue.d.ts +32 -0
  135. package/dist/components/nodes/OutputNode.d.vue.ts +21 -0
  136. package/dist/components/nodes/OutputNode.vue +53 -0
  137. package/dist/components/nodes/OutputNode.vue.d.ts +21 -0
  138. package/dist/components/nodes/ai-workflow/AiAgentNode.d.vue.ts +20 -0
  139. package/dist/components/nodes/ai-workflow/AiAgentNode.vue +59 -0
  140. package/dist/components/nodes/ai-workflow/AiAgentNode.vue.d.ts +20 -0
  141. package/dist/components/nodes/ai-workflow/AiConditionNode.d.vue.ts +19 -0
  142. package/dist/components/nodes/ai-workflow/AiConditionNode.vue +65 -0
  143. package/dist/components/nodes/ai-workflow/AiConditionNode.vue.d.ts +19 -0
  144. package/dist/components/nodes/ai-workflow/AiEndNode.d.vue.ts +19 -0
  145. package/dist/components/nodes/ai-workflow/AiEndNode.vue +47 -0
  146. package/dist/components/nodes/ai-workflow/AiEndNode.vue.d.ts +19 -0
  147. package/dist/components/nodes/ai-workflow/AiLlmNode.d.vue.ts +19 -0
  148. package/dist/components/nodes/ai-workflow/AiLlmNode.vue +64 -0
  149. package/dist/components/nodes/ai-workflow/AiLlmNode.vue.d.ts +19 -0
  150. package/dist/components/nodes/ai-workflow/AiMemoryNode.d.vue.ts +19 -0
  151. package/dist/components/nodes/ai-workflow/AiMemoryNode.vue +59 -0
  152. package/dist/components/nodes/ai-workflow/AiMemoryNode.vue.d.ts +19 -0
  153. package/dist/components/nodes/ai-workflow/AiPromptNode.d.vue.ts +19 -0
  154. package/dist/components/nodes/ai-workflow/AiPromptNode.vue +61 -0
  155. package/dist/components/nodes/ai-workflow/AiPromptNode.vue.d.ts +19 -0
  156. package/dist/components/nodes/ai-workflow/AiStartNode.d.vue.ts +19 -0
  157. package/dist/components/nodes/ai-workflow/AiStartNode.vue +47 -0
  158. package/dist/components/nodes/ai-workflow/AiStartNode.vue.d.ts +19 -0
  159. package/dist/components/nodes/ai-workflow/AiToolNode.d.vue.ts +19 -0
  160. package/dist/components/nodes/ai-workflow/AiToolNode.vue +59 -0
  161. package/dist/components/nodes/ai-workflow/AiToolNode.vue.d.ts +19 -0
  162. package/dist/components/nodes/ai-workflow/index.cjs +109 -0
  163. package/dist/components/nodes/ai-workflow/index.d.ts +23 -0
  164. package/dist/components/nodes/ai-workflow/index.mjs +37 -0
  165. package/dist/components/nodes/bpmn/BpmnEndEvent.d.vue.ts +19 -0
  166. package/dist/components/nodes/bpmn/BpmnEndEvent.vue +50 -0
  167. package/dist/components/nodes/bpmn/BpmnEndEvent.vue.d.ts +19 -0
  168. package/dist/components/nodes/bpmn/BpmnExclusiveGateway.d.vue.ts +19 -0
  169. package/dist/components/nodes/bpmn/BpmnExclusiveGateway.vue +60 -0
  170. package/dist/components/nodes/bpmn/BpmnExclusiveGateway.vue.d.ts +19 -0
  171. package/dist/components/nodes/bpmn/BpmnInclusiveGateway.d.vue.ts +19 -0
  172. package/dist/components/nodes/bpmn/BpmnInclusiveGateway.vue +60 -0
  173. package/dist/components/nodes/bpmn/BpmnInclusiveGateway.vue.d.ts +19 -0
  174. package/dist/components/nodes/bpmn/BpmnParallelGateway.d.vue.ts +19 -0
  175. package/dist/components/nodes/bpmn/BpmnParallelGateway.vue +60 -0
  176. package/dist/components/nodes/bpmn/BpmnParallelGateway.vue.d.ts +19 -0
  177. package/dist/components/nodes/bpmn/BpmnServiceTask.d.vue.ts +19 -0
  178. package/dist/components/nodes/bpmn/BpmnServiceTask.vue +55 -0
  179. package/dist/components/nodes/bpmn/BpmnServiceTask.vue.d.ts +19 -0
  180. package/dist/components/nodes/bpmn/BpmnStartEvent.d.vue.ts +19 -0
  181. package/dist/components/nodes/bpmn/BpmnStartEvent.vue +50 -0
  182. package/dist/components/nodes/bpmn/BpmnStartEvent.vue.d.ts +19 -0
  183. package/dist/components/nodes/bpmn/BpmnTask.d.vue.ts +19 -0
  184. package/dist/components/nodes/bpmn/BpmnTask.vue +54 -0
  185. package/dist/components/nodes/bpmn/BpmnTask.vue.d.ts +19 -0
  186. package/dist/components/nodes/bpmn/BpmnUserTask.d.vue.ts +19 -0
  187. package/dist/components/nodes/bpmn/BpmnUserTask.vue +55 -0
  188. package/dist/components/nodes/bpmn/BpmnUserTask.vue.d.ts +19 -0
  189. package/dist/components/nodes/bpmn/index.cjs +109 -0
  190. package/dist/components/nodes/bpmn/index.d.ts +23 -0
  191. package/dist/components/nodes/bpmn/index.mjs +37 -0
  192. package/dist/components/nodes/index.cjs +246 -0
  193. package/dist/components/nodes/index.d.ts +13 -0
  194. package/dist/components/nodes/index.mjs +44 -0
  195. package/dist/core/FlowContext.cjs +21 -0
  196. package/dist/core/FlowContext.d.ts +10 -0
  197. package/dist/core/FlowContext.mjs +13 -0
  198. package/dist/core/index.cjs +104 -0
  199. package/dist/core/index.d.ts +9 -0
  200. package/dist/core/index.mjs +9 -0
  201. package/dist/core/useAlignment.cjs +81 -0
  202. package/dist/core/useAlignment.d.ts +33 -0
  203. package/dist/core/useAlignment.mjs +71 -0
  204. package/dist/core/useEdges.cjs +132 -0
  205. package/dist/core/useEdges.d.ts +29 -0
  206. package/dist/core/useEdges.mjs +89 -0
  207. package/dist/core/useFlow.cjs +40 -0
  208. package/dist/core/useFlow.d.ts +31 -0
  209. package/dist/core/useFlow.mjs +32 -0
  210. package/dist/core/useHistory.cjs +63 -0
  211. package/dist/core/useHistory.d.ts +15 -0
  212. package/dist/core/useHistory.mjs +54 -0
  213. package/dist/core/useKeyboard.cjs +54 -0
  214. package/dist/core/useKeyboard.d.ts +18 -0
  215. package/dist/core/useKeyboard.mjs +45 -0
  216. package/dist/core/useNodeDistribution.cjs +171 -0
  217. package/dist/core/useNodeDistribution.d.ts +12 -0
  218. package/dist/core/useNodeDistribution.mjs +145 -0
  219. package/dist/core/useNodes.cjs +146 -0
  220. package/dist/core/useNodes.d.ts +26 -0
  221. package/dist/core/useNodes.mjs +101 -0
  222. package/dist/core/useSelection.cjs +83 -0
  223. package/dist/core/useSelection.d.ts +18 -0
  224. package/dist/core/useSelection.mjs +53 -0
  225. package/dist/core/useViewport.cjs +157 -0
  226. package/dist/core/useViewport.d.ts +65 -0
  227. package/dist/core/useViewport.mjs +125 -0
  228. package/dist/flow.cjs +240 -0
  229. package/dist/flow.d.ts +276 -0
  230. package/dist/flow.mjs +230 -0
  231. package/dist/index.cjs +378 -0
  232. package/dist/index.d.ts +28 -0
  233. package/dist/index.mjs +50 -0
  234. package/dist/plugins/index.cjs +96 -0
  235. package/dist/plugins/index.d.ts +34 -0
  236. package/dist/plugins/index.mjs +47 -0
  237. package/dist/plugins/plugin.cjs +117 -0
  238. package/dist/plugins/plugin.d.ts +72 -0
  239. package/dist/plugins/plugin.mjs +110 -0
  240. package/dist/plugins/plugins/controls.cjs +38 -0
  241. package/dist/plugins/plugins/controls.d.ts +12 -0
  242. package/dist/plugins/plugins/controls.mjs +28 -0
  243. package/dist/plugins/plugins/export.cjs +102 -0
  244. package/dist/plugins/plugins/export.d.ts +12 -0
  245. package/dist/plugins/plugins/export.mjs +89 -0
  246. package/dist/plugins/plugins/grid.cjs +36 -0
  247. package/dist/plugins/plugins/grid.d.ts +11 -0
  248. package/dist/plugins/plugins/grid.mjs +26 -0
  249. package/dist/plugins/plugins/history.cjs +140 -0
  250. package/dist/plugins/plugins/history.d.ts +53 -0
  251. package/dist/plugins/plugins/history.mjs +132 -0
  252. package/dist/plugins/plugins/index.cjs +104 -0
  253. package/dist/plugins/plugins/index.d.ts +9 -0
  254. package/dist/plugins/plugins/index.mjs +9 -0
  255. package/dist/plugins/plugins/keyboard.cjs +27 -0
  256. package/dist/plugins/plugins/keyboard.d.ts +10 -0
  257. package/dist/plugins/plugins/keyboard.mjs +18 -0
  258. package/dist/plugins/plugins/layout.cjs +275 -0
  259. package/dist/plugins/plugins/layout.d.ts +34 -0
  260. package/dist/plugins/plugins/layout.mjs +246 -0
  261. package/dist/plugins/plugins/minimap.cjs +60 -0
  262. package/dist/plugins/plugins/minimap.d.ts +25 -0
  263. package/dist/plugins/plugins/minimap.mjs +50 -0
  264. package/dist/plugins/plugins/node-group.cjs +209 -0
  265. package/dist/plugins/plugins/node-group.d.ts +26 -0
  266. package/dist/plugins/plugins/node-group.mjs +178 -0
  267. package/dist/plugins/plugins/snap.cjs +36 -0
  268. package/dist/plugins/plugins/snap.d.ts +12 -0
  269. package/dist/plugins/plugins/snap.mjs +26 -0
  270. package/dist/renderer/AlignmentLines.d.vue.ts +5 -0
  271. package/dist/renderer/AlignmentLines.vue +113 -0
  272. package/dist/renderer/AlignmentLines.vue.d.ts +5 -0
  273. package/dist/renderer/Background.d.vue.ts +7 -0
  274. package/dist/renderer/Background.vue +86 -0
  275. package/dist/renderer/Background.vue.d.ts +7 -0
  276. package/dist/renderer/Controls.d.vue.ts +13 -0
  277. package/dist/renderer/Controls.vue +82 -0
  278. package/dist/renderer/Controls.vue.d.ts +13 -0
  279. package/dist/renderer/EdgeHandlesRenderer.d.vue.ts +11 -0
  280. package/dist/renderer/EdgeHandlesRenderer.vue +75 -0
  281. package/dist/renderer/EdgeHandlesRenderer.vue.d.ts +11 -0
  282. package/dist/renderer/EdgeRenderer.d.vue.ts +39 -0
  283. package/dist/renderer/EdgeRenderer.vue +204 -0
  284. package/dist/renderer/EdgeRenderer.vue.d.ts +39 -0
  285. package/dist/renderer/FlowBackground.d.vue.ts +11 -0
  286. package/dist/renderer/FlowBackground.vue +82 -0
  287. package/dist/renderer/FlowBackground.vue.d.ts +11 -0
  288. package/dist/renderer/Minimap.d.vue.ts +30 -0
  289. package/dist/renderer/Minimap.vue +290 -0
  290. package/dist/renderer/Minimap.vue.d.ts +30 -0
  291. package/dist/renderer/NodeRenderer.d.vue.ts +56 -0
  292. package/dist/renderer/NodeRenderer.vue +328 -0
  293. package/dist/renderer/NodeRenderer.vue.d.ts +56 -0
  294. package/dist/renderer/SelectionBox.d.vue.ts +11 -0
  295. package/dist/renderer/SelectionBox.vue +28 -0
  296. package/dist/renderer/SelectionBox.vue.d.ts +11 -0
  297. package/dist/types/edge.cjs +13 -0
  298. package/dist/types/edge.d.ts +65 -0
  299. package/dist/types/edge.mjs +6 -0
  300. package/dist/types/events.cjs +1 -0
  301. package/dist/types/events.d.ts +115 -0
  302. package/dist/types/events.mjs +0 -0
  303. package/dist/types/index.cjs +1 -0
  304. package/dist/types/index.d.ts +366 -0
  305. package/dist/types/index.mjs +0 -0
  306. package/dist/types/node.cjs +9 -0
  307. package/dist/types/node.d.ts +90 -0
  308. package/dist/types/node.mjs +3 -0
  309. package/dist/types/viewport.cjs +42 -0
  310. package/dist/types/viewport.d.ts +62 -0
  311. package/dist/types/viewport.mjs +36 -0
  312. package/dist/utils/bpmn-engine.cjs +390 -0
  313. package/dist/utils/bpmn-engine.d.ts +164 -0
  314. package/dist/utils/bpmn-engine.mjs +378 -0
  315. package/dist/utils/bpmn.cjs +492 -0
  316. package/dist/utils/bpmn.d.ts +53 -0
  317. package/dist/utils/bpmn.mjs +430 -0
  318. package/dist/utils/collaboration.cjs +537 -0
  319. package/dist/utils/collaboration.d.ts +189 -0
  320. package/dist/utils/collaboration.mjs +521 -0
  321. package/dist/utils/custom-types.cjs +138 -0
  322. package/dist/utils/custom-types.d.ts +78 -0
  323. package/dist/utils/custom-types.mjs +108 -0
  324. package/dist/utils/edge.cjs +235 -0
  325. package/dist/utils/edge.d.ts +79 -0
  326. package/dist/utils/edge.mjs +172 -0
  327. package/dist/utils/event-bus.cjs +91 -0
  328. package/dist/utils/event-bus.d.ts +39 -0
  329. package/dist/utils/event-bus.mjs +82 -0
  330. package/dist/utils/geometry.cjs +178 -0
  331. package/dist/utils/geometry.d.ts +186 -0
  332. package/dist/utils/geometry.mjs +144 -0
  333. package/dist/utils/graph.cjs +158 -0
  334. package/dist/utils/graph.d.ts +40 -0
  335. package/dist/utils/graph.mjs +147 -0
  336. package/dist/utils/index.cjs +137 -0
  337. package/dist/utils/index.d.ts +12 -0
  338. package/dist/utils/index.mjs +12 -0
  339. package/dist/utils/performance.cjs +94 -0
  340. package/dist/utils/performance.d.ts +18 -0
  341. package/dist/utils/performance.mjs +82 -0
  342. package/dist/utils/screenshot.cjs +87 -0
  343. package/dist/utils/screenshot.d.ts +22 -0
  344. package/dist/utils/screenshot.mjs +66 -0
  345. package/dist/utils/theme.cjs +228 -0
  346. package/dist/utils/theme.d.ts +92 -0
  347. package/dist/utils/theme.mjs +217 -0
  348. package/dist/utils/transform.cjs +76 -0
  349. package/dist/utils/transform.d.ts +45 -0
  350. package/dist/utils/transform.mjs +57 -0
  351. package/dist/utils/validation.cjs +107 -0
  352. package/dist/utils/validation.d.ts +29 -0
  353. package/dist/utils/validation.mjs +85 -0
  354. package/package.json +61 -0
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+
3
+ var _vitest = require("vitest");
4
+ var _vue = require("vue");
5
+ var _plugin = require("../plugins/plugin.cjs");
6
+ function createMockFlowInstance() {
7
+ const nodes = (0, _vue.ref)([]);
8
+ const edges = (0, _vue.ref)([]);
9
+ const viewport = (0, _vue.ref)({
10
+ x: 0,
11
+ y: 0,
12
+ zoom: 1
13
+ });
14
+ const draggingNodeId = (0, _vue.ref)(null);
15
+ return {
16
+ nodes,
17
+ edges,
18
+ viewport,
19
+ draggingNodeId,
20
+ addNode: _vitest.vi.fn(node => {
21
+ nodes.value = [...nodes.value, node];
22
+ }),
23
+ removeNode: _vitest.vi.fn(),
24
+ updateNode: _vitest.vi.fn(),
25
+ getNode: _vitest.vi.fn(id => nodes.value.find(n => n.id === id)),
26
+ addEdge: _vitest.vi.fn(),
27
+ removeEdge: _vitest.vi.fn(),
28
+ updateEdge: _vitest.vi.fn(),
29
+ getEdge: _vitest.vi.fn(),
30
+ setViewport: _vitest.vi.fn(),
31
+ fitView: _vitest.vi.fn(),
32
+ zoomIn: _vitest.vi.fn(),
33
+ zoomOut: _vitest.vi.fn(),
34
+ centerView: _vitest.vi.fn(),
35
+ selectNode: _vitest.vi.fn(),
36
+ selectEdge: _vitest.vi.fn(),
37
+ clearSelection: _vitest.vi.fn(),
38
+ getNodes: _vitest.vi.fn(() => nodes.value),
39
+ getEdges: _vitest.vi.fn(() => edges.value),
40
+ getViewport: _vitest.vi.fn(() => viewport.value),
41
+ screenToCanvas: _vitest.vi.fn((x, y) => ({
42
+ x,
43
+ y
44
+ })),
45
+ canvasToScreen: _vitest.vi.fn((x, y) => ({
46
+ x,
47
+ y
48
+ })),
49
+ on: _vitest.vi.fn(),
50
+ off: _vitest.vi.fn(),
51
+ emit: _vitest.vi.fn(),
52
+ isValidConnection: _vitest.vi.fn(() => true),
53
+ $el: void 0,
54
+ usePlugin: _vitest.vi.fn(),
55
+ removePlugin: _vitest.vi.fn()
56
+ };
57
+ }
58
+ (0, _vitest.describe)("flow/plugins/plugin", () => {
59
+ (0, _vitest.it)("PluginManager should register and unregister plugin", () => {
60
+ const flow = createMockFlowInstance();
61
+ const pm = new _plugin.PluginManager();
62
+ pm.init(flow);
63
+ const install = _vitest.vi.fn();
64
+ const plugin = {
65
+ id: "test-plugin",
66
+ name: "Test",
67
+ install
68
+ };
69
+ pm.register(plugin);
70
+ (0, _vitest.expect)(install).toHaveBeenCalledWith(flow, void 0);
71
+ (0, _vitest.expect)(pm.hasPlugin("test-plugin")).toBe(true);
72
+ (0, _vitest.expect)(pm.getPlugin("test-plugin")).toBe(plugin);
73
+ pm.unregister("test-plugin");
74
+ (0, _vitest.expect)(pm.hasPlugin("test-plugin")).toBe(false);
75
+ (0, _vitest.expect)(pm.getPlugin("test-plugin")).toBeUndefined();
76
+ });
77
+ (0, _vitest.it)("PluginManager should call destroy on unregister", () => {
78
+ const flow = createMockFlowInstance();
79
+ const pm = new _plugin.PluginManager();
80
+ pm.init(flow);
81
+ const destroy = _vitest.vi.fn();
82
+ pm.register({
83
+ id: "d",
84
+ name: "D",
85
+ install: _vitest.vi.fn(),
86
+ destroy
87
+ });
88
+ pm.unregister("d");
89
+ (0, _vitest.expect)(destroy).toHaveBeenCalledTimes(1);
90
+ });
91
+ (0, _vitest.it)("PluginManager should not register same id twice", () => {
92
+ const flow = createMockFlowInstance();
93
+ const pm = new _plugin.PluginManager();
94
+ pm.init(flow);
95
+ const install = _vitest.vi.fn();
96
+ const plugin = {
97
+ id: "dup",
98
+ name: "Dup",
99
+ install
100
+ };
101
+ pm.register(plugin);
102
+ pm.register(plugin);
103
+ (0, _vitest.expect)(install).toHaveBeenCalledTimes(1);
104
+ });
105
+ (0, _vitest.it)("createPlugin should produce plugin with install", () => {
106
+ const flow = createMockFlowInstance();
107
+ const installFn = _vitest.vi.fn();
108
+ const plugin = (0, _plugin.createPlugin)({
109
+ id: "factory",
110
+ name: "Factory"
111
+ }, installFn);
112
+ (0, _vitest.expect)(plugin.id).toBe("factory");
113
+ (0, _vitest.expect)(plugin.name).toBe("Factory");
114
+ plugin.install(flow);
115
+ (0, _vitest.expect)(installFn).toHaveBeenCalledWith(flow, {
116
+ id: "factory",
117
+ name: "Factory"
118
+ });
119
+ });
120
+ (0, _vitest.it)("createPlugin with enabled false should not call install", () => {
121
+ const flow = createMockFlowInstance();
122
+ const installFn = _vitest.vi.fn();
123
+ const plugin = (0, _plugin.createPlugin)({
124
+ id: "disabled",
125
+ name: "Disabled",
126
+ enabled: false
127
+ }, installFn);
128
+ plugin.install(flow);
129
+ (0, _vitest.expect)(installFn).not.toHaveBeenCalled();
130
+ });
131
+ (0, _vitest.it)("destroyAll should clear all and call destroy", () => {
132
+ const flow = createMockFlowInstance();
133
+ const pm = new _plugin.PluginManager();
134
+ pm.init(flow);
135
+ const destroy = _vitest.vi.fn();
136
+ pm.register({
137
+ id: "a",
138
+ name: "A",
139
+ install: _vitest.vi.fn(),
140
+ destroy
141
+ });
142
+ pm.register({
143
+ id: "b",
144
+ name: "B",
145
+ install: _vitest.vi.fn()
146
+ });
147
+ pm.destroyAll();
148
+ (0, _vitest.expect)(destroy).toHaveBeenCalledTimes(1);
149
+ (0, _vitest.expect)(pm.getPlugins()).toHaveLength(0);
150
+ });
151
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,116 @@
1
+ import { describe, it, expect, vi } from "vitest";
2
+ import { ref } from "vue";
3
+ import { PluginManager, createPlugin } from "../plugins/plugin.mjs";
4
+ function createMockFlowInstance() {
5
+ const nodes = ref([]);
6
+ const edges = ref([]);
7
+ const viewport = ref({ x: 0, y: 0, zoom: 1 });
8
+ const draggingNodeId = ref(null);
9
+ return {
10
+ nodes,
11
+ edges,
12
+ viewport,
13
+ draggingNodeId,
14
+ addNode: vi.fn((node) => {
15
+ nodes.value = [...nodes.value, node];
16
+ }),
17
+ removeNode: vi.fn(),
18
+ updateNode: vi.fn(),
19
+ getNode: vi.fn((id) => nodes.value.find((n) => n.id === id)),
20
+ addEdge: vi.fn(),
21
+ removeEdge: vi.fn(),
22
+ updateEdge: vi.fn(),
23
+ getEdge: vi.fn(),
24
+ setViewport: vi.fn(),
25
+ fitView: vi.fn(),
26
+ zoomIn: vi.fn(),
27
+ zoomOut: vi.fn(),
28
+ centerView: vi.fn(),
29
+ selectNode: vi.fn(),
30
+ selectEdge: vi.fn(),
31
+ clearSelection: vi.fn(),
32
+ getNodes: vi.fn(() => nodes.value),
33
+ getEdges: vi.fn(() => edges.value),
34
+ getViewport: vi.fn(() => viewport.value),
35
+ screenToCanvas: vi.fn((x, y) => ({ x, y })),
36
+ canvasToScreen: vi.fn((x, y) => ({ x, y })),
37
+ on: vi.fn(),
38
+ off: vi.fn(),
39
+ emit: vi.fn(),
40
+ isValidConnection: vi.fn(() => true),
41
+ $el: void 0,
42
+ usePlugin: vi.fn(),
43
+ removePlugin: vi.fn()
44
+ };
45
+ }
46
+ describe("flow/plugins/plugin", () => {
47
+ it("PluginManager should register and unregister plugin", () => {
48
+ const flow = createMockFlowInstance();
49
+ const pm = new PluginManager();
50
+ pm.init(flow);
51
+ const install = vi.fn();
52
+ const plugin = {
53
+ id: "test-plugin",
54
+ name: "Test",
55
+ install
56
+ };
57
+ pm.register(plugin);
58
+ expect(install).toHaveBeenCalledWith(flow, void 0);
59
+ expect(pm.hasPlugin("test-plugin")).toBe(true);
60
+ expect(pm.getPlugin("test-plugin")).toBe(plugin);
61
+ pm.unregister("test-plugin");
62
+ expect(pm.hasPlugin("test-plugin")).toBe(false);
63
+ expect(pm.getPlugin("test-plugin")).toBeUndefined();
64
+ });
65
+ it("PluginManager should call destroy on unregister", () => {
66
+ const flow = createMockFlowInstance();
67
+ const pm = new PluginManager();
68
+ pm.init(flow);
69
+ const destroy = vi.fn();
70
+ pm.register({
71
+ id: "d",
72
+ name: "D",
73
+ install: vi.fn(),
74
+ destroy
75
+ });
76
+ pm.unregister("d");
77
+ expect(destroy).toHaveBeenCalledTimes(1);
78
+ });
79
+ it("PluginManager should not register same id twice", () => {
80
+ const flow = createMockFlowInstance();
81
+ const pm = new PluginManager();
82
+ pm.init(flow);
83
+ const install = vi.fn();
84
+ const plugin = { id: "dup", name: "Dup", install };
85
+ pm.register(plugin);
86
+ pm.register(plugin);
87
+ expect(install).toHaveBeenCalledTimes(1);
88
+ });
89
+ it("createPlugin should produce plugin with install", () => {
90
+ const flow = createMockFlowInstance();
91
+ const installFn = vi.fn();
92
+ const plugin = createPlugin({ id: "factory", name: "Factory" }, installFn);
93
+ expect(plugin.id).toBe("factory");
94
+ expect(plugin.name).toBe("Factory");
95
+ plugin.install(flow);
96
+ expect(installFn).toHaveBeenCalledWith(flow, { id: "factory", name: "Factory" });
97
+ });
98
+ it("createPlugin with enabled false should not call install", () => {
99
+ const flow = createMockFlowInstance();
100
+ const installFn = vi.fn();
101
+ const plugin = createPlugin({ id: "disabled", name: "Disabled", enabled: false }, installFn);
102
+ plugin.install(flow);
103
+ expect(installFn).not.toHaveBeenCalled();
104
+ });
105
+ it("destroyAll should clear all and call destroy", () => {
106
+ const flow = createMockFlowInstance();
107
+ const pm = new PluginManager();
108
+ pm.init(flow);
109
+ const destroy = vi.fn();
110
+ pm.register({ id: "a", name: "A", install: vi.fn(), destroy });
111
+ pm.register({ id: "b", name: "B", install: vi.fn() });
112
+ pm.destroyAll();
113
+ expect(destroy).toHaveBeenCalledTimes(1);
114
+ expect(pm.getPlugins()).toHaveLength(0);
115
+ });
116
+ });
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ var _vitest = require("vitest");
4
+ var _transform = require("../utils/transform.cjs");
5
+ (0, _vitest.describe)("flow/utils/transform", () => {
6
+ (0, _vitest.it)("screenToCanvas and canvasToScreen should be inverse (basic)", () => {
7
+ const t = {
8
+ x: 100,
9
+ y: 50,
10
+ zoom: 2
11
+ };
12
+ const screen = {
13
+ x: 300,
14
+ y: 250
15
+ };
16
+ const canvas = (0, _transform.screenToCanvas)(screen.x, screen.y, t);
17
+ const back = (0, _transform.canvasToScreen)(canvas.x, canvas.y, t);
18
+ (0, _vitest.expect)(back.x).toBe(screen.x);
19
+ (0, _vitest.expect)(back.y).toBe(screen.y);
20
+ });
21
+ (0, _vitest.it)("projectNodePosition should transform between viewports", () => {
22
+ const from = {
23
+ x: 10,
24
+ y: 20,
25
+ zoom: 2
26
+ };
27
+ const to = {
28
+ x: -5,
29
+ y: 15,
30
+ zoom: 1
31
+ };
32
+ const p = {
33
+ x: 110,
34
+ y: 220
35
+ };
36
+ const projected = (0, _transform.projectNodePosition)(p, from, to);
37
+ const canvas = (0, _transform.screenToCanvas)(p.x, p.y, from);
38
+ const expected = (0, _transform.canvasToScreen)(canvas.x, canvas.y, to);
39
+ (0, _vitest.expect)(projected).toEqual(expected);
40
+ });
41
+ (0, _vitest.it)("snapToGrid should round to nearest grid", () => {
42
+ (0, _vitest.expect)((0, _transform.snapToGrid)(0, 10)).toBe(0);
43
+ (0, _vitest.expect)((0, _transform.snapToGrid)(4, 10)).toBe(0);
44
+ (0, _vitest.expect)((0, _transform.snapToGrid)(5, 10)).toBe(10);
45
+ (0, _vitest.expect)((0, _transform.snapToGrid)(14, 10)).toBe(10);
46
+ (0, _vitest.expect)((0, _transform.snapToGrid)(15, 10)).toBe(20);
47
+ });
48
+ (0, _vitest.it)("snapPositionToGrid should snap x/y independently", () => {
49
+ const p = (0, _transform.snapPositionToGrid)({
50
+ x: 17,
51
+ y: 23
52
+ }, [10, 5]);
53
+ (0, _vitest.expect)(p).toEqual({
54
+ x: 20,
55
+ y: 25
56
+ });
57
+ });
58
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import {
3
+ canvasToScreen,
4
+ screenToCanvas,
5
+ projectNodePosition,
6
+ snapToGrid,
7
+ snapPositionToGrid
8
+ } from "../utils/transform.mjs";
9
+ describe("flow/utils/transform", () => {
10
+ it("screenToCanvas and canvasToScreen should be inverse (basic)", () => {
11
+ const t = { x: 100, y: 50, zoom: 2 };
12
+ const screen = { x: 300, y: 250 };
13
+ const canvas = screenToCanvas(screen.x, screen.y, t);
14
+ const back = canvasToScreen(canvas.x, canvas.y, t);
15
+ expect(back.x).toBe(screen.x);
16
+ expect(back.y).toBe(screen.y);
17
+ });
18
+ it("projectNodePosition should transform between viewports", () => {
19
+ const from = { x: 10, y: 20, zoom: 2 };
20
+ const to = { x: -5, y: 15, zoom: 1 };
21
+ const p = { x: 110, y: 220 };
22
+ const projected = projectNodePosition(p, from, to);
23
+ const canvas = screenToCanvas(p.x, p.y, from);
24
+ const expected = canvasToScreen(canvas.x, canvas.y, to);
25
+ expect(projected).toEqual(expected);
26
+ });
27
+ it("snapToGrid should round to nearest grid", () => {
28
+ expect(snapToGrid(0, 10)).toBe(0);
29
+ expect(snapToGrid(4, 10)).toBe(0);
30
+ expect(snapToGrid(5, 10)).toBe(10);
31
+ expect(snapToGrid(14, 10)).toBe(10);
32
+ expect(snapToGrid(15, 10)).toBe(20);
33
+ });
34
+ it("snapPositionToGrid should snap x/y independently", () => {
35
+ const p = snapPositionToGrid({ x: 17, y: 23 }, [10, 5]);
36
+ expect(p).toEqual({ x: 20, y: 25 });
37
+ });
38
+ });
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ var _vitest = require("vitest");
4
+ var _vue = require("vue");
5
+ var _useAlignment = require("../core/useAlignment.cjs");
6
+ const node = (id, x, y, w = 200, h = 50) => ({
7
+ id,
8
+ type: "default",
9
+ position: {
10
+ x,
11
+ y
12
+ },
13
+ data: {},
14
+ width: w,
15
+ height: h
16
+ });
17
+ (0, _vitest.describe)("flow/core/useAlignment", () => {
18
+ (0, _vitest.it)("should return same position when no other nodes", () => {
19
+ const nodes = (0, _vue.ref)([node("1", 100, 50)]);
20
+ const a = (0, _useAlignment.useAlignment)({
21
+ nodes,
22
+ snapThreshold: 10
23
+ });
24
+ const result = a.getAlignmentSnap("1", {
25
+ x: 100,
26
+ y: 50
27
+ });
28
+ (0, _vitest.expect)(result.x).toBe(100);
29
+ (0, _vitest.expect)(result.y).toBe(50);
30
+ (0, _vitest.expect)(result.snappedX).toBe(false);
31
+ (0, _vitest.expect)(result.snappedY).toBe(false);
32
+ });
33
+ (0, _vitest.it)("should snap Y when dragging node center aligns with other center", () => {
34
+ const nodes = (0, _vue.ref)([node("1", 0, 0), node("2", 300, 100)]);
35
+ const a = (0, _useAlignment.useAlignment)({
36
+ nodes,
37
+ snapThreshold: 10
38
+ });
39
+ const pos = {
40
+ x: 300,
41
+ y: 100
42
+ };
43
+ const result = a.getAlignmentSnap("1", pos);
44
+ (0, _vitest.expect)(result.snappedY).toBe(true);
45
+ (0, _vitest.expect)(result.y).toBe(100);
46
+ });
47
+ (0, _vitest.it)("should snap X when left edges align", () => {
48
+ const nodes = (0, _vue.ref)([node("1", 0, 0), node("2", 100, 200)]);
49
+ const a = (0, _useAlignment.useAlignment)({
50
+ nodes,
51
+ snapThreshold: 15
52
+ });
53
+ const pos = {
54
+ x: 98,
55
+ y: 200
56
+ };
57
+ const result = a.getAlignmentSnap("1", pos);
58
+ (0, _vitest.expect)(result.snappedX).toBe(true);
59
+ (0, _vitest.expect)(result.x).toBe(100);
60
+ });
61
+ (0, _vitest.it)("snapToAlignment should return only x,y", () => {
62
+ const nodes = (0, _vue.ref)([node("1", 0, 0), node("2", 100, 100)]);
63
+ const a = (0, _useAlignment.useAlignment)({
64
+ nodes,
65
+ snapThreshold: 20
66
+ });
67
+ const out = a.snapToAlignment("1", {
68
+ x: 105,
69
+ y: 105
70
+ });
71
+ (0, _vitest.expect)(out).toHaveProperty("x");
72
+ (0, _vitest.expect)(out).toHaveProperty("y");
73
+ (0, _vitest.expect)(Object.keys(out)).toHaveLength(2);
74
+ });
75
+ (0, _vitest.it)("should return position when nodeId not found", () => {
76
+ const nodes = (0, _vue.ref)([node("1", 0, 0)]);
77
+ const a = (0, _useAlignment.useAlignment)({
78
+ nodes
79
+ });
80
+ const result = a.getAlignmentSnap("missing", {
81
+ x: 50,
82
+ y: 50
83
+ });
84
+ (0, _vitest.expect)(result).toEqual({
85
+ x: 50,
86
+ y: 50,
87
+ snappedX: false,
88
+ snappedY: false
89
+ });
90
+ });
91
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,52 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { ref } from "vue";
3
+ import { useAlignment } from "../core/useAlignment.mjs";
4
+ const node = (id, x, y, w = 200, h = 50) => ({
5
+ id,
6
+ type: "default",
7
+ position: { x, y },
8
+ data: {},
9
+ width: w,
10
+ height: h
11
+ });
12
+ describe("flow/core/useAlignment", () => {
13
+ it("should return same position when no other nodes", () => {
14
+ const nodes = ref([node("1", 100, 50)]);
15
+ const a = useAlignment({ nodes, snapThreshold: 10 });
16
+ const result = a.getAlignmentSnap("1", { x: 100, y: 50 });
17
+ expect(result.x).toBe(100);
18
+ expect(result.y).toBe(50);
19
+ expect(result.snappedX).toBe(false);
20
+ expect(result.snappedY).toBe(false);
21
+ });
22
+ it("should snap Y when dragging node center aligns with other center", () => {
23
+ const nodes = ref([node("1", 0, 0), node("2", 300, 100)]);
24
+ const a = useAlignment({ nodes, snapThreshold: 10 });
25
+ const pos = { x: 300, y: 100 };
26
+ const result = a.getAlignmentSnap("1", pos);
27
+ expect(result.snappedY).toBe(true);
28
+ expect(result.y).toBe(100);
29
+ });
30
+ it("should snap X when left edges align", () => {
31
+ const nodes = ref([node("1", 0, 0), node("2", 100, 200)]);
32
+ const a = useAlignment({ nodes, snapThreshold: 15 });
33
+ const pos = { x: 98, y: 200 };
34
+ const result = a.getAlignmentSnap("1", pos);
35
+ expect(result.snappedX).toBe(true);
36
+ expect(result.x).toBe(100);
37
+ });
38
+ it("snapToAlignment should return only x,y", () => {
39
+ const nodes = ref([node("1", 0, 0), node("2", 100, 100)]);
40
+ const a = useAlignment({ nodes, snapThreshold: 20 });
41
+ const out = a.snapToAlignment("1", { x: 105, y: 105 });
42
+ expect(out).toHaveProperty("x");
43
+ expect(out).toHaveProperty("y");
44
+ expect(Object.keys(out)).toHaveLength(2);
45
+ });
46
+ it("should return position when nodeId not found", () => {
47
+ const nodes = ref([node("1", 0, 0)]);
48
+ const a = useAlignment({ nodes });
49
+ const result = a.getAlignmentSnap("missing", { x: 50, y: 50 });
50
+ expect(result).toEqual({ x: 50, y: 50, snappedX: false, snappedY: false });
51
+ });
52
+ });
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ var _vitest = require("vitest");
4
+ var _vue = require("vue");
5
+ var _useEdges = require("../core/useEdges.cjs");
6
+ const node = id => ({
7
+ id,
8
+ type: "default",
9
+ position: {
10
+ x: 0,
11
+ y: 0
12
+ },
13
+ data: {}
14
+ });
15
+ const edge = (id, source, target) => ({
16
+ id,
17
+ source,
18
+ target,
19
+ type: "bezier"
20
+ });
21
+ (0, _vitest.describe)("flow/core/useEdges", () => {
22
+ (0, _vitest.it)("should add and remove edge", () => {
23
+ const edges = (0, _vue.ref)([]);
24
+ const nodes = (0, _vue.ref)([node("1"), node("2")]);
25
+ const e = (0, _useEdges.useEdges)({
26
+ edges,
27
+ nodes
28
+ });
29
+ e.addEdge(edge("e1", "1", "2"));
30
+ (0, _vitest.expect)(edges.value).toHaveLength(1);
31
+ (0, _vitest.expect)(e.getEdge("e1")).toBeDefined();
32
+ e.removeEdge("e1");
33
+ (0, _vitest.expect)(edges.value).toHaveLength(0);
34
+ });
35
+ (0, _vitest.it)("should not add duplicate connection", () => {
36
+ const edges = (0, _vue.ref)([edge("e1", "1", "2")]);
37
+ const nodes = (0, _vue.ref)([node("1"), node("2")]);
38
+ const e = (0, _useEdges.useEdges)({
39
+ edges,
40
+ nodes
41
+ });
42
+ e.addEdge(edge("e2", "1", "2"));
43
+ (0, _vitest.expect)(edges.value).toHaveLength(1);
44
+ });
45
+ (0, _vitest.it)("should respect isValidConnection", () => {
46
+ const edges = (0, _vue.ref)([]);
47
+ const nodes = (0, _vue.ref)([node("1"), node("2"), node("3")]);
48
+ const e = (0, _useEdges.useEdges)({
49
+ edges,
50
+ nodes,
51
+ isValidConnection: c => c.target !== "2"
52
+ });
53
+ e.addEdge(edge("e1", "1", "2"));
54
+ (0, _vitest.expect)(edges.value).toHaveLength(0);
55
+ e.addEdge(edge("e2", "1", "3"));
56
+ (0, _vitest.expect)(edges.value).toHaveLength(1);
57
+ });
58
+ (0, _vitest.it)("should update edge", () => {
59
+ const edges = (0, _vue.ref)([edge("e1", "1", "2")]);
60
+ const nodes = (0, _vue.ref)([node("1"), node("2")]);
61
+ const e = (0, _useEdges.useEdges)({
62
+ edges,
63
+ nodes
64
+ });
65
+ e.updateEdge("e1", {
66
+ label: "updated",
67
+ type: "straight"
68
+ });
69
+ (0, _vitest.expect)(edges.value[0].label).toBe("updated");
70
+ (0, _vitest.expect)(edges.value[0].type).toBe("straight");
71
+ });
72
+ (0, _vitest.it)("should select edge single and multi", () => {
73
+ const edges = (0, _vue.ref)([{
74
+ ...edge("e1", "1", "2"),
75
+ selected: true
76
+ }, {
77
+ ...edge("e2", "2", "3"),
78
+ selected: false
79
+ }]);
80
+ const nodes = (0, _vue.ref)([node("1"), node("2"), node("3")]);
81
+ const e = (0, _useEdges.useEdges)({
82
+ edges,
83
+ nodes
84
+ });
85
+ e.selectEdge("e2", true, false);
86
+ (0, _vitest.expect)(edges.value.find(x => x.id === "e1")?.selected).toBe(false);
87
+ (0, _vitest.expect)(edges.value.find(x => x.id === "e2")?.selected).toBe(true);
88
+ e.selectEdge("e1", true, true);
89
+ (0, _vitest.expect)(edges.value.filter(x => x.selected)).toHaveLength(2);
90
+ });
91
+ (0, _vitest.it)("should getEdgesForNode and getConnectedEdges", () => {
92
+ const edges = (0, _vue.ref)([edge("e1", "1", "2"), edge("e2", "2", "3"), edge("e3", "1", "3")]);
93
+ const nodes = (0, _vue.ref)([node("1"), node("2"), node("3")]);
94
+ const e = (0, _useEdges.useEdges)({
95
+ edges,
96
+ nodes
97
+ });
98
+ (0, _vitest.expect)(e.getEdgesForNode("1")).toHaveLength(2);
99
+ (0, _vitest.expect)(e.getConnectedEdges("2")).toHaveLength(2);
100
+ });
101
+ (0, _vitest.it)("should clearSelection and setEdges", () => {
102
+ const edges = (0, _vue.ref)([{
103
+ ...edge("e1", "1", "2"),
104
+ selected: true
105
+ }]);
106
+ const nodes = (0, _vue.ref)([node("1"), node("2")]);
107
+ const e = (0, _useEdges.useEdges)({
108
+ edges,
109
+ nodes
110
+ });
111
+ e.clearSelection();
112
+ (0, _vitest.expect)(edges.value[0].selected).toBeFalsy();
113
+ e.setEdges([edge("e2", "1", "2")]);
114
+ (0, _vitest.expect)(edges.value).toHaveLength(1);
115
+ (0, _vitest.expect)(edges.value[0].id).toBe("e2");
116
+ });
117
+ });
@@ -0,0 +1 @@
1
+ export {};