@termuijs/widgets 0.1.3 → 0.1.5

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,3 +1,4 @@
1
+ import * as _termuijs_core from '@termuijs/core';
1
2
  import { Style, Rect, EventEmitter, KeyEvent, MouseEvent, LayoutNode, Screen, Color } from '@termuijs/core';
2
3
 
3
4
  /**
@@ -190,6 +191,293 @@ declare class LogView extends Widget {
190
191
  private _getLineColor;
191
192
  }
192
193
 
194
+ interface TreeNode {
195
+ label: string;
196
+ children?: TreeNode[];
197
+ expanded?: boolean;
198
+ data?: unknown;
199
+ }
200
+ interface TreeOptions {
201
+ nodes: TreeNode[];
202
+ onSelect?: (node: TreeNode, path: number[]) => void;
203
+ indent?: number;
204
+ }
205
+ interface VisibleEntry {
206
+ node: TreeNode;
207
+ depth: number;
208
+ path: number[];
209
+ }
210
+ /**
211
+ * Tree — a collapsible tree widget for displaying hierarchical data.
212
+ *
213
+ * Supports:
214
+ * - Expand/collapse of parent nodes
215
+ * - Keyboard navigation (ArrowUp/Down/Left/Right, j/k/h/l, Home/End)
216
+ * - Enter/Space to toggle or select
217
+ * - onSelect callback for leaf nodes
218
+ * - Unicode and ASCII fallback symbols
219
+ * - Scrolling when tree exceeds visible height
220
+ */
221
+ declare class Tree extends Widget {
222
+ private _nodes;
223
+ private _onSelect?;
224
+ protected _indent: number;
225
+ protected _selectedIndex: number;
226
+ protected _scrollOffset: number;
227
+ protected _visibleNodes: VisibleEntry[];
228
+ constructor(options: TreeOptions, style?: Partial<Style>);
229
+ get selectedIndex(): number;
230
+ get selectedNode(): TreeNode | undefined;
231
+ setNodes(nodes: TreeNode[]): void;
232
+ /** Move cursor up one visible row */
233
+ movePrev(): void;
234
+ /** Move cursor down one visible row */
235
+ moveNext(): void;
236
+ /** Go to first visible node */
237
+ moveFirst(): void;
238
+ /** Go to last visible node */
239
+ moveLast(): void;
240
+ /** Expand the selected node (if it's a collapsed parent) */
241
+ expand(): void;
242
+ /** Collapse the selected node, or move to parent if already collapsed/leaf */
243
+ collapse(): void;
244
+ /** Toggle expand/collapse (parent) or call onSelect (leaf) */
245
+ toggle(): void;
246
+ /**
247
+ * Handle a key event. Call this from your app's key-routing logic
248
+ * when this widget is focused.
249
+ */
250
+ handleKey(key: string): void;
251
+ protected _renderSelf(screen: Screen): void;
252
+ /** Rebuild the flat visible-node list from the tree */
253
+ private _buildVisibleNodes;
254
+ /** Ensure scroll keeps the selected index in view */
255
+ private _clampScroll;
256
+ }
257
+
258
+ type JSONNodeType = 'null' | 'boolean' | 'number' | 'string' | 'array' | 'object' | 'unknown';
259
+ interface JSONNodeData {
260
+ type: JSONNodeType;
261
+ /** Original key (if any) that prefixes the label */
262
+ key?: string;
263
+ /** Raw primitive value (for non-container nodes) */
264
+ value?: unknown;
265
+ }
266
+ interface JSONViewOptions {
267
+ /** The JSON value to display */
268
+ data: unknown;
269
+ /** Callback when a leaf node is selected */
270
+ onSelect?: (node: TreeNode, path: number[]) => void;
271
+ /** Spaces per indent level (default: 2) */
272
+ indent?: number;
273
+ }
274
+ /**
275
+ * Convert any JSON-compatible value to a TreeNode, optionally prefixed
276
+ * by `key` (the property name or array index in the parent container).
277
+ */
278
+ declare function jsonToTree(value: unknown, key?: string): TreeNode;
279
+ /**
280
+ * JSONView — a syntax-colored, collapsible JSON viewer.
281
+ *
282
+ * Extends `Tree` and overrides `_renderSelf` to colorize each row:
283
+ * - Key portion (the `"key: "` prefix) is rendered in cyan
284
+ * - Value portion is colored by JSON type:
285
+ * - string → green
286
+ * - number → yellow
287
+ * - boolean / null → magenta
288
+ * - object `{n}` / array `[n]` → white (default)
289
+ *
290
+ * Usage:
291
+ * ```ts
292
+ * const view = new JSONView({ data: { name: 'Alice', age: 30 } });
293
+ * view.updateRect({ x: 0, y: 0, width: 60, height: 20 });
294
+ * view.render(screen);
295
+ * ```
296
+ */
297
+ declare class JSONView extends Tree {
298
+ constructor(options: JSONViewOptions, style?: Partial<Style>);
299
+ /**
300
+ * Replicate Tree's _renderSelf but colorize key/value segments.
301
+ * We access the private state via `(this as any)` since Tree doesn't
302
+ * expose those fields publicly — the tradeoff of extending vs composing.
303
+ */
304
+ protected _renderSelf(screen: Screen): void;
305
+ }
306
+
307
+ interface DiffLine {
308
+ type: 'add' | 'remove' | 'context';
309
+ content: string;
310
+ lineNo?: number;
311
+ }
312
+ interface DiffViewOptions {
313
+ lines: DiffLine[];
314
+ showLineNumbers?: boolean;
315
+ gutterWidth?: number;
316
+ }
317
+ /**
318
+ * DiffView — a scrollable unified diff viewer with +/- line coloring.
319
+ *
320
+ * Supports:
321
+ * - Gutter with optional right-aligned line numbers (dim)
322
+ * - '+' prefix for added lines (green fg)
323
+ * - '-' prefix for removed lines (red fg)
324
+ * - ' ' prefix for context lines (dim fg)
325
+ * - Keyboard scrolling: ArrowUp/Down, j/k, PageUp/PageDown, Home/End
326
+ */
327
+ declare class DiffView extends Widget {
328
+ private _lines;
329
+ private _scrollOffset;
330
+ private _showLineNumbers;
331
+ private _gutterWidth;
332
+ constructor(options: DiffViewOptions, style?: Partial<Style>);
333
+ setLines(lines: DiffLine[]): void;
334
+ protected _renderSelf(screen: Screen): void;
335
+ handleKey(key: string): void;
336
+ }
337
+
338
+ interface StreamingTextOptions {
339
+ /** Full text content */
340
+ text: string;
341
+ /** Cursor character. Default: '▋' */
342
+ cursor?: string;
343
+ /** Characters to reveal per tick (0 = show all immediately). Default: 0 */
344
+ speed?: number;
345
+ /** Cursor blink interval in ms. Default: 530 */
346
+ blinkInterval?: number;
347
+ }
348
+ /**
349
+ * StreamingText — renders text that "streams in" token by token with a blinking cursor.
350
+ *
351
+ * Useful for displaying AI response streams or typewriter-style text effects.
352
+ *
353
+ * - When `speed === 0`: shows full text immediately, cursor blinks at end.
354
+ * - When `speed > 0`: reveals `speed` chars per `tick()` call until complete.
355
+ * - Cursor blinks every `blinkInterval` ms via the shared timer pool.
356
+ */
357
+ declare class StreamingText extends Widget {
358
+ private _text;
359
+ private _cursor;
360
+ private _speed;
361
+ private _blinkInterval;
362
+ /** Number of characters currently revealed (used when speed > 0) */
363
+ private _revealed;
364
+ private _cursorVisible;
365
+ private _blinkUnsub?;
366
+ constructor(options: StreamingTextOptions, style?: Partial<Style>);
367
+ /** Replace text content and reset the revealed counter to 0. */
368
+ setText(text: string): void;
369
+ /**
370
+ * Advance `_revealed` by `speed` characters.
371
+ * Call this from an external tick/render loop when `speed > 0`.
372
+ */
373
+ tick(): void;
374
+ /** Returns true when all text has been revealed. */
375
+ isComplete(): boolean;
376
+ /** Lifecycle: start the blink timer (only when motion is enabled). */
377
+ mount(): void;
378
+ /** Lifecycle: stop the blink timer. */
379
+ unmount(): void;
380
+ protected _renderSelf(screen: Screen): void;
381
+ }
382
+
383
+ type MessageRole = 'user' | 'assistant' | 'system' | 'tool';
384
+ interface ChatMessageOptions {
385
+ role: MessageRole;
386
+ content: string;
387
+ timestamp?: Date;
388
+ }
389
+ /**
390
+ * ChatMessage — displays a single chat message with a colored role badge
391
+ * and word-wrapped content text.
392
+ *
393
+ * Layout:
394
+ * Row 0: [Role badge] (colored) optional timestamp (dim, right-aligned)
395
+ * Row 1..N: content text, word-wrapped, indented 2 spaces
396
+ */
397
+ declare class ChatMessage extends Widget {
398
+ private _role;
399
+ private _content;
400
+ private _timestamp?;
401
+ constructor(options: ChatMessageOptions, style?: Partial<Style>);
402
+ /** Update the message content and mark dirty. */
403
+ setContent(content: string): void;
404
+ /** Update the message role and mark dirty. */
405
+ setRole(role: MessageRole): void;
406
+ protected _renderSelf(screen: Screen): void;
407
+ }
408
+
409
+ type ToolCallStatus = 'pending' | 'running' | 'done' | 'error';
410
+ interface ToolCallOptions {
411
+ name: string;
412
+ args: Record<string, unknown>;
413
+ result?: unknown;
414
+ status: ToolCallStatus;
415
+ collapsed?: boolean;
416
+ }
417
+ interface ToolApprovalOptions extends ToolCallOptions {
418
+ onApprove?: () => void;
419
+ onDeny?: () => void;
420
+ }
421
+ /**
422
+ * ToolCall — displays an AI tool invocation with status indicator,
423
+ * tool name, arguments, and optional result.
424
+ *
425
+ * Layout (expanded):
426
+ * Row 0: ▶/▼ tool_name [status-symbol] [status-label]
427
+ * Row 1+: " arg: value" (one per arg, 2-space indent)
428
+ * (if done/error and result present): " result: ..."
429
+ *
430
+ * Space or Enter toggles collapsed/expanded state.
431
+ */
432
+ declare class ToolCall extends Widget {
433
+ protected _name: string;
434
+ protected _args: Record<string, unknown>;
435
+ protected _result: unknown;
436
+ protected _status: ToolCallStatus;
437
+ protected _collapsed: boolean;
438
+ constructor(options: ToolCallOptions, style?: Partial<Style>);
439
+ setStatus(status: ToolCallStatus): void;
440
+ setResult(result: unknown): void;
441
+ collapse(): void;
442
+ expand(): void;
443
+ handleKey(key: string): void;
444
+ protected _renderSelf(screen: Screen): void;
445
+ }
446
+ /**
447
+ * ToolApproval — extends ToolCall with an approval prompt row.
448
+ * When focused, shows "[y] Approve [n] Deny" after the args/result.
449
+ * y/Enter calls onApprove; n/Escape calls onDeny.
450
+ */
451
+ declare class ToolApproval extends ToolCall {
452
+ private _onApprove?;
453
+ private _onDeny?;
454
+ constructor(options: ToolApprovalOptions, style?: Partial<Style>);
455
+ protected _renderSelf(screen: Screen): void;
456
+ handleKey(key: string): void;
457
+ }
458
+
459
+ interface ScrollRange {
460
+ start: number;
461
+ end: number;
462
+ offsetPx: number;
463
+ }
464
+ /**
465
+ * Compute visible range for fixed-height items.
466
+ * @param scrollOffset - first visible item index (scroll position in items, NOT pixels)
467
+ * @param viewportItems - number of items visible in the viewport
468
+ * @param itemCount - total number of items
469
+ * @param overscan - extra items to render beyond viewport edges (default: 2)
470
+ */
471
+ declare function computeRange(scrollOffset: number, viewportItems: number, itemCount: number, overscan?: number): ScrollRange;
472
+ /**
473
+ * Compute visible range for variable-height items.
474
+ * @param scrollPx - scroll position in pixels
475
+ * @param viewportPx - viewport height in pixels
476
+ * @param sizes - array of item heights in pixels
477
+ * @param overscan - extra items to render (default: 2)
478
+ */
479
+ declare function computeVariableRange(scrollPx: number, viewportPx: number, sizes: number[], overscan?: number): ScrollRange;
480
+
193
481
  interface ListItem {
194
482
  label: string;
195
483
  value: string;
@@ -335,6 +623,60 @@ declare class VirtualList extends Widget {
335
623
  private _clampScroll;
336
624
  }
337
625
 
626
+ interface Command {
627
+ id: string;
628
+ label: string;
629
+ description?: string;
630
+ action: () => void;
631
+ }
632
+ interface CommandPaletteOptions {
633
+ commands: Command[];
634
+ onClose?: () => void;
635
+ /** Placeholder shown when query is empty. Default: 'Type to search...' */
636
+ placeholder?: string;
637
+ /** Max number of commands shown at once. Default: 8 */
638
+ maxVisible?: number;
639
+ }
640
+ /**
641
+ * CommandPalette — a fuzzy-search overlay widget.
642
+ *
643
+ * Renders a floating panel with:
644
+ * - Row 0: `> ` + query text (or placeholder when empty)
645
+ * - Rows 1..N: filtered command list with label + description
646
+ *
647
+ * Key bindings:
648
+ * - Printable chars: append to query
649
+ * - Backspace: delete last query character
650
+ * - ArrowUp / k: move selection up
651
+ * - ArrowDown / j: move selection down
652
+ * - Enter: execute selected command
653
+ * - Escape: call onClose
654
+ */
655
+ declare class CommandPalette extends Widget {
656
+ private _commands;
657
+ private _filtered;
658
+ private _query;
659
+ private _selectedIndex;
660
+ private _options;
661
+ constructor(options: CommandPaletteOptions, style?: Partial<Style>);
662
+ /** Update the full command list and re-filter. */
663
+ setCommands(commands: Command[]): void;
664
+ /**
665
+ * Reset query, re-filter all commands, reset selection.
666
+ * Call this when opening the palette.
667
+ */
668
+ open(): void;
669
+ /** Current query string. */
670
+ getQuery(): string;
671
+ /** Filter commands based on current query (case-insensitive substring). */
672
+ private _filter;
673
+ private _executeSelected;
674
+ private _moveUp;
675
+ private _moveDown;
676
+ handleKey(key: string): void;
677
+ protected _renderSelf(screen: Screen): void;
678
+ }
679
+
338
680
  interface TableColumn {
339
681
  /** Column header label */
340
682
  header: string;
@@ -503,6 +845,137 @@ declare class BarChart extends Widget {
503
845
  private _renderHorizontal;
504
846
  }
505
847
 
848
+ interface GridOptions {
849
+ /** Number of equal-width columns */
850
+ columns: number;
851
+ /** Gap between items in both directions (default: 1) */
852
+ gap?: number;
853
+ /** Row gap override (overrides gap for rows) */
854
+ rowGap?: number;
855
+ /** Column gap override (overrides gap for columns) */
856
+ colGap?: number;
857
+ }
858
+ /**
859
+ * Grid — a CSS-Grid-like layout widget.
860
+ *
861
+ * Items fill left-to-right, wrapping to a new row every `columns` items.
862
+ * Internally creates a column-flex Box per row, each with equal-flex-grow items.
863
+ *
864
+ * The `addChild()` override means the reconciler's generic child-adding
865
+ * loop works without any special casing.
866
+ */
867
+ declare class Grid extends Widget {
868
+ private _columns;
869
+ private _colGap;
870
+ private _rowGap;
871
+ private _rows;
872
+ private _itemCount;
873
+ constructor(style: Partial<Style>, options: GridOptions);
874
+ protected _renderSelf(_screen: Screen): void;
875
+ /**
876
+ * Add a widget to the grid. Items fill left-to-right,
877
+ * wrapping to a new row automatically every `columns` items.
878
+ * Overrides Widget.addChild so the reconciler generic loop works unchanged.
879
+ */
880
+ addChild(widget: Widget): void;
881
+ /** Add an item explicitly (alias for addChild) */
882
+ addItem(widget: Widget): void;
883
+ /** Remove all items and reset the grid */
884
+ clearItems(): void;
885
+ }
886
+
887
+ interface ScrollViewOptions {
888
+ /** Total height of content in rows */
889
+ contentHeight?: number;
890
+ /** Show scrollbar indicator on right edge */
891
+ showScrollbar?: boolean;
892
+ }
893
+ /**
894
+ * ScrollView — a height-bounded scrollable container.
895
+ *
896
+ * Children are rendered with a vertical offset applied (scrolling).
897
+ * Responds to up/down arrow keys and Page Up/Page Down.
898
+ */
899
+ declare class ScrollView extends Widget {
900
+ private _scrollOffset;
901
+ private _contentHeight;
902
+ private _showScrollbar;
903
+ constructor(style?: Partial<Style>, opts?: ScrollViewOptions);
904
+ /** Set the total content height (in rows) */
905
+ setContentHeight(h: number): void;
906
+ /** Get current scroll offset */
907
+ get scrollOffset(): number;
908
+ /** Scroll by delta rows */
909
+ scrollBy(delta: number): void;
910
+ /** Scroll to absolute offset */
911
+ scrollTo(offset: number): void;
912
+ private _clampOffset;
913
+ /** Handle keyboard navigation */
914
+ onKey(event: KeyEvent): void;
915
+ render(screen: Screen): void;
916
+ private _renderScrollbar;
917
+ protected _renderSelf(_screen: Screen): void;
918
+ }
919
+
920
+ interface CenterOptions {
921
+ /** Center horizontally (default: true) */
922
+ horizontal?: boolean;
923
+ /** Center vertically (default: true) */
924
+ vertical?: boolean;
925
+ }
926
+ /**
927
+ * Center — centers a single child widget horizontally and/or vertically.
928
+ *
929
+ * Computes centering offsets at render time from the child's measured size.
930
+ */
931
+ declare class Center extends Widget {
932
+ private _horizontal;
933
+ private _vertical;
934
+ constructor(style?: Partial<Style>, opts?: CenterOptions);
935
+ protected _renderSelf(_screen: Screen): void;
936
+ render(screen: Screen): void;
937
+ }
938
+
939
+ interface CardOptions {
940
+ /** Optional title shown in the top border */
941
+ title?: string;
942
+ /** Color for the border and title */
943
+ borderColor?: Color;
944
+ }
945
+ /**
946
+ * Card — a bordered container with an optional title in the top border.
947
+ *
948
+ * Like a Box with border + padding, but supports embedding a title string
949
+ * directly in the top border line.
950
+ */
951
+ declare class Card extends Widget {
952
+ private _title;
953
+ private _borderColor?;
954
+ constructor(style?: Partial<Style>, opts?: CardOptions);
955
+ setTitle(title: string): void;
956
+ protected _renderSelf(screen: Screen): void;
957
+ }
958
+
959
+ interface ColumnsOptions {
960
+ /** Gap between columns in cells (default: 1) */
961
+ gap?: number;
962
+ }
963
+ /**
964
+ * Columns — splits available width evenly across child widgets.
965
+ *
966
+ * Children are laid out side-by-side with equal flex-grow.
967
+ * Internally uses a flex-row Box; the addChild override applies
968
+ * flexGrow:1 to each child so the reconciler's generic loop works.
969
+ */
970
+ declare class Columns extends Widget {
971
+ private _inner;
972
+ constructor(style?: Partial<Style>, opts?: ColumnsOptions);
973
+ addChild(widget: Widget): void;
974
+ removeChild(widget: Widget): void;
975
+ clearChildren(): void;
976
+ protected _renderSelf(_screen: Screen): void;
977
+ }
978
+
506
979
  interface ProgressBarOptions {
507
980
  /** Current value (0–1) */
508
981
  value?: number;
@@ -543,6 +1016,49 @@ declare class ProgressBar extends Widget {
543
1016
  protected _renderSelf(screen: Screen): void;
544
1017
  }
545
1018
 
1019
+ /**
1020
+ * A single progress item in MultiProgress
1021
+ */
1022
+ interface ProgressItem {
1023
+ label: string;
1024
+ value: number;
1025
+ color?: Color;
1026
+ }
1027
+ /**
1028
+ * Options for MultiProgress widget
1029
+ */
1030
+ interface MultiProgressOptions {
1031
+ items: ProgressItem[];
1032
+ labelWidth?: number;
1033
+ showValues?: boolean;
1034
+ }
1035
+ /**
1036
+ * MultiProgress — stacks multiple labeled progress bars in a vertical list.
1037
+ *
1038
+ * Each item renders on its own row with a label, bar, and optional percentage.
1039
+ *
1040
+ * Supports:
1041
+ * - Multiple items with individual colors
1042
+ * - Custom label column width
1043
+ * - Optional percentage display
1044
+ * - Smooth animation-ready value changes
1045
+ */
1046
+ declare class MultiProgress extends Widget {
1047
+ private _items;
1048
+ private _labelWidth;
1049
+ private _showValues;
1050
+ constructor(options: MultiProgressOptions, style?: Partial<Style>);
1051
+ /**
1052
+ * Replace all items and mark dirty
1053
+ */
1054
+ setItems(items: ProgressItem[]): void;
1055
+ /**
1056
+ * Update a single item's value
1057
+ */
1058
+ updateItem(index: number, value: number): void;
1059
+ protected _renderSelf(screen: Screen): void;
1060
+ }
1061
+
546
1062
  /**
547
1063
  * Built-in spinner frame sets.
548
1064
  */
@@ -578,6 +1094,7 @@ declare class Spinner extends Widget {
578
1094
  private _color;
579
1095
  private _lastTick;
580
1096
  private _elapsed;
1097
+ private _timerUnsub?;
581
1098
  constructor(style?: Partial<Style>, options?: SpinnerOptions);
582
1099
  /** Update the spinner label */
583
1100
  setLabel(label: string): void;
@@ -586,6 +1103,10 @@ declare class Spinner extends Widget {
586
1103
  * Call this with a delta (ms) from the render loop.
587
1104
  */
588
1105
  tick(deltaMs: number): void;
1106
+ /** Lifecycle: start the frame-advance timer (only when motion is enabled). */
1107
+ mount(): void;
1108
+ /** Lifecycle: stop the frame-advance timer. */
1109
+ unmount(): void;
589
1110
  protected _renderSelf(screen: Screen): void;
590
1111
  }
591
1112
 
@@ -621,4 +1142,282 @@ declare class Scrollbar extends Widget {
621
1142
  protected _renderSelf(screen: Screen): void;
622
1143
  }
623
1144
 
624
- export { type Bar, BarChart, type BarChartDirection, type BarChartOptions, type BarGroup, Box, Gauge, type GaugeOptions, List, type ListItem, LogView, type LogViewOptions, ProgressBar, type ProgressBarOptions, SPINNER_FRAMES, Scrollbar, type ScrollbarOptions, type ScrollbarOrientation, Sparkline, type SparklineOptions, Spinner, type SpinnerOptions, StatusIndicator, type StatusIndicatorOptions, Table, type TableColumn, type TableOptions, type TableRow, Text, TextInput, type TextProps, VirtualList, type VirtualListOptions, Widget, type WidgetEvents };
1145
+ interface SkeletonOptions {
1146
+ /** Animation style: 'pulse' alternates two chars; 'shimmer' scrolls a highlight band */
1147
+ variant?: 'pulse' | 'shimmer';
1148
+ /** Animation interval in ms (default: 600) */
1149
+ intervalMs?: number;
1150
+ /** Characters for pulse: [dim, bright]. Default: ['░', '▒'] (ASCII fallback: ['-', '#']) */
1151
+ chars?: [string, string];
1152
+ /** Color for the bright state (optional) */
1153
+ color?: Color;
1154
+ }
1155
+ /**
1156
+ * Skeleton — animated loading placeholder.
1157
+ *
1158
+ * Supports:
1159
+ * - 'pulse' variant: alternates between dim and bright fill characters
1160
+ * - 'shimmer' variant: scrolls a bright band (~20% width) across the widget
1161
+ * - Automatic ASCII fallback when unicode is unavailable
1162
+ * - No animation when caps.motion is false (static frame 0)
1163
+ */
1164
+ declare class Skeleton extends Widget {
1165
+ private _frame;
1166
+ private _shimmerPos;
1167
+ private _unsub?;
1168
+ private _chars;
1169
+ private _variant;
1170
+ private _intervalMs;
1171
+ constructor(style?: Partial<Style>, options?: SkeletonOptions);
1172
+ unmount(): void;
1173
+ protected _renderSelf(screen: Screen): void;
1174
+ }
1175
+
1176
+ type StatusVariant = 'success' | 'error' | 'warning' | 'info';
1177
+ interface StatusMessageOptions {
1178
+ /** Variant determines icon and color */
1179
+ variant?: StatusVariant;
1180
+ /** Override the icon character */
1181
+ icon?: string;
1182
+ }
1183
+ /**
1184
+ * StatusMessage — a single-line status indicator.
1185
+ *
1186
+ * Renders an icon (✓/✗/⚠/ℹ) followed by a message, colored by variant.
1187
+ */
1188
+ declare class StatusMessage extends Widget {
1189
+ private _message;
1190
+ private _variant;
1191
+ private _icon?;
1192
+ constructor(message: string, style?: Partial<Style>, opts?: StatusMessageOptions);
1193
+ setMessage(message: string): void;
1194
+ setVariant(variant: StatusVariant): void;
1195
+ protected _renderSelf(screen: Screen): void;
1196
+ }
1197
+
1198
+ interface BannerOptions {
1199
+ /** Variant determines border color */
1200
+ variant?: StatusVariant;
1201
+ /** Title displayed on first line in bold */
1202
+ title?: string;
1203
+ /** Body text */
1204
+ body?: string;
1205
+ }
1206
+ /**
1207
+ * Banner — full-width alert with title and body text.
1208
+ *
1209
+ * Shows a bordered box with a bold title line and body text,
1210
+ * colored according to variant. The border is drawn manually
1211
+ * to use the variant color.
1212
+ */
1213
+ declare class Banner extends Widget {
1214
+ private _variant;
1215
+ private _title;
1216
+ private _body;
1217
+ constructor(style?: Partial<Style>, opts?: BannerOptions);
1218
+ setTitle(title: string): void;
1219
+ setBody(body: string): void;
1220
+ setVariant(variant: StatusVariant): void;
1221
+ protected _renderSelf(screen: Screen): void;
1222
+ }
1223
+
1224
+ interface KeyValuePair {
1225
+ key: string;
1226
+ value: string;
1227
+ }
1228
+ interface KeyValueOptions {
1229
+ /** Separator between key and value (default: ': ') */
1230
+ separator?: string;
1231
+ /** Color for keys */
1232
+ keyColor?: _termuijs_core.Color;
1233
+ /** Color for values */
1234
+ valueColor?: _termuijs_core.Color;
1235
+ }
1236
+ /**
1237
+ * KeyValue — aligned key: value pairs.
1238
+ *
1239
+ * Keys are right-aligned to the width of the longest key.
1240
+ * Values follow after the separator.
1241
+ */
1242
+ declare class KeyValue extends Widget {
1243
+ private _pairs;
1244
+ private _separator;
1245
+ private _keyColor?;
1246
+ private _valueColor?;
1247
+ constructor(pairs: Array<KeyValuePair> | Record<string, string>, style?: Partial<Style>, opts?: KeyValueOptions);
1248
+ setPairs(pairs: Array<KeyValuePair> | Record<string, string>): void;
1249
+ protected _renderSelf(screen: Screen): void;
1250
+ }
1251
+
1252
+ interface SidebarItem {
1253
+ label: string;
1254
+ badge?: string;
1255
+ active?: boolean;
1256
+ }
1257
+ interface SidebarOptions {
1258
+ /** Whether the sidebar is collapsed */
1259
+ collapsed?: boolean;
1260
+ /** Collapsed width in cells (default: 3) */
1261
+ collapsedWidth?: number;
1262
+ /** Active item highlight color */
1263
+ activeColor?: _termuijs_core.Color;
1264
+ /** Badge color */
1265
+ badgeColor?: _termuijs_core.Color;
1266
+ }
1267
+ /**
1268
+ * Sidebar — a vertical list of navigation items with optional badges.
1269
+ *
1270
+ * Supports active item highlighting and collapsible mode.
1271
+ */
1272
+ declare class Sidebar extends Widget {
1273
+ private _items;
1274
+ private _collapsed;
1275
+ private _collapsedWidth;
1276
+ private _activeColor;
1277
+ private _badgeColor;
1278
+ constructor(items: SidebarItem[], style?: Partial<Style>, opts?: SidebarOptions);
1279
+ setItems(items: SidebarItem[]): void;
1280
+ setCollapsed(collapsed: boolean): void;
1281
+ toggle(): void;
1282
+ get isCollapsed(): boolean;
1283
+ protected _renderSelf(screen: Screen): void;
1284
+ }
1285
+
1286
+ interface LineChartOptions {
1287
+ /** Color of the plotted points/lines */
1288
+ color?: Color;
1289
+ /** Show Y-axis labels */
1290
+ showYAxis?: boolean;
1291
+ /** Show X-axis labels */
1292
+ showXAxis?: boolean;
1293
+ /** Label for the Y axis */
1294
+ yLabel?: string;
1295
+ /** Maximum Y value (auto if not set) */
1296
+ max?: number;
1297
+ /** Minimum Y value (auto if not set) */
1298
+ min?: number;
1299
+ }
1300
+ /**
1301
+ * LineChart — ASCII/Unicode line plot for a series of numbers.
1302
+ *
1303
+ * Normalizes data to the available height, samples to fit width.
1304
+ * Plots points with simple vertical bar connectors between adjacent points.
1305
+ */
1306
+ declare class LineChart extends Widget {
1307
+ private _data;
1308
+ private _color;
1309
+ private _showYAxis;
1310
+ private _showXAxis;
1311
+ private _yLabel;
1312
+ private _max?;
1313
+ private _min?;
1314
+ constructor(data: number[], style?: Partial<Style>, opts?: LineChartOptions);
1315
+ setData(data: number[]): void;
1316
+ pushValue(value: number): void;
1317
+ protected _renderSelf(screen: Screen): void;
1318
+ }
1319
+
1320
+ interface HeatMapOptions {
1321
+ /** Color for maximum value cells */
1322
+ highColor?: Color;
1323
+ /** Color for minimum value cells */
1324
+ lowColor?: Color;
1325
+ /** Row labels (left side) */
1326
+ rowLabels?: string[];
1327
+ /** Column labels (top) */
1328
+ colLabels?: string[];
1329
+ }
1330
+ /**
1331
+ * HeatMap — 2D matrix displayed with character-density shading.
1332
+ *
1333
+ * Values are normalized 0–1 and mapped to 4 shading levels.
1334
+ */
1335
+ declare class HeatMap extends Widget {
1336
+ private _matrix;
1337
+ private _highColor;
1338
+ private _lowColor;
1339
+ private _rowLabels;
1340
+ private _colLabels;
1341
+ constructor(matrix: number[][], style?: Partial<Style>, opts?: HeatMapOptions);
1342
+ setMatrix(matrix: number[][]): void;
1343
+ protected _renderSelf(screen: Screen): void;
1344
+ }
1345
+
1346
+ interface DefinitionPair {
1347
+ term: string;
1348
+ definition: string;
1349
+ }
1350
+ interface DefinitionOptions {
1351
+ /** Indentation for definition lines (default: 2) */
1352
+ indent?: number;
1353
+ /** Blank line between pairs (default: true) */
1354
+ spacing?: boolean;
1355
+ /** Color for term labels */
1356
+ termColor?: _termuijs_core.Color;
1357
+ /** Color for definition text */
1358
+ definitionColor?: _termuijs_core.Color;
1359
+ }
1360
+ /**
1361
+ * Definition — term + definition pairs, stacked vertically.
1362
+ *
1363
+ * Each pair renders as:
1364
+ * Term
1365
+ * definition text (indented)
1366
+ *
1367
+ * Similar to KeyValue but stacked rather than inline.
1368
+ */
1369
+ declare class Definition extends Widget {
1370
+ private _pairs;
1371
+ private _indent;
1372
+ private _spacing;
1373
+ private _termColor?;
1374
+ private _definitionColor?;
1375
+ constructor(pairs: DefinitionPair[] | Record<string, string>, style?: Partial<Style>, opts?: DefinitionOptions);
1376
+ setPairs(pairs: DefinitionPair[] | Record<string, string>): void;
1377
+ protected _renderSelf(screen: Screen): void;
1378
+ }
1379
+
1380
+ interface BigTextOptions {
1381
+ /** Color for the rendered characters */
1382
+ color?: Color;
1383
+ }
1384
+ /**
1385
+ * BigText — renders text as large 5×3 ASCII art banner characters.
1386
+ *
1387
+ * Supports A–Z (uppercase), 0–9, and common punctuation.
1388
+ * Unrecognized characters fall back to a narrow glyph.
1389
+ */
1390
+ declare class BigText extends Widget {
1391
+ private _text;
1392
+ private _color;
1393
+ constructor(text: string, style?: Partial<Style>, opts?: BigTextOptions);
1394
+ setText(text: string): void;
1395
+ protected _renderSelf(screen: Screen): void;
1396
+ }
1397
+
1398
+ interface GradientOptions {
1399
+ /** Start color (hex string like '#ff0000' or named color string) */
1400
+ startColor?: string;
1401
+ /** End color (hex string like '#0000ff' or named color string) */
1402
+ endColor?: string;
1403
+ /** Text alignment */
1404
+ align?: 'left' | 'center' | 'right';
1405
+ }
1406
+ /**
1407
+ * Gradient — text rendered with a smooth color gradient.
1408
+ *
1409
+ * Each character is colored by linearly interpolating between startColor and endColor.
1410
+ * Falls back to a single foreground color if true-color is unavailable.
1411
+ */
1412
+ declare class Gradient extends Widget {
1413
+ private _text;
1414
+ private _startColor;
1415
+ private _endColor;
1416
+ private _align;
1417
+ constructor(text: string, style?: Partial<Style>, opts?: GradientOptions);
1418
+ setText(text: string): void;
1419
+ setColors(start: string, end: string): void;
1420
+ protected _renderSelf(screen: Screen): void;
1421
+ }
1422
+
1423
+ export { Banner, type BannerOptions, type Bar, BarChart, type BarChartDirection, type BarChartOptions, type BarGroup, BigText, type BigTextOptions, Box, Card, type CardOptions, Center, type CenterOptions, ChatMessage, type ChatMessageOptions, Columns, type ColumnsOptions, type Command, CommandPalette, type CommandPaletteOptions, Definition, type DefinitionOptions, type DefinitionPair, type DiffLine, DiffView, type DiffViewOptions, Gauge, type GaugeOptions, Gradient, type GradientOptions, Grid, type GridOptions, HeatMap, type HeatMapOptions, type JSONNodeData, type JSONNodeType, JSONView, type JSONViewOptions, KeyValue, type KeyValueOptions, type KeyValuePair, LineChart, type LineChartOptions, List, type ListItem, LogView, type LogViewOptions, type MessageRole, MultiProgress, type MultiProgressOptions, ProgressBar, type ProgressBarOptions, type ProgressItem, SPINNER_FRAMES, type ScrollRange, ScrollView, type ScrollViewOptions, Scrollbar, type ScrollbarOptions, type ScrollbarOrientation, Sidebar, type SidebarItem, type SidebarOptions, Skeleton, type SkeletonOptions, Sparkline, type SparklineOptions, Spinner, type SpinnerOptions, StatusIndicator, type StatusIndicatorOptions, StatusMessage, type StatusMessageOptions, type StatusVariant, StreamingText, type StreamingTextOptions, Table, type TableColumn, type TableOptions, type TableRow, Text, TextInput, type TextProps, ToolApproval, type ToolApprovalOptions, ToolCall, type ToolCallOptions, type ToolCallStatus, Tree, type TreeNode, type TreeOptions, VirtualList, type VirtualListOptions, Widget, type WidgetEvents, computeRange, computeVariableRange, jsonToTree };