UNPKG

@teaui/core

Version:

A high-level terminal UI library for Node

84 lines (83 loc) 3.04 kB
import type { Viewport } from '../Viewport.js'; import { type Props as ContainerProps, Container } from '../Container.js'; import { View } from '../View.js'; import { Size } from '../geometry.js'; import { Style } from '../Style.js'; import { type Direction } from '../types.js'; interface Props extends ContainerProps { /** * Layout direction for rows. * - 'down' (default): rows stack top-to-bottom, columns go left-to-right * - 'up': rows stack bottom-to-top, columns go left-to-right * - 'left': columns stack right-to-left, rows go top-to-bottom * - 'right': columns stack left-to-right, rows go top-to-bottom * @default 'down' */ direction?: Direction; /** * The separator character drawn between aligned columns. * @default '│' */ separator?: string; /** * Style applied to the separator character. */ separatorStyle?: Style; } type ShorthandProps = NonNullable<Props['children']> | Omit<Props, 'direction'>; /** * AlignRow (or AlignColumn) groups children into aligned columns. * When placed inside an Align container, each child occupies a column * that is sized to the maximum width across all rows. * * Children that are not AlignRow instances span the full width. */ export declare class AlignRow extends Container { constructor(props?: ContainerProps); update(props: ContainerProps): void; naturalSize(available: Size): Size; render(viewport: Viewport): void; } /** * Align manages columnar alignment across multiple rows. * * Each child can be an `AlignRow` (whose children become aligned columns) * or any other View (which spans the full width). * * ```ts * new Align({ * children: [ * Align.row([ * new Text({text: 'Actors'}), * new Text({text: 'Keanu Reeves, Lori Petty'}), * ]), * Align.row([ * new Text({text: 'Released'}), * new Text({text: '1991'}), * ]), * ], * }) * ``` */ export declare class Align extends Container { #private; static down(props?: ShorthandProps, extraProps?: Omit<Props, 'children' | 'direction'>): Align; static up(props?: ShorthandProps, extraProps?: Omit<Props, 'children' | 'direction'>): Align; static right(props?: ShorthandProps, extraProps?: Omit<Props, 'children' | 'direction'>): Align; static left(props?: ShorthandProps, extraProps?: Omit<Props, 'children' | 'direction'>): Align; /** Alias for Align.right / Align.left */ static column: typeof Align.right; /** * Creates an AlignRow with the given children. */ static row(children: View[]): AlignRow; constructor({ children, child, direction, separator, separatorStyle, ...props }: Props); update({ children, child, direction, separator, separatorStyle, ...props }: Props): void; add(child: View, at?: number): void; removeChild(child: View): void; removeAllChildren(): void; get children(): View[]; naturalSize(available: Size): Size; render(viewport: Viewport): void; } export {};