UNPKG

@oclif/table

Version:

Display table in terminal

59 lines (58 loc) 2.6 kB
import React from 'react'; import { CellProps, ContainerProps, HorizontalAlignment, Overflow, TableOptions } from './types.js'; export declare function formatTextWithMargins({ horizontalAlignment, overflow, padding, trimWhitespace, value, width, }: { overflow: Overflow; value: unknown; width: number; padding: number; horizontalAlignment: HorizontalAlignment; trimWhitespace?: boolean; }): { text: string; marginLeft: number; marginRight: number; }; export declare function Table<T extends Record<string, unknown>>(props: TableOptions<T>): React.JSX.Element; /** * Renders the header of a table. */ export declare function Header(props: React.PropsWithChildren): React.JSX.Element; /** * Renders a cell in the table. */ export declare function Cell(props: CellProps): React.JSX.Element; /** * Renders the scaffold of the table. */ export declare function Skeleton(props: React.PropsWithChildren & { readonly height?: number; }): React.JSX.Element; /** * Prints a table based on the provided options. If the data length exceeds 10,000 entries, * the table is rendered in a non-styled format to avoid memory issues. * * @template T - A generic type that extends a record with string keys and unknown values. * @param {TableOptions<T>} options - The options for rendering the table, including data and other configurations. * @returns {void} */ export declare function printTable<T extends Record<string, unknown>>(options: TableOptions<T>): void; /** * Generates a table as a string based on the provided options. * * @template T - A generic type extending a record with string keys and unknown values. * @param {TableOptions<T>} options - The options to configure the table. * @returns {string} The rendered table as a string. */ export declare function makeTable<T extends Record<string, unknown>>(options: TableOptions<T>): string; /** * Prints multiple tables to the console. * * @template T - An array of records where each record represents a table. * @param {Object.<keyof T, TableOptions<T[keyof T]>>} tables - An object containing table options for each table. * @param {Omit<ContainerProps, 'children'>} [options] - Optional container properties excluding 'children'. * @throws {Error} Throws an error if the total number of rows across all tables exceeds 10,000. * @throws {Error} Throws an error if any of the tables have `maxWidth: "none"`. */ export declare function printTables<T extends Record<string, unknown>[]>(tables: { [P in keyof T]: TableOptions<T[P]>; }, options?: Omit<ContainerProps, 'children'>): void;