@xyflow/svelte
Advanced tools
Comparing version 0.0.32 to 0.0.33
import { type Writable } from 'svelte/store'; | ||
import { type FitBoundsOptions, type SetCenterOptions, type Viewport, type ViewportHelperFunctionOptions, type XYPosition, type ZoomInOut, type Rect, type OnBeforeDelete } from '@xyflow/system'; | ||
import { type FitBoundsOptions, type SetCenterOptions, type Viewport, type ViewportHelperFunctionOptions, type XYPosition, type ZoomInOut, type Rect } from '@xyflow/system'; | ||
import type { Edge, FitViewOptions, Node } from '../types'; | ||
@@ -26,7 +26,10 @@ /** | ||
fitBounds: (bounds: Rect, options?: FitBoundsOptions) => void; | ||
deleteElements: (nodesToRemove?: (Node | { | ||
id: Node['id']; | ||
})[], edgesToRemove?: (Edge | { | ||
id: Edge['id']; | ||
})[], onBeforeDelete?: OnBeforeDelete) => Promise<{ | ||
deleteElements: ({ nodes, edges }: { | ||
nodes?: (Node | { | ||
id: Node['id']; | ||
})[]; | ||
edges?: (Edge | { | ||
id: Edge['id']; | ||
})[]; | ||
}) => Promise<{ | ||
deletedNodes: Node[]; | ||
@@ -33,0 +36,0 @@ deletedEdges: Edge[]; |
@@ -84,3 +84,3 @@ import { get } from 'svelte/store'; | ||
}, | ||
deleteElements: async (nodesToRemove = [], edgesToRemove = [], onBeforeDelete) => { | ||
deleteElements: async ({ nodes: nodesToRemove = [], edges: edgesToRemove = [] }) => { | ||
const { nodes: matchingNodes, edges: matchingEdges } = await getElementsToRemove({ | ||
@@ -91,3 +91,3 @@ nodesToRemove, | ||
edges: get(edges), | ||
onBeforeDelete | ||
onBeforeDelete: get(onbeforedelete) | ||
}); | ||
@@ -94,0 +94,0 @@ if (matchingNodes) { |
@@ -11,2 +11,3 @@ import type { PanelPosition } from '@xyflow/system'; | ||
buttonColorHover?: string; | ||
'aria-label'?: string; | ||
}; |
@@ -112,26 +112,19 @@ import { getContext, setContext } from 'svelte'; | ||
} | ||
function resetSelectedItem(ids) { | ||
return (item) => { | ||
if (item.selected && ids.includes(item.id)) { | ||
return { | ||
...item, | ||
selected: false | ||
}; | ||
function resetSelectedElements(elements) { | ||
let elementsChanged = false; | ||
elements.forEach((element) => { | ||
if (element.selected) { | ||
element.selected = false; | ||
elementsChanged = true; | ||
} | ||
return item; | ||
}; | ||
}); | ||
return elementsChanged; | ||
} | ||
function unselectNodesAndEdges(params) { | ||
const selectedNodeIds = (params?.nodes ? params.nodes : get(store.nodes)) | ||
.filter((node) => node.selected) | ||
.map((node) => node.id); | ||
const selectedEdgeIds = (params?.edges ? params.edges : get(store.edges)) | ||
.filter((edge) => edge.selected) | ||
.map((edge) => edge.id); | ||
if (selectedNodeIds.length) { | ||
store.nodes.update((ns) => ns.map(resetSelectedItem(selectedNodeIds))); | ||
} | ||
if (selectedEdgeIds.length) { | ||
store.edges.update((es) => es.map(resetSelectedItem(selectedEdgeIds))); | ||
} | ||
const resetNodes = resetSelectedElements(params?.nodes || get(store.nodes)); | ||
if (resetNodes) | ||
store.nodes.set(get(store.nodes)); | ||
const resetEdges = resetSelectedElements(params?.edges || get(store.edges)); | ||
if (resetEdges) | ||
store.edges.set(get(store.edges)); | ||
} | ||
@@ -138,0 +131,0 @@ store.deleteKeyPressed.subscribe(async (deleteKeyPressed) => { |
/// <reference types="svelte" /> | ||
import { SelectionMode, ConnectionMode, ConnectionLineType, type SelectionRect, type SnapGrid, type MarkerProps, type PanZoomInstance, type CoordinateExtent, type IsValidConnection, type NodeOrigin, type OnError, type Viewport, type ConnectionLookup, type OnConnect, type OnConnectStart, type OnConnectEnd, type NodeLookup, type OnBeforeDelete } from '@xyflow/system'; | ||
import { SelectionMode, ConnectionMode, ConnectionLineType, type SelectionRect, type SnapGrid, type MarkerProps, type PanZoomInstance, type CoordinateExtent, type IsValidConnection, type NodeOrigin, type OnError, type Viewport, type ConnectionLookup, type OnConnect, type OnConnectStart, type OnConnectEnd, type NodeLookup, type OnBeforeDelete, type EdgeLookup } from '@xyflow/system'; | ||
import DefaultNode from '../components/nodes/DefaultNode.svelte'; | ||
@@ -38,2 +38,3 @@ import InputNode from '../components/nodes/InputNode.svelte'; | ||
nodeLookup: import("svelte/store").Readable<NodeLookup>; | ||
edgeLookup: import("svelte/store").Readable<EdgeLookup>; | ||
visibleNodes: import("svelte/store").Readable<Node[]>; | ||
@@ -40,0 +41,0 @@ edges: import("svelte/store").Writable<Edge[]> & { |
@@ -41,2 +41,3 @@ import { readable, writable } from 'svelte/store'; | ||
nodeLookup: readable(nodeLookup), | ||
edgeLookup: readable(edgeLookup), | ||
visibleNodes: readable([]), | ||
@@ -43,0 +44,0 @@ edges: createEdgesStore(edges, connectionLookup, edgeLookup), |
{ | ||
"name": "@xyflow/svelte", | ||
"version": "0.0.32", | ||
"version": "0.0.33", | ||
"description": "Svelte Flow - A highly customizable Svelte library for building node-based editors, workflow systems, diagrams and more.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
255904
4189