LivePanels.Graph.Query (livepanels v0.1.0)

Copy Markdown View Source

Headless graph query helpers for connectors, selections, and navigation.

Summary

Functions

Returns a directed adjacency projection keyed by source item id.

Returns the number of active connector drafts in an assigned draft map.

Returns a map of item id to all connectors touching that item.

Returns a map of {item_id, port_name} to connectors touching that port.

Returns all connectors touching item_id.

Returns all connectors touching port_name on item_id.

Returns true when adding a connector from from_id to to_id would create a cycle.

Returns connectors that target item_id.

Returns ordered item ids reachable from a graph navigation anchor.

Returns connectors that start from item_id.

Returns true when connector_id is selected in the given graph selection.

Returns true when item_id is selected in the given graph selection.

Types

connector_source()

@type connector_source() :: LivePanels.Canvas.State.t() | [LivePanels.Item.t()]

direction()

@type direction() :: :incoming | :outgoing | :connected

navigation_anchor()

@type navigation_anchor() ::
  String.t()
  | {:item, String.t()}
  | {:connector, String.t()}
  | LivePanels.Item.t()
  | LivePanels.Canvas.Selection.t()

Functions

adjacency(source)

@spec adjacency(connector_source()) :: %{optional(String.t()) => [String.t()]}

Returns a directed adjacency projection keyed by source item id.

Duplicate target ids are collapsed while preserving first-seen connector order.

connector_draft_count(connector_drafts)

@spec connector_draft_count(map() | term()) :: non_neg_integer()

Returns the number of active connector drafts in an assigned draft map.

connectors_by_item(source)

@spec connectors_by_item(connector_source()) :: %{
  optional(String.t()) => [LivePanels.Item.t()]
}

Returns a map of item id to all connectors touching that item.

connectors_by_port(source)

@spec connectors_by_port(connector_source()) :: %{
  optional({String.t(), String.t() | nil}) => [LivePanels.Item.t()]
}

Returns a map of {item_id, port_name} to connectors touching that port.

connectors_for_item(source, item_id)

@spec connectors_for_item(connector_source(), String.t()) :: [LivePanels.Item.t()]

Returns all connectors touching item_id.

connectors_for_port(source, item_id, port_name)

@spec connectors_for_port(connector_source(), String.t(), String.t() | atom()) :: [
  LivePanels.Item.t()
]

Returns all connectors touching port_name on item_id.

creates_cycle?(source, from_id, to_id)

@spec creates_cycle?(connector_source(), String.t(), String.t()) :: boolean()

Returns true when adding a connector from from_id to to_id would create a cycle.

incoming_connectors(source, item_id)

@spec incoming_connectors(connector_source(), String.t()) :: [LivePanels.Item.t()]

Returns connectors that target item_id.

outgoing_connectors(source, item_id)

@spec outgoing_connectors(connector_source(), String.t()) :: [LivePanels.Item.t()]

Returns connectors that start from item_id.

selected_connector?(selection, connector_id)

@spec selected_connector?(LivePanels.Canvas.Selection.t(), String.t()) :: boolean()

Returns true when connector_id is selected in the given graph selection.

selected_item?(selection, item_id)

@spec selected_item?(LivePanels.Canvas.Selection.t(), String.t()) :: boolean()

Returns true when item_id is selected in the given graph selection.