• Stars
    star
    526
  • Rank 84,247 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 3 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A highly customizable streaming flow builder.

Introduction

English | 简体中文

A highly customizable streaming flow builder. The registration ability can flexibly customize your nodes, different types of node display and form, etc.

demo1 demo2

Try it out

http://react-flow-builder.site

Github

https://github.com/bytedance/flow-builder

Installation

yarn add react-flow-builder

or

npm install react-flow-builder

Usage

// index.tsx
import React, { useState, useContext } from 'react';
import FlowBuilder, {
  NodeContext,
  INode,
  IRegisterNode,
} from 'react-flow-builder';

import './index.css';

const StartNodeDisplay: React.FC = () => {
  const node = useContext(NodeContext);
  return <div className="start-node">{node.name}</div>;
};

const EndNodeDisplay: React.FC = () => {
  const node = useContext(NodeContext);
  return <div className="end-node">{node.name}</div>;
};

const OtherNodeDisplay: React.FC = () => {
  const node = useContext(NodeContext);
  return <div className="other-node">{node.name}</div>;
};

const ConditionNodeDisplay: React.FC = () => {
  const node = useContext(NodeContext);
  return <div className="condition-node">{node.name}</div>;
};

const registerNodes: IRegisterNode[] = [
  {
    type: 'start',
    name: 'start node',
    displayComponent: StartNodeDisplay,
    isStart: true,
  },
  {
    type: 'end',
    name: 'end node',
    displayComponent: EndNodeDisplay,
    isEnd: true,
  },
  {
    type: 'node',
    name: 'other node',
    displayComponent: OtherNodeDisplay,
  },
  {
    type: 'condition',
    name: 'condition node',
    displayComponent: ConditionNodeDisplay,
  },
  {
    type: 'branch',
    name: 'branch node',
    conditionNodeType: 'condition',
  },
];

const Demo = () => {
  const [nodes, setNodes] = useState<INode[]>([]);

  const handleChange = (nodes: INode[]) => {
    console.log('nodes change', nodes);
    setNodes(nodes);
  };

  return (
    <FlowBuilder
      nodes={nodes}
      onChange={handleChange}
      registerNodes={registerNodes}
    />
  );
};

export default Demo;

// index.css
.start-node, .end-node {
  height: 64px;
  width: 64px;
  border-radius: 50%;
  line-height: 64px;
  color: #fff;
  text-align: center;
}

.start-node {
  background-color: #338aff;
}

.end-node {
  background-color: #666;
}

.other-node, .condition-node {
  width: 224px;
  border-radius: 4px;
  color: #666;
  background: #fff;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.08);
}

