AshReports.Layout.IR (ash_reports v0.1.0)
Intermediate Representation (IR) for layout containers.
This module defines the core IR type structures that represent layout containers (Grid, Table, Stack) in a normalized format suitable for all renderers. The IR handles cell positioning calculations, spanning logic, and provides a consistent data structure for Typst, HTML, and JSON output.
Usage
# Create a grid IR
grid_ir = %AshReports.Layout.IR{
type: :grid,
properties: %{columns: ["1fr", "2fr"], rows: ["auto"]},
children: [cell_ir1, cell_ir2],
lines: []
}Types
The IR supports three layout types:
:grid- CSS Grid-like layout with explicit columns/rows:table- Table with headers/footers:stack- Flexbox-like stack layout
Summary
Functions
Adds a child to the layout IR.
Adds a footer to the layout IR (for tables).
Adds a header to the layout IR (for tables).
Adds a line to the layout IR.
Gets a property from the layout IR.
Creates a grid IR with the given properties.
Creates a new LayoutIR struct with the given type and options.
Sets a property on the layout IR.
Creates a stack IR with the given properties.
Creates a table IR with the given properties.
Types
@type child() :: AshReports.Layout.IR.Cell.t() | AshReports.Layout.IR.Row.t() | AshReports.Layout.IR.Content.t()
@type layout_type() :: :grid | :table | :stack
@type t() :: %AshReports.Layout.IR{ children: [child()], footers: [AshReports.Layout.IR.Footer.t()], headers: [AshReports.Layout.IR.Header.t()], lines: [AshReports.Layout.IR.Line.t()], properties: map(), type: layout_type() }
Functions
Adds a child to the layout IR.
@spec add_header(t(), AshReports.Layout.IR.Header.t()) :: t()
Adds a header to the layout IR (for tables).
@spec add_line(t(), AshReports.Layout.IR.Line.t()) :: t()
Adds a line to the layout IR.
Gets a property from the layout IR.
Creates a grid IR with the given properties.
@spec new(layout_type(), Keyword.t()) :: t()
Creates a new LayoutIR struct with the given type and options.
Options
:properties- Map of normalized property values:children- List of CellIR, RowIR, or ContentIR:lines- List of LineIR for hline/vline:headers- List of HeaderIR (for tables):footers- List of FooterIR (for tables)
Examples
iex> AshReports.Layout.IR.new(:grid, properties: %{columns: ["1fr", "1fr"]})
%AshReports.Layout.IR{type: :grid, properties: %{columns: ["1fr", "1fr"]}, ...}
Sets a property on the layout IR.
Creates a stack IR with the given properties.
Creates a table IR with the given properties.