UNPKG

@teaui/core

Version:

A high-level terminal UI library for Node

58 lines (57 loc) 2.54 kB
import type { Viewport } from '../Viewport.js'; import { type Props as ViewProps, View } from '../View.js'; import { Container } from '../Container.js'; import { Size } from '../geometry.js'; import type { Location } from './ZStack.js'; interface Props extends ViewProps { children?: View[]; child?: View; location?: Location; useAvailable?: boolean; } type ShorthandProps = NonNullable<Props['children']> | Omit<Props, 'location'>; /** * Positions its children at a fixed location within the available space. * Children are rendered as a ZStack (overlaid on top of each other), then * placed according to `location`. * * Designed for use inside a ZStack to anchor content at edges or corners. * * When `useAvailable` is true, the component uses the viewport's * `availableRect` instead of `contentRect` for sizing and placement. * * ```ts * new ZStack({ * children: [ * new Space({background: '#333'}), * At.topRight([new Text({text: 'top-right'})]), * At.bottomCenter([new Text({text: 'bottom'})]), * ], * }) * ``` */ export declare class At extends Container { #private; static topLeft(props?: ShorthandProps, extraProps?: Omit<Props, 'children' | 'location'>): At; static topCenter(props?: ShorthandProps, extraProps?: Omit<Props, 'children' | 'location'>): At; static topRight(props?: ShorthandProps, extraProps?: Omit<Props, 'children' | 'location'>): At; static left(props?: ShorthandProps, extraProps?: Omit<Props, 'children' | 'location'>): At; static center(props?: ShorthandProps, extraProps?: Omit<Props, 'children' | 'location'>): At; static right(props?: ShorthandProps, extraProps?: Omit<Props, 'children' | 'location'>): At; static bottomLeft(props?: ShorthandProps, extraProps?: Omit<Props, 'children' | 'location'>): At; static bottomCenter(props?: ShorthandProps, extraProps?: Omit<Props, 'children' | 'location'>): At; static bottomRight(props?: ShorthandProps, extraProps?: Omit<Props, 'children' | 'location'>): At; constructor({ children, child, location, useAvailable, ...viewProps }: Props); get location(): Location; set location(value: Location); get useAvailable(): boolean; set useAvailable(value: boolean); update({ children, child, location, useAvailable, ...props }: Props): void; /** * The At component fills all available space — it's meant to be used * inside a ZStack layer. */ naturalSize(available: Size): Size; render(viewport: Viewport): void; } export {};