1declare namespace CliTable3 { 2 type CharName = 3 "top" | 4 "top-mid" | 5 "top-left" | 6 "top-right" | 7 "bottom" | 8 "bottom-mid" | 9 "bottom-left" | 10 "bottom-right" | 11 "left" | 12 "left-mid" | 13 "mid" | 14 "mid-mid" | 15 "right" | 16 "right-mid" | 17 "middle"; 18 19 type HorizontalAlignment = "left" | "center" | "right"; 20 type VerticalAlignment = "top" | "center" | "bottom"; 21 22 interface TableOptions { 23 truncate: string; 24 colWidths: Array<number | null>; 25 rowHeights: Array<number | null>; 26 colAligns: HorizontalAlignment[]; 27 rowAligns: VerticalAlignment[]; 28 head: string[]; 29 wordWrap: boolean; 30 } 31 32 interface TableInstanceOptions extends TableOptions { 33 chars: Record<CharName, string>; 34 style: { 35 "padding-left": number; 36 "padding-right": number; 37 head: string[]; 38 border: string[]; 39 compact: boolean; 40 }; 41 } 42 43 interface TableConstructorOptions extends Partial<TableOptions> { 44 chars?: Partial<Record<CharName, string>>; 45 style?: Partial<TableInstanceOptions["style"]>; 46 } 47 48 type CellValue = boolean | number | string | null | undefined; 49 50 interface CellOptions { 51 content: CellValue; 52 chars?: Partial<Record<CharName, string>>; 53 truncate?: string; 54 colSpan?: number; 55 rowSpan?: number; 56 hAlign?: HorizontalAlignment; 57 vAlign?: VerticalAlignment; 58 style?: { 59 "padding-left"?: number; 60 "padding-right"?: number; 61 head?: string[]; 62 border?: string[]; 63 }; 64 } 65 66 interface GenericTable<T> extends Array<T> { 67 options: TableInstanceOptions; 68 readonly width: number; 69 } 70 71 type Table = HorizontalTable | VerticalTable | CrossTable; 72 type Cell = CellValue | CellOptions; 73 74 type HorizontalTable = GenericTable<HorizontalTableRow>; 75 type HorizontalTableRow = Cell[]; 76 77 type VerticalTable = GenericTable<VerticalTableRow>; 78 interface VerticalTableRow { 79 [name: string]: Cell; 80 } 81 82 type CrossTable = GenericTable<CrossTableRow>; 83 interface CrossTableRow { 84 [name: string]: Cell[]; 85 } 86} 87 88interface CliTable3 { 89 new (options?: CliTable3.TableConstructorOptions): CliTable3.Table; 90 readonly prototype: CliTable3.Table; 91} 92 93declare const CliTable3: CliTable3; 94 95export = CliTable3; 96