@termuijs/ui 0.1.4 → 0.1.6

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.d.cts CHANGED
@@ -1,6 +1,55 @@
1
1
  import { Widget } from '@termuijs/widgets';
2
2
  export { Box, Gauge, List, LogView, ProgressBar, Sparkline, Spinner, StatusIndicator, Table, Text, TextInput, Widget } from '@termuijs/widgets';
3
- import { Style, Screen, KeyEvent } from '@termuijs/core';
3
+ import { Style, Screen, KeyEvent, Color, LayoutNode, Rect } from '@termuijs/core';
4
+ import { StandardSchemaV1 } from '@standard-schema/spec';
5
+ import { VNode } from '@termuijs/jsx';
6
+ export * from '@termuijs/tss';
7
+
8
+ interface SliderOptions {
9
+ min: number;
10
+ max: number;
11
+ step?: number;
12
+ value?: number;
13
+ onChange?: (value: number) => void;
14
+ }
15
+ interface RangeInputOptions {
16
+ min: number;
17
+ max: number;
18
+ step?: number;
19
+ low?: number;
20
+ high?: number;
21
+ onChange?: (low: number, high: number) => void;
22
+ }
23
+ declare class Slider extends Widget {
24
+ private _value;
25
+ private _min;
26
+ private _max;
27
+ private _step;
28
+ onChange?: (value: number) => void;
29
+ focusable: boolean;
30
+ constructor(style: Partial<Style> | undefined, opts: SliderOptions);
31
+ private _clamp;
32
+ getValue(): number;
33
+ setValue(value: number): void;
34
+ increment(): void;
35
+ decrement(): void;
36
+ handleKey(event: KeyEvent): void;
37
+ protected _renderSelf(screen: Screen): void;
38
+ }
39
+ declare class RangeInput extends Widget {
40
+ private _low;
41
+ private _high;
42
+ private _min;
43
+ private _max;
44
+ private _step;
45
+ onChange?: (low: number, high: number) => void;
46
+ focusable: boolean;
47
+ constructor(style: Partial<Style> | undefined, opts: RangeInputOptions);
48
+ getLow(): number;
49
+ getHigh(): number;
50
+ setRange(low: number, high: number): void;
51
+ protected _renderSelf(screen: Screen): void;
52
+ }
4
53
 
