/** * Groups of frames on a composed page (#856, DESIGN §2.3, §5.3): a `stack` * lays its frames top to bottom, a `row` start to end, with `gap` between * them; `grow`, `shrink` and `priority` decide who takes spare space and * who gives space back; `pin` frames stay where the template puts them and * the others flow round them. Pure: what a frame's content needs comes from * a callback, so the rules are tested without laying text out. * * Also the order frames are placed and filled in once groups count * ({@link composedOrder}): a group is placed as a whole, after everything * its frames anchor to and before every frame that anchors to it or to one * of its frames. */ import type { Rect } from './geometry.js'; import type { ResolvedFrame, ResolvedFrameGroup, ResolvedPageTemplate } from './types.js'; /** A frame of a group as the solver reads it. Lengths in page px. */ export interface GroupItem { name: string; /** The frame's box from its own placement: a stack keeps its `x` and * `width`, a row its `height` when the frame's height is fixed; a pinned * frame keeps all of it. */ own: Rect; /** The height the frame asks for: its fixed height, or its content's at * its width (`'auto'`), before min/max. */ want: number; min: number; max: number; minWidth: number; maxWidth: number; grow: number; shrink: number; priority: number; pin: boolean; /** A height written as a length: a row does not stretch it. */ fixedHeight: boolean; /** The content's height at a width (rows negotiate widths with it). */ need?: (width: number) => number; /** The least height a stack cuts the frame to when nothing more yields * (#911): its `minHeight`. Default `min`. */ floor?: number; } export interface GroupLayoutInput { kind: 'stack' | 'row'; /** The group's box: its own (`placement` / `grid`), or, for a group with * none (`elastic`), where its first frame stands. */ box: Rect; /** No box of its own: a stack runs down as far as its frames need, to * the foot of `limit`; a row takes its frames' widths and grows as tall * as the tallest needs. Spare space, `grow` and `align` only apply to a * group with a box. */ elastic: boolean; /** How far an elastic group may run (the template's area). */ limit: Rect; gap: number; align: 'start' | 'center' | 'end' | 'space-between'; /** In group order. */ items: readonly GroupItem[]; /** Pinned frames outside the group: the group's frames flow round them. */ obstacles?: readonly Rect[]; /** Page px in a millimetre: a row negotiates widths in whole millimetres. */ mmPx: number; /** Rows: take width from siblings for a frame whose content runs past * the row's height. Off for the template's own (declared) layout. */ negotiate: boolean; } /** Share `amount` among `items` in proportion to `weight`, none past its * `room`; what an item cannot take goes to the others. Returns each one's * share, in `items` order. */ export declare function shareOut(amount: number, items: readonly { weight: number; room: number; }[]): number[]; /** The boxes of a group's frames, by name. */ export declare function layoutGroup(input: GroupLayoutInput): Map; /** A step of a composed page's layout: one frame, or a whole group. */ export type ComposedStep = { kind: 'frame'; frame: ResolvedFrame; } | { kind: 'group'; group: ResolvedFrameGroup; frames: ResolvedFrame[]; }; /** The group each frame belongs to (its first, when validation found it * in two). Groups with no frame are left out. */ export declare function groupOfFrames(template: Pick): Map; /** * The order a composed page is placed and filled in: P4's * {@link frameOrder} rules (a frame after what it anchors to and after the * frame its chain comes from, frames that push text first, else template * order), with each group a single step. A group comes after everything * its frames and its own box anchor to; anything anchored to the group or * to one of its frames comes after it. Its frames are filled in group * order. Loops (a group's frame anchored to a frame anchored back into the * group) are broken where they close, as P4 breaks anchor loops. */ export declare function composedOrder(template: Pick): ComposedStep[]; //# sourceMappingURL=groups.d.ts.map