windmill-components 1.379.4 → 1.382.3

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 (199) hide show
  1. package/package/base.d.ts +1 -1
  2. package/package/base.js +1 -1
  3. package/package/components/ArgInput.svelte +33 -3
  4. package/package/components/DisplayResult.svelte +17 -5
  5. package/package/components/EditorBar.svelte +48 -38
  6. package/package/components/EditorBar.svelte.d.ts +2 -0
  7. package/package/components/ErrorOrRecoveryHandler.svelte +3 -2
  8. package/package/components/FlowBuilder.svelte +18 -12
  9. package/package/components/FlowBuilder.svelte.d.ts +3 -2
  10. package/package/components/FlowGraphViewer.svelte +6 -5
  11. package/package/components/FlowJobResult.svelte +4 -2
  12. package/package/components/FlowJobResult.svelte.d.ts +2 -0
  13. package/package/components/FlowStatusViewer.svelte +7 -1
  14. package/package/components/FlowStatusViewer.svelte.d.ts +3 -0
  15. package/package/components/FlowStatusViewerInner.svelte +29 -11
  16. package/package/components/FlowViewer.svelte +3 -1
  17. package/package/components/FlowViewer.svelte.d.ts +1 -0
  18. package/package/components/HighlightCode.svelte +2 -2
  19. package/package/components/ModulePreviewForm.svelte +1 -1
  20. package/package/components/ObjectResourceInput.svelte +7 -2
  21. package/package/components/ObjectResourceInput.svelte.d.ts +2 -0
  22. package/package/components/ResourcePicker.svelte +60 -48
  23. package/package/components/ScriptBuilder.svelte +42 -36
  24. package/package/components/ScriptBuilder.svelte.d.ts +2 -0
  25. package/package/components/ScriptEditor.svelte +3 -1
  26. package/package/components/ScriptEditor.svelte.d.ts +2 -0
  27. package/package/components/ScriptVersionHistory.svelte +63 -7
  28. package/package/components/apps/components/display/AppText.svelte +8 -3
  29. package/package/components/apps/components/display/dbtable/DbExplorerCount.svelte +3 -2
  30. package/package/components/apps/components/display/table/AppAggridExplorerTable.svelte +22 -5
  31. package/package/components/apps/components/display/table/AppAggridTable.svelte +14 -5
  32. package/package/components/apps/components/display/table/AppAggridTableActions.svelte +23 -8
  33. package/package/components/apps/components/display/table/AppAggridTableActions.svelte.d.ts +5 -3
  34. package/package/components/apps/components/display/table/utils.js +8 -7
  35. package/package/components/apps/components/helpers/RunnableComponent.svelte +13 -1
  36. package/package/components/apps/components/helpers/eval.js +31 -25
  37. package/package/components/apps/components/inputs/AppSelect.svelte +45 -29
  38. package/package/components/apps/editor/AppEditorHeader.svelte +1 -0
  39. package/package/components/apps/editor/AppReportsDrawer.svelte +4 -3
  40. package/package/components/apps/editor/component/components.d.ts +7 -1
  41. package/package/components/apps/editor/component/components.js +6 -0
  42. package/package/components/apps/editor/settingsPanel/DecisionTreeGraphEditor.svelte +0 -1
  43. package/package/components/apps/editor/settingsPanel/DecisionTreeGraphHeader.svelte +55 -45
  44. package/package/components/apps/editor/settingsPanel/DecisionTreeGraphHeader.svelte.d.ts +7 -9
  45. package/package/components/apps/editor/settingsPanel/DecisionTreeGraphNode.svelte +66 -59
  46. package/package/components/apps/editor/settingsPanel/DecisionTreeGraphNode.svelte.d.ts +9 -11
  47. package/package/components/apps/editor/settingsPanel/decisionTree/DecisionTreePreview.svelte +213 -254
  48. package/package/components/apps/editor/settingsPanel/decisionTree/DecisionTreePreview.svelte.d.ts +0 -1
  49. package/package/components/apps/editor/settingsPanel/decisionTree/nodeHelpers.d.ts +1 -1
  50. package/package/components/apps/editor/settingsPanel/decisionTree/nodeHelpers.js +2 -6
  51. package/package/components/custom_ui.d.ts +35 -1
  52. package/package/components/details/DetailPageDetailPanel.svelte +9 -1
  53. package/package/components/details/DetailPageDetailPanel.svelte.d.ts +2 -1
  54. package/package/components/details/DetailPageLayout.svelte +2 -0
  55. package/package/components/details/DetailPageLayout.svelte.d.ts +3 -0
  56. package/package/components/details/EmailTriggerPanel.svelte +128 -0
  57. package/package/components/details/EmailTriggerPanel.svelte.d.ts +20 -0
  58. package/package/components/details/WebhooksPanel.svelte +10 -71
  59. package/package/components/flows/FlowHistory.svelte +1 -0
  60. package/package/components/flows/content/FlowInputs.svelte +0 -1
  61. package/package/components/flows/content/FlowModuleComponent.svelte +8 -2
  62. package/package/components/flows/content/FlowModuleEarlyStop.svelte +193 -66
  63. package/package/components/flows/content/FlowModuleHeader.svelte +1 -1
  64. package/package/components/flows/content/FlowModuleScript.svelte +33 -3
  65. package/package/components/flows/content/FlowModuleScript.svelte.d.ts +2 -0
  66. package/package/components/flows/content/FlowModuleSuspend.svelte +15 -0
  67. package/package/components/flows/content/FlowSettings.svelte +26 -15
  68. package/package/components/flows/flowExplorer.js +3 -0
  69. package/package/components/flows/flowInfers.js +1 -1
  70. package/package/components/flows/map/FlowJobsMenu.svelte +39 -44
  71. package/package/components/flows/map/FlowModuleSchemaItem.svelte +1 -2
  72. package/package/components/flows/map/FlowModuleSchemaMap.svelte +4 -3
  73. package/package/components/flows/map/InsertModuleButton.svelte +16 -9
  74. package/package/components/flows/map/MapItem.svelte +4 -98
  75. package/package/components/flows/map/MapItem.svelte.d.ts +0 -5
  76. package/package/components/flows/map/VirtualItem.svelte +6 -159
  77. package/package/components/flows/map/VirtualItem.svelte.d.ts +0 -15
  78. package/package/components/flows/propPicker/PropPickerWrapper.svelte +2 -0
  79. package/package/components/flows/propPicker/PropPickerWrapper.svelte.d.ts +1 -0
  80. package/package/components/flows/types.d.ts +2 -0
  81. package/package/components/graph/FlowGraphV2.svelte +256 -0
  82. package/package/components/graph/{FlowGraph.svelte.d.ts → FlowGraphV2.svelte.d.ts} +8 -8
  83. package/package/components/graph/graphBuilder.d.ts +15 -0
  84. package/package/components/graph/graphBuilder.js +337 -0
  85. package/package/components/graph/index.d.ts +0 -1
  86. package/package/components/graph/index.js +0 -1
  87. package/package/components/graph/model.d.ts +4 -8
  88. package/package/components/graph/renderers/edges/BaseEdge.svelte +109 -0
  89. package/package/components/graph/renderers/edges/BaseEdge.svelte.d.ts +35 -0
  90. package/package/components/graph/renderers/edges/DataflowEdge.svelte +37 -0
  91. package/package/components/graph/renderers/edges/DataflowEdge.svelte.d.ts +29 -0
  92. package/package/components/graph/renderers/edges/EmptyEdge.svelte +22 -0
  93. package/package/components/graph/renderers/edges/EmptyEdge.svelte.d.ts +23 -0
  94. package/package/components/graph/renderers/nodes/BranchAllStart.svelte +44 -0
  95. package/package/components/graph/renderers/nodes/BranchAllStart.svelte.d.ts +29 -0
  96. package/package/components/graph/renderers/nodes/BranchOneStart.svelte +41 -0
  97. package/package/components/graph/renderers/nodes/BranchOneStart.svelte.d.ts +29 -0
  98. package/package/components/graph/renderers/nodes/ForLoopEndNode.svelte +19 -0
  99. package/package/components/graph/renderers/nodes/ForLoopEndNode.svelte.d.ts +24 -0
  100. package/package/components/graph/renderers/nodes/ForLoopStartNode.svelte +20 -0
  101. package/package/components/graph/renderers/nodes/ForLoopStartNode.svelte.d.ts +25 -0
  102. package/package/components/graph/renderers/nodes/InputNode.svelte +74 -0
  103. package/package/components/graph/renderers/nodes/InputNode.svelte.d.ts +23 -0
  104. package/package/components/graph/renderers/nodes/ModuleNode.svelte +71 -0
  105. package/package/components/graph/renderers/nodes/ModuleNode.svelte.d.ts +41 -0
  106. package/package/components/graph/renderers/nodes/NoBranchNode.svelte +20 -0
  107. package/package/components/graph/renderers/nodes/NoBranchNode.svelte.d.ts +27 -0
  108. package/package/components/graph/renderers/nodes/NodeWrapper.svelte +21 -0
  109. package/package/components/graph/renderers/nodes/NodeWrapper.svelte.d.ts +22 -0
  110. package/package/components/graph/renderers/nodes/ResultNode.svelte +24 -0
  111. package/package/components/graph/renderers/nodes/ResultNode.svelte.d.ts +22 -0
  112. package/package/components/graph/renderers/nodes/branchAllEndNode.svelte +19 -0
  113. package/package/components/graph/renderers/nodes/branchAllEndNode.svelte.d.ts +26 -0
  114. package/package/components/graph/renderers/nodes/branchOneEndNode.svelte +19 -0
  115. package/package/components/graph/renderers/nodes/branchOneEndNode.svelte.d.ts +24 -0
  116. package/package/components/graph/renderers/utils.d.ts +8 -0
  117. package/package/components/graph/renderers/utils.js +26 -0
  118. package/package/components/graph/util.d.ts +1 -2
  119. package/package/components/graph/util.js +2 -8
  120. package/package/components/propertyPicker/PropPickerResult.svelte +6 -1
  121. package/package/components/propertyPicker/PropPickerResult.svelte.d.ts +1 -0
  122. package/package/components/runs/RunsFilter.svelte +15 -17
  123. package/package/components/sidebar/changelogs.js +5 -0
  124. package/package/gen/core/OpenAPI.js +1 -1
  125. package/package/gen/schemas.gen.d.ts +3 -0
  126. package/package/gen/schemas.gen.js +3 -0
  127. package/package/gen/services.gen.d.ts +22 -3
  128. package/package/gen/services.gen.js +38 -2
  129. package/package/gen/types.gen.d.ts +69 -6
  130. package/package/hub.d.ts +11 -0
  131. package/package/hub.js +2 -0
  132. package/package/hubPaths.json +9 -0
  133. package/package/init_scripts/python_failure_module.d.ts +1 -1
  134. package/package/init_scripts/python_failure_module.js +4 -3
  135. package/package/script_helpers.d.ts +2 -2
  136. package/package/script_helpers.js +11 -9
  137. package/package.json +2 -1
  138. package/package/components/graph/FlowGraph.svelte +0 -614
  139. package/package/components/graph/svelvet/LICENSE +0 -21
  140. package/package/components/graph/svelvet/container/README.md +0 -7
  141. package/package/components/graph/svelvet/container/controllers/middleware.d.ts +0 -11
  142. package/package/components/graph/svelvet/container/controllers/middleware.js +0 -87
  143. package/package/components/graph/svelvet/container/models/index.d.ts +0 -0
  144. package/package/components/graph/svelvet/container/models/index.js +0 -1
  145. package/package/components/graph/svelvet/container/views/GraphView.svelte +0 -262
  146. package/package/components/graph/svelvet/container/views/GraphView.svelte.d.ts +0 -26
  147. package/package/components/graph/svelvet/container/views/Svelvet.svelte +0 -121
  148. package/package/components/graph/svelvet/container/views/Svelvet.svelte.d.ts +0 -36
  149. package/package/components/graph/svelvet/customCss/controllers/getCss.d.ts +0 -2
  150. package/package/components/graph/svelvet/customCss/controllers/getCss.js +0 -46
  151. package/package/components/graph/svelvet/d3/controllers/d3.d.ts +0 -5
  152. package/package/components/graph/svelvet/d3/controllers/d3.js +0 -59
  153. package/package/components/graph/svelvet/edges/controllers/anchorCbDev.d.ts +0 -4
  154. package/package/components/graph/svelvet/edges/controllers/anchorCbDev.js +0 -92
  155. package/package/components/graph/svelvet/edges/controllers/anchorCbUser.d.ts +0 -57
  156. package/package/components/graph/svelvet/edges/controllers/anchorCbUser.js +0 -73
  157. package/package/components/graph/svelvet/edges/controllers/util.d.ts +0 -37
  158. package/package/components/graph/svelvet/edges/controllers/util.js +0 -71
  159. package/package/components/graph/svelvet/edges/models/Anchor.d.ts +0 -48
  160. package/package/components/graph/svelvet/edges/models/Anchor.js +0 -122
  161. package/package/components/graph/svelvet/edges/models/Edge.d.ts +0 -48
  162. package/package/components/graph/svelvet/edges/models/Edge.js +0 -109
  163. package/package/components/graph/svelvet/edges/types/types.d.ts +0 -18
  164. package/package/components/graph/svelvet/edges/types/types.js +0 -1
  165. package/package/components/graph/svelvet/edges/views/Edges/BaseEdge.svelte +0 -104
  166. package/package/components/graph/svelvet/edges/views/Edges/BaseEdge.svelte.d.ts +0 -18
  167. package/package/components/graph/svelvet/edges/views/Edges/EdgeText.svelte +0 -42
  168. package/package/components/graph/svelvet/edges/views/Edges/EdgeText.svelte.d.ts +0 -17
  169. package/package/components/graph/svelvet/edges/views/Edges/SimpleBezierEdge.svelte +0 -151
  170. package/package/components/graph/svelvet/edges/views/Edges/SimpleBezierEdge.svelte.d.ts +0 -17
  171. package/package/components/graph/svelvet/edges/views/Edges/SmoothStepEdge.svelte +0 -157
  172. package/package/components/graph/svelvet/edges/views/Edges/SmoothStepEdge.svelte.d.ts +0 -60
  173. package/package/components/graph/svelvet/edges/views/Edges/StepEdge.svelte +0 -8
  174. package/package/components/graph/svelvet/edges/views/Edges/StepEdge.svelte.d.ts +0 -25
  175. package/package/components/graph/svelvet/edges/views/Edges/types.d.ts +0 -52
  176. package/package/components/graph/svelvet/edges/views/Edges/types.js +0 -1
  177. package/package/components/graph/svelvet/edges/views/Edges/utils.d.ts +0 -33
  178. package/package/components/graph/svelvet/edges/views/Edges/utils.js +0 -31
  179. package/package/components/graph/svelvet/nodes/controllers/util.d.ts +0 -9
  180. package/package/components/graph/svelvet/nodes/controllers/util.js +0 -13
  181. package/package/components/graph/svelvet/nodes/models/Node.d.ts +0 -74
  182. package/package/components/graph/svelvet/nodes/models/Node.js +0 -156
  183. package/package/components/graph/svelvet/nodes/views/Node.svelte +0 -84
  184. package/package/components/graph/svelvet/nodes/views/Node.svelte.d.ts +0 -21
  185. package/package/components/graph/svelvet/store/controllers/storeApi.d.ts +0 -25
  186. package/package/components/graph/svelvet/store/controllers/storeApi.js +0 -91
  187. package/package/components/graph/svelvet/store/controllers/userApi.d.ts +0 -3
  188. package/package/components/graph/svelvet/store/controllers/userApi.js +0 -18
  189. package/package/components/graph/svelvet/store/controllers/util.d.ts +0 -24
  190. package/package/components/graph/svelvet/store/controllers/util.js +0 -148
  191. package/package/components/graph/svelvet/store/models/store.d.ts +0 -13
  192. package/package/components/graph/svelvet/store/models/store.js +0 -12
  193. package/package/components/graph/svelvet/store/types/types.d.ts +0 -127
  194. package/package/components/graph/svelvet/store/types/types.js +0 -1
  195. package/package/components/graph/svelvet/types/README.md +0 -3
  196. package/package/components/graph/svelvet/types/index.d.ts +0 -2
  197. package/package/components/graph/svelvet/types/index.js +0 -1
  198. package/package/components/graph/svelvet/types/types.d.ts +0 -50
  199. package/package/components/graph/svelvet/types/types.js +0 -18
