LivePanels.Canvas.Selection (livepanels v0.1.0)

Copy Markdown View Source

Actor-scoped canvas item selection.

Selection is runtime state, not layout. It lets applications build item, graph, and drawing editors with shared target state without turning product chrome into core.

Summary

Types

t()

First argument accepted by selection command helpers.

Functions

Clears the current actor selection and returns the command result.

Clears the current actor selection.

Returns the number of selected items.

Returns true when the selection contains no items.

Includes one or more items and returns the command result.

Includes one or more items in the current actor selection.

Returns the number of selected items.

Replaces the current actor selection and returns the command result.

Replaces the current actor selection.

Selects every item and connector item and returns the command result.

Selects every item and connector item the current actor can select.

Returns true when the selection contains the given canvas item.

Returns selected canvas item ids.

Toggles one or more items and returns the command result.

Toggles one or more items in the current actor selection.

Types

command_result()

@type command_result() :: LivePanels.Canvas.Command.result()

item_ref()

@type item_ref() :: LivePanels.Item.ref()

selection_ref()

@type selection_ref() :: t() | [item_ref()] | item_ref()

socket()

@type socket() :: Phoenix.LiveView.Socket.t()

t()

@type t() :: %LivePanels.Canvas.Selection{item_ids: MapSet.t(String.t())}

target()

@type target() :: LivePanels.Canvas.command_target()

First argument accepted by selection command helpers.

Pass a LiveView socket for a standalone command, or a LivePanels.Canvas.Transaction context inside LivePanels.Canvas.transaction/2.

Functions

clear(target)

@spec clear(target()) :: command_result()

Clears the current actor selection and returns the command result.

clear!(target)

@spec clear!(target()) :: target()

Clears the current actor selection.

count(selection)

@spec count(t() | term()) :: non_neg_integer()

Returns the number of selected items.

empty?(selection)

@spec empty?(t()) :: boolean()

Returns true when the selection contains no items.

include(target, selection)

@spec include(target(), selection_ref()) :: command_result()

Includes one or more items and returns the command result.

include!(target, selection)

@spec include!(target(), selection_ref()) :: target()

Includes one or more items in the current actor selection.

item_count(selection)

@spec item_count(t() | term()) :: non_neg_integer()

Returns the number of selected items.

select(target, selection)

@spec select(target(), selection_ref()) :: command_result()

Replaces the current actor selection and returns the command result.

select!(target, selection)

@spec select!(target(), selection_ref()) :: target()

Replaces the current actor selection.

select_all(target)

@spec select_all(target()) :: command_result()

Selects every item and connector item and returns the command result.

select_all!(target)

@spec select_all!(target()) :: target()

Selects every item and connector item the current actor can select.

selected_item?(selection, item)

@spec selected_item?(t(), item_ref()) :: boolean()

Returns true when the selection contains the given canvas item.

selected_item_ids(selection)

@spec selected_item_ids(t() | map() | term()) :: MapSet.t(String.t())

Returns selected canvas item ids.

toggle(target, selection)

@spec toggle(target(), selection_ref()) :: command_result()

Toggles one or more items and returns the command result.

toggle!(target, selection)

@spec toggle!(target(), selection_ref()) :: target()

Toggles one or more items in the current actor selection.