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