.other-node {
  height: 118px;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.condition-node {
  height: 44px;
  padding: 12px 16px;
}

API

FlowBuilder

Property Description Type Required Default Version
backgroundColor The color of background string #F7F7F7
className The class name of the container string -
draggable drag and drop boolean false 1.0.0
DragComponent custom drag component React.FC<DragComponent> - 1.0.0
DropComponent custom drop component React.FC<DropComponent> - 1.0.0
createUuid custom node uuid (type?: string) => string - 2.0.0
DrawerComponent Drawer component React.FC<DrawerComponent> - 2.0.0
PopoverComponent Popover component React.FC<PopoverComponent> - 2.0.0
PopconfirmComponent Popconfirm component React.FC<PopconfirmComponent> - 2.0.0
drawerProps Extra props of DrawerComponent any -
drawerVisibleWhenAddNode Drawer visible when add node boolean false
historyTool undo and redo boolean | HistoryToolConfig false
layout Use vertical or horizontal layout vertical | horizontal vertical
lineColor The color of line string #999999
nodes The nodes of FlowBuilder Node[] -
readonly Readonly mode, cannot add, remove, configure. boolean false
registerNodes The registered nodes RegisterNode[] -
registerRemoteNodes The registered remote nodes RegisterRemoteNode[] - 1.3.0
showPracticalBranchNode - boolean false 1.1.0
showPracticalBranchRemove - boolean false 1.1.0
sortable Condition nodes can be dragged and sorted in branch boolean false 1.4.0
sortableAnchor Anchor for start dragging 序 ReactNode - 1.4.0
spaceX Horizontal spacing between nodes number 16
spaceY Vertical spacing between nodes number 16
zoomTool zoom boolean | ZoomToolConfig false
onChange Callback function for when the data change (nodes: Node[], changeEvent?: string) => void -
onHistoryChange (undoDisabled: boolean, redoDisabled: boolean) => void -
onZoomChange (outDisabled: boolean, value: number, inDisabled: boolean) => void -
showArrow Show arrow boolean false 1.4.5
arrowIcon The icon of the arrow ReactNode - 1.4.5
onAddNodeSuccess Called when add node success (type: string) => void - 1.4.9
onDropNodeSuccess Called when drop node success (type: string) => void - 1.4.9

HistoryToolConfig

Property Description Type Default
hidden boolean false
max number 10

ZoomToolConfig

Property Description Type Default
hidden boolean false
initialValue number 100
min number 10
max number 200
step number 10

DragComponent

Property Description Type Version
onDragStart The dragStart event of the custom drag component needs to call this method to set the dragged type( dragType in BuilderContext ) (nodeType: string) => void 1.0.0
onDragEnd The dragEnd event of the custom drag component needs to call this method to clear the dragged type( dragType in BuilderContext ) () => void 1.0.0

DropComponent

Property Description Type Version
onDrop The drop event of the custom drop component needs to call this method to add the new node type () => void 1.0.0

DrawerComponent

Property Description Type Version
visible You can judge the boolean value of selectedNode by yourself. any 2.0.0
onClose You can also call closeDrawer by yourself. any 2.0.0
children any 2.0.0
title any 2.0.0
width any 2.0.0
destroyOnClose any 2.0.0
maskClosable any 2.0.0

PopoverComponent

Property Description Type Version
visible any 2.0.0
onVisibleChange any 2.0.0
children any 2.0.0
overlayClassName any 2.0.0
placement any 2.0.0
trigger any 2.0.0
content any 2.0.0
getPopupContainer any 2.0.0

PopconfirmComponent

Property Description Type Version
title any 2.0.0
onConfirm You can also call removeNode yourself. any 2.0.0
children any 2.0.0
getPopupContainer any 2.0.0

FlowBuilderInstance

Name Description Type Version
add add node (node: INode, newNodeType: string) => void | (newNodeType: string) => void
history undo, redo (type: 'undo' | 'redo') => void
remove remove noded (nodes: INode | INode[] = useContext(NodeContext)) => void
zoom zoom (type: 'out' | 'in' | number) => void
closeDrawer close drawer () => void
context BuilderContext BuilderContext 1.3.5

Formatter

Name Description Type
buildFlatNodes Translate to flat nodes (params: {registerNodes: IRegisterNode[], nodes: INode[]}) => INode[]
buildTreeNodes Translate to tree nodes (params: {nodes: INode[]}) => INode[]
createUuid Create uuid (prefix?: string) => string

RegisterNode

Property Description Type Required Default Version
addableComponent React.FC<AddableComponent> -
addableNodeTypes The list of nodes that can be added below the node string[] -
addIcon The icon in addable node list (There are already some default icons) ReactNode -
addConditionIcon The icon of the branch node when adding a condition (The default icon already exists) ReactNode - 1.3.3
className The class name of node string - 1.3.4
conditionMaxNum The max number of condition node number -
conditionNodeType The type of condition node string -
configComponent The Component of configuring node form React.FC<ConfigComponent> -
configTitle The drawer title of configuring node string | ((node: INode, nodes: INode[]) => string) -
customRemove Custom remove button boolean false
displayComponent The Component of displaying node React.FC<DisplayComponent> -
initialNodeData the initial data when add new node Record<string, any> -
isStart Is start node boolean false
isEnd Is end node boolean false
isLoop Is loop node boolean false 1.4.6
name The name of node string -
removeConfirmTitle The confirmation information before deleting the node. The title of Popconfirm string | ReactNode Are you sure to remove this node?
showPracticalBranchNode - boolean false 1.1.0
showPracticalBranchRemove - boolean false 1.1.0
type The type of node, promise start is start node type and end is end node type string -

RegisterRemoteNode

Property Description Type Required Default Version
url remote url string - 1.3.0
cssUrl remote css url string - 1.3.0

DisplayComponent

Property Description Type
node The all information of node (NodeContext is recommended since V1) Node
nodes (BuilderContext is recommended since V1) Node[]
readonly (BuilderContext is recommended since V1) boolean
remove Remove node (useAction is recommended since V1) (nodes?: INode | INode[]) => void

ConfigComponent

Property Description Type
cancel Called on cancel, used to close the drawer (useDrawer is recommended since V1) () => void
node The all information of node (NodeContext is recommended since V1) Node
nodes (BuilderContext is recommended since V1) Node[]
save Called on save node data (automatically close the drawer, no need to call cancel). FlowBuilder will set the validateStatusError property according to the second param (useDrawer is recommended since V1) (values: any, validateStatusError?: boolean) => void

AddableComponent

Property Description Type
add (type: string) => void
node The all information of node (NodeContext is recommended since V1) Node
nodes (BuilderContext is recommended since V1) Node[]

Node

Property Description Type
children The condition nodes array of branch node, or the next flow of condition node Node[]
configuring Whether configuring of node. The display Component can highlight the node according to this property boolean
data The data of node any
id The unique id of node string
name The name of node. Same as the name of the registered node string
path The full path in FlowBuilder string[]
type The type of node. Same as the type of the registered node string
validateStatusError The Component of configuring node form validate failed. The display Component can highlight the node according to this property boolean

Context

Added since V1

In the context of FlowBuilder the following contexts can be used

BuilderContext

Contains props and state. The following is the state:

Property Description Type
zoomValue current zoom value number
setZoomValue set zoomValue (zoomValue: number) => void
historyRecords history nodes records INode[][]
setHistoryRecords set historyRecords (records: INode[][]) => void
activeHistoryRecordIndex current index in history nodes records number
setActiveHistoryRecordIndex set activeHistoryRecordIndex (index: number) => void
selectedNode current selecred node INode | undefined
setSelectedNode set selectedNode (node: INode | undefined) => void
drawerTitle the title of Drawer string
setDrawerTitle set drawerTitle (title: string) => void
dragType dragged node type string
setDragType set dragType (type: string) => void

NodeContext

Get the data of the node where it is used. For details Node

Hooks

Added since V1

In the context of FlowBuilder the following hooks can be used

useAction

Property Description Type Version
clickNode click node (node: INode = useContext(NodeContext)) => void
addNode add one node. (Get the current node through NodeContext when there is no node property) (node: INode, newNodeType: string) => void | (newNodeType: string) => void
addNodeInLoop add one node in loop node. (newNodeType: string) => void 1.4.6
removeNode remove one node or more nodes. (targetNode: INode | INode[] = useContext(NodeContext)) => void

useDrawer

Property Description Type
closeDrawer close Drawer and clear selectedNode () => void
saveDrawer save the content in Drawer (same as the save method in ConfigComponent) (values: any, validateStatusError?: boolean) => void

useZoom

Property Description Type
minZoom minimum zoom value number
maxZoom maximum zoom value number
zoom change zoom value (same as the zoom method in FlowBuilderInstance) (type: 'out' | 'in' | number) => void

useHistory

Property Description Type
maxLength Maximum length of history nodes records number
pushHistory add history nodes record (record?: INode[] = useContext(BuilderContext).nodes) => void
history undo, redo (same as the history method in FlowBuilderInstance) (type: 'undo' | 'redo') => void

useSort

Property Description Type Version
backward sort to backward (node: INode = useContext(NodeContext)) => void 1.4.3
forward sort to forward (node: INode = useContext(NodeContext)) => void 1.4.3
end sort to end (node: INode = useContext(NodeContext)) => void 1.4.3
start sort to start (node: INode = useContext(NodeContext)) => void 1.4.3

More Repositories

1

IconPark

🍎Transform an SVG icon into multiple themes, and generate React icons,Vue icons,svg icons
TypeScript
8,298
star
2

xgplayer

A HTML5 video player with a parser that saves traffic
JavaScript
8,260
star
3

sonic

A blazingly fast JSON serializing & deserializing library
Assembly
6,870
star
4

monoio

Rust async runtime based on io-uring.
Rust
3,864
star
5

byteps

A high performance and generic framework for distributed DNN training
Python
3,603
star
6

lightseq

LightSeq: A High Performance Library for Sequence Processing and Generation
C++
3,193
star
7

ByteX

ByteX is a bytecode plugin platform based on Android Gradle Transform API and ASM. 字节码插件开发平台
Java
2,865
star
8

Elkeid

Elkeid is an open source solution that can meet the security requirements of various workloads such as hosts, containers and K8s, and serverless. It is derived from ByteDance's internal best practices.
Go
2,226
star
9

AlphaPlayer

AlphaPlayer is a video animation engine.
Java
2,181
star
10

scene

Android Single Activity Framework compatible with Fragment.
Java
2,097
star
11

bhook

🔥 ByteHook is an Android PLT hook library which supports armeabi-v7a, arm64-v8a, x86 and x86_64.
C
2,073
star
12

flutter_ume

UME is an in-app debug kits platform for Flutter. Produced by Flutter Infra team of ByteDance
Dart
2,053
star
13

terarkdb

A RocksDB compatible KV storage engine with better performance
C++
2,044
star
14

btrace

🔥🔥 btrace(AKA RheaTrace) is a high performance Android trace tool which is based on Perfetto, it support to define custom events automatically during building apk and using bhook to provider more native events like Render/Binder/IO etc.
Kotlin
1,913
star
15

gopkg

Universal Utilities for Go
Go
1,704
star
16

android-inline-hook

🔥 ShadowHook is an Android inline hook library which supports thumb, arm32 and arm64.
C
1,660
star
17

bitsail

BitSail is a distributed high-performance data integration engine which supports batch, streaming and incremental scenarios. BitSail is widely used to synchronize hundreds of trillions of data every day.
Java
1,627
star
18

go-tagexpr

An interesting go struct tag expression syntax for field validation, etc.
Go
1,470
star
19

GiantMIDI-Piano

Python
1,431
star
20

appshark

Appshark is a static taint analysis platform to scan vulnerabilities in an Android app.
Kotlin
1,363
star
21

AabResGuard

The tool of obfuscated aab resources.(Android app bundle资源混淆工具)
Java
1,307
star
22

piano_transcription

Python
1,247
star
23

CodeLocator

Kotlin
1,163
star
24

BoostMultiDex

BoostMultiDex is a solution for quickly loading multiple dex files on low Android version devices (4.X and below, SDK <21).
Java
1,106
star
25

music_source_separation

Python
1,039
star
26

Fastbot_Android

Fastbot(2.0) is a model-based testing tool for modeling GUI transitions to discover app stability problems
C++
1,031
star
27

SALMONN

SALMONN: Speech Audio Language Music Open Neural Network
Python
1,000
star
28

memory-leak-detector

C
919
star
29

fedlearner

A multi-party collaborative machine learning framework
Python
892
star
30

monolith

ByteDance's Recommendation System
Python
844
star
31

sonic-cpp

A fast JSON serializing & deserializing library, accelerated by SIMD.
C++
811
star
32

godlp

sensitive information protection toolkit
Go
770
star
33

MVDream

Multi-view Diffusion for 3D Generation
Python
744
star
34

res-adapter

Official implementation of "ResAdapter: Domain Consistent Resolution Adapter for Diffusion Models".
Python
724
star
35

bytemd

ByteMD v1 repository
TypeScript
679
star
36

tailor

C
669
star
37

ibot

iBOT 🤖: Image BERT Pre-Training with Online Tokenizer (ICLR 2022)
Jupyter Notebook
663
star
38

RealRichText

A Tricky Solution for Implementing Inline-Image-In-Text Feature in Flutter.
Dart
658
star
39

guide

A new feature guide component by react 🧭
TypeScript
651
star
40

mockey

a simple and easy-to-use golang mock library
Go
622
star
41

magic-microservices

Make Web Components easier and powerful!😘
TypeScript
570
star
42

Fastbot_iOS

About Fastbot(2.0) is a model-based testing tool for modeling GUI transitions to discover app stability problems
Objective-C
553
star
43

MVDream-threestudio

3D generation code for MVDream
Python
473
star
44

effective_transformer

Running BERT without Padding
C++
457
star
45

ByteTransformer

optimized BERT transformer inference on NVIDIA GPU. https://arxiv.org/abs/2210.03052
C++
449
star
46

Next-ViT

Python
426
star
47

matxscript

A high-performance, extensible Python AOT compiler.
C++
408
star
48

byteir

A model compilation solution for various hardware
MLIR
362
star
49

syllepsis

Syllepsis is an out-of-the-box rich text editor.
TypeScript
355
star
50

uss

This is the PyTorch implementation of the Universal Source Separation with Weakly labelled Data.
Python
324
star
51

OMGD

Online Multi-Granularity Distillation for GAN Compression (ICCV2021)
Python
323
star
52

neurst

Neural end-to-end Speech Translation Toolkit
Python
298
star
53

danmu.js

HTML5 danmu (danmaku) plugin for any DOM element
JavaScript
292
star
54

vArmor

vArmor is a cloud native container sandbox system based on AppArmor/BPF/Seccomp. It also includes multiple built-in protection rules that are ready to use out of the box.
Go
263
star
55

particle-sfm

ParticleSfM: Exploiting Dense Point Trajectories for Localizing Moving Cameras in the Wild. ECCV 2022.
C++
263
star
56

CloudShuffleService

Cloud Shuffle Service(CSS) is a general purpose remote shuffle solution for compute engines, including Spark/Flink/MapReduce.
Java
245
star
57

lynx-llm

paper: https://arxiv.org/abs/2307.02469 page: https://lynx-llm.github.io/
Python
227
star
58

g3

Enterprise-oriented Generic Proxy Solutions
Rust
227
star
59

xgplayer-vue

Vue component for xgplayer, a HTML5 video player with a parser that saves traffic
JavaScript
219
star
60

DEADiff

[CVPR 2024] Official implementation of "DEADiff: An Efficient Stylization Diffusion Model with Disentangled Representations"
Python
209
star
61

flux

A fast communication-overlapping library for tensor parallelism on GPUs.
C++
201
star
62

trace-irqoff

Interrupts-off or softirqs-off latency tracer
C
195
star
63

ParaGen

ParaGen is a PyTorch deep learning framework for parallel sequence generation.
Python
186
star
64

ByteMLPerf

AI Accelerator Benchmark focuses on evaluating AI Accelerators from a practical production perspective, including the ease of use and versatility of software and hardware.
Python
181
star
65

MoMA

MoMA: Multimodal LLM Adapter for Fast Personalized Image Generation
Jupyter Notebook
177
star
66

AWERTL

An non-invasive iOS framework for quickly adapting Right-To-Left style UI
Objective-C
175
star
67

Bytedance-UnionAD

Ruby
170
star
68

keyhouse

Keyhouse is a skeleton of general-purpose Key Management System written in Rust.
Rust
163
star
69

react-model

The next generation state management library for React
TypeScript
162
star
70

LargeBatchCTR

Large batch training of CTR models based on DeepCTR with CowClip.
Python
162
star
71

ic_flow_platform

IFP (ic flow platform) is an integrated circuit design flow platform, mainly used for IC process specification management and data flow contral.
Python
154
star
72

DanmakuRenderEngine

DanmakuRenderEngine is a lightweight and scalable Android danmaku library. 轻量级高扩展安卓弹幕渲染引擎
Kotlin
149
star
73

primus

Java
148
star
74

diat

A CLI tool to help with diagnosing Node.js processes basing on inspector.
JavaScript
146
star
75

coconut_cvpr2024

Jupyter Notebook
143
star
76

Hammer

An efficient toolkit for training deep models.
Python
138
star
77

ns-x

An easy-to-use, flexible network simulator library in Go.
Go
116
star
78

pv3d

Python
113
star
79

fc-clip

This repo contains the code for our paper Convolutions Die Hard: Open-Vocabulary Segmentation with Single Frozen Convolutional CLIP
Python
109
star
80

RLFN

Winner of runtime track in NTIRE 2022 challenge on Efficient Super-Resolution
Python
106
star
81

DCFrame

DCFrame is a Swift UI collection framework, which can easily create complex UI.
Swift
100
star
82

trace-noschedule

Trace noschedule thread
C
99
star
83

decoupleQ

A quantization algorithm for LLM
Cuda
99
star
84

tar-wasm

A faster experimental wasm-based tar implementation for browsers.
Rust
95
star
85

TWIST

Official codes: Self-Supervised Learning by Estimating Twin Class Distribution
Python
95
star
86

magic-portal

⚡ A blazing fast micro-component and micro-frontend solution uses web-components under the hood.
TypeScript
91
star
87

xgplayer-react

React component for xgplayer, a HTML5 video player with a parser that saves traffic
JavaScript
84
star
88

fe-foundation

UI Foundation for React Hooks and Vue Composition Api
TypeScript
80
star
89

nnproxy

Scalable NameNode RPC Proxy for HDFS Federation
Java
79
star
90

dbatman

Go
74
star
91

Elkeid-HUB

Elkeid HUB is a rule/event processing engine maintained by the Elkeid Team that supports streaming/offline (not yet supported by the community edition) data processing. The original intention is to solve complex data/event processing and external system linkage requirements through standardized rules.
Python
74
star
92

FreeSeg

Python
69
star
93

pull_to_refresh

Flutter pull_to_refresh widget
Dart
67
star
94

Jeddak-DPSQL

DPSQL (Privacy Protection SQL Query Service) - This project is a microservice Middleware located between the database engine ( Hive , Clickhouse , etc.) and the application system. It provides transparent SQL query result desensitization capabilities.
Python
62
star
95

terark-zip

A data structure and algorithm library built for TerarkDB
C++
62
star
96

trace-runqlat

C
61
star
97

ipmb

An interprocess message bus system built in Rust.
Rust
60
star
98

X-Portrait

Source code for the SIGGRAPH 2024 paper "X-Portrait: Expressive Portrait Animation with Hierarchical Motion Attention"
Python
59
star
99

kernel

ByteDance kernel for use on cloud.
C
57
star
100

scroll_kit

Dart
56
star