AshReports.Layout.IR.Content (ash_reports v0.1.0)
Intermediate Representation for content elements.
This module defines IR types for content that can appear within cells:
LabelIR- Static text contentFieldIR- Dynamic field values with formattingNestedLayoutIR- Nested layout containers
Content Union Type
The t() type is a union of all content types, making content polymorphic
within cells.
Examples
# Label content
label = AshReports.Layout.IR.Content.label("Total:", style: %{font_weight: :bold})
# Field content
field = AshReports.Layout.IR.Content.field(:amount,
format: :currency,
decimal_places: 2
)
# Nested layout
nested = AshReports.Layout.IR.Content.nested_layout(grid_ir)
Summary
Functions
Returns the type of content IR.
Creates a field content IR.
Creates a label content IR.
Creates a nested layout content IR.
Types
@type field_ir() :: %AshReports.Layout.IR.Content.Field{ source: atom() | [atom()], format: atom() | nil, decimal_places: non_neg_integer() | nil, style: AshReports.Layout.IR.Style.t() | nil }
@type label_ir() :: %AshReports.Layout.IR.Content.Label{ text: String.t(), style: AshReports.Layout.IR.Style.t() | nil }
@type nested_layout_ir() :: %AshReports.Layout.IR.Content.NestedLayout{ layout: AshReports.Layout.IR.t() }
Functions
@spec content_type(t()) :: :label | :field | :nested_layout
Returns the type of content IR.
Examples
iex> AshReports.Layout.IR.Content.content_type(%AshReports.Layout.IR.Content.Label{})
:label
@spec field(atom() | [atom()], Keyword.t()) :: AshReports.Layout.IR.Content.Field.t()
Creates a field content IR.
Options
:format- Format type (:number, :currency, :date, etc.):decimal_places- Number of decimal places for numeric formats:style- StyleIR for field styling
Examples
iex> AshReports.Layout.IR.Content.field(:amount, format: :currency)
%AshReports.Layout.IR.Content.Field{source: :amount, format: :currency, ...}
@spec label(String.t(), Keyword.t()) :: AshReports.Layout.IR.Content.Label.t()
Creates a label content IR.
Options
:style- StyleIR for text styling
Examples
iex> AshReports.Layout.IR.Content.label("Hello")
%AshReports.Layout.IR.Content.Label{text: "Hello", style: nil}
@spec nested_layout(AshReports.Layout.IR.t()) :: AshReports.Layout.IR.Content.NestedLayout.t()
Creates a nested layout content IR.
Examples
iex> grid_ir = AshReports.Layout.IR.grid()
iex> AshReports.Layout.IR.Content.nested_layout(grid_ir)
%AshReports.Layout.IR.Content.NestedLayout{layout: %AshReports.Layout.IR{...}}