/** * Layout Functions * Handle all layout concerns including columns, breaks, and section properties */ import { ComponentDefinition, ColumnSettings } from '../types'; import { ThemeConfig } from '../styles'; import { ProcessedSection } from './structure'; export interface LayoutPlan { sections: SectionLayout[]; } export interface WordSectionProperties { page: { size: { width: number; height: number; /** * OOXML `w:pgSz/@w:code` — the DEVMODE paper code printer drivers key * off. Set only for a named size; a custom `{width, height}` has none. */ code?: number; }; margin: { top: number; right: number; bottom: number; left: number; header?: number; footer?: number; gutter?: number; }; }; column: ColumnSettings & { /** * The same explicit columns as `children`, in twips. * * `children` holds docx `Column` instances, which keep their width and * space private, so anything downstream of a renderer boundary cannot read * them back. This is the plain-numbers copy the DocxIR compiler reads. */ widths?: Array<{ width: number; space?: number; }>; }; type?: 'continuous' | 'nextColumn' | 'nextPage' | 'evenPage' | 'oddPage'; } export interface SectionLayout { properties: WordSectionProperties; components: ComponentDefinition[]; layoutType: 'single' | 'multi-column'; breakBefore: boolean; header?: ComponentDefinition[] | 'linkToPrevious'; footer?: ComponentDefinition[] | 'linkToPrevious'; /** True if this layout section comes from a user-defined Section component */ isUserSection: boolean; /** True if this layout chunk belongs to a user-defined Section (all chunks of that section) */ belongsToUserSection: boolean; /** Page configuration override for this section */ pageOverride?: { size?: 'A4' | 'A3' | 'LETTER' | 'LEGAL' | { width: number; height: number; }; margins?: { top?: number; bottom?: number; left?: number; right?: number; header?: number; footer?: number; gutter?: number; }; }; /** * Set when the section asked to continue on the page but its paper size or * orientation differs from the section before it. A continuous break cannot * change either, so the layout started it on a new page instead; the * compiler reports that the author's request was overridden. */ forcedPageBreak?: boolean; } export interface LayoutGroup { layout: 'single' | 'multi-column'; components: ComponentDefinition[]; breakBefore: boolean; } /** * Apply layout to processed sections */ export declare function applyLayout(sections: ProcessedSection[], theme: ThemeConfig, themeName: string): LayoutPlan; /** * Analyze components to determine layout groups */ export declare function analyzeLayoutGroups(components: ComponentDefinition[]): LayoutGroup[]; /** * Determine layout type for a component */ export declare function determineComponentLayout(component: ComponentDefinition): 'single' | 'multi-column'; /** * Process components for layout (insert breaks where needed) */ export declare function processLayoutComponents(components: ComponentDefinition[]): ComponentDefinition[]; /** * Get column settings for layout type */ export declare function getColumnSettings(layout: 'single' | 'multi-column'): ColumnSettings; /** * Create Word section properties */ export declare function createSectionProperties(columnSettings: ColumnSettings, theme: ThemeConfig, themeName: string, sectionType?: 'continuous' | 'nextPage', pageOverride?: { size?: 'A4' | 'A3' | 'LETTER' | 'LEGAL' | { width: number; height: number; }; margins?: { top?: number; bottom?: number; left?: number; right?: number; header?: number; footer?: number; gutter?: number; }; }): WordSectionProperties; /** * Calculate optimal column distribution for content */ export declare function calculateColumnDistribution(components: ComponentDefinition[], columnCount: number): ComponentDefinition[][]; //# sourceMappingURL=layout.d.ts.map