windmill-components 1.379.3 → 1.382.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/components/ArgInput.svelte +33 -3
- package/package/components/DisplayResult.svelte +17 -5
- package/package/components/ErrorOrRecoveryHandler.svelte +3 -2
- package/package/components/FlowBuilder.svelte +3 -0
- package/package/components/FlowBuilder.svelte.d.ts +1 -0
- package/package/components/FlowGraphViewer.svelte +6 -5
- package/package/components/FlowJobResult.svelte +4 -2
- package/package/components/FlowJobResult.svelte.d.ts +2 -0
- package/package/components/FlowStatusViewerInner.svelte +17 -6
- package/package/components/FlowViewer.svelte +1 -0
- package/package/components/HighlightCode.svelte +2 -2
- package/package/components/ModulePreviewForm.svelte +1 -1
- package/package/components/ObjectResourceInput.svelte +7 -2
- package/package/components/ObjectResourceInput.svelte.d.ts +2 -0
- package/package/components/ResourcePicker.svelte +60 -48
- package/package/components/ScriptVersionHistory.svelte +63 -7
- package/package/components/apps/components/display/dbtable/DbExplorerCount.svelte +3 -2
- package/package/components/apps/components/display/table/AppAggridExplorerTable.svelte +22 -5
- package/package/components/apps/components/display/table/AppAggridTable.svelte +14 -5
- package/package/components/apps/components/display/table/AppAggridTableActions.svelte +23 -8
- package/package/components/apps/components/display/table/AppAggridTableActions.svelte.d.ts +5 -3
- package/package/components/apps/components/display/table/utils.js +8 -7
- package/package/components/apps/components/helpers/RunnableComponent.svelte +13 -1
- package/package/components/apps/components/helpers/eval.js +31 -25
- package/package/components/apps/editor/AppEditorHeader.svelte +1 -0
- package/package/components/apps/editor/AppReportsDrawer.svelte +4 -3
- package/package/components/apps/editor/component/components.d.ts +1 -1
- package/package/components/apps/editor/settingsPanel/DecisionTreeGraphEditor.svelte +0 -1
- package/package/components/apps/editor/settingsPanel/DecisionTreeGraphHeader.svelte +55 -45
- package/package/components/apps/editor/settingsPanel/DecisionTreeGraphHeader.svelte.d.ts +7 -9
- package/package/components/apps/editor/settingsPanel/DecisionTreeGraphNode.svelte +66 -59
- package/package/components/apps/editor/settingsPanel/DecisionTreeGraphNode.svelte.d.ts +9 -11
- package/package/components/apps/editor/settingsPanel/decisionTree/DecisionTreePreview.svelte +213 -254
- package/package/components/apps/editor/settingsPanel/decisionTree/DecisionTreePreview.svelte.d.ts +0 -1
- package/package/components/apps/editor/settingsPanel/decisionTree/nodeHelpers.d.ts +1 -1
- package/package/components/apps/editor/settingsPanel/decisionTree/nodeHelpers.js +2 -6
- package/package/components/details/DetailPageDetailPanel.svelte +9 -1
- package/package/components/details/DetailPageDetailPanel.svelte.d.ts +2 -1
- package/package/components/details/DetailPageLayout.svelte +2 -0
- package/package/components/details/DetailPageLayout.svelte.d.ts +3 -0
- package/package/components/details/EmailTriggerPanel.svelte +128 -0
- package/package/components/details/EmailTriggerPanel.svelte.d.ts +20 -0
- package/package/components/details/WebhooksPanel.svelte +7 -68
- package/package/components/flows/FlowHistory.svelte +1 -0
- package/package/components/flows/content/FlowInputs.svelte +0 -1
- package/package/components/flows/content/FlowModuleScript.svelte +33 -3
- package/package/components/flows/content/FlowModuleScript.svelte.d.ts +2 -0
- package/package/components/flows/content/FlowModuleSuspend.svelte +15 -0
- package/package/components/flows/flowInfers.js +1 -1
- package/package/components/flows/map/FlowJobsMenu.svelte +39 -44
- package/package/components/flows/map/FlowModuleSchemaItem.svelte +1 -2
- package/package/components/flows/map/FlowModuleSchemaMap.svelte +4 -3
- package/package/components/flows/map/InsertModuleButton.svelte +16 -9
- package/package/components/flows/map/MapItem.svelte +3 -97
- package/package/components/flows/map/MapItem.svelte.d.ts +0 -5
- package/package/components/flows/map/VirtualItem.svelte +6 -159
- package/package/components/flows/map/VirtualItem.svelte.d.ts +0 -15
- package/package/components/graph/FlowGraphV2.svelte +256 -0
- package/package/components/graph/{FlowGraph.svelte.d.ts → FlowGraphV2.svelte.d.ts} +8 -8
- package/package/components/graph/graphBuilder.d.ts +15 -0
- package/package/components/graph/graphBuilder.js +337 -0
- package/package/components/graph/index.d.ts +0 -1
- package/package/components/graph/index.js +0 -1
- package/package/components/graph/model.d.ts +1 -8
- package/package/components/graph/renderers/edges/BaseEdge.svelte +109 -0
- package/package/components/graph/renderers/edges/BaseEdge.svelte.d.ts +35 -0
- package/package/components/graph/renderers/edges/DataflowEdge.svelte +37 -0
- package/package/components/graph/renderers/edges/DataflowEdge.svelte.d.ts +29 -0
- package/package/components/graph/renderers/edges/EmptyEdge.svelte +22 -0
- package/package/components/graph/renderers/edges/EmptyEdge.svelte.d.ts +23 -0
- package/package/components/graph/renderers/nodes/BranchAllStart.svelte +44 -0
- package/package/components/graph/renderers/nodes/BranchAllStart.svelte.d.ts +29 -0
- package/package/components/graph/renderers/nodes/BranchOneStart.svelte +41 -0
- package/package/components/graph/renderers/nodes/BranchOneStart.svelte.d.ts +29 -0
- package/package/components/graph/renderers/nodes/ForLoopEndNode.svelte +19 -0
- package/package/components/graph/renderers/nodes/ForLoopEndNode.svelte.d.ts +24 -0
- package/package/components/graph/renderers/nodes/ForLoopStartNode.svelte +20 -0
- package/package/components/graph/renderers/nodes/ForLoopStartNode.svelte.d.ts +25 -0
- package/package/components/graph/renderers/nodes/InputNode.svelte +74 -0
- package/package/components/graph/renderers/nodes/InputNode.svelte.d.ts +23 -0
- package/package/components/graph/renderers/nodes/ModuleNode.svelte +71 -0
- package/package/components/graph/renderers/nodes/ModuleNode.svelte.d.ts +41 -0
- package/package/components/graph/renderers/nodes/NoBranchNode.svelte +20 -0
- package/package/components/graph/renderers/nodes/NoBranchNode.svelte.d.ts +27 -0
- package/package/components/graph/renderers/nodes/NodeWrapper.svelte +21 -0
- package/package/components/graph/renderers/nodes/NodeWrapper.svelte.d.ts +22 -0
- package/package/components/graph/renderers/nodes/ResultNode.svelte +24 -0
- package/package/components/graph/renderers/nodes/ResultNode.svelte.d.ts +22 -0
- package/package/components/graph/renderers/nodes/branchAllEndNode.svelte +19 -0
- package/package/components/graph/renderers/nodes/branchAllEndNode.svelte.d.ts +26 -0
- package/package/components/graph/renderers/nodes/branchOneEndNode.svelte +19 -0
- package/package/components/graph/renderers/nodes/branchOneEndNode.svelte.d.ts +24 -0
- package/package/components/graph/renderers/utils.d.ts +8 -0
- package/package/components/graph/renderers/utils.js +26 -0
- package/package/components/graph/util.d.ts +1 -2
- package/package/components/graph/util.js +2 -8
- package/package/components/home/Item.svelte +1 -1
- package/package/components/runs/RunsFilter.svelte +15 -17
- package/package/forLater.js +8 -4
- package/package/gen/core/OpenAPI.js +1 -1
- package/package/gen/schemas.gen.d.ts +3 -0
- package/package/gen/schemas.gen.js +3 -0
- package/package/gen/services.gen.d.ts +22 -3
- package/package/gen/services.gen.js +38 -2
- package/package/gen/types.gen.d.ts +69 -6
- package/package/hub.d.ts +11 -0
- package/package/hub.js +2 -0
- package/package/hubPaths.json +9 -0
- package/package/init_scripts/python_failure_module.d.ts +1 -1
- package/package/init_scripts/python_failure_module.js +4 -3
- package/package/script_helpers.d.ts +2 -2
- package/package/script_helpers.js +11 -9
- package/package.json +2 -1
- package/package/components/graph/FlowGraph.svelte +0 -614
- package/package/components/graph/svelvet/LICENSE +0 -21
- package/package/components/graph/svelvet/container/README.md +0 -7
- package/package/components/graph/svelvet/container/controllers/middleware.d.ts +0 -11
- package/package/components/graph/svelvet/container/controllers/middleware.js +0 -87
- package/package/components/graph/svelvet/container/models/index.d.ts +0 -0
- package/package/components/graph/svelvet/container/models/index.js +0 -1
- package/package/components/graph/svelvet/container/views/GraphView.svelte +0 -262
- package/package/components/graph/svelvet/container/views/GraphView.svelte.d.ts +0 -26
- package/package/components/graph/svelvet/container/views/Svelvet.svelte +0 -121
- package/package/components/graph/svelvet/container/views/Svelvet.svelte.d.ts +0 -36
- package/package/components/graph/svelvet/customCss/controllers/getCss.d.ts +0 -2
- package/package/components/graph/svelvet/customCss/controllers/getCss.js +0 -46
- package/package/components/graph/svelvet/d3/controllers/d3.d.ts +0 -5
- package/package/components/graph/svelvet/d3/controllers/d3.js +0 -59
- package/package/components/graph/svelvet/edges/controllers/anchorCbDev.d.ts +0 -4
- package/package/components/graph/svelvet/edges/controllers/anchorCbDev.js +0 -92
- package/package/components/graph/svelvet/edges/controllers/anchorCbUser.d.ts +0 -57
- package/package/components/graph/svelvet/edges/controllers/anchorCbUser.js +0 -73
- package/package/components/graph/svelvet/edges/controllers/util.d.ts +0 -37
- package/package/components/graph/svelvet/edges/controllers/util.js +0 -71
- package/package/components/graph/svelvet/edges/models/Anchor.d.ts +0 -48
- package/package/components/graph/svelvet/edges/models/Anchor.js +0 -122
- package/package/components/graph/svelvet/edges/models/Edge.d.ts +0 -48
- package/package/components/graph/svelvet/edges/models/Edge.js +0 -109
- package/package/components/graph/svelvet/edges/types/types.d.ts +0 -18
- package/package/components/graph/svelvet/edges/types/types.js +0 -1
- package/package/components/graph/svelvet/edges/views/Edges/BaseEdge.svelte +0 -104
- package/package/components/graph/svelvet/edges/views/Edges/BaseEdge.svelte.d.ts +0 -18
- package/package/components/graph/svelvet/edges/views/Edges/EdgeText.svelte +0 -42
- package/package/components/graph/svelvet/edges/views/Edges/EdgeText.svelte.d.ts +0 -17
- package/package/components/graph/svelvet/edges/views/Edges/SimpleBezierEdge.svelte +0 -151
- package/package/components/graph/svelvet/edges/views/Edges/SimpleBezierEdge.svelte.d.ts +0 -17
- package/package/components/graph/svelvet/edges/views/Edges/SmoothStepEdge.svelte +0 -157
- package/package/components/graph/svelvet/edges/views/Edges/SmoothStepEdge.svelte.d.ts +0 -60
- package/package/components/graph/svelvet/edges/views/Edges/StepEdge.svelte +0 -8
- package/package/components/graph/svelvet/edges/views/Edges/StepEdge.svelte.d.ts +0 -25
- package/package/components/graph/svelvet/edges/views/Edges/types.d.ts +0 -52
- package/package/components/graph/svelvet/edges/views/Edges/types.js +0 -1
- package/package/components/graph/svelvet/edges/views/Edges/utils.d.ts +0 -33
- package/package/components/graph/svelvet/edges/views/Edges/utils.js +0 -31
- package/package/components/graph/svelvet/nodes/controllers/util.d.ts +0 -9
- package/package/components/graph/svelvet/nodes/controllers/util.js +0 -13
- package/package/components/graph/svelvet/nodes/models/Node.d.ts +0 -74
- package/package/components/graph/svelvet/nodes/models/Node.js +0 -156
- package/package/components/graph/svelvet/nodes/views/Node.svelte +0 -84
- package/package/components/graph/svelvet/nodes/views/Node.svelte.d.ts +0 -21
- package/package/components/graph/svelvet/store/controllers/storeApi.d.ts +0 -25
- package/package/components/graph/svelvet/store/controllers/storeApi.js +0 -91
- package/package/components/graph/svelvet/store/controllers/userApi.d.ts +0 -3
- package/package/components/graph/svelvet/store/controllers/userApi.js +0 -18
- package/package/components/graph/svelvet/store/controllers/util.d.ts +0 -24
- package/package/components/graph/svelvet/store/controllers/util.js +0 -148
- package/package/components/graph/svelvet/store/models/store.d.ts +0 -13
- package/package/components/graph/svelvet/store/models/store.js +0 -12
- package/package/components/graph/svelvet/store/types/types.d.ts +0 -127
- package/package/components/graph/svelvet/store/types/types.js +0 -1
- package/package/components/graph/svelvet/types/README.md +0 -3
- package/package/components/graph/svelvet/types/index.d.ts +0 -2
- package/package/components/graph/svelvet/types/index.js +0 -1
- package/package/components/graph/svelvet/types/types.d.ts +0 -50
- package/package/components/graph/svelvet/types/types.js +0 -18
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
This file contains "middleware" functions that sanitize user input (UserNodeType and UserEdgeType). Put functions that
|
|
3
|
-
maintain consistency between previous
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
import { bottomCb, leftCb, rightCb, topCb } from '../../edges/controllers/anchorCbUser';
|
|
7
|
-
/**
|
|
8
|
-
* sanitizeUserNodesAndEdges will sanitize the data initially passed in to Svelvet component. For example, the node that user specified have an integar as its id but to instantiate a Node and be compatible with uuid we will need to convert the integar id to a string.
|
|
9
|
-
* @param userNodes The array of nodes that have a UserNodeType
|
|
10
|
-
* @param userEdges The array of edges that have a UserEdgeType
|
|
11
|
-
* @returns An object of sanitized userNodes and userEdges
|
|
12
|
-
*/
|
|
13
|
-
export function sanitizeUserNodesAndEdges(userNodes, userEdges) {
|
|
14
|
-
convertIdToString(userNodes);
|
|
15
|
-
convertEdgeIdsToString(userEdges);
|
|
16
|
-
convertAnchorPositionsToCallbacks(userNodes, userEdges);
|
|
17
|
-
setDefaultEdgeType(userEdges);
|
|
18
|
-
return { userNodes, userEdges };
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* setDefaultEdgeType ensures a default edge type of 'bezier' if the user does not set one, or sets a nonsense type.
|
|
22
|
-
* @param userEdges The array of edges that have a UserEdgeType
|
|
23
|
-
* @returns No return, the function edits the objects in place
|
|
24
|
-
*/
|
|
25
|
-
function setDefaultEdgeType(userEdges) {
|
|
26
|
-
for (let userEdge of userEdges) {
|
|
27
|
-
if (!['smoothstep', 'step', 'bezier', 'straight'].includes(userEdge.type))
|
|
28
|
-
userEdge.type = 'bezier';
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* convertAnchorPositionsToCallbacks
|
|
33
|
-
* @description
|
|
34
|
-
* WHY: This function is in order to maintain compliance with earlier versions of Svelvet.
|
|
35
|
-
* HISTORY: In Svelvet<=5, anchor points were hard-coded onto each node. Each node had a "sourcePosition"
|
|
36
|
-
* "targetPosition" where the edges would be attached. In Svelvet6, the store was re-designed
|
|
37
|
-
* from the ground up into an object-relational data model where anchor points could be attached
|
|
38
|
-
* at any point on the node using callbacks. This enabled features such as custom edge position,
|
|
39
|
-
* adaptive edge positioning, and dynamic edges.
|
|
40
|
-
* The purpose of this function is to parse the old way of specifying edge positions (as two source/target
|
|
41
|
-
* anchors on the node) into the Svelvet6 (where anchors are separate objects) in order to maintain a
|
|
42
|
-
* consistent user experience. However, we suggest that this functionality (parsing Svelvet5 syntax into
|
|
43
|
-
* Svelvet6 syntax) be removed completely in favor of only using Svelvet6 syntax in order to reduce edge cases.
|
|
44
|
-
*/
|
|
45
|
-
function convertAnchorPositionsToCallbacks(userNodes, userEdges) {
|
|
46
|
-
// convert userNodes array into object for constant time lookup by id
|
|
47
|
-
const userNodesObj = {};
|
|
48
|
-
for (let userNode of userNodes)
|
|
49
|
-
userNodesObj[userNode.id] = userNode;
|
|
50
|
-
// iterate through userEdges, and check the source/target nodes.
|
|
51
|
-
for (let userEdge of userEdges) {
|
|
52
|
-
const userNodeSource = userNodesObj[userEdge.source];
|
|
53
|
-
const userNodeTarget = userNodesObj[userEdge.target];
|
|
54
|
-
if (!userNodeSource || !userNodeTarget)
|
|
55
|
-
continue;
|
|
56
|
-
const sourcePosition = userNodeSource.sourcePosition;
|
|
57
|
-
const targetPosition = userNodeTarget.targetPosition;
|
|
58
|
-
const cbs = { left: leftCb, right: rightCb, top: topCb, bottom: bottomCb };
|
|
59
|
-
if (sourcePosition)
|
|
60
|
-
userEdge.sourceAnchorCb = cbs[sourcePosition];
|
|
61
|
-
if (targetPosition)
|
|
62
|
-
userEdge.targetAnchorCb = cbs[targetPosition];
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Converts node id's to strings. For Svelvet<6, node id's were numbers. These were switched to strings for compatibility with uuid. This function does not return a new array, instead it mutates and sanitizes the original array.
|
|
67
|
-
* @param userNodes The array of userNodes (not yet sanitized)
|
|
68
|
-
*/
|
|
69
|
-
function convertIdToString(userNodes) {
|
|
70
|
-
userNodes = userNodes.map((node) => {
|
|
71
|
-
node.id = node.id.toString();
|
|
72
|
-
node.childNodes =
|
|
73
|
-
node.childNodes === undefined ? [] : node.childNodes.map((childId) => childId.toString());
|
|
74
|
-
return node;
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Converts source/target node id's to string. For Svelvet<6, id's were numbers. These were switched to strings for compatibility with uuid. This function does not return a new array, instead it mutates and sanitizes the original array.
|
|
79
|
-
* @param userEdges The array of userEdges (not yet sanitized)
|
|
80
|
-
*/
|
|
81
|
-
function convertEdgeIdsToString(userEdges) {
|
|
82
|
-
userEdges = userEdges.map((edge) => {
|
|
83
|
-
edge.source = edge.source.toString();
|
|
84
|
-
edge.target = edge.target.toString();
|
|
85
|
-
return edge;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
<script>import { pointer, select, selectAll } from 'd3-selection';
|
|
2
|
-
import { zoom, zoomIdentity, zoomTransform } from 'd3-zoom';
|
|
3
|
-
import { createEventDispatcher, getContext, onMount } from 'svelte';
|
|
4
|
-
import SimpleBezierEdge from '../../edges/views/Edges/SimpleBezierEdge.svelte';
|
|
5
|
-
import SmoothStepEdge from '../../edges/views/Edges/SmoothStepEdge.svelte';
|
|
6
|
-
import StepEdge from '../../edges/views/Edges/StepEdge.svelte';
|
|
7
|
-
import Node from '../../nodes/views/Node.svelte';
|
|
8
|
-
import { determineD3Instance } from '../..//d3/controllers/d3';
|
|
9
|
-
import { findStore } from '../../store/models/store';
|
|
10
|
-
import { Expand, Minus, Plus } from 'lucide-svelte';
|
|
11
|
-
import Toggle from '../../../../Toggle.svelte';
|
|
12
|
-
import { fade } from 'svelte/transition';
|
|
13
|
-
//these are typscripted as any, however they have been transformed inside of store.ts
|
|
14
|
-
export let canvasId;
|
|
15
|
-
export let width;
|
|
16
|
-
export let height;
|
|
17
|
-
export let boundary = false;
|
|
18
|
-
export let scroll = false;
|
|
19
|
-
export let dataflow = false;
|
|
20
|
-
export let download = false;
|
|
21
|
-
export let showDataflowToggle = false;
|
|
22
|
-
// here we lookup the store using the unique key
|
|
23
|
-
const store = findStore(canvasId);
|
|
24
|
-
const { edgesStore, nodesStore, nodeSelected, backgroundStore, movementStore, widthStore, heightStore, d3Scale } = store;
|
|
25
|
-
$: nodes = Object.values($nodesStore);
|
|
26
|
-
$: edges = Object.values($edgesStore);
|
|
27
|
-
// declaring the grid and dot size for d3's transformations and zoom
|
|
28
|
-
const gridSize = 15;
|
|
29
|
-
const dotSize = 10;
|
|
30
|
-
const dispatch = createEventDispatcher();
|
|
31
|
-
// leveraging d3 library to zoom/pan
|
|
32
|
-
let d3 = {
|
|
33
|
-
zoom,
|
|
34
|
-
zoomTransform,
|
|
35
|
-
zoomIdentity,
|
|
36
|
-
select,
|
|
37
|
-
selectAll,
|
|
38
|
-
pointer
|
|
39
|
-
};
|
|
40
|
-
let d3Zoom = determineD3Instance(boundary, d3, nodeSelected, width, height, movementStore, backgroundStore, gridSize, dotSize, canvasId, d3Scale, handleZoom);
|
|
41
|
-
// d3Translate is used for the minimap
|
|
42
|
-
onMount(() => {
|
|
43
|
-
// actualizes the d3 instance
|
|
44
|
-
const nodes = d3.select(`#zoomable-${canvasId}`).call(d3Zoom).on('dblclick.zoom', null);
|
|
45
|
-
if (!scroll) {
|
|
46
|
-
;
|
|
47
|
-
[nodes].forEach((d3Instance) => {
|
|
48
|
-
d3Instance
|
|
49
|
-
.on('wheel.zoom', null)
|
|
50
|
-
.on('mousewheel.zoom', null)
|
|
51
|
-
.on('mousemove.zoom', null)
|
|
52
|
-
.on('DOMMouseScroll.zoom', null);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
d3.select(`#zoom_in_${canvasId}`).on('click', function () {
|
|
56
|
-
try {
|
|
57
|
-
// @ts-ignore
|
|
58
|
-
d3Zoom.scaleBy(nodes.transition().duration(250), 1.4);
|
|
59
|
-
}
|
|
60
|
-
catch (e) {
|
|
61
|
-
console.log('error', e);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
d3.select(`#zoom_out_${canvasId}`).on('click', function () {
|
|
65
|
-
try {
|
|
66
|
-
// @ts-ignore
|
|
67
|
-
d3Zoom.scaleBy(nodes.transition().duration(250), 0.714);
|
|
68
|
-
}
|
|
69
|
-
catch (e) {
|
|
70
|
-
console.log('error', e);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
function handleZoom(e) {
|
|
75
|
-
if (!$movementStore)
|
|
76
|
-
return;
|
|
77
|
-
//add a store that contains the current value of the d3-zoom's scale to be used in onMouseMove function
|
|
78
|
-
d3Scale.set(e.transform.k);
|
|
79
|
-
// transform 'g' SVG elements (edge, edge text, edge anchor)
|
|
80
|
-
d3.select(`.Edges-${canvasId} g`).attr('transform', e.transform);
|
|
81
|
-
// transform div elements (nodes)
|
|
82
|
-
//@ts-ignore
|
|
83
|
-
let transform = d3.zoomTransform(this);
|
|
84
|
-
store.d3ZoomParameters.set({ ...transform }); // record x,y position of pan, and zoom level
|
|
85
|
-
// selects and transforms all node divs from class 'Node' and performs transformation
|
|
86
|
-
d3.select(`.Node-${canvasId}`)
|
|
87
|
-
.style('transform', 'translate(' + transform.x + 'px,' + transform.y + 'px) scale(' + transform.k + ')')
|
|
88
|
-
.style('transform-origin', '0 0');
|
|
89
|
-
}
|
|
90
|
-
const { currentStepStore: copilotCurrentStepStore } = getContext('FlowCopilotContext') || {};
|
|
91
|
-
$: {
|
|
92
|
-
if ($copilotCurrentStepStore !== undefined) {
|
|
93
|
-
// reset zoom
|
|
94
|
-
d3.select(`#zoomable-${canvasId}`).call(d3Zoom.transform, d3.zoomIdentity);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
</script>
|
|
98
|
-
|
|
99
|
-
<div class="zoomable" id={`zoomable-${canvasId}`}>
|
|
100
|
-
<!-- This is the container that holds GraphView and we have disabled right click functionality to prevent a sticking behavior -->
|
|
101
|
-
<div id="graphview-container">
|
|
102
|
-
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
103
|
-
<div class={`Nodes Nodes-${canvasId}`} on:contextmenu|preventDefault>
|
|
104
|
-
<!-- This container is transformed by d3zoom -->
|
|
105
|
-
<div class={`Node Node-${canvasId}`}>
|
|
106
|
-
{#if $copilotCurrentStepStore !== undefined}
|
|
107
|
-
<div transition:fade class="fixed inset-0 bg-gray-500 bg-opacity-75 z-[900] !m-0" />
|
|
108
|
-
{/if}
|
|
109
|
-
{#each nodes as node}
|
|
110
|
-
{#if node.data.html}
|
|
111
|
-
<Node {node} {canvasId}>{@html node.data.html}</Node>
|
|
112
|
-
{:else if node.data.custom}
|
|
113
|
-
<Node isCustom {node} {canvasId}>
|
|
114
|
-
<svelte:component
|
|
115
|
-
this={node.data.custom.component}
|
|
116
|
-
on:new={(e) => node?.data?.custom?.cb?.('new', e.detail)}
|
|
117
|
-
on:delete={(e) => node?.data?.custom?.cb?.('delete', e.detail)}
|
|
118
|
-
on:select={(e) => node?.data?.custom?.cb?.('select', e.detail)}
|
|
119
|
-
on:insert={(e) => node?.data?.custom?.cb?.('insert', e.detail)}
|
|
120
|
-
on:newBranch={(e) => node?.data?.custom?.cb?.('newBranch', e.detail)}
|
|
121
|
-
on:deleteBranch={(e) => node?.data?.custom?.cb?.('deleteBranch', e.detail)}
|
|
122
|
-
on:move={(e) => node?.data?.custom?.cb?.('move', e.detail)}
|
|
123
|
-
on:nodeInsert={(e) => node?.data?.custom?.cb?.('nodeInsert', e.detail)}
|
|
124
|
-
on:addBranch={(e) => node?.data?.custom?.cb?.('addBranch', e.detail)}
|
|
125
|
-
on:removeBranch={(e) => node?.data?.custom?.cb?.('removeBranch', e.detail)}
|
|
126
|
-
on:selectedIteration={(e) =>
|
|
127
|
-
node?.data?.custom?.cb?.('selectedIteration', e.detail)}
|
|
128
|
-
{...node.data.custom.props}
|
|
129
|
-
/>
|
|
130
|
-
</Node>
|
|
131
|
-
{:else}
|
|
132
|
-
<Node {node} {canvasId}>{node.data.label}</Node>
|
|
133
|
-
{/if}
|
|
134
|
-
{/each}
|
|
135
|
-
</div>
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
<!-- rendering dots on the background depending on the zoom level -->
|
|
139
|
-
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
140
|
-
<svg
|
|
141
|
-
class={`Edges Edges-${canvasId}`}
|
|
142
|
-
viewBox="0 0 {$widthStore} {$heightStore}"
|
|
143
|
-
on:contextmenu|preventDefault
|
|
144
|
-
>
|
|
145
|
-
<defs>
|
|
146
|
-
<pattern
|
|
147
|
-
id={`background-${canvasId}`}
|
|
148
|
-
x="0"
|
|
149
|
-
y="0"
|
|
150
|
-
width={gridSize}
|
|
151
|
-
height={gridSize}
|
|
152
|
-
patternUnits="userSpaceOnUse"
|
|
153
|
-
>
|
|
154
|
-
<circle
|
|
155
|
-
id="dot"
|
|
156
|
-
cx={gridSize / 2 - dotSize / 2}
|
|
157
|
-
cy={gridSize / 2 - dotSize / 2}
|
|
158
|
-
r="0.5"
|
|
159
|
-
style="fill: gray"
|
|
160
|
-
/>
|
|
161
|
-
</pattern>
|
|
162
|
-
</defs>
|
|
163
|
-
|
|
164
|
-
<!-- <g> tag defines which edge type to render depending on properties of edge object -->
|
|
165
|
-
<g>
|
|
166
|
-
{#each edges as edge}
|
|
167
|
-
{#if edge.type === 'smoothstep'}
|
|
168
|
-
<SmoothStepEdge {edge} {canvasId} />
|
|
169
|
-
{:else if edge.type === 'step'}
|
|
170
|
-
<StepEdge {edge} {canvasId} />
|
|
171
|
-
{:else}
|
|
172
|
-
<SimpleBezierEdge edgeId={edge.id} {canvasId} />
|
|
173
|
-
{/if}
|
|
174
|
-
{/each}
|
|
175
|
-
|
|
176
|
-
<!-- {#each filteredAnchors as anchor} -->
|
|
177
|
-
<!-- note that these are SVG -->
|
|
178
|
-
<!-- <EdgeAnchor x={anchor.positionX} y={anchor.positionY} /> -->
|
|
179
|
-
<!-- {/each} -->
|
|
180
|
-
</g>
|
|
181
|
-
</svg>
|
|
182
|
-
</div>
|
|
183
|
-
{#if showDataflowToggle}
|
|
184
|
-
<div id="dataflow_toggle">
|
|
185
|
-
<Toggle
|
|
186
|
-
disabled={$copilotCurrentStepStore !== undefined}
|
|
187
|
-
textClass="!text-secondary"
|
|
188
|
-
size="xs"
|
|
189
|
-
bind:checked={dataflow}
|
|
190
|
-
options={{
|
|
191
|
-
right: 'dataflow'
|
|
192
|
-
}}
|
|
193
|
-
/>
|
|
194
|
-
</div>
|
|
195
|
-
{/if}
|
|
196
|
-
|
|
197
|
-
<div id="buttons">
|
|
198
|
-
<button
|
|
199
|
-
title="Zoom In"
|
|
200
|
-
id={`zoom_in_${canvasId}`}
|
|
201
|
-
class={'relative overflow-hidden ' +
|
|
202
|
-
($copilotCurrentStepStore !== undefined
|
|
203
|
-
? '!bg-gray-400/20 text-black/20 border-gray-400/20'
|
|
204
|
-
: '')}
|
|
205
|
-
>
|
|
206
|
-
<Plus size="14" class="flex justify-start m-1" />
|
|
207
|
-
</button>
|
|
208
|
-
<button
|
|
209
|
-
title="Zoom Out"
|
|
210
|
-
id={`zoom_out_${canvasId}`}
|
|
211
|
-
class={'relative overflow-hidden ' +
|
|
212
|
-
($copilotCurrentStepStore !== undefined
|
|
213
|
-
? '!bg-gray-400/20 text-black/20 border-gray-400/20'
|
|
214
|
-
: '')}
|
|
215
|
-
>
|
|
216
|
-
<Minus size="14" class="flex justify-start m-1" />
|
|
217
|
-
</button>
|
|
218
|
-
|
|
219
|
-
{#if download}
|
|
220
|
-
<button on:click={() => dispatch('expand')}>
|
|
221
|
-
<Expand size="14" class="flex justify-start m-1" />
|
|
222
|
-
</button>
|
|
223
|
-
{/if}
|
|
224
|
-
</div>
|
|
225
|
-
|
|
226
|
-
<style>
|
|
227
|
-
#dataflow_toggle {
|
|
228
|
-
position: absolute;
|
|
229
|
-
top: 3px;
|
|
230
|
-
left: 8px;
|
|
231
|
-
}
|
|
232
|
-
#buttons {
|
|
233
|
-
position: absolute;
|
|
234
|
-
top: 8px;
|
|
235
|
-
right: 8px;
|
|
236
|
-
z-index: 20;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
#buttons > button {
|
|
240
|
-
border-radius: 4px;
|
|
241
|
-
--tw-bg-opacity: 1;
|
|
242
|
-
background-color: rgb(var(--color-surface) / var(--tw-bg-opacity));
|
|
243
|
-
border-width: 1px;
|
|
244
|
-
transition: all;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
.Nodes {
|
|
248
|
-
position: absolute;
|
|
249
|
-
width: 100%;
|
|
250
|
-
height: 100%;
|
|
251
|
-
}
|
|
252
|
-
.Node {
|
|
253
|
-
color: black; /* remove this once color is set to default via types */
|
|
254
|
-
width: 100%;
|
|
255
|
-
height: 100%;
|
|
256
|
-
}
|
|
257
|
-
#graphview-container {
|
|
258
|
-
pointer-events: none;
|
|
259
|
-
}
|
|
260
|
-
.pointer-events-auto {
|
|
261
|
-
pointer-events: auto;
|
|
262
|
-
}</style>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
declare const __propDef: {
|
|
3
|
-
props: {
|
|
4
|
-
canvasId: string;
|
|
5
|
-
width: number;
|
|
6
|
-
height: number;
|
|
7
|
-
boundary?: boolean | undefined;
|
|
8
|
-
scroll?: boolean | undefined;
|
|
9
|
-
dataflow?: boolean | undefined;
|
|
10
|
-
download?: boolean | undefined;
|
|
11
|
-
showDataflowToggle?: boolean | undefined;
|
|
12
|
-
};
|
|
13
|
-
events: {
|
|
14
|
-
contextmenu: MouseEvent;
|
|
15
|
-
expand: CustomEvent<any>;
|
|
16
|
-
} & {
|
|
17
|
-
[evt: string]: CustomEvent<any>;
|
|
18
|
-
};
|
|
19
|
-
slots: {};
|
|
20
|
-
};
|
|
21
|
-
export type GraphViewProps = typeof __propDef.props;
|
|
22
|
-
export type GraphViewEvents = typeof __propDef.events;
|
|
23
|
-
export type GraphViewSlots = typeof __propDef.slots;
|
|
24
|
-
export default class GraphView extends SvelteComponent<GraphViewProps, GraphViewEvents, GraphViewSlots> {
|
|
25
|
-
}
|
|
26
|
-
export {};
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
<script>const pkStringGenerator = () => (Math.random() + 1).toString(36).substring(7);
|
|
2
|
-
import { createStoreEmpty, populateSvelvetStoreFromUserInput } from '../../store/controllers/storeApi';
|
|
3
|
-
import { afterUpdate, onMount } from 'svelte';
|
|
4
|
-
import GraphView from './GraphView.svelte';
|
|
5
|
-
import { sanitizeUserNodesAndEdges } from '../controllers/middleware';
|
|
6
|
-
export let nodes;
|
|
7
|
-
export let edges;
|
|
8
|
-
export let width = 600;
|
|
9
|
-
export let height = 600;
|
|
10
|
-
export let background = true;
|
|
11
|
-
export let movement = true;
|
|
12
|
-
export let canvasId = pkStringGenerator();
|
|
13
|
-
export let snap = false;
|
|
14
|
-
export let snapTo = 30;
|
|
15
|
-
export let nodeCreate = false;
|
|
16
|
-
export let boundary = false;
|
|
17
|
-
export let locked = false; // if true, node movement is disabled
|
|
18
|
-
export let editable = false;
|
|
19
|
-
export let highlightEdges = true;
|
|
20
|
-
export let scroll = false;
|
|
21
|
-
export let download = false;
|
|
22
|
-
export let dataflow = false;
|
|
23
|
-
export let nodeSelected = false;
|
|
24
|
-
// generates a unique string for each svelvet component's unique store instance
|
|
25
|
-
// creates a store that uses the unique sting as the key to create and look up the corresponding store
|
|
26
|
-
// this way we can have multiple Svelvet Components on the same page and prevent overlap of information
|
|
27
|
-
const store = createStoreEmpty(canvasId);
|
|
28
|
-
// stores (state) within stores, so that we cannot access values from everywhere
|
|
29
|
-
// const { widthStore, heightStore, nodesStore, derivedEdges } = svelvetStore;
|
|
30
|
-
let error = '';
|
|
31
|
-
// sets the state of the store to the values passed in from the Svelvet Component on initial render
|
|
32
|
-
onMount(() => {
|
|
33
|
-
try {
|
|
34
|
-
// sanitize user input
|
|
35
|
-
let output = sanitizeUserNodesAndEdges(nodes, edges);
|
|
36
|
-
const userNodes = output['userNodes'];
|
|
37
|
-
const userEdges = output['userEdges'];
|
|
38
|
-
// set canvas related stores. you need to do this before setting node/edge related stores because
|
|
39
|
-
// initializing nodes/edges might read relevant options from the store.
|
|
40
|
-
store.widthStore.set(width);
|
|
41
|
-
store.heightStore.set(height);
|
|
42
|
-
store.backgroundStore.set(background);
|
|
43
|
-
store.movementStore.set(movement);
|
|
44
|
-
const optionsObj = { snap, snapTo }; // TODO: rename to snap
|
|
45
|
-
store.options.set(optionsObj); //
|
|
46
|
-
store.nodeCreate.set(nodeCreate);
|
|
47
|
-
store.boundary.set(boundary);
|
|
48
|
-
store.lockedOption.set(locked);
|
|
49
|
-
store.editableOption.set(editable);
|
|
50
|
-
store.highlightEdgesOption.set(highlightEdges);
|
|
51
|
-
// set node/edge related stores
|
|
52
|
-
populateSvelvetStoreFromUserInput(canvasId, userNodes, userEdges);
|
|
53
|
-
error = '';
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
error = 'There was an error displaying the flow. Please report the error.' + e.message;
|
|
57
|
-
console.error(e);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
// // enables data reactivity. TODO: this needs to be added back in
|
|
61
|
-
// Probably need to use findStore, not create store
|
|
62
|
-
afterUpdate(() => {
|
|
63
|
-
try {
|
|
64
|
-
// sanitize user input
|
|
65
|
-
let output = sanitizeUserNodesAndEdges(nodes, edges);
|
|
66
|
-
const userNodes = output['userNodes'];
|
|
67
|
-
const userEdges = output['userEdges'];
|
|
68
|
-
// set canvas related stores. you need to do this before setting node/edge related stores because
|
|
69
|
-
// initializing nodes/edges might read relevant options from the store.
|
|
70
|
-
store.widthStore.set(width);
|
|
71
|
-
store.heightStore.set(height);
|
|
72
|
-
store.backgroundStore.set(background);
|
|
73
|
-
store.movementStore.set(movement);
|
|
74
|
-
const optionsObj = { snap, snapTo }; // TODO: rename to snap
|
|
75
|
-
store.options.set(optionsObj); //
|
|
76
|
-
store.nodeCreate.set(nodeCreate);
|
|
77
|
-
store.boundary.set(boundary);
|
|
78
|
-
store.lockedOption.set(locked);
|
|
79
|
-
store.editableOption.set(editable);
|
|
80
|
-
store.highlightEdgesOption.set(highlightEdges);
|
|
81
|
-
// set node/edge related stores
|
|
82
|
-
populateSvelvetStoreFromUserInput(canvasId, userNodes, userEdges);
|
|
83
|
-
error = '';
|
|
84
|
-
}
|
|
85
|
-
catch (e) {
|
|
86
|
-
error = 'There was an error displaying the flow. Please report the error.' + e.message;
|
|
87
|
-
console.error(e);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
</script>
|
|
91
|
-
|
|
92
|
-
<!-- Now that a store has been created from the initial nodes and initial edges we drill props from the store down to the D3 GraphView along with the unique key -->
|
|
93
|
-
<div
|
|
94
|
-
class="Svelvet bg-surface-secondary"
|
|
95
|
-
style={`width: ${width}px; min-height: 100%; height: ${height}px;`}
|
|
96
|
-
>
|
|
97
|
-
{#if error != ''}
|
|
98
|
-
<div class="error text-red-600 center-center p-4">{error}</div>
|
|
99
|
-
{:else}
|
|
100
|
-
<GraphView
|
|
101
|
-
showDataflowToggle={nodeSelected}
|
|
102
|
-
bind:dataflow
|
|
103
|
-
on:expand
|
|
104
|
-
{download}
|
|
105
|
-
{scroll}
|
|
106
|
-
{canvasId}
|
|
107
|
-
{width}
|
|
108
|
-
{height}
|
|
109
|
-
{boundary}
|
|
110
|
-
/>
|
|
111
|
-
{/if}
|
|
112
|
-
</div>
|
|
113
|
-
|
|
114
|
-
<style>
|
|
115
|
-
.Svelvet {
|
|
116
|
-
position: relative;
|
|
117
|
-
overflow: hidden;
|
|
118
|
-
display: grid;
|
|
119
|
-
font-family: 'Segoe UI', sans-serif;
|
|
120
|
-
z-index: 1;
|
|
121
|
-
}</style>
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { UserEdgeType, UserNodeType } from '../../types/types';
|
|
3
|
-
declare const __propDef: {
|
|
4
|
-
props: {
|
|
5
|
-
nodes: UserNodeType[];
|
|
6
|
-
edges: UserEdgeType[];
|
|
7
|
-
width?: number | undefined;
|
|
8
|
-
height?: number | undefined;
|
|
9
|
-
background?: boolean | undefined;
|
|
10
|
-
movement?: boolean | undefined;
|
|
11
|
-
canvasId?: string | undefined;
|
|
12
|
-
snap?: boolean | undefined;
|
|
13
|
-
snapTo?: number | undefined;
|
|
14
|
-
nodeCreate?: boolean | undefined;
|
|
15
|
-
boundary?: boolean | undefined;
|
|
16
|
-
locked?: boolean | undefined;
|
|
17
|
-
editable?: boolean | undefined;
|
|
18
|
-
highlightEdges?: boolean | undefined;
|
|
19
|
-
scroll?: boolean | undefined;
|
|
20
|
-
download?: boolean | undefined;
|
|
21
|
-
dataflow?: boolean | undefined;
|
|
22
|
-
nodeSelected?: boolean | undefined;
|
|
23
|
-
};
|
|
24
|
-
events: {
|
|
25
|
-
expand: CustomEvent<any>;
|
|
26
|
-
} & {
|
|
27
|
-
[evt: string]: CustomEvent<any>;
|
|
28
|
-
};
|
|
29
|
-
slots: {};
|
|
30
|
-
};
|
|
31
|
-
export type SvelvetProps = typeof __propDef.props;
|
|
32
|
-
export type SvelvetEvents = typeof __propDef.events;
|
|
33
|
-
export type SvelvetSlots = typeof __propDef.slots;
|
|
34
|
-
export default class Svelvet extends SvelteComponent<SvelvetProps, SvelvetEvents, SvelvetSlots> {
|
|
35
|
-
}
|
|
36
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// Required for "custom css" feature
|
|
2
|
-
// WHAT: For a given node with a user-defined classname, see if there are any css properties for height and width
|
|
3
|
-
// Get that height and width and set properties in node store. This is necessary for
|
|
4
|
-
export const forceCssHeightAndWidth = (store, node) => {
|
|
5
|
-
let width, height, innerText;
|
|
6
|
-
// Look through each CSS rule to find the one the user defined
|
|
7
|
-
for (let i = 0; i < document.styleSheets.length; i++) {
|
|
8
|
-
const styleSheet = document.styleSheets[i];
|
|
9
|
-
const styleRules = styleSheet.cssRules;
|
|
10
|
-
for (let j = 0; j < styleRules.length; j++) {
|
|
11
|
-
const rule = styleRules[j];
|
|
12
|
-
// this is necessary to get rid of typescript warning for rule.selectorText
|
|
13
|
-
if (!(rule instanceof CSSStyleRule))
|
|
14
|
-
continue;
|
|
15
|
-
if (rule.selectorText === `.${node.className}`) {
|
|
16
|
-
const initialText = rule.cssText; // getting the full text of the CSS rule
|
|
17
|
-
const i = initialText.indexOf('{'); // finding index of first bracket
|
|
18
|
-
innerText = initialText.substring(i + 1, initialText.length - 1); // extracting the CSS to insert into inline style
|
|
19
|
-
// Adjusting the width and height if they are set via the custom class
|
|
20
|
-
const arr = innerText.split(' ');
|
|
21
|
-
arr.forEach((str, i) => {
|
|
22
|
-
if (str === 'width:') {
|
|
23
|
-
width = str.concat(arr[i + 1]); // go through the array and join width and the number
|
|
24
|
-
const w = parseInt(arr[i + 1]); // getting the number for the width
|
|
25
|
-
width = w;
|
|
26
|
-
}
|
|
27
|
-
if (str === 'height:') {
|
|
28
|
-
height = str.concat(arr[i + 1]); // same as with the width
|
|
29
|
-
const h = parseInt(arr[i + 1]);
|
|
30
|
-
height = h;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// update the width/height of the node
|
|
37
|
-
store.nodesStore.update((nodes) => {
|
|
38
|
-
if (width !== undefined)
|
|
39
|
-
nodes[node.id].width = width;
|
|
40
|
-
if (height !== undefined)
|
|
41
|
-
nodes[node.id].height = height;
|
|
42
|
-
return { ...nodes };
|
|
43
|
-
});
|
|
44
|
-
// move the node a bit to force update to anchors, potential anchors
|
|
45
|
-
node.setPositionFromMovement(0, 0);
|
|
46
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ZoomBehavior } from 'd3-zoom';
|
|
2
|
-
export declare function zoomInit(d3: any, canvasId: any, d3Zoom: any, d3Translate: any, initialLocation: any, initialZoom: any, d3Scale: any): any;
|
|
3
|
-
export declare function determineD3Instance(boundary: any, d3: {
|
|
4
|
-
zoom: () => ZoomBehavior<any, any>;
|
|
5
|
-
}, nodeSelected: any, width: any, height: any, movementStore: any, backgroundStore: any, gridSize: any, dotSize: any, canvasId: any, d3Scale: any, handleZoom: any): ZoomBehavior<any, any>;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { get } from 'svelte/store';
|
|
2
|
-
export function zoomInit(d3, canvasId, d3Zoom, d3Translate, initialLocation, initialZoom, d3Scale) {
|
|
3
|
-
//set default zoom logic
|
|
4
|
-
d3.select(`.Edges-${canvasId}`)
|
|
5
|
-
//makes sure translation is default at center coordinates
|
|
6
|
-
.transition()
|
|
7
|
-
.duration(0)
|
|
8
|
-
.call(d3Zoom.translateTo, 0, 0)
|
|
9
|
-
//moves camera to coordinates
|
|
10
|
-
.transition()
|
|
11
|
-
.duration(0)
|
|
12
|
-
.call(d3Zoom.translateTo, initialLocation.x / initialZoom, initialLocation.y / initialZoom)
|
|
13
|
-
// zooms in on selected point
|
|
14
|
-
.transition()
|
|
15
|
-
.duration(0)
|
|
16
|
-
.call(d3Zoom.scaleTo, initialZoom.toFixed(2));
|
|
17
|
-
// updates d3Translate with d3 object with x, y, and k values to be sent down to the minimap to be further calculated further
|
|
18
|
-
d3Translate = d3.zoomIdentity
|
|
19
|
-
.translate(initialLocation.x, initialLocation.y)
|
|
20
|
-
.scale(initialZoom.toFixed(2));
|
|
21
|
-
d3.select(`.Nodes-${canvasId}`)
|
|
22
|
-
.transition()
|
|
23
|
-
.duration(0)
|
|
24
|
-
.call(d3Zoom.translateTo, 0, 0)
|
|
25
|
-
.transition()
|
|
26
|
-
.duration(0)
|
|
27
|
-
.call(d3Zoom.translateTo, initialLocation.x / initialZoom, initialLocation.y / initialZoom)
|
|
28
|
-
.transition()
|
|
29
|
-
.duration(0)
|
|
30
|
-
.call(d3Zoom.scaleTo, initialZoom.toFixed(2));
|
|
31
|
-
// sets D3 scale to current k of object
|
|
32
|
-
d3Scale.set(d3.zoomTransform(d3.select(`.Nodes-${canvasId}`)).k);
|
|
33
|
-
return d3Translate;
|
|
34
|
-
}
|
|
35
|
-
// create d3 instance conditionally based on boundary prop
|
|
36
|
-
export function determineD3Instance(boundary, d3, nodeSelected, width, height, movementStore, backgroundStore, gridSize, dotSize, canvasId, d3Scale, handleZoom) {
|
|
37
|
-
if (boundary) {
|
|
38
|
-
return d3
|
|
39
|
-
.zoom()
|
|
40
|
-
.filter(() => !get(nodeSelected))
|
|
41
|
-
.scaleExtent([0.4, 4]) // limits for zooming in/out
|
|
42
|
-
.translateExtent([
|
|
43
|
-
[0, 0],
|
|
44
|
-
[boundary.x, boundary.y],
|
|
45
|
-
]) // world extent
|
|
46
|
-
.extent([
|
|
47
|
-
[0, 0],
|
|
48
|
-
[width, height],
|
|
49
|
-
])
|
|
50
|
-
.on('zoom', handleZoom);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
return d3
|
|
54
|
-
.zoom()
|
|
55
|
-
.filter(() => !get(nodeSelected))
|
|
56
|
-
.scaleExtent([0.4, 2])
|
|
57
|
-
.on('zoom', handleZoom);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { AnchorCbType } from '../../edges/types/types';
|
|
2
|
-
import type { StoreType } from '../../store/types/types';
|
|
3
|
-
export declare function fixedCbCreator(store: StoreType, edgeId: string, anchorId: string, userNodeId: string, positionCb: Function): AnchorCbType;
|
|
4
|
-
export declare function dynamicCbCreator(store: StoreType, edgeId: string, anchorId: string): AnchorCbType;
|