Merge branch 'master' of github.com:wbkd/react-graph

This commit is contained in:
moklick
2019-07-29 22:11:58 +02:00
34 changed files with 43948 additions and 102 deletions

View File

@@ -1,18 +1,20 @@
import React, { PureComponent } from 'react';
import Graph, { isEdge, removeElements, getOutgoers } from '../src';
import Graph, { isEdge, removeElements, getOutgoers, SourceHandle, TargetHandle } from '../src';
// import Graph from '../dist/ReactGraph';
const SpecialNode = ({ data, onChange, styles }) => (
<div
style={{ background: '#FFCC00', padding: 10, borderRadius: 30, ...styles }}
style={{ background: '#FFCC00', padding: 10, borderRadius: 2, ...styles }}
>
<TargetHandle style={{ left: 10, background: '#999' }} />
<div>I am <strong>special</strong>!<br />{data.label}</div>
<select onChange={(e) => onChange(e.target.value, data)}>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<SourceHandle style={{ left: 10, background: '#999' }} />
</div>
);
@@ -46,12 +48,14 @@ class App extends PureComponent {
{ id: '3', data: { label: 'I bring my own style' }, position: { x: 100, y: 200 }, style: { background: '#eee', color: '#222', border: '1px solid #bbb' } },
{ id: '4', type: 'output', data: { label: 'nody nodes' }, position: { x: 50, y: 300 } },
{ id: '5', type: 'default', data: { label: 'Another node'}, position: { x: 400, y: 300 } },
{ id: '6', type: 'special', onChange, data: { label: 'no option selected' }, position: { x: 425, y: 400 } },
{ id: '6', type: 'special', onChange, data: { label: 'no option selected' }, position: { x: 425, y: 375 } },
{ id: '7', type: 'output', data: { label: 'output' }, position: { x: 250, y: 500 } },
{ source: '1', target: '2', animated: true },
{ source: '2', target: '3' },
{ source: '3', target: '4' },
{ source: '3', target: '5' },
{ source: '5', target: '6', type: 'straight', animated: true, style: { stroke: '#FFCC00' } }
{ source: '5', target: '6', type: 'straight', animated: true, style: { stroke: '#FFCC00' } },
{ source: '6', target: '7', style: { stroke: '#FFCC00' }},
]
};
}
@@ -114,6 +118,7 @@ class App extends PureComponent {
elements={this.state.elements}
onElementClick={element => this.onElementClick(element)}
onElementsRemove={elements => this.onElementsRemove(elements)}
onConnect={params => console.log(params)}
style={{ width: '100%', height: '100%' }}
onLoad={graphInstance => this.onLoad(graphInstance)}
onChange={(elements) => this.onChange(elements)}