Aurora.Uix.Layout.Options.Index (Aurora UIX v0.1.4-rc.0)

Copy Markdown

Handles retrieval and processing of options specific to :index layout type.

Provides functionality for managing index layout options, including pagination controls, page bar configurations, and row data handling. Integrates with the Aurora.Uix layout system to provide consistent option retrieval and processing for index-based layouts.

Options

  • :alternate_streams_suffixes - A list of suffixes use for producing multiple streams. Current implementation produces an alternate stream for displaying in card format.
    • Default: ["mobile"].
  • :infinite_scroll_items_load - The count of items to read into the streams when the infinity scroll pagination triggers.
    • Default: 200.
  • :pagination_disabled? - Controls whether pagination is enabled for the index list
    • Accepts boolean() or function of arity 1 that receives assigns and returns boolean
    • Default: false (pagination active)
  • :pagination_items_per_page - Number of items to display per page.
    • Default: 40.
  • :pages_bar_range_offset - Function for calculating pagination bar range offset
  • :page_title - Title for showing in the page.
    • Accepts a binary() (static title) or a function of arity 1 that receives assigns and returns a Phoenix.LiveView.Rendered.
    • Default: "List {name}", where {name} is the resource name.
  • :page_subtitle - The subtitle for the index list.
    • Accepts a binary() or a function of arity 1 that receives assigns and returns a Phoenix.LiveView.Rendered.
    • Default: "".
  • :get_streams - Function for extracting row data from assigns
  • :row_id - Function for extracting row identifiers

Summary

Functions

The default infinity scroll items to load.

Extracts row data from assigns.

Calculates the page bar range offset based on media query breakpoint.

Extracts row identifier from various row data formats.

Functions

default_infinity_scroll_items_load()

@spec default_infinity_scroll_items_load() :: integer()

The default infinity scroll items to load.

get(assigns, option)

@spec get(map(), atom()) :: {:ok, term()} | {:not_found, atom()}

Callback implementation for Aurora.Uix.Layout.Options.get/2.

get_streams(map)

@spec get_streams(map()) :: list()

Extracts row data from assigns.

Retrieves row data from either streams (if available and matching source_key) or directly from the auix.rows field. Prioritizes stream data when both are present and source_key matches.

Parameters

  • assigns (map()) - Assigns map containing auix and optionally streams.

Returns

list() - List of row data, or empty list if no rows found.

page_bar_range_offset(assigns, arg2)

@spec page_bar_range_offset(map(), atom()) :: integer()

Calculates the page bar range offset based on media query breakpoint.

Computes the range offset for pagination bar display based on the provided media query breakpoint. Larger breakpoints receive proportionally larger offsets to accommodate more pagination links on wider screens.

Parameters

  • assigns (map()) - The assigns map (currently unused but maintained for consistency).
  • media_query (atom()) - The media query breakpoint identifier.

Returns

integer() - The calculated range offset value.

Media Query Multipliers

  • :xl2 - 5x the default offset (10)
  • :xl - 4x the default offset (8)
  • :lg - 3x the default offset (6)
  • :md - 2x the default offset (4)
  • Other values - Default offset (2)

row_id(arg1)

@spec row_id({term(), term()} | map() | term()) :: term() | nil

Extracts row identifier from various row data formats.

Handles different row data structures to extract a consistent identifier. Supports tuple format {id, item}, map format with :id key, and returns nil for unsupported formats.

Parameters

  • row ({term(), term()} | map() | term()) - Row data in various formats

Returns

  • term() | nil - The row identifier, or nil if format is unsupported