diff --git a/.gitignore b/.gitignore index 72cf9624..733f8f6e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ examples/build cypress/videos cypress/screenshots dist -.env \ No newline at end of file +.env +stats.html \ No newline at end of file diff --git a/README.md b/README.md index 57ccb09a..6ced9125 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ React Flow is a library for building node-based graphs. You can easily implement - [Key Features](#key-features) - [Installation](#installation) - [Usage](#usage) -- [ReactFlow Component Props](#reactflow-component-props) +- [ReactFlow Component Prop Types](#reactflow-component-prop-types) - [Styling](#styling) - [Nodes](#nodes) - [Options](#options-1) @@ -62,7 +62,7 @@ const BasicFlow = () => ( ); ``` -## ReactFlow Component Props +## ReactFlow Component Prop Types - `elements`: array of [nodes](#nodes) and [edges](#edges) *(required)* - `onElementClick`: element click handler @@ -249,20 +249,34 @@ import ReactFlow, { isNode, isEdge, removeElements, addEdge } from 'react-flow-r #### isEdge -`isEdge = (element: Node | Edge): boolean` +Returns true if element is an edge + +`isEdge = (element: Node | Edge): element is Edge` #### isNode -`isNode = (element: Node | Edge): boolean` +Returns true if element is a node + +`isNode = (element: Node | Edge): element is Node` #### removeElements +Returns elements without the elements from `elementsToRemove` + `removeElements = (elementsToRemove: Elements, elements: Elements): Elements` #### addEdge +Returns elements array with added edge + `addEdge = (edgeParams: Edge, elements: Elements): Elements` +#### project + +Transforms pixel coordinates to the internal React Flow coordinate system + +`project = (position: XYPosition): XYPosition` + You can use these function as seen in [this example](/example/src/Overview/index.js#L40-L41) or use your own ones. ## Plugins diff --git a/cypress/integration/flow/basic.spec.js b/cypress/integration/flow/basic.spec.js index ae69e220..46e2aed7 100644 --- a/cypress/integration/flow/basic.spec.js +++ b/cypress/integration/flow/basic.spec.js @@ -3,6 +3,7 @@ describe('Basic Graph Rendering', () => { cy.visit('/basic'); cy.get('.react-flow__renderer'); + cy.get('.react-flow-basic-example'); // check if className prop works cy.get('.react-flow__node').should('have.length', 4); cy.get('.react-flow__edge').should('have.length', 2); cy.get('.react-flow__node').children('div').children('.react-flow__handle'); diff --git a/example/package-lock.json b/example/package-lock.json index 8ab267cc..d72cffdc 100644 --- a/example/package-lock.json +++ b/example/package-lock.json @@ -10701,13 +10701,13 @@ "react-flow-renderer": { "version": "file:..", "requires": { - "@welldone-software/why-did-you-render": "^4.2.0", + "@welldone-software/why-did-you-render": "^4.2.1", "classnames": "^2.2.6", "d3-selection": "^1.4.1", "d3-zoom": "^1.8.3", "easy-peasy": "^3.3.0", "fast-deep-equal": "^3.1.1", - "react-draggable": "^4.3.1", + "react-draggable": "^4.4.2", "resize-observer": "^1.0.0" }, "dependencies": { diff --git a/example/src/Basic/index.js b/example/src/Basic/index.js index 5edc5ce6..002ef268 100644 --- a/example/src/Basic/index.js +++ b/example/src/Basic/index.js @@ -49,6 +49,7 @@ const BasicFlow = () => { onNodeDragStop={onNodeDragStop} style={{ width: '100%', height: '100%' }} backgroundType="lines" + className="react-flow-basic-example" >