UNPKG

@xyflow/svelte

Version:

Svelte Flow - A highly customizable Svelte library for building node-based editors, workflow systems, diagrams and more.

27 lines (26 loc) 1.01 kB
import { isNodeBase, isEdgeBase } from '@xyflow/system'; /** * Test whether an object is usable as a Node * @public * @remarks In TypeScript this is a type guard that will narrow the type of whatever you pass in to Node if it returns true * @param element - The element to test * @returns A boolean indicating whether the element is an Node */ export const isNode = (element) => isNodeBase(element); /** * Test whether an object is usable as an Edge * @public * @remarks In TypeScript this is a type guard that will narrow the type of whatever you pass in to Edge if it returns true * @param element - The element to test * @returns A boolean indicating whether the element is an Edge */ export const isEdge = (element) => isEdgeBase(element); export function toPxString(value) { return value === undefined ? undefined : `${value}px`; } export const arrowKeyDiffs = { ArrowUp: { x: 0, y: -1 }, ArrowDown: { x: 0, y: 1 }, ArrowLeft: { x: -1, y: 0 }, ArrowRight: { x: 1, y: 0 } };