UNPKG

asciitorium

Version:
39 lines (38 loc) 1.81 kB
import type { SizeValue, SizeContext } from '../types.js'; /** * Parse a percentage string and return the numeric value * @param value - Percentage string like "50%" * @returns Numeric percentage (0.5 for "50%") */ export declare function parsePercentage(value: string): number; /** * Check if a size value is a percentage string * @param value - Size value to check * @returns True if the value is a percentage string */ export declare function isPercentage(value: SizeValue): value is `${number}%`; /** * Resolve a SizeValue to an absolute pixel value * @param size - The size value to resolve * @param context - Parent size context for percentage calculations * @param dimension - Whether this is width or height (affects which parent dimension to use) * @returns Absolute size in characters */ export declare function resolveSize(size: SizeValue | undefined, context: SizeContext, dimension: 'width' | 'height'): number | undefined; /** * Calculate the available space after accounting for fixed-size children * @param parentSize - Total parent size * @param children - Array of child size values * @param context - Size context for resolution * @param dimension - Width or height dimension * @returns Available space for flexible children */ export declare function calculateAvailableSpace(parentSize: number, children: (SizeValue | undefined)[], context: SizeContext, dimension: 'width' | 'height'): number; /** * Create a SizeContext from parent dimensions * @param parentWidth - Parent component width * @param parentHeight - Parent component height * @param borderPadding - Border padding to account for * @returns SizeContext for child calculations */ export declare function createSizeContext(parentWidth: number, parentHeight: number, borderPadding?: number): SizeContext;