Raxol.Protocols.CoreProtocols.Component protocol (Raxol v2.0.1)

View Source

Protocol for renderable UI components. Combines functionality from Renderable, Styleable, and EventHandler protocols.

Summary

Types

t()

All the types that implement this protocol.

Functions

Applies styling to the component.

Gets the component's metadata (dimensions, capabilities, etc.).

Handles events sent to the component.

Renders the component to terminal output with the given options.

Validates the component's configuration.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

apply_style(component, style)

@spec apply_style(t(), map()) :: t()

Applies styling to the component.

get_metadata(component)

@spec get_metadata(t()) :: map()

Gets the component's metadata (dimensions, capabilities, etc.).

handle_event(component, event, state)

@spec handle_event(t(), map(), any()) :: {:ok | :unhandled, t(), any()}

Handles events sent to the component.

render(component, opts \\ %{})

@spec render(t(), map()) :: String.t()

Renders the component to terminal output with the given options.

validate(component)

@spec validate(t()) :: :ok | {:error, [String.t()]}

Validates the component's configuration.