Skip to content

Intrinsic sizing contracts

Read as Markdown

Typecheck paired intrinsic sizes, baseline results, and fit-content sizing values.

Plain source. This example demonstrates a type-level or host-specific contract; it is checked with TypeScript rather than presented as an animated preview.

import {
fitContent,
type BaselineMeasureInput,
type BaselinesResult,
type FitContent,
type FlexMargin,
type IntrinsicAxisConstraints,
type IntrinsicConstraints,
type IntrinsicMeasureInput,
type IntrinsicSizesResult,
type SizingKeyword,
type SizingLength,
type SystemStyle,
} from "@pibbl/core";
const width: IntrinsicAxisConstraints = { kind: "bounded", min: 0, max: 240 };
const constraints: IntrinsicConstraints = {
width,
height: { kind: "unbounded", min: 0 },
};
const bound: FitContent = fitContent(120);
const keyword: SizingKeyword = "max-content";
const length: SizingLength = bound;
const margin: FlexMargin = "auto";
const intrinsic: IntrinsicSizesResult = {
status: "measured",
minContent: { width: 40, height: 18 },
maxContent: { width: 120, height: 18 },
};
const baselines: BaselinesResult = { status: "measured", first: 14, last: 14 };
type TextIntrinsicInput = IntrinsicMeasureInput<{ text: string }, SystemStyle>;
type TextBaselineInput = BaselineMeasureInput<{ text: string }, SystemStyle>;
const summary: [
IntrinsicConstraints,
SizingKeyword,
SizingLength,
FlexMargin,
IntrinsicSizesResult,
BaselinesResult,
] = [constraints, keyword, length, margin, intrinsic, baselines];
void (summary as unknown as TextIntrinsicInput | TextBaselineInput);
  • Uses the public intrinsic and sizing contracts without relying on runtime internals.

Documentation built with @pibbl/core 0.0.2, revision a1dcf8e. ALPHA — NOT FOR PRODUCTION USE.