Skip to content

Commit

Permalink
Merge pull request #1605 from alibaba/xflow
Browse files Browse the repository at this point in the history
Xflow
  • Loading branch information
lhbxs authored Jan 6, 2025
2 parents db8b84d + 3a937c5 commit 7eab2c6
Show file tree
Hide file tree
Showing 27 changed files with 492 additions and 324 deletions.
108 changes: 60 additions & 48 deletions docs/xflow/api.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/xflow/demo/layout/LR/setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export const nodes = [
data: {
list: [
{
_conditionId: 'iawoyh5niyi6zjob',
_id: 'iawoyh5niyi6zjob',
},
],
},
Expand Down Expand Up @@ -259,8 +259,8 @@ export const edges = [
{
type: 'buttonedge',
source: 'b6zsd6w5ah2b209t',
sourceHandle: 'condition_else',
sourceHandle: 'id_else',
target: '4',
id: 'xy-edge__b6zsd6w5ah2b209tcondition_else-4',
id: 'xy-edge__b6zsd6w5ah2b209tid_else-4',
},
];
6 changes: 3 additions & 3 deletions docs/xflow/demo/layout/TB/setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const nodes = [
data: {
list: [
{
_conditionId: 'iawoyh5niyi6zjob',
_id: 'iawoyh5niyi6zjob',
},
],
},
Expand Down Expand Up @@ -273,8 +273,8 @@ export const edges = [
{
type: 'buttonedge',
source: 'b6zsd6w5ah2b209t',
sourceHandle: 'condition_else',
sourceHandle: 'id_else',
target: '4',
id: 'xy-edge__b6zsd6w5ah2b209tcondition_else-4',
id: 'xy-edge__b6zsd6w5ah2b209tid_else-4',
},
];
8 changes: 4 additions & 4 deletions docs/xflow/demo/log/buildIn-log/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export default () => {
_status: 'warning',
list: [
{
_parallelId: 'parallel_30ds0x3evus7ogo2',
_id: 'id_30ds0x3evus7ogo2',
value: '事件1',
},
{
_parallelId: 'parallel_m1l276eelcgn7s1p',
_id: 'id_m1l276eelcgn7s1p',
value: '事件2',
},
],
Expand Down Expand Up @@ -121,13 +121,13 @@ export default () => {
id: 'ky0eedrd6t2hqq81',
source: 'mcelcsg6pinydoy7',
target: '4m9tee00n819nyyy',
sourceHandle: 'parallel_30ds0x3evus7ogo2',
sourceHandle: 'id_30ds0x3evus7ogo2',
},
{
id: '7tm5a339lj94ugtn',
source: 'mcelcsg6pinydoy7',
target: 'j0kufl0o4fca4ee9',
sourceHandle: 'parallel_m1l276eelcgn7s1p',
sourceHandle: 'id_m1l276eelcgn7s1p',
},
{
type: 'buttonedge',
Expand Down
8 changes: 4 additions & 4 deletions docs/xflow/demo/log/custom-log/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export default () => {
_status: 'warning',
list: [
{
_parallelId: 'parallel_30ds0x3evus7ogo2',
_id: 'id_30ds0x3evus7ogo2',
value: '事件1',
},
{
_parallelId: 'parallel_m1l276eelcgn7s1p',
_id: 'id_m1l276eelcgn7s1p',
value: '事件2',
},
],
Expand Down Expand Up @@ -81,13 +81,13 @@ export default () => {
id: 'ky0eedrd6t2hqq81',
source: 'mcelcsg6pinydoy7',
target: '4m9tee00n819nyyy',
sourceHandle: 'parallel_30ds0x3evus7ogo2',
sourceHandle: 'id_30ds0x3evus7ogo2',
},
{
id: '7tm5a339lj94ugtn',
source: 'mcelcsg6pinydoy7',
target: 'j0kufl0o4fca4ee9',
sourceHandle: 'parallel_m1l276eelcgn7s1p',
sourceHandle: 'id_m1l276eelcgn7s1p',
},
{
type: 'buttonedge',
Expand Down
8 changes: 4 additions & 4 deletions docs/xflow/demo/log/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export default () => {
_status: 'warning',
list: [
{
_parallelId: 'parallel_30ds0x3evus7ogo2',
_id: 'id_30ds0x3evus7ogo2',
value: '事件1',
},
{
_parallelId: 'parallel_m1l276eelcgn7s1p',
_id: 'id_m1l276eelcgn7s1p',
value: '事件2',
},
],
Expand Down Expand Up @@ -121,13 +121,13 @@ export default () => {
id: 'ky0eedrd6t2hqq81',
source: 'mcelcsg6pinydoy7',
target: '4m9tee00n819nyyy',
sourceHandle: 'parallel_30ds0x3evus7ogo2',
sourceHandle: 'id_30ds0x3evus7ogo2',
},
{
id: '7tm5a339lj94ugtn',
source: 'mcelcsg6pinydoy7',
target: 'j0kufl0o4fca4ee9',
sourceHandle: 'parallel_m1l276eelcgn7s1p',
sourceHandle: 'id_m1l276eelcgn7s1p',
},
{
type: 'buttonedge',
Expand Down
6 changes: 3 additions & 3 deletions docs/xflow/demo/nodeSetting/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export const nodes = [
data: {
list: [
{
_conditionId: 'iawoyh5niyi6zjob',
_id: 'iawoyh5niyi6zjob',
},
],
},
Expand Down Expand Up @@ -224,8 +224,8 @@ export const edges = [
{
type: 'buttonedge',
source: 'b6zsd6w5ah2b209t',
sourceHandle: 'condition_else',
sourceHandle: 'id_else',
target: '4',
id: 'xy-edge__b6zsd6w5ah2b209tcondition_else-4',
id: 'xy-edge__b6zsd6w5ah2b209tid_else-4',
},
];
2 changes: 1 addition & 1 deletion docs/xflow/demo/nodeSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Flow = () => {
nodeSelector={{
showSearch: true,
}}
layout="TB"
// layout="TB"
globalConfig={{
nodePanel: {
width: '400px',
Expand Down
10 changes: 6 additions & 4 deletions docs/xflow/demo/parallelNode/custome/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ export default () => {
data: {
list: [
{
_parallelId: 'parallel_30ds0x3evus7ogo2',
_id: 'id_30ds0x3evus7ogo2',
value: '事件1',
title: "事件1"
},
{
_parallelId: 'parallel_m1l276eelcgn7s1p',
_id: 'id_m1l276eelcgn7s1p',
value: '事件2',
title: "事件1"
},
],
},
Expand Down Expand Up @@ -71,13 +73,13 @@ export default () => {
id: 'ky0eedrd6t2hqq81',
source: 'mcelcsg6pinydoy7',
target: '4m9tee00n819nyyy',
sourceHandle: 'parallel_30ds0x3evus7ogo2',
sourceHandle: 'id_30ds0x3evus7ogo2',
},
{
id: '7tm5a339lj94ugtn',
source: 'mcelcsg6pinydoy7',
target: 'j0kufl0o4fca4ee9',
sourceHandle: 'parallel_m1l276eelcgn7s1p',
sourceHandle: 'id_m1l276eelcgn7s1p',
},
{
type: 'buttonedge',
Expand Down
10 changes: 6 additions & 4 deletions docs/xflow/demo/parallelNode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ export default () => {
data: {
list: [
{
_parallelId: 'parallel_30ds0x3evus7ogo2',
_id: 'id_30ds0x3evus7ogo2',
value: '事件1',
title:"标题1"
},
{
_parallelId: 'parallel_m1l276eelcgn7s1p',
_id: 'id_m1l276eelcgn7s1p',
value: '事件2',
title: "标题2"
},
],
},
Expand Down Expand Up @@ -65,13 +67,13 @@ export default () => {
id: 'ky0eedrd6t2hqq81',
source: 'mcelcsg6pinydoy7',
target: '4m9tee00n819nyyy',
sourceHandle: 'parallel_30ds0x3evus7ogo2',
sourceHandle: 'id_30ds0x3evus7ogo2',
},
{
id: '7tm5a339lj94ugtn',
source: 'mcelcsg6pinydoy7',
target: 'j0kufl0o4fca4ee9',
sourceHandle: 'parallel_m1l276eelcgn7s1p',
sourceHandle: 'id_m1l276eelcgn7s1p',
},
{
type: 'buttonedge',
Expand Down
27 changes: 15 additions & 12 deletions docs/xflow/demo/switchNode/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import XFlow from '@xrenders/xflow';
import settings from './setting';
import React from 'react';

export default () => {
const nodes = [
Expand All @@ -22,16 +21,20 @@ export default () => {
data: {
list: [
{
_conditionId: 'condition_1nmzbhnbtv1se6sd', // 对应的 sourceHandle: 'condition_1nmzbhnbtv1se6sd'的边
_id: 'id_1nmzbhnbtv1se6sd', // 对应的 sourceHandle: 'id_1nmzbhnbtv1se6sd'的边
value: '条件1',
name: "这里是条件一",
title:"默认title"
},
{
value: '条件2',
_conditionId: 'condition_enxhwfca1ebn55td', // 对应sourceHandle: 'condition_enxhwfca1ebn55td'的边
_id: 'id_enxhwfca1ebn55td', // 对应sourceHandle: 'id_enxhwfca1ebn55td'的边
name:"这里是条件一"
},
{
value: '条件3',
_conditionId: 'condition_z1f7b93zwbx1xycu',// 对应sourceHandle: 'condition_z1f7b93zwbx1xycu'的边
_id: 'id_z1f7b93zwbx1xycu', // 对应sourceHandle: 'id_z1f7b93zwbx1xycu'的边
name:'这里是条件一'
},
],
desc: '',
Expand Down Expand Up @@ -95,27 +98,27 @@ export default () => {
},
{
id: '5s6af77jbcqvzfod',
source: 'kshd2hp4vqm8ww19',// switch节点的边
source: 'kshd2hp4vqm8ww19', // switch节点的边
target: 'ql61j2tdli4xage0',
sourceHandle: 'condition_1nmzbhnbtv1se6sd', // 对应 _conditionId为'condition_1nmzbhnbtv1se6sd'的条件
sourceHandle: 'id_1nmzbhnbtv1se6sd', // 对应 _id为'id_1nmzbhnbtv1se6sd'的条件
},
{
id: '6tw709qgc3mtazrv',
source: 'kshd2hp4vqm8ww19',// switch节点的边
source: 'kshd2hp4vqm8ww19', // switch节点的边
target: 'fab1j735q8iow6u3',
sourceHandle: 'condition_enxhwfca1ebn55td', // 对应 _conditionId为'condition_enxhwfca1ebn55td'的条件
sourceHandle: 'id_enxhwfca1ebn55td', // 对应 _id为'id_enxhwfca1ebn55td'的条件
},
{
id: 'vzlvdo69ljcqegc8',
source: 'kshd2hp4vqm8ww19',// switch节点的边
source: 'kshd2hp4vqm8ww19', // switch节点的边
target: '9mc5i628mfrxdow0',
sourceHandle: 'condition_z1f7b93zwbx1xycu',// 对应 _conditionId为'condition_z1f7b93zwbx1xycu'的条件
sourceHandle: 'id_z1f7b93zwbx1xycu', // 对应 _id为'id_z1f7b93zwbx1xycu'的条件
},
{
id: 'j8p8fnr5au9k25pb',
source: 'kshd2hp4vqm8ww19',// switch节点的边
source: 'kshd2hp4vqm8ww19', // switch节点的边
target: 'anmv2kcadqxj4k63',
sourceHandle: 'condition_else',// condition_else 对应默认路径ELSE
sourceHandle: 'id_else', // id_else 对应默认路径ELSE
},
{
id: '0qfpkc9vcjdb31qp',
Expand Down
5 changes: 5 additions & 0 deletions docs/xflow/demo/switchNode/setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ export default [
type: 'icon-fenzhi',
bgColor: '#06AED4',
},
switchExtra: { // 条件节点额外属性配置
// hideElse: true,
valueKey: 'value',
titleKey: 'name'
}
},
{
title: '开始',
Expand Down
8 changes: 4 additions & 4 deletions docs/xflow/nodeBuildIn.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ group:
## 条件内置节点
内置条件节点,可以直接设置type为`Switch`使用。

条件节点的数据格式为`data:{list:[{value:"条件1",_conditionId:"condition_${随机数}"}]}``_conditionId`为边数据的`sourceHandle`,以便条件和边一一对应。
有条件参数value(可以通过自定义条件节点配置面板更改配置参数)的放入list数组里面作为`IF或者ELIF`渲染,没有条件参数的,为默认执行路径`ELSE`,`ELSE`路径的固定`_conditionId``condition_else`,即边数据的`sourceHandle`必须为`condition_else`才能链接`ELSE`链接头,比如:
条件节点的数据格式为`data:{list:[{value:"条件1",_id:"id_${随机数}"}]}``_id`为边数据的`sourceHandle`,以便条件和边一一对应。
有条件参数value(可以通过自定义条件节点配置面板更改配置参数)的放入list数组里面作为`IF或者ELIF`渲染,没有条件参数的,为默认执行路径`ELSE`,`ELSE`路径的固定`_id``id_else`,即边数据的`sourceHandle`必须为`id_else`才能链接`ELSE`链接头,比如:
```js
{
id: 'j8p8fnr5au9k25pb',
source: 'kshd2hp4vqm8ww19',
target: 'anmv2kcadqxj4k63',
sourceHandle: 'condition_else', // else路径的边
sourceHandle: 'id_else', // else路径的边
}
```

Expand All @@ -40,7 +40,7 @@ group:
<code src="./demo/switchNode/customSwitchNode/index.tsx"></code>
## 并行节点
内置并行节点,可以直接设置type为`Parallel`使用,并行节点的数据格式为`data:{list:[{value:"条件1",_parallelId:"parallel_${随机数}"}]}`,`_parallelId`为边数据的`sourceHandle`,以便条件和边一一对应。
内置并行节点,可以直接设置type为`Parallel`使用,并行节点的数据格式为`data:{list:[{title:"事件一",value:"值1",_id:"id_${随机数}"}]}`,`_id`为边数据的`sourceHandle`,以便条件和边一一对应。
并行节点的每个连接头只能连接一个节点,不能连接多个节点,如果要更换节点,可以通过删除已连接节点或者在连接线上新增节点的方式更换目标节点。
Expand Down
2 changes: 1 addition & 1 deletion packages/x-flow/src/XFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ const XFlow: FC<FlowProps> = memo(props => {
onNodeClick={(event, node) => {
onNodeClick && onNodeClick(event, node);
}}

deleteKeyCode={globalConfig?.deleteKeyCode}
>
<CandidateNode />
<Operator addNode={handleAddNode} xflowRef={workflowContainerRef} />
Expand Down
Loading

0 comments on commit 7eab2c6

Please sign in to comment.