Raxol.UI.Components.Selection.Dropdown (Raxol v0.5.0)

View Source

A dropdown component that allows selecting one option from a list.

Summary

Types

t()

State for the Selection.Dropdown component.

Functions

Handles key events for the Dropdown component, including toggling expansion and forwarding to the list.

Initializes the Dropdown component state from props.

Renders the Dropdown component, showing either the expanded or collapsed state.

Updates the Dropdown component state in response to messages.

Types

t()

@type t() :: %Raxol.UI.Components.Selection.Dropdown{
  expanded: boolean(),
  focused: boolean(),
  id: any(),
  list_height: non_neg_integer(),
  list_state: any(),
  on_change: (any() -> any()) | nil,
  options: list(),
  selected_option: any(),
  style: map(),
  width: non_neg_integer()
}

State for the Selection.Dropdown component.

  • :id - unique identifier
  • :options - list of options
  • :selected_option - currently selected option
  • :expanded - whether dropdown is expanded
  • :width - dropdown width
  • :list_height - height of the dropdown list
  • :style - style map
  • :focused - whether the dropdown is focused
  • :on_change - callback for selection change
  • :list_state - state of the nested list

Functions

broadcast(msg)

command(cmd)

handle_event(event, props, state)

@spec handle_event(map(), map(), t()) :: {t(), list()}

Handles key events for the Dropdown component, including toggling expansion and forwarding to the list.

init(props)

@spec init(map()) :: t()

Initializes the Dropdown component state from props.

mount(state)

Callback implementation for Raxol.UI.Components.Base.Component.mount/1.

render(state, props)

@spec render(t(), map()) :: any()

Renders the Dropdown component, showing either the expanded or collapsed state.

schedule(msg, delay)

unmount(state)

Callback implementation for Raxol.UI.Components.Base.Component.unmount/1.

update(msg, state)

@spec update(term(), t()) :: {t(), list()}

Updates the Dropdown component state in response to messages.