@ant-design/pro-flow
Version:
A React based Flow components
66 lines • 1.19 kB
JavaScript
export function convertNodeChange(c) {
switch (c.type) {
case 'addNode':
{
return [{
item: c.node,
type: 'add'
}];
}
case 'addNodes':
{
return Object.keys(c.nodes).map(function (key) {
return {
item: c.nodes[key],
type: 'add'
};
});
}
case 'deleteNode':
{
return [{
id: c.id,
type: 'remove'
}];
}
case 'updateNodePosition':
{
return [{
id: c.id,
type: 'position',
position: c.position
}];
}
default:
return [];
}
}
export function convertEdgeChange(c) {
switch (c.type) {
case 'addEdge':
{
return [{
item: c.edge,
type: 'add'
}];
}
case 'addEdges':
{
return Object.keys(c.edges).map(function (key) {
return {
item: c.edges[key],
type: 'add'
};
});
}
case 'deleteEdge':
{
return [{
id: c.id,
type: 'remove'
}];
}
default:
return [];
}
}