LivePanels.Item.Connector (livepanels v0.1.0)

Copy Markdown View Source

Connector capability helpers.

A connector is a LivePanels.Item with type: "connector". This module validates connector capability state, builds connector items, and provides accessors over those items. A connector is a core wire primitive; graph and drawing extensions consume it without owning it.

Summary

Functions

Returns the connector's routed bend points.

Builds a port-to-port connection connector item.

Returns true when a connector represents a port connection.

Returns true when a connector should render directionally.

Returns the connector emphasis.

Builds a connection endpoint map from an item id and port name.

Returns the connector's source endpoint.

Returns the source item id touched by a connector.

Returns true when a connector touches an item id.

Returns item ids touched by a connector.

Returns the connector label.

Returns the marker style for one connector endpoint.

Builds a connector item or raises when the connector state is invalid.

Returns the port name from a connector anchor.

Returns the connector presentation projection.

Updates a connector's routed bend points.

Returns a connector with presentation fields updated.

Returns a connector with updated endpoint resolution.

Builds an item-to-item relationship connector item.

Returns true when a connector represents an item relationship.

Replaces every connector touching one item id.

Returns the connector role.

Returns connector routing options stored on the item.

Returns the connector semantic.

Returns the connector's target endpoint.

Returns the target item id touched by a connector.

Types

anchor()

@type anchor() :: :center | {:port, String.t()}

bend()

@type bend() :: %{x: number(), y: number()}

connection_endpoint()

@type connection_endpoint() :: %{item_id: String.t(), port: String.t()}

emphasis()

@type emphasis() :: :muted | :normal | :active

endpoint()

@type endpoint() :: %{item_id: String.t(), anchor: anchor()}

semantic()

@type semantic() :: :connection | :relationship

t()

@type t() :: LivePanels.Item.t()

Functions

bends(connector)

@spec bends(LivePanels.Item.t()) :: [bend()]

Returns the connector's routed bend points.

connection(attrs)

@spec connection(keyword() | map()) :: LivePanels.Item.t()

Builds a port-to-port connection connector item.

connection?(connector)

@spec connection?(LivePanels.Item.t()) :: boolean()

Returns true when a connector represents a port connection.

directed?(connector)

@spec directed?(LivePanels.Item.t() | map()) :: boolean()

Returns true when a connector should render directionally.

emphasis(connector)

@spec emphasis(LivePanels.Item.t()) :: emphasis()

Returns the connector emphasis.

endpoint(item_id, port)

@spec endpoint(String.t(), String.t() | atom()) :: connection_endpoint()

Builds a connection endpoint map from an item id and port name.

from(connector)

@spec from(LivePanels.Item.t()) :: endpoint() | nil

Returns the connector's source endpoint.

from_item_id(connector)

@spec from_item_id(term()) :: String.t() | nil

Returns the source item id touched by a connector.

involves_item?(connector, item_id)

@spec involves_item?(LivePanels.Item.t(), String.t()) :: boolean()

Returns true when a connector touches an item id.

item_ids(connector)

@spec item_ids(LivePanels.Item.t()) :: [String.t()]

Returns item ids touched by a connector.

label(connector)

@spec label(LivePanels.Item.t()) :: String.t() | nil

Returns the connector label.

marker(connector, endpoint)

@spec marker(LivePanels.Item.t(), :start | :end) :: atom() | String.t() | nil

Returns the marker style for one connector endpoint.

new(semantic, from, to, opts \\ %{})

@spec new(semantic(), endpoint(), endpoint(), keyword() | map()) ::
  LivePanels.Item.t()

Builds a connector item or raises when the connector state is invalid.

port_name(arg1)

@spec port_name(anchor()) :: String.t() | nil

Returns the port name from a connector anchor.

presentation(connector)

@spec presentation(LivePanels.Item.t()) :: map()

Returns the connector presentation projection.

put_bends(connector, bends)

@spec put_bends(LivePanels.Item.t(), [bend()]) :: {:ok, LivePanels.Item.t()} | :error

Updates a connector's routed bend points.

put_presentation(connector, attrs)

@spec put_presentation(LivePanels.Item.t(), keyword() | map()) ::
  {:ok, LivePanels.Item.t()} | :error

Returns a connector with presentation fields updated.

reconnect(connector, resolution)

@spec reconnect(LivePanels.Item.t(), map()) :: LivePanels.Item.t()

Returns a connector with updated endpoint resolution.

relationship(from_id, to_id, opts \\ %{})

@spec relationship(String.t(), String.t(), keyword() | map()) :: LivePanels.Item.t()

Builds an item-to-item relationship connector item.

relationship?(connector)

@spec relationship?(LivePanels.Item.t()) :: boolean()

Returns true when a connector represents an item relationship.

replace_item_connectors(connectors, item_id, replacements)

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

Replaces every connector touching one item id.

role(connector)

@spec role(LivePanels.Item.t()) :: atom() | String.t() | nil

Returns the connector role.

route_options(connector)

@spec route_options(LivePanels.Item.t() | map()) :: keyword()

Returns connector routing options stored on the item.

semantic(connector)

@spec semantic(LivePanels.Item.t()) :: semantic() | nil

Returns the connector semantic.

to(connector)

@spec to(LivePanels.Item.t()) :: endpoint() | nil

Returns the connector's target endpoint.

to_item_id(connector)

@spec to_item_id(term()) :: String.t() | nil

Returns the target item id touched by a connector.