Canvas-domain graph API for connector items and ports.
Graph commands submit through the canonical canvas command path and create or
update connector items in LivePanels.Canvas.State. Graph-owned modules hold
connection resolution, graph command DOM attrs, runtime graph events, and
layout helpers. Connector item modeling, path projection, and SVG item
rendering live under LivePanels.Item.Connector.
Headless connector and navigation queries live in LivePanels.Graph.Query.
Viewport-fit bounds live in LivePanels.Graph.Bounds. Layout helpers live in
LivePanels.Graph.Layout.
LivePanels permits cyclic graphs. Applications that need DAG semantics should
reject connector commands in policy with LivePanels.Graph.Query.creates_cycle?/3.
LivePanels.Toolkit.Graph is the public DOM-protocol helper module for graph
ports, connector commands, graph controls, and graph marker imports.
Summary
Types
First argument accepted by graph command helpers.
Functions
Connects two declared ports and returns the command result.
Connects two declared ports through the canvas command path.
Returns connector items from canvas state or an item collection.
Removes a connector and returns the command result.
Removes a connector through the canvas command path.
Edits connectors and returns the command result.
Edits connector presentation, labels, route, markers, emphasis, curvature, or bends.
Explicit connector edit variant of edit/3 that returns the command result.
Explicit connector edit variant of edit/3.
Fits the full graph or current graph selection in the viewport.
Includes graph items or connector items and returns the command result.
Includes graph items or connector items in the current actor graph selection.
Applies a graph layout strategy and returns the command result.
Applies a graph layout strategy through ordinary canvas placement commands.
Reconnects an existing connector endpoint and returns the command result.
Reconnects an existing connector endpoint through the validated reconnect path.
Replaces the current actor graph selection and returns the command result.
Replaces the current actor graph selection.
Selects every visible graph item and connector item and returns the command result.
Selects every visible graph item and connector item for the current actor.
Toggles graph items or connector items and returns the command result.
Toggles graph items or connector items in the current actor graph selection.
Types
@type command_result() :: LivePanels.Canvas.Command.result()
@type connect_opts() :: keyword()
@type connector_edit_opts() :: connector_presentation_opts() | [{:bends, [map()]}]
@type connector_presentation_opts() :: [ label: String.t() | nil, labels: %{optional(String.t()) => String.t() | nil}, role: atom() | String.t() | nil, marker_start: atom() | String.t() | nil, marker_end: atom() | String.t() | nil, emphasis: :muted | :normal | :active | String.t() | nil, directed?: boolean() | String.t() | nil, route: :bezier | :orthogonal | :straight | String.t() | nil, direction: :horizontal | :vertical | String.t() | nil, precision: non_neg_integer() | String.t() | nil, curvature: number() | String.t() | nil, min_curvature: number() | String.t() | nil ]
@type connector_ref() :: LivePanels.Item.t() | String.t() | atom()
@type connector_target() :: :all | connector_ref() | [connector_ref()]
@type fit_target() :: :graph | :selection
@type reconnect_opts() :: [endpoint: :from | :to, target: endpoint_ref()]
@type socket() :: Phoenix.LiveView.Socket.t()
@type target() :: LivePanels.Canvas.command_target()
First argument accepted by graph command helpers.
Pass a LiveView socket for a standalone command, or a
LivePanels.Canvas.Transaction context inside LivePanels.Canvas.transaction/2.
Functions
@spec connect(target(), connect_opts()) :: command_result()
Connects two declared ports and returns the command result.
@spec connect!(target(), connect_opts()) :: target()
Connects two declared ports through the canvas command path.
Route, label, marker, role, direction, and emphasis options are stored on the connector item and rendered by the graph SVG item projection.
@spec connectors(term()) :: [LivePanels.Item.t()]
Returns connector items from canvas state or an item collection.
@spec disconnect(target(), connector_ref()) :: command_result()
Removes a connector and returns the command result.
@spec disconnect!(target(), connector_ref()) :: target()
Removes a connector through the canvas command path.
@spec edit(target(), connector_target(), connector_edit_opts()) :: command_result()
Edits connectors and returns the command result.
@spec edit!(target(), connector_target(), connector_edit_opts()) :: target()
Edits connector presentation, labels, route, markers, emphasis, curvature, or bends.
@spec edit_connector(target(), connector_target(), connector_edit_opts()) :: command_result()
Explicit connector edit variant of edit/3 that returns the command result.
@spec edit_connector!(target(), connector_target(), connector_edit_opts()) :: target()
Explicit connector edit variant of edit/3.
@spec fit(socket(), fit_target()) :: socket()
Fits the full graph or current graph selection in the viewport.
@spec include(target(), term()) :: command_result()
Includes graph items or connector items and returns the command result.
Includes graph items or connector items in the current actor graph selection.
@spec layout(target(), LivePanels.Graph.Layout.layout_strategy(), keyword()) :: command_result()
Applies a graph layout strategy and returns the command result.
@spec layout!(target(), LivePanels.Graph.Layout.layout_strategy(), keyword()) :: target()
Applies a graph layout strategy through ordinary canvas placement commands.
@spec reconnect(target(), connector_ref(), reconnect_opts()) :: command_result()
Reconnects an existing connector endpoint and returns the command result.
@spec reconnect!(target(), connector_ref(), reconnect_opts()) :: target()
Reconnects an existing connector endpoint through the validated reconnect path.
@spec select(target(), term()) :: command_result()
Replaces the current actor graph selection and returns the command result.
Replaces the current actor graph selection.
@spec select_all(target()) :: command_result()
Selects every visible graph item and connector item and returns the command result.
Selects every visible graph item and connector item for the current actor.
@spec toggle(target(), term()) :: command_result()
Toggles graph items or connector items and returns the command result.
Toggles graph items or connector items in the current actor graph selection.