5
54
  interface DividerOptions {
6
55
  char?: string;
@@ -44,6 +93,93 @@ declare class Tabs extends Widget {
44
93
  protected _renderSelf(screen: Screen): void;
45
94
  }
46
95
 
96
+ interface MenuItem$1 {
97
+ label: string;
98
+ action?: () => void;
99
+ disabled?: boolean;
100
+ }
101
+ interface MenuBarItem {
102
+ label: string;
103
+ items: MenuItem$1[];
104
+ }
105
+ interface MenuBarOptions {
106
+ activeColor?: Color;
107
+ }
108
+ declare class MenuBar extends Widget {
109
+ private _menus;
110
+ private _activeMenu;
111
+ private _isOpen;
112
+ private _activeItem;
113
+ private _activeColor;
114
+ focusable: boolean;
115
+ constructor(menus: MenuBarItem[], style?: Partial<Style>, opts?: MenuBarOptions);
116
+ get activeMenu(): number;
117
+ get isOpen(): boolean;
118
+ get activeItem(): number;
119
+ get menus(): MenuBarItem[];
120
+ setMenus(menus: MenuBarItem[]): void;
121
+ private _initActiveItem;
122
+ private _selectNextItem;
123
+ private _selectPrevItem;
124
+ private _openMenu;
125
+ private _closeMenu;
126
+ selectNextMenu(): void;
127
+ selectPrevMenu(): void;
128
+ handleKey(event: KeyEvent): void;
129
+ protected _renderSelf(screen: Screen): void;
130
+ }
131
+
132
+ interface MenuItem {
133
+ label: string;
134
+ shortcut?: string;
135
+ disabled?: boolean;
136
+ onSelect?: () => void;
137
+ }
138
+ interface MenuOptions {
139
+ items: MenuItem[];
140
+ onClose?: () => void;
141
+ style?: Partial<Style>;
142
+ }
143
+ /**
144
+ * Menu — a vertical list of interactive items supporting keyboard navigation,
145
+ * shortcuts, and disabled states.
146
+ */
147
+ declare class Menu extends Widget {
148
+ private _items;
149
+ private _selectedIndex;
150
+ private _onClose?;
151
+ constructor(options: MenuOptions);
152
+ private _initSelection;
153
+ private _selectNext;
154
+ private _selectPrev;
155
+ private _confirm;
156
+ handleKey(event: KeyEvent): boolean;
157
+ protected _renderSelf(screen: Screen): void;
158
+ }
159
+
160
+ interface CarouselOptions {
161
+ showDots?: boolean;
162
+ onChange?: (index: number) => void;
163
+ }
164
+ declare class Carousel extends Widget {
165
+ private _slides;
166
+ private _activeIndex;
167
+ private _showDots;
168
+ private _onChange?;
169
+ focusable: boolean;
170
+ constructor(slides: string[], options?: CarouselOptions);
171
+ get activeIndex(): number;
172
+ get currentSlide(): string;
173
+ get slides(): string[];
174
+ get showDots(): boolean;
175
+ setIndex(index: number): void;
176
+ next(): void;
177
+ prev(): void;
178
+ handleKey(event: KeyEvent): void;
179
+ protected _renderSelf(screen: Screen): void;
180
+ private _normalizeIndex;
181
+ }
182
+
47
183
  interface ModalOptions {
48
184
  title?: string;
49
185
  width?: number;
@@ -59,7 +195,7 @@ declare class Modal extends Widget {
59
195
  private _backdropChar;
60
196
  private _visible;
61
197
  private _content;
62
- constructor(options?: ModalOptions);
198
+ constructor(options?: ModalOptions, style?: Partial<Style>);
63
199
  get visible(): boolean;
64
200
  show(): void;
65
201
  hide(): void;
@@ -68,6 +204,100 @@ declare class Modal extends Widget {
68
204
  protected _renderSelf(screen: Screen): void;
69
205
  }
70
206
 
207
+ /** The edge from which the drawer slides into view. */
208
+ type DrawerPosition = 'left' | 'right' | 'top' | 'bottom';
209
+ interface DrawerOptions {
210
+ /** Edge the drawer appears from. */
211
+ position: DrawerPosition;
212
+ /**
213
+ * Panel width in columns.
214
+ * Applies to 'left' and 'right' positions only.
215
+ * Defaults to 30.
216
+ */
217
+ width?: number;
218
+ /**
219
+ * Panel height in rows.
220
+ * Applies to 'top' and 'bottom' positions only.
221
+ * Defaults to 10.
222
+ */
223
+ height?: number;
224
+ /** Optional title shown in the drawer's top border. */
225
+ title?: string;
226
+ /** Called when the user presses Escape or explicitly closes the drawer. */
227
+ onClose: () => void;
228
+ /** Character used for the dimmed backdrop. Defaults to '░' (unicode) or ' '. */
229
+ backdropChar?: string;
230
+ /** Border colour. Defaults to cyan. */
231
+ borderColor?: Style['fg'];
232
+ }
233
+ /**
234
+ * Drawer — a side panel that slides in from any edge.
235
+ *
236
+ * Usage:
237
+ * ```ts
238
+ * const drawer = new Drawer({
239
+ * position: 'right',
240
+ * width: 30,
241
+ * title: 'Settings',
242
+ * onClose: () => closeDrawer(),
243
+ * });
244
+ * drawer.addChild(new Form({ fields: settingsFields }));
245
+ * drawer.open();
246
+ * ```
247
+ *
248
+ * Wire keyboard events via `handleKey(event)`.
249
+ */
250
+ declare class Drawer extends Widget {
251
+ private _position;
252
+ private _panelWidth;
253
+ private _panelHeight;
254
+ private _title;
255
+ private _onClose;
256
+ private _backdropChar;
257
+ private _borderColor;
258
+ private _open;
259
+ /**
260
+ * Index into the flat list of focusable children that currently
261
+ * holds the "focused" slot inside the focus trap.
262
+ * Starts at -1 so the first Tab press naturally lands on index 0.
263
+ */
264
+ private _focusIndex;
265
+ focusable: boolean;
266
+ constructor(options: DrawerOptions);
267
+ /** Whether the drawer is currently open. */
268
+ get isOpen(): boolean;
269
+ /** Open the drawer and mark dirty. */
270
+ open(): void;
271
+ /** Close the drawer and mark dirty. */
272
+ close(): void;
273
+ /** Toggle open/close state. */
274
+ toggle(): void;
275
+ /**
276
+ * Handle keyboard input.
277
+ *
278
+ * | Key | Action |
279
+ * |--------------|---------------------------------|
280
+ * | `Escape` | Fire `onClose` |
281
+ * | `Tab` | Move focus to next child |
282
+ * | `Shift+Tab` | Move focus to previous child |
283
+ */
284
+ handleKey(event: KeyEvent): void;
285
+ /**
286
+ * Return a flat list of all focusable descendants in tree order.
287
+ * Used to implement the focus trap.
288
+ */
289
+ private _focusableChildren;
290
+ private _focusNext;
291
+ private _focusPrev;
292
+ private _applyFocus;
293
+ /**
294
+ * Compute the panel rect (position + dimensions) relative to the
295
+ * full widget rect.
296
+ */
297
+ private _panelRect;
298
+ protected _renderSelf(screen: Screen): void;
299
+ }
300
+
71
301
  interface SelectOption {
72
302
  label: string;
73
303
  value: string;
@@ -86,7 +316,7 @@ declare class Select extends Widget {
86
316
  private _activeColor;
87
317
  private _onSelect?;
88
318
  focusable: boolean;
89
- constructor(options: SelectOption[], config?: SelectOptions);
319
+ constructor(options: SelectOption[], config?: SelectOptions, style?: Partial<Style>);
90
320
  get selectedOption(): SelectOption | undefined;
91
321
  get selectedIndex(): number;
92
322
  get isOpen(): boolean;
@@ -99,6 +329,111 @@ declare class Select extends Widget {
99
329
  protected _renderSelf(screen: Screen): void;
100
330
  }
101
331
 
332
+ interface ComboboxOption {
333
+ label: string;
334
+ value: string;
335
+ }
336
+ interface ComboboxOptions {
337
+ placeholder?: string;
338
+ activeColor?: Style['fg'];
339
+ onSelect?: (value: string) => void;
340
+ }
341
+ declare class Combobox extends Widget {
342
+ private _options;
343
+ private _placeholder;
344
+ private _activeColor;
345
+ private _onSelect?;
346
+ private _inputValue;
347
+ private _committedValue;
348
+ private _isOpen;
349
+ private _selectedIndex;
350
+ focusable: boolean;
351
+ constructor(options: ComboboxOption[], config?: ComboboxOptions);
352
+ get value(): string;
353
+ get filtered(): ComboboxOption[];
354
+ handleKey(event: KeyEvent): void;
355
+ protected _renderSelf(screen: Screen): void;
356
+ }
357
+
358
+ interface LinearPromptOption {
359
+ label: string;
360
+ value: string;
361
+ disabled?: boolean;
362
+ }
363
+ interface LinearPromptOptions {
364
+ question: string;
365
+ activeColor?: Style['fg'];
366
+ onSelect?: (option: LinearPromptOption, index: number) => void;
367
+ }
368
+ declare class LinearPrompt extends Widget {
369
+ private _options;
370
+ private _selectedIndex;
371
+ private _question;
372
+ private _activeColor;
373
+ private _onSelect?;
374
+ focusable: boolean;
375
+ constructor(options: LinearPromptOption[], config: LinearPromptOptions);
376
+ get selectedOption(): LinearPromptOption | undefined;
377
+ get selectedIndex(): number;
378
+ selectNext(): void;
379
+ selectPrev(): void;
380
+ confirm(): void;
381
+ handleKey(event: KeyEvent): void;
382
+ protected _renderSelf(screen: Screen): void;
383
+ }
384
+
385
+ interface Page {
386
+ name: string;
387
+ content: Widget;
388
+ overlay?: boolean;
389
+ }
390
+ interface PagesOptions {
391
+ style?: Partial<Style>;
392
+ }
393
+ declare class Pages extends Widget {
394
+ private _pages;
395
+ private _activePageName?;
396
+ constructor(pages: Page[], options?: PagesOptions);
397
+ get activePage(): string | undefined;
398
+ switchTo(name: string): void;
399
+ protected _renderSelf(_screen: Screen): void;
400
+ private _updatePageVisibility;
401
+ }
402
+
403
+ declare class ContentSwitcher extends Widget {
404
+ private _activeId?;
405
+ constructor(style?: Partial<Style>);
406
+ get activeId(): string | undefined;
407
+ addChild(child: Widget): void;
408
+ setActive(id: string): void;
409
+ protected _renderSelf(_screen: Screen): void;
410
+ private _updateChildVisibility;
411
+ }
412
+
413
+ interface SnippetPromptOptions {
414
+ validate?: Record<string, (value: string) => string | null>;
415
+ }
416
+ declare class SnippetPrompt extends Widget {
417
+ private _placeholders;
418
+ private _values;
419
+ private _errors;
420
+ private _validators;
421
+ private _activeIndex;
422
+ constructor(template: string, options?: SnippetPromptOptions);
423
+ readonly template: string;
424
+ get placeholders(): string[];
425
+ get activeField(): string | undefined;
426
+ get values(): Record<string, string>;
427
+ get errors(): Record<string, string>;
428
+ setValue(field: string, value: string): void;
429
+ nextField(): void;
430
+ prevField(): void;
431
+ validate(): boolean;
432
+ buildResult(): string;
433
+ protected _renderSelf(_screen: Screen): void;
434
+ private _parsePlaceholders;
435
+ }
436
+
102
437
  interface MultiSelectOption {
103
438
  label: string;
104
439
  value: string;
@@ -128,6 +463,42 @@ declare class MultiSelect extends Widget {
128
463
  protected _renderSelf(screen: Screen): void;
129
464
  }
130
465
 
466
+ interface TransferItem {
467
+ label: string;
468
+ value: string;
469
+ disabled?: boolean;
470
+ }
471
+ interface TransferOptions {
472
+ activeColor?: Style['fg'];
473
+ onChange?: (targetValues: string[]) => void;
474
+ }
475
+ declare class Transfer extends Widget {
476
+ private _sourceItems;
477
+ private _targetItems;
478
+ private _sourceCursorIndex;
479
+ private _targetCursorIndex;
480
+ private _activePane;
481
+ private _activeColor;
482
+ private _onChange?;
483
+ focusable: boolean;
484
+ constructor(items: TransferItem[], config?: TransferOptions);
485
+ get targetValues(): string[];
486
+ get sourceValues(): string[];
487
+ get targetItems(): TransferItem[];
488
+ get sourceItems(): TransferItem[];
489
+ get activePane(): 'source' | 'target';
490
+ get sourceCursorIndex(): number;
491
+ get targetCursorIndex(): number;
492
+ toggleActivePane(): void;
493
+ private _clampCursors;
494
+ selectNext(): void;
495
+ selectPrev(): void;
496
+ transferToTarget(): void;
497
+ transferToSource(): void;
498
+ handleKey(event: KeyEvent): void;
499
+ protected _renderSelf(screen: Screen): void;
500
+ }
501
+
131
502
  interface TreeNode {
132
503
  label: string;
133
504
  children?: TreeNode[];
@@ -153,6 +524,26 @@ declare class Tree extends Widget {
153
524
  protected _renderSelf(screen: Screen): void;
154
525
  }
155
526
 
527
+ interface SortPromptOptions {
528
+ activeColor?: Style['fg'];
529
+ onSubmit?: (items: string[]) => void;
530
+ }
531
+ declare class SortPrompt extends Widget {
532
+ private _items;
533
+ private _cursorIndex;
534
+ private _activeColor;
535
+ private _onSubmit?;
536
+ focusable: boolean;
537
+ constructor(items: string[], options?: SortPromptOptions);
538
+ selectNext(): void;
539
+ selectPrev(): void;
540
+ moveItemUp(): void;
541
+ moveItemDown(): void;
542
+ submit(): void;
543
+ handleKey(event: KeyEvent): void;
544
+ protected _renderSelf(screen: Screen): void;
545
+ }
546
+
156
547
  type ToastType = 'info' | 'success' | 'warning' | 'error';
157
548
  interface ToastMessage {
158
549
  text: string;
@@ -163,18 +554,22 @@ interface ToastOptions {
163
554
  position?: 'top-right' | 'bottom-right' | 'top-left' | 'bottom-left';
164
555
  durationMs?: number;
165
556
  maxVisible?: number;
557
+ /** Enable screen reader announcements (default: true) */
558
+ announce?: boolean;
166
559
  }
167
560
  declare class Toast extends Widget {
168
561
  private _messages;
169
562
  private _position;
170
563
  private _durationMs;
171
564
  private _maxVisible;
565
+ private _announce;
172
566
  constructor(options?: ToastOptions);
173
567
  push(text: string, type?: ToastType): void;
174
568
  info(text: string): void;
175
569
  success(text: string): void;
176
570
  warning(text: string): void;
177
571
  error(text: string): void;
572
+ private _announceToScreenReader;
178
573
  protected _renderSelf(screen: Screen): void;
179
574
  }
180
575
 
@@ -204,9 +599,13 @@ declare class ConfirmDialog extends Widget {
204
599
  selectCancel(): void;
205
600
  toggleSelection(): void;
206
601
  confirm(): void;
602
+ private handleKey;
207
603
  protected _renderSelf(screen: Screen): void;
208
604
  }
209
605
 
606
+ type InputValidator = StandardSchemaV1 | ((v: unknown) => string | undefined | null);
607
+ declare function validateInput(validator: InputValidator | undefined, value: unknown): string | undefined;
608
+
210
609
  interface FormField {
211
610
  name: string;
212
611
  label: string;
@@ -214,7 +613,7 @@ interface FormField {
214
613
  placeholder?: string;
215
614
  required?: boolean;
216
615
  options?: string[];
217
- validate?: (value: string) => string | null;
616
+ validate?: InputValidator;
218
617
  }
219
618
  interface FormOptions {
220
619
  labelColor?: Style['fg'];
@@ -240,6 +639,8 @@ declare class Form extends Widget {
240
639
  insertChar(ch: string): void;
241
640
  deleteBack(): void;
242
641
  submit(): void;
642
+ /** Minimal key router — printable chars -> insertChar, backspace -> deleteBack */
643
+ handleKey(event: KeyEvent): void;
243
644
  protected _renderSelf(screen: Screen): void;
244
645
  }
245
646
 
@@ -278,10 +679,72 @@ declare class CommandPalette extends Widget {
278
679
  selectNext(): void;
279
680
  selectPrev(): void;
280
681
  confirm(): void;
682
+ /**
683
+ * Handle a KeyEvent from @termuijs/core.
684
+ *
685
+ * Wires all palette interactions to a single entry point so callers
686
+ * only need:
687
+ * app.on('key', e => palette.handleKey(e))
688
+ *
689
+ * Built-in bindings (only active while the palette is visible):
690
+ * Ctrl+P — open / close (toggle)
691
+ * ArrowUp / k — move selection up
692
+ * ArrowDown / j — move selection down
693
+ * Enter — confirm selected command
694
+ * Escape — close
695
+ * Backspace — delete last character
696
+ * any printable — append character to query
697
+ *
698
+ * Ctrl+P is also handled while hidden so the palette can be opened.
699
+ * All handled events have stopPropagation() called automatically.
700
+ */
701
+ handleKey(event: KeyEvent): void;
281
702
  private _filter;
282
703
  protected _renderSelf(screen: Screen): void;
283
704
  }
284
705
 
706
+ interface UseCommandPaletteOptions extends CommandPaletteOptions {
707
+ /** Initial command list */
708
+ commands: Command[];
709
+ }
710
+ interface UseCommandPaletteReturn {
711
+ /** The CommandPalette widget instance — add it to your layout */
712
+ palette: CommandPalette;
713
+ /**
714
+ * Pass this directly to your app's key event listener.
715
+ *
716
+ * @example
717
+ * ```ts
718
+ * const { palette, handleKey } = useCommandPalette({ commands })
719
+ * app.on('key', handleKey)
720
+ * layout.add(palette)
721
+ * ```
722
+ */
723
+ handleKey: (event: KeyEvent) => void;
724
+ }
725
+ /**
726
+ * Create a CommandPalette and return the widget plus a bound key handler.
727
+ *
728
+ * The handler automatically wires Ctrl+P (open/close), arrow navigation,
729
+ * Enter, Escape, Backspace, and character input — no manual binding needed.
730
+ *
731
+ * @example
732
+ * ```ts
733
+ * import { useCommandPalette } from '@termuijs/ui'
734
+ *
735
+ * const { palette, handleKey } = useCommandPalette({
736
+ * commands: [
737
+ * { id: 'save', label: 'Save File', shortcut: 'Ctrl+S', action: () => save() },
738
+ * { id: 'quit', label: 'Quit', category: 'App', action: () => process.exit(0) },
739
+ * ],
740
+ * })
741
+ *
742
+ * app.on('key', handleKey)
743
+ * rootLayout.add(palette)
744
+ * ```
745
+ */
746
+ declare function useCommandPalette(options: UseCommandPaletteOptions): UseCommandPaletteReturn;
747
+
285
748
  declare class NonInteractiveError extends Error {
286
749
  constructor();
287
750
  }
@@ -341,6 +804,7 @@ declare class NotificationStore {
341
804
  push(message: string, type?: Notification['type'], durationMs?: number): string;
342
805
  dismiss(id: string): void;
343
806
  dismissAll(): void;
807
+ reset(): void;
344
808
  subscribe(fn: (notifications: Notification[]) => void): () => void;
345
809
  get notifications(): Notification[];
346
810
  private _emit;
@@ -461,6 +925,80 @@ declare class NumberInput extends Widget {
461
925
  protected _renderSelf(screen: Screen): void;
462
926
  }
463
927
 
928
+ interface TagInputOptions {
929
+ placeholder?: string;
930
+ defaultTags?: string[];
931
+ onChange?: (tags: string[]) => void;
932
+ }
933
+ declare class TagInput extends Widget {
934
+ private _tags;
935
+ private _draft;
936
+ private _placeholder;
937
+ private _onChange?;
938
+ focusable: boolean;
939
+ constructor(style?: Partial<Style>, options?: TagInputOptions);
940
+ /** The current list of committed tags. */
941
+ get tags(): string[];
942
+ /** Add a tag to the list. Empty/whitespace-only strings are ignored. */
943
+ addTag(tag: string): void;
944
+ /** Remove the last tag from the list. No-op if the list is empty. */
945
+ removeLast(): void;
946
+ /**
947
+ * Handle key events. Call this from your input loop.
948
+ */
949
+ handleKey(event: KeyEvent): void;
950
+ /** Format a single chip token using caps.unicode for glyph choice. */
951
+ private _formatChip;
952
+ protected _renderSelf(screen: Screen): void;
953
+ }
954
+
955
+ interface MaskedInputOptions {
956
+ /** Mask template. '_' = editable slot. Other chars are fixed. Example: '__/__/____' */
957
+ mask: string;
958
+ /** Character shown in empty slots. Default: '_' */
959
+ placeholder?: string;
960
+ /** Callback when all slots are filled */
961
+ onComplete?: (value: string) => void;
962
+ /** Callback on every change */
963
+ onChange?: (value: string) => void;
964
+ /** Color for the text */
965
+ color?: Color;
966
+ }
967
+ declare class MaskedInput extends Widget {
968
+ private _mask;
969
+ private _slots;
970
+ private _cursorSlotIndex;
971
+ private _placeholder;
972
+ private _onComplete?;
973
+ private _onChange?;
974
+ private _color?;
975
+ focusable: boolean;
976
+ constructor(style: Partial<Style> | undefined, options: MaskedInputOptions);
977
+ /** Get the complete masked string with current values filled in. */
978
+ getValue(): string;
979
+ /** Reset all slots to empty and position cursor at first slot. */
980
+ reset(): void;
981
+ /** Check if all slots are filled. */
982
+ private _isComplete;
983
+ /** Move cursor to the next empty slot, skipping filled ones. Auto-advance on input. */
984
+ private _advanceToNextEmpty;
985
+ /** Move cursor right to the next slot. */
986
+ private _moveCursorRight;
987
+ /** Move cursor to the previous slot. */
988
+ private _moveCursorLeft;
989
+ /** Insert a digit character at the current slot. Auto-advance past filled chars. */
990
+ private _insertDigit;
991
+ /** Clear the previous slot and move cursor back. */
992
+ private _deleteBack;
993
+ /**
994
+ * Handle key events. Call this from your input loop.
995
+ */
996
+ handleKey(event: KeyEvent): void;
997
+ protected _renderSelf(screen: Screen): void;
998
+ /** Calculate the display position of the cursor (account for fixed chars before it). */
999
+ private _getCursorDisplayPos;
1000
+ }
1001
+
464
1002
  interface PathInputOptions {
465
1003
  placeholder?: string;
466
1004
  maxLength?: number;
@@ -557,4 +1095,1055 @@ declare class KeyboardShortcuts extends Widget {
557
1095
  protected _renderSelf(screen: Screen): void;
558
1096
  }
559
1097
 
560
- export { type Command, CommandPalette, type CommandPaletteOptions, ConfirmDialog, type ConfirmDialogOptions, type ConfirmPromptOptions, Divider, type DividerOptions, Form, type FormField, type FormOptions, KeyboardShortcuts, type KeyboardShortcutsOptions, Modal, type ModalOptions, MultiSelect, type MultiSelectOption, type MultiSelectOptions, NonInteractiveError, type Notification, NotificationCenter, type NotificationCenterOptions, NotificationStore, NumberInput, type NumberInputOptions, PasswordInput, type PasswordInputOptions, PathInput, type PathInputOptions, Select, type SelectOption, type SelectOptions, type SelectPromptOptions, type ShortcutBinding, Spacer, type Tab, Tabs, type TabsOptions, type TextPromptOptions, Toast, type ToastMessage, type ToastOptions, type ToastType, Tree, type TreeNode, type TreeOptions, notifications, prompt, useNotifications };
1098
+ /** A single entry shown in the file picker list. */
1099
+ interface FileEntry {
1100
+ /** Basename only (never a full path). */
1101
+ name: string;
1102
+ /** True when the entry is a directory. */
1103
+ isDir: boolean;
1104
+ /** Resolved absolute path. */
1105
+ fullPath: string;
1106
+ }
1107
+ interface FilePickerOptions {
1108
+ /** Initial directory. Defaults to `process.cwd()`. */
1109
+ startPath?: string;
1110
+ /**
1111
+ * Extension filter (e.g. `['.ts', '.tsx']`).
1112
+ * When provided, only files whose extension matches are shown.
1113
+ * Directories are always shown regardless of this filter.
1114
+ */
1115
+ filter?: string[];
1116
+ /** Show dot-files / dot-directories. Default: `false`. */
1117
+ showHidden?: boolean;
1118
+ /** Foreground colour for directory entries. Default: cyan. */
1119
+ dirColor?: Style['fg'];
1120
+ /** Foreground colour for file entries. Default: white. */
1121
+ fileColor?: Style['fg'];
1122
+ /** Foreground colour for the highlighted (active) row. Default: yellow. */
1123
+ activeColor?: Style['fg'];
1124
+ /** Called with the absolute path when the user selects a file. */
1125
+ onSelect?: (path: string) => void;
1126
+ /** Called when the user presses Escape. */
1127
+ onCancel?: () => void;
1128
+ }
1129
+ /**
1130
+ * FilePicker — an interactive file browser widget.
1131
+ *
1132
+ * Wire keyboard events via `handleKey(event)`.
1133
+ * The widget is self-contained: it reads the filesystem on construction
1134
+ * and every time the directory changes.
1135
+ */
1136
+ declare class FilePicker extends Widget {
1137
+ private _cwd;
1138
+ private _filter;
1139
+ private _showHidden;
1140
+ private _entries;
1141
+ private _cursor;
1142
+ private _scrollTop;
1143
+ private _dirColor;
1144
+ private _fileColor;
1145
+ private _activeColor;
1146
+ private _onSelect?;
1147
+ private _onCancel?;
1148
+ focusable: boolean;
1149
+ constructor(options?: FilePickerOptions);
1150
+ /** The absolute path of the directory currently being displayed. */
1151
+ get currentPath(): string;
1152
+ /** The `FileEntry` the cursor is currently on, or `undefined` if the list is empty. */
1153
+ get selectedEntry(): FileEntry | undefined;
1154
+ /** Read-only snapshot of the currently visible entries. */
1155
+ get entries(): readonly FileEntry[];
1156
+ /** Current cursor index within `entries`. */
1157
+ get cursorIndex(): number;
1158
+ /** Move the cursor one row down. Clamps at the last entry. */
1159
+ selectNext(): void;
1160
+ /** Move the cursor one row up. Clamps at the first entry. */
1161
+ selectPrev(): void;
1162
+ /**
1163
+ * Confirm the current selection:
1164
+ * - If the entry is a directory (including `..`), navigate into it.
1165
+ * - If the entry is a file, fire `onSelect(fullPath)`.
1166
+ */
1167
+ confirm(): void;
1168
+ /**
1169
+ * Navigate to the parent directory.
1170
+ * No-ops when already at the filesystem root.
1171
+ */
1172
+ goUp(): void;
1173
+ /** Fire `onCancel`. */
1174
+ cancel(): void;
1175
+ /**
1176
+ * Convenience key handler. Wire this to your app's input loop.
1177
+ *
1178
+ * | Key | Action |
1179
+ * |-------------------|----------------|
1180
+ * | `up` / `k` | `selectPrev()` |
1181
+ * | `down` / `j` | `selectNext()` |
1182
+ * | `enter`/`return` | `confirm()` |
1183
+ * | `backspace` | `goUp()` |
1184
+ * | `escape` | `cancel()` |
1185
+ */
1186
+ handleKey(event: KeyEvent): void;
1187
+ /**
1188
+ * Navigate to an absolute directory path.
1189
+ * Reloads the entry list and resets cursor / scroll.
1190
+ */
1191
+ private _navigateTo;
1192
+ /**
1193
+ * Read `this._cwd` and populate `this._entries`.
1194
+ *
1195
+ * Layout:
1196
+ * 1. `..` parent entry (omitted at root)
1197
+ * 2. Directories — alpha-sorted
1198
+ * 3. Files — alpha-sorted, filtered by `this._filter`
1199
+ */
1200
+ private _loadEntries;
1201
+ /** Safe stat to check if a symlink target is a directory. Never throws. */
1202
+ private _isDir;
1203
+ protected _renderSelf(screen: Screen): void;
1204
+ }
1205
+
1206
+ interface DatePickerOptions {
1207
+ value?: Date;
1208
+ onChange?: (date: Date) => void;
1209
+ }
1210
+ declare class DatePicker extends Widget {
1211
+ private _selectedDate;
1212
+ private _currentMonth;
1213
+ private _onChange?;
1214
+ focusable: boolean;
1215
+ constructor(options?: DatePickerOptions);
1216
+ get value(): Date;
1217
+ set value(date: Date);
1218
+ moveSelection(days: number): void;
1219
+ changeMonth(months: number): void;
1220
+ confirm(): void;
1221
+ handleKey(event: KeyEvent): void;
1222
+ protected _renderSelf(screen: Screen): void;
1223
+ }
1224
+
1225
+ interface TimePickerOptions {
1226
+ value?: Date;
1227
+ onChange?: (date: Date) => void;
1228
+ use24Hour?: boolean;
1229
+ }
1230
+ declare class TimePicker extends Widget {
1231
+ private _date;
1232
+ private _use24Hour;
1233
+ private _activeSegment;
1234
+ private _onChange?;
1235
+ focusable: boolean;
1236
+ constructor(options?: TimePickerOptions);
1237
+ get value(): Date;
1238
+ set value(val: Date);
1239
+ private _updateSegment;
1240
+ private _nextSegment;
1241
+ handleKey(event: KeyEvent): void;
1242
+ protected _renderSelf(screen: Screen): void;
1243
+ }
1244
+
1245
+ interface DateRange {
1246
+ start: Date;
1247
+ end: Date;
1248
+ }
1249
+ interface DateRangePickerOptions {
1250
+ value?: Partial<DateRange>;
1251
+ onChange?: (range: Partial<DateRange>) => void;
1252
+ }
1253
+ declare class DateRangePicker extends Widget {
1254
+ private _cursorDate;
1255
+ private _currentMonth;
1256
+ private _rangeStart;
1257
+ private _rangeEnd;
1258
+ private _selectionState;
1259
+ private _onChange?;
1260
+ focusable: boolean;
1261
+ constructor(options?: DateRangePickerOptions);
1262
+ private _zeroTime;
1263
+ get range(): Partial<DateRange>;
1264
+ moveSelection(days: number): void;
1265
+ changeMonth(months: number): void;
1266
+ confirm(): void;
1267
+ handleKey(event: KeyEvent): void;
1268
+ protected _renderSelf(screen: Screen): void;
1269
+ }
1270
+
1271
+ interface ColorPickerOptions {
1272
+ value?: string | Color;
1273
+ onChange?: (color: Color) => void;
1274
+ }
1275
+ declare class ColorPicker extends Widget {
1276
+ private _selectedColor;
1277
+ private _hexValue;
1278
+ private _paletteIndex;
1279
+ private _onChange?;
1280
+ focusable: boolean;
1281
+ constructor(options?: ColorPickerOptions);
1282
+ get value(): Color;
1283
+ set value(val: string | Color);
1284
+ private _colorToHexStr;
1285
+ private _colorsEqual;
1286
+ private _updateFromHexInput;
1287
+ handleKey(event: KeyEvent): void;
1288
+ protected _renderSelf(screen: Screen): void;
1289
+ }
1290
+
1291
+ interface AccordionItem {
1292
+ title: string;
1293
+ body: string;
1294
+ }
1295
+ interface AccordionOptions {
1296
+ /** Allow multiple sections open at once. Default: false (one at a time) */
1297
+ multi?: boolean;
1298
+ onToggle?: (index: number, open: boolean) => void;
1299
+ }
1300
+ declare class Accordion extends Widget {
1301
+ private _items;
1302
+ private _multi;
1303
+ private _onToggle?;
1304
+ private _focusIndex;
1305
+ private _openSet;
1306
+ focusable: boolean;
1307
+ constructor(items: AccordionItem[], style?: Partial<Style>, opts?: AccordionOptions);
1308
+ setItems(items: AccordionItem[]): void;
1309
+ openSection(index: number): void;
1310
+ closeSection(index: number): void;
1311
+ handleKey(event: KeyEvent): void;
1312
+ protected _renderSelf(screen: Screen): void;
1313
+ }
1314
+
1315
+ interface AppShellOptions {
1316
+ header?: Widget;
1317
+ footer?: Widget;
1318
+ sidebar?: Widget;
1319
+ main: Widget;
1320
+ sidebarWidth?: number;
1321
+ }
1322
+ declare class AppShell extends Widget {
1323
+ private _header?;
1324
+ private _footer?;
1325
+ private _sidebar?;
1326
+ private _main;
1327
+ private _sidebarWidth;
1328
+ private _sidebarVisible;
1329
+ private _mainScrollOffset;
1330
+ constructor(options: AppShellOptions);
1331
+ get sidebarVisible(): boolean;
1332
+ getLayoutNode(): LayoutNode;
1333
+ updateRect(rect: Rect): void;
1334
+ handleResize(cols: number, rows: number): void;
1335
+ scrollUp(lines?: number): void;
1336
+ scrollDown(lines?: number): void;
1337
+ handleKey(event: KeyEvent): void;
1338
+ toggleSidebar(): void;
1339
+ protected _renderSelf(_screen: Screen): void;
1340
+ render(screen: Screen): void;
1341
+ private _renderFooter;
1342
+ private _renderFixedChild;
1343
+ private _clampMainScroll;
1344
+ private _bodyHeight;
1345
+ }
1346
+
1347
+ interface PaginationOptions {
1348
+ onChange?: (page: number) => void;
1349
+ }
1350
+ declare class Pagination extends Widget {
1351
+ private _page;
1352
+ private _totalPages;
1353
+ private _onChange?;
1354
+ focusable: boolean;
1355
+ constructor(page: number, totalPages: number, options?: PaginationOptions);
1356
+ get page(): number;
1357
+ get totalPages(): number;
1358
+ private _clamp;
1359
+ setPage(n: number): void;
1360
+ next(): void;
1361
+ prev(): void;
1362
+ handleKey(event: KeyEvent): void;
1363
+ protected _renderSelf(screen: Screen): void;
1364
+ }
1365
+
1366
+ interface ScalePromptOptions {
1367
+ max?: number;
1368
+ question?: string;
1369
+ endLabels?: [string, string];
1370
+ activeColor?: Color;
1371
+ onSelect?: (value: number) => void;
1372
+ }
1373
+ declare class ScalePrompt extends Widget {
1374
+ private _max;
1375
+ private _value;
1376
+ private _question?;
1377
+ private _endLabels?;
1378
+ private _activeColor;
1379
+ private _onSelect?;
1380
+ focusable: boolean;
1381
+ constructor(style?: Partial<Style>, opts?: ScalePromptOptions);
1382
+ getValue(): number;
1383
+ private _setValue;
1384
+ handleKey(event: KeyEvent): void;
1385
+ protected _renderSelf(screen: Screen): void;
1386
+ }
1387
+
1388
+ interface SegmentedControlOptions {
1389
+ options: string[];
1390
+ value?: string;
1391
+ activeColor?: Style['fg'];
1392
+ onChange?: (value: string) => void;
1393
+ }
1394
+ declare class SegmentedControl extends Widget {
1395
+ private _options;
1396
+ private _selectedIndex;
1397
+ private _activeColor;
1398
+ private _onChange?;
1399
+ focusable: boolean;
1400
+ constructor(config: SegmentedControlOptions);
1401
+ get value(): string;
1402
+ private _setIndex;
1403
+ next(): void;
1404
+ prev(): void;
1405
+ handleKey(event: KeyEvent): void;
1406
+ protected _renderSelf(screen: Screen): void;
1407
+ }
1408
+
1409
+ declare class SearchableSelect extends Widget {
1410
+ private _searchQuery;
1411
+ private _options;
1412
+ private _selectedIndex;
1413
+ constructor();
1414
+ get searchQuery(): string;
1415
+ get selectedOption(): string;
1416
+ handleKey(event: KeyEvent): void;
1417
+ selectNext(): void;
1418
+ selectPrev(): void;
1419
+ confirm(): void;
1420
+ private _filterOptions;
1421
+ protected _renderSelf(screen: Screen): void;
1422
+ }
1423
+
1424
+ interface AutocompleteOptions {
1425
+ /** List of search suggestions / candidates */
1426
+ items: string[];
1427
+ /** Callback when an item is selected or submitted */
1428
+ onSelect?: (value: string) => void;
1429
+ /** Callback when the query text changes */
1430
+ onChange?: (value: string) => void;
1431
+ /** Custom filter function to override default lowercase startsWith matching */
1432
+ filter?: (query: string, item: string) => boolean;
1433
+ /** Maximum number of suggestions to display in dropdown. Default: 5 */
1434
+ maxSuggestions?: number;
1435
+ /** Placeholder text when query is empty */
1436
+ placeholder?: string;
1437
+ /** Highlight color for the selected suggestion */
1438
+ highlightColor?: Color;
1439
+ }
1440
+ declare class Autocomplete extends Widget {
1441
+ private _items;
1442
+ private _query;
1443
+ private _isOpen;
1444
+ private _selectedIndex;
1445
+ private _onSelect?;
1446
+ private _onChange?;
1447
+ private _filter;
1448
+ private _maxSuggestions;
1449
+ private _placeholder;
1450
+ private _highlightColor;
1451
+ constructor(style?: Partial<Style>, options?: AutocompleteOptions);
1452
+ get query(): string;
1453
+ set query(value: string);
1454
+ get items(): string[];
1455
+ setItems(items: string[]): void;
1456
+ private get _filteredItems();
1457
+ handleKey(event: KeyEvent): void;
1458
+ protected _renderSelf(screen: Screen): void;
1459
+ }
1460
+
1461
+ interface ToggleOptions {
1462
+ defaultValue?: boolean;
1463
+ label?: string;
1464
+ onChange?: (value: boolean) => void;
1465
+ }
1466
+ declare class Toggle extends Widget {
1467
+ private _value;
1468
+ private _label?;
1469
+ onChange?: (value: boolean) => void;
1470
+ focusable: boolean;
1471
+ constructor(options?: ToggleOptions);
1472
+ get value(): boolean;
1473
+ setValue(value: boolean): void;
1474
+ toggle(): void;
1475
+ handleKey(event: KeyEvent): void;
1476
+ protected _renderSelf(screen: Screen): void;
1477
+ }
1478
+
1479
+ interface SwitchOptions {
1480
+ defaultValue?: boolean;
1481
+ label?: string;
1482
+ onChange?: (value: boolean) => void;
1483
+ }
1484
+ declare class Switch extends Widget {
1485
+ private _value;
1486
+ private _label?;
1487
+ onChange?: (value: boolean) => void;
1488
+ focusable: boolean;
1489
+ constructor(options?: SwitchOptions);
1490
+ get value(): boolean;
1491
+ setValue(value: boolean): void;
1492
+ toggle(): void;
1493
+ handleKey(event: KeyEvent): void;
1494
+ protected _renderSelf(screen: Screen): void;
1495
+ }
1496
+
1497
+ interface CheckboxOptions {
1498
+ label: string;
1499
+ defaultChecked?: boolean;
1500
+ onChange?: (checked: boolean) => void;
1501
+ }
1502
+ declare class Checkbox extends Widget {
1503
+ private _checked;
1504
+ private _label;
1505
+ onChange?: (checked: boolean) => void;
1506
+ focusable: boolean;
1507
+ constructor(options: CheckboxOptions);
1508
+ get checked(): boolean;
1509
+ setChecked(checked: boolean): void;
1510
+ toggle(): void;
1511
+ handleKey(event: KeyEvent): void;
1512
+ protected _renderSelf(screen: Screen): void;
1513
+ }
1514
+
1515
+ interface CheckboxGroupOption {
1516
+ label: string;
1517
+ value: string;
1518
+ }
1519
+ interface CheckboxGroupOptions {
1520
+ options: CheckboxGroupOption[];
1521
+ defaultValues?: string[];
1522
+ onChange?: (selectedValues: string[]) => void;
1523
+ }
1524
+ declare class CheckboxGroup extends Widget {
1525
+ private _options;
1526
+ private _selected;
1527
+ private _focusedIndex;
1528
+ onChange?: (selectedValues: string[]) => void;
1529
+ focusable: boolean;
1530
+ constructor(options: CheckboxGroupOptions);
1531
+ get selectedValues(): string[];
1532
+ private emitChange;
1533
+ selectNext(): void;
1534
+ selectPrev(): void;
1535
+ toggleCurrent(): void;
1536
+ handleKey(event: KeyEvent): void;
1537
+ protected _renderSelf(screen: Screen): void;
1538
+ }
1539
+
1540
+ interface ButtonGroupItem {
1541
+ label: string;
1542
+ value: string;
1543
+ disabled?: boolean;
1544
+ }
1545
+ interface ButtonGroupOptions {
1546
+ activeColor?: Color;
1547
+ inactiveColor?: Color;
1548
+ onSelect?: (value: string) => void;
1549
+ }
1550
+ declare class ButtonGroup extends Widget {
1551
+ private _items;
1552
+ private _activeIndex;
1553
+ private _activeColor;
1554
+ private _inactiveColor;
1555
+ private _onSelect?;
1556
+ focusable: boolean;
1557
+ constructor(items: ButtonGroupItem[], style?: Partial<Style>, opts?: ButtonGroupOptions);
1558
+ setItems(items: ButtonGroupItem[]): void;
1559
+ setActiveValue(value: string): void;
1560
+ getActiveValue(): string;
1561
+ handleKey(event: KeyEvent): void;
1562
+ private _firstEnabledIndex;
1563
+ private _move;
1564
+ protected _renderSelf(screen: Screen): void;
1565
+ }
1566
+
1567
+ interface WizardStep {
1568
+ title: string;
1569
+ render: () => Widget;
1570
+ validate?: () => boolean | string;
1571
+ }
1572
+ interface WizardOptions {
1573
+ style?: Partial<Style>;
1574
+ onComplete?: (stepData: unknown[]) => void;
1575
+ }
1576
+ declare class Wizard extends Widget {
1577
+ private _steps;
1578
+ private _stepWidgets;
1579
+ private _currentStepIndex;
1580
+ private _error;
1581
+ private _onComplete?;
1582
+ focusable: boolean;
1583
+ constructor(steps: WizardStep[], options?: WizardOptions);
1584
+ get currentStepIndex(): number;
1585
+ get error(): string;
1586
+ get stepWidgets(): ReadonlyArray<Widget>;
1587
+ nextStep(): void;
1588
+ prevStep(): void;
1589
+ complete(): void;
1590
+ private _showStep;
1591
+ private _getStepData;
1592
+ handleKey(event: KeyEvent): void;
1593
+ protected _renderSelf(screen: Screen): void;
1594
+ }
1595
+
1596
+ interface MultilineTextInputOptions {
1597
+ placeholder?: string;
1598
+ onChange?: (value: string) => void;
1599
+ onSubmit?: (value: string) => void;
1600
+ }
1601
+ declare class MultilineTextInput extends Widget {
1602
+ /** Each element is one logical line (no '\n' inside). */
1603
+ private _lines;
1604
+ /** Cursor position: line index. */
1605
+ private _cursorLine;
1606
+ /** Cursor position: column index within the logical line. */
1607
+ private _cursorCol;
1608
+ private _placeholder;
1609
+ private _onChange?;
1610
+ private _onSubmit?;
1611
+ focusable: boolean;
1612
+ constructor(style?: Partial<Style>, options?: MultilineTextInputOptions);
1613
+ /** Full text value with newlines. */
1614
+ get value(): string;
1615
+ /** Set text programmatically. */
1616
+ set value(v: string);
1617
+ /** Clear all content. */
1618
+ clear(): void;
1619
+ /** Insert a single printable character at the cursor position. */
1620
+ insertChar(char: string): void;
1621
+ /** Insert a newline — splits the current line at cursor. */
1622
+ insertNewline(): void;
1623
+ /** Delete the character before the cursor (Backspace). */
1624
+ deleteBack(): void;
1625
+ /** Delete the character after the cursor (Delete). */
1626
+ deleteForward(): void;
1627
+ moveCursorLeft(): void;
1628
+ moveCursorRight(): void;
1629
+ moveCursorUp(): void;
1630
+ moveCursorDown(): void;
1631
+ moveCursorHome(): void;
1632
+ moveCursorEnd(): void;
1633
+ submit(): void;
1634
+ /**
1635
+ * Handle key events. Call this from your application input loop.
1636
+ * Returns true if the event was consumed.
1637
+ */
1638
+ handleKey(event: KeyEvent): boolean;
1639
+ protected _renderSelf(screen: Screen): void;
1640
+ private _notify;
1641
+ private _softWrap;
1642
+ /**
1643
+ * Compute the display row and column for the current cursor position,
1644
+ * given the content area width.
1645
+ */
1646
+ private _cursorDisplayPos;
1647
+ /**
1648
+ * Calculate a scroll offset so the cursor row is always visible.
1649
+ */
1650
+ private _calcScrollY;
1651
+ }
1652
+
1653
+ interface BasicAuthCredentials {
1654
+ username: string;
1655
+ password: string;
1656
+ }
1657
+ interface BasicAuthPromptOptions {
1658
+ usernameLabel?: string;
1659
+ passwordLabel?: string;
1660
+ onSubmit?: (credentials: BasicAuthCredentials) => void;
1661
+ }
1662
+ declare class BasicAuthPrompt extends Widget {
1663
+ private _username;
1664
+ private _password;
1665
+ private _activeField;
1666
+ private _opts;
1667
+ private get _maskChar();
1668
+ constructor(style?: Partial<Style>, opts?: BasicAuthPromptOptions);
1669
+ getCredentials(): BasicAuthCredentials;
1670
+ private onSubmit;
1671
+ private deleteBackward;
1672
+ private insertChar;
1673
+ handleKey(event: KeyEvent): void;
1674
+ protected _renderSelf(screen: Screen): void;
1675
+ }
1676
+
1677
+ interface TextAreaOptions {
1678
+ /** Number of visible rows (default: 4) */
1679
+ rows?: number;
1680
+ placeholder?: string;
1681
+ onChange?: (value: string) => void;
1682
+ onSubmit?: (value: string) => void;
1683
+ }
1684
+ /**
1685
+ * TextArea - a multi-line text input field.
1686
+ *
1687
+ * Supports:
1688
+ * - Multi-line editing (Enter for newline)
1689
+ * - Cursor movement (up/down/left/right)
1690
+ * - Ctrl+Enter to submit
1691
+ * - Horizontal/Vertical scrolling when content overflows
1692
+ */
1693
+ declare class TextArea extends Widget {
1694
+ private _lines;
1695
+ private _cursor;
1696
+ private _placeholder;
1697
+ private _onChange?;
1698
+ private _onSubmit?;
1699
+ constructor(style?: Partial<Style>, options?: TextAreaOptions);
1700
+ get value(): string;
1701
+ set value(v: string);
1702
+ insertChar(char: string): void;
1703
+ insertNewline(): void;
1704
+ deleteBack(): void;
1705
+ moveCursorLeft(): void;
1706
+ moveCursorRight(): void;
1707
+ moveCursorUp(): void;
1708
+ moveCursorDown(): void;
1709
+ handleKey(event: KeyEvent): void;
1710
+ private _notify;
1711
+ protected _renderSelf(screen: Screen): void;
1712
+ }
1713
+
1714
+ interface StepperOptions {
1715
+ completedColor?: Style['fg'];
1716
+ activeColor?: Style['fg'];
1717
+ pendingColor?: Style['fg'];
1718
+ connectorChar?: string;
1719
+ }
1720
+ declare class Stepper extends Widget {
1721
+ private _labels;
1722
+ private _activeStep;
1723
+ private _completedColor;
1724
+ private _activeColor;
1725
+ private _pendingColor;
1726
+ private _connectorChar;
1727
+ constructor(labels: string[], style?: Partial<Style>, opts?: StepperOptions);
1728
+ get activeStep(): number;
1729
+ setActiveStep(index: number): void;
1730
+ protected _renderSelf(screen: Screen): void;
1731
+ }
1732
+
1733
+ type Shortcut = {
1734
+ key: string;
1735
+ label: string;
1736
+ };
1737
+ interface ShortcutHelpOverlayProps {
1738
+ shortcuts?: Shortcut[];
1739
+ }
1740
+ declare function ShortcutHelpOverlay({ shortcuts }: ShortcutHelpOverlayProps): any;
1741
+
1742
+ interface RadioGroupOption {
1743
+ label: string;
1744
+ value: string;
1745
+ disabled?: boolean;
1746
+ }
1747
+ interface RadioGroupOptions {
1748
+ options: Array<RadioGroupOption>;
1749
+ defaultValue?: string;
1750
+ onChange?: (value: string) => void;
1751
+ }
1752
+ /**
1753
+ * RadioGroup — renders a vertical list of mutually exclusive options.
1754
+ *
1755
+ * Example output (unicode):
1756
+ * (o) Dark
1757
+ * ( ) Light
1758
+ * ( ) System
1759
+ */
1760
+ declare class RadioGroup extends Widget {
1761
+ private _options;
1762
+ private _selectedValue;
1763
+ private _focusedIndex;
1764
+ /** Fires whenever the confirmed selection changes. */
1765
+ onChange?: (value: string) => void;
1766
+ focusable: boolean;
1767
+ constructor(config: RadioGroupOptions);
1768
+ /** The value of the currently confirmed selection. */
1769
+ get selectedValue(): string;
1770
+ /** The index currently under the keyboard cursor. */
1771
+ get focusedIndex(): number;
1772
+ /** Move cursor to the next enabled option. */
1773
+ selectNext(): void;
1774
+ /** Move cursor to the previous enabled option. */
1775
+ selectPrev(): void;
1776
+ /** Confirm the focused option and fire onChange. */
1777
+ confirm(): void;
1778
+ handleKey(event: KeyEvent): void;
1779
+ protected _renderSelf(screen: Screen): void;
1780
+ }
1781
+
1782
+ interface RatingOptions {
1783
+ /** Total number of stars. Default: 5 */
1784
+ max?: number;
1785
+ /** Initial rating. Default: 0 */
1786
+ value?: number;
1787
+ /** Filled star character. Default: '★' with ASCII fallback '*' */
1788
+ filledChar?: string;
1789
+ /** Empty star character. Default: '☆' with ASCII fallback '-' */
1790
+ emptyChar?: string;
1791
+ /** Color for filled stars */
1792
+ filledColor?: Color;
1793
+ /** Callback when the user confirms a rating via enter */
1794
+ onSelect?: (value: number) => void;
1795
+ }
1796
+ /**
1797
+ * Rating — renders a row of star glyphs for a 1-to-N rating.
1798
+ *
1799
+ * Example output (unicode, max=5, value=3):
1800
+ * ★★★☆☆
1801
+ *
1802
+ * ASCII fallback:
1803
+ * ***--
1804
+ */
1805
+ declare class Rating extends Widget {
1806
+ private _value;
1807
+ private _max;
1808
+ private _filledChar?;
1809
+ private _emptyChar?;
1810
+ private _filledColor?;
1811
+ /** Callback when the user confirms a rating via enter. */
1812
+ onSelect?: (value: number) => void;
1813
+ focusable: boolean;
1814
+ constructor(style?: Partial<Style>, opts?: RatingOptions);
1815
+ /** The current rating value (0 to max). */
1816
+ get value(): number;
1817
+ /** The maximum number of stars. */
1818
+ get max(): number;
1819
+ /** Set the rating value (clamped to 0..max). Calls markDirty(). */
1820
+ setValue(value: number): void;
1821
+ /** Get the current rating value. */
1822
+ getValue(): number;
1823
+ handleKey(event: KeyEvent): void;
1824
+ protected _renderSelf(screen: Screen): void;
1825
+ }
1826
+
1827
+ interface ThemeSwitcherOptions {
1828
+ themes?: string[];
1829
+ activeTheme?: string;
1830
+ onChange?: (theme: string) => void;
1831
+ activeColor?: Style['fg'];
1832
+ }
1833
+ declare class ThemeSwitcher extends Widget {
1834
+ private _themes;
1835
+ private _activeTheme;
1836
+ private _selectedIndex;
1837
+ private _onChange?;
1838
+ private _activeColor;
1839
+ focusable: boolean;
1840
+ constructor(options?: ThemeSwitcherOptions);
1841
+ get activeTheme(): string;
1842
+ set activeTheme(theme: string);
1843
+ get themes(): string[];
1844
+ get selectedIndex(): number;
1845
+ selectNext(): void;
1846
+ selectPrev(): void;
1847
+ confirm(): void;
1848
+ handleKey(event: KeyEvent): void;
1849
+ protected _renderSelf(screen: Screen): void;
1850
+ }
1851
+
1852
+ interface TreeSelectNode {
1853
+ label: string;
1854
+ value: string;
1855
+ children?: TreeSelectNode[];
1856
+ expanded?: boolean;
1857
+ }
1858
+ interface TreeSelectOptions {
1859
+ multiple?: boolean;
1860
+ activeColor?: Style['fg'];
1861
+ onChange?: (values: string[]) => void;
1862
+ }
1863
+ declare class TreeSelect extends Widget {
1864
+ private _roots;
1865
+ private _cursorIndex;
1866
+ private _selected;
1867
+ private _multiple;
1868
+ private _activeColor;
1869
+ private _onChange?;
1870
+ focusable: boolean;
1871
+ constructor(roots: TreeSelectNode[], options?: TreeSelectOptions);
1872
+ get selectedValues(): string[];
1873
+ private _flatten;
1874
+ selectNext(): void;
1875
+ selectPrev(): void;
1876
+ expand(): void;
1877
+ collapse(): void;
1878
+ toggleSelection(): void;
1879
+ handleKey(event: KeyEvent): void;
1880
+ protected _renderSelf(screen: Screen): void;
1881
+ }
1882
+
1883
+ interface EmailInputOptions {
1884
+ placeholder?: string;
1885
+ /** Common domains to suggest after '@'. Default: ['gmail.com','outlook.com','yahoo.com'] */
1886
+ domains?: string[];
1887
+ onSubmit?: (value: string) => void;
1888
+ onChange?: (value: string, valid: boolean) => void;
1889
+ errorColor?: Color;
1890
+ }
1891
+ declare class EmailInput extends Widget {
1892
+ private _raw;
1893
+ private _cursorPos;
1894
+ private _placeholder;
1895
+ private _domains;
1896
+ private _onSubmit?;
1897
+ private _onChange?;
1898
+ private _errorColor;
1899
+ focusable: boolean;
1900
+ constructor(style?: Partial<Style>, opts?: EmailInputOptions);
1901
+ getValue(): string;
1902
+ isValid(): boolean;
1903
+ private _notify;
1904
+ insertChar(char: string): void;
1905
+ deleteBack(): void;
1906
+ deleteForward(): void;
1907
+ moveCursorLeft(): void;
1908
+ moveCursorRight(): void;
1909
+ moveCursorHome(): void;
1910
+ moveCursorEnd(): void;
1911
+ autocompleteDomain(): void;
1912
+ handleKey(event: KeyEvent): void;
1913
+ protected _renderSelf(screen: Screen): void;
1914
+ }
1915
+
1916
+ interface QuizQuestion {
1917
+ question: string;
1918
+ options: string[];
1919
+ correctIndex: number;
1920
+ }
1921
+ interface QuizResult {
1922
+ total: number;
1923
+ correct: number;
1924
+ answers: number[];
1925
+ }
1926
+ interface QuizPromptOptions {
1927
+ correctColor?: Style['fg'];
1928
+ wrongColor?: Style['fg'];
1929
+ onComplete?: (result: QuizResult) => void;
1930
+ }
1931
+ declare class QuizPrompt extends Widget {
1932
+ private _questions;
1933
+ private _currentIndex;
1934
+ private _selectedIndex;
1935
+ private _answers;
1936
+ private _feedback;
1937
+ private _feedbackTimeout;
1938
+ private _correctColor;
1939
+ private _wrongColor;
1940
+ private _onComplete?;
1941
+ focusable: boolean;
1942
+ constructor(questions: QuizQuestion[], style?: Partial<Style>, opts?: QuizPromptOptions);
1943
+ getResult(): QuizResult;
1944
+ handleKey(event: KeyEvent): void;
1945
+ private submitAnswer;
1946
+ protected _renderSelf(screen: Screen): void;
1947
+ }
1948
+
1949
+ interface EditablePromptChoice {
1950
+ type: 'checkbox' | 'text';
1951
+ name: string;
1952
+ message: string;
1953
+ initial?: string;
1954
+ disabled?: boolean;
1955
+ }
1956
+ interface EditablePromptResult {
1957
+ selected: string[];
1958
+ values: Record<string, string>;
1959
+ }
1960
+ interface EditablePromptOptions {
1961
+ message?: string;
1962
+ choices: EditablePromptChoice[];
1963
+ onChange?: (result: EditablePromptResult) => void;
1964
+ }
1965
+ declare class EditablePrompt extends Widget {
1966
+ private _message;
1967
+ private _choices;
1968
+ private _checkedNames;
1969
+ private _textValues;
1970
+ private _focusedIndex;
1971
+ private _editingIndex;
1972
+ private _editingValue;
1973
+ private _onChange?;
1974
+ focusable: boolean;
1975
+ constructor(options: EditablePromptOptions);
1976
+ get result(): EditablePromptResult;
1977
+ private emitChange;
1978
+ selectNext(): void;
1979
+ selectPrev(): void;
1980
+ toggleCheckbox(): void;
1981
+ enterEditMode(): void;
1982
+ submitEdit(): void;
1983
+ cancelEdit(): void;
1984
+ handleKey(event: KeyEvent): void;
1985
+ protected _renderSelf(screen: Screen): void;
1986
+ }
1987
+
1988
+ interface SurveyQuestion {
1989
+ id: string;
1990
+ question: string;
1991
+ type: "text" | "choice";
1992
+ options?: string[];
1993
+ }
1994
+ interface SurveyPromptOptions {
1995
+ onComplete?: (answers: Record<string, string>) => void;
1996
+ }
1997
+ declare class SurveyPrompt extends Widget {
1998
+ private _questions;
1999
+ private _currentIndex;
2000
+ private _answers;
2001
+ private _textBuffer;
2002
+ private _choiceIndex;
2003
+ private _onComplete?;
2004
+ focusable: boolean;
2005
+ constructor(questions: SurveyQuestion[], style?: Partial<Style>, opts?: SurveyPromptOptions);
2006
+ getAnswers(): Record<string, string>;
2007
+ getCurrentIndex(): number;
2008
+ private _advance;
2009
+ handleKey(event: KeyEvent): void;
2010
+ protected _renderSelf(screen: Screen): void;
2011
+ }
2012
+
2013
+ interface BreadcrumbItem {
2014
+ label: string;
2015
+ onSelect?: () => void;
2016
+ }
2017
+ interface BreadcrumbOptions {
2018
+ items: BreadcrumbItem[];
2019
+ currentColor?: Color;
2020
+ inactiveColor?: Color;
2021
+ separatorColor?: Color;
2022
+ }
2023
+ declare class Breadcrumb extends Widget {
2024
+ private _items;
2025
+ private _focusedIndex;
2026
+ private _currentColor;
2027
+ private _inactiveColor;
2028
+ private _separatorColor;
2029
+ focusable: boolean;
2030
+ constructor(options: BreadcrumbOptions);
2031
+ get items(): ReadonlyArray<BreadcrumbItem>;
2032
+ get focusedIndex(): number;
2033
+ setItems(items: BreadcrumbItem[]): void;
2034
+ handleKey(event: KeyEvent): void;
2035
+ protected _renderSelf(screen: Screen): void;
2036
+ }
2037
+
2038
+ interface DisclosureOptions {
2039
+ summary: string;
2040
+ defaultOpen?: boolean;
2041
+ onToggle?: (open: boolean) => void;
2042
+ }
2043
+ declare class Disclosure extends Widget {
2044
+ private _isOpen;
2045
+ private summary;
2046
+ private onToggleCallback?;
2047
+ private content;
2048
+ private _customStyle;
2049
+ constructor(content: Widget, options: DisclosureOptions, style?: Partial<Style>);
2050
+ get isOpen(): boolean;
2051
+ open(): void;
2052
+ close(): void;
2053
+ toggle(): void;
2054
+ handleKey(event: KeyEvent): void;
2055
+ protected _renderSelf(screen: Screen): void;
2056
+ }
2057
+
2058
+ interface ListbarItem {
2059
+ label: string;
2060
+ key?: string;
2061
+ action?: () => void;
2062
+ disabled?: boolean;
2063
+ }
2064
+ interface ListbarOptions {
2065
+ activeColor?: Color;
2066
+ keyColor?: Color;
2067
+ separator?: string;
2068
+ }
2069
+ declare class Listbar extends Widget {
2070
+ private _items;
2071
+ private _activeIndex;
2072
+ private _activeColor;
2073
+ private _keyColor;
2074
+ private _separator;
2075
+ focusable: boolean;
2076
+ constructor(items: ListbarItem[], style?: Partial<Style>, opts?: ListbarOptions);
2077
+ get activeItem(): number;
2078
+ setItems(items: ListbarItem[]): void;
2079
+ handleKey(event: KeyEvent): void;
2080
+ private _initActiveIndex;
2081
+ private _nextEnabled;
2082
+ protected _renderSelf(screen: Screen): void;
2083
+ }
2084
+
2085
+ type PopoverPlacement = 'top' | 'bottom' | 'left' | 'right';
2086
+ interface PopoverOptions {
2087
+ /** The placement of the popover relative to the anchor. Default: 'bottom'. */
2088
+ placement?: PopoverPlacement;
2089
+ /** Title shown in the panel border. */
2090
+ title?: string;
2091
+ /** Border color. */
2092
+ borderColor?: Style['fg'];
2093
+ /** * The specific terminal coordinates (row/col) to anchor this popover to.
2094
+ * If omitted, it will attempt to use its own rect as the anchor bounds.
2095
+ */
2096
+ anchor?: {
2097
+ x: number;
2098
+ y: number;
2099
+ };
2100
+ }
2101
+ declare class Popover extends Widget {
2102
+ private _isOpen;
2103
+ private content;
2104
+ private opts;
2105
+ constructor(content: Widget, style?: Partial<Style>, opts?: PopoverOptions);
2106
+ get isOpen(): boolean;
2107
+ open(): void;
2108
+ close(): void;
2109
+ toggle(): void;
2110
+ /** Update the anchor coordinates dynamically */
2111
+ setAnchor(x: number, y: number): void;
2112
+ handleKey(event: KeyEvent): void;
2113
+ private getBorderChars;
2114
+ protected _renderSelf(screen: Screen): void;
2115
+ }
2116
+
2117
+ interface FormContextValue {
2118
+ submit: () => void;
2119
+ }
2120
+ interface FormBuilderProps {
2121
+ onSubmit?: () => void;
2122
+ children?: VNode | VNode[];
2123
+ }
2124
+ declare function FormBuilder({ onSubmit, children }: FormBuilderProps): VNode;
2125
+ declare function useForm(): FormContextValue;
2126
+
2127
+ interface SearchInputOptions {
2128
+ placeholder?: string;
2129
+ debounce?: number;
2130
+ onSearch?: (value: string) => void;
2131
+ }
2132
+ declare class SearchInput extends Widget {
2133
+ private _value;
2134
+ private _placeholder;
2135
+ private _debounce;
2136
+ onSearch?: (value: string) => void;
2137
+ private _debounceTimer;
2138
+ focusable: boolean;
2139
+ constructor(options?: SearchInputOptions);
2140
+ get value(): string;
2141
+ setValue(value: string): void;
2142
+ clear(): void;
2143
+ handleKey(event: KeyEvent): void;
2144
+ private _scheduleSearch;
2145
+ private _cancelDebounce;
2146
+ protected _renderSelf(screen: Screen): void;
2147
+ }
2148
+
2149
+ export { Accordion, type AccordionItem, type AccordionOptions, AppShell, type AppShellOptions, Autocomplete, type AutocompleteOptions, type BasicAuthCredentials, BasicAuthPrompt, type BasicAuthPromptOptions, Breadcrumb, type BreadcrumbItem, type BreadcrumbOptions, ButtonGroup, type ButtonGroupItem, type ButtonGroupOptions, Carousel, type CarouselOptions, Checkbox, CheckboxGroup, type CheckboxGroupOption, type CheckboxGroupOptions, type CheckboxOptions, ColorPicker, type ColorPickerOptions, Combobox, type ComboboxOption, type ComboboxOptions, type Command, CommandPalette, type CommandPaletteOptions, ConfirmDialog, type ConfirmDialogOptions, type ConfirmPromptOptions, ContentSwitcher, DatePicker, type DatePickerOptions, type DateRange, DateRangePicker, type DateRangePickerOptions, Disclosure, type DisclosureOptions, Divider, type DividerOptions, Drawer, type DrawerOptions, type DrawerPosition, EditablePrompt, type EditablePromptChoice, type EditablePromptOptions, type EditablePromptResult, EmailInput, type EmailInputOptions, type FileEntry, FilePicker, type FilePickerOptions, Form, FormBuilder, type FormBuilderProps, type FormField, type FormOptions, type InputValidator, KeyboardShortcuts, type KeyboardShortcutsOptions, LinearPrompt, type LinearPromptOption, type LinearPromptOptions, Listbar, type ListbarItem, type ListbarOptions, MaskedInput, type MaskedInputOptions, Menu, MenuBar, type MenuBarItem, type MenuItem$1 as MenuBarItemType, type MenuBarOptions, type MenuItem, type MenuOptions, Modal, type ModalOptions, MultiSelect, type MultiSelectOption, type MultiSelectOptions, MultilineTextInput, type MultilineTextInputOptions, NonInteractiveError, type Notification, NotificationCenter, type NotificationCenterOptions, NotificationStore, NumberInput, type NumberInputOptions, type Page, Pages, type PagesOptions, Pagination, type PaginationOptions, PasswordInput, type PasswordInputOptions, PathInput, type PathInputOptions, Popover, type PopoverOptions, type PopoverPlacement, QuizPrompt, type QuizPromptOptions, type QuizQuestion, type QuizResult, RadioGroup, type RadioGroupOption, type RadioGroupOptions, RangeInput, Rating, type RatingOptions, ScalePrompt, type ScalePromptOptions, SearchInput, type SearchInputOptions, SearchableSelect, SegmentedControl, type SegmentedControlOptions, Select, type SelectOption, type SelectOptions, type SelectPromptOptions, type Shortcut, type ShortcutBinding, ShortcutHelpOverlay, type ShortcutHelpOverlayProps, Slider, SnippetPrompt, type SnippetPromptOptions, SortPrompt, type SortPromptOptions, Spacer, Stepper, type StepperOptions, SurveyPrompt, type SurveyPromptOptions, type SurveyQuestion, Switch, type SwitchOptions, type Tab, Tabs, type TabsOptions, TagInput, type TagInputOptions, TextArea, type TextAreaOptions, type TextPromptOptions, ThemeSwitcher, type ThemeSwitcherOptions, TimePicker, type TimePickerOptions, Toast, type ToastMessage, type ToastOptions, type ToastType, Toggle, type ToggleOptions, Transfer, type TransferItem, type TransferOptions, Tree, type TreeNode, type TreeOptions, TreeSelect, type TreeSelectNode, type TreeSelectOptions, type UseCommandPaletteOptions, type UseCommandPaletteReturn, Wizard, type WizardOptions, type WizardStep, notifications, prompt, useCommandPalette, useForm, useNotifications, validateInput };