UNPKG

4.18 kBTypeScriptView Raw
1export declare type DrawLinePredicate = (index: number, size: number) => boolean;
2export declare type DrawVerticalLine = DrawLinePredicate;
3export declare type DrawHorizontalLine = DrawLinePredicate;
4export declare type BorderUserConfig = {
5 readonly topLeft?: string;
6 readonly topRight?: string;
7 readonly topBody?: string;
8 readonly topJoin?: string;
9 readonly bottomLeft?: string;
10 readonly bottomRight?: string;
11 readonly bottomBody?: string;
12 readonly bottomJoin?: string;
13 readonly joinLeft?: string;
14 readonly joinRight?: string;
15 readonly joinBody?: string;
16 readonly joinJoin?: string;
17 readonly joinMiddleUp?: string;
18 readonly joinMiddleDown?: string;
19 readonly joinMiddleLeft?: string;
20 readonly joinMiddleRight?: string;
21 readonly headerJoin?: string;
22 readonly bodyRight?: string;
23 readonly bodyLeft?: string;
24 readonly bodyJoin?: string;
25};
26export declare type BorderConfig = Required<BorderUserConfig>;
27export declare type Alignment = 'center' | 'justify' | 'left' | 'right';
28export declare type VerticalAlignment = 'bottom' | 'middle' | 'top';
29export declare type CellUserConfig = {
30 /**
31 * Cell content horizontal alignment (default: left)
32 */
33 readonly alignment?: Alignment;
34 /**
35 * Cell content vertical alignment (default: top)
36 */
37 readonly verticalAlignment?: VerticalAlignment;
38 /**
39 * Number of characters are which the content will be truncated (default: Infinity)
40 */
41 readonly truncate?: number;
42 /**
43 * Cell content padding width left (default: 1)
44 */
45 readonly paddingLeft?: number;
46 /**
47 * Cell content padding width right (default: 1)
48 */
49 readonly paddingRight?: number;
50 /**
51 * If true, the text is broken at the nearest space or one of the special characters: "\|/_.,;-"
52 */
53 readonly wrapWord?: boolean;
54};
55export declare type ColumnUserConfig = CellUserConfig & {
56 /**
57 * Column width (default: auto calculation based on the cell content)
58 */
59 readonly width?: number;
60};
61/**
62 * @deprecated Use spanning cell API instead
63 */
64export declare type HeaderUserConfig = Omit<ColumnUserConfig, 'verticalAlignment' | 'width'> & {
65 readonly content: string;
66};
67export declare type BaseUserConfig = {
68 /**
69 * Custom border
70 */
71 readonly border?: BorderUserConfig;
72 /**
73 * Default values for all columns. Column specific settings overwrite the default values.
74 */
75 readonly columnDefault?: ColumnUserConfig;
76 /**
77 * Column specific configuration.
78 */
79 readonly columns?: Indexable<ColumnUserConfig>;
80 /**
81 * Used to tell whether to draw a vertical line.
82 * This callback is called for each non-content line of the table.
83 * The default behavior is to always return true.
84 */
85 readonly drawVerticalLine?: DrawVerticalLine;
86};
87export declare type TableUserConfig = BaseUserConfig & {
88 /**
89 * The header configuration
90 */
91 readonly header?: HeaderUserConfig;
92 /**
93 * Used to tell whether to draw a horizontal line.
94 * This callback is called for each non-content line of the table.
95 * The default behavior is to always return true.
96 */
97 readonly drawHorizontalLine?: DrawHorizontalLine;
98 /**
99 * Horizontal lines inside the table are not drawn.
100 */
101 readonly singleLine?: boolean;
102 readonly spanningCells?: SpanningCellConfig[];
103};
104export declare type SpanningCellConfig = CellUserConfig & {
105 readonly row: number;
106 readonly col: number;
107 readonly rowSpan?: number;
108 readonly colSpan?: number;
109};
110export declare type StreamUserConfig = BaseUserConfig & {
111 /**
112 * The number of columns
113 */
114 readonly columnCount: number;
115 /**
116 * Default values for all columns. Column specific settings overwrite the default values.
117 */
118 readonly columnDefault: ColumnUserConfig & {
119 /**
120 * The default width for each column
121 */
122 readonly width: number;
123 };
124};
125export declare type WritableStream = {
126 readonly write: (rows: string[]) => void;
127};
128export declare type Indexable<T> = {
129 readonly [index: number]: T;
130};