ink-hud 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +284 -0
- package/dist/index.cjs +3012 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1510 -0
- package/dist/index.d.ts +1510 -0
- package/dist/index.js +2951 -0
- package/dist/index.js.map +1 -0
- package/package.json +89 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1510 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BoxProps } from 'ink';
|
|
3
|
+
|
|
4
|
+
interface Pixel {
|
|
5
|
+
/** Whether the pixel is active (lit) */
|
|
6
|
+
active: boolean;
|
|
7
|
+
/** Color of the pixel */
|
|
8
|
+
color?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A line of rendered text, consisting of segments with optional styling.
|
|
12
|
+
*/
|
|
13
|
+
type RenderedLine = Array<{
|
|
14
|
+
text: string;
|
|
15
|
+
color?: string;
|
|
16
|
+
backgroundColor?: string;
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Renderer Module - Defines a unified interface for all renderers
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Renderer type
|
|
24
|
+
*/
|
|
25
|
+
type RendererType = 'braille' | 'block' | 'ascii';
|
|
26
|
+
/**
|
|
27
|
+
* Renderer resolution information
|
|
28
|
+
* Represents how many pixels each character can display
|
|
29
|
+
*/
|
|
30
|
+
interface RendererResolution {
|
|
31
|
+
/** Pixels per character horizontally (e.g. Braille 2, Block 2, ASCII 1) */
|
|
32
|
+
horizontal: number;
|
|
33
|
+
/** Pixels per character vertically (e.g. Braille 4, Block 8, ASCII 1) */
|
|
34
|
+
vertical: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Renderer metadata
|
|
38
|
+
* Describes renderer capabilities and requirements
|
|
39
|
+
*/
|
|
40
|
+
interface RendererMetadata {
|
|
41
|
+
/** Renderer name */
|
|
42
|
+
name: RendererType;
|
|
43
|
+
/** Renderer display name */
|
|
44
|
+
displayName: string;
|
|
45
|
+
/** Renderer description */
|
|
46
|
+
description: string;
|
|
47
|
+
/** Renderer resolution */
|
|
48
|
+
resolution: RendererResolution;
|
|
49
|
+
/** Whether UTF-8 support is required */
|
|
50
|
+
requiresUtf8: boolean;
|
|
51
|
+
/** Whether Unicode support is required */
|
|
52
|
+
requiresUnicode: boolean;
|
|
53
|
+
/** Minimum terminal capability score requirement (0-100) */
|
|
54
|
+
minScore: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Abstract Renderer base class
|
|
58
|
+
*
|
|
59
|
+
* Provides common implementations for all drawing primitives. Subclasses only need to implement:
|
|
60
|
+
* - getMetadata(): Return renderer metadata
|
|
61
|
+
* - renderCanvas(): Convert Pixel[][] to terminal characters
|
|
62
|
+
*/
|
|
63
|
+
declare abstract class Renderer {
|
|
64
|
+
/**
|
|
65
|
+
* Get renderer metadata (must be implemented by subclasses)
|
|
66
|
+
*/
|
|
67
|
+
abstract getMetadata(): RendererMetadata;
|
|
68
|
+
/**
|
|
69
|
+
* Render Canvas as styled lines of text (must be implemented by subclasses)
|
|
70
|
+
* @param pixels - 2D pixel array
|
|
71
|
+
* @param width - Canvas width (pixels)
|
|
72
|
+
* @param height - Canvas height (pixels)
|
|
73
|
+
* @returns Array of colored text lines
|
|
74
|
+
*/
|
|
75
|
+
abstract renderCanvas(pixels: Pixel[][], width: number, height: number): RenderedLine[];
|
|
76
|
+
/**
|
|
77
|
+
* Create a blank Canvas
|
|
78
|
+
* @param width - Canvas width (pixels)
|
|
79
|
+
* @param height - Canvas height (pixels)
|
|
80
|
+
* @returns 2D pixel array
|
|
81
|
+
*/
|
|
82
|
+
createCanvas(width: number, height: number): Pixel[][];
|
|
83
|
+
/**
|
|
84
|
+
* Set a single pixel on the Canvas
|
|
85
|
+
* @param canvas - Canvas
|
|
86
|
+
* @param x - x coordinate
|
|
87
|
+
* @param y - y coordinate
|
|
88
|
+
* @param pixel - Pixel properties (active, color, etc.)
|
|
89
|
+
*/
|
|
90
|
+
setPixel(canvas: Pixel[][], x: number, y: number, pixel?: Partial<Pixel>): void;
|
|
91
|
+
/**
|
|
92
|
+
* Draw line segments (Bresenham's algorithm)
|
|
93
|
+
*/
|
|
94
|
+
drawLine(canvas: Pixel[][], x0: number, y0: number, x1: number, y1: number, pixel?: Partial<Pixel>): void;
|
|
95
|
+
/**
|
|
96
|
+
* Draw circle or ring (Midpoint Circle algorithm)
|
|
97
|
+
*/
|
|
98
|
+
drawCircle(canvas: Pixel[][], centerX: number, centerY: number, radius: number, filled?: boolean, pixel?: Partial<Pixel>): void;
|
|
99
|
+
/**
|
|
100
|
+
* Draw arc (Parametric equation)
|
|
101
|
+
*/
|
|
102
|
+
drawArc(canvas: Pixel[][], centerX: number, centerY: number, radius: number, startAngle: number, endAngle: number, thickness?: number, pixel?: Partial<Pixel>): void;
|
|
103
|
+
/**
|
|
104
|
+
* Draw rectangle
|
|
105
|
+
*/
|
|
106
|
+
drawRect(canvas: Pixel[][], x: number, y: number, width: number, height: number, filled?: boolean, pixel?: Partial<Pixel>): void;
|
|
107
|
+
/**
|
|
108
|
+
* Get renderer resolution
|
|
109
|
+
*/
|
|
110
|
+
getResolution(): RendererResolution;
|
|
111
|
+
/**
|
|
112
|
+
* Get renderer name
|
|
113
|
+
*/
|
|
114
|
+
getName(): RendererType;
|
|
115
|
+
/**
|
|
116
|
+
* Calculate number of character rows and columns needed to render specified dimensions
|
|
117
|
+
*/
|
|
118
|
+
calculateCharDimensions(pixelWidth: number, pixelHeight: number): {
|
|
119
|
+
rows: number;
|
|
120
|
+
cols: number;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Braille Renderer
|
|
126
|
+
*
|
|
127
|
+
* Implements 2x4 dot matrix rendering using Braille Unicode characters (U+2800-U+28FF)
|
|
128
|
+
* Each character can represent 8 sub-pixels, providing 8x resolution
|
|
129
|
+
*/
|
|
130
|
+
declare class BrailleRenderer extends Renderer {
|
|
131
|
+
getMetadata(): RendererMetadata;
|
|
132
|
+
private createBrailleChar;
|
|
133
|
+
private pixelToDotIndex;
|
|
134
|
+
private fillBrailleDots;
|
|
135
|
+
private resolveColor;
|
|
136
|
+
renderCanvas(pixels: Pixel[][], width: number, height: number): RenderedLine[];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Block Elements renderer
|
|
141
|
+
*
|
|
142
|
+
* Implements 2x8 dot matrix rendering using Unicode Block Elements characters (U+2581-U+2588)
|
|
143
|
+
* Vertical 8x resolution, horizontal 2x resolution
|
|
144
|
+
*/
|
|
145
|
+
declare class BlockRenderer extends Renderer {
|
|
146
|
+
private static readonly BLOCK_LUT;
|
|
147
|
+
getMetadata(): RendererMetadata;
|
|
148
|
+
/**
|
|
149
|
+
* Determine primary color
|
|
150
|
+
*/
|
|
151
|
+
private resolveColor;
|
|
152
|
+
renderCanvas(pixels: Pixel[][], width: number, height: number): RenderedLine[];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* ASCII renderer
|
|
157
|
+
*
|
|
158
|
+
* Implements 1x3 dot matrix rendering using basic ASCII characters
|
|
159
|
+
* Simulates subtle height variations using top/middle/bottom character segments
|
|
160
|
+
*/
|
|
161
|
+
declare class AsciiRenderer extends Renderer {
|
|
162
|
+
getMetadata(): RendererMetadata;
|
|
163
|
+
/**
|
|
164
|
+
* Check if the pixel at the specified position is set
|
|
165
|
+
*/
|
|
166
|
+
private isPixelSet;
|
|
167
|
+
private getCellPositions;
|
|
168
|
+
private getNeighborPosition;
|
|
169
|
+
private selectMultiPixelChar;
|
|
170
|
+
private selectHorizontalChar;
|
|
171
|
+
private selectDiagonalChar;
|
|
172
|
+
private selectIsolatedChar;
|
|
173
|
+
private selectSinglePixelChar;
|
|
174
|
+
/**
|
|
175
|
+
* Intelligently select ASCII character
|
|
176
|
+
* Select appropriate character based on 1x3 vertical pixels and adjacent column connections
|
|
177
|
+
*/
|
|
178
|
+
private selectAsciiChar;
|
|
179
|
+
/**
|
|
180
|
+
* Determine the primary color for this character cell
|
|
181
|
+
*/
|
|
182
|
+
private resolveColor;
|
|
183
|
+
renderCanvas(pixels: Pixel[][], width: number, height: number): RenderedLine[];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Terminal detection type definitions
|
|
188
|
+
*
|
|
189
|
+
* Define type interfaces for terminal capabilities and environment information
|
|
190
|
+
*/
|
|
191
|
+
/**
|
|
192
|
+
* Terminal capability information
|
|
193
|
+
*
|
|
194
|
+
* Describes features supported by the current terminal and the overall score
|
|
195
|
+
*/
|
|
196
|
+
interface TerminalCapabilities {
|
|
197
|
+
/** Whether UTF-8 encoding is supported */
|
|
198
|
+
supportsUtf8: boolean;
|
|
199
|
+
/** Whether Unicode characters are supported */
|
|
200
|
+
supportsUnicode: boolean;
|
|
201
|
+
/** Whether Braille characters are supported (U+2800-U+28FF) */
|
|
202
|
+
supportsBraille: boolean;
|
|
203
|
+
/** Whether Block Elements characters are supported (U+2580-U+259F) */
|
|
204
|
+
supportsBlockElements: boolean;
|
|
205
|
+
/** Whether colors are supported (16 colors or more) */
|
|
206
|
+
supportsColor: boolean;
|
|
207
|
+
/** Whether true color is supported (24-bit RGB) */
|
|
208
|
+
supportsTrueColor: boolean;
|
|
209
|
+
/** Comprehensive terminal capability score (0-100) */
|
|
210
|
+
score: number;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Environment information
|
|
214
|
+
*
|
|
215
|
+
* Terminal-related information extracted from process environment variables
|
|
216
|
+
*/
|
|
217
|
+
interface EnvironmentInfo {
|
|
218
|
+
/** Language environment variable (e.g. en_US.UTF-8) */
|
|
219
|
+
LANG?: string;
|
|
220
|
+
/** Terminal type (e.g. xterm-256color) */
|
|
221
|
+
TERM?: string;
|
|
222
|
+
/** Color support (e.g. truecolor) */
|
|
223
|
+
COLORTERM?: string;
|
|
224
|
+
/** Terminal program name (e.g. iTerm.app, Warp) */
|
|
225
|
+
TERM_PROGRAM?: string;
|
|
226
|
+
/** Terminal program version */
|
|
227
|
+
TERM_PROGRAM_VERSION?: string;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Terminal capabilities detector
|
|
232
|
+
*
|
|
233
|
+
* Automatically detect terminal-supported features by analyzing environment variables
|
|
234
|
+
*/
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Terminal capabilities detector
|
|
238
|
+
*
|
|
239
|
+
* Analyze process environment variables to determine current terminal's supported character sets, colors, and other features
|
|
240
|
+
*/
|
|
241
|
+
declare class TerminalDetector {
|
|
242
|
+
/** Terminal whitelist supporting Braille characters (lowercase) */
|
|
243
|
+
private static readonly BRAILLE_SUPPORTED_TERMINALS;
|
|
244
|
+
/** Environment variable information */
|
|
245
|
+
private envInfo;
|
|
246
|
+
constructor(env?: NodeJS.ProcessEnv);
|
|
247
|
+
/**
|
|
248
|
+
* Extract relevant information from environment variables
|
|
249
|
+
* @param env - Environment variable object
|
|
250
|
+
* @returns Environment information
|
|
251
|
+
*/
|
|
252
|
+
private extractEnvInfo;
|
|
253
|
+
/**
|
|
254
|
+
* Detect UTF-8 support
|
|
255
|
+
* @returns Whether UTF-8 is supported
|
|
256
|
+
*/
|
|
257
|
+
private checkUtf8Support;
|
|
258
|
+
/**
|
|
259
|
+
* Detect Unicode support
|
|
260
|
+
* UTF-8 terminals usually support Unicode
|
|
261
|
+
* @returns Whether Unicode is supported
|
|
262
|
+
*/
|
|
263
|
+
private checkUnicodeSupport;
|
|
264
|
+
/**
|
|
265
|
+
* Detect Braille character support
|
|
266
|
+
* Determine based on terminal program whitelist
|
|
267
|
+
* @returns Whether Braille characters are supported
|
|
268
|
+
*/
|
|
269
|
+
private checkBrailleSupport;
|
|
270
|
+
/**
|
|
271
|
+
* Detect Block Elements character support
|
|
272
|
+
* Most terminals supporting Unicode also support Block Elements
|
|
273
|
+
* @returns Whether Block Elements are supported
|
|
274
|
+
*/
|
|
275
|
+
private checkBlockElementsSupport;
|
|
276
|
+
/**
|
|
277
|
+
* Detect color support (16 colors or more)
|
|
278
|
+
* @returns Whether colors are supported
|
|
279
|
+
*/
|
|
280
|
+
private checkColorSupport;
|
|
281
|
+
/**
|
|
282
|
+
* Detect true color support (24-bit RGB)
|
|
283
|
+
* @returns Whether true color is supported
|
|
284
|
+
*/
|
|
285
|
+
private checkTrueColorSupport;
|
|
286
|
+
/**
|
|
287
|
+
* Calculate comprehensive terminal capability score (0-100)
|
|
288
|
+
* @returns Score
|
|
289
|
+
*/
|
|
290
|
+
private calculateScore;
|
|
291
|
+
/**
|
|
292
|
+
* Detect terminal capabilities
|
|
293
|
+
* @returns Terminal capability information
|
|
294
|
+
*/
|
|
295
|
+
detect(): TerminalCapabilities;
|
|
296
|
+
/**
|
|
297
|
+
* Get environment information
|
|
298
|
+
* @returns Environment information
|
|
299
|
+
*/
|
|
300
|
+
getEnvironmentInfo(): EnvironmentInfo;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Global terminal detector instance
|
|
304
|
+
*/
|
|
305
|
+
declare const terminalDetector: TerminalDetector;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Renderer Selector
|
|
309
|
+
*
|
|
310
|
+
* Automatically selects the optimal renderer based on terminal capabilities to achieve intelligent fallback
|
|
311
|
+
*/
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Renderer Selector
|
|
315
|
+
*
|
|
316
|
+
* Automatically detects terminal capabilities and selects the optimal renderer
|
|
317
|
+
* Supports custom fallback chains and renderer caching
|
|
318
|
+
*/
|
|
319
|
+
declare class RendererSelector {
|
|
320
|
+
/** Terminal detector */
|
|
321
|
+
private detector;
|
|
322
|
+
constructor(detector?: TerminalDetector);
|
|
323
|
+
/**
|
|
324
|
+
* Creates a renderer instance of the specified type
|
|
325
|
+
* @param type - Renderer type
|
|
326
|
+
* @returns Renderer instance
|
|
327
|
+
*/
|
|
328
|
+
private createRenderer;
|
|
329
|
+
/**
|
|
330
|
+
* Get renderer by type
|
|
331
|
+
* @param type - Renderer type
|
|
332
|
+
* @returns Renderer instance
|
|
333
|
+
*/
|
|
334
|
+
getRenderer(type: RendererType): Renderer;
|
|
335
|
+
/**
|
|
336
|
+
* Check if the renderer meets terminal capability requirements
|
|
337
|
+
* @param renderer - Renderer instance
|
|
338
|
+
* @param capabilities - Terminal capabilities
|
|
339
|
+
* @returns Whether requirements are met
|
|
340
|
+
*/
|
|
341
|
+
private isRendererSupported;
|
|
342
|
+
/**
|
|
343
|
+
* Automatically select the best renderer
|
|
344
|
+
*
|
|
345
|
+
* Try in the order of the priority chain, returning the first renderer that meets terminal capability requirements
|
|
346
|
+
* If none are satisfied, fallback to ASCII
|
|
347
|
+
*
|
|
348
|
+
* @param preferredChain - Priority chain (default: ['braille', 'block', 'ascii'])
|
|
349
|
+
* @returns Selected renderer instance
|
|
350
|
+
*/
|
|
351
|
+
selectBest(preferredChain?: RendererType[]): Renderer;
|
|
352
|
+
/**
|
|
353
|
+
* Get terminal capability information
|
|
354
|
+
* @returns Terminal capabilities
|
|
355
|
+
*/
|
|
356
|
+
getTerminalCapabilities(): TerminalCapabilities;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Global RendererSelector instance
|
|
360
|
+
*/
|
|
361
|
+
declare const rendererSelector: RendererSelector;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* ink-hud Context Provider
|
|
365
|
+
*
|
|
366
|
+
* Provide dependency injection, replacing the global singleton
|
|
367
|
+
*/
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* InkHud Context value
|
|
371
|
+
*/
|
|
372
|
+
interface InkHudContextValue {
|
|
373
|
+
/** Renderer selector */
|
|
374
|
+
selector: RendererSelector;
|
|
375
|
+
/** Get terminal capabilities */
|
|
376
|
+
getCapabilities: () => TerminalCapabilities;
|
|
377
|
+
/** Get renderer of specified type */
|
|
378
|
+
getRenderer: (type: RendererType) => Renderer;
|
|
379
|
+
/** Select best renderer */
|
|
380
|
+
selectBest: (chain?: RendererType[]) => Renderer;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* InkHud Provider Props
|
|
384
|
+
*/
|
|
385
|
+
interface InkHudProviderProps {
|
|
386
|
+
/**
|
|
387
|
+
* Custom terminal detector
|
|
388
|
+
* For testing or simulating different terminal environments
|
|
389
|
+
*/
|
|
390
|
+
detector?: TerminalDetector;
|
|
391
|
+
/**
|
|
392
|
+
* Force use of specified renderer
|
|
393
|
+
* Override automatic detection for testing or specific scenarios
|
|
394
|
+
*/
|
|
395
|
+
forceRenderer?: RendererType;
|
|
396
|
+
children: React.ReactNode;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* InkHud Context Provider
|
|
400
|
+
*
|
|
401
|
+
* Encapsulate renderer selection logic, supports dependency injection
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
* ```tsx
|
|
405
|
+
* // Standard usage (automatic detection)
|
|
406
|
+
* <InkHudProvider>
|
|
407
|
+
* <MyApp />
|
|
408
|
+
* </InkHudProvider>
|
|
409
|
+
*
|
|
410
|
+
* // Inject mock for testing
|
|
411
|
+
* <InkHudProvider detector={mockDetector}>
|
|
412
|
+
* <MyApp />
|
|
413
|
+
* </InkHudProvider>
|
|
414
|
+
*
|
|
415
|
+
* // Force ASCII renderer
|
|
416
|
+
* <InkHudProvider forceRenderer="ascii">
|
|
417
|
+
* <MyApp />
|
|
418
|
+
* </InkHudProvider>
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
declare const InkHudProvider: React.FC<InkHudProviderProps>;
|
|
422
|
+
/**
|
|
423
|
+
* Get InkHud Context
|
|
424
|
+
*
|
|
425
|
+
* Even without a Provider, returns the default Context (using the global detector)
|
|
426
|
+
*/
|
|
427
|
+
declare function useInkHud(): InkHudContextValue;
|
|
428
|
+
/**
|
|
429
|
+
* Get renderer selector
|
|
430
|
+
*
|
|
431
|
+
* Simplified Hook to directly get the selector
|
|
432
|
+
*/
|
|
433
|
+
declare function useRendererSelector(): RendererSelector;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* ThemeContext - Theme Context
|
|
437
|
+
*
|
|
438
|
+
* Provides unified color configuration, replacing hardcoded colors
|
|
439
|
+
*/
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Semantic color configuration
|
|
443
|
+
*/
|
|
444
|
+
interface SemanticColors {
|
|
445
|
+
/** Success/Up */
|
|
446
|
+
success: string;
|
|
447
|
+
/** Error/Down */
|
|
448
|
+
error: string;
|
|
449
|
+
/** Warning */
|
|
450
|
+
warning: string;
|
|
451
|
+
/** Info */
|
|
452
|
+
info: string;
|
|
453
|
+
/** Secondary/Disabled */
|
|
454
|
+
muted: string;
|
|
455
|
+
/** Primary text */
|
|
456
|
+
text: string;
|
|
457
|
+
/** Secondary text */
|
|
458
|
+
textSecondary: string;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Theme configuration
|
|
462
|
+
*/
|
|
463
|
+
interface Theme {
|
|
464
|
+
/** Theme name */
|
|
465
|
+
name: string;
|
|
466
|
+
/** Series colors (for charts) */
|
|
467
|
+
palette: string[];
|
|
468
|
+
/** Semantic colors */
|
|
469
|
+
semantic: SemanticColors;
|
|
470
|
+
/** Heatmap gradient */
|
|
471
|
+
heatmapGradient: string[];
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* One Dark Theme (default)
|
|
475
|
+
*/
|
|
476
|
+
declare const ONE_DARK_THEME: Theme;
|
|
477
|
+
/**
|
|
478
|
+
* Theme Provider Props
|
|
479
|
+
*/
|
|
480
|
+
interface ThemeProviderProps {
|
|
481
|
+
/** Custom theme (optional) */
|
|
482
|
+
theme?: Partial<Theme>;
|
|
483
|
+
children: React.ReactNode;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Theme Provider
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* ```tsx
|
|
490
|
+
* <ThemeProvider>
|
|
491
|
+
* <App />
|
|
492
|
+
* </ThemeProvider>
|
|
493
|
+
*
|
|
494
|
+
* // Custom theme
|
|
495
|
+
* <ThemeProvider theme={{ semantic: { success: '#00ff00' } }}>
|
|
496
|
+
* <App />
|
|
497
|
+
* </ThemeProvider>
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
500
|
+
declare const ThemeProvider: React.FC<ThemeProviderProps>;
|
|
501
|
+
/**
|
|
502
|
+
* Get current theme
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* ```tsx
|
|
506
|
+
* const theme = useTheme();
|
|
507
|
+
* <Text color={theme.semantic.success}>Success</Text>
|
|
508
|
+
* ```
|
|
509
|
+
*/
|
|
510
|
+
declare function useTheme(): Theme;
|
|
511
|
+
/**
|
|
512
|
+
* Get semantic colors
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* ```tsx
|
|
516
|
+
* const colors = useSemanticColors();
|
|
517
|
+
* <Text color={colors.error}>Error</Text>
|
|
518
|
+
* ```
|
|
519
|
+
*/
|
|
520
|
+
declare function useSemanticColors(): SemanticColors;
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Data scaling utility module
|
|
524
|
+
*
|
|
525
|
+
* Provides data normalization and linear scaling functions for mapping data to chart coordinate space
|
|
526
|
+
*/
|
|
527
|
+
/**
|
|
528
|
+
* Linear scale function
|
|
529
|
+
* Map value from input domain to output domain
|
|
530
|
+
*
|
|
531
|
+
* @param value - Value to scale
|
|
532
|
+
* @param domain - Input domain [min, max]
|
|
533
|
+
* @param range - Output range [min, max]
|
|
534
|
+
* @returns Scaled value
|
|
535
|
+
*
|
|
536
|
+
* @example
|
|
537
|
+
* linearScale(50, [0, 100], [0, 10]); // Returns 5
|
|
538
|
+
* linearScale(75, [0, 100], [0, 20]); // Returns 15
|
|
539
|
+
*/
|
|
540
|
+
declare function linearScale(value: number, domain: [number, number], range: [number, number]): number;
|
|
541
|
+
/**
|
|
542
|
+
* Data normalization
|
|
543
|
+
* Map array data to [0, 1] interval
|
|
544
|
+
*
|
|
545
|
+
* @param data - Original data array
|
|
546
|
+
* @returns Normalized data array
|
|
547
|
+
*
|
|
548
|
+
* @example
|
|
549
|
+
* normalize([0, 50, 100]); // Returns [0, 0.5, 1]
|
|
550
|
+
* normalize([10, 20, 30]); // Returns [0, 0.5, 1]
|
|
551
|
+
*/
|
|
552
|
+
declare function normalize(data: number[]): number[];
|
|
553
|
+
/**
|
|
554
|
+
* Scale data to specified range
|
|
555
|
+
* Map array data to specified output range
|
|
556
|
+
*
|
|
557
|
+
* @param data - Original data array
|
|
558
|
+
* @param range - Output range [min, max]
|
|
559
|
+
* @returns Scaled data array
|
|
560
|
+
*
|
|
561
|
+
* @example
|
|
562
|
+
* scaleToRange([0, 50, 100], [0, 10]); // Returns [0, 5, 10]
|
|
563
|
+
* scaleToRange([-10, 0, 10], [0, 100]); // Returns [0, 50, 100]
|
|
564
|
+
*/
|
|
565
|
+
declare function scaleToRange(data: number[], range: [number, number]): number[];
|
|
566
|
+
/**
|
|
567
|
+
* Clamp value within specified range (clamp)
|
|
568
|
+
*
|
|
569
|
+
* @param value - Value to clamp
|
|
570
|
+
* @param min - Minimum value
|
|
571
|
+
* @param max - Maximum value
|
|
572
|
+
* @returns Clamped value
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* clamp(5, 0, 10); // Returns 5
|
|
576
|
+
* clamp(-5, 0, 10); // Returns 0
|
|
577
|
+
* clamp(15, 0, 10); // Returns 10
|
|
578
|
+
*/
|
|
579
|
+
declare function clamp(value: number, min: number, max: number): number;
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Gradient tool module
|
|
583
|
+
*
|
|
584
|
+
* Use tinygradient and chalk to implement terminal color gradients
|
|
585
|
+
*/
|
|
586
|
+
/**
|
|
587
|
+
* Generate gradient color array
|
|
588
|
+
*
|
|
589
|
+
* @param colors - Start and end color array (supports hex, rgb, css color names)
|
|
590
|
+
* @param steps - Interpolation steps
|
|
591
|
+
* @returns Chalk color function array
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* const gradient = createGradient(['#00f', '#0ff', '#0f0'], 10);
|
|
595
|
+
* gradient[0]('text'); // Blue
|
|
596
|
+
* gradient[9]('text'); // Green
|
|
597
|
+
*/
|
|
598
|
+
declare function createGradient(colors: string[], steps: number): Array<(text: string) => string>;
|
|
599
|
+
/**
|
|
600
|
+
* Palette type
|
|
601
|
+
* Supports built-in palette names or custom color arrays
|
|
602
|
+
*/
|
|
603
|
+
type ColorPalette = 'one-dark' | 'one-dark-vivid' | string[];
|
|
604
|
+
/**
|
|
605
|
+
* Assign different colors for data series
|
|
606
|
+
*
|
|
607
|
+
* @param seriesCount - Number of series
|
|
608
|
+
* @param palette - Palette configuration (default: 'one-dark')
|
|
609
|
+
* @returns Color array (hex format)
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* const colors = assignColors(5);
|
|
613
|
+
* // Use Vivid variant
|
|
614
|
+
* const vividColors = assignColors(5, 'one-dark-vivid');
|
|
615
|
+
*/
|
|
616
|
+
declare function assignColors(seriesCount: number, palette?: ColorPalette): string[];
|
|
617
|
+
/**
|
|
618
|
+
* Convert color string to chalk color function
|
|
619
|
+
*
|
|
620
|
+
* @param color - Color string (hex, css color names)
|
|
621
|
+
* @returns Chalk color function
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* const colorFn = colorToChalk('#ff0000');
|
|
625
|
+
* console.log(colorFn('Red text'));
|
|
626
|
+
*/
|
|
627
|
+
declare function colorToChalk(color: string): (text: string) => string;
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Geometry calculation utility module
|
|
631
|
+
*
|
|
632
|
+
* Provides helper functions for calculating geometric shapes like circles and arcs
|
|
633
|
+
*/
|
|
634
|
+
/**
|
|
635
|
+
* Midpoint Circle Algorithm
|
|
636
|
+
* Calculate all points on the circle (8 symmetry points)
|
|
637
|
+
*
|
|
638
|
+
* @param centerX - Center x coordinate
|
|
639
|
+
* @param centerY - Center y coordinate
|
|
640
|
+
* @param radius - Radius
|
|
641
|
+
* @returns Array of coordinates for all points on circle
|
|
642
|
+
*
|
|
643
|
+
* @example
|
|
644
|
+
* const points = midpointCircle(50, 50, 20);
|
|
645
|
+
* points.forEach(([x, y]) => {
|
|
646
|
+
* console.log(`Point coordinates: (${x}, ${y})`);
|
|
647
|
+
* });
|
|
648
|
+
*/
|
|
649
|
+
declare function midpointCircle(centerX: number, centerY: number, radius: number): Array<[number, number]>;
|
|
650
|
+
/**
|
|
651
|
+
* Calculate point coordinates at specified angle on arc
|
|
652
|
+
* Using parametric equations: x = centerX + r * cos(θ), y = centerY + r * sin(θ)
|
|
653
|
+
*
|
|
654
|
+
* @param centerX - Center x coordinate
|
|
655
|
+
* @param centerY - Center y coordinate
|
|
656
|
+
* @param radius - Radius
|
|
657
|
+
* @param angle - Angle (radians)
|
|
658
|
+
* @returns Point coordinates [x, y]
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* // Calculate the point at 45° (π/4 radians)
|
|
662
|
+
* const [x, y] = pointOnArc(50, 50, 20, Math.PI / 4);
|
|
663
|
+
*/
|
|
664
|
+
declare function pointOnArc(centerX: number, centerY: number, radius: number, angle: number): [number, number];
|
|
665
|
+
/**
|
|
666
|
+
* Calculate multiple points on the arc
|
|
667
|
+
*
|
|
668
|
+
* @param centerX - Center x coordinate
|
|
669
|
+
* @param centerY - Center y coordinate
|
|
670
|
+
* @param radius - Radius
|
|
671
|
+
* @param startAngle - Start angle (radians)
|
|
672
|
+
* @param endAngle - End angle (radians)
|
|
673
|
+
* @param steps - Steps (default calculated based on radius)
|
|
674
|
+
* @returns Array of coordinates for all points on arc
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* // Calculate arc points from 0° to 90°
|
|
678
|
+
* const points = arcPoints(50, 50, 20, 0, Math.PI / 2, 20);
|
|
679
|
+
*/
|
|
680
|
+
declare function arcPoints(centerX: number, centerY: number, radius: number, startAngle: number, endAngle: number, steps?: number): Array<[number, number]>;
|
|
681
|
+
/**
|
|
682
|
+
* Convert angle from degrees to radians
|
|
683
|
+
*
|
|
684
|
+
* @param degrees - Angle (degrees)
|
|
685
|
+
* @returns Angle (radians)
|
|
686
|
+
*
|
|
687
|
+
* @example
|
|
688
|
+
* const radians = degreesToRadians(90); // π/2
|
|
689
|
+
*/
|
|
690
|
+
declare function degreesToRadians(degrees: number): number;
|
|
691
|
+
/**
|
|
692
|
+
* Convert angle from radians to degrees
|
|
693
|
+
*
|
|
694
|
+
* @param radians - Angle (radians)
|
|
695
|
+
* @returns Angle (degrees)
|
|
696
|
+
*
|
|
697
|
+
* @example
|
|
698
|
+
* const degrees = radiansToDegrees(Math.PI / 2); // 90
|
|
699
|
+
*/
|
|
700
|
+
declare function radiansToDegrees(radians: number): number;
|
|
701
|
+
/**
|
|
702
|
+
* Calculate distance between two points
|
|
703
|
+
*
|
|
704
|
+
* @param x1 - First point x coordinate
|
|
705
|
+
* @param y1 - First point y coordinate
|
|
706
|
+
* @param x2 - Second point x coordinate
|
|
707
|
+
* @param y2 - Second point y coordinate
|
|
708
|
+
* @returns Distance
|
|
709
|
+
*
|
|
710
|
+
* @example
|
|
711
|
+
* const distance = distanceBetweenPoints(0, 0, 3, 4); // 5
|
|
712
|
+
*/
|
|
713
|
+
declare function distanceBetweenPoints(x1: number, y1: number, x2: number, y2: number): number;
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Data downsampling module
|
|
717
|
+
*
|
|
718
|
+
* Provides downsampling algorithms for large datasets to display many data points in limited-width charts
|
|
719
|
+
*/
|
|
720
|
+
/**
|
|
721
|
+
* LTTB (Largest Triangle Three Buckets) algorithm
|
|
722
|
+
* An efficient data downsampling algorithm that preserves visually important data points
|
|
723
|
+
*
|
|
724
|
+
* Algorithm principles:
|
|
725
|
+
* 1. Always preserve first and last points
|
|
726
|
+
* 2. Divide intermediate data into multiple buckets
|
|
727
|
+
* 3. Select the point with largest triangle area in each bucket (forming largest triangle with adjacent points)
|
|
728
|
+
*
|
|
729
|
+
* @param data - Original data array
|
|
730
|
+
* @param threshold - Target number of data points
|
|
731
|
+
* @returns Downsampled data array
|
|
732
|
+
*
|
|
733
|
+
* @example
|
|
734
|
+
* const data = Array.from({ length: 1000 }, (_, i) => Math.sin(i / 10));
|
|
735
|
+
* const sampled = lttb(data, 100); // Downsample from 1000 points to 100 points
|
|
736
|
+
*/
|
|
737
|
+
declare function lttb(data: number[], threshold: number): number[];
|
|
738
|
+
/**
|
|
739
|
+
* Simple fixed-interval downsampling
|
|
740
|
+
* Select one data point at fixed intervals
|
|
741
|
+
*
|
|
742
|
+
* @param data - Original data array
|
|
743
|
+
* @param threshold - Target number of data points
|
|
744
|
+
* @returns Downsampled data array
|
|
745
|
+
*
|
|
746
|
+
* @example
|
|
747
|
+
* const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
748
|
+
* const sampled = fixedIntervalDownsampling(data, 5); // [1, 3, 5, 7, 10]
|
|
749
|
+
*/
|
|
750
|
+
declare function fixedIntervalDownsampling(data: number[], threshold: number): number[];
|
|
751
|
+
/**
|
|
752
|
+
* Average Downsampling
|
|
753
|
+
* Divide data into multiple buckets, taking the average value for each bucket
|
|
754
|
+
*
|
|
755
|
+
* @param data - Original data array
|
|
756
|
+
* @param threshold - Target number of data points
|
|
757
|
+
* @returns Downsampled data array
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* const data = [1, 2, 3, 4, 5, 6, 7, 8];
|
|
761
|
+
* const sampled = averageDownsampling(data, 4); // [1.5, 3.5, 5.5, 7.5]
|
|
762
|
+
*/
|
|
763
|
+
declare function averageDownsampling(data: number[], threshold: number): number[];
|
|
764
|
+
/**
|
|
765
|
+
* Min-Max Downsampling
|
|
766
|
+
* Divide data into multiple buckets, preserving the Maximum and Minimum values for each bucket
|
|
767
|
+
* Suitable for preserving peaks and valleys in data
|
|
768
|
+
*
|
|
769
|
+
* @param data - Original data array
|
|
770
|
+
* @param threshold - Target number of data points (actual returned points will be 2x threshold)
|
|
771
|
+
* @returns Downsampled data array
|
|
772
|
+
*
|
|
773
|
+
* @example
|
|
774
|
+
* const data = [1, 5, 2, 8, 3, 6, 4, 7];
|
|
775
|
+
* const sampled = minMaxDownsampling(data, 4); // [1, 5, 2, 8, 3, 6, 4, 7]
|
|
776
|
+
*/
|
|
777
|
+
declare function minMaxDownsampling(data: number[], threshold: number): number[];
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Data smooth transition Hook module
|
|
781
|
+
*
|
|
782
|
+
* Provides smooth animation effects for data changes
|
|
783
|
+
*/
|
|
784
|
+
/**
|
|
785
|
+
* Easing function type
|
|
786
|
+
*/
|
|
787
|
+
type EasingFunction = (t: number) => number;
|
|
788
|
+
/**
|
|
789
|
+
* Quadratic easing function (accelerate then decelerate)
|
|
790
|
+
* @param t - Progress (0-1)
|
|
791
|
+
* @returns Eased progress (0-1)
|
|
792
|
+
*/
|
|
793
|
+
declare function easeInOutQuad(t: number): number;
|
|
794
|
+
/**
|
|
795
|
+
* Linear easing function (constant speed)
|
|
796
|
+
* @param t - Progress (0-1)
|
|
797
|
+
* @returns Eased progress (0-1)
|
|
798
|
+
*/
|
|
799
|
+
declare function easeLinear(t: number): number;
|
|
800
|
+
/**
|
|
801
|
+
* Cubic ease-out function (decelerate)
|
|
802
|
+
* @param t - Progress (0-1)
|
|
803
|
+
* @returns Eased progress (0-1)
|
|
804
|
+
*/
|
|
805
|
+
declare function easeOutCubic(t: number): number;
|
|
806
|
+
/**
|
|
807
|
+
* Cubic ease-in function (accelerate)
|
|
808
|
+
* @param t - Progress (0-1)
|
|
809
|
+
* @returns Eased progress (0-1)
|
|
810
|
+
*/
|
|
811
|
+
declare function easeInCubic(t: number): number;
|
|
812
|
+
/**
|
|
813
|
+
* Data smooth transition Hook
|
|
814
|
+
* Smooth transition to new value when target changes
|
|
815
|
+
*
|
|
816
|
+
* @param targetValue - Target value
|
|
817
|
+
* @param duration - Transition duration (ms, default 300)
|
|
818
|
+
* @param easingFn - Easing function (default easeInOutQuad)
|
|
819
|
+
* @returns Current smooth value
|
|
820
|
+
*
|
|
821
|
+
* @example
|
|
822
|
+
* const smoothValue = useSmooth(cpuUsage, 500);
|
|
823
|
+
* return <LineChart series={[{ name: 'Value', data: [smoothValue] }]} />;
|
|
824
|
+
*/
|
|
825
|
+
declare function useSmooth(targetValue: number, duration?: number, easingFn?: EasingFunction): number;
|
|
826
|
+
/**
|
|
827
|
+
* Array data smooth transition Hook
|
|
828
|
+
* Smooth transition to new data when target changes
|
|
829
|
+
*
|
|
830
|
+
* @param targetData - Target data array
|
|
831
|
+
* @param duration - Transition duration (ms, default 300)
|
|
832
|
+
* @param easingFn - Easing function (default easeInOutQuad)
|
|
833
|
+
* @returns Current smooth data array
|
|
834
|
+
*
|
|
835
|
+
* @example
|
|
836
|
+
* const smoothData = useSmoothArray(memoryData, 500);
|
|
837
|
+
* return <LineChart data={[{ name: 'Memory', data: smoothData }]} />;
|
|
838
|
+
*/
|
|
839
|
+
declare function useSmoothArray(targetData: number[], duration?: number, easingFn?: EasingFunction): number[];
|
|
840
|
+
/**
|
|
841
|
+
* Throttling Hook
|
|
842
|
+
* Limit animation frame rate to avoid terminal flicker
|
|
843
|
+
*
|
|
844
|
+
* @param value - Current value
|
|
845
|
+
* @param fps - Target frame rate (default 30)
|
|
846
|
+
* @returns Throttled value
|
|
847
|
+
*
|
|
848
|
+
* @example
|
|
849
|
+
* const throttledValue = useThrottle(cpuUsage, 30);
|
|
850
|
+
*/
|
|
851
|
+
declare function useThrottle<T>(value: T, fps?: number): T;
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Common type definitions for Chart components
|
|
855
|
+
*
|
|
856
|
+
* Unified base property interface for all chart components
|
|
857
|
+
*/
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* Basic chart dimensions and renderer configuration
|
|
861
|
+
*/
|
|
862
|
+
interface BaseChartProps {
|
|
863
|
+
/** Chart width (character count) */
|
|
864
|
+
width?: number;
|
|
865
|
+
/** Chart height (character rows) */
|
|
866
|
+
height?: number;
|
|
867
|
+
/** Manually specify Renderer type */
|
|
868
|
+
renderer?: RendererType;
|
|
869
|
+
/** Custom renderer fallback chain */
|
|
870
|
+
rendererChain?: RendererType[];
|
|
871
|
+
/**
|
|
872
|
+
* Width offset
|
|
873
|
+
* @deprecated Recommend wrapping chart with `<Panel>`, Panel automatically handles border overhead
|
|
874
|
+
*/
|
|
875
|
+
widthOffset?: number;
|
|
876
|
+
/**
|
|
877
|
+
* Height offset
|
|
878
|
+
* @deprecated Recommend wrapping chart with `<Panel>`, Panel automatically handles border overhead
|
|
879
|
+
*/
|
|
880
|
+
heightOffset?: number;
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Legend configuration
|
|
884
|
+
*/
|
|
885
|
+
interface LegendProps$1 {
|
|
886
|
+
/** Whether to show legend (default true) */
|
|
887
|
+
showLegend?: boolean;
|
|
888
|
+
/** Legend position (default 'right') */
|
|
889
|
+
legendPosition?: 'right' | 'bottom' | 'top';
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Color configuration
|
|
893
|
+
*/
|
|
894
|
+
interface ColorProps {
|
|
895
|
+
/** Color array (auto-assigned if not specified) */
|
|
896
|
+
colors?: string[];
|
|
897
|
+
/** Palette name or custom color array */
|
|
898
|
+
colorPalette?: ColorPalette;
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Axis configuration (shared by LineChart/AreaChart/BarChart)
|
|
902
|
+
*/
|
|
903
|
+
interface AxisProps$1 {
|
|
904
|
+
/** Whether to show axis (default true) */
|
|
905
|
+
showAxis?: boolean;
|
|
906
|
+
/** Whether to show X-axis (defaults to showAxis) */
|
|
907
|
+
showXAxis?: boolean;
|
|
908
|
+
/** Whether to show Y-axis (defaults to showAxis) */
|
|
909
|
+
showYAxis?: boolean;
|
|
910
|
+
/** X-axis label */
|
|
911
|
+
xAxisLabel?: string;
|
|
912
|
+
/** Y-axis label */
|
|
913
|
+
yAxisLabel?: string;
|
|
914
|
+
/** X-axis tick count (default 5) */
|
|
915
|
+
xTickCount?: number;
|
|
916
|
+
/** Y-axis tick count (default 5) */
|
|
917
|
+
yTickCount?: number;
|
|
918
|
+
/** X-axis tick formatter function */
|
|
919
|
+
xTickFormat?: (value: number) => string;
|
|
920
|
+
/** Y-axis tick formatter function */
|
|
921
|
+
yTickFormat?: (value: number) => string;
|
|
922
|
+
/** Whether to force X-axis ticks to be integers (default true) */
|
|
923
|
+
xIntegerScale?: boolean;
|
|
924
|
+
/** Whether to force Y-axis ticks to be integers (default false) */
|
|
925
|
+
yIntegerScale?: boolean;
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Time series data configuration (shared by LineChart/AreaChart/BarChart)
|
|
929
|
+
*/
|
|
930
|
+
interface SeriesDataProps {
|
|
931
|
+
/** Multi-series data */
|
|
932
|
+
series?: Array<{
|
|
933
|
+
name: string;
|
|
934
|
+
data: number[];
|
|
935
|
+
color?: string;
|
|
936
|
+
}>;
|
|
937
|
+
/** Single-series data (simplified) */
|
|
938
|
+
data?: number[];
|
|
939
|
+
/** Single-series name (simplified) */
|
|
940
|
+
seriesName?: string;
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* Complete time series chart properties (shared by LineChart/AreaChart)
|
|
944
|
+
*/
|
|
945
|
+
type TimeSeriesChartProps = BaseChartProps & LegendProps$1 & ColorProps & AxisProps$1 & SeriesDataProps;
|
|
946
|
+
|
|
947
|
+
/**
|
|
948
|
+
* LineChart - Basic line chart component
|
|
949
|
+
*/
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* LineChart component props
|
|
953
|
+
*/
|
|
954
|
+
type LineChartProps = TimeSeriesChartProps;
|
|
955
|
+
declare const LineChart: React.FC<LineChartProps>;
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* AreaChart - Basic area chart component
|
|
959
|
+
*/
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* AreaChart component props
|
|
963
|
+
*/
|
|
964
|
+
type AreaChartProps = TimeSeriesChartProps;
|
|
965
|
+
declare const AreaChart: React.FC<AreaChartProps>;
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* BarChart Basic bar chart component
|
|
969
|
+
*/
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* BarChart component props
|
|
973
|
+
*/
|
|
974
|
+
type BarChartProps = TimeSeriesChartProps & {
|
|
975
|
+
/** Orientation (default 'vertical') */
|
|
976
|
+
orientation?: 'vertical' | 'horizontal';
|
|
977
|
+
};
|
|
978
|
+
declare const BarChart: React.FC<BarChartProps>;
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* PieChart Pie chart component
|
|
982
|
+
*
|
|
983
|
+
* Basic pie chart display with built-in legend
|
|
984
|
+
*/
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* PieChart data item
|
|
988
|
+
*/
|
|
989
|
+
interface PieChartDataItem {
|
|
990
|
+
/** Name */
|
|
991
|
+
name: string;
|
|
992
|
+
/** Value */
|
|
993
|
+
value: number;
|
|
994
|
+
/** Color (optional, auto-assigned if not specified) */
|
|
995
|
+
color?: string;
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* PieChart component props
|
|
999
|
+
*/
|
|
1000
|
+
interface PieChartProps {
|
|
1001
|
+
/**
|
|
1002
|
+
* Data array - supports two formats:
|
|
1003
|
+
* 1. Simplified mode: number[] (requires labels)
|
|
1004
|
+
* 2. Detailed mode: PieChartDataItem[]
|
|
1005
|
+
*/
|
|
1006
|
+
data?: number[] | PieChartDataItem[];
|
|
1007
|
+
/**
|
|
1008
|
+
* Label array (used in simplified mode)
|
|
1009
|
+
* When used with data: number[], provides name for each value
|
|
1010
|
+
*/
|
|
1011
|
+
labels?: string[];
|
|
1012
|
+
/** Chart width (character count, default 30) */
|
|
1013
|
+
width?: number;
|
|
1014
|
+
/** Chart height (character lines, default 15) */
|
|
1015
|
+
height?: number;
|
|
1016
|
+
/** Outer radius (pixels, auto-calculated by default) */
|
|
1017
|
+
radius?: number;
|
|
1018
|
+
/** Aspect ratio correction (default 2) */
|
|
1019
|
+
aspectRatio?: number;
|
|
1020
|
+
/** Donut inner radius ratio (0-1, default 0) */
|
|
1021
|
+
donutRatio?: number;
|
|
1022
|
+
/** Whether to show percentage labels (default false) */
|
|
1023
|
+
showLabels?: boolean;
|
|
1024
|
+
/** Whether to show legend (default true) */
|
|
1025
|
+
showLegend?: boolean;
|
|
1026
|
+
/** Legend position (default 'right') */
|
|
1027
|
+
legendPosition?: 'right' | 'bottom';
|
|
1028
|
+
/** Color array (auto-assigned if not specified) */
|
|
1029
|
+
colors?: string[];
|
|
1030
|
+
/** Palette name or custom color array */
|
|
1031
|
+
colorPalette?: ColorPalette;
|
|
1032
|
+
/** Manually specify renderer type (optional) */
|
|
1033
|
+
renderer?: RendererType;
|
|
1034
|
+
/** Custom renderer fallback chain (default: ['braille', 'block', 'ascii']) */
|
|
1035
|
+
rendererChain?: RendererType[];
|
|
1036
|
+
/**
|
|
1037
|
+
* Height offset
|
|
1038
|
+
* @deprecated Recommend wrapping chart with `<Panel>`, Panel automatically handles border overhead
|
|
1039
|
+
*/
|
|
1040
|
+
heightOffset?: number;
|
|
1041
|
+
/**
|
|
1042
|
+
* Width offset
|
|
1043
|
+
* @deprecated Recommend wrapping chart with `<Panel>`, Panel automatically handles border overhead
|
|
1044
|
+
*/
|
|
1045
|
+
widthOffset?: number;
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* PieChart Pie chart component
|
|
1049
|
+
*/
|
|
1050
|
+
declare const PieChart: React.FC<PieChartProps>;
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Sparkline - Mini trend chart component
|
|
1054
|
+
*/
|
|
1055
|
+
|
|
1056
|
+
interface SparklineProps {
|
|
1057
|
+
/** Array of data points */
|
|
1058
|
+
data: number[];
|
|
1059
|
+
/**
|
|
1060
|
+
* Target width (character count)
|
|
1061
|
+
* If number of data points exceeds width, will automatically use LTTB algorithm for downsampling
|
|
1062
|
+
* If not provided, width will equal the number of data points
|
|
1063
|
+
*/
|
|
1064
|
+
width?: number;
|
|
1065
|
+
/** Minimum value (default: calculation from data) */
|
|
1066
|
+
min?: number;
|
|
1067
|
+
/** Maximum value (default: calculation from data) */
|
|
1068
|
+
max?: number;
|
|
1069
|
+
/** Color */
|
|
1070
|
+
color?: string;
|
|
1071
|
+
/** Rendering style (default: 'block') */
|
|
1072
|
+
variant?: 'block' | 'braille' | 'ascii';
|
|
1073
|
+
}
|
|
1074
|
+
declare const Sparkline: React.FC<SparklineProps>;
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Coordinate axis component
|
|
1078
|
+
*
|
|
1079
|
+
* Used for X-axis and Y-axis display in charts
|
|
1080
|
+
*/
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* Coordinate axis component props
|
|
1084
|
+
*/
|
|
1085
|
+
interface AxisProps {
|
|
1086
|
+
/** Axis type */
|
|
1087
|
+
type: 'x' | 'y';
|
|
1088
|
+
/** Minimum data value */
|
|
1089
|
+
min: number;
|
|
1090
|
+
/** Maximum data value */
|
|
1091
|
+
max: number;
|
|
1092
|
+
/** Tick count (default 5) */
|
|
1093
|
+
tickCount?: number;
|
|
1094
|
+
/** Tick formatter function */
|
|
1095
|
+
tickFormat?: (value: number) => string;
|
|
1096
|
+
/** Axis label */
|
|
1097
|
+
label?: string;
|
|
1098
|
+
/** Axis length (character count) */
|
|
1099
|
+
length: number;
|
|
1100
|
+
/** Text color (default 'gray') */
|
|
1101
|
+
color?: string;
|
|
1102
|
+
/** Whether to show grid lines (default false) */
|
|
1103
|
+
showGrid?: boolean;
|
|
1104
|
+
/** Whether to force ticks to be integers (default false) */
|
|
1105
|
+
integerScale?: boolean;
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Coordinate axis component
|
|
1109
|
+
*
|
|
1110
|
+
* @example
|
|
1111
|
+
* // X-axis
|
|
1112
|
+
* <Axis type="x" min={0} max={100} length={50} label="Time" />
|
|
1113
|
+
*
|
|
1114
|
+
* // Y-axis
|
|
1115
|
+
* <Axis type="y" min={0} max={100} length={10} label="Value" />
|
|
1116
|
+
*/
|
|
1117
|
+
declare const Axis: React.FC<AxisProps>;
|
|
1118
|
+
|
|
1119
|
+
interface GridProps {
|
|
1120
|
+
/** Number of columns in the grid (default: 12) */
|
|
1121
|
+
columns?: number;
|
|
1122
|
+
/** Gap between items (horizontal and vertical) */
|
|
1123
|
+
gap?: number;
|
|
1124
|
+
/**
|
|
1125
|
+
* Total width of the grid in characters.
|
|
1126
|
+
* If not provided, it will automatically use the terminal width (stdout.columns).
|
|
1127
|
+
*/
|
|
1128
|
+
width?: number;
|
|
1129
|
+
/**
|
|
1130
|
+
* Width offset to subtract from the terminal width when auto-calculating.
|
|
1131
|
+
* Use this to account for parent padding or borders.
|
|
1132
|
+
* @deprecated Recommend wrapping content with `<Panel>`, which automatically handles border overhead
|
|
1133
|
+
*/
|
|
1134
|
+
widthOffset?: number;
|
|
1135
|
+
/**
|
|
1136
|
+
* Default height for all rows/items in the grid.
|
|
1137
|
+
* Can be overridden by individual GridItem height prop.
|
|
1138
|
+
*/
|
|
1139
|
+
rowHeight?: number | string | undefined;
|
|
1140
|
+
/** Children should be GridItem components */
|
|
1141
|
+
children: React.ReactNode;
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Grid Container
|
|
1145
|
+
* Acts like a CSS Grid container, arranging items in columns.
|
|
1146
|
+
*/
|
|
1147
|
+
declare const Grid: React.FC<GridProps>;
|
|
1148
|
+
interface GridItemProps {
|
|
1149
|
+
/** Number of columns to span (default: 1) */
|
|
1150
|
+
span?: number;
|
|
1151
|
+
/** Fixed height for this item */
|
|
1152
|
+
height?: number | string;
|
|
1153
|
+
/** Minimum height for this item */
|
|
1154
|
+
minHeight?: number | string;
|
|
1155
|
+
/** Overflow behavior */
|
|
1156
|
+
overflow?: 'visible' | 'hidden';
|
|
1157
|
+
children: React.ReactNode;
|
|
1158
|
+
}
|
|
1159
|
+
/**
|
|
1160
|
+
* Grid Item
|
|
1161
|
+
* A cell in the grid that spans a specific number of columns.
|
|
1162
|
+
*/
|
|
1163
|
+
declare const GridItem: React.FC<GridItemProps>;
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* Legend component
|
|
1167
|
+
*
|
|
1168
|
+
* Used to display chart legend
|
|
1169
|
+
*/
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* Legend item
|
|
1173
|
+
*/
|
|
1174
|
+
interface LegendItem {
|
|
1175
|
+
/** Legend name */
|
|
1176
|
+
name: string;
|
|
1177
|
+
/** Legend color */
|
|
1178
|
+
color: string;
|
|
1179
|
+
/** Legend symbol (default '●') */
|
|
1180
|
+
symbol?: string;
|
|
1181
|
+
}
|
|
1182
|
+
/**
|
|
1183
|
+
* Legend component props
|
|
1184
|
+
*/
|
|
1185
|
+
interface LegendProps {
|
|
1186
|
+
/** Legend items array */
|
|
1187
|
+
items: LegendItem[];
|
|
1188
|
+
/** Layout direction (default 'horizontal') */
|
|
1189
|
+
position?: 'horizontal' | 'vertical';
|
|
1190
|
+
/** Overall text color (defaults to each item's own color) */
|
|
1191
|
+
color?: string;
|
|
1192
|
+
/** Gap between legend items (default 2) */
|
|
1193
|
+
gap?: number;
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Legend component
|
|
1197
|
+
*
|
|
1198
|
+
* @example
|
|
1199
|
+
* // Horizontal legend
|
|
1200
|
+
* <Legend
|
|
1201
|
+
* items={[
|
|
1202
|
+
* { name: 'CPU', color: 'blue', symbol: '●' },
|
|
1203
|
+
* { name: 'Memory', color: 'green', symbol: '●' },
|
|
1204
|
+
* ]}
|
|
1205
|
+
* position="horizontal"
|
|
1206
|
+
* />
|
|
1207
|
+
*
|
|
1208
|
+
* // Vertical legend
|
|
1209
|
+
* <Legend
|
|
1210
|
+
* items={[
|
|
1211
|
+
* { name: 'Series 1', color: 'cyan' },
|
|
1212
|
+
* { name: 'Series 2', color: 'yellow' },
|
|
1213
|
+
* ]}
|
|
1214
|
+
* position="vertical"
|
|
1215
|
+
* />
|
|
1216
|
+
*/
|
|
1217
|
+
declare const Legend: React.FC<LegendProps>;
|
|
1218
|
+
|
|
1219
|
+
interface PanelProps {
|
|
1220
|
+
/**
|
|
1221
|
+
* Panel title
|
|
1222
|
+
*/
|
|
1223
|
+
title?: string;
|
|
1224
|
+
/**
|
|
1225
|
+
* Title alignment
|
|
1226
|
+
* @default 'left'
|
|
1227
|
+
*/
|
|
1228
|
+
titleAlignment?: 'left' | 'center' | 'right';
|
|
1229
|
+
/**
|
|
1230
|
+
* Border style
|
|
1231
|
+
* @default 'round'
|
|
1232
|
+
*/
|
|
1233
|
+
borderStyle?: BoxProps['borderStyle'];
|
|
1234
|
+
/**
|
|
1235
|
+
* Border color
|
|
1236
|
+
* @default 'white'
|
|
1237
|
+
*/
|
|
1238
|
+
borderColor?: string;
|
|
1239
|
+
/**
|
|
1240
|
+
* Content padding
|
|
1241
|
+
* @default 0
|
|
1242
|
+
*/
|
|
1243
|
+
padding?: number;
|
|
1244
|
+
/**
|
|
1245
|
+
* Panel width
|
|
1246
|
+
*/
|
|
1247
|
+
width?: number | string;
|
|
1248
|
+
/**
|
|
1249
|
+
* Panel height
|
|
1250
|
+
*/
|
|
1251
|
+
height?: number | string;
|
|
1252
|
+
/**
|
|
1253
|
+
* Children (content)
|
|
1254
|
+
*/
|
|
1255
|
+
children: React.ReactNode;
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Panel - Card component with title and border
|
|
1259
|
+
*
|
|
1260
|
+
* Unified encapsulation of borders, titles, and padding, supporting various border styles.
|
|
1261
|
+
*/
|
|
1262
|
+
declare const Panel: React.FC<PanelProps>;
|
|
1263
|
+
|
|
1264
|
+
interface GaugeProps {
|
|
1265
|
+
/**
|
|
1266
|
+
* Current value
|
|
1267
|
+
*/
|
|
1268
|
+
value: number;
|
|
1269
|
+
/**
|
|
1270
|
+
* Minimum value
|
|
1271
|
+
* @default 0
|
|
1272
|
+
*/
|
|
1273
|
+
min?: number;
|
|
1274
|
+
/**
|
|
1275
|
+
* Maximum value
|
|
1276
|
+
* @default 100
|
|
1277
|
+
*/
|
|
1278
|
+
max?: number;
|
|
1279
|
+
/**
|
|
1280
|
+
* Progress bar width (character count), excluding percentage text
|
|
1281
|
+
* @default 20
|
|
1282
|
+
*/
|
|
1283
|
+
width?: number;
|
|
1284
|
+
/**
|
|
1285
|
+
* Fill color
|
|
1286
|
+
* @default 'green'
|
|
1287
|
+
*/
|
|
1288
|
+
color?: string;
|
|
1289
|
+
/**
|
|
1290
|
+
* Unfilled character color
|
|
1291
|
+
* @default 'gray'
|
|
1292
|
+
*/
|
|
1293
|
+
emptyColor?: string;
|
|
1294
|
+
/**
|
|
1295
|
+
* Whether to show percentage text
|
|
1296
|
+
* @default true
|
|
1297
|
+
*/
|
|
1298
|
+
showPercent?: boolean;
|
|
1299
|
+
/**
|
|
1300
|
+
* Rendering style
|
|
1301
|
+
* - 'unicode': Use Unicode block characters (█░)
|
|
1302
|
+
* - 'ascii': Use ASCII characters (#-)
|
|
1303
|
+
* @default 'unicode'
|
|
1304
|
+
*/
|
|
1305
|
+
variant?: 'unicode' | 'ascii';
|
|
1306
|
+
/**
|
|
1307
|
+
* Custom fill character (overrides variant setting)
|
|
1308
|
+
*/
|
|
1309
|
+
fillChar?: string;
|
|
1310
|
+
/**
|
|
1311
|
+
* Custom unfilled character (overrides variant setting)
|
|
1312
|
+
*/
|
|
1313
|
+
emptyChar?: string;
|
|
1314
|
+
/**
|
|
1315
|
+
* Prefix label
|
|
1316
|
+
*/
|
|
1317
|
+
label?: string;
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Gauge - Gauge/progress bar component
|
|
1321
|
+
*
|
|
1322
|
+
* Display progress or load of a single metric.
|
|
1323
|
+
* Style examples:
|
|
1324
|
+
* - unicode: [██████░░░░] 60%
|
|
1325
|
+
* - ascii: [######----] 60%
|
|
1326
|
+
*/
|
|
1327
|
+
declare const Gauge: React.FC<GaugeProps>;
|
|
1328
|
+
|
|
1329
|
+
/**
|
|
1330
|
+
* Multi-Style Big Fonts for BigNumber Component
|
|
1331
|
+
*
|
|
1332
|
+
* Supports three rendering styles:
|
|
1333
|
+
* - block: Unicode Block Elements (█▀▄)
|
|
1334
|
+
* - braille: Braille patterns (⠿)
|
|
1335
|
+
* - ascii: Pure ASCII characters
|
|
1336
|
+
*/
|
|
1337
|
+
type FontStyle = 'block' | 'braille' | 'ascii';
|
|
1338
|
+
|
|
1339
|
+
interface BigNumberProps {
|
|
1340
|
+
/**
|
|
1341
|
+
* Main value
|
|
1342
|
+
*/
|
|
1343
|
+
value: string | number;
|
|
1344
|
+
/**
|
|
1345
|
+
* Subtitle/label
|
|
1346
|
+
*/
|
|
1347
|
+
label?: string;
|
|
1348
|
+
/**
|
|
1349
|
+
* Color
|
|
1350
|
+
* @default 'white'
|
|
1351
|
+
*/
|
|
1352
|
+
color?: string;
|
|
1353
|
+
/**
|
|
1354
|
+
* Trend direction (for rendering arrows)
|
|
1355
|
+
*/
|
|
1356
|
+
trendDirection?: 'up' | 'down' | 'neutral';
|
|
1357
|
+
/**
|
|
1358
|
+
* Trend label (e.g., "12%")
|
|
1359
|
+
*/
|
|
1360
|
+
trendLabel?: string;
|
|
1361
|
+
/**
|
|
1362
|
+
* Trend arrow style
|
|
1363
|
+
* - 'unicode': Use Unicode arrows
|
|
1364
|
+
* - 'ascii': Use ASCII characters
|
|
1365
|
+
* @default 'unicode'
|
|
1366
|
+
*/
|
|
1367
|
+
variant?: 'unicode' | 'ascii';
|
|
1368
|
+
/**
|
|
1369
|
+
* Large font style
|
|
1370
|
+
* - 'block': Block Elements characters (default)
|
|
1371
|
+
* - 'braille': Braille Dot Matrix characters
|
|
1372
|
+
* - 'ascii': Pure ASCII characters
|
|
1373
|
+
* @default 'block'
|
|
1374
|
+
*/
|
|
1375
|
+
fontStyle?: FontStyle;
|
|
1376
|
+
/**
|
|
1377
|
+
* Alignment
|
|
1378
|
+
* @default 'center'
|
|
1379
|
+
*/
|
|
1380
|
+
align?: 'left' | 'center' | 'right';
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* BigNumber - Key metric card component
|
|
1384
|
+
*
|
|
1385
|
+
* Display core KPIs with large font for main value, supports subtitle and trend indicators.
|
|
1386
|
+
*/
|
|
1387
|
+
declare const BigNumber: React.FC<BigNumberProps>;
|
|
1388
|
+
|
|
1389
|
+
interface HeatmapProps {
|
|
1390
|
+
/**
|
|
1391
|
+
* Data matrix (2D array)
|
|
1392
|
+
* e.g. rows x cols
|
|
1393
|
+
*/
|
|
1394
|
+
data: number[][];
|
|
1395
|
+
/**
|
|
1396
|
+
* Color gradient (from low to high)
|
|
1397
|
+
* Defaults to theme's heatmapGradient
|
|
1398
|
+
*/
|
|
1399
|
+
colors?: string[];
|
|
1400
|
+
/**
|
|
1401
|
+
* Empty/zero value color (if not handled in gradient)
|
|
1402
|
+
*/
|
|
1403
|
+
emptyColor?: string;
|
|
1404
|
+
/**
|
|
1405
|
+
* Rendering style
|
|
1406
|
+
* - 'unicode': Use Unicode Blocks character (■)
|
|
1407
|
+
* - 'ascii': Use ASCII characters (#)
|
|
1408
|
+
* @default 'unicode'
|
|
1409
|
+
*/
|
|
1410
|
+
variant?: 'unicode' | 'ascii';
|
|
1411
|
+
/**
|
|
1412
|
+
* Custom character (overrides variant setting)
|
|
1413
|
+
*/
|
|
1414
|
+
char?: string;
|
|
1415
|
+
}
|
|
1416
|
+
declare const Heatmap: React.FC<HeatmapProps>;
|
|
1417
|
+
|
|
1418
|
+
/**
|
|
1419
|
+
* LogStream - Log stream display component
|
|
1420
|
+
*
|
|
1421
|
+
* Pure log display component, without borders and title.
|
|
1422
|
+
* If borders are needed, please use the <Panel><LogStream /></Panel> pattern.
|
|
1423
|
+
*/
|
|
1424
|
+
|
|
1425
|
+
interface LogStreamProps {
|
|
1426
|
+
/**
|
|
1427
|
+
* Array of log strings
|
|
1428
|
+
*/
|
|
1429
|
+
logs: string[];
|
|
1430
|
+
/**
|
|
1431
|
+
* Maximum retained lines (counted from end)
|
|
1432
|
+
* @default 100
|
|
1433
|
+
*/
|
|
1434
|
+
maxLines?: number;
|
|
1435
|
+
/**
|
|
1436
|
+
* Display height (number of lines)
|
|
1437
|
+
* If not provided, will adapt to content (but not exceed maxLines)
|
|
1438
|
+
*/
|
|
1439
|
+
height?: number;
|
|
1440
|
+
/**
|
|
1441
|
+
* Display width (character count)
|
|
1442
|
+
* If not provided, will adapt to parent container
|
|
1443
|
+
*/
|
|
1444
|
+
width?: number;
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* LogStream - Scrolling log viewer component
|
|
1448
|
+
*
|
|
1449
|
+
* Features:
|
|
1450
|
+
* - Automatically display latest logs (render tail)
|
|
1451
|
+
* - Intelligently parse timestamps and log levels
|
|
1452
|
+
* - Use icons and colors to distinguish levels
|
|
1453
|
+
* - Support maximum line limit
|
|
1454
|
+
*/
|
|
1455
|
+
declare const LogStream: React.FC<LogStreamProps>;
|
|
1456
|
+
|
|
1457
|
+
interface TableColumn<T> {
|
|
1458
|
+
/**
|
|
1459
|
+
* Header title
|
|
1460
|
+
*/
|
|
1461
|
+
header: string;
|
|
1462
|
+
/**
|
|
1463
|
+
* Data accessor key (if property of T) or render function
|
|
1464
|
+
*/
|
|
1465
|
+
accessor: keyof T | ((item: T) => React.ReactNode);
|
|
1466
|
+
/**
|
|
1467
|
+
* Optional fixed width (if not provided, auto-calculated)
|
|
1468
|
+
*/
|
|
1469
|
+
width?: number;
|
|
1470
|
+
/**
|
|
1471
|
+
* Alignment
|
|
1472
|
+
* @default 'left'
|
|
1473
|
+
*/
|
|
1474
|
+
align?: 'left' | 'right' | 'center';
|
|
1475
|
+
}
|
|
1476
|
+
interface TableProps<T> {
|
|
1477
|
+
/**
|
|
1478
|
+
* Data array
|
|
1479
|
+
*/
|
|
1480
|
+
data: T[];
|
|
1481
|
+
/**
|
|
1482
|
+
* Column definitions
|
|
1483
|
+
*/
|
|
1484
|
+
columns: TableColumn<T>[];
|
|
1485
|
+
/**
|
|
1486
|
+
* Currently sorted column key (matches matches column header or some ID? Let's use header/index for simplicity or separate ID)
|
|
1487
|
+
* For simplicity, let's match 'header' string or an index.
|
|
1488
|
+
* Let's use the index of the column for simplicity in this TUI context, or match header string.
|
|
1489
|
+
*/
|
|
1490
|
+
sortColumn?: number | string;
|
|
1491
|
+
/**
|
|
1492
|
+
* Sort direction
|
|
1493
|
+
*/
|
|
1494
|
+
sortDirection?: 'asc' | 'desc';
|
|
1495
|
+
/**
|
|
1496
|
+
* Enable zebra striping
|
|
1497
|
+
* @default false
|
|
1498
|
+
*/
|
|
1499
|
+
zebra?: boolean;
|
|
1500
|
+
/**
|
|
1501
|
+
* Callback when a column header is activated (sorted)
|
|
1502
|
+
*/
|
|
1503
|
+
onSort?: (column: TableColumn<T>, index: number) => void;
|
|
1504
|
+
}
|
|
1505
|
+
/**
|
|
1506
|
+
* Table - Data table with interactive sort headers
|
|
1507
|
+
*/
|
|
1508
|
+
declare const Table: <T>({ data, columns, sortColumn, sortDirection, zebra, onSort, }: TableProps<T>) => React.JSX.Element;
|
|
1509
|
+
|
|
1510
|
+
export { AreaChart, type AreaChartProps, AsciiRenderer, Axis, type AxisProps, BarChart, type BarChartProps, BigNumber, type BigNumberProps, BlockRenderer, BrailleRenderer, type EasingFunction, type EnvironmentInfo, Gauge, type GaugeProps, Grid, GridItem, type GridItemProps, type GridProps, Heatmap, type HeatmapProps, type InkHudContextValue, InkHudProvider, type InkHudProviderProps, Legend, type LegendItem, type LegendProps, LineChart, type LineChartProps, LogStream, type LogStreamProps, ONE_DARK_THEME, Panel, type PanelProps, PieChart, type PieChartDataItem, type PieChartProps, Renderer, type RendererMetadata, type RendererResolution, RendererSelector, type RendererType, type SemanticColors, Sparkline, type SparklineProps, Table, type TableColumn, type TableProps, type TerminalCapabilities, TerminalDetector, type Theme, ThemeProvider, arcPoints, assignColors, averageDownsampling, clamp, colorToChalk, createGradient, degreesToRadians, distanceBetweenPoints, easeInCubic, easeInOutQuad, easeLinear, easeOutCubic, fixedIntervalDownsampling, linearScale, lttb, midpointCircle, minMaxDownsampling, normalize, pointOnArc, radiansToDegrees, rendererSelector, scaleToRange, terminalDetector, useInkHud, useRendererSelector, useSemanticColors, useSmooth, useSmoothArray, useTheme, useThrottle };
|