@teaui/core
Version:
A high-level terminal UI library for Node
56 lines (55 loc) • 1.95 kB
TypeScript
import { Container, type Props as ContainerProps } from '../Container.js';
import { Size } from '../geometry.js';
import { View } from '../View.js';
import { Viewport } from '../Viewport.js';
import { System } from '../System.js';
import { type MouseEvent, type KeyEvent } from '../events/index.js';
interface Props extends ContainerProps {
activeIndex?: number;
onChange?: (index: number) => void;
}
interface SectionProps extends ContainerProps {
title?: string;
}
export declare class Page extends Container {
#private;
static Section: typeof Section;
static create(sections: ([string, View] | Section)[], extraProps?: Props): Page;
constructor(props?: Props);
update(props: Props): void;
get sections(): SectionLike[];
get activeIndex(): number;
set activeIndex(value: number);
addSection(title: string, view: View): void;
addSection(section: Section): void;
naturalSize(available: Size): Size;
receiveKey(event: KeyEvent): void;
receiveMouse(event: MouseEvent, system: System): void;
receiveTick(dt: number): boolean;
render(viewport: Viewport): void;
}
declare class Section extends Container {
#private;
static create(title: string, child: View, extraProps?: Omit<SectionProps, 'title'>): Section;
constructor({ title, ...props }: SectionProps);
/**
* Returns the explicit title if set, otherwise falls back to the first
* child's `heading` property.
*/
get title(): string;
set title(value: string);
update({ title, ...props }: SectionProps): void;
}
/**
* Lightweight wrapper so non-Section children can be treated uniformly.
* Delegates rendering and sizing to the underlying view.
*/
declare class ImplicitSection {
#private;
constructor(view: View);
get title(): string;
naturalSize(available: Size): Size;
render(viewport: Viewport): void;
}
type SectionLike = Section | ImplicitSection;
export {};