UNPKG

@delove/reaflow

Version:

Node-based Visualizations for React

38 lines (37 loc) 1.42 kB
import { EdgeData, NodeData } from '../types'; import { ElkNode } from 'elkjs/lib/elk.bundled.js'; import PCancelable from 'p-cancelable'; export type CanvasDirection = 'LEFT' | 'RIGHT' | 'DOWN' | 'UP'; /** * ELKjs layout options for the Canvas. * * Unfortunately, the ELKjs documentation is not straightforward. * You'll likely need to take a look at the ELK options reference to see all available options. * * @see https://github.com/kieler/elkjs#layout-options * @see https://www.eclipse.org/elk/reference/options.html */ export interface ElkCanvasLayoutOptions { 'elk.direction'?: CanvasDirection; [key: string]: string; } /** * ELKjs layout option for a node. * * TODO add reference link, I don't know what are the available options. * * @see https://www.eclipse.org/elk/reference/options.html */ export interface ElkNodeLayoutOptions { [key: string]: string; /** * @example [left=12, top=12, right=12, bottom=12] * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-padding.html */ 'elk.padding': string; /** * @see https://www.eclipse.org/elk/reference/options/org-eclipse-elk-portConstraints.html */ portConstraints: 'UNDEFINED' | 'FREE' | 'FIXED_SIDE' | 'FIXED_ORDER' | 'FIXED_RATIO' | 'FIXED_POS'; } export declare const elkLayout: (nodes: NodeData[], edges: EdgeData[], options: ElkCanvasLayoutOptions) => PCancelable<ElkNode>;