@visulima/tui-kit 0.0.0 → 1.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 (371) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/LICENSE.md +2095 -0
  3. package/README.md +115 -29
  4. package/dist/accordion.d.ts +59 -0
  5. package/dist/accordion.js +1 -0
  6. package/dist/alert.d.ts +26 -0
  7. package/dist/alert.js +1 -0
  8. package/dist/animate-presence.d.ts +18 -0
  9. package/dist/animate-presence.js +1 -0
  10. package/dist/approval-prompt.d.ts +65 -0
  11. package/dist/approval-prompt.js +1 -0
  12. package/dist/area-chart.d.ts +66 -0
  13. package/dist/area-chart.js +1 -0
  14. package/dist/badge.d.ts +22 -0
  15. package/dist/badge.js +1 -0
  16. package/dist/bar-chart.d.ts +67 -0
  17. package/dist/bar-chart.js +1 -0
  18. package/dist/big-text.d.ts +81 -0
  19. package/dist/big-text.js +1 -0
  20. package/dist/blink-dot.d.ts +36 -0
  21. package/dist/blink-dot.js +1 -0
  22. package/dist/breadcrumb.d.ts +33 -0
  23. package/dist/breadcrumb.js +1 -0
  24. package/dist/button.d.ts +45 -0
  25. package/dist/button.js +1 -0
  26. package/dist/calendar.d.ts +72 -0
  27. package/dist/calendar.js +1 -0
  28. package/dist/card.d.ts +57 -0
  29. package/dist/card.js +1 -0
  30. package/dist/checkbox-group.d.ts +59 -0
  31. package/dist/checkbox-group.js +1 -0
  32. package/dist/checkbox.d.ts +48 -0
  33. package/dist/checkbox.js +1 -0
  34. package/dist/code.d.ts +48 -0
  35. package/dist/code.js +2 -0
  36. package/dist/collapsible.d.ts +53 -0
  37. package/dist/collapsible.js +1 -0
  38. package/dist/color-picker.d.ts +71 -0
  39. package/dist/color-picker.js +1 -0
  40. package/dist/command-block.d.ts +47 -0
  41. package/dist/command-block.js +4 -0
  42. package/dist/command-palette.d.ts +82 -0
  43. package/dist/command-palette.js +1 -0
  44. package/dist/confirm-dialog.d.ts +75 -0
  45. package/dist/confirm-dialog.js +1 -0
  46. package/dist/confirm-input.d.ts +38 -0
  47. package/dist/confirm-input.js +1 -0
  48. package/dist/console-overlay.d.ts +54 -0
  49. package/dist/console-overlay.js +1 -0
  50. package/dist/content-switcher.d.ts +57 -0
  51. package/dist/content-switcher.js +1 -0
  52. package/dist/controlled-scroll-view.d.ts +3 -0
  53. package/dist/controlled-scroll-view.js +1 -0
  54. package/dist/data-grid.d.ts +49 -0
  55. package/dist/data-grid.js +1 -0
  56. package/dist/date-picker.d.ts +65 -0
  57. package/dist/date-picker.js +1 -0
  58. package/dist/definition-list.d.ts +44 -0
  59. package/dist/definition-list.js +1 -0
  60. package/dist/dialog.d.ts +110 -0
  61. package/dist/dialog.js +1 -0
  62. package/dist/diff-view.d.ts +85 -0
  63. package/dist/diff-view.js +1 -0
  64. package/dist/digits.d.ts +30 -0
  65. package/dist/digits.js +1 -0
  66. package/dist/directory-tree.d.ts +51 -0
  67. package/dist/directory-tree.js +1 -0
  68. package/dist/divider.d.ts +49 -0
  69. package/dist/divider.js +1 -0
  70. package/dist/drawer.d.ts +53 -0
  71. package/dist/drawer.js +1 -0
  72. package/dist/file-change.d.ts +40 -0
  73. package/dist/file-change.js +1 -0
  74. package/dist/file-picker-entry.d.ts +2 -0
  75. package/dist/file-picker-entry.js +1 -0
  76. package/dist/form.d.ts +81 -0
  77. package/dist/form.js +1 -0
  78. package/dist/gauge.d.ts +87 -0
  79. package/dist/gauge.js +1 -0
  80. package/dist/gradient.d.ts +42 -0
  81. package/dist/gradient.js +1 -0
  82. package/dist/grid.d.ts +40 -0
  83. package/dist/grid.js +1 -0
  84. package/dist/heading.d.ts +33 -0
  85. package/dist/heading.js +1 -0
  86. package/dist/heatmap.d.ts +62 -0
  87. package/dist/heatmap.js +1 -0
  88. package/dist/help.d.ts +52 -0
  89. package/dist/help.js +1 -0
  90. package/dist/histogram.d.ts +62 -0
  91. package/dist/histogram.js +1 -0
  92. package/dist/image.d.ts +26 -0
  93. package/dist/image.js +1 -0
  94. package/dist/index.d.ts +125 -0
  95. package/dist/index.js +1 -0
  96. package/dist/json.d.ts +58 -0
  97. package/dist/json.js +1 -0
  98. package/dist/kbd.d.ts +31 -0
  99. package/dist/kbd.js +1 -0
  100. package/dist/line-chart.d.ts +109 -0
  101. package/dist/line-chart.js +1 -0
  102. package/dist/link.d.ts +38 -0
  103. package/dist/link.js +1 -0
  104. package/dist/loading-indicator.d.ts +29 -0
  105. package/dist/loading-indicator.js +1 -0
  106. package/dist/log.d.ts +38 -0
  107. package/dist/log.js +1 -0
  108. package/dist/markdown.d.ts +40 -0
  109. package/dist/markdown.js +1 -0
  110. package/dist/masked-input.d.ts +50 -0
  111. package/dist/masked-input.js +1 -0
  112. package/dist/menu.d.ts +78 -0
  113. package/dist/menu.js +1 -0
  114. package/dist/message-bubble.d.ts +43 -0
  115. package/dist/message-bubble.js +1 -0
  116. package/dist/model-badge.d.ts +39 -0
  117. package/dist/model-badge.js +1 -0
  118. package/dist/model-selector.d.ts +52 -0
  119. package/dist/model-selector.js +1 -0
  120. package/dist/multi-progress.d.ts +55 -0
  121. package/dist/multi-progress.js +1 -0
  122. package/dist/multi-select.d.ts +65 -0
  123. package/dist/multi-select.js +1 -0
  124. package/dist/notification-badge.d.ts +47 -0
  125. package/dist/notification-badge.js +1 -0
  126. package/dist/number-input.d.ts +85 -0
  127. package/dist/number-input.js +1 -0
  128. package/dist/operation-tree.d.ts +49 -0
  129. package/dist/operation-tree.js +1 -0
  130. package/dist/option-list.d.ts +47 -0
  131. package/dist/option-list.js +1 -0
  132. package/dist/ordered-list.d.ts +24 -0
  133. package/dist/ordered-list.js +1 -0
  134. package/dist/packem_shared/ControlledScrollView-BzlbIUph.js +1 -0
  135. package/dist/packem_shared/FilePicker-V5H2fb-v.js +1 -0
  136. package/dist/packem_shared/ScrollBar-C9i3z3Ft.js +1 -0
  137. package/dist/packem_shared/ScrollBarBox-DZEC8YnV.js +1 -0
  138. package/dist/packem_shared/ScrollList-Djtb2vVy.js +1 -0
  139. package/dist/packem_shared/ScrollView-ESxpl6Hy.js +1 -0
  140. package/dist/packem_shared/TreeNodeMap-cJlYqckB.js +1 -0
  141. package/dist/packem_shared/TreeView-q0l446NV.js +1 -0
  142. package/dist/packem_shared/controlled-scroll-view-DerVKKv6.js +1 -0
  143. package/dist/packem_shared/controlled-scroll-view.d-vF4wevEJ.d.ts +54 -0
  144. package/dist/packem_shared/file-picker.d-Cie6aAMD.d.ts +104 -0
  145. package/dist/packem_shared/line-chart-BbhMhcZg.js +1 -0
  146. package/dist/packem_shared/scroll-bar-box.d-DSBbBsRc.d.ts +30 -0
  147. package/dist/packem_shared/scroll-bar.d-B4sD1hBR.d.ts +18 -0
  148. package/dist/packem_shared/scroll-list.d-BP0UZSY4.d.ts +12 -0
  149. package/dist/packem_shared/scroll-view.d-BqKpI-F-.d.ts +119 -0
  150. package/dist/packem_shared/treeViewTheme-Dq3ekRAC.js +1 -0
  151. package/dist/packem_shared/use-tree-view.d-dXTKoDPM.d.ts +350 -0
  152. package/dist/packem_shared/useTreeView-D0JEqT6W.js +1 -0
  153. package/dist/packem_shared/useTreeViewState-BiTJakkh.js +1 -0
  154. package/dist/packem_shared/variant-config-BJqpNo7H.js +1 -0
  155. package/dist/packem_shared/variant-config.d-D5NnrrQK.d.ts +2 -0
  156. package/dist/paginator.d.ts +69 -0
  157. package/dist/paginator.js +1 -0
  158. package/dist/paragraph.d.ts +38 -0
  159. package/dist/paragraph.js +1 -0
  160. package/dist/path-input.d.ts +67 -0
  161. package/dist/path-input.js +1 -0
  162. package/dist/pie-chart.d.ts +50 -0
  163. package/dist/pie-chart.js +1 -0
  164. package/dist/placeholder.d.ts +55 -0
  165. package/dist/placeholder.js +1 -0
  166. package/dist/popover.d.ts +46 -0
  167. package/dist/popover.js +1 -0
  168. package/dist/progress-bar.d.ts +51 -0
  169. package/dist/progress-bar.js +1 -0
  170. package/dist/progress-circle.d.ts +59 -0
  171. package/dist/progress-circle.js +1 -0
  172. package/dist/qr-code.d.ts +45 -0
  173. package/dist/qr-code.js +1 -0
  174. package/dist/r/accordion.json +24 -0
  175. package/dist/r/alert.json +24 -0
  176. package/dist/r/animate-presence.json +22 -0
  177. package/dist/r/approval-prompt.json +24 -0
  178. package/dist/r/area-chart.json +27 -0
  179. package/dist/r/badge.json +24 -0
  180. package/dist/r/bar-chart.json +24 -0
  181. package/dist/r/big-text.json +23 -0
  182. package/dist/r/blink-dot.json +24 -0
  183. package/dist/r/breadcrumb.json +24 -0
  184. package/dist/r/button.json +24 -0
  185. package/dist/r/calendar.json +24 -0
  186. package/dist/r/card.json +26 -0
  187. package/dist/r/chart-utils.json +24 -0
  188. package/dist/r/checkbox-group.json +24 -0
  189. package/dist/r/checkbox.json +24 -0
  190. package/dist/r/code.json +23 -0
  191. package/dist/r/collapsible.json +24 -0
  192. package/dist/r/color-picker.json +24 -0
  193. package/dist/r/command-block.json +26 -0
  194. package/dist/r/command-palette.json +24 -0
  195. package/dist/r/confirm-dialog.json +24 -0
  196. package/dist/r/confirm-input.json +22 -0
  197. package/dist/r/console-overlay.json +22 -0
  198. package/dist/r/content-switcher.json +24 -0
  199. package/dist/r/controlled-scroll-view.json +24 -0
  200. package/dist/r/data-grid.json +24 -0
  201. package/dist/r/date-picker.json +26 -0
  202. package/dist/r/definition-list.json +24 -0
  203. package/dist/r/dialog.json +24 -0
  204. package/dist/r/diff-view.json +24 -0
  205. package/dist/r/digits.json +24 -0
  206. package/dist/r/directory-tree.json +24 -0
  207. package/dist/r/divider.json +24 -0
  208. package/dist/r/drawer.json +24 -0
  209. package/dist/r/file-change.json +24 -0
  210. package/dist/r/file-picker.json +44 -0
  211. package/dist/r/form.json +24 -0
  212. package/dist/r/gauge.json +24 -0
  213. package/dist/r/gradient.json +24 -0
  214. package/dist/r/grid.json +22 -0
  215. package/dist/r/heading.json +24 -0
  216. package/dist/r/heatmap.json +24 -0
  217. package/dist/r/help.json +22 -0
  218. package/dist/r/histogram.json +26 -0
  219. package/dist/r/image.json +24 -0
  220. package/dist/r/json.json +24 -0
  221. package/dist/r/kbd.json +24 -0
  222. package/dist/r/line-chart.json +26 -0
  223. package/dist/r/link.json +23 -0
  224. package/dist/r/loading-indicator.json +27 -0
  225. package/dist/r/log.json +24 -0
  226. package/dist/r/markdown.json +29 -0
  227. package/dist/r/masked-input.json +22 -0
  228. package/dist/r/menu.json +24 -0
  229. package/dist/r/message-bubble.json +24 -0
  230. package/dist/r/model-badge.json +24 -0
  231. package/dist/r/model-selector.json +24 -0
  232. package/dist/r/multi-progress.json +24 -0
  233. package/dist/r/multi-select.json +24 -0
  234. package/dist/r/notification-badge.json +24 -0
  235. package/dist/r/number-input.json +24 -0
  236. package/dist/r/operation-tree.json +26 -0
  237. package/dist/r/option-list.json +24 -0
  238. package/dist/r/ordered-list.json +22 -0
  239. package/dist/r/paginator.json +22 -0
  240. package/dist/r/paragraph.json +24 -0
  241. package/dist/r/path-input.json +26 -0
  242. package/dist/r/pie-chart.json +24 -0
  243. package/dist/r/placeholder.json +24 -0
  244. package/dist/r/popover.json +24 -0
  245. package/dist/r/progress-bar.json +22 -0
  246. package/dist/r/progress-circle.json +24 -0
  247. package/dist/r/qr-code.json +24 -0
  248. package/dist/r/radio-group.json +24 -0
  249. package/dist/r/registry.json +1051 -0
  250. package/dist/r/scatter-plot.json +27 -0
  251. package/dist/r/scroll-bar-box.json +24 -0
  252. package/dist/r/scroll-bar.json +24 -0
  253. package/dist/r/scroll-list.json +24 -0
  254. package/dist/r/scroll-view.json +24 -0
  255. package/dist/r/scroll.json +58 -0
  256. package/dist/r/search-input.json +26 -0
  257. package/dist/r/select-input-indicator.json +24 -0
  258. package/dist/r/select-input-item.json +24 -0
  259. package/dist/r/select-input.json +28 -0
  260. package/dist/r/shimmer-text.json +24 -0
  261. package/dist/r/sidebar.json +24 -0
  262. package/dist/r/slider.json +24 -0
  263. package/dist/r/sparkline.json +24 -0
  264. package/dist/r/spinner.json +23 -0
  265. package/dist/r/status-line.json +24 -0
  266. package/dist/r/status-message.json +24 -0
  267. package/dist/r/stepper.json +24 -0
  268. package/dist/r/stopwatch.json +22 -0
  269. package/dist/r/streaming-text.json +24 -0
  270. package/dist/r/switch.json +24 -0
  271. package/dist/r/tab.json +22 -0
  272. package/dist/r/table.json +23 -0
  273. package/dist/r/tabs.json +26 -0
  274. package/dist/r/tag-input.json +24 -0
  275. package/dist/r/tag.json +24 -0
  276. package/dist/r/text-input.json +22 -0
  277. package/dist/r/textarea.json +22 -0
  278. package/dist/r/thinking-block.json +24 -0
  279. package/dist/r/time-picker.json +24 -0
  280. package/dist/r/timer.json +22 -0
  281. package/dist/r/toast.json +24 -0
  282. package/dist/r/token-usage.json +24 -0
  283. package/dist/r/tool-call.json +24 -0
  284. package/dist/r/tooltip.json +24 -0
  285. package/dist/r/transition.json +22 -0
  286. package/dist/r/tree-select.json +24 -0
  287. package/dist/r/tree-view.json +64 -0
  288. package/dist/r/unordered-list.json +22 -0
  289. package/dist/r/use-linked-scroll.json +24 -0
  290. package/dist/r/variant-config.json +22 -0
  291. package/dist/radio-group.d.ts +74 -0
  292. package/dist/radio-group.js +1 -0
  293. package/dist/scatter-plot.d.ts +35 -0
  294. package/dist/scatter-plot.js +1 -0
  295. package/dist/scroll-bar-box.d.ts +3 -0
  296. package/dist/scroll-bar-box.js +1 -0
  297. package/dist/scroll-bar.d.ts +3 -0
  298. package/dist/scroll-bar.js +1 -0
  299. package/dist/scroll-list.d.ts +4 -0
  300. package/dist/scroll-list.js +1 -0
  301. package/dist/scroll-view.d.ts +3 -0
  302. package/dist/scroll-view.js +1 -0
  303. package/dist/search-input.d.ts +55 -0
  304. package/dist/search-input.js +1 -0
  305. package/dist/select-input-indicator.d.ts +32 -0
  306. package/dist/select-input-indicator.js +1 -0
  307. package/dist/select-input-item.d.ts +41 -0
  308. package/dist/select-input-item.js +1 -0
  309. package/dist/select-input.d.ts +110 -0
  310. package/dist/select-input.js +1 -0
  311. package/dist/shimmer-text.d.ts +47 -0
  312. package/dist/shimmer-text.js +1 -0
  313. package/dist/sidebar.d.ts +47 -0
  314. package/dist/sidebar.js +1 -0
  315. package/dist/slider.d.ts +103 -0
  316. package/dist/slider.js +1 -0
  317. package/dist/sparkline.d.ts +42 -0
  318. package/dist/sparkline.js +1 -0
  319. package/dist/spinner.d.ts +17 -0
  320. package/dist/spinner.js +1 -0
  321. package/dist/status-line.d.ts +37 -0
  322. package/dist/status-line.js +1 -0
  323. package/dist/status-message.d.ts +21 -0
  324. package/dist/status-message.js +1 -0
  325. package/dist/stepper.d.ts +48 -0
  326. package/dist/stepper.js +1 -0
  327. package/dist/stopwatch.d.ts +49 -0
  328. package/dist/stopwatch.js +1 -0
  329. package/dist/streaming-text.d.ts +46 -0
  330. package/dist/streaming-text.js +1 -0
  331. package/dist/switch.d.ts +55 -0
  332. package/dist/switch.js +1 -0
  333. package/dist/tab.d.ts +19 -0
  334. package/dist/tab.js +1 -0
  335. package/dist/table.d.ts +119 -0
  336. package/dist/table.js +1 -0
  337. package/dist/tabs.d.ts +107 -0
  338. package/dist/tabs.js +1 -0
  339. package/dist/tag-input.d.ts +71 -0
  340. package/dist/tag-input.js +1 -0
  341. package/dist/tag.d.ts +35 -0
  342. package/dist/tag.js +1 -0
  343. package/dist/text-input.d.ts +48 -0
  344. package/dist/text-input.js +1 -0
  345. package/dist/textarea.d.ts +68 -0
  346. package/dist/textarea.js +2 -0
  347. package/dist/thinking-block.d.ts +57 -0
  348. package/dist/thinking-block.js +1 -0
  349. package/dist/time-picker.d.ts +67 -0
  350. package/dist/time-picker.js +1 -0
  351. package/dist/timer.d.ts +59 -0
  352. package/dist/timer.js +1 -0
  353. package/dist/toast.d.ts +49 -0
  354. package/dist/toast.js +1 -0
  355. package/dist/token-usage.d.ts +50 -0
  356. package/dist/token-usage.js +1 -0
  357. package/dist/tool-call.d.ts +33 -0
  358. package/dist/tool-call.js +1 -0
  359. package/dist/tooltip.d.ts +43 -0
  360. package/dist/tooltip.js +1 -0
  361. package/dist/transition.d.ts +74 -0
  362. package/dist/transition.js +1 -0
  363. package/dist/tree-select.d.ts +65 -0
  364. package/dist/tree-select.js +1 -0
  365. package/dist/tree-view-entry.d.ts +4 -0
  366. package/dist/tree-view-entry.js +1 -0
  367. package/dist/unordered-list.d.ts +30 -0
  368. package/dist/unordered-list.js +1 -0
  369. package/dist/use-linked-scroll.d.ts +42 -0
  370. package/dist/use-linked-scroll.js +1 -0
  371. package/package.json +553 -7
