Raxol.Core.Renderer.Views.Table (Raxol v0.5.0)

View Source

Table view component for displaying tabular data.

Features:

  • Column headers
  • Row striping
  • Column alignment
  • Border styles
  • Column resizing
  • Row selection

Summary

Functions

Initializes the Table component with props. Props are expected to be a map.

Called when the component is mounted.

Constructs a Table struct for view usage (not stateful component usage). Accepts a map of props and returns the struct directly (not a tuple).

Renders the Table component based on its current state.

Renders the table content, potentially with a border.

Called when the component is about to be unmounted.

Handles updates to the component state.

Types

column()

@type column() :: %{
  header: String.t(),
  key: atom() | (map() -> term()),
  width: non_neg_integer() | :auto,
  align: :left | :center | :right,
  format: (term() -> String.t()) | nil
}

props()

@type props() :: %{
  columns: [column()],
  data: [map()],
  border: Raxol.Core.Renderer.View.border_style(),
  striped: boolean(),
  selectable: boolean(),
  selected: non_neg_integer() | nil,
  header_style: Raxol.Core.Renderer.View.style(),
  row_style: Raxol.Core.Renderer.View.style()
}

Functions

fetch(table, key)

get_and_update(table, key, fun)

handle_call(arg, from, state)

handle_event(event, props_or_context, state)

Handles dispatched events.

init(props)

Initializes the Table component with props. Props are expected to be a map.

mount(state)

Called when the component is mounted.

new(props)

Constructs a Table struct for view usage (not stateful component usage). Accepts a map of props and returns the struct directly (not a tuple).

pop(table, key)

render(state, props_or_context)

Renders the Table component based on its current state.

render_content(state)

Renders the table content, potentially with a border.

unmount(state)

Called when the component is about to be unmounted.

update(state, message)

Handles updates to the component state.