UNPKG

@cnvx/nodal

Version:

A Svelte 5 library for creating interactive node diagrams with customizable connections and layouts

33 lines (32 loc) 1.28 kB
import type { Attachment } from "svelte/attachments"; import type { HTMLAttributes } from "svelte/elements"; import { SvelteMap } from "svelte/reactivity"; import { type Writable } from "svelte/store"; import type { SurfaceEdge, SurfaceEdgeParams } from "./Surface.svelte"; import type { Vector2 } from "./diagram-lib.js"; type IndividualConnectActionParam = string | (SurfaceEdgeParams & { target: string | string[]; }) | (SurfaceEdgeParams & { source: string | string[]; }); interface NodalSurfaceElement extends HTMLElement { _nodalSurface: { internals: { width: Writable<number> | undefined; height: Writable<number> | undefined; edges: SvelteMap<string, SurfaceEdge>; }; schedule: () => void; }; } export declare function createNodal({ svgAttributes, getNodeAnchor, fadeInDuration, onMount, }?: Partial<{ svgAttributes: HTMLAttributes<SVGElement>; onMount: (engine: NodalSurfaceElement["_nodalSurface"]) => void; getNodeAnchor: (node: HTMLElement, anchor: Vector2, svgElement: SVGElement) => { top: number; left: number; }; fadeInDuration: number; }>): Attachment; export declare function connectTo(...edges: IndividualConnectActionParam[]): Attachment; export {};