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

Miso.Flow.View

Description

Pure views rendering the DOM contract that the miso-flow JavaScript bridge (and the imperative @xyflow/system modules behind it) expects:

div.miso-flow[.dark]
  svg.miso-flow__background          (optional dot grid)
  div.miso-flow__pane
    div.miso-flowviewport.xyflowviewport   (viewport transform)
      svg.miso-flow__edges           (edge paths + marker defs)
      div.miso-flow__nodes
        div.miso-flow__node[data-id] (measured + dragged by the bridge)
          …user content…
          div.miso-flow__handle…     (connection handles)
      svg.miso-flow__connectionline  (while connecting)
  div.miso-flow__panel…              (controls, custom panels)

The selector contract: the bridge looks up .miso-flow__pane and .xyflow__viewport, measures handles via the source / target classes and data-handleid / data-handlepos, and resolves connections over data-nodeid / data-id and the connectable / connectablestart / connectableend classes.

Synopsis

Lifecycle hooks

data FlowHooks action Source #

Actions dispatched from VDOM lifecycle events; the component layer uses these to create the JavaScript store and attach gestures to the elements as they appear.

Constructors

FlowHooks 

Fields

Configuration

data FlowViewConfig ctx n e model action Source #

Constructors

FlowViewConfig 

Fields

flowViewConfig Source #

Arguments

:: FlowHooks action 
-> (n -> View ctx model action)

node label

-> FlowViewConfig ctx n e model action 

Config with xyflow-like defaults; nodes render their nodeData through the given label view.

type NodeContentRenderer ctx n e model action = FlowViewConfig ctx n e model action -> Node n -> [View ctx model action] Source #

Content rendered inside the node wrapper element (the wrapper itself — positioning, classes, lifecycle — is owned by flowView).

Scene

data FlowScene n e Source #

Everything flowView draws in one frame.

Constructors

FlowScene 

Fields

Views

flowView :: FlowViewConfig ctx n e model action -> FlowScene n e -> View ctx model action Source #

The full flow container.

defaultNodeContent Source #

Arguments

:: (Node n -> View ctx model action)

label

-> NodeContentRenderer ctx n e model action 

Default node content: a target handle, the label, a source handle.

handleView Source #

Arguments

:: FlowViewConfig ctx n e model action 
-> Node n 
-> HandleType 
-> Position 
-> Maybe MisoString

handle id (for multi-handle nodes)

-> View ctx model action 

A connection handle, carrying all attributes the gesture system reads ('data-id' mirrors the TS template including its null for a missing handle id).

panelView :: PanelPosition -> [View ctx model action] -> View ctx model action Source #

A positioned overlay panel (see .miso-flow__panel in Miso.Flow.Style).

controlsView :: PanelPosition -> [(MisoString, action)] -> View ctx model action Source #

A column of control buttons, one per (label, action).

Minimap

defaultMinimapConfig :: MinimapConfig Source #

xyflow's minimap defaults (pannable/zoomable on, bottom right).

minimapView :: MinimapConfig -> FlowViewConfig ctx n e model action -> FlowScene n e -> View ctx model action Source #

A pannable/zoomable overview map. Include it in fvcChildren.

minimapViewScaleFor :: MinimapConfig -> Dimensions -> Viewport -> NodeLookup n -> Double Source #

The scale the XYMinimap gesture code needs (the component layer forwards it over the bridge whenever the scene changes).

Node resizer

nodeResizerView :: ResizerConfig -> FlowViewConfig ctx n e model action -> Node n -> [View ctx model action] Source #

Resize controls for one node: four edge lines plus four corner handles, wired to XYResizer through the bridge. Render them inside the node's content (typically only while the node is selected):

myContent cfg n =
  nodeResizerView defaultResizerConfig cfg n <> defaultNodeContent label cfg n

Node toolbar

data ToolbarConfig Source #

Constructors

ToolbarConfig 

Instances

Instances details
Show ToolbarConfig Source # 
Instance details

Defined in Miso.Flow.View

Eq ToolbarConfig Source # 
Instance details

Defined in Miso.Flow.View

nodeToolbarView Source #

Arguments

:: ToolbarConfig 
-> FlowScene n e 
-> NodeId 
-> [View ctx model action]

toolbar content

-> [View ctx model action] 

A toolbar floating next to a node, in container coordinates (it does not scale with the zoom). Include it via fvcChildren:

fvcChildren = \scene ->
  [ v
  | n <- sceneNodes scene, nodeSelected n
  , v <- nodeToolbarView defaultToolbarConfig scene (nodeId n) [ … ]
  ]

edgeToolbarView Source #

Arguments

:: FlowViewConfig ctx n e model action 
-> FlowScene n e 
-> EdgeId 
-> [View ctx model action]

toolbar content

-> [View ctx model action] 

A toolbar floating at an edge's label position. Rendered in flow coordinates but inverse-scaled so it keeps a constant size — include it via fvcViewportChildren (it must live inside the viewport):

fvcViewportChildren = scene ->
  [ v
  | e <- sceneEdges scene, edgeSelected e
  , v <- edgeToolbarView cfg scene (edgeId e) [ … ]
  ]

Edge paths

edgePathFor :: ConnectionMode -> NodeLookup n -> Edge e -> Maybe EdgePath Source #

Resolve an edge's endpoints against the lookup and produce its path, honoring the edge's type (default / bezier, straight, step, smoothstep, simplebezier). Nothing until both endpoint nodes are measured.

edgePositionFor :: ConnectionMode -> NodeLookup n -> Edge e -> Maybe EdgePosition Source #

Resolve an edge's endpoints against the lookup; Nothing until both endpoint nodes are measured.

connectionPathFor :: ConnectionLineType -> ConnectionInProgress n -> EdgePath Source #

Path of the in-progress connection line, from the source handle to the pointer.