import type { IOutput } from '../io'; /** * Type of horizontal spacer, such as between the header and rows. */ export declare enum HorizontalSpacerType { TOP = 0, MIDDLE = 1, BOTTOM = 2 } /** * Type of vertical spacer used between adjacent columns in the same row. */ export declare enum VerticalSpacerType { LEFT = 0, INNER = 1, RIGHT = 2 } /** * Abstract base class for table which displays a 2D grid of headers and rows with each column sized * to fit its longest item. The number of columns is given by the maximum number of items in all * rows ahd header rows; rows with fewer items are right-padded with empty strings. It does not * care about terminal width or height, so may overrun in width and take up more than page. */ declare abstract class BaseTable { readonly options: BaseTable.IOptions; constructor(options: BaseTable.IOptions); addHeaderRow(headerRow: string[]): void; addRow(row: string[]): void; /** * Return a default colorByColumn map for clients that want to color columns but don't want to * define their own. */ static defaultColorByColumn(): Map; /** * Generator for output lines, one at a time. * @param prefix String to insert at beginning of each line, default ''. * @param suffix String to append to end of each line, default ''. */ lines(prefix?: string, suffix?: string): Generator; /** * Return horizontal spacer, such as between the header and rows, or undefined if there is no * such spacer. */ protected abstract horizontalSpacer(type: HorizontalSpacerType): string | undefined; /** * Returns number of rows in body of table. Does not include header rows. */ get rowCount(): number; /** * Return vertical spacer, i.e. spacer between adjacent columns in the same row. */ protected abstract verticalSpacer(type: VerticalSpacerType): string; /** * Write table to output. * @param output Output to write to. * @param prefix String to insert at beginning of each line, default ''. * @param suffix String to append to end of each line, default '\n'. */ write(output: IOutput, prefix?: string, suffix?: string): void; private _cleanString; private _updateColumnWidths; protected _columnWidths: number[]; private _headerRows; private _rows; } /** * Simple table with horizontal line between header and rows such as: * * header1 header2 * ──────────────── * aaaa bbb * cc dd */ export declare class Table extends BaseTable { constructor(options?: Table.IOptions); protected horizontalSpacer(type: HorizontalSpacerType): string | undefined; protected verticalSpacer(type: VerticalSpacerType): string; private _totalSeparatorSize; private _spacer; private _spacersAtEnds; } /** * Table with border such as: * * ╭─────────┬─────────╮", * │ header1 │ header2 │", * ├─────────┼─────────┤", * │ aaaa │ bbb │", * │ cc │ d │", * ╰─────────┴─────────╯", */ export declare class BorderTable extends BaseTable { constructor(options?: BorderTable.IOptions); protected horizontalSpacer(type: HorizontalSpacerType): string | undefined; protected verticalSpacer(type: VerticalSpacerType): string; } export declare namespace BaseTable { interface IOptions { colorByColumn?: Map; sortByColumn?: number[]; } } export declare namespace Table { interface IOptions extends BaseTable.IOptions { spacerSize?: number; spacersAtEnds?: boolean; } } export declare namespace BorderTable { interface IOptions extends BaseTable.IOptions { } } export {};