Raxol.UI.Components.Display.Table (Raxol v0.4.0)

View Source

A component for displaying tabular data with sorting, filtering, and pagination.

Summary

Functions

Handles events for the Table component.

Initializes the Table component state from props.

Mounts the Table component, performing any setup needed.

Renders the Table component.

Updates the Table component state in response to messages. Handles prop updates, sorting, filtering, and selection.

Types

cell()

@type cell() :: String.t() | number() | atom()

header()

@type header() :: String.t()

headers()

@type headers() :: [header()]

props()

@type props() :: %{
  optional(:id) => String.t(),
  optional(:columns) => list(),
  optional(:data) => list(),
  optional(:style) => map(),
  optional(:headers) => [header()],
  optional(:rows) => [row()],
  optional(:column_widths) => [:auto | [integer() | :auto]],
  optional(:theme) => map(),
  optional(:border_style) => :single | :double | :none | map(),
  optional(:width) => integer() | :auto,
  optional(:alignments) => [:left | :center | :right | [atom()]],
  optional(:sortable) => boolean(),
  optional(:filterable) => boolean(),
  optional(:selectable) => boolean(),
  optional(:striped) => boolean(),
  optional(:selected) => integer() | nil
}

row()

@type row() :: [cell()]

rows()

@type rows() :: [row()]

state()

@type state() :: %{
  id: String.t() | atom(),
  columns: list(),
  data: list(),
  style: map(),
  row_style: map() | nil,
  cell_style: map() | nil,
  header_style: map(),
  footer: map() | nil,
  scroll_top: integer(),
  scroll_left: integer(),
  focused_row: integer() | nil,
  focused_col: integer() | nil,
  max_height: integer() | nil,
  max_width: integer() | nil,
  sort_by: atom() | nil,
  sort_direction: :asc | :desc | nil,
  filter_term: String.t(),
  selected_row: integer() | nil,
  striped: boolean(),
  border_style: :single | :double | :none | map()
}

Functions

handle_event(state, event, context)

@spec handle_event(state(), term(), map()) ::
  {:noreply, state()} | {:noreply, state(), list()}

Handles events for the Table component.

init(attrs)

@spec init(map()) :: {:ok, state()}

Initializes the Table component state from props.

mount(state)

@spec mount(state()) :: {:ok, state(), list()}

Mounts the Table component, performing any setup needed.

render(state, context)

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

Renders the Table component.

update(message, state)

@spec update(term(), state()) :: {:noreply, state()}
@spec update(
  {:update_props, map()},
  state()
) :: {:noreply, state()}
@spec update(
  {:sort, atom()},
  state()
) :: {:noreply, state()}
@spec update(
  {:filter, String.t()},
  state()
) :: {:noreply, state()}
@spec update(
  {:select_row, integer()},
  state()
) :: {:noreply, state()}

Updates the Table component state in response to messages. Handles prop updates, sorting, filtering, and selection.