Merge branch 'main' of github.com:wbkd/react-flow into main

This commit is contained in:
moklick
2020-10-06 17:34:39 +02:00
10 changed files with 40 additions and 8 deletions
+14
View File
@@ -131,6 +131,12 @@ const BasicFlow = () => <ReactFlow elements={elements} />;
- `deleteKeyCode`: default: `8` (delete) - `deleteKeyCode`: default: `8` (delete)
- `selectionKeyCode`: default: `16` (shift) - `selectionKeyCode`: default: `16` (shift)
**Typescript:** The interface of the ReactFlow Prop Types are exported as `ReactFlowProps`. You can use it in your code as follows:
```javascript
import { ReactFlowProps } from 'react-flow-renderer';
```
## React Flow Instance ## React Flow Instance
You can receive a `reactFlowInstance` by using the `onLoad` callback: You can receive a `reactFlowInstance` by using the `onLoad` callback:
@@ -272,6 +278,8 @@ const targetHandleWithValidation = (
- `style`: css properties - `style`: css properties
- `className`: additional class name - `className`: additional class name
**Typescript:** The interface of the Handle Prop Types are exported as `HandleProps`.
### Validation ### Validation
The handle receives the additional class names `connecting` when the connection line is above the handle and `valid` if the connection is valid. You can find an example which uses these classes [here](/example/src/Validation/index.js). The handle receives the additional class names `connecting` when the connection line is above the handle and `valid` if the connection is valid. You can find an example which uses these classes [here](/example/src/Validation/index.js).
@@ -413,6 +421,8 @@ const FlowWithBackground = () => (
- `style`: css properties - `style`: css properties
- `className`: additional class name - `className`: additional class name
**Typescript:** The interface of the Background Prop Types are exported as `BackgroundProps`.
## MiniMap ## MiniMap
You can use the mini map plugin by passing it as a children to the `ReactFlow` component: You can use the mini map plugin by passing it as a children to the `ReactFlow` component:
@@ -446,6 +456,8 @@ const FlowWithMiniMap = () => (
- `style`: css properties - `style`: css properties
- `className`: additional class name - `className`: additional class name
**Typescript:** The interface of the MiniMap Prop Types are exported as `MiniMapProps`.
## Controls ## Controls
The control panel contains a zoom-in, zoom-out, fit-view and a lock/unlock button. You can use it by passing it as a children to the `ReactFlow` component: The control panel contains a zoom-in, zoom-out, fit-view and a lock/unlock button. You can use it by passing it as a children to the `ReactFlow` component:
@@ -472,6 +484,8 @@ const FlowWithControls = () => (
- `style`: css properties - `style`: css properties
- `className`: additional class name - `className`: additional class name
**Typescript:** The interface of the Controls Prop Types are exported as `ControlProps`.
## ReactFlowProvider ## ReactFlowProvider
If you need access to the internal state and action of React Flow outside of the `ReactFlow` component you can wrap it with the `ReactFlowProvider` component: If you need access to the internal state and action of React Flow outside of the `ReactFlow` component you can wrap it with the `ReactFlowProvider` component:
@@ -7,7 +7,7 @@ import { createGridLinesPath, createGridDotsPath } from './utils';
import './style.css'; import './style.css';
interface BackgroundProps extends HTMLAttributes<SVGElement> { export interface BackgroundProps extends HTMLAttributes<SVGElement> {
variant?: BackgroundVariant; variant?: BackgroundVariant;
gap?: number; gap?: number;
color?: string; color?: string;
+1 -1
View File
@@ -11,7 +11,7 @@ import UnlockIcon from '../../../assets/icons/unlock.svg';
import './style.css'; import './style.css';
interface ControlProps extends React.HTMLAttributes<HTMLDivElement> { export interface ControlProps extends React.HTMLAttributes<HTMLDivElement> {
showZoom?: boolean; showZoom?: boolean;
showFitView?: boolean; showFitView?: boolean;
showInteractive?: boolean; showInteractive?: boolean;
+1 -1
View File
@@ -10,7 +10,7 @@ import './style.css';
type StringFunc = (node: Node) => string; type StringFunc = (node: Node) => string;
interface MiniMapProps extends React.HTMLAttributes<SVGSVGElement> { export interface MiniMapProps extends React.HTMLAttributes<SVGSVGElement> {
nodeColor?: string | StringFunc; nodeColor?: string | StringFunc;
nodeStrokeColor?: string | StringFunc; nodeStrokeColor?: string | StringFunc;
nodeClassName?: string | StringFunc; nodeClassName?: string | StringFunc;
+6 -2
View File
@@ -1,7 +1,6 @@
import ReactFlow from './container/ReactFlow'; import ReactFlow from './container/ReactFlow';
export default ReactFlow; export default ReactFlow;
export { ReactFlowProps } from './container/ReactFlow';
export { default as Handle } from './components/Handle'; export { default as Handle } from './components/Handle';
export { default as EdgeText } from './components/Edges/EdgeText'; export { default as EdgeText } from './components/Edges/EdgeText';
@@ -12,5 +11,10 @@ export { getMarkerEnd, getCenter as getEdgeCenter } from './components/Edges/uti
export { isNode, isEdge, removeElements, addEdge, getOutgoers, getIncomers, getConnectedEdges } from './utils/graph'; export { isNode, isEdge, removeElements, addEdge, getOutgoers, getIncomers, getConnectedEdges } from './utils/graph';
export * from './additional-components'; export * from './additional-components';
export * from './types';
export * from './store/hooks'; export * from './store/hooks';
export * from './types';
export { ReactFlowProps } from './container/ReactFlow';
export { MiniMapProps } from './additional-components/MiniMap';
export { ControlProps } from './additional-components/Controls';
export { BackgroundProps } from './additional-components/Background';
@@ -71,3 +71,9 @@ import ReactFlow from 'react-flow-renderer';
### Keys ### Keys
- `deleteKeyCode`: default: `8` (backspace) - `deleteKeyCode`: default: `8` (backspace)
- `selectionKeyCode`: default: `16` (shift) - `selectionKeyCode`: default: `16` (shift)
**Typescript:** The interface of the ReactFlow Prop Types are exported as `ReactFlowProps`. You can use it in your code as follows:
```javascript
import { ReactFlowProps } from 'react-flow-renderer';
```
@@ -29,3 +29,5 @@ const FlowWithBackground = () => (
- `color`: string - the color of the dots or lines - default: `#81818a` for dots, `#eee` for lines - `color`: string - the color of the dots or lines - default: `#81818a` for dots, `#eee` for lines
- `style`: css properties - `style`: css properties
- `className`: additional class name - `className`: additional class name
**Typescript:** The interface of the Background Prop Types are exported as `BackgroundProps`.
@@ -23,3 +23,5 @@ const FlowWithControls = () => (
- `showInteractive`: boolean - default: true - `showInteractive`: boolean - default: true
- `style`: css properties - `style`: css properties
- `className`: additional class name - `className`: additional class name
**Typescript:** The interface of the Controls Prop Types are exported as `ControlProps`.
@@ -34,3 +34,5 @@ const FlowWithMiniMap = () => (
- `maskColor`: string - `maskColor`: string
- `style`: css properties - `style`: css properties
- `className`: additional class name - `className`: additional class name
**Typescript:** The interface of the MiniMap Prop Types are exported as `MiniMapProps`.
+2
View File
@@ -28,6 +28,8 @@ const targetHandleWithValidation = (
- `style`: css properties - `style`: css properties
- `className`: additional class name - `className`: additional class name
**Typescript:** The interface of the Handle Prop Types are exported as `HandleProps`.
### Validation ### Validation
The handle receives the additional class names `connecting` when the connection line is above the handle and `valid` if the connection is valid. You can find an example which uses these classes [here](/examples/validation). The handle receives the additional class names `connecting` when the connection line is above the handle and `valid` if the connection is valid. You can find an example which uses these classes [here](/examples/validation).