resolveBox
import { resolveBox, type Constraints } from "@pibbl/core";resolveBox(style, constraints, context?) resolves public BoxStyle into a
ResolvedBoxStyle with border and content boxes. It applies min/max lengths,
the boxSizing policy, padding, and finite constraint validation, and raises LayoutDiagnostic for
impossible or indefinite inputs.
const constraints: Constraints = { minWidth: 0, maxWidth: 320, minHeight: 0, maxHeight: 240,};const box = resolveBox({ width: "50%", padding: 12 }, constraints);It accepts Constraints and is a public layout helper, not a retained layout engine.
boxSizing: "content-box" is the default. With "border-box", dimensions and
bounds include padding and layout borders; percentages resolve before the insets are subtracted.
For example, width100/height30/padding10 yields an outer100×30 box and content80×10.
Content never becomes negative: width8 with padding10 yields outer20/content0 on
that axis, even when a declared maximum or parent bound is smaller. Opposing
min/max values remain errors. Painted stroke widths are independent of this box.
style.borderWidth reserves finite nonnegative layout insets, using a number or
physical { top, right, bottom, left } edges. It defaults to zero and does not
paint. Padding and borders combine once: content-box40×30 with padding10 and
borderWidth2 occupies64×54; border-box64×54 preserves40×30 content.
strokeWidth remains independent paint. Percentage/logical border aliases are
not supported. Layer raster sizing retains its separate width/height policy.
API details from source
Section titled “API details from source”
Resolves declared box sizing and padding into border and content boxes under parent constraints.
resolveBox: (style: Readonly<BoxStyle>, constraints: Readonly<Constraints>, context?: Readonly<LayoutDiagnosticContext>) => ResolvedBoxStyleRelated API: resolveBox, BoxStyle, Constraints, LayoutDiagnosticContext, ResolvedBoxStyle.
Parameters
Section titled “Parameters”-
style— Declared box sizing and edge properties. See BoxStyle. -
constraints— Available dimensions used to resolve percentages and constraints. See Constraints . -
context— Component and property context for diagnostic messages. See LayoutDiagnosticContext .
Returns
Section titled “Returns”Resolved box dimensions and edge values. See ResolvedBoxStyle.
See also
Section titled “See also”View source — packages/core/src/lib/layout/box.ts:27
Implementation guidance for agents
Section titled “Implementation guidance for agents”Read the Authoring, signals, and lifecycle companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.
Complete minimal examples
Section titled “Complete minimal examples”- Box resolution: Resolve padding, percentages, and a constrained box with typed diagnostics. Plain source
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision a1dcf8e. ALPHA — NOT FOR PRODUCTION USE.