@termuijs/ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +780 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +285 -0
- package/dist/index.d.ts +285 -0
- package/dist/index.js +746 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { Widget } from '@termuijs/widgets';
|
|
2
|
+
export { Box, Gauge, List, LogView, ProgressBar, Sparkline, Spinner, StatusIndicator, Table, Text, TextInput, Widget } from '@termuijs/widgets';
|
|
3
|
+
import { Style, Screen } from '@termuijs/core';
|
|
4
|
+
|
|
5
|
+
interface DividerOptions {
|
|
6
|
+
char?: string;
|
|
7
|
+
color?: Style['fg'];
|
|
8
|
+
title?: string;
|
|
9
|
+
}
|
|
10
|
+
declare class Divider extends Widget {
|
|
11
|
+
private _char;
|
|
12
|
+
private _color;
|
|
13
|
+
private _title;
|
|
14
|
+
constructor(options?: DividerOptions);
|
|
15
|
+
protected _renderSelf(screen: Screen): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare class Spacer extends Widget {
|
|
19
|
+
constructor(grow?: number);
|
|
20
|
+
protected _renderSelf(_screen: Screen): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface Tab {
|
|
24
|
+
label: string;
|
|
25
|
+
content: Widget;
|
|
26
|
+
}
|
|
27
|
+
interface TabsOptions {
|
|
28
|
+
activeColor?: Style['fg'];
|
|
29
|
+
inactiveColor?: Style['fg'];
|
|
30
|
+
border?: Style['border'];
|
|
31
|
+
}
|
|
32
|
+
declare class Tabs extends Widget {
|
|
33
|
+
private _tabs;
|
|
34
|
+
private _activeIndex;
|
|
35
|
+
private _activeColor;
|
|
36
|
+
private _inactiveColor;
|
|
37
|
+
focusable: boolean;
|
|
38
|
+
constructor(tabs: Tab[], options?: TabsOptions);
|
|
39
|
+
get activeIndex(): number;
|
|
40
|
+
selectTab(i: number): void;
|
|
41
|
+
nextTab(): void;
|
|
42
|
+
prevTab(): void;
|
|
43
|
+
get activeContent(): Widget | undefined;
|
|
44
|
+
protected _renderSelf(screen: Screen): void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface ModalOptions {
|
|
48
|
+
title?: string;
|
|
49
|
+
width?: number;
|
|
50
|
+
height?: number;
|
|
51
|
+
borderColor?: Style['fg'];
|
|
52
|
+
backdropChar?: string;
|
|
53
|
+
}
|
|
54
|
+
declare class Modal extends Widget {
|
|
55
|
+
private _title;
|
|
56
|
+
private _modalWidth;
|
|
57
|
+
private _modalHeight;
|
|
58
|
+
private _borderColor;
|
|
59
|
+
private _backdropChar;
|
|
60
|
+
private _visible;
|
|
61
|
+
private _content;
|
|
62
|
+
constructor(options?: ModalOptions);
|
|
63
|
+
get visible(): boolean;
|
|
64
|
+
show(): void;
|
|
65
|
+
hide(): void;
|
|
66
|
+
toggle(): void;
|
|
67
|
+
setContent(content: Widget): void;
|
|
68
|
+
protected _renderSelf(screen: Screen): void;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface SelectOption {
|
|
72
|
+
label: string;
|
|
73
|
+
value: string;
|
|
74
|
+
disabled?: boolean;
|
|
75
|
+
}
|
|
76
|
+
interface SelectOptions {
|
|
77
|
+
placeholder?: string;
|
|
78
|
+
activeColor?: Style['fg'];
|
|
79
|
+
onSelect?: (option: SelectOption, index: number) => void;
|
|
80
|
+
}
|
|
81
|
+
declare class Select extends Widget {
|
|
82
|
+
private _options;
|
|
83
|
+
private _selectedIndex;
|
|
84
|
+
private _isOpen;
|
|
85
|
+
private _placeholder;
|
|
86
|
+
private _activeColor;
|
|
87
|
+
private _onSelect?;
|
|
88
|
+
focusable: boolean;
|
|
89
|
+
constructor(options: SelectOption[], config?: SelectOptions);
|
|
90
|
+
get selectedOption(): SelectOption | undefined;
|
|
91
|
+
get selectedIndex(): number;
|
|
92
|
+
get isOpen(): boolean;
|
|
93
|
+
open(): void;
|
|
94
|
+
close(): void;
|
|
95
|
+
toggle(): void;
|
|
96
|
+
selectNext(): void;
|
|
97
|
+
selectPrev(): void;
|
|
98
|
+
confirm(): void;
|
|
99
|
+
protected _renderSelf(screen: Screen): void;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
interface MultiSelectOption {
|
|
103
|
+
label: string;
|
|
104
|
+
value: string;
|
|
105
|
+
disabled?: boolean;
|
|
106
|
+
}
|
|
107
|
+
interface MultiSelectOptions {
|
|
108
|
+
activeColor?: Style['fg'];
|
|
109
|
+
checkChar?: string;
|
|
110
|
+
uncheckChar?: string;
|
|
111
|
+
onSubmit?: (selected: MultiSelectOption[]) => void;
|
|
112
|
+
}
|
|
113
|
+
declare class MultiSelect extends Widget {
|
|
114
|
+
private _options;
|
|
115
|
+
private _cursorIndex;
|
|
116
|
+
private _checked;
|
|
117
|
+
private _activeColor;
|
|
118
|
+
private _checkChar;
|
|
119
|
+
private _uncheckChar;
|
|
120
|
+
private _onSubmit?;
|
|
121
|
+
focusable: boolean;
|
|
122
|
+
constructor(options: MultiSelectOption[], config?: MultiSelectOptions);
|
|
123
|
+
get selectedOptions(): MultiSelectOption[];
|
|
124
|
+
selectNext(): void;
|
|
125
|
+
selectPrev(): void;
|
|
126
|
+
toggleCurrent(): void;
|
|
127
|
+
submit(): void;
|
|
128
|
+
protected _renderSelf(screen: Screen): void;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface TreeNode {
|
|
132
|
+
label: string;
|
|
133
|
+
children?: TreeNode[];
|
|
134
|
+
expanded?: boolean;
|
|
135
|
+
icon?: string;
|
|
136
|
+
}
|
|
137
|
+
interface TreeOptions {
|
|
138
|
+
activeColor?: Style['fg'];
|
|
139
|
+
onSelect?: (node: TreeNode, path: number[]) => void;
|
|
140
|
+
}
|
|
141
|
+
declare class Tree extends Widget {
|
|
142
|
+
private _roots;
|
|
143
|
+
private _cursorIndex;
|
|
144
|
+
private _activeColor;
|
|
145
|
+
private _onSelect?;
|
|
146
|
+
focusable: boolean;
|
|
147
|
+
constructor(roots: TreeNode[], options?: TreeOptions);
|
|
148
|
+
private _flatten;
|
|
149
|
+
selectNext(): void;
|
|
150
|
+
selectPrev(): void;
|
|
151
|
+
toggleExpand(): void;
|
|
152
|
+
confirm(): void;
|
|
153
|
+
protected _renderSelf(screen: Screen): void;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
type ToastType = 'info' | 'success' | 'warning' | 'error';
|
|
157
|
+
interface ToastMessage {
|
|
158
|
+
text: string;
|
|
159
|
+
type: ToastType;
|
|
160
|
+
expireAt: number;
|
|
161
|
+
}
|
|
162
|
+
interface ToastOptions {
|
|
163
|
+
position?: 'top-right' | 'bottom-right' | 'top-left' | 'bottom-left';
|
|
164
|
+
durationMs?: number;
|
|
165
|
+
maxVisible?: number;
|
|
166
|
+
}
|
|
167
|
+
declare class Toast extends Widget {
|
|
168
|
+
private _messages;
|
|
169
|
+
private _position;
|
|
170
|
+
private _durationMs;
|
|
171
|
+
private _maxVisible;
|
|
172
|
+
constructor(options?: ToastOptions);
|
|
173
|
+
push(text: string, type?: ToastType): void;
|
|
174
|
+
info(text: string): void;
|
|
175
|
+
success(text: string): void;
|
|
176
|
+
warning(text: string): void;
|
|
177
|
+
error(text: string): void;
|
|
178
|
+
protected _renderSelf(screen: Screen): void;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
interface ConfirmDialogOptions {
|
|
182
|
+
message: string;
|
|
183
|
+
confirmLabel?: string;
|
|
184
|
+
cancelLabel?: string;
|
|
185
|
+
borderColor?: Style['fg'];
|
|
186
|
+
onConfirm?: () => void;
|
|
187
|
+
onCancel?: () => void;
|
|
188
|
+
}
|
|
189
|
+
declare class ConfirmDialog extends Widget {
|
|
190
|
+
private _message;
|
|
191
|
+
private _confirmLabel;
|
|
192
|
+
private _cancelLabel;
|
|
193
|
+
private _borderColor;
|
|
194
|
+
private _selected;
|
|
195
|
+
private _visible;
|
|
196
|
+
private _onConfirm?;
|
|
197
|
+
private _onCancel?;
|
|
198
|
+
focusable: boolean;
|
|
199
|
+
constructor(options: ConfirmDialogOptions);
|
|
200
|
+
get visible(): boolean;
|
|
201
|
+
show(): void;
|
|
202
|
+
hide(): void;
|
|
203
|
+
selectConfirm(): void;
|
|
204
|
+
selectCancel(): void;
|
|
205
|
+
toggleSelection(): void;
|
|
206
|
+
confirm(): void;
|
|
207
|
+
protected _renderSelf(screen: Screen): void;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
interface FormField {
|
|
211
|
+
name: string;
|
|
212
|
+
label: string;
|
|
213
|
+
type: 'text' | 'select' | 'checkbox';
|
|
214
|
+
placeholder?: string;
|
|
215
|
+
required?: boolean;
|
|
216
|
+
options?: string[];
|
|
217
|
+
validate?: (value: string) => string | null;
|
|
218
|
+
}
|
|
219
|
+
interface FormOptions {
|
|
220
|
+
labelColor?: Style['fg'];
|
|
221
|
+
errorColor?: Style['fg'];
|
|
222
|
+
activeColor?: Style['fg'];
|
|
223
|
+
onSubmit?: (values: Record<string, string>) => void;
|
|
224
|
+
}
|
|
225
|
+
declare class Form extends Widget {
|
|
226
|
+
private _fields;
|
|
227
|
+
private _values;
|
|
228
|
+
private _errors;
|
|
229
|
+
private _activeField;
|
|
230
|
+
private _cursorPos;
|
|
231
|
+
private _labelColor;
|
|
232
|
+
private _errorColor;
|
|
233
|
+
private _activeColor;
|
|
234
|
+
private _onSubmit?;
|
|
235
|
+
focusable: boolean;
|
|
236
|
+
constructor(fields: FormField[], options?: FormOptions);
|
|
237
|
+
get values(): Record<string, string>;
|
|
238
|
+
nextField(): void;
|
|
239
|
+
prevField(): void;
|
|
240
|
+
insertChar(ch: string): void;
|
|
241
|
+
deleteBack(): void;
|
|
242
|
+
submit(): void;
|
|
243
|
+
protected _renderSelf(screen: Screen): void;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
interface Command {
|
|
247
|
+
id: string;
|
|
248
|
+
label: string;
|
|
249
|
+
shortcut?: string;
|
|
250
|
+
action: () => void;
|
|
251
|
+
category?: string;
|
|
252
|
+
}
|
|
253
|
+
interface CommandPaletteOptions {
|
|
254
|
+
placeholder?: string;
|
|
255
|
+
borderColor?: Style['fg'];
|
|
256
|
+
activeColor?: Style['fg'];
|
|
257
|
+
maxVisible?: number;
|
|
258
|
+
}
|
|
259
|
+
declare class CommandPalette extends Widget {
|
|
260
|
+
private _commands;
|
|
261
|
+
private _filtered;
|
|
262
|
+
private _query;
|
|
263
|
+
private _cursorPos;
|
|
264
|
+
private _selectedIndex;
|
|
265
|
+
private _visible;
|
|
266
|
+
private _placeholder;
|
|
267
|
+
private _borderColor;
|
|
268
|
+
private _activeColor;
|
|
269
|
+
private _maxVisible;
|
|
270
|
+
focusable: boolean;
|
|
271
|
+
constructor(commands: Command[], options?: CommandPaletteOptions);
|
|
272
|
+
get visible(): boolean;
|
|
273
|
+
show(): void;
|
|
274
|
+
hide(): void;
|
|
275
|
+
toggle(): void;
|
|
276
|
+
insertChar(ch: string): void;
|
|
277
|
+
deleteBack(): void;
|
|
278
|
+
selectNext(): void;
|
|
279
|
+
selectPrev(): void;
|
|
280
|
+
confirm(): void;
|
|
281
|
+
private _filter;
|
|
282
|
+
protected _renderSelf(screen: Screen): void;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export { type Command, CommandPalette, type CommandPaletteOptions, ConfirmDialog, type ConfirmDialogOptions, Divider, type DividerOptions, Form, type FormField, type FormOptions, Modal, type ModalOptions, MultiSelect, type MultiSelectOption, type MultiSelectOptions, Select, type SelectOption, type SelectOptions, Spacer, type Tab, Tabs, type TabsOptions, Toast, type ToastMessage, type ToastOptions, type ToastType, Tree, type TreeNode, type TreeOptions };
|