@visulima/tui 1.0.8 → 2.0.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.
Files changed (279) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +54 -2444
  3. package/MIGRATION-GUIDE.md +164 -0
  4. package/README.md +15 -12
  5. package/dist/components/box.d.ts +3 -4
  6. package/dist/components/canvas.d.ts +2 -2
  7. package/dist/components/canvas.js +1 -1
  8. package/dist/components/cursor.d.ts +3 -4
  9. package/dist/components/error-boundary.d.ts +16 -0
  10. package/dist/components/error-boundary.js +1 -0
  11. package/dist/components/error-overview.d.ts +8 -0
  12. package/dist/components/error-overview.js +1 -0
  13. package/dist/components/static-render.d.ts +3 -4
  14. package/dist/components/static.d.ts +1 -2
  15. package/dist/components/text.d.ts +1 -2
  16. package/dist/core/index.d.ts +1 -2
  17. package/dist/core/index.js +1 -1
  18. package/dist/ink/canvas/index.d.ts +24 -0
  19. package/dist/ink/canvas/index.js +1 -0
  20. package/dist/ink/hooks/use-app.d.ts +1 -32
  21. package/dist/ink/hooks/use-app.js +1 -1
  22. package/dist/ink/hooks/use-box-metrics.d.ts +3 -4
  23. package/dist/ink/hooks/use-cursor.d.ts +1 -1
  24. package/dist/ink/hooks/use-input.js +2 -2
  25. package/dist/ink/hooks/use-paste.js +1 -1
  26. package/dist/ink/hooks/use-persistent-state.js +2 -2
  27. package/dist/ink/hooks/use-text-selection.d.ts +4 -5
  28. package/dist/ink/hooks/use-window-size.js +1 -1
  29. package/dist/ink/index.d.ts +7 -7
  30. package/dist/ink/index.js +1 -1
  31. package/dist/ink/mouse/use-element-position.d.ts +3 -4
  32. package/dist/ink/mouse/use-on-mouse-click.d.ts +3 -4
  33. package/dist/ink/mouse/use-on-mouse-hover.d.ts +3 -4
  34. package/dist/ink/mouse/use-on-mouse-state.d.ts +3 -4
  35. package/dist/ink/public/cursor.d.ts +47 -0
  36. package/dist/ink/public/cursor.js +1 -0
  37. package/dist/ink/public/dom.d.ts +6 -0
  38. package/dist/ink/public/dom.js +0 -0
  39. package/dist/ink/public/highlighter.d.ts +54 -0
  40. package/dist/ink/public/highlighter.js +1 -0
  41. package/dist/ink/public/input.d.ts +14 -0
  42. package/dist/ink/public/input.js +1 -0
  43. package/dist/ink/public/styles.d.ts +4 -0
  44. package/dist/ink/public/styles.js +0 -0
  45. package/dist/ink/public/utils.d.ts +5 -0
  46. package/dist/ink/public/utils.js +1 -0
  47. package/dist/packem_chunks/devtools.js +1 -1
  48. package/dist/packem_shared/{DevTools-k6uiVzqv.js → DevTools-D9tfChBc.js} +1 -1
  49. package/dist/packem_shared/InputParser-CiBitCva.js +2 -0
  50. package/dist/packem_shared/TuiApp-DjIgv5Sk.js +1 -0
  51. package/dist/packem_shared/app-context-DTm1_XBA.js +1 -0
  52. package/dist/packem_shared/app-context.d-CG88lgkg.d.ts +56 -0
  53. package/dist/packem_shared/boxes-DyY_LXCi.js +1 -0
  54. package/dist/packem_shared/{buffer.d-EJkZr8uH.d.ts → buffer.d-j_dP5JyC.d.ts} +29 -1
  55. package/dist/packem_shared/buildCursorOnlySequence-CerkmjWt.js +1 -0
  56. package/dist/packem_shared/{braille-ch3O5D7I.js → createBrailleGrid-BTOQrujS.js} +1 -1
  57. package/dist/packem_shared/createCanvasBuffer-CL6sAM-A.js +1 -0
  58. package/dist/packem_shared/disposeHighlighter-D9OkrhwX.js +1 -0
  59. package/dist/packem_shared/{dom.d-B4kXbaVY.d.ts → dom.d-g-nsYquD.d.ts} +3 -4
  60. package/dist/packem_shared/formatDuration-Bdx4ZgRh.js +1 -0
  61. package/dist/packem_shared/index-Dl9I2_QH.js +75 -0
  62. package/dist/packem_shared/input.d-D-Yxqha8.d.ts +172 -0
  63. package/dist/packem_shared/{input-utils-BSWCb4F_.js → isControlCharacter-uDgBe_32.js} +1 -1
  64. package/dist/packem_shared/{reconciler-CFyBVf7l.js → reconciler-DhUGYWCr.js} +1 -1
  65. package/dist/packem_shared/render-D7aV_hO1.js +24 -0
  66. package/dist/packem_shared/{render-DFZ8NHlG.js → render-DMcWfI6-.js} +1 -1
  67. package/dist/packem_shared/{render.d-CBnYBDk2.d.ts → render.d-BvfwvSCx.d.ts} +20 -2
  68. package/dist/packem_shared/{renderToString-L_bpw4OQ.js → renderToString-DkTmJPaS.js} +1 -1
  69. package/dist/packem_shared/{renderToString-DwXFY8Qh.js → renderToString-DqLFFPvO.js} +1 -1
  70. package/dist/packem_shared/renderToken-DjiQ6dfv.js +1 -0
  71. package/dist/packem_shared/renderTreeToBuffer-BpSD0sBJ.js +2 -0
  72. package/dist/packem_shared/{renderer-k-xShm1P.js → renderer-Cs0KEr1o.js} +4 -4
  73. package/dist/packem_shared/{selection.d-CI3_p8wg.d.ts → selection.d-KWphH--_.d.ts} +1 -1
  74. package/dist/packem_shared/{styles.d-cMo36xQz.d.ts → styles.d-D7iZuNC-.d.ts} +97 -1
  75. package/dist/packem_shared/utils-C8l_3Dzw.js +1 -0
  76. package/dist/react/index.d.ts +1 -2
  77. package/dist/react/index.js +1 -1
  78. package/dist/testing/index.d.ts +5 -5
  79. package/dist/testing/index.js +1 -1
  80. package/index.js +26 -26
  81. package/package.json +49 -384
  82. package/dist/components/accordion.d.ts +0 -59
  83. package/dist/components/accordion.js +0 -1
  84. package/dist/components/alert.d.ts +0 -26
  85. package/dist/components/alert.js +0 -1
  86. package/dist/components/animate-presence.d.ts +0 -18
  87. package/dist/components/animate-presence.js +0 -1
  88. package/dist/components/approval-prompt.d.ts +0 -65
  89. package/dist/components/approval-prompt.js +0 -1
  90. package/dist/components/area-chart.d.ts +0 -66
  91. package/dist/components/area-chart.js +0 -1
  92. package/dist/components/badge.d.ts +0 -22
  93. package/dist/components/badge.js +0 -1
  94. package/dist/components/bar-chart.d.ts +0 -67
  95. package/dist/components/bar-chart.js +0 -1
  96. package/dist/components/big-text.d.ts +0 -81
  97. package/dist/components/big-text.js +0 -1
  98. package/dist/components/blink-dot.d.ts +0 -36
  99. package/dist/components/blink-dot.js +0 -1
  100. package/dist/components/breadcrumb.d.ts +0 -33
  101. package/dist/components/breadcrumb.js +0 -1
  102. package/dist/components/button.d.ts +0 -45
  103. package/dist/components/button.js +0 -1
  104. package/dist/components/calendar.d.ts +0 -72
  105. package/dist/components/calendar.js +0 -1
  106. package/dist/components/card.d.ts +0 -57
  107. package/dist/components/card.js +0 -1
  108. package/dist/components/checkbox.d.ts +0 -48
  109. package/dist/components/checkbox.js +0 -1
  110. package/dist/components/code.d.ts +0 -48
  111. package/dist/components/code.js +0 -2
  112. package/dist/components/collapsible.d.ts +0 -53
  113. package/dist/components/collapsible.js +0 -1
  114. package/dist/components/command-block.d.ts +0 -47
  115. package/dist/components/command-block.js +0 -4
  116. package/dist/components/command-palette.d.ts +0 -82
  117. package/dist/components/command-palette.js +0 -1
  118. package/dist/components/confirm-dialog.d.ts +0 -75
  119. package/dist/components/confirm-dialog.js +0 -1
  120. package/dist/components/confirm-input.d.ts +0 -38
  121. package/dist/components/confirm-input.js +0 -1
  122. package/dist/components/console-overlay.d.ts +0 -54
  123. package/dist/components/console-overlay.js +0 -1
  124. package/dist/components/content-switcher.d.ts +0 -57
  125. package/dist/components/content-switcher.js +0 -1
  126. package/dist/components/controlled-scroll-view.d.ts +0 -61
  127. package/dist/components/controlled-scroll-view.js +0 -1
  128. package/dist/components/date-picker.d.ts +0 -65
  129. package/dist/components/date-picker.js +0 -1
  130. package/dist/components/definition-list.d.ts +0 -44
  131. package/dist/components/definition-list.js +0 -1
  132. package/dist/components/dialog.d.ts +0 -117
  133. package/dist/components/dialog.js +0 -1
  134. package/dist/components/diff-view.d.ts +0 -85
  135. package/dist/components/diff-view.js +0 -1
  136. package/dist/components/divider.d.ts +0 -49
  137. package/dist/components/divider.js +0 -1
  138. package/dist/components/file-picker-entry.d.ts +0 -104
  139. package/dist/components/file-picker-entry.js +0 -1
  140. package/dist/components/form.d.ts +0 -81
  141. package/dist/components/form.js +0 -1
  142. package/dist/components/gauge.d.ts +0 -87
  143. package/dist/components/gauge.js +0 -1
  144. package/dist/components/gradient.d.ts +0 -42
  145. package/dist/components/gradient.js +0 -1
  146. package/dist/components/heading.d.ts +0 -33
  147. package/dist/components/heading.js +0 -1
  148. package/dist/components/heatmap.d.ts +0 -62
  149. package/dist/components/heatmap.js +0 -1
  150. package/dist/components/help.d.ts +0 -52
  151. package/dist/components/help.js +0 -1
  152. package/dist/components/histogram.d.ts +0 -62
  153. package/dist/components/histogram.js +0 -1
  154. package/dist/components/kbd.d.ts +0 -31
  155. package/dist/components/kbd.js +0 -1
  156. package/dist/components/line-chart.d.ts +0 -109
  157. package/dist/components/line-chart.js +0 -1
  158. package/dist/components/link.d.ts +0 -38
  159. package/dist/components/link.js +0 -1
  160. package/dist/components/loading-indicator.d.ts +0 -29
  161. package/dist/components/loading-indicator.js +0 -1
  162. package/dist/components/markdown.d.ts +0 -40
  163. package/dist/components/markdown.js +0 -1
  164. package/dist/components/masked-input.d.ts +0 -50
  165. package/dist/components/masked-input.js +0 -1
  166. package/dist/components/menu.d.ts +0 -78
  167. package/dist/components/menu.js +0 -1
  168. package/dist/components/message-bubble.d.ts +0 -43
  169. package/dist/components/message-bubble.js +0 -1
  170. package/dist/components/model-badge.d.ts +0 -39
  171. package/dist/components/model-badge.js +0 -1
  172. package/dist/components/multi-select.d.ts +0 -65
  173. package/dist/components/multi-select.js +0 -1
  174. package/dist/components/operation-tree.d.ts +0 -49
  175. package/dist/components/operation-tree.js +0 -1
  176. package/dist/components/option-list.d.ts +0 -47
  177. package/dist/components/option-list.js +0 -1
  178. package/dist/components/ordered-list.d.ts +0 -24
  179. package/dist/components/ordered-list.js +0 -1
  180. package/dist/components/paginator.d.ts +0 -69
  181. package/dist/components/paginator.js +0 -1
  182. package/dist/components/paragraph.d.ts +0 -38
  183. package/dist/components/paragraph.js +0 -1
  184. package/dist/components/placeholder.d.ts +0 -55
  185. package/dist/components/placeholder.js +0 -1
  186. package/dist/components/progress-bar.d.ts +0 -56
  187. package/dist/components/progress-bar.js +0 -1
  188. package/dist/components/radio-group.d.ts +0 -74
  189. package/dist/components/radio-group.js +0 -1
  190. package/dist/components/scatter-plot.d.ts +0 -35
  191. package/dist/components/scatter-plot.js +0 -1
  192. package/dist/components/scroll-bar-box.d.ts +0 -37
  193. package/dist/components/scroll-bar-box.js +0 -1
  194. package/dist/components/scroll-bar.d.ts +0 -25
  195. package/dist/components/scroll-bar.js +0 -1
  196. package/dist/components/scroll-list.d.ts +0 -20
  197. package/dist/components/scroll-list.js +0 -1
  198. package/dist/components/scroll-view.d.ts +0 -10
  199. package/dist/components/scroll-view.js +0 -1
  200. package/dist/components/search-input.d.ts +0 -55
  201. package/dist/components/search-input.js +0 -1
  202. package/dist/components/select-input-indicator.d.ts +0 -32
  203. package/dist/components/select-input-indicator.js +0 -1
  204. package/dist/components/select-input-item.d.ts +0 -41
  205. package/dist/components/select-input-item.js +0 -1
  206. package/dist/components/select-input.d.ts +0 -110
  207. package/dist/components/select-input.js +0 -1
  208. package/dist/components/shimmer-text.d.ts +0 -47
  209. package/dist/components/shimmer-text.js +0 -1
  210. package/dist/components/slider.d.ts +0 -103
  211. package/dist/components/slider.js +0 -1
  212. package/dist/components/sparkline.d.ts +0 -35
  213. package/dist/components/sparkline.js +0 -1
  214. package/dist/components/spinner.d.ts +0 -17
  215. package/dist/components/spinner.js +0 -1
  216. package/dist/components/status-line.d.ts +0 -37
  217. package/dist/components/status-line.js +0 -1
  218. package/dist/components/status-message.d.ts +0 -21
  219. package/dist/components/status-message.js +0 -1
  220. package/dist/components/stepper.d.ts +0 -48
  221. package/dist/components/stepper.js +0 -1
  222. package/dist/components/stopwatch.d.ts +0 -49
  223. package/dist/components/stopwatch.js +0 -1
  224. package/dist/components/streaming-text.d.ts +0 -46
  225. package/dist/components/streaming-text.js +0 -1
  226. package/dist/components/switch.d.ts +0 -55
  227. package/dist/components/switch.js +0 -1
  228. package/dist/components/tab.d.ts +0 -19
  229. package/dist/components/tab.js +0 -1
  230. package/dist/components/table.d.ts +0 -119
  231. package/dist/components/table.js +0 -1
  232. package/dist/components/tabs.d.ts +0 -107
  233. package/dist/components/tabs.js +0 -1
  234. package/dist/components/tag.d.ts +0 -35
  235. package/dist/components/tag.js +0 -1
  236. package/dist/components/text-input.d.ts +0 -48
  237. package/dist/components/text-input.js +0 -1
  238. package/dist/components/textarea.d.ts +0 -68
  239. package/dist/components/textarea.js +0 -2
  240. package/dist/components/timer.d.ts +0 -59
  241. package/dist/components/timer.js +0 -1
  242. package/dist/components/toast.d.ts +0 -49
  243. package/dist/components/toast.js +0 -1
  244. package/dist/components/tooltip.d.ts +0 -43
  245. package/dist/components/tooltip.js +0 -1
  246. package/dist/components/transition.d.ts +0 -74
  247. package/dist/components/transition.js +0 -1
  248. package/dist/components/tree-view-entry.d.ts +0 -357
  249. package/dist/components/tree-view-entry.js +0 -1
  250. package/dist/components/unordered-list.d.ts +0 -30
  251. package/dist/components/unordered-list.js +0 -1
  252. package/dist/ink/hooks/use-linked-scroll.d.ts +0 -49
  253. package/dist/ink/hooks/use-linked-scroll.js +0 -1
  254. package/dist/packem_shared/ControlledScrollView-Cn4byU2n.js +0 -1
  255. package/dist/packem_shared/FilePicker-BLS9nOPz.js +0 -1
  256. package/dist/packem_shared/InputParser-CtwkCbrQ.js +0 -2
  257. package/dist/packem_shared/ScrollBar-qa1IzDDv.js +0 -1
  258. package/dist/packem_shared/ScrollBarBox-DchESZWv.js +0 -1
  259. package/dist/packem_shared/ScrollList-BBAnRsrC.js +0 -1
  260. package/dist/packem_shared/ScrollView-CHAo7Epj.js +0 -1
  261. package/dist/packem_shared/TreeNodeMap-cJlYqckB.js +0 -1
  262. package/dist/packem_shared/TreeView-BsvLCsf0.js +0 -1
  263. package/dist/packem_shared/TuiApp-BPL8v1i1.js +0 -1
  264. package/dist/packem_shared/app-context-BVpKlG1z.js +0 -1
  265. package/dist/packem_shared/controlled-scroll-view-BVg7ywNW.js +0 -1
  266. package/dist/packem_shared/cursor-helpers.d-BONB9tky.d.ts +0 -12
  267. package/dist/packem_shared/format-time-fjoQHMxD.js +0 -1
  268. package/dist/packem_shared/input.d-CgxV2e8U.d.ts +0 -90
  269. package/dist/packem_shared/line-chart-C7CUrvVs.js +0 -1
  270. package/dist/packem_shared/render-CuQecTAs.js +0 -24
  271. package/dist/packem_shared/renderTreeToBuffer-C8lS0lJ2.js +0 -2
  272. package/dist/packem_shared/scroll-view.d-DtpsgHLg.d.ts +0 -119
  273. package/dist/packem_shared/token-to-elements-D6J6-P2A.js +0 -1
  274. package/dist/packem_shared/treeViewTheme-Dq3ekRAC.js +0 -1
  275. package/dist/packem_shared/useTreeView-D5ifGwG3.js +0 -1
  276. package/dist/packem_shared/useTreeViewState-BiTJakkh.js +0 -1
  277. package/dist/packem_shared/utils-Bup8lyK8.js +0 -1
  278. package/dist/packem_shared/variant-config-BJqpNo7H.js +0 -1
  279. package/dist/packem_shared/variant-config.d-D5NnrrQK.d.ts +0 -2