@@ -1,92 +0,0 @@
1
- import { rightCb, leftCb, topCb, bottomCb } from './anchorCbUser'; // these are callbacks used to calculate anchor position relative to node
2
- import { getAnchors } from './util';
3
- import { getNodeById } from '../../nodes/controllers/util';
4
- export function fixedCbCreator(store, edgeId, anchorId, userNodeId, positionCb // positionCb should be a function that takes 4 arguments (x,y,width,height) and returns a 3-array [x,y,angle] that represents the x,y position of the anchor as well as it's angle with respect to it's node.
5
- ) {
6
- const rn = fixedCb;
7
- rn.type = 'fixed';
8
- return rn;
9
- function fixedCb() {
10
- // get the two anchors
11
- const anchors = getAnchors(store, { edgeId: edgeId });
12
- if (anchors.length !== 2)
13
- throw `there should be two anchors per edge, have: ${anchors.length}`;
14
- let [anchorSelf, anchorOther] = anchors;
15
- if (anchorSelf.id !== anchorId)
16
- [anchorSelf, anchorOther] = [anchorOther, anchorSelf];
17
- const node = getNodeById(store, userNodeId);
18
- const { positionX, positionY, width, height } = node;
19
- const [x, y, angle] = positionCb(positionX, positionY, width, height);
20
- anchorSelf.positionX = x;
21
- anchorSelf.positionY = y;
22
- anchorSelf.angle = angle;
23
- // update the other anchor if it is a dynamic anchor
24
- // Note dyanamic anchor callbacks have a check that prevents an infinite loop
25
- if (anchorOther.callback.type === 'dynamic')
26
- anchorOther.callback();
27
- }
28
- }
29
- export function dynamicCbCreator(store, edgeId, anchorId) {
30
- const rn = dynamicCb;
31
- rn.type = 'dynamic';
32
- return rn;
33
- function dynamicCb() {
34
- // get the two anchors
35
- const anchors = getAnchors(store, { edgeId: edgeId });
36
- if (anchors.length !== 2)
37
- throw `there should be two anchors per edge, have: ${anchors.length}`;
38
- let [anchorSelf, anchorOther] = anchors;
39
- if (anchorSelf.id !== anchorId)
40
- [anchorSelf, anchorOther] = [anchorOther, anchorSelf];
41
- // get the two nodes
42
- const nodeSelf = getNodeById(store, anchorSelf.nodeId);
43
- const nodeOther = getNodeById(store, anchorOther.nodeId);
44
- // get the midpoints
45
- const [xSelf, ySelf, xOther, yOther] = [
46
- nodeSelf.positionX + nodeSelf.width / 2,
47
- nodeSelf.positionY + nodeSelf.height / 2,
48
- nodeOther.positionX + nodeOther.width / 2,
49
- nodeOther.positionY + nodeOther.height / 2
50
- ];
51
- // record angle for later. We use this so we don't have an infinite loop
52
- let prevAngle = anchorSelf.angle;
53
- // calculate the slope
54
- const slope = (ySelf - yOther) / (xSelf - xOther);
55
- // slope<1 means -45 to 45 degrees so left/right anchors
56
- if (Math.abs(slope) < 1) {
57
- // self node is on the left, other node is on the right
58
- if (nodeSelf.positionX < nodeOther.positionX) {
59
- const [selfX, selfY] = rightCb(nodeSelf.positionX, nodeSelf.positionY, nodeSelf.width, nodeSelf.height);
60
- leftCb(nodeOther.positionX, nodeOther.positionY, nodeOther.width, nodeOther.height);
61
- anchorSelf.setPosition(selfX, selfY);
62
- anchorSelf.angle = 0; // if the self node is on the left, the anchor should have orientation of 0 degrees on the unit circle
63
- }
64
- else {
65
- // in this case, the self node is on the right and the other node is on the left
66
- const [selfX, selfY] = leftCb(nodeSelf.positionX, nodeSelf.positionY, nodeSelf.width, nodeSelf.height);
67
- rightCb(nodeOther.positionX, nodeOther.positionY, nodeOther.width, nodeOther.height);
68
- anchorSelf.setPosition(selfX, selfY);
69
- anchorSelf.angle = 180;
70
- }
71
- }
72
- else {
73
- if (nodeSelf.positionY < nodeOther.positionY) {
74
- // here the self node is above the other node
75
- const [selfX, selfY] = bottomCb(nodeSelf.positionX, nodeSelf.positionY, nodeSelf.width, nodeSelf.height);
76
- topCb(nodeOther.positionX, nodeOther.positionY, nodeOther.width, nodeOther.height);
77
- anchorSelf.setPosition(selfX, selfY);
78
- anchorSelf.angle = 270;
79
- }
80
- else {
81
- const [selfX, selfY] = topCb(nodeSelf.positionX, nodeSelf.positionY, nodeSelf.width, nodeSelf.height);
82
- bottomCb(nodeOther.positionX, nodeOther.positionY, nodeOther.width, nodeOther.height);
83
- anchorSelf.setPosition(selfX, selfY);
84
- anchorSelf.angle = 90;
85
- }
86
- }
87
- // if the anchor changed position, then do operation for other anchor
88
- // otherwise, don't do anything. This check is so we don't have an infinite loop
89
- if (prevAngle !== anchorSelf.angle)
90
- anchorOther.callback();
91
- }
92
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * These are callbacks used to define anchor positions relative to the node they are attached to.
3
- * These may be provided to developers as examples of how to write their own custom callbacks for adjustable anchors
4
- * It calculates the position of an anchor (x,y) coordinates given a node parameterized by (x,y,width, height)
5
- */
6
- /**
7
- * @function rightCb - This is a callback function to define the anchor position on the node to be on the right side of the node.
8
- * @param xNode - positionX of the attached node
9
- * @param yNode - positionY of the attached node
10
- * @param widthNode - width of the attached node
11
- * @param heightNode - height of the attached node
12
- * @returns [xAnchor, yAnchor, 0]
13
- * xAnchor - positionX for the anchor
14
- * yAnchor - positionY for the anchor
15
- * 0 - this is angle of the anchor with respect to the node. The right anchor should fall at 0 degrees on the unit circle.
16
- * @export rightCb
17
- */
18
- export declare const rightCb: (xNode: number, yNode: number, widthNode: number, heightNode: number) => number[];
19
- /**
20
- * @function leftCb - This is a callback function to define the anchor position on the node to be on the left side of the node.
21
- * @param xNode - positionX of the attached node
22
- * @param yNode - positionY of the attached node
23
- * @param widthNode - width of the attached node
24
- * @param heightNode - height of the attached node
25
- * @returns [xAnchor, yAnchor, 180]
26
- * xAnchor - positionX for the anchor
27
- * yAnchor - positionY for the anchor
28
- * 180 - this is angle of the anchor with respect to the node. The left anchor should fall at 180 degrees on the unit circle.
29
- * @export leftCb
30
- */
31
- export declare const leftCb: (xNode: number, yNode: number, widthNode: number, heightNode: number) => number[];
32
- /**
33
- * @function topCb - This is a callback function to define the anchor position on the node to be on the top of the node.
34
- * @param xNode - positionX of the attached node
35
- * @param yNode - positionY of the attached node
36
- * @param widthNode - width of the attached node
37
- * @param heightNode - height of the attached node
38
- * @returns [xAnchor, yAnchor, 90]
39
- * xAnchor - positionX for the anchor
40
- * yAnchor - positionY for the anchor
41
- * 90 - this is angle of the anchor with respect to the node. The top anchor should fall at 90 degrees on the unit circle.
42
- * @export topCb
43
- */
44
- export declare const topCb: (xNode: number, yNode: number, widthNode: number, heightNode: number) => number[];
45
- /**
46
- * @function bottomCb - This is a callback function to define the anchor position on the node to be on the bottom of the node.
47
- * @param xNode - positionX of the attached node
48
- * @param yNode - positionY of the attached node
49
- * @param widthNode - width of the attached node
50
- * @param heightNode - height of the attached node
51
- * @returns - [xAnchor, yAnchor, 90]
52
- * xAnchor - positionX for the anchor
53
- * yAnchor - positionY for the anchor
54
- * 270 - this is angle of the anchor with respect to the node. The bottom anchor should fall at 270 degrees on the unit circle.
55
- * @export bottomCb
56
- */
57
- export declare const bottomCb: (xNode: number, yNode: number, widthNode: number, heightNode: number) => number[];
@@ -1,73 +0,0 @@
1
- /**
2
- * These are callbacks used to define anchor positions relative to the node they are attached to.
3
- * These may be provided to developers as examples of how to write their own custom callbacks for adjustable anchors
4
- * It calculates the position of an anchor (x,y) coordinates given a node parameterized by (x,y,width, height)
5
- */
6
- /**
7
- * @function rightCb - This is a callback function to define the anchor position on the node to be on the right side of the node.
8
- * @param xNode - positionX of the attached node
9
- * @param yNode - positionY of the attached node
10
- * @param widthNode - width of the attached node
11
- * @param heightNode - height of the attached node
12
- * @returns [xAnchor, yAnchor, 0]
13
- * xAnchor - positionX for the anchor
14
- * yAnchor - positionY for the anchor
15
- * 0 - this is angle of the anchor with respect to the node. The right anchor should fall at 0 degrees on the unit circle.
16
- * @export rightCb
17
- */
18
- export const rightCb = (xNode, yNode, widthNode, heightNode) => {
19
- const xAnchor = xNode + widthNode;
20
- const yAnchor = yNode + heightNode / 2;
21
- return [xAnchor, yAnchor, 0];
22
- };
23
- /**
24
- * @function leftCb - This is a callback function to define the anchor position on the node to be on the left side of the node.
25
- * @param xNode - positionX of the attached node
26
- * @param yNode - positionY of the attached node
27
- * @param widthNode - width of the attached node
28
- * @param heightNode - height of the attached node
29
- * @returns [xAnchor, yAnchor, 180]
30
- * xAnchor - positionX for the anchor
31
- * yAnchor - positionY for the anchor
32
- * 180 - this is angle of the anchor with respect to the node. The left anchor should fall at 180 degrees on the unit circle.
33
- * @export leftCb
34
- */
35
- export const leftCb = (xNode, yNode, widthNode, heightNode) => {
36
- const xAnchor = xNode;
37
- const yAnchor = yNode + heightNode / 2;
38
- return [xAnchor, yAnchor, 180];
39
- };
40
- /**
41
- * @function topCb - This is a callback function to define the anchor position on the node to be on the top of the node.
42
- * @param xNode - positionX of the attached node
43
- * @param yNode - positionY of the attached node
44
- * @param widthNode - width of the attached node
45
- * @param heightNode - height of the attached node
46
- * @returns [xAnchor, yAnchor, 90]
47
- * xAnchor - positionX for the anchor
48
- * yAnchor - positionY for the anchor
49
- * 90 - this is angle of the anchor with respect to the node. The top anchor should fall at 90 degrees on the unit circle.
50
- * @export topCb
51
- */
52
- export const topCb = (xNode, yNode, widthNode, heightNode) => {
53
- const xAnchor = xNode + widthNode / 2;
54
- const yAnchor = yNode;
55
- return [xAnchor, yAnchor, 90];
56
- };
57
- /**
58
- * @function bottomCb - This is a callback function to define the anchor position on the node to be on the bottom of the node.
59
- * @param xNode - positionX of the attached node
60
- * @param yNode - positionY of the attached node
61
- * @param widthNode - width of the attached node
62
- * @param heightNode - height of the attached node
63
- * @returns - [xAnchor, yAnchor, 90]
64
- * xAnchor - positionX for the anchor
65
- * yAnchor - positionY for the anchor
66
- * 270 - this is angle of the anchor with respect to the node. The bottom anchor should fall at 270 degrees on the unit circle.
67
- * @export bottomCb
68
- */
69
- export const bottomCb = (xNode, yNode, widthNode, heightNode) => {
70
- const xAnchor = xNode + widthNode / 2;
71
- const yAnchor = yNode + heightNode;
72
- return [xAnchor, yAnchor, 270];
73
- };
@@ -1,37 +0,0 @@
1
- import type { StoreType } from '../../store/types/types';
2
- import type { AnchorType } from '../types/types';
3
- /**
4
- * Finds all Anchors that matches the conditions specified in the filter parameter from a Svelvet store and returns these Anchors in an array.
5
- *
6
- * @param store The Svelvet store containing the state of a Svelvet component
7
- * @param filter An object to specify conditions. Example: if filter = \{ sourceOrTarget: 'source', positionX: 35 \} then we will return all anchors with sourceOrTarget = source AND poxitionX = 35
8
- * @returns An array of Anchors that matches the conditions specified in the filter parameter
9
- */
10
- export declare function getAnchors(store: StoreType, filter?: {
11
- [key: string]: any;
12
- }): AnchorType[];
13
- /**
14
- * Gets one anchor (source anchor or target anchor) from a given edge
15
- *
16
- * @param store The Svelvet store containing the state of the Svelvet component
17
- * @param edgeId The id of a given edge
18
- * @param sourceOrTarget A string of 'source' or 'target' to specify which anchor the function should return
19
- * @returns The source or target Anchor object of a given edge
20
- */
21
- export declare function getAnchorFromEdge(store: StoreType, edgeId: string, sourceOrTarget: 'source' | 'target'): AnchorType;
22
- /**
23
- * getEdgeById will look for the targeted Edge that has the same id provided in the Svelvet component store.
24
- *
25
- * @param store The Svelvet store containing the state of a Svelvet component
26
- * @param id The id of the targeted Node
27
- * @returns The targeted Edge object in store.edgesStore
28
- */
29
- export declare function getEdgeById(store: StoreType, id: string): import("../../store/types/types").EdgeType;
30
- /**
31
- * getAnchorById will look for the targeted Anchor that has the same id in the Svelvet component store.
32
- *
33
- * @param store The Svelvet store containing the state of a Svelvet component
34
- * @param id The id of the targeted Anchor
35
- * @returns The target Anchor object in store.anchorsStore
36
- */
37
- export declare function getAnchorById(store: StoreType, id: string): AnchorType;
@@ -1,71 +0,0 @@
1
- import { get } from 'svelte/store';
2
- /**
3
- * Finds all Anchors that matches the conditions specified in the filter parameter from a Svelvet store and returns these Anchors in an array.
4
- *
5
- * @param store The Svelvet store containing the state of a Svelvet component
6
- * @param filter An object to specify conditions. Example: if filter = \{ sourceOrTarget: 'source', positionX: 35 \} then we will return all anchors with sourceOrTarget = source AND poxitionX = 35
7
- * @returns An array of Anchors that matches the conditions specified in the filter parameter
8
- */
9
- export function getAnchors(store, filter) {
10
- let anchors = Object.values(get(store.anchorsStore));
11
- // filter the array of anchors for elements that match filter
12
- // Example: if filter = {sourceOrTarget: 'source', positionX: 35} then we will
13
- //return all anchors with sourceOrTarget = source AND poxitionX = 35
14
- if (filter !== undefined) {
15
- anchors = anchors.filter((anchor) => {
16
- for (let filterKey in filter) {
17
- const filterValue = filter[filterKey];
18
- if (anchor[filterKey] !== filterValue)
19
- return false;
20
- }
21
- return true;
22
- });
23
- }
24
- // return list of anchors
25
- return anchors;
26
- }
27
- /**
28
- * Gets one anchor (source anchor or target anchor) from a given edge
29
- *
30
- * @param store The Svelvet store containing the state of the Svelvet component
31
- * @param edgeId The id of a given edge
32
- * @param sourceOrTarget A string of 'source' or 'target' to specify which anchor the function should return
33
- * @returns The source or target Anchor object of a given edge
34
- */
35
- export function getAnchorFromEdge(store, edgeId, sourceOrTarget) {
36
- getEdgeById(store, edgeId);
37
- const anchors = getAnchors(store, { edgeId: edgeId });
38
- if (anchors.length !== 2)
39
- throw `there should be two anchors for a given edge, there are ${anchors.length}`;
40
- // there should be one source anchor and one target anchor. Return the source anchor
41
- const anchor = anchors.filter((anchor) => anchor.sourceOrTarget === sourceOrTarget);
42
- if (anchor.length !== 1)
43
- throw `there should only be one source/target anchor`;
44
- return anchor[0];
45
- }
46
- /**
47
- * getEdgeById will look for the targeted Edge that has the same id provided in the Svelvet component store.
48
- *
49
- * @param store The Svelvet store containing the state of a Svelvet component
50
- * @param id The id of the targeted Node
51
- * @returns The targeted Edge object in store.edgesStore
52
- */
53
- export function getEdgeById(store, id) {
54
- const edgesStore = get(store.edgesStore);
55
- const edge = edgesStore[id];
56
- if (edge === undefined)
57
- throw 'edge not found';
58
- return edge;
59
- }
60
- /**
61
- * getAnchorById will look for the targeted Anchor that has the same id in the Svelvet component store.
62
- *
63
- * @param store The Svelvet store containing the state of a Svelvet component
64
- * @param id The id of the targeted Anchor
65
- * @returns The target Anchor object in store.anchorsStore
66
- */
67
- export function getAnchorById(store, id) {
68
- const anchorsStore = get(store.anchorsStore);
69
- const anchor = anchorsStore[id];
70
- return anchor;
71
- }
@@ -1,48 +0,0 @@
1
- /**
2
- * This is where we create, update the Anchor store.
3
- */
4
- import type { AnchorCbType, AnchorType } from '../../edges/types/types';
5
- /** Class representing an Anchor that implements Anchortype.
6
- * @param {string} id The id of the Anchor
7
- * @param {string} nodeId The id of the Node which the instantiated Anchor will be attached to
8
- * @param {string} edgeId The id of the Edge which connects to the instantiated Anchor
9
- * @param {'source' | 'target'} sourceOrTarget Specify the Anchor is a source or target
10
- * @param {number} positionX The 'X' coordinate of the Anchor
11
- * @param {number} positionY The 'Y' coordinate of the Anchor
12
- * @param {function} callback The callback function that will determine the position of this Anchor
13
- * @param {string} canvasId The canvasId of the Svelvet component that will hold this Anchor
14
- * @param { number } angle This is the orientation of the anchor and is used to make sure bezier/step curves are rendered perpendicular to the node. Angles are defined along the unit circle. EX: 0 = right side of node, 180 = left side of node.
15
- */
16
- export declare class Anchor implements AnchorType {
17
- id: string;
18
- nodeId: string;
19
- edgeId: string;
20
- sourceOrTarget: 'source' | 'target';
21
- positionX: number;
22
- positionY: number;
23
- callback: AnchorCbType;
24
- canvasId: string;
25
- angle: 0 | 90 | 180 | 270;
26
- constructor(id: string, nodeId: string, edgeId: string, sourceOrTarget: 'source' | 'target', positionX: number, positionY: number, callback: AnchorCbType, canvasId: string, angle: 0 | 90 | 180 | 270);
27
- getOtherAnchorId(): string;
28
- /**
29
- * setPositionFromNode will invoke the user-defined callback to calculate the position of the Anchor, set the position of the Anchor in the anchorsStore, and also update the Edge position accordingly.
30
- */
31
- setPositionFromNode(): void;
32
- /**
33
- * updateEdges will update the edgesStore based on Anchor's change.
34
- */
35
- updateEdges(): void;
36
- /**
37
- * setPosition will update the positionX and positionY of the Anchor and also cascade changes to related Edge.
38
- * @param x The X coordinate of the new position for the Anchor
39
- * @param y The Y coordinate of the new position for the Anchor
40
- */
41
- setPosition(x: number, y: number): void;
42
- /**
43
- * Anchor.setPositionFromMovement works similarly to Anchor.setPosition. But setPosition is more powerful and we recommend using setPosition whenever possible and in the future, setPositionFromMovement can be removed.
44
- * @param movementX The mouse movement value on the X-axis
45
- * @param movementY The mouse movement value on the Y-axis
46
- */
47
- setPositionFromMovement(movementX: number, movementY: number): void;
48
- }
@@ -1,122 +0,0 @@
1
- /**
2
- * This is where we create, update the Anchor store.
3
- */
4
- import { stores } from '../../store/models/store';
5
- import { getAnchors } from '../controllers/util';
6
- /** Class representing an Anchor that implements Anchortype.
7
- * @param {string} id The id of the Anchor
8
- * @param {string} nodeId The id of the Node which the instantiated Anchor will be attached to
9
- * @param {string} edgeId The id of the Edge which connects to the instantiated Anchor
10
- * @param {'source' | 'target'} sourceOrTarget Specify the Anchor is a source or target
11
- * @param {number} positionX The 'X' coordinate of the Anchor
12
- * @param {number} positionY The 'Y' coordinate of the Anchor
13
- * @param {function} callback The callback function that will determine the position of this Anchor
14
- * @param {string} canvasId The canvasId of the Svelvet component that will hold this Anchor
15
- * @param { number } angle This is the orientation of the anchor and is used to make sure bezier/step curves are rendered perpendicular to the node. Angles are defined along the unit circle. EX: 0 = right side of node, 180 = left side of node.
16
- */
17
- export class Anchor {
18
- id;
19
- nodeId;
20
- edgeId;
21
- sourceOrTarget;
22
- positionX;
23
- positionY;
24
- callback;
25
- canvasId;
26
- angle;
27
- constructor(id, nodeId, edgeId, sourceOrTarget, positionX, positionY, callback, canvasId, angle) {
28
- this.id = id;
29
- this.nodeId = nodeId;
30
- this.edgeId = edgeId;
31
- this.sourceOrTarget = sourceOrTarget;
32
- this.positionX = positionX;
33
- this.positionY = positionY;
34
- this.callback = callback;
35
- this.canvasId = canvasId;
36
- this.angle = angle;
37
- }
38
- getOtherAnchorId() {
39
- const store = stores[this.canvasId];
40
- const anchors = getAnchors(store, { edgeId: this.edgeId });
41
- if (anchors.length !== 2)
42
- throw 'something is wrong, every anchor should have exactly one other associated anchor';
43
- const anchor = anchors.filter((anchor) => anchor.id !== this.id)[0];
44
- return anchor.id;
45
- }
46
- /**
47
- * setPositionFromNode will invoke the user-defined callback to calculate the position of the Anchor, set the position of the Anchor in the anchorsStore, and also update the Edge position accordingly.
48
- */
49
- setPositionFromNode() {
50
- // calculate the new position of the anchor using user-defined callback
51
- this.callback();
52
- const { edgesStore } = stores[this.canvasId];
53
- // update edges
54
- edgesStore.update((edges) => {
55
- const edge = edges[this.edgeId];
56
- if (this.sourceOrTarget === 'source') {
57
- edge.sourceX = this.positionX;
58
- edge.sourceY = this.positionY;
59
- }
60
- else {
61
- edge.targetX = this.positionX;
62
- edge.targetY = this.positionY;
63
- }
64
- return { ...edges };
65
- });
66
- }
67
- /**
68
- * updateEdges will update the edgesStore based on Anchor's change.
69
- */
70
- updateEdges() {
71
- const { edgesStore } = stores[this.canvasId];
72
- /** update edges by deconstructing edges store and setting its new vlue to stores[this.canvasID] */
73
- edgesStore.update((edges) => {
74
- const edge = edges[this.edgeId];
75
- // this means that no edge was found, just return without doing anything
76
- if (edge === undefined) {
77
- return { ...edges };
78
- }
79
- if (this.sourceOrTarget === 'source') {
80
- edge.sourceX = this.positionX;
81
- edge.sourceY = this.positionY;
82
- }
83
- else {
84
- edge.targetX = this.positionX;
85
- edge.targetY = this.positionY;
86
- }
87
- return { ...edges };
88
- });
89
- }
90
- /**
91
- * setPosition will update the positionX and positionY of the Anchor and also cascade changes to related Edge.
92
- * @param x The X coordinate of the new position for the Anchor
93
- * @param y The Y coordinate of the new position for the Anchor
94
- */
95
- setPosition(x, y) {
96
- this.positionX = x;
97
- this.positionY = y;
98
- this.updateEdges();
99
- }
100
- /**
101
- * Anchor.setPositionFromMovement works similarly to Anchor.setPosition. But setPosition is more powerful and we recommend using setPosition whenever possible and in the future, setPositionFromMovement can be removed.
102
- * @param movementX The mouse movement value on the X-axis
103
- * @param movementY The mouse movement value on the Y-axis
104
- */
105
- setPositionFromMovement(movementX, movementY) {
106
- this.positionX += movementX;
107
- this.positionY += movementY;
108
- const { edgesStore } = stores[this.canvasId];
109
- edgesStore.update((edges) => {
110
- const edge = edges[this.edgeId];
111
- if (this.sourceOrTarget === 'source') {
112
- edge.sourceX += movementX;
113
- edge.sourceY += movementY;
114
- }
115
- else {
116
- edge.targetX += movementX;
117
- edge.targetY += movementY;
118
- }
119
- return { ...edges };
120
- });
121
- }
122
- }
@@ -1,48 +0,0 @@
1
- import type { UserEdgeType } from '../../types/types';
2
- import type { EdgeType } from '../../store/types/types';
3
- /**
4
- * Class Edge that implements EdgeType.
5
- * @param id The id of the Edge
6
- * @param sourceX The X coordinate of the source Anchor
7
- * @param sourceY The Y coordinate of the source Anchor
8
- * @param targetX The X coordinate of the target Anchor
9
- * @param targetY The Y coordinate of the target Anchor
10
- * @param canvasId The canvasId of the Svelvet component that holds the instantiated Edge
11
- * @param label The label of the Edge
12
- * @param type The type of the Edge (options: 'straight', 'smoothstep', 'step', or 'bezier'). If user doesn't specify, the type will default to 'bezier'.
13
- * @param labelBgColor The background color of the Edge label
14
- * @param labelTextColor The text color of the Edge label
15
- * @param edgeColor The color of the Edge
16
- * @param animate Boolean value to specify whether the Edge should be animated
17
- * @param noHandle Boolean value but looks like it is already depracated and can be removed without damage
18
- * @param arraw Boolean value to specify whether the Edge displays an arrow near its target Anchor
19
- */
20
- export declare class Edge implements EdgeType {
21
- id: string;
22
- sourceX: number;
23
- sourceY: number;
24
- targetX: number;
25
- targetY: number;
26
- canvasId: string;
27
- label: string;
28
- type: 'straight' | 'smoothstep' | 'step' | 'bezier';
29
- labelBgColor: string;
30
- labelTextColor: string;
31
- edgeColor: string;
32
- animate: boolean;
33
- noHandle: boolean;
34
- arrow: boolean;
35
- clickCallback: Function;
36
- className: string;
37
- offset?: number | undefined;
38
- constructor(id: string, sourceX: number, sourceY: number, targetX: number, targetY: number, canvasId: string, label: string, type: 'straight' | 'smoothstep' | 'step' | 'bezier', labelBgColor: string, labelTextColor: string, edgeColor: string, animate: boolean, noHandle: boolean, arrow: boolean, clickCallback: Function, className: string, offset?: number | undefined);
39
- /**
40
- * delete is going to delete the Edge and also delete associated Anchors
41
- */
42
- delete(): void;
43
- /**
44
- * setExportableData will construct an object that holds all the edge data that can be exported. This is needed for the Exporting Diagram feature.
45
- * @returns The object of exportable edge data. The format of the object should be as close as what user initially passes in to Svelvet.
46
- */
47
- setExportableData(): UserEdgeType;
48
- }
@@ -1,109 +0,0 @@
1
- import { findStore } from '../../store/models/store';
2
- import { stores } from '../../store/models/store';
3
- import { getAnchors, getAnchorFromEdge } from '../../edges/controllers/util';
4
- /**
5
- * Class Edge that implements EdgeType.
6
- * @param id The id of the Edge
7
- * @param sourceX The X coordinate of the source Anchor
8
- * @param sourceY The Y coordinate of the source Anchor
9
- * @param targetX The X coordinate of the target Anchor
10
- * @param targetY The Y coordinate of the target Anchor
11
- * @param canvasId The canvasId of the Svelvet component that holds the instantiated Edge
12
- * @param label The label of the Edge
13
- * @param type The type of the Edge (options: 'straight', 'smoothstep', 'step', or 'bezier'). If user doesn't specify, the type will default to 'bezier'.
14
- * @param labelBgColor The background color of the Edge label
15
- * @param labelTextColor The text color of the Edge label
16
- * @param edgeColor The color of the Edge
17
- * @param animate Boolean value to specify whether the Edge should be animated
18
- * @param noHandle Boolean value but looks like it is already depracated and can be removed without damage
19
- * @param arraw Boolean value to specify whether the Edge displays an arrow near its target Anchor
20
- */
21
- export class Edge {
22
- id;
23
- sourceX;
24
- sourceY;
25
- targetX;
26
- targetY;
27
- canvasId;
28
- label;
29
- type;
30
- labelBgColor;
31
- labelTextColor;
32
- edgeColor;
33
- animate;
34
- noHandle;
35
- arrow;
36
- clickCallback;
37
- className;
38
- offset;
39
- constructor(id, sourceX, sourceY, targetX, targetY, canvasId, label, type, labelBgColor, labelTextColor, edgeColor, animate, noHandle, arrow, clickCallback, className, offset) {
40
- this.id = id;
41
- this.sourceX = sourceX;
42
- this.sourceY = sourceY;
43
- this.targetX = targetX;
44
- this.targetY = targetY;
45
- this.canvasId = canvasId;
46
- this.label = label;
47
- this.type = type;
48
- this.labelBgColor = labelBgColor;
49
- this.labelTextColor = labelTextColor;
50
- this.edgeColor = edgeColor;
51
- this.animate = animate;
52
- this.noHandle = noHandle;
53
- this.arrow = arrow;
54
- this.clickCallback = clickCallback;
55
- this.className = className;
56
- this.offset = offset;
57
- }
58
- /**
59
- * delete is going to delete the Edge and also delete associated Anchors
60
- */
61
- delete() {
62
- const store = stores[this.canvasId];
63
- const { anchorsStore, edgesStore } = store;
64
- const sourceAnchor = getAnchorFromEdge(store, this.id, 'source'); // this is a bit wasteful
65
- const targetAnchor = getAnchorFromEdge(store, this.id, 'target');
66
- anchorsStore.update((anchors) => {
67
- for (const anchorId in anchors) {
68
- if (anchorId === sourceAnchor.id || anchorId == targetAnchor.id)
69
- delete anchors[anchorId];
70
- }
71
- return { ...anchors };
72
- });
73
- edgesStore.update((edges) => {
74
- delete edges[this.id];
75
- return { ...edges };
76
- });
77
- }
78
- /**
79
- * setExportableData will construct an object that holds all the edge data that can be exported. This is needed for the Exporting Diagram feature.
80
- * @returns The object of exportable edge data. The format of the object should be as close as what user initially passes in to Svelvet.
81
- */
82
- setExportableData() {
83
- const exportableData = {
84
- id: this.id,
85
- label: this.label,
86
- type: this.type,
87
- labelBgColor: this.labelBgColor,
88
- labelTextColor: this.labelTextColor,
89
- edgeColor: this.edgeColor,
90
- animate: this.animate,
91
- noHandle: this.noHandle,
92
- arrow: this.arrow,
93
- source: 'dummy',
94
- target: 'dummy' // these will be set later
95
- };
96
- // set source, target on exportableData
97
- const store = findStore(this.canvasId);
98
- const anchors = getAnchors(store, { edgeId: this.id });
99
- if (anchors.length !== 2)
100
- throw 'there should be two anchors per edge';
101
- for (const anchor of anchors) {
102
- if (anchor.sourceOrTarget === 'target')
103
- exportableData.target = anchor.nodeId;
104
- if (anchor.sourceOrTarget === 'source')
105
- exportableData.source = anchor.nodeId;
106
- }
107
- return exportableData;
108
- }
109
- }