@joint/react
Version:
React bindings and hooks for JointJS to build interactive diagrams and graphs.
55 lines (54 loc) • 2.33 kB
TypeScript
import type { dia } from '@joint/core';
import type { GraphLink } from '../../types/link-types';
import type { GraphElement } from '../../types/element-types';
interface Options {
readonly graph: dia.Graph;
readonly initialLinks?: Array<dia.Link | GraphLink>;
readonly initialElements?: Array<dia.Element | GraphElement>;
}
/**
* Process a link: convert GraphLink to a standard JointJS link if needed.
* @param link - The link to process.
* @group utils
* @description
* This function is used to process a link and convert it to a standard JointJS link if needed.
* It also converts the source and target of the link to a standard format.
* @returns
* A standard JointJS link or a JSON representation of the link.
*/
export declare function processLink(link: dia.Link | GraphLink): dia.Link | dia.Cell.JSON;
/**
* Set links to the graph.
* @param options - The options for setting links.
* @group utils
* @description
* This function is used to set links to the graph.
* It processes the links and adds them to the graph.
* It also converts the source and target of the links to a standard format.
*/
export declare function setLinks(options: Options): void;
/**
* Process an element: create a ReactElement if applicable, otherwise a standard Cell.
* @param element - The element to process.
* @param unsizedIds - A set of unsized element IDs.
* @returns A standard JointJS element or a JSON representation of the element.
* @group utils
* @description
* This function is used to process an element and convert it to a standard JointJS element if needed.
* It also checks if the element is a ReactElement and if it has a size.
* If the element is a ReactElement and has no size, it adds its ID to the unsizedIds set.
* @private
*/
export declare function processElement<T extends dia.Element | GraphElement>(element: T, unsizedIds?: Set<string>): dia.Element | dia.Cell.JSON;
/**
* Set elements to the graph.
* @param options - The options for setting elements.
* @group utils
* @description
* This function is used to set elements to the graph.
* @returns A set of unsized element IDs.
* It processes the elements and adds them to the graph.
* It also checks for unsized elements and returns their IDs.
*/
export declare function setElements(options: Options): Set<string>;
export {};