@@ -1,78 +0,0 @@
1
- import { AnsiColors } from '@visulima/colorize';
2
- import { ReactNode, ReactElement } from 'react';
3
- import { LiteralUnion } from 'type-fest';
4
- type MenuItem = {
5
- /**
6
- * Optional hotkey rendered on the right side of the row (e.g. `"Ctrl+S"`).
7
- */
8
- readonly hotkey?: string;
9
- /**
10
- * Optional icon rendered before the label.
11
- */
12
- readonly icon?: ReactNode;
13
- /**
14
- * Identifier returned by `onSelect`.
15
- */
16
- readonly id: string;
17
- /**
18
- * When true, renders the item dimmed and skips it during navigation.
19
- */
20
- readonly isDisabled?: boolean;
21
- /**
22
- * Human-readable label.
23
- */
24
- readonly label: ReactNode;
25
- };
26
- type MenuSection = {
27
- readonly id: string;
28
- readonly items: ReadonlyArray<MenuItem>;
29
- readonly title?: string;
30
- };
31
- type Props = {
32
- /**
33
- * Accent color for the focused item.
34
- * @default "blue"
35
- */
36
- readonly accentColor?: LiteralUnion<AnsiColors, string>;
37
- /**
38
- * Auto-focus the menu on mount.
39
- */
40
- readonly autoFocus?: boolean;
41
- /**
42
- * Render a border around the menu.
43
- * @default true
44
- */
45
- readonly bordered?: boolean;
46
- /**
47
- * Flat list of items. Ignored if `sections` is provided.
48
- */
49
- readonly items?: ReadonlyArray<MenuItem>;
50
- /**
51
- * Called with the item id when the user presses Enter.
52
- */
53
- readonly onSelect: (id: string) => void;
54
- /**
55
- * Grouped items. Takes precedence over `items`.
56
- */
57
- readonly sections?: ReadonlyArray<MenuSection>;
58
- /**
59
- * Optional title rendered at the top of the menu.
60
- */
61
- readonly title?: string;
62
- };
63
- /**
64
- * Dropdown / context menu with optional sections and disabled items.
65
- * Keyboard: ↑/↓ (or j/k) to navigate, Enter to select, Esc to cancel.
66
- * @returns A `ReactElement` rendering the menu, optionally wrapped in a
67
- * rounded border when `bordered` is true.
68
- */
69
- declare function Menu({
70
- accentColor,
71
- autoFocus,
72
- bordered,
73
- items,
74
- onSelect,
75
- sections,
76
- title
77
- }: Props): ReactElement;
78
- export { Menu, MenuItem, type Props as MenuProps, MenuSection, Props, Menu as default };
@@ -1 +0,0 @@
1
- import{jsxs as b,jsx as l}from"react/jsx-runtime";import{useMemo as g,useState as A,useRef as F,useEffect as j,useCallback as y}from"react";import M from"../ink/hooks/use-focus.js";import $ from"../ink/hooks/use-input.js";import{Box as m}from"./box.js";import{Text as f}from"./text.js";const B=(t,r)=>{if(r&&r.length>0){const o=[];for(const i of r){i.title!==void 0&&o.push({kind:"section-header",sectionId:i.id,title:i.title});for(const d of i.items)o.push({item:d,kind:"item",sectionId:i.id})}return o}return(t??[]).map(o=>({item:o,kind:"item",sectionId:void 0}))},w=(t,r,o)=>{const i=t.length;if(i===0)return r;for(let d=1;d<=i;d+=1){const a=(r+o*d+i*d)%i,h=t[a];if(h?.kind==="item"&&!h.item.isDisabled)return a}return r},I=t=>{for(const[r,o]of t.entries())if(o.kind==="item"&&!o.item.isDisabled)return r;return 0};function W({accentColor:t="blue",autoFocus:r=!1,bordered:o=!0,items:i,onSelect:d,sections:a,title:h}){const{isFocused:p}=M({autoFocus:r}),n=g(()=>B(i,a),[i,a]),S=g(()=>I(n),[n]),[k,v]=A(S),u=F(k);u.current=k,j(()=>{const{current:s}=u,c=n[s];if(!(c?.kind==="item"&&!c.item.isDisabled)){const e=I(n);v(e),u.current=e}},[n]),$(y((s,c)=>{if(p){if(c.downArrow||s==="j")v(w(n,u.current,1));else if(c.upArrow||s==="k")v(w(n,u.current,-1));else if(c.return){const e=n[u.current];e?.kind==="item"&&!e.item.isDisabled&&d(e.item.id)}}},[p,n,d]),{isActive:p});const D=b(m,{flexDirection:"column",children:[h===void 0?void 0:l(m,{marginBottom:1,children:l(f,{bold:!0,color:t,children:h})}),n.map((s,c)=>{if(s.kind==="section-header")return l(m,{marginTop:c===0?0:1,children:l(f,{dimColor:!0,children:s.title.toUpperCase()})},`header:${s.sectionId}`);const{item:e}=s,x=p&&c===k,C=x?t:void 0;return b(m,{children:[l(f,{color:C,dimColor:e.isDisabled,children:x?"▸ ":" "}),e.icon===void 0?void 0:b(f,{color:C,dimColor:e.isDisabled,children:[e.icon," "]}),l(m,{flexGrow:1,flexShrink:1,minWidth:0,children:l(f,{bold:x,color:C,dimColor:e.isDisabled,wrap:"truncate-end",children:e.label})}),e.hotkey===void 0?void 0:l(m,{flexShrink:0,children:b(f,{dimColor:!0,children:[" ",e.hotkey]})})]},`item:${e.id}`)})]});return o?l(m,{borderColor:p?t:void 0,borderStyle:"round",paddingX:1,children:D}):D}export{W as Menu,W as default};
@@ -1,43 +0,0 @@
1
- import { AnsiColors } from '@visulima/colorize';
2
- import { ReactNode, ReactElement } from 'react';
3
- import { LiteralUnion } from 'type-fest';
4
- type MessageRole = "assistant" | "system" | "tool" | "user";
5
- type Props = {
6
- /**
7
- * Bubble body.
8
- */
9
- readonly children: ReactNode;
10
- /**
11
- * Color override.
12
- */
13
- readonly color?: LiteralUnion<AnsiColors, string>;
14
- /**
15
- * When true, draws the bubble without a border.
16
- */
17
- readonly flat?: boolean;
18
- /**
19
- * Text rendered above the bubble (name, model, etc.).
20
- */
21
- readonly label?: string;
22
- /**
23
- * Optional metadata rendered next to the label (e.g. timestamp).
24
- */
25
- readonly meta?: string;
26
- /**
27
- * Determines the alignment, color, and icon of the bubble.
28
- * @default "assistant"
29
- */
30
- readonly role?: MessageRole;
31
- };
32
- /**
33
- * Chat-style message bubble for AI agent UIs.
34
- */
35
- declare function MessageBubble({
36
- children,
37
- color,
38
- flat,
39
- label,
40
- meta,
41
- role
42
- }: Props): ReactElement;
43
- export { MessageBubble, type Props as MessageBubbleProps, MessageRole, Props, MessageBubble as default };
@@ -1 +0,0 @@
1
- import{jsxs as a,jsx as o}from"react/jsx-runtime";import{Box as i}from"./box.js";import{Text as e}from"./text.js";const f={assistant:{align:"flex-start",color:"blueBright",icon:""},system:{align:"flex-start",color:"gray",icon:""},tool:{align:"flex-start",color:"magentaBright",icon:""},user:{align:"flex-end",color:"greenBright",icon:""}};function u({children:r,color:d,flat:s=!1,label:l,meta:n,role:g="assistant"}){const c=f[g],t=d??c.color;return a(i,{alignSelf:c.align,flexDirection:"column",marginBottom:1,children:[l===void 0&&n===void 0?void 0:a(i,{gap:1,paddingX:1,children:[l===void 0?void 0:o(e,{bold:!0,color:t,children:l}),n===void 0?void 0:o(e,{dimColor:!0,children:n})]}),s?a(i,{paddingX:1,children:[o(e,{color:t,children:"│ "}),o(i,{flexDirection:"column",flexGrow:1,children:typeof r=="string"?o(e,{children:r}):r})]}):o(i,{borderColor:t,borderStyle:"round",flexDirection:"column",paddingX:1,children:typeof r=="string"?o(e,{children:r}):r})]})}export{u as MessageBubble,u as default};
@@ -1,39 +0,0 @@
1
- import { AnsiColors } from '@visulima/colorize';
2
- import { ReactNode, ReactElement } from 'react';
3
- import { LiteralUnion } from 'type-fest';
4
- type Props = {
5
- /**
6
- * Background color of the badge.
7
- * @default "magenta"
8
- */
9
- readonly color?: LiteralUnion<AnsiColors, string>;
10
- /**
11
- * Optional icon/symbol (e.g. `✨`, `◈`) shown before the label.
12
- */
13
- readonly icon?: ReactNode;
14
- /**
15
- * Short model identifier, e.g. `claude-opus-4.6`.
16
- */
17
- readonly model: string;
18
- /**
19
- * Optional provider name rendered as a separate chip before the model.
20
- */
21
- readonly provider?: string;
22
- /**
23
- * Visual style.
24
- * @default "solid"
25
- */
26
- readonly variant?: "outline" | "solid" | "subtle";
27
- };
28
- /**
29
- * Pill-shaped chip identifying the active model / provider. Pair with
30
- * `MessageBubble` to label assistant output.
31
- */
32
- declare function ModelBadge({
33
- color,
34
- icon,
35
- model,
36
- provider,
37
- variant
38
- }: Props): ReactElement;
39
- export { ModelBadge, type Props as ModelBadgeProps, Props, ModelBadge as default };
@@ -1 +0,0 @@
1
- import{jsxs as o,jsx as l,Fragment as u}from"react/jsx-runtime";import{Box as m}from"./box.js";import{Text as r}from"./text.js";function g({color:e="magenta",icon:i,model:c,provider:t,variant:a="solid"}){const s=d=>{const n=i===void 0?void 0:o(u,{children:[i," "]});return a==="outline"?l(m,{borderColor:e,borderStyle:"round",paddingX:1,children:o(r,{color:e,children:[n,d]})}):a==="subtle"?o(r,{color:e,children:[n,d]}):o(r,{backgroundColor:e,color:"black",children:[" ",n,d," "]})};return t===void 0?s(c):o(m,{children:[l(r,{dimColor:!0,children:t}),l(r,{dimColor:!0,children:"/"}),s(c)]})}export{g as ModelBadge,g as default};
@@ -1,65 +0,0 @@
1
- import { AnsiColors } from '@visulima/colorize';
2
- import { ReactElement } from 'react';
3
- import { LiteralUnion } from 'type-fest';
4
- type MultiSelectOption = {
5
- readonly key?: string;
6
- readonly label: string;
7
- readonly value: string;
8
- };
9
- type Props = {
10
- /**
11
- * Color for the focused item indicator and selected checkmarks.
12
- * @default "blue"
13
- */
14
- readonly accentColor?: LiteralUnion<AnsiColors, string>;
15
- /**
16
- * Color for unselected, unfocused option labels.
17
- */
18
- readonly defaultColor?: LiteralUnion<AnsiColors, string>;
19
- /**
20
- * Initially selected values.
21
- */
22
- readonly defaultValue?: ReadonlyArray<string>;
23
- /**
24
- * When true, all input is ignored and labels are dimmed.
25
- * @default false
26
- */
27
- readonly isDisabled?: boolean;
28
- /**
29
- * Whether the parent has focus. When false, indicators are dimmed.
30
- * @default true
31
- */
32
- readonly isFocused?: boolean;
33
- /**
34
- * Number of visible options before scrolling.
35
- * When omitted, auto-limits to terminal height.
36
- */
37
- readonly limit?: number;
38
- /**
39
- * Fires when the set of selected values changes (space to toggle).
40
- */
41
- readonly onChange?: (values: ReadonlyArray<string>) => void;
42
- /**
43
- * Fires when the user presses Enter to submit.
44
- */
45
- readonly onSubmit?: (values: ReadonlyArray<string>) => void;
46
- /**
47
- * Available choices to pick from.
48
- */
49
- readonly options: ReadonlyArray<MultiSelectOption>;
50
- };
51
- /**
52
- * Renders a multi-choice selection list with checkboxes and keyboard navigation.
53
- */
54
- declare function MultiSelect({
55
- accentColor,
56
- defaultColor,
57
- defaultValue,
58
- isDisabled,
59
- isFocused,
60
- limit: customLimit,
61
- onChange,
62
- onSubmit,
63
- options
64
- }: Props): ReactElement;
65
- export { MultiSelect, MultiSelectOption, type Props as MultiSelectProps, Props, MultiSelect as default };
@@ -1 +0,0 @@
1
- import{jsx as m,jsxs as S}from"react/jsx-runtime";import{useReducer as V,useState as B,useRef as f,useMemo as E,useCallback as F}from"react";import U from"../ink/hooks/use-input.js";import W from"../ink/hooks/use-window-size.js";import{Box as A}from"./box.js";import{Text as a}from"./text.js";const Y=[],q=(o,u)=>{switch(u.type){case"focus":return{...o,focusedIndex:u.index};case"focus-next":{const i=o.focusedIndex+1,c=i>=o.visibleFrom+u.limit;return{...o,focusedIndex:i,visibleFrom:c?o.visibleFrom+1:o.visibleFrom}}case"focus-prev":{const i=o.focusedIndex-1,c=i<o.visibleFrom;return{...o,focusedIndex:i,visibleFrom:c?o.visibleFrom-1:o.visibleFrom}}default:return o}};function N({accentColor:o="blue",defaultColor:u,defaultValue:i=Y,isDisabled:c=!1,isFocused:v=!0,limit:g,onChange:C,onSubmit:I,options:t}){const{rows:D}=W(),l=Math.min(typeof g=="number"?g:D,t.length),[s,w]=V(q,{focusedIndex:0,visibleFrom:0}),[b,k]=B(i),M=f(b);M.current=b;const j=f(I);j.current=I;const p=f(C);p.current=C;const x=f(s);x.current=s;const T=E(()=>t.slice(s.visibleFrom,s.visibleFrom+l),[t,s.visibleFrom,l]),y=F(()=>{const e=t[x.current.focusedIndex]?.value;e&&k(r=>{const n=r.includes(e)?r.filter(d=>d!==e):[...r,e];return p.current?.(n),n})},[t]),R=F(()=>{k(e=>{const r=e.length===t.length?[]:t.map(n=>n.value);return p.current?.(r),r})},[t]);return U(F((e,r)=>{const{focusedIndex:n}=x.current;(r.downArrow||e==="j")&&n<t.length-1&&w({limit:l,type:"focus-next"}),(r.upArrow||e==="k")&&n>0&&w({limit:l,type:"focus-prev"}),e===" "&&y(),e==="a"&&R(),r.return&&j.current?.(M.current)},[t.length,l,y,R]),{isActive:!c&&v}),m(A,{flexDirection:"column",children:T.map((e,r)=>{const n=s.visibleFrom+r===s.focusedIndex,d=b.includes(e.value);let h=u;return d?h="green":n&&(h=o),S(A,{gap:1,children:[n?m(a,{color:o,dimColor:!v,children:"▸"}):m(a,{children:" "}),S(a,{color:h,dimColor:c,children:[d?"◼":"◻"," ",e.label]}),d?m(a,{color:"green",dimColor:!v,children:"✓"}):void 0]},e.key??e.value)})})}export{N as MultiSelect,N as default};
@@ -1,49 +0,0 @@
1
- import { ReactNode, ReactElement } from 'react';
2
- type OperationStatus = "completed" | "error" | "pending" | "running" | "skipped";
3
- type OperationNode = {
4
- /**
5
- * Nested child operations rendered beneath this node.
6
- */
7
- readonly children?: ReadonlyArray<OperationNode>;
8
- /**
9
- * Optional supplementary info rendered on the next line (dimmed).
10
- */
11
- readonly details?: ReactNode;
12
- /**
13
- * Wall-clock duration in ms, displayed right-aligned.
14
- */
15
- readonly durationMs?: number;
16
- /**
17
- * Unique identifier within the tree.
18
- */
19
- readonly id: string;
20
- /**
21
- * Human-readable label.
22
- */
23
- readonly label: ReactNode;
24
- /**
25
- * Lifecycle state controlling icon + color.
26
- */
27
- readonly status: OperationStatus;
28
- };
29
- type Props = {
30
- /**
31
- * Tree of operations. Each node can have its own children.
32
- */
33
- readonly nodes: ReadonlyArray<OperationNode>;
34
- /**
35
- * When true, runs the running-spinner animation.
36
- * @default true
37
- */
38
- readonly showSpinner?: boolean;
39
- };
40
- /**
41
- * Renders a tree of operations with per-node status. Perfect for agent
42
- * progress panels (reading → editing → running tests → done).
43
- * @returns A `ReactElement` rendering the nested tree of operation rows.
44
- */
45
- declare function OperationTree({
46
- nodes,
47
- showSpinner
48
- }: Props): ReactElement;
49
- export { OperationNode, OperationStatus, OperationTree, type Props as OperationTreeProps, Props, OperationTree as default };
@@ -1 +0,0 @@
1
- import{jsx as n,jsxs as s,Fragment as S}from"react/jsx-runtime";import{Box as t}from"./box.js";import{Spinner as k}from"./spinner.js";import{Text as o}from"./text.js";const w={completed:"green",error:"red",pending:"gray",running:"cyan",skipped:"yellow"},C={completed:"✔",error:"✖",pending:"○",skipped:"⊘"},y=e=>{if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const r=Math.round(e/1e3),i=Math.floor(r/60),d=r%60;return`${i}m ${d}s`},h=({isLast:e,node:r,prefix:i,showSpinner:d})=>{const p=w[r.status],c=e?"└─ ":"├─ ",u=i.length===0?"":c,l=i+(e?" ":"│ "),m=d?n(k,{type:"dots"}):"…",f=r.status==="running"?m:C[r.status];return s(S,{children:[s(t,{children:[n(o,{dimColor:!0,children:i}),n(o,{dimColor:!0,children:u}),n(t,{flexShrink:0,children:n(o,{color:p,children:f})}),n(o,{children:" "}),n(t,{flexGrow:1,flexShrink:1,minWidth:0,children:n(o,{bold:r.status==="running",color:r.status==="pending"?"gray":void 0,dimColor:r.status==="skipped",wrap:"truncate-end",children:r.label})}),r.durationMs===void 0?void 0:n(t,{flexShrink:0,children:s(o,{dimColor:!0,children:[" ",y(r.durationMs)]})})]}),r.details===void 0?void 0:s(t,{children:[n(o,{dimColor:!0,children:l}),n(o,{dimColor:!0,children:r.details})]}),r.children?.map((a,x,g)=>n(h,{isLast:x===g.length-1,node:a,prefix:l,showSpinner:d},a.id))]})};function T({nodes:e,showSpinner:r=!0}){return n(t,{flexDirection:"column",children:e.map((i,d)=>n(h,{isLast:d===e.length-1,node:i,prefix:"",showSpinner:r},i.id))})}export{T as OperationTree,T as default};
@@ -1,47 +0,0 @@
1
- import { AnsiColors } from '@visulima/colorize';
2
- import { ReactNode, ReactElement } from 'react';
3
- import { LiteralUnion } from 'type-fest';
4
- type OptionListEntry = {
5
- readonly description?: string;
6
- readonly icon?: ReactNode;
7
- readonly id: string;
8
- readonly label: ReactNode;
9
- readonly trailing?: ReactNode;
10
- };
11
- type Props = {
12
- /**
13
- * Highlight color for the row marked as current.
14
- */
15
- readonly accentColor?: LiteralUnion<AnsiColors, string>;
16
- /**
17
- * Render the list with a border.
18
- */
19
- readonly bordered?: boolean;
20
- /**
21
- * Id of the row to highlight. No visual change if omitted.
22
- */
23
- readonly currentId?: string;
24
- /**
25
- * Icon width in characters for column alignment.
26
- * @default 2
27
- */
28
- readonly iconColumnWidth?: number;
29
- /**
30
- * Entries to render.
31
- */
32
- readonly options: ReadonlyArray<OptionListEntry>;
33
- };
34
- /**
35
- * Read-only presentational option list. Like `SelectInput` but without focus,
36
- * input handling, or scrolling — just a styled list of rows. Useful inside
37
- * modals, sidebars, or summary panels.
38
- * @returns A `ReactElement` rendering the list; bordered when requested.
39
- */
40
- declare function OptionList({
41
- accentColor,
42
- bordered,
43
- currentId,
44
- iconColumnWidth,
45
- options
46
- }: Props): ReactElement;
47
- export { OptionList, OptionListEntry, type Props as OptionListProps, Props, OptionList as default };
@@ -1 +0,0 @@
1
- import{jsx as i,jsxs as c}from"react/jsx-runtime";import{Box as r}from"./box.js";import{Text as o}from"./text.js";function x({accentColor:a="blue",bordered:h=!1,currentId:s,iconColumnWidth:d=2,options:f}){const l=i(r,{flexDirection:"column",children:f.map(n=>{const e=n.id===s,t=e?a:void 0;return c(r,{flexDirection:"column",children:[c(r,{children:[i(r,{flexShrink:0,width:d,children:i(o,{color:t,children:n.icon??(e?"▸":" ")})}),i(r,{flexGrow:1,flexShrink:1,minWidth:0,children:i(o,{bold:e,color:t,wrap:"truncate-end",children:n.label})}),n.trailing===void 0?void 0:i(r,{flexShrink:0,children:n.trailing})]}),n.description===void 0?void 0:i(r,{marginLeft:d,children:i(o,{dimColor:!0,wrap:"truncate-end",children:n.description})})]},n.id)})});return h?i(r,{borderStyle:"round",paddingX:1,children:l}):l}export{x as OptionList,x as default};
@@ -1,24 +0,0 @@
1
- import { ReactNode, ReactElement } from 'react';
2
- type OrderedListEntry = {
3
- /**
4
- * Nested sub-items, rendered as a sub-list with hierarchical numbering.
5
- */
6
- readonly children?: ReadonlyArray<OrderedListEntry>;
7
- /**
8
- * Display text for this item.
9
- */
10
- readonly label: ReactNode;
11
- };
12
- type Props = {
13
- /**
14
- * Entries to render as a numbered list.
15
- */
16
- readonly items: ReadonlyArray<OrderedListEntry>;
17
- };
18
- /**
19
- * Renders a numbered list with hierarchical nesting support.
20
- */
21
- declare function OrderedList({
22
- items
23
- }: Props): ReactElement;
24
- export { OrderedList, OrderedListEntry, type Props as OrderedListProps, Props, OrderedList as default };
@@ -1 +0,0 @@
1
- import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Box as n}from"./box.js";import{Text as c}from"./text.js";const d=(r,s)=>{const m=String(r.length).length;return e(n,{flexDirection:"column",children:r.map((t,i)=>{const a=`${String(i+1).padStart(m)}.`,o=`${s}${a}`;return l(n,{gap:1,children:[e(c,{dimColor:!0,children:o}),l(n,{flexDirection:"column",children:[e(c,{children:t.label}),t.children?d(t.children,o):void 0]})]},i)})})};function f({items:r}){return d(r,"")}export{f as OrderedList,f as default};
@@ -1,69 +0,0 @@
1
- import { ReactNode, ReactElement } from 'react';
2
- /**
3
- * Metadata about the current page state, passed to the render-prop children.
4
- */
5
- type PageMeta = {
6
- readonly currentPage: number;
7
- readonly endIndex: number;
8
- readonly isFirstPage: boolean;
9
- readonly isLastPage: boolean;
10
- readonly startIndex: number;
11
- readonly totalPages: number;
12
- };
13
- type Props<T> = {
14
- /**
15
- * Render-prop that receives the current page items and page metadata.
16
- */
17
- readonly children: (pageItems: ReadonlyArray<T>, meta: PageMeta) => ReactNode;
18
- /**
19
- * Uncontrolled initial page (0-indexed).
20
- * @default 0
21
- */
22
- readonly defaultPage?: number;
23
- /**
24
- * Color for the active page indicator.
25
- * @default "cyan"
26
- */
27
- readonly indicatorColor?: string;
28
- /**
29
- * Whether keyboard navigation is active.
30
- * @default true
31
- */
32
- readonly isFocused?: boolean;
33
- /**
34
- * The full list of items to paginate.
35
- */
36
- readonly items: ReadonlyArray<T>;
37
- /**
38
- * Called when the page changes.
39
- */
40
- readonly onChange?: (page: number) => void;
41
- /**
42
- * Controlled current page (0-indexed). When provided, the component is controlled.
43
- */
44
- readonly page?: number;
45
- /**
46
- * Number of items per page.
47
- */
48
- readonly pageSize: number;
49
- /**
50
- * Indicator style.
51
- * - `"dots"`: `● ○ ○ ○`
52
- * - `"numeric"`: `‹ 1 / 4 ›`
53
- * - `"fraction"`: `1/4`
54
- * @default "dots"
55
- */
56
- readonly style?: "dots" | "fraction" | "numeric";
57
- };
58
- declare const Paginator: <T>({
59
- children,
60
- defaultPage,
61
- indicatorColor,
62
- isFocused,
63
- items,
64
- onChange,
65
- page: controlledPage,
66
- pageSize,
67
- style
68
- }: Props<T>) => ReactElement;
69
- export { PageMeta, Paginator, type Props as PaginatorProps, Props, Paginator as default };
@@ -1 +0,0 @@
1
- import{jsxs as m,jsx as r}from"react/jsx-runtime";import{useState as j,useCallback as M}from"react";import k from"../ink/hooks/use-input.js";import{Box as p}from"./box.js";import{Text as e}from"./text.js";const D=({color:i,currentPage:c,style:u,totalPages:l})=>{if(u==="fraction")return m(e,{children:[r(e,{color:i,children:c+1}),m(e,{dimColor:!0,children:["/",l]})]});if(u==="numeric"){const h=c>0?r(e,{color:i,children:"‹ "}):r(e,{dimColor:!0,children:"‹ "}),n=c<l-1?r(e,{color:i,children:" ›"}):r(e,{dimColor:!0,children:" ›"});return m(p,{children:[h,r(e,{color:i,children:c+1}),m(e,{dimColor:!0,children:[" ","/",l]}),n]})}const d=Array.from({length:l},(h,n)=>n===c?r(e,{color:i,children:"●"},n):r(e,{dimColor:!0,children:"○"},n));return r(p,{gap:1,children:d})},L=({children:i,defaultPage:c=0,indicatorColor:u="cyan",isFocused:l=!0,items:d,onChange:h,page:n,pageSize:g,style:y="dots"})=>{const f=n!==void 0,[w,A]=j(c),v=f?n:w,o=Math.max(1,Math.ceil(d.length/g)),a=Math.max(0,Math.min(v,o-1)),s=M(C=>{const t=Math.max(0,Math.min(C,o-1));f||A(t),h?.(t)},[o,f,h]);k(M((C,t)=>{t.leftArrow||t.pageUp?s(a-1):t.rightArrow||t.pageDown?s(a+1):t.home?s(0):t.end&&s(o-1)},[a,o,s]),{isActive:l});const x=a*g,P=Math.min(x+g,d.length),I=d.slice(x,P),b={currentPage:a,endIndex:P,isFirstPage:a===0,isLastPage:a===o-1,startIndex:x,totalPages:o};return m(p,{flexDirection:"column",children:[i(I,b),o>1&&r(D,{color:u,currentPage:a,style:y,totalPages:o})]})};export{L as Paginator,L as default};
@@ -1,38 +0,0 @@
1
- import { AnsiColors } from '@visulima/colorize';
2
- import { ReactNode, ReactElement } from 'react';
3
- import { LiteralUnion } from 'type-fest';
4
- type Props = {
5
- /**
6
- * Paragraph body.
7
- */
8
- readonly children: ReactNode;
9
- /**
10
- * Foreground color.
11
- */
12
- readonly color?: LiteralUnion<AnsiColors, string>;
13
- /**
14
- * Render the paragraph with dim color.
15
- */
16
- readonly dimColor?: boolean;
17
- /**
18
- * Blank lines to add after the paragraph.
19
- * @default 1
20
- */
21
- readonly marginBottom?: number;
22
- /**
23
- * Blank lines to add before the paragraph.
24
- * @default 0
25
- */
26
- readonly marginTop?: number;
27
- };
28
- /**
29
- * Wraps body text with a trailing blank line. Useful for README-style layouts.
30
- */
31
- declare function Paragraph({
32
- children,
33
- color,
34
- dimColor,
35
- marginBottom,
36
- marginTop
37
- }: Props): ReactElement;
38
- export { Paragraph, type Props as ParagraphProps, Props, Paragraph as default };
@@ -1 +0,0 @@
1
- import{jsx as o}from"react/jsx-runtime";import{Box as t}from"./box.js";import{Text as l}from"./text.js";function p({children:r,color:i,dimColor:m=!1,marginBottom:a=1,marginTop:n=0}){return o(t,{flexDirection:"column",marginBottom:a,marginTop:n,children:o(l,{color:i,dimColor:m,children:r})})}export{p as Paragraph,p as default};
@@ -1,55 +0,0 @@
1
- import { AnsiColors } from '@visulima/colorize';
2
- import { ReactElement } from 'react';
3
- import { LiteralUnion } from 'type-fest';
4
- type Props = {
5
- /**
6
- * Whether to pulse the skeleton blocks (shimmer).
7
- * @default true
8
- */
9
- readonly animated?: boolean;
10
- /**
11
- * Glyph repeated to fill each placeholder block.
12
- * @default "█" (full block)
13
- */
14
- readonly character?: string;
15
- /**
16
- * Block color.
17
- * @default "gray"
18
- */
19
- readonly color?: LiteralUnion<AnsiColors, string>;
20
- /**
21
- * Milliseconds between pulses.
22
- * @default 500
23
- */
24
- readonly interval?: number;
25
- /**
26
- * Number of skeleton rows to render.
27
- * @default 3
28
- */
29
- readonly rows?: number;
30
- /**
31
- * Total width reference. When omitted, the block flexes to fill its
32
- * parent.
33
- */
34
- readonly width?: number;
35
- /**
36
- * Relative widths of each row (0–1). The list is sampled cyclically.
37
- * @default [1, 0.85, 0.6]
38
- */
39
- readonly widths?: ReadonlyArray<number>;
40
- };
41
- /**
42
- * Skeleton loading indicator. Renders a stack of solid blocks whose widths
43
- * vary to mimic text placeholders. Pair with `async` data fetching.
44
- * @returns A `ReactElement` rendering the skeleton rows.
45
- */
46
- declare function Placeholder({
47
- animated,
48
- character,
49
- color,
50
- interval,
51
- rows,
52
- width,
53
- widths
54
- }: Props): ReactElement;
55
- export { Placeholder, type Props as PlaceholderProps, Props, Placeholder as default };
@@ -1 +0,0 @@
1
- import{jsx as t}from"react/jsx-runtime";import w from"../ink/hooks/use-animation.js";import g from"../ink/hooks/use-window-size.js";import{Box as i}from"./box.js";import{Text as v}from"./text.js";const y=[1,.85,.6];function C({animated:o=!0,character:l="█",color:m="gray",interval:c=500,rows:h=3,width:e,widths:r=y}){const{frame:d}=w({interval:c,isActive:o}),{columns:s}=g(),f=o&&d%2===0,u=e??Math.max(1,s);return t(i,{flexDirection:"column",width:e,children:Array.from({length:h},(M,a)=>{const p=r.length>0?r[a%r.length]??1:1,n=Math.max(1,Math.round(u*p)),x=l.repeat(n);return t(i,{width:n,children:t(v,{color:m,dimColor:f,wrap:"truncate-end",children:x})},a)})})}export{C as Placeholder,C as default};
@@ -1,56 +0,0 @@
1
- import { ReactElement } from 'react';
2
- import { Props as Props$1 } from "./text.js";
3
- import '@visulima/colorize';
4
- import 'type-fest';
5
- import "../packem_shared/styles.d-cMo36xQz.js";
6
- import 'cli-boxes';
7
- import 'yoga-layout';
8
- type Props = {
9
- /** Fill glyph repeated across the completed portion of the progress bar. Defaults to "█". */
10
- readonly character?: string;
11
- /**
12
- * Override the terminal width used for calculation.
13
- * When 0, uses the actual terminal width.
14
- * @default 0
15
- */
16
- readonly columns?: number;
17
- /**
18
- * Number of columns reserved on the left side (e.g. for labels).
19
- * @default 0
20
- */
21
- readonly left?: number;
22
- /**
23
- * Completion percentage between 0 and 1.
24
- * @default 1
25
- */
26
- readonly percent?: number;
27
- /**
28
- * Number of columns reserved on the right side (e.g. for percentage text).
29
- * @default 0
30
- */
31
- readonly right?: number;
32
- /**
33
- * Whether to pad the remaining space with whitespace.
34
- * Useful when rendering the bar over a background color.
35
- * @default false
36
- */
37
- readonly rightPad?: boolean;
38
- } & Omit<Props$1, "children">;
39
- /**
40
- * A terminal progress bar that fills proportionally to a percentage value.
41
- *
42
- * ```tsx
43
- * &lt;ProgressBar percent={0.5} />
44
- * &lt;ProgressBar percent={0.75} color="green" left={10} right={5} />
45
- * ```
46
- */
47
- declare function ProgressBar({
48
- character,
49
- columns: columnsProp,
50
- left,
51
- percent,
52
- right,
53
- rightPad,
54
- ...textProps
55
- }: Props): ReactElement;
56
- export { ProgressBar, type Props as ProgressBarProps, Props, ProgressBar as default };
@@ -1 +0,0 @@
1
- import{jsx as f}from"react/jsx-runtime";import l from"../ink/hooks/use-window-size.js";import{Text as p}from"./text.js";function d({character:a="█",columns:e=0,left:o=0,percent:m=1,right:i=0,rightPad:n=!1,...s}){const{columns:c}=l(),r=Math.max(0,(e||c||80)-i-o),t=Math.min(Math.floor(r*Math.max(0,Math.min(1,m))),r),h=a.repeat(t)+(n?" ".repeat(r-t):"");return f(p,{...s,children:h})}export{d as ProgressBar,d as default};