AshReports.Element (ash_reports v0.1.0)

Base module for report elements.

Elements are the visual components within bands that display data, labels, lines, boxes, images, etc.

Summary

Functions

Converts a keyword list to a map for position/style properties.

Merges position properties with defaults.

Merges style properties with defaults.

Gets the type of the element.

Checks if the element should be displayed based on its conditional expression.

Types

element_type()

@type element_type() ::
  :field | :label | :expression | :aggregate | :line | :box | :image

position()

@type position() :: %{
  optional(:x) => number(),
  optional(:y) => number(),
  optional(:width) => number(),
  optional(:height) => number()
}

style()

@type style() :: %{
  optional(:font) => String.t(),
  optional(:font_size) => number(),
  optional(:font_weight) => :normal | :bold,
  optional(:font_style) => :normal | :italic,
  optional(:text_align) => :left | :center | :right | :justify,
  optional(:vertical_align) => :top | :middle | :bottom,
  optional(:color) => String.t(),
  optional(:background_color) => String.t(),
  optional(:border) => map(),
  optional(:padding) => number() | map(),
  optional(:margin) => number() | map()
}

t()

@type t() :: %{
  __struct__: module(),
  name: atom(),
  type: element_type(),
  position: position(),
  style: style(),
  conditional: Ash.Expr.t() | nil
}

Functions

keyword_to_map(keyword)

@spec keyword_to_map(Keyword.t()) :: map()

Converts a keyword list to a map for position/style properties.

merge_position(position, defaults)

@spec merge_position(map(), map()) :: map()

Merges position properties with defaults.

merge_style(style, defaults)

@spec merge_style(map(), map()) :: map()

Merges style properties with defaults.

type(map)

@spec type(t()) :: element_type()

Gets the type of the element.

visible?(map, context)

@spec visible?(t(), map()) :: boolean()

Checks if the element should be displayed based on its conditional expression.