Raxol. UI. Layout. FlexItem
(Raxol v2.6.1)
View Source
A flex child resolved into the inputs the flexible-length solver needs.
This is the interface contract between element resolution and the
flexible-length solver. One FlexItem is resolved per child before
distribution; Flexbox.Solver then works exclusively on these — it
never reads raw elements or style maps.
Semantics
base_size— resolvedflex-basis;:autoresolves via the measure function passed toresolve/5.style: %{flex: n}expands to grow n / shrink 1 / basis 0 ANDmin_main: 0, so equal columns actually equalize. An explicitmin_width/min_heightstill wins over the sugar.{:pct, n}resolves against the container's dimension when definite, else behaves as:auto(spec). Margin percentages always resolve against the container's WIDTH (spec).- Invalid values (negative sizes/factors, malformed percentages)
clamp to the nearest valid value and emit
[:raxol, :layout, :invalid_style]— layout never raises on style input. marginsides may be:auto, treated as 0 for sizing (outer_main/2); positioning distributes free space into them.
frozen, frozen_reason, and main_size belong to the
resolve-flexible-lengths loop and live here so the struct is the
single currency across resolution, distribution, and positioning.
Summary
Functions
Clamp a candidate main size into the item's [min_main, max_main].
Cross-axis {start, end} margins for the given MAIN axis.
Hypothetical main size: base size clamped (spec 9.7 step 1 input).
Expands the flex shorthand plus explicit grow/shrink/basis keys.
Main-axis {start, end} margins for the given axis.
Outer main size: margins + size; :auto margins count as 0 here.
Resolves a raw child element into a FlexItem.
Resolves a single dimension value against a containing dimension.
Types
@type dimension() :: non_neg_integer() | :infinity
@type margin_side() :: non_neg_integer() | :auto
@type pct() :: {:pct, number()}
@type t() :: %Raxol.UI.Layout.FlexItem{ align_self: atom() | nil, base_size: non_neg_integer(), cross_size: non_neg_integer() | nil, element: map(), frozen: boolean(), frozen_reason: nil | :inflexible | :min_violation | :max_violation, grow: non_neg_integer(), main_size: non_neg_integer() | nil, margin: {margin_side(), margin_side(), margin_side(), margin_side()}, max_cross: dimension(), max_main: dimension(), min_cross: non_neg_integer(), min_main: non_neg_integer(), shrink: non_neg_integer() }
Functions
Clamp a candidate main size into the item's [min_main, max_main].
Cross-axis {start, end} margins for the given MAIN axis.
Hypothetical main size: base size clamped (spec 9.7 step 1 input).
Expands the flex shorthand plus explicit grow/shrink/basis keys.
Returns %{grow, shrink, basis, min_main_override}.
flex: n(int) -> grow n, shrink 1, basis 0, min_main_override 0flex: {g, s, b}-> as given, no min overrideflex: %{...}map -> grow/shrink/basis keys, no min override- legacy
attrs.flex-> same as map form (lowest precedence)
Main-axis {start, end} margins for the given axis.
Outer main size: margins + size; :auto margins count as 0 here.
Resolves a raw child element into a FlexItem.
child— element map (style read from:style, flex attrs also honored from legacychild.attrs.flexfor back-compat)main_axis—:horizontal | :verticalcontainer—%{width: definite | nil, height: definite | nil}; nil marks an indefinite dimension (percentages resolve to:auto)content_size_fun— zero-arg fun returning the content main size; called ONLY when basis resolves to:autoauto_min_fun— zero-arg fun returning the automatic minimum size (specmin-width: auto= min-content); called ONLY when no explicit min is set and no sugar override applies. Defaults to 0.
Resolves a single dimension value against a containing dimension.
int -> int (clamped non-negative); {:pct, n} -> rounded share of a
definite container, :auto against an indefinite one; nil/:auto -> :auto.