miso-flow
LicenseBSD3-style (see the file LICENSE)
Safe HaskellNone
LanguageHaskell2010

Miso.Flow

Description

Node-based UIs for miso, powered by xyflow. This module wraps the pure ports (Miso.Flow.Types, Miso.Flow.Utils), the view layer (Miso.Flow.View) and the JavaScript gesture bridge (Miso.Flow.Internal.Bridge) into an MVU component:

main :: IO ()
main = startApp defaultEvents $
  flowComponent defaultStoreOptions (text . nodeLabel) id myNodes myEdges

Requires js/miso-flow.js (it defines globalThis.MisoFlow); it ships inside the compiled output (js-sources on the GHCJS/JS backends, a compile-time splice on WASM).

Synopsis

Component

flowComponent Source #

Arguments

:: Eq n 
=> StoreOptions 
-> FlowSettings 
-> (n -> View ctx (FlowModel n e) (FlowAction n e))

node label

-> (FlowViewConfig ctx n e (FlowModel n e) (FlowAction n e) -> FlowViewConfig ctx n e (FlowModel n e) (FlowAction n e))

view customization (id for the defaults)

-> [Node n] 
-> [Edge e] 
-> Component ctx props (FlowModel n e) (FlowAction n e) 

A ready-to-mount flow. The view config passed to the customization function is pre-wired: hooks, flow id and connection mode match the store options, nodes render the given label view.

Settings

newtype FlowSettings Source #

Behavioral settings that cannot live in the (JSON-serialized) StoreOptions or the (Eq-constrained) model.

Constructors

FlowSettings 

Fields

  • fsValidateConnection :: Maybe (Connection -> Bool)

    consulted synchronously by the gesture system while a connection (or reconnection) is dragged; invalid targets render the connection line in the invalid style and refuse to connect

Model

data FlowModel n e Source #

State of one flow: the user graph, its computed internals, and the handle to the JavaScript store.

Instances

Instances details
(Eq n, Eq e) => Eq (FlowModel n e) Source # 
Instance details

Defined in Miso.Flow

Methods

(==) :: FlowModel n e -> FlowModel n e -> Bool #

(/=) :: FlowModel n e -> FlowModel n e -> Bool #

flowModel :: Eq n => StoreOptions -> [Node n] -> [Edge e] -> FlowModel n e Source #

Initial model from user nodes and edges.

Actions

Update / view (for manual embedding)

updateFlow :: Eq n => FlowAction n e -> Effect ctx props (FlowModel n e) (FlowAction n e) Source #

updateFlowWith with default settings.

updateFlowWith :: Eq n => FlowSettings -> FlowAction n e -> Effect ctx props (FlowModel n e) (FlowAction n e) Source #

Transition function; embed it directly if you are not using flowComponent.

viewFlow :: FlowViewConfig ctx n e (FlowModel n e) (FlowAction n e) -> FlowModel n e -> View ctx (FlowModel n e) (FlowAction n e) Source #

Draw a model with a view config (see flowViewConfig).

flowHooks :: FlowHooks (FlowAction n e) Source #

The standard wiring of VDOM lifecycle events into FlowActions.

sceneFromModel :: FlowModel n e -> FlowScene n e Source #

The scene flowView draws for a model.

Re-exports

data StoreOptions Source #

Options handed to the JavaScript store; mirrors the union of pane, drag and connection settings across @xyflow/system's modules.

defaultStoreOptions :: StoreOptions Source #

Defaults matching xyflow's.

flowCSS :: CSS Source #

Base + default theme, ready for a component's styles field.

flowBaseCSS :: CSS Source #

Structural contract only, for apps shipping their own theme.

flowBaseStyles :: MisoString Source #

Layout and interaction rules the bridge requires; no colors, no decoration. Do not override positioning, transforms or pointer-events in these classes.

flowThemeCSS :: CSS Source #

Default theme only.

flowThemeStyles :: MisoString Source #

The default look. Driven by CSS custom properties on .miso-flow (restyle by overriding them): --mf-bg, --mf-dots, --mf-node-bg, --mf-node-color, --mf-node-border, --mf-node-shadow, --mf-node-shadow-selected, --mf-accent, --mf-accent-soft, --mf-edge, --mf-edge-selected, --mf-edge-label-bg, --mf-handle, --mf-handle-border, --mf-connection, --mf-connection-invalid, --mf-connection-valid, --mf-panel-bg, --mf-panel-border, --mf-panel-color, --mf-minimap-mask, --mf-minimap-node, --mf-selection, --mf-font. Add a dark class on the container for the dark palette.