fix linting, formatting
This commit is contained in:
@@ -110,6 +110,7 @@
|
||||
let prevConnections: Map<string, HandleConnection> | null = null;
|
||||
$effect.pre(() => {
|
||||
// connectionLookup is not reactive, so we use edges to get notified about updates
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
$edges;
|
||||
if (onconnect || ondisconnect) {
|
||||
let connections = $connectionLookup.get(`${nodeId}-${type}-${handleId}`);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
let bounds: Rect | null = $derived.by(() => {
|
||||
if ($selectionRectMode === 'nodes') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
$nodes;
|
||||
return getInternalNodesBounds($nodeLookup, { filter: (node) => !!node.selected });
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { setContext, onDestroy } from 'svelte';
|
||||
import { get, writable } from 'svelte/store';
|
||||
import { get } from 'svelte/store';
|
||||
import cc from 'classcat';
|
||||
import { errorMessages, Position } from '@xyflow/system';
|
||||
|
||||
@@ -132,12 +132,13 @@
|
||||
|
||||
// TODO: extract this part!
|
||||
$effect(() => {
|
||||
// TODO: HOLY MOLY! changing the order of the initialized breaks effect subscriptions
|
||||
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
||||
if (resizeObserver && (!initialized || nodeRef !== prevNodeRef)) {
|
||||
prevNodeRef && resizeObserver.unobserve(prevNodeRef);
|
||||
nodeRef && resizeObserver.observe(nodeRef);
|
||||
prevNodeRef = nodeRef;
|
||||
}
|
||||
/* eslint-enable @typescript-eslint/no-unused-expressions */
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
initialWidth,
|
||||
initialHeight,
|
||||
nodeOrigin,
|
||||
fitView
|
||||
fitView,
|
||||
children
|
||||
}: SvelteFlowProviderProps = $props();
|
||||
|
||||
const store = createStore({
|
||||
@@ -31,4 +32,4 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<slot />
|
||||
{@render children?.()}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { Edge, Node } from '$lib/types';
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { NodeOrigin } from '@xyflow/system';
|
||||
import type { Edge, Node } from '$lib/types';
|
||||
|
||||
export type SvelteFlowProviderProps = {
|
||||
initialNodes?: Node[];
|
||||
@@ -8,4 +9,5 @@ export type SvelteFlowProviderProps = {
|
||||
initialHeight?: number;
|
||||
fitView?: boolean;
|
||||
nodeOrigin?: NodeOrigin;
|
||||
children?: Snippet;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { NodeProps } from '$lib/types';
|
||||
|
||||
// eslint-disable-next-line no-empty-pattern
|
||||
let {}: NodeProps = $props();
|
||||
</script>
|
||||
|
||||
@@ -254,7 +254,6 @@
|
||||
<Pane {nodes} {edges} {onpaneclick} {onpanecontextmenu} {panOnDrag} {selectionOnDrag}>
|
||||
<ViewportComponent>
|
||||
<EdgeRenderer
|
||||
on:edgeclick
|
||||
{onedgeclick}
|
||||
{onedgecontextmenu}
|
||||
{onedgemouseenter}
|
||||
|
||||
@@ -42,7 +42,7 @@ export function useNodesData(nodeIds: any): any {
|
||||
|
||||
if (!shallowNodeData(nextNodesData, prevNodesData) || initialRun) {
|
||||
prevNodesData = nextNodesData;
|
||||
set(isArrayOfIds ? nextNodesData : nextNodesData[0] ?? null);
|
||||
set(isArrayOfIds ? nextNodesData : (nextNodesData[0] ?? null));
|
||||
initialRun = false;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
getBoundsOfRects,
|
||||
getInternalNodesBounds,
|
||||
getNodeDimensions,
|
||||
nodeHasDimensions,
|
||||
type Rect
|
||||
nodeHasDimensions
|
||||
} from '@xyflow/system';
|
||||
|
||||
import { useStore } from '$lib/store';
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
const contextNodeId = getContext<string>('svelteflow__node_id');
|
||||
|
||||
let toolbarNodes: InternalNode[] = $derived.by(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
$nodes;
|
||||
const nodeIds = Array.isArray(nodeId) ? nodeId : [nodeId ?? contextNodeId];
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import { derived, get, writable } from 'svelte/store';
|
||||
import {
|
||||
createMarkerIds,
|
||||
fitView as fitViewSystem,
|
||||
getElementsToRemove,
|
||||
panBy as panBySystem,
|
||||
updateNodeInternals as updateNodeInternalsSystem,
|
||||
addEdge as addEdgeUtil,
|
||||
|
||||
@@ -127,6 +127,8 @@ export type NodeStoreOptions = {
|
||||
elevateNodesOnSelect?: boolean;
|
||||
};
|
||||
|
||||
type Update<T> = Writable<T>['update'];
|
||||
|
||||
// we are creating a custom store for the internals nodes in order to update the zIndex and positionAbsolute.
|
||||
// The user only passes in relative positions, so we need to calculate the absolute positions based on the parent nodes.
|
||||
export const createNodesStore = (
|
||||
@@ -142,7 +144,7 @@ export const createNodesStore = (
|
||||
setDefaultOptions: (opts: DefaultNodeOptions) => void;
|
||||
setOptions: (opts: NodeStoreOptions) => void;
|
||||
} => {
|
||||
const { subscribe, set, update } = writable<Node[]>([]);
|
||||
const { subscribe, set } = writable<Node[]>([]);
|
||||
let value = nodes;
|
||||
let defaults = {};
|
||||
let elevateNodesOnSelect = true;
|
||||
@@ -163,7 +165,7 @@ export const createNodesStore = (
|
||||
return value;
|
||||
};
|
||||
|
||||
const _update: typeof update = (fn: (nds: Node[]) => Node[]) => _set(fn(value));
|
||||
const _update: Update<Node[]> = (fn: (nds: Node[]) => Node[]) => _set(fn(value));
|
||||
|
||||
const setDefaultOptions = (options: DefaultNodeOptions) => {
|
||||
defaults = options;
|
||||
@@ -190,7 +192,7 @@ export const createEdgesStore = (
|
||||
edgeLookup: EdgeLookup<Edge>,
|
||||
defaultOptions?: DefaultEdgeOptions
|
||||
): Writable<Edge[]> & { setDefaultOptions: (opts: DefaultEdgeOptions) => void } => {
|
||||
const { subscribe, set, update } = writable<Edge[]>([]);
|
||||
const { subscribe, set } = writable<Edge[]>([]);
|
||||
let value = edges;
|
||||
let defaults = defaultOptions || {};
|
||||
|
||||
@@ -203,7 +205,7 @@ export const createEdgesStore = (
|
||||
set(value);
|
||||
};
|
||||
|
||||
const _update: typeof update = (fn: (eds: Edge[]) => Edge[]) => _set(fn(value));
|
||||
const _update: Update<Edge[]> = (fn: (eds: Edge[]) => Edge[]) => _set(fn(value));
|
||||
|
||||
const setDefaultOptions = (options: DefaultEdgeOptions) => {
|
||||
defaults = options;
|
||||
|
||||
Reference in New Issue
Block a user