@@ -0,0 +1 @@
1
+ import{jsxs as a,jsx as n}from"react/jsx-runtime";import d from"@visulima/tui/components/box";import t from"@visulima/tui/components/text";import M from"@visulima/tui/hooks/use-focus";import S from"@visulima/tui/hooks/use-input";import{isInsertableInput as T}from"@visulima/tui/input";import{useState as y,useRef as D,useMemo as F,useEffect as A,useCallback as L}from"react";const j=(m,f)=>{if(m.length===0)return 1;const p=[f.label,f.description??"",...f.keywords??[]].map(i=>i.toLowerCase()).filter(i=>i.length>0),h=m.toLowerCase();let s=0;for(const i of p){if(i.includes(h)){const u=i.indexOf(h);s=Math.max(s,100-u);continue}let x=0,g=0;for(const u of h){const c=i.indexOf(u,x);if(c===-1){g=0;break}g+=1,x=c+1}g===h.length&&(s=Math.max(s,20))}return s};function P({accentColor:m="cyan",autoFocus:f=!0,commands:p,emptyText:h="No results",limit:s=8,onCancel:i,onSelect:x,placeholder:g="Type a command or search..."}){const{isFocused:u}=M({autoFocus:f}),[c,k]=y(""),[w,C]=y(0),b=D(w);b.current=w;const l=F(()=>{const e=p.map(r=>({command:r,score:j(c,r)})).filter(({score:r})=>r>0);return e.sort((r,o)=>o.score-r.score),e.slice(0,s).map(({command:r})=>r)},[p,c,s]);return A(()=>{const e=Math.max(0,l.length-1);b.current>e&&(b.current=e,C(e))},[l]),S(L((e,r)=>{if(u){if(r.escape){i?.();return}if(r.downArrow){if(l.length===0)return;C(o=>Math.min(l.length-1,o+1));return}if(r.upArrow){C(o=>Math.max(0,o-1));return}if(r.return){const o=l[b.current];o&&x(o.id,c);return}if(r.backspace||r.delete){k(o=>o.slice(0,-1)),C(0);return}T(e,r)&&(k(o=>o+e),C(0))}},[u,l,c,x,i]),{isActive:u}),a(d,{borderColor:m,borderStyle:"round",flexDirection:"column",paddingX:1,children:[a(d,{children:[n(t,{color:m,children:"❯"}),a(t,{children:[" ",c.length===0?n(t,{dimColor:!0,children:g}):c]}),n(t,{inverse:!0,children:" "})]}),n(d,{marginTop:1,children:a(t,{dimColor:!0,children:[l.length," of ",p.length]})}),n(d,{flexDirection:"column",marginTop:1,children:l.length===0?n(t,{dimColor:!0,children:h}):l.map((e,r)=>{const o=r===w,v=o?m:void 0;return a(d,{flexDirection:"column",children:[a(d,{children:[n(t,{color:v,children:o?"▸ ":" "}),e.icon===void 0?void 0:a(t,{color:v,children:[e.icon," "]}),n(d,{flexGrow:1,flexShrink:1,minWidth:0,children:n(t,{bold:o,color:v,wrap:"truncate-end",children:e.label})}),e.hotkey===void 0?void 0:n(d,{flexShrink:0,children:a(t,{dimColor:!0,children:[" ",e.hotkey]})})]}),e.description===void 0?void 0:n(d,{marginLeft:2,children:n(t,{dimColor:!0,wrap:"truncate-end",children:e.description})})]},e.id)})})]})}export{P as CommandPalette,P as default};
@@ -0,0 +1,75 @@
1
+ import { ReactNode, ReactElement } from 'react';
2
+ type ConfirmTone = "danger" | "info" | "warning";
3
+ type Props = {
4
+ /**
5
+ * Auto-focus the dialog on mount. Set `false` if a parent already owns
6
+ * focus and routes input here.
7
+ * @default true
8
+ */
9
+ readonly autoFocus?: boolean;
10
+ /**
11
+ * Label for the cancel button.
12
+ * @default "Cancel"
13
+ */
14
+ readonly cancelLabel?: string;
15
+ /**
16
+ * Body content (rendered between title and buttons).
17
+ */
18
+ readonly children?: ReactNode;
19
+ /**
20
+ * Label for the confirm button.
21
+ * @default "Confirm"
22
+ */
23
+ readonly confirmLabel?: string;
24
+ /**
25
+ * Default button when opening the dialog.
26
+ * @default "confirm"
27
+ */
28
+ readonly defaultFocus?: "cancel" | "confirm";
29
+ /**
30
+ * Disable input.
31
+ */
32
+ readonly isDisabled?: boolean;
33
+ /**
34
+ * Fired when the user declines.
35
+ */
36
+ readonly onCancel: () => void;
37
+ /**
38
+ * Fired when the user confirms.
39
+ */
40
+ readonly onConfirm: () => void;
41
+ /**
42
+ * Heading rendered at the top of the dialog.
43
+ */
44
+ readonly title?: string;
45
+ /**
46
+ * Controls the border color.
47
+ * @default "info"
48
+ */
49
+ readonly tone?: ConfirmTone;
50
+ /**
51
+ * Dialog width.
52
+ */
53
+ readonly width?: number;
54
+ };
55
+ /**
56
+ * Full-width modal-style confirm/cancel prompt. Unlike `ConfirmInput`, this
57
+ * renders a visible two-button UI: ← / → to toggle focus, Enter to activate,
58
+ * y/n as shortcuts, Esc to cancel.
59
+ * @returns A bordered `ReactElement` with optional title, body, and two
60
+ * buttons (cancel / confirm).
61
+ */
62
+ declare function ConfirmDialog({
63
+ autoFocus,
64
+ cancelLabel,
65
+ children,
66
+ confirmLabel,
67
+ defaultFocus,
68
+ isDisabled,
69
+ onCancel,
70
+ onConfirm,
71
+ title,
72
+ tone,
73
+ width
74
+ }: Props): ReactElement;
75
+ export { ConfirmDialog, type Props as ConfirmDialogProps, ConfirmTone, Props, ConfirmDialog as default };
@@ -0,0 +1 @@
1
+ import{jsxs as b,jsx as o}from"react/jsx-runtime";import n from"@visulima/tui/components/box";import s from"@visulima/tui/components/text";import x from"@visulima/tui/hooks/use-focus";import y from"@visulima/tui/hooks/use-input";import{useState as D,useCallback as A}from"react";const j={danger:"red",info:"blue",warning:"yellow"},p=({color:l,isFocused:r,label:i})=>o(n,{backgroundColor:r?l:void 0,borderColor:r?l:void 0,borderStyle:"round",paddingX:1,children:o(s,{bold:r,color:r?"black":void 0,children:i})});function Y({autoFocus:l=!0,cancelLabel:r="Cancel",children:i,confirmLabel:h="Confirm",defaultFocus:g="confirm",isDisabled:u=!1,onCancel:a,onConfirm:f,title:m,tone:v="info",width:C}){const[e,F]=D(g),c=j[v],{isFocused:w}=x({autoFocus:l,isActive:!u});return y(A((t,d)=>{if(d.leftArrow||d.rightArrow||t==="h"||t==="l"){F(e==="confirm"?"cancel":"confirm");return}if(d.return){e==="confirm"?f():a();return}if(d.escape||t==="n"){a();return}t==="y"&&f()},[e,f,a]),{isActive:!u&&w}),b(n,{borderColor:c,borderStyle:"round",flexDirection:"column",paddingX:1,paddingY:1,width:C,children:[m===void 0?void 0:o(n,{marginBottom:1,children:o(s,{bold:!0,color:c,children:m})}),i===void 0?void 0:o(n,{flexDirection:"column",marginBottom:1,children:typeof i=="string"?o(s,{children:i}):i}),b(n,{gap:2,justifyContent:"flex-end",children:[o(p,{color:c,isFocused:e==="cancel",label:r}),o(p,{color:c,isFocused:e==="confirm",label:h})]})]})}export{Y as ConfirmDialog,Y as default};
@@ -0,0 +1,38 @@
1
+ import { ReactElement } from 'react';
2
+ type Props = {
3
+ /**
4
+ * The default action when pressing Enter without typing Y or N.
5
+ * @default "confirm"
6
+ */
7
+ readonly defaultChoice?: "cancel" | "confirm";
8
+ /**
9
+ * Whether the input is disabled.
10
+ * @default false
11
+ */
12
+ readonly isDisabled?: boolean;
13
+ /**
14
+ * Called when the user cancels (presses N).
15
+ */
16
+ readonly onCancel: () => void;
17
+ /**
18
+ * Called when the user confirms (presses Y).
19
+ */
20
+ readonly onConfirm: () => void;
21
+ /**
22
+ * Whether pressing Enter submits the default choice.
23
+ * @default true
24
+ */
25
+ readonly submitOnEnter?: boolean;
26
+ };
27
+ /**
28
+ * Renders a Y/N confirmation prompt. Shows "Y/n" when default is confirm,
29
+ * or "y/N" when default is cancel.
30
+ */
31
+ declare function ConfirmInput({
32
+ defaultChoice,
33
+ isDisabled,
34
+ onCancel,
35
+ onConfirm,
36
+ submitOnEnter
37
+ }: Props): ReactElement;
38
+ export { ConfirmInput, type Props as ConfirmInputProps, Props, ConfirmInput as default };
@@ -0,0 +1 @@
1
+ import{jsx as s,jsxs as a}from"react/jsx-runtime";import l from"@visulima/tui/components/box";import p from"@visulima/tui/components/text";import C from"@visulima/tui/hooks/use-input";import{useRef as f,useCallback as d}from"react";function y({defaultChoice:r="confirm",isDisabled:n=!1,onCancel:t,onConfirm:i,submitOnEnter:c=!0}){const e=f(i);e.current=i;const o=f(t);return o.current=t,C(d((u,m)=>{if(u.toLowerCase()==="y"){e.current();return}if(u.toLowerCase()==="n"){o.current();return}m.return&&c&&(r==="confirm"?e.current():o.current())},[c,r]),{isActive:!n}),s(l,{children:a(p,{dimColor:n,children:[r==="confirm"?"Y":"y","/",r==="cancel"?"N":"n"]})})}export{y as ConfirmInput,y as default};
@@ -0,0 +1,54 @@
1
+ import { ConsoleLevel } from '@visulima/tui/hooks/use-console-capture';
2
+ import { ReactElement } from 'react';
3
+ type ConsoleOverlayDock = "bottom" | "top";
4
+ type Props = {
5
+ /**
6
+ * Dock position within the parent container.
7
+ * @default "bottom"
8
+ */
9
+ readonly dock?: ConsoleOverlayDock;
10
+ /**
11
+ * Which console levels to capture.
12
+ * @default ["log", "info", "warn", "error", "debug"]
13
+ */
14
+ readonly filter?: ReadonlyArray<ConsoleLevel>;
15
+ /**
16
+ * Visible height in rows.
17
+ * @default 8
18
+ */
19
+ readonly height?: number;
20
+ /**
21
+ * Maximum entries to keep in the buffer.
22
+ * @default 200
23
+ */
24
+ readonly maxEntries?: number;
25
+ /**
26
+ * Show the log level label.
27
+ * @default true
28
+ */
29
+ readonly showLevel?: boolean;
30
+ /**
31
+ * Show timestamps on each entry.
32
+ * @default true
33
+ */
34
+ readonly showTimestamp?: boolean;
35
+ };
36
+ /**
37
+ * A dockable console overlay that captures and displays console output.
38
+ *
39
+ * ```tsx
40
+ * &lt;Box flexDirection="column" height="100%">
41
+ * &lt;Box flexGrow={1}>{mainContent}&lt;/Box>
42
+ * &lt;ConsoleOverlay dock="bottom" height={6} />
43
+ * &lt;/Box>
44
+ * ```
45
+ */
46
+ declare function ConsoleOverlay({
47
+ dock,
48
+ filter,
49
+ height,
50
+ maxEntries,
51
+ showLevel,
52
+ showTimestamp
53
+ }: Props): ReactElement;
54
+ export { ConsoleOverlay, ConsoleOverlayDock, type Props as ConsoleOverlayProps, Props, ConsoleOverlay as default };
@@ -0,0 +1 @@
1
+ import{jsx as m,jsxs as d}from"react/jsx-runtime";import p from"@visulima/tui/components/box";import l from"@visulima/tui/components/text";import u from"@visulima/tui/hooks/use-console-capture";import{useMemo as c}from"react";const h={debug:"gray",error:"red",info:"blue",log:"white",warn:"yellow"},f={debug:"DBG",error:"ERR",info:"INF",log:"LOG",warn:"WRN"},b=t=>{const r=new Date(t),o=String(r.getHours()).padStart(2,"0"),i=String(r.getMinutes()).padStart(2,"0"),n=String(r.getSeconds()).padStart(2,"0");return`${o}:${i}:${n}`};function y({dock:t="bottom",filter:r,height:o=8,maxEntries:i=200,showLevel:n=!0,showTimestamp:g=!0}){const{entries:a}=u({filter:r,maxEntries:i}),s=c(()=>a.slice(-o),[a,o]);return m(p,{borderBottom:t==="top",borderBottomColor:"gray",borderTop:t==="bottom",borderTopColor:"gray",flexDirection:"column",height:o+1,children:s.length===0?m(l,{dimColor:!0,children:"Console output will appear here..."}):s.map(e=>d(p,{children:[g?d(l,{dimColor:!0,children:["[",b(e.timestamp),"]"," "]}):void 0,n?d(l,{color:h[e.level],children:[f[e.level]," "]}):void 0,m(l,{color:e.level==="error"?"red":e.level==="warn"?"yellow":void 0,children:e.message})]},e.id))})}export{y as ConsoleOverlay,y as default};
@@ -0,0 +1,57 @@
1
+ import { AnsiColors } from '@visulima/colorize';
2
+ import { ReactNode, ReactElement } from 'react';
3
+ import { LiteralUnion } from 'type-fest';
4
+ type ContentSwitcherOption = {
5
+ readonly content: ReactNode;
6
+ readonly icon?: ReactNode;
7
+ readonly id: string;
8
+ readonly label: string;
9
+ };
10
+ type Props = {
11
+ /**
12
+ * Accent color for the selected segment.
13
+ * @default "blue"
14
+ */
15
+ readonly accentColor?: LiteralUnion<AnsiColors, string>;
16
+ /**
17
+ * Auto-focus the switcher on mount.
18
+ */
19
+ readonly autoFocus?: boolean;
20
+ /**
21
+ * Initial selected id (uncontrolled).
22
+ */
23
+ readonly defaultValue?: string;
24
+ /**
25
+ * Disable input.
26
+ */
27
+ readonly isDisabled?: boolean;
28
+ /**
29
+ * Called when the selection changes.
30
+ */
31
+ readonly onChange?: (id: string) => void;
32
+ /**
33
+ * Segments to toggle between.
34
+ */
35
+ readonly options: ReadonlyArray<ContentSwitcherOption>;
36
+ /**
37
+ * Controlled selected id.
38
+ */
39
+ readonly value?: string;
40
+ };
41
+ /**
42
+ * Segmented control that flips between mutually exclusive content. More
43
+ * compact than `Tabs`: the selected segment is highlighted as a pill, and
44
+ * only the active segment's content is rendered.
45
+ * @returns A `ReactElement` with a segmented header row and the active
46
+ * panel's content beneath it.
47
+ */
48
+ declare function ContentSwitcher({
49
+ accentColor,
50
+ autoFocus,
51
+ defaultValue,
52
+ isDisabled,
53
+ onChange,
54
+ options,
55
+ value
56
+ }: Props): ReactElement;
57
+ export { ContentSwitcher, ContentSwitcherOption, type Props as ContentSwitcherProps, Props, ContentSwitcher as default };
@@ -0,0 +1 @@
1
+ import{jsxs as u,jsx as v,Fragment as w}from"react/jsx-runtime";import m from"@visulima/tui/components/box";import D from"@visulima/tui/components/text";import F from"@visulima/tui/hooks/use-focus";import M from"@visulima/tui/hooks/use-input";import{useState as k,useMemo as j,useCallback as p}from"react";function q({accentColor:g="blue",autoFocus:x=!1,defaultValue:b,isDisabled:l=!1,onChange:f,options:r,value:t}){const{isFocused:c}=F({autoFocus:x,isActive:!l}),C=b??r[0]?.id,[a,A]=k(C),d=t??a,n=j(()=>{if(d===void 0)return 0;const o=r.findIndex(i=>i.id===d);return Math.max(o,0)},[r,d]),s=p(o=>{const i=r[o];if(!i)return;const e=t??a;i.id!==e&&(t===void 0&&A(i.id),f?.(i.id))},[r,t,a,f]);M(p((o,i)=>{c&&(i.leftArrow||o==="h"?s(Math.max(0,n-1)):(i.rightArrow||o==="l")&&s(Math.min(r.length-1,n+1)))},[c,n,r.length,s]),{isActive:!l&&c});const h=r[n];return u(m,{flexDirection:"column",children:[v(m,{children:r.map((o,i)=>{const e=i===n;return u(D,{backgroundColor:e?g:void 0,color:e?"black":void 0,dimColor:l&&!e,children:[" ",o.icon===void 0?void 0:u(w,{children:[o.icon," "]}),o.label," "]},o.id)})}),h===void 0?void 0:v(m,{flexDirection:"column",marginTop:1,children:h.content})]})}export{q as ContentSwitcher,q as default};
@@ -0,0 +1,3 @@
1
+ export { C as ControlledScrollView, type a as ControlledScrollViewProps, type b as ControlledScrollViewRef } from "./packem_shared/controlled-scroll-view.d-vF4wevEJ.js";
2
+ import '@visulima/tui/components/box';
3
+ import 'react';
@@ -0,0 +1 @@
1
+ import{C as r}from"./packem_shared/controlled-scroll-view-DerVKKv6.js";export{r as ControlledScrollView};
@@ -0,0 +1,49 @@
1
+ import { AnsiColors } from '@visulima/colorize';
2
+ import { ReactElement } from 'react';
3
+ import { LiteralUnion } from 'type-fest';
4
+ type DataGridColumn<Row> = {
5
+ readonly align?: "left" | "right";
6
+ readonly header: string;
7
+ readonly key: keyof Row & string;
8
+ /**
9
+ * Render a cell to a string. Defaults to `String(row[key])`.
10
+ */
11
+ readonly render?: (row: Row) => string;
12
+ readonly width?: number;
13
+ };
14
+ type Props<Row extends Record<string, unknown>> = {
15
+ /**
16
+ * Accent color for the cursor row and active sort column.
17
+ * @default "blue"
18
+ */
19
+ readonly accentColor?: LiteralUnion<AnsiColors, string>;
20
+ /**
21
+ * Auto-focus for keyboard navigation.
22
+ */
23
+ readonly autoFocus?: boolean;
24
+ /**
25
+ * Column definitions in display order.
26
+ */
27
+ readonly columns: ReadonlyArray<DataGridColumn<Row>>;
28
+ /**
29
+ * The rows to display.
30
+ */
31
+ readonly data: ReadonlyArray<Row>;
32
+ /**
33
+ * Fires with the row under the cursor when Enter is pressed.
34
+ */
35
+ readonly onSelect?: (row: Row) => void;
36
+ };
37
+ /**
38
+ * A navigable, sortable table. ↑/↓ move the row cursor, ←/→ move the column
39
+ * cursor, `s` sorts by the cursor column (toggling direction), and Enter fires
40
+ * `onSelect` with the current row. Column widths default to the widest cell.
41
+ */
42
+ declare function DataGrid<Row extends Record<string, unknown>>({
43
+ accentColor,
44
+ autoFocus,
45
+ columns,
46
+ data,
47
+ onSelect
48
+ }: Props<Row>): ReactElement;
49
+ export { DataGrid, DataGridColumn, type Props as DataGridProps, Props, DataGrid as default };
@@ -0,0 +1 @@
1
+ import{jsxs as N,jsx as d}from"react/jsx-runtime";import m from"@visulima/tui/components/box";import h from"@visulima/tui/components/text";import M from"@visulima/tui/hooks/use-focus";import P from"@visulima/tui/hooks/use-input";import{useState as w,useMemo as D,useCallback as T}from"react";function f(t,i){return i===0?0:(t%i+i)%i}const g=(t,i)=>t.render?t.render(i):String(i[t.key]??""),R=(t,i,n)=>t.length>=i?t.slice(0,i):n==="right"?t.padStart(i):t.padEnd(i);function L({accentColor:t="blue",autoFocus:i=!1,columns:n,data:l,onSelect:b}){const{isFocused:p}=M({autoFocus:i}),[k,A]=w(0),[y,S]=w(0),[a,j]=w(void 0),C=D(()=>n.map(r=>{if(r.width!==void 0)return r.width;let o=r.header.length+2;for(const e of l)o=Math.max(o,g(r,e).length);return o}),[n,l]),s=D(()=>{if(a===void 0)return l;const r=n.find(e=>e.key===a.key);if(r===void 0)return l;const o=a.direction==="asc"?1:-1;return[...l].toSorted((e,c)=>{const u=g(r,e),v=g(r,c),x=Number(u),F=Number(v),G=u.length>0&&v.length>0&&!Number.isNaN(x)&&!Number.isNaN(F);return o*(G?x-F:u.localeCompare(v))})},[n,l,a]),B=T((r,o)=>{if(o.upArrow)A(e=>f(e-1,s.length));else if(o.downArrow)A(e=>f(e+1,s.length));else if(o.leftArrow)S(e=>f(e-1,n.length));else if(o.rightArrow)S(e=>f(e+1,n.length));else if(r==="s"){const e=n[y];e!==void 0&&j(c=>c?.key===e.key&&c.direction==="asc"?{direction:"desc",key:e.key}:{direction:"asc",key:e.key})}else if(o.return){const e=s[k];e!==void 0&&b?.(e)}},[y,n,b,k,s]);P(B,{isActive:p});const E=r=>a?.key!==r?"":a.direction==="asc"?" ▲":" ▼";return N(m,{flexDirection:"column",children:[N(m,{children:[d(h,{children:" "}),n.map((r,o)=>d(m,{marginRight:1,children:d(h,{bold:!0,color:p&&o===y?t:void 0,children:R(`${r.header}${E(r.key)}`,C[o],r.align??"left")})},r.key))]}),s.map((r,o)=>{const e=p&&o===k;return N(m,{children:[d(h,{color:e?t:void 0,children:e?"❯":" "}),n.map((c,u)=>d(m,{marginRight:1,children:d(h,{color:e?t:void 0,dimColor:!e,children:R(g(c,r),C[u],c.align??"left")})},c.key))]},o)})]})}export{L as DataGrid,L as default};
@@ -0,0 +1,65 @@
1
+ import { AnsiColors } from '@visulima/colorize';
2
+ import { ReactElement } from 'react';
3
+ import { LiteralUnion } from 'type-fest';
4
+ type Props = {
5
+ /**
6
+ * Accent color used by the inner calendar when open.
7
+ * @default "blue"
8
+ */
9
+ readonly accentColor?: LiteralUnion<AnsiColors, string>;
10
+ /**
11
+ * Auto-focus the picker on mount.
12
+ */
13
+ readonly autoFocus?: boolean;
14
+ /**
15
+ * Initial selected date when uncontrolled.
16
+ */
17
+ readonly defaultValue?: Date;
18
+ /**
19
+ * Override the way the selected date is rendered in the input row.
20
+ */
21
+ readonly formatValue?: (date: Date) => string;
22
+ /**
23
+ * Disable the picker.
24
+ */
25
+ readonly isDisabled?: boolean;
26
+ /**
27
+ * Upper bound for selectable dates.
28
+ */
29
+ readonly maxDate?: Date;
30
+ /**
31
+ * Lower bound for selectable dates.
32
+ */
33
+ readonly minDate?: Date;
34
+ /**
35
+ * Fired when the user commits a date with Enter.
36
+ */
37
+ readonly onChange?: (date: Date) => void;
38
+ /**
39
+ * Placeholder rendered when no date is selected.
40
+ * @default "Pick a date"
41
+ */
42
+ readonly placeholder?: string;
43
+ /**
44
+ * Controlled selected date.
45
+ */
46
+ readonly value?: Date;
47
+ };
48
+ /**
49
+ * Compact date input. Shows the currently-selected date; Enter / Space opens
50
+ * the inline `Calendar` for navigation. Enter inside the calendar commits the
51
+ * date and closes the picker.
52
+ */
53
+ declare function DatePicker({
54
+ accentColor,
55
+ autoFocus,
56
+ defaultValue,
57
+ formatValue,
58
+ isDisabled,
59
+ maxDate,
60
+ minDate,
61
+ onChange,
62
+ placeholder,
63
+ value
64
+ }: Props): ReactElement;
65
+ export { DatePicker, type Props as DatePickerProps, Props, DatePicker as default };
@@ -0,0 +1 @@
1
+ import{jsxs as g,jsx as o}from"react/jsx-runtime";import i from"@visulima/tui/components/box";import l from"@visulima/tui/components/text";import k from"@visulima/tui/hooks/use-focus";import C from"@visulima/tui/hooks/use-input";import{useState as D,useCallback as h}from"react";import{Calendar as V}from"./calendar.js";const j=e=>{const n=e.getFullYear(),c=String(e.getMonth()+1).padStart(2,"0"),d=String(e.getDate()).padStart(2,"0");return`${n}-${c}-${d}`};function O({accentColor:e="blue",autoFocus:n=!1,defaultValue:c,formatValue:d=j,isDisabled:s=!1,maxDate:b,minDate:S,onChange:v,placeholder:x="Pick a date",value:u}){const{isFocused:r}=k({autoFocus:n,isActive:!s}),[t,m]=D(!1),[F,$]=D(c),f=u??F;C(h((a,p)=>{!r||t||(p.return||a===" ")&&m(!0)},[r,t]),{isActive:!s&&r&&!t}),C(h((a,p)=>{p.escape&&m(!1)},[]),{isActive:!s&&r&&t});const A=h(a=>{u===void 0&&$(a),m(!1),v?.(a)},[u,v]);return g(i,{flexDirection:"column",children:[g(i,{borderColor:r?e:void 0,borderStyle:"round",paddingX:1,children:[o(l,{color:e,children:"📅 "}),f===void 0?o(l,{dimColor:!0,children:x}):o(l,{bold:!0,children:d(f)}),r&&!t?o(i,{marginLeft:1,children:o(l,{dimColor:!0,children:"(Enter to open)"})}):void 0]}),t?o(i,{marginTop:1,children:o(V,{accentColor:e,autoFocus:!0,defaultValue:f,maxDate:b,minDate:S,onSubmit:A})}):void 0]})}export{O as DatePicker,O as default};
@@ -0,0 +1,44 @@
1
+ import { AnsiColors } from '@visulima/colorize';
2
+ import { ReactNode, ReactElement } from 'react';
3
+ import { LiteralUnion } from 'type-fest';
4
+ type DefinitionItem = {
5
+ readonly description: ReactNode;
6
+ readonly key?: string;
7
+ readonly term: ReactNode;
8
+ };
9
+ type Props = {
10
+ /**
11
+ * Spacing between term and description columns.
12
+ * @default 2
13
+ */
14
+ readonly columnGap?: number;
15
+ /**
16
+ * Entries to render.
17
+ */
18
+ readonly items: ReadonlyArray<DefinitionItem>;
19
+ /**
20
+ * Inline items display on the same row; stacked items display with the term above the description.
21
+ * @default "inline"
22
+ */
23
+ readonly layout?: "inline" | "stacked";
24
+ /**
25
+ * Color applied to the term.
26
+ * @default "cyan"
27
+ */
28
+ readonly termColor?: LiteralUnion<AnsiColors, string>;
29
+ /**
30
+ * Minimum width used to align inline terms.
31
+ */
32
+ readonly termWidth?: number;
33
+ };
34
+ /**
35
+ * Key/value style definition list. Equivalent to the HTML `&lt;dl>` element.
36
+ */
37
+ declare function DefinitionList({
38
+ columnGap,
39
+ items,
40
+ layout,
41
+ termColor,
42
+ termWidth
43
+ }: Props): ReactElement;
44
+ export { DefinitionItem, DefinitionList, type Props as DefinitionListProps, Props, DefinitionList as default };
@@ -0,0 +1 @@
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import r from"@visulima/tui/components/box";import n from"@visulima/tui/components/text";function s({columnGap:d=2,items:c,layout:m="inline",termColor:o="cyan",termWidth:h}){return m==="stacked"?e(r,{flexDirection:"column",gap:1,children:c.map((i,l)=>t(r,{flexDirection:"column",children:[e(n,{bold:!0,color:o,children:i.term}),e(n,{children:i.description})]},i.key??l))}):e(r,{flexDirection:"column",children:c.map((i,l)=>t(r,{gap:d,children:[e(r,{flexShrink:0,width:h,children:e(n,{color:o,children:i.term})}),e(r,{flexGrow:1,flexShrink:1,children:e(n,{children:i.description})})]},i.key??l))})}export{s as DefinitionList,s as default};
@@ -0,0 +1,110 @@
1
+ import { ReactNode, ReactElement } from 'react';
2
+ import '@visulima/tui/components/box';
3
+ import { b as ScrollViewRef } from "./packem_shared/scroll-view.d-BqKpI-F-.js";
4
+ type Props = {
5
+ /**
6
+ * Background color for the dialog. Defaults to the detected terminal
7
+ * background color, falling back to `"black"`.
8
+ */
9
+ readonly backgroundColor?: string;
10
+ /**
11
+ * Border color.
12
+ * @default "cyan"
13
+ */
14
+ readonly borderColor?: string;
15
+ /**
16
+ * Border style.
17
+ * @default "round"
18
+ */
19
+ readonly borderStyle?: "arrow" | "bold" | "classic" | "double" | "doubleSingle" | "round" | "single" | "singleDouble";
20
+ /**
21
+ * Dialog content.
22
+ */
23
+ readonly children: ReactNode;
24
+ /**
25
+ * Override terminal columns. Useful in renderToString or testing contexts
26
+ * where useWindowSize is unavailable.
27
+ */
28
+ readonly columns?: number;
29
+ /**
30
+ * Footer content rendered below the scrollable area.
31
+ * Useful for hints like "Press ? to close".
32
+ */
33
+ readonly footer?: ReactNode;
34
+ /**
35
+ * Maximum height as a fraction of terminal rows (0-1) or absolute rows.
36
+ * Values &lt;= 1 are treated as fractions; values > 1 as absolute row counts.
37
+ * @default 0.8
38
+ */
39
+ readonly maxHeight?: number;
40
+ /**
41
+ * Padding inside the dialog border.
42
+ * @default 2
43
+ */
44
+ readonly paddingX?: number;
45
+ /**
46
+ * Vertical padding inside the dialog border.
47
+ * @default 1
48
+ */
49
+ readonly paddingY?: number;
50
+ /**
51
+ * Override terminal rows. Useful in renderToString or testing contexts
52
+ * where useWindowSize is unavailable.
53
+ */
54
+ readonly rows?: number;
55
+ /**
56
+ * Scrollbar visual style.
57
+ * @default "block"
58
+ */
59
+ readonly scrollbarStyle?: "arrow" | "block" | "bold" | "classic" | "dots" | "double" | "doubleSingle" | "line" | "round" | "single" | "singleDouble" | "thick";
60
+ /**
61
+ * Ref to the internal ScrollView for programmatic scrolling.
62
+ */
63
+ readonly scrollRef?: React.Ref<ScrollViewRef>;
64
+ /**
65
+ * Title rendered at the top of the dialog. If a string is provided,
66
+ * it is rendered as bold cyan text.
67
+ */
68
+ readonly title?: ReactNode;
69
+ /**
70
+ * Whether the dialog is visible. When `false`, nothing is rendered.
71
+ * @default true
72
+ */
73
+ readonly visible?: boolean;
74
+ /**
75
+ * Dialog width in columns.
76
+ * @default 60
77
+ */
78
+ readonly width?: number;
79
+ };
80
+ /**
81
+ * A centered overlay dialog with automatic scrolling and scrollbar when
82
+ * content exceeds the available terminal height.
83
+ *
84
+ * Uses the terminal's detected background color by default so the
85
+ * dialog blends with the user's theme.
86
+ *
87
+ * ```tsx
88
+ * &lt;Dialog title="Help" footer={&lt;Text dimColor>Press Esc to close&lt;/Text>}>
89
+ * &lt;Text>Dialog content here&lt;/Text>
90
+ * &lt;/Dialog>
91
+ * ```
92
+ */
93
+ declare const Dialog: ({
94
+ backgroundColor: backgroundColorProp,
95
+ borderColor,
96
+ borderStyle,
97
+ children,
98
+ columns: columnsProp,
99
+ footer,
100
+ maxHeight: maxHeightProp,
101
+ paddingX,
102
+ paddingY,
103
+ rows: rowsProp,
104
+ scrollbarStyle: scrollbarStyleProp,
105
+ scrollRef: externalScrollRef,
106
+ title,
107
+ visible,
108
+ width
109
+ }: Props) => ReactElement | null;
110
+ export { Dialog, type Props as DialogProps, Props, Dialog as default };
package/dist/dialog.js ADDED
@@ -0,0 +1 @@
1
+ import{jsx as r,jsxs as B}from"react/jsx-runtime";import o from"@visulima/tui/components/box";import M from"@visulima/tui/components/text";import H from"@visulima/tui/hooks/use-terminal-palette";import I from"@visulima/tui/hooks/use-window-size";import{useRef as R}from"react";import{ScrollView as V}from"./packem_shared/ScrollView-ESxpl6Hy.js";const T=({backgroundColor:u,borderColor:l="cyan",borderStyle:f="round",children:h,columns:g,footer:d,maxHeight:e=.8,paddingX:i=2,paddingY:p=1,rows:b,scrollbarStyle:k="block",scrollRef:x,title:n,visible:C=!0,width:S=60})=>{const c=I(),{isLoading:w,palette:y}=H(),D=R(null),X=x??D;if(!C)return null;const a=g??(c.columns||80),t=b??(c.rows||24),m=u??(w?"black":y?.background??"black"),j=e<=1?Math.floor(t*e):Math.min(e,t-2),s=typeof n=="string"?r(o,{marginBottom:1,children:r(M,{bold:!0,color:l,children:n})}):n??null;return r(o,{alignItems:"center",height:t,justifyContent:"center",position:"absolute",width:a,children:B(o,{backgroundColor:m,borderBackgroundColor:m,borderColor:l,borderStyle:f,flexDirection:"column",maxHeight:j,opaque:!0,paddingY:p,width:Math.min(S,a-4),children:[s!=null&&r(o,{flexShrink:0,paddingX:i,children:s}),r(V,{flexGrow:1,flexShrink:1,paddingX:i,ref:X,scrollbar:!0,scrollbarColor:l,scrollbarStyle:k,children:h}),d!=null&&r(o,{alignItems:"center",flexDirection:"column",flexShrink:0,marginTop:1,paddingX:i,children:d})]})})};export{T as Dialog,T as default};
@@ -0,0 +1,85 @@
1
+ import { ReactElement } from 'react';
2
+ type DiffViewMode = "split" | "unified";
3
+ type InlineDiffMode = "chars" | "words";
4
+ type Props = {
5
+ /**
6
+ * Number of unchanged context lines around changes.
7
+ * @default 3
8
+ */
9
+ readonly context?: number;
10
+ /**
11
+ * Pre-computed unified diff string. If provided, `oldText`/`newText` are ignored.
12
+ */
13
+ readonly diff?: string;
14
+ /**
15
+ * Enable character-level inline diff highlighting within changed lines.
16
+ * @default true
17
+ */
18
+ readonly inlineDiff?: boolean;
19
+ /**
20
+ * Granularity of inline diff highlighting.
21
+ * - `"chars"` — character-level (best for code)
22
+ * - `"words"` — word-level (best for prose)
23
+ * @default "chars"
24
+ */
25
+ readonly inlineDiffMode?: InlineDiffMode;
26
+ /**
27
+ * Programming language for syntax highlighting within diff lines.
28
+ * When provided, diff content is highlighted with Shiki.
29
+ */
30
+ readonly language?: string;
31
+ /**
32
+ * Display mode: unified (interleaved) or split (side-by-side).
33
+ * @default "unified"
34
+ */
35
+ readonly mode?: DiffViewMode;
36
+ /**
37
+ * Label for the new version.
38
+ */
39
+ readonly newLabel?: string;
40
+ /**
41
+ * Modified text ("new" / right side).
42
+ */
43
+ readonly newText?: string;
44
+ /**
45
+ * Label for the old version.
46
+ */
47
+ readonly oldLabel?: string;
48
+ /**
49
+ * Original text ("old" / left side).
50
+ */
51
+ readonly oldText?: string;
52
+ /**
53
+ * Whether to display line numbers.
54
+ * @default true
55
+ */
56
+ readonly showLineNumbers?: boolean;
57
+ /**
58
+ * Shiki theme for syntax highlighting.
59
+ * @default "github-dark-default"
60
+ */
61
+ readonly theme?: string;
62
+ };
63
+ /**
64
+ * Display file differences with colored additions/deletions.
65
+ *
66
+ * ```tsx
67
+ * &lt;DiffView oldText="hello" newText="hello world" />
68
+ * &lt;DiffView diff={unifiedDiffString} mode="split" />
69
+ * ```
70
+ */
71
+ declare function DiffView({
72
+ context,
73
+ diff: diffProp,
74
+ inlineDiff,
75
+ inlineDiffMode,
76
+ language,
77
+ mode,
78
+ newLabel,
79
+ newText,
80
+ oldLabel,
81
+ oldText,
82
+ showLineNumbers,
83
+ theme
84
+ }: Props): ReactElement;
85
+ export { DiffView, DiffViewMode, type Props as DiffViewProps, InlineDiffMode, Props, DiffView as default };
@@ -0,0 +1 @@
1
+ import{jsx as u,jsxs as g,Fragment as H}from"react/jsx-runtime";import p from"@visulima/tui/components/box";import a from"@visulima/tui/components/text";import{resolveLanguage as P,isLanguageSupported as T,getHighlighter as I,getCachedTokens as M,renderTokenLine as W}from"@visulima/tui/highlighter";import j from"@visulima/tui/hooks/use-window-size";import{createPatch as B,parsePatch as E,diffWords as q,diffChars as z}from"diff";import{useMemo as y,useState as A,useRef as F,useEffect as G}from"react";const L=(r,i,n,d)=>{if(!i||n===void 0||n<1||n>i.length)return d?u(a,{color:d,children:r}):u(a,{dimColor:!0,children:r});const o=i[n-1];return!o||o.length===0?d?u(a,{color:d,children:r}):u(a,{dimColor:!0,children:r}):W(o)},b=(r,i,n)=>{const[d,o]=A(null),h=F(!1);return G(()=>{if(h.current=!1,!i){o(null);return}const e=P(i);if(!T(e)){o(null);return}return(async()=>{try{const f=await I([e],n),l=M(f,r,e,n);h.current||o(l.tokens)}catch{h.current||o(null)}})(),()=>{h.current=!0}},[r,i,n]),d},R=(r,i,n="chars")=>{const d=E(r),o=[];for(const h of d)for(const e of h.hunks){const f=`@@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@`,l=[];let s=e.oldStart,c=e.newStart;for(const w of e.lines)w.startsWith("\\")||(w.startsWith("+")?l.push({content:w.slice(1),newLineNum:c++,type:"add"}):w.startsWith("-")?l.push({content:w.slice(1),oldLineNum:s++,type:"del"}):l.push({content:w.slice(1),newLineNum:c++,oldLineNum:s++,type:"context"}));if(i){const w=V(l);for(const[N,t]of w)if(l[N].type==="del"&&l[t].type==="add"){const m=U(l[N].content,l[t].content,n);l[N].inlineDiff=m??void 0,l[N].pairedIndex=t,l[t].inlineDiff=m??void 0,l[t].pairedIndex=N}}o.push({header:f,lines:l})}return o},k=500,U=(r,i,n="chars")=>{if(r.length>k||i.length>k)return null;const d=n==="words"?q(r,i):z(r,i),o=[],h=[];for(const e of d)e.removed?o.push({highlight:!0,value:e.value}):e.added?h.push({highlight:!0,value:e.value}):(o.push({highlight:!1,value:e.value}),h.push({highlight:!1,value:e.value}));return{addParts:h,delParts:o}},D=(r,i,n)=>u(H,{children:r.map((d,o)=>d.highlight?u(a,{backgroundColor:n,color:"white",children:d.value},o):u(a,{color:i,children:d.value},o))}),V=r=>{const i=new Map;let n=0;for(;n<r.length;){const d=n;for(;n<r.length&&r[n].type==="del";)n++;const o=n,h=n;for(;n<r.length&&r[n].type==="add";)n++;const e=n,f=o-d,l=e-h,s=Math.min(f,l);for(let c=0;c<s;c++)i.set(d+c,h+c),i.set(h+c,d+c);n===d&&n++}return i};function X({hunks:r,newHighlighted:i,oldHighlighted:n,showLineNumbers:d}){return u(p,{flexDirection:"column",children:r.map((o,h)=>g(p,{flexDirection:"column",children:[h>0?u(p,{marginBottom:0,marginTop:0,children:u(a,{dimColor:!0,children:"···"})}):void 0,u(a,{color:"cyan",dimColor:!0,children:o.header}),o.lines.map((e,f)=>{let l,s,c;switch(e.type){case"add":{s="+",c="green",l=e.inlineDiff?D(e.inlineDiff.addParts,"green","green"):L(e.content,i,e.newLineNum,"green");break}case"del":{s="-",c="red",l=e.inlineDiff?D(e.inlineDiff.delParts,"red","red"):L(e.content,n,e.oldLineNum,"red");break}default:{s=" ",c=void 0,l=L(e.content,n,e.oldLineNum);break}}return g(p,{children:[d?g(a,{color:c,dimColor:e.type==="context",children:[String(e.oldLineNum??"").padStart(4)," ",String(e.newLineNum??"").padStart(4)," "]}):void 0,u(a,{color:c,children:s}),l]},f)})]},h))})}function J({hunks:r,newHighlighted:i,oldHighlighted:n,showLineNumbers:d,width:o}){const h=Math.floor(o/2)-1;return u(p,{flexDirection:"column",children:r.map((e,f)=>{const l=f>0?u(p,{marginBottom:0,marginTop:0,children:u(a,{dimColor:!0,children:"···"})}):void 0,s=[],c=[];for(let N=0;N<e.lines.length;N++){const t=e.lines[N];switch(t.type){case"add":{t.pairedIndex===void 0&&(s.push({content:u(a,{dimColor:!0})}),c.push({content:L(t.content,i,t.newLineNum,"green"),lineNum:t.newLineNum}));break}case"context":{s.push({content:L(t.content,n,t.oldLineNum),lineNum:t.oldLineNum}),c.push({content:L(t.content,i,t.newLineNum),lineNum:t.newLineNum});break}case"del":{if(t.pairedIndex===void 0)s.push({content:L(t.content,n,t.oldLineNum,"red"),lineNum:t.oldLineNum}),c.push({content:u(a,{dimColor:!0})});else{const m=e.lines[t.pairedIndex];s.push({content:t.inlineDiff?D(t.inlineDiff.delParts,"red","red"):L(t.content,n,t.oldLineNum,"red"),lineNum:t.oldLineNum}),c.push({content:m.inlineDiff?D(m.inlineDiff.addParts,"green","green"):L(m.content,i,m.newLineNum,"green"),lineNum:m.newLineNum})}break}}}const w=Math.max(s.length,c.length);return g(p,{flexDirection:"column",children:[l,u(a,{color:"cyan",dimColor:!0,children:e.header}),Array.from({length:w},(N,t)=>{const m=s[t],x=c[t];return g(p,{flexDirection:"row",children:[g(p,{width:h,children:[d?g(a,{dimColor:!0,children:[String(m?.lineNum??"").padStart(4)," "]}):void 0,m?.content]}),u(a,{dimColor:!0,children:"│"}),g(p,{width:h,children:[d?g(a,{dimColor:!0,children:[String(x?.lineNum??"").padStart(4)," "]}):void 0,x?.content]})]},t)})]},f)})})}function ee({context:r=3,diff:i,inlineDiff:n=!0,inlineDiffMode:d="chars",language:o,mode:h="unified",newLabel:e="new",newText:f="",oldLabel:l="old",oldText:s="",showLineNumbers:c=!0,theme:w="github-dark-default"}){const{columns:N}=j(),t=b(s,o,w),m=b(f,o,w),x=y(()=>i||B("file",s,f,l,e,{context:r}),[i,s,f,l,e,r]),v=y(()=>R(x,n,d),[x,n,d]);if(v.every(S=>S.lines.length===0))return u(p,{children:u(a,{dimColor:!0,children:"No differences found."})});const C=g(p,{flexDirection:"column",children:[g(a,{color:"red",dimColor:!0,children:["---"," ",l]}),g(a,{color:"green",dimColor:!0,children:["+++"," ",e]})]});return h==="split"?g(p,{flexDirection:"column",children:[C,u(J,{hunks:v,newHighlighted:m,oldHighlighted:t,showLineNumbers:c,width:N??80})]}):g(p,{flexDirection:"column",children:[C,u(X,{hunks:v,newHighlighted:m,oldHighlighted:t,showLineNumbers:c})]})}export{ee as DiffView,ee as default};