@boba-cli/dsl 0.1.0-alpha.1 โ†’ 1.0.0-alpha.2

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/README.md CHANGED
@@ -19,7 +19,7 @@ const app = createApp()
19
19
  .onKey(['q', 'ctrl+c'], ({ quit }) => quit())
20
20
  .view(({ state, components }) =>
21
21
  vstack(
22
- text('๐Ÿงผ My App').bold().foreground('#ff79c6'),
22
+ text('๐Ÿง‹ My App').bold().foreground('#ff79c6'),
23
23
  spacer(),
24
24
  hstack(components.loading, text(' ' + state.message)),
25
25
  spacer(),
@@ -223,12 +223,208 @@ vstack(
223
223
 
224
224
  ### Component Builders
225
225
 
226
+ The DSL provides 17 component builders for common CLI patterns. All components integrate seamlessly with the App builder pattern and provide declarative configuration.
227
+
228
+ #### `code(options: CodeBuilderOptions): ComponentBuilder<CodeModel>`
229
+
230
+ Displays syntax-highlighted source code from files with scrolling support.
231
+
232
+ ```typescript
233
+ import { NodeFileSystemAdapter, NodePathAdapter } from '@boba-cli/machine/node'
234
+
235
+ .component('viewer', code({
236
+ filesystem: new NodeFileSystemAdapter(),
237
+ path: new NodePathAdapter(),
238
+ active: true,
239
+ theme: 'dracula',
240
+ width: 80,
241
+ height: 24
242
+ }))
243
+ ```
244
+
245
+ **Options:**
246
+ - `filesystem` - Filesystem adapter (required, use `NodeFileSystemAdapter` for Node.js)
247
+ - `path` - Path adapter (required, use `NodePathAdapter` for Node.js)
248
+ - `active` - Whether component receives keyboard input (default: `false`)
249
+ - `theme` - Syntax theme like `"dracula"`, `"monokai"`, `"github-light"` (default: `"dracula"`)
250
+ - `width` - Viewer width in characters (default: `0`)
251
+ - `height` - Viewer height in lines (default: `0`)
252
+
253
+ #### `filepicker(options: FilepickerBuilderOptions): ComponentBuilder<FilepickerModel>`
254
+
255
+ Interactive file system browser with selection support.
256
+
257
+ ```typescript
258
+ import { NodeFileSystemAdapter, NodePathAdapter } from '@boba-cli/machine/node'
259
+
260
+ .component('picker', filepicker({
261
+ filesystem: new NodeFileSystemAdapter(),
262
+ path: new NodePathAdapter(),
263
+ currentPath: process.cwd(),
264
+ height: 15,
265
+ width: 60
266
+ }))
267
+ ```
268
+
269
+ **Options:**
270
+ - `filesystem` - Filesystem adapter (required)
271
+ - `path` - Path adapter (required)
272
+ - `currentPath` - Initial directory path
273
+ - `height` - Picker height in lines
274
+ - `width` - Picker width in characters
275
+ - Additional styling and behavior options available
276
+
277
+ #### `filetree(options: FiletreeBuilderOptions): ComponentBuilder<FiletreeModel>`
278
+
279
+ Directory tree viewer with expandable folders.
280
+
281
+ ```typescript
282
+ .component('tree', filetree({
283
+ root: { name: 'src', isDirectory: true, children: [...] }
284
+ }))
285
+ ```
286
+
287
+ **Options:**
288
+ - `root` - Root directory item (required, must be a `DirectoryItem`)
289
+ - `showFiles` - Whether to show files or only directories (default: `true`)
290
+ - Custom styling options available
291
+
292
+ #### `help(options?: HelpBuilderOptions): ComponentBuilder<HelpModel>`
293
+
294
+ Full-screen key binding help display.
295
+
296
+ ```typescript
297
+ .component('help', help({
298
+ keyBindings: [
299
+ { key: 'q', description: 'Quit application' },
300
+ { key: 'โ†‘/โ†“', description: 'Navigate list' }
301
+ ],
302
+ showHelp: true
303
+ }))
304
+ ```
305
+
306
+ **Options:**
307
+ - `keyBindings` - Array of key binding descriptions
308
+ - `showHelp` - Whether help is visible (default: `false`)
309
+ - Custom styling options available
310
+
311
+ #### `helpBubble(options?: HelpBubbleBuilderOptions): ComponentBuilder<HelpBubbleModel>`
312
+
313
+ Compact inline help bubble with keyboard shortcuts.
314
+
315
+ ```typescript
316
+ .component('shortcuts', helpBubble({
317
+ entries: [
318
+ { key: 'enter', description: 'Select' },
319
+ { key: 'q', description: 'Quit' }
320
+ ]
321
+ }))
322
+ ```
323
+
324
+ **Options:**
325
+ - `entries` - Array of shortcut entries with `key` and `description`
326
+ - Custom styling options available
327
+
328
+ #### `list<T>(options: ListBuilderOptions<T>): ComponentBuilder<ListModel<T>>`
329
+
330
+ Filterable, paginated list with keyboard navigation. Items must implement the `Item` interface.
331
+
332
+ ```typescript
333
+ import { list, type Item } from '@boba-cli/dsl'
334
+
335
+ interface TodoItem extends Item {
336
+ filterValue: () => string
337
+ title: () => string
338
+ description: () => string
339
+ }
340
+
341
+ const items: TodoItem[] = [
342
+ { filterValue: () => 'Buy milk', title: () => 'Buy milk', description: () => 'From the store' }
343
+ ]
344
+
345
+ .component('todos', list({ items, title: 'Tasks', height: 20 }))
346
+ ```
347
+
348
+ **Options:**
349
+ - `items` - Array of items implementing `Item` interface (required)
350
+ - `title` - List title
351
+ - `height` - List height in lines
352
+ - `width` - List width in characters
353
+ - `showTitle`, `showFilter`, `showPagination`, `showHelp`, `showStatusBar` - Toggle UI elements
354
+ - `filteringEnabled` - Enable/disable filtering (default: `true`)
355
+ - `styles` - Custom styles for list components
356
+ - `keyMap` - Custom key bindings
357
+ - `delegate` - Custom item rendering
358
+
359
+ #### `markdown(options?: MarkdownBuilderOptions): ComponentBuilder<MarkdownModel>`
360
+
361
+ Renders markdown with syntax highlighting.
362
+
363
+ ```typescript
364
+ .component('docs', markdown({
365
+ content: '# Hello\n\nThis is **markdown**.',
366
+ width: 80
367
+ }))
368
+ ```
369
+
370
+ **Options:**
371
+ - `content` - Markdown content to render
372
+ - `width` - Rendering width in characters
373
+ - Custom styling options available
374
+
375
+ #### `paginator(options?: PaginatorBuilderOptions): ComponentBuilder<PaginatorModel>`
376
+
377
+ Dot-style page indicator (e.g., `โ— โ—‹ โ—‹`).
378
+
379
+ ```typescript
380
+ .component('pages', paginator({
381
+ totalPages: 5,
382
+ currentPage: 0
383
+ }))
384
+ ```
385
+
386
+ **Options:**
387
+ - `totalPages` - Total number of pages (default: `3`)
388
+ - `currentPage` - Current page index (default: `0`)
389
+ - Custom styling options available
390
+
391
+ #### `progress(options?: ProgressBuilderOptions): ComponentBuilder<ProgressModel>`
392
+
393
+ Animated progress bar with gradient support and spring physics.
394
+
395
+ ```typescript
396
+ .component('progress', progress({
397
+ width: 40,
398
+ gradient: {
399
+ start: '#5A56E0',
400
+ end: '#EE6FF8',
401
+ scaleGradientToProgress: false
402
+ },
403
+ showPercentage: true,
404
+ spring: {
405
+ frequency: 18,
406
+ damping: 1
407
+ }
408
+ }))
409
+ ```
410
+
411
+ **Options:**
412
+ - `width` - Progress bar width in characters (default: `40`)
413
+ - `full` - Character for filled portion (default: `'โ–ˆ'`)
414
+ - `empty` - Character for empty portion (default: `'โ–‘'`)
415
+ - `fullColor` - Color for filled portion (default: `'#7571F9'`)
416
+ - `emptyColor` - Color for empty portion (default: `'#606060'`)
417
+ - `showPercentage` - Display percentage value (default: `true`)
418
+ - `percentFormat` - Printf-style format string (default: `' %3.0f%%'`)
419
+ - `gradient` - Gradient configuration with `start`, `end`, `scaleGradientToProgress`
420
+ - `spring` - Spring physics with `frequency`, `damping`
421
+ - `percentageStyle` - Style for percentage text
422
+
226
423
  #### `spinner(options?: SpinnerBuilderOptions): ComponentBuilder<SpinnerModel>`
227
424
 
228
- Creates an animated spinner component.
425
+ Animated loading spinner.
229
426
 
230
427
  ```typescript
231
- .component('loading', spinner())
232
428
  .component('loading', spinner({
233
429
  spinner: dot,
234
430
  style: new Style().foreground('#50fa7b')
@@ -244,9 +440,149 @@ Creates an animated spinner component.
244
440
  import { line, dot, miniDot, pulse, points, moon, meter, ellipsis } from '@boba-cli/dsl'
245
441
  ```
246
442
 
443
+ #### `statusBar(options?: StatusBarBuilderOptions): ComponentBuilder<StatusBarModel>`
444
+
445
+ Multi-column status bar for displaying key-value pairs.
446
+
447
+ ```typescript
448
+ .component('status', statusBar({
449
+ columns: [
450
+ { key: 'mode', value: 'NORMAL' },
451
+ { key: 'line', value: '42' }
452
+ ]
453
+ }))
454
+ ```
455
+
456
+ **Options:**
457
+ - `columns` - Array of column definitions with `key` and `value`
458
+ - Custom styling options available
459
+
460
+ #### `stopwatch(options?: StopwatchBuilderOptions): ComponentBuilder<StopwatchModel>`
461
+
462
+ Displays elapsed time since start.
463
+
464
+ ```typescript
465
+ .component('elapsed', stopwatch({
466
+ format: 'mm:ss.SSS',
467
+ running: true
468
+ }))
469
+ ```
470
+
471
+ **Options:**
472
+ - `format` - Time format string (default: `'mm:ss.SSS'`)
473
+ - `running` - Whether stopwatch is running (default: `false`)
474
+ - Custom styling options available
475
+
476
+ #### `table(options?: TableBuilderOptions): ComponentBuilder<TableModel>`
477
+
478
+ Scrollable data table with headers and rows.
479
+
480
+ ```typescript
481
+ .component('data', table({
482
+ headers: ['Name', 'Age', 'City'],
483
+ rows: [
484
+ ['Alice', '30', 'NYC'],
485
+ ['Bob', '25', 'SF']
486
+ ],
487
+ height: 10
488
+ }))
489
+ ```
490
+
491
+ **Options:**
492
+ - `headers` - Column headers
493
+ - `rows` - Data rows
494
+ - `height` - Table height in lines
495
+ - `width` - Table width in characters
496
+ - Custom styling and scrolling options available
497
+
498
+ #### `textArea(options?: TextAreaBuilderOptions): ComponentBuilder<TextAreaModel>`
499
+
500
+ Multi-line text editor with scrolling and editing.
501
+
502
+ ```typescript
503
+ .component('editor', textArea({
504
+ value: 'Initial text',
505
+ width: 80,
506
+ height: 20,
507
+ active: true
508
+ }))
509
+ ```
510
+
511
+ **Options:**
512
+ - `value` - Initial text content
513
+ - `width` - Editor width in characters
514
+ - `height` - Editor height in lines
515
+ - `active` - Whether editor receives keyboard input (default: `false`)
516
+ - Custom styling options available
517
+
518
+ #### `textInput(options?: TextInputBuilderOptions): ComponentBuilder<TextInputModel>`
519
+
520
+ Single-line text input with validation, placeholders, and echo modes.
521
+
522
+ ```typescript
523
+ .component('input', textInput({
524
+ placeholder: 'Enter your name...',
525
+ value: '',
526
+ active: true,
527
+ validate: (value) => value.length > 0 ? null : 'Required'
528
+ }))
529
+ ```
530
+
531
+ **Options:**
532
+ - `value` - Initial input value
533
+ - `placeholder` - Placeholder text
534
+ - `active` - Whether input receives keyboard input (default: `false`)
535
+ - `validate` - Validation function returning error message or `null`
536
+ - `echoMode` - Input display mode (normal, password, none)
537
+ - `cursorMode` - Cursor style
538
+ - Custom styling options available
539
+
540
+ **Re-exported types:**
541
+ ```typescript
542
+ import { EchoMode, CursorMode, type ValidateFunc } from '@boba-cli/dsl'
543
+ ```
544
+
545
+ #### `timer(options?: TimerBuilderOptions): ComponentBuilder<TimerModel>`
546
+
547
+ Countdown timer display.
548
+
549
+ ```typescript
550
+ .component('countdown', timer({
551
+ duration: 60000, // 60 seconds in milliseconds
552
+ format: 'mm:ss',
553
+ running: true
554
+ }))
555
+ ```
556
+
557
+ **Options:**
558
+ - `duration` - Total duration in milliseconds
559
+ - `format` - Time format string (default: `'mm:ss'`)
560
+ - `running` - Whether timer is running (default: `false`)
561
+ - Custom styling options available
562
+
563
+ #### `viewport(options?: ViewportBuilderOptions): ComponentBuilder<ViewportModel>`
564
+
565
+ Scrollable content viewport for displaying large content.
566
+
567
+ ```typescript
568
+ .component('content', viewport({
569
+ content: longTextContent,
570
+ width: 80,
571
+ height: 20,
572
+ active: true
573
+ }))
574
+ ```
575
+
576
+ **Options:**
577
+ - `content` - Content to display (string or array of strings)
578
+ - `width` - Viewport width in characters
579
+ - `height` - Viewport height in lines
580
+ - `active` - Whether viewport receives keyboard input for scrolling (default: `false`)
581
+ - Custom styling options available
582
+
247
583
  ### Re-exported Types
248
584
 
249
- For convenience, the DSL re-exports commonly used types:
585
+ For convenience, the DSL re-exports commonly used types from underlying packages:
250
586
 
251
587
  ```typescript
252
588
  // From @boba-cli/chapstick
@@ -254,6 +590,18 @@ import { Style } from '@boba-cli/dsl'
254
590
 
255
591
  // From @boba-cli/spinner
256
592
  import { type Spinner, line, dot, miniDot, pulse, points, moon, meter, ellipsis } from '@boba-cli/dsl'
593
+
594
+ // From @boba-cli/textinput
595
+ import { type TextInputModel, EchoMode, CursorMode, type ValidateFunc } from '@boba-cli/dsl'
596
+
597
+ // From @boba-cli/list
598
+ import { type Item } from '@boba-cli/dsl'
599
+
600
+ // From @boba-cli/filetree
601
+ import { type DirectoryItem } from '@boba-cli/dsl'
602
+
603
+ // From @boba-cli/help-bubble
604
+ import { type Entry } from '@boba-cli/dsl'
257
605
  ```
258
606
 
259
607
  ## Type Safety