1 | declare namespace CliTable2 {
|
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: Cell[];
|
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>> | undefined;
|
45 | style?: Partial<TableInstanceOptions["style"]> | undefined;
|
46 | }
|
47 |
|
48 | type CellValue = boolean | number | string | null | undefined;
|
49 |
|
50 | interface CellOptions {
|
51 | content: CellValue;
|
52 | chars?: Partial<Record<CharName, string>> | undefined;
|
53 | truncate?: string | undefined;
|
54 | colSpan?: number | undefined;
|
55 | rowSpan?: number | undefined;
|
56 | hAlign?: HorizontalAlignment | undefined;
|
57 | vAlign?: VerticalAlignment | undefined;
|
58 | style?: {
|
59 | "padding-left"?: number | undefined;
|
60 | "padding-right"?: number | undefined;
|
61 | head?: string[] | undefined;
|
62 | border?: string[] | undefined;
|
63 | } | undefined;
|
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 |
|
88 | interface CliTable2 {
|
89 | new(options?: CliTable2.TableConstructorOptions): CliTable2.Table;
|
90 | readonly prototype: CliTable2.Table;
|
91 | }
|
92 |
|
93 | declare const CliTable2: CliTable2;
|
94 |
|
95 | export = CliTable2;
|