|
| 1 | +# Flow Components |
| 2 | + |
| 3 | +This page documents the main components provided by the `rxe.flow` library. |
| 4 | + |
| 5 | +## rxe.flow.provider |
| 6 | + |
| 7 | +The `FlowProvider` component is a context provider that makes it possible to access a flow’s internal state outside of the `<ReactFlow />` component. Many of the hooks we provide rely on this component to work. |
| 8 | + |
| 9 | +**Props:** |
| 10 | + |
| 11 | +- `initial_nodes`: `Sequence[Node]` - These nodes are used to initialize the flow. They are not dynamic. |
| 12 | +- `default_edges`: `Sequence[Edge]` - These edges are used to initialize the flow. They are not dynamic. |
| 13 | +- `initial_width`: `float` - The initial width is necessary to be able to use fitView on the server. |
| 14 | +- `initial_height`: `float` - The initial height is necessary to be able to use fitView on the server. |
| 15 | +- `fit_view`: `bool` - When true, the flow will be zoomed and panned to fit all the nodes initially provided. |
| 16 | +- `initial_fit_view_options`: `FitViewOptions` - You can provide an object of options to customize the initial fitView behavior. |
| 17 | +- `initial_min_zoom`: `float` - Initial minimum zoom level. |
| 18 | +- `initial_max_zoom`: `float` - Initial maximum zoom level. |
| 19 | +- `node_origin`: `NodeOrigin` - The origin of the node to use when placing it in the flow or looking up its x and y position. |
| 20 | +- `node_extent`: `CoordinateExtent` - The boundary a node can be moved in. |
| 21 | + |
| 22 | +## rxe.flow |
| 23 | + |
| 24 | +The `Flow` component is the main component that renders the flow. It takes in nodes and edges, and provides event handlers for user interactions. |
| 25 | + |
| 26 | +**Props:** |
| 27 | + |
| 28 | +- `nodes`: `Sequence[Node]` - An array of nodes to render in a controlled flow. |
| 29 | +- `edges`: `Sequence[Edge]` - An array of edges to render in a controlled flow. |
| 30 | +- `default_nodes`: `Sequence[Node]` - The initial nodes to render in an uncontrolled flow. |
| 31 | +- `default_edges`: `Sequence[Edge]` - The initial edges to render in an uncontrolled flow. |
| 32 | +- `node_types`: `Mapping[str, Any]` - Custom node types. |
| 33 | +- `edge_types`: `Mapping[str, Any]` - Custom edge types. |
| 34 | +- `on_nodes_change`: Event handler for when nodes change. |
| 35 | +- `on_edges_change`: Event handler for when edges change. |
| 36 | +- `on_connect`: Event handler for when a connection is made. |
| 37 | +- `fit_view`: `bool` - When true, the flow will be zoomed and panned to fit all the nodes initially provided. |
| 38 | +- `fit_view_options`: `FitViewOptions` - Options for `fit_view`. |
| 39 | +- `style`: The style of the component. |
| 40 | + |
| 41 | +## rxe.flow.background |
| 42 | + |
| 43 | +The `Background` component renders a background for the flow. It can be a pattern of lines, dots, or a cross. |
| 44 | + |
| 45 | +**Props:** |
| 46 | + |
| 47 | +- `color`: `str` - Color of the pattern. |
| 48 | +- `bg_color`: `str` - Color of the background. |
| 49 | +- `variant`: `Literal["lines", "dots", "cross"]` - The type of pattern to render. |
| 50 | +- `gap`: `float | tuple[float, float]` - The gap between patterns. |
| 51 | +- `size`: `float` - The size of the pattern elements. |
| 52 | + |
| 53 | +**Example:** |
| 54 | + |
| 55 | +```python |
| 56 | +rxe.flow.background(variant="dots", gap=20, size=1) |
| 57 | +``` |
| 58 | + |
| 59 | +## rxe.flow.controls |
| 60 | + |
| 61 | +The `Controls` component renders a panel with buttons to zoom in, zoom out, fit the view, and lock the viewport. |
| 62 | + |
| 63 | +**Props:** |
| 64 | + |
| 65 | +- `show_zoom`: `bool` - Whether to show the zoom buttons. |
| 66 | +- `show_fit_view`: `bool` - Whether to show the fit view button. |
| 67 | +- `show_interactive`: `bool` - Whether to show the lock button. |
| 68 | +- `position`: `PanelPosition` - The position of the controls on the pane. |
| 69 | + |
| 70 | +**Example:** |
| 71 | + |
| 72 | +```python |
| 73 | +rxe.flow.controls() |
| 74 | +``` |
| 75 | + |
| 76 | +## rxe.flow.mini_map |
| 77 | + |
| 78 | +The `MiniMap` component renders a small overview of your flow. |
| 79 | + |
| 80 | +**Props:** |
| 81 | + |
| 82 | +- `node_color`: `str | Any` - Color of nodes on minimap. |
| 83 | +- `node_stroke_color`: `str | Any` - Stroke color of nodes on minimap. |
| 84 | +- `pannable`: `bool` - Determines whether you can pan the viewport by dragging inside the minimap. |
| 85 | +- `zoomable`: `bool` - Determines whether you can zoom the viewport by scrolling inside the minimap. |
| 86 | +- `position`: `PanelPosition` - Position of minimap on pane. |
| 87 | + |
| 88 | +**Example:** |
| 89 | + |
| 90 | +```python |
| 91 | +rxe.flow.mini_map(pannable=True, zoomable=True) |
| 92 | +``` |
0 commit comments