@visulima/tui-kit 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/accordion.js +1 -1
  3. package/dist/alert.js +1 -1
  4. package/dist/animate-presence.js +1 -1
  5. package/dist/approval-prompt.js +1 -1
  6. package/dist/area-chart.js +1 -1
  7. package/dist/badge.js +1 -1
  8. package/dist/bar-chart.js +1 -1
  9. package/dist/big-text.js +1 -1
  10. package/dist/blink-dot.js +1 -1
  11. package/dist/breadcrumb.js +1 -1
  12. package/dist/button.js +1 -1
  13. package/dist/calendar.js +1 -1
  14. package/dist/card.js +1 -1
  15. package/dist/checkbox-group.js +1 -1
  16. package/dist/checkbox.js +1 -1
  17. package/dist/code.js +2 -2
  18. package/dist/collapsible.js +1 -1
  19. package/dist/color-picker.js +1 -1
  20. package/dist/command-block.js +4 -4
  21. package/dist/command-palette.js +1 -1
  22. package/dist/confirm-dialog.js +1 -1
  23. package/dist/confirm-input.js +1 -1
  24. package/dist/console-overlay.js +1 -1
  25. package/dist/content-switcher.js +1 -1
  26. package/dist/controlled-scroll-view.d.ts +43 -3
  27. package/dist/controlled-scroll-view.js +1 -1
  28. package/dist/data-grid.js +1 -1
  29. package/dist/date-picker.js +1 -1
  30. package/dist/definition-list.js +1 -1
  31. package/dist/dialog.d.ts +1 -1
  32. package/dist/dialog.js +1 -1
  33. package/dist/diff-view.js +1 -1
  34. package/dist/digits.js +1 -1
  35. package/dist/directory-tree.js +1 -1
  36. package/dist/divider.js +1 -1
  37. package/dist/drawer.js +1 -1
  38. package/dist/file-change.js +1 -1
  39. package/dist/file-picker-entry.d.ts +92 -2
  40. package/dist/file-picker-entry.js +1 -1
  41. package/dist/form.js +1 -1
  42. package/dist/gauge.js +1 -1
  43. package/dist/gradient.js +1 -1
  44. package/dist/grid.js +1 -1
  45. package/dist/heading.js +1 -1
  46. package/dist/heatmap.js +1 -1
  47. package/dist/help.js +1 -1
  48. package/dist/histogram.js +1 -1
  49. package/dist/image.js +1 -1
  50. package/dist/index.d.ts +25 -9
  51. package/dist/index.js +1 -1
  52. package/dist/json.js +1 -1
  53. package/dist/kbd.js +1 -1
  54. package/dist/line-chart.js +1 -1
  55. package/dist/link.js +1 -1
  56. package/dist/loading-indicator.js +1 -1
  57. package/dist/log.js +1 -1
  58. package/dist/markdown.js +1 -1
  59. package/dist/masked-input.js +1 -1
  60. package/dist/menu.js +1 -1
  61. package/dist/message-bubble.js +1 -1
  62. package/dist/model-badge.js +1 -1
  63. package/dist/model-selector.js +1 -1
  64. package/dist/multi-progress.js +1 -1
  65. package/dist/multi-select.js +1 -1
  66. package/dist/notification-badge.js +1 -1
  67. package/dist/number-input.js +1 -1
  68. package/dist/operation-tree.js +1 -1
  69. package/dist/option-list.js +1 -1
  70. package/dist/ordered-list.js +1 -1
  71. package/dist/packem_shared/ControlledScrollView-soZtm3m7.js +1 -0
  72. package/dist/packem_shared/FilePicker-KGAg6v5x.js +1 -0
  73. package/dist/packem_shared/ScrollBar-arHRP6OT.js +1 -0
  74. package/dist/packem_shared/ScrollBarBox-C8wZ_Slk.js +1 -0
  75. package/dist/packem_shared/ScrollList-BCqHHps6.js +1 -0
  76. package/dist/packem_shared/ScrollView-Dt5E9Yl7.js +1 -0
  77. package/dist/packem_shared/TreeNodeMap-BK7nRlt0.js +1 -0
  78. package/dist/packem_shared/TreeView-BEZAFOfr.js +1 -0
  79. package/dist/packem_shared/controlled-scroll-view-BHCYjiKa.js +1 -0
  80. package/dist/packem_shared/line-chart-BqOUjZTt.js +1 -0
  81. package/dist/packem_shared/treeViewTheme-DuCcyBDe.js +1 -0
  82. package/dist/packem_shared/useTreeView-Dt_iWxVs.js +1 -0
  83. package/dist/packem_shared/useTreeViewState-aHwNZhIE.js +1 -0
  84. package/dist/packem_shared/{variant-config-BJqpNo7H.js → variant-config-BnAmf1rP.js} +1 -1
  85. package/dist/paginator.js +1 -1
  86. package/dist/paragraph.js +1 -1
  87. package/dist/path-input.js +1 -1
  88. package/dist/pie-chart.js +1 -1
  89. package/dist/placeholder.js +1 -1
  90. package/dist/popover.js +1 -1
  91. package/dist/progress-bar.js +1 -1
  92. package/dist/progress-circle.js +1 -1
  93. package/dist/qr-code.js +1 -1
  94. package/dist/radio-group.js +1 -1
  95. package/dist/scatter-plot.js +1 -1
  96. package/dist/scroll-bar-box.d.ts +13 -3
  97. package/dist/scroll-bar-box.js +1 -1
  98. package/dist/scroll-bar.d.ts +18 -3
  99. package/dist/scroll-bar.js +1 -1
  100. package/dist/scroll-list.d.ts +12 -3
  101. package/dist/scroll-list.js +1 -1
  102. package/dist/scroll-view.d.ts +98 -3
  103. package/dist/scroll-view.js +1 -1
  104. package/dist/search-input.js +1 -1
  105. package/dist/select-input-indicator.js +1 -1
  106. package/dist/select-input-item.js +1 -1
  107. package/dist/select-input.js +1 -1
  108. package/dist/shimmer-text.js +1 -1
  109. package/dist/sidebar.js +1 -1
  110. package/dist/slider.js +1 -1
  111. package/dist/sparkline.js +1 -1
  112. package/dist/spinner.js +1 -1
  113. package/dist/status-line.js +1 -1
  114. package/dist/status-message.js +1 -1
  115. package/dist/stepper.js +1 -1
  116. package/dist/stopwatch.js +1 -1
  117. package/dist/streaming-text.js +1 -1
  118. package/dist/switch.js +1 -1
  119. package/dist/tab.js +1 -1
  120. package/dist/table.js +1 -1
  121. package/dist/tabs.js +1 -1
  122. package/dist/tag-input.js +1 -1
  123. package/dist/tag.js +1 -1
  124. package/dist/text-input.js +1 -1
  125. package/dist/textarea.js +2 -2
  126. package/dist/thinking-block.js +1 -1
  127. package/dist/time-picker.js +1 -1
  128. package/dist/timer.js +1 -1
  129. package/dist/toast.js +1 -1
  130. package/dist/token-usage.js +1 -1
  131. package/dist/tool-call.js +1 -1
  132. package/dist/tooltip.js +1 -1
  133. package/dist/transition.js +1 -1
  134. package/dist/tree-select.js +1 -1
  135. package/dist/tree-view-entry.d.ts +314 -4
  136. package/dist/tree-view-entry.js +1 -1
  137. package/dist/unordered-list.js +1 -1
  138. package/dist/use-linked-scroll.d.ts +1 -1
  139. package/dist/use-linked-scroll.js +1 -1
  140. package/package.json +8 -8
  141. package/dist/packem_shared/ControlledScrollView-BzlbIUph.js +0 -1
  142. package/dist/packem_shared/FilePicker-V5H2fb-v.js +0 -1
  143. package/dist/packem_shared/ScrollBar-C9i3z3Ft.js +0 -1
  144. package/dist/packem_shared/ScrollBarBox-DZEC8YnV.js +0 -1
  145. package/dist/packem_shared/ScrollList-Djtb2vVy.js +0 -1
  146. package/dist/packem_shared/ScrollView-ESxpl6Hy.js +0 -1
  147. package/dist/packem_shared/TreeNodeMap-cJlYqckB.js +0 -1
  148. package/dist/packem_shared/TreeView-q0l446NV.js +0 -1
  149. package/dist/packem_shared/controlled-scroll-view-DerVKKv6.js +0 -1
  150. package/dist/packem_shared/controlled-scroll-view.d-D3kZZzjI.d.ts +0 -43
  151. package/dist/packem_shared/file-picker.d-CH7pccC7.d.ts +0 -92
  152. package/dist/packem_shared/line-chart-BbhMhcZg.js +0 -1
  153. package/dist/packem_shared/scroll-bar-box.d-CpTYEcTZ.d.ts +0 -13
  154. package/dist/packem_shared/scroll-bar.d-B4sD1hBR.d.ts +0 -18
  155. package/dist/packem_shared/scroll-list.d-CPCF0RwC.d.ts +0 -12
  156. package/dist/packem_shared/scroll-view.d-GZcgAHl4.d.ts +0 -98
  157. package/dist/packem_shared/treeViewTheme-Dq3ekRAC.js +0 -1
  158. package/dist/packem_shared/use-tree-view.d-DeMQ6G2r.d.ts +0 -314
  159. package/dist/packem_shared/useTreeView-D0JEqT6W.js +0 -1
  160. package/dist/packem_shared/useTreeViewState-BiTJakkh.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## @visulima/tui-kit [1.0.5](https://github.com/visulima/visulima/compare/%40visulima%2Ftui-kit%401.0.4...%40visulima%2Ftui-kit%401.0.5) (2026-08-18)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@visulima/ansi:** upgraded to 4.2.0
7
+ * **@visulima/tui:** upgraded to 4.0.2
8
+
9
+ ## @visulima/tui-kit [1.0.4](https://github.com/visulima/visulima/compare/%40visulima%2Ftui-kit%401.0.3...%40visulima%2Ftui-kit%401.0.4) (2026-08-17)
10
+
11
+
12
+ ### Dependencies
13
+
14
+ * **@visulima/tui:** upgraded to 4.0.1
15
+
1
16
  ## @visulima/tui-kit [1.0.3](https://github.com/visulima/visulima/compare/%40visulima%2Ftui-kit%401.0.2...%40visulima%2Ftui-kit%401.0.3) (2026-08-08)
2
17
 
3
18
 
package/dist/accordion.js CHANGED
@@ -1 +1 @@
1
- import{jsx as m,jsxs as a}from"react/jsx-runtime";import u from"@visulima/tui/components/box";import b from"@visulima/tui/components/text";import F from"@visulima/tui/hooks/use-focus";import j from"@visulima/tui/hooks/use-input";import{useState as v,useRef as k,useCallback as A}from"react";function R({accentColor:D="blue",allowMultiple:d=!1,autoFocus:g=!1,defaultExpanded:n,isDisabled:c=!1,items:l}){const{isFocused:s}=F({autoFocus:g,isActive:!c}),[w,C]=v(()=>n===void 0||n.length===0?[]:d?n:n.slice(0,1)),[f,p]=v(0),i=k(f);i.current=f;const h=A(r=>{C(e=>{const o=e.includes(r);return d?o?e.filter(t=>t!==r):[...e,r]:o?[]:[r]})},[d]);return j(A((r,e)=>{if(!s)return;const o=l.length;if((e.downArrow||r==="j")&&i.current<o-1)p(i.current+1);else if((e.upArrow||r==="k")&&i.current>0)p(i.current-1);else if(e.return||r===" "){const t=l[i.current];t&&h(t.id)}},[s,l,h]),{isActive:!c&&s}),m(u,{flexDirection:"column",children:l.map((r,e)=>{const o=w.includes(r.id),t=s&&e===f,x=t?D:void 0;return a(u,{flexDirection:"column",children:[a(u,{children:[a(b,{color:x,dimColor:c,children:[t?"▸ ":" ",o?"▼ ":"▶ "]}),m(b,{bold:t,color:x,dimColor:c,children:r.title})]}),o?m(u,{flexDirection:"column",marginBottom:1,marginLeft:4,children:r.content}):void 0]},r.id)})})}export{R as Accordion,R as default};
1
+ import{jsx as m,jsxs as x}from"react/jsx-runtime";import f from"@visulima/tui/components/box";import A from"@visulima/tui/components/text";import B from"@visulima/tui/hooks/use-focus";import O from"@visulima/tui/hooks/use-input";import{useState as I,useRef as R,useCallback as a}from"react";function q({accentColor:F="blue",allowMultiple:l=!1,autoFocus:j=!1,defaultExpanded:c,isDisabled:s=!1,items:i}){const{isFocused:u}=B({autoFocus:j,isActive:!s}),[v,C]=I(()=>c===void 0||c.length===0?[]:l?c:c.slice(0,1)),[d,h]=I(0),t=R(d);t.current=d;const g=a(r=>{C(e=>{const n=e.includes(r);return l?n?e.filter(o=>o!==r):[...e,r]:n?[]:[r]})},[l]);return O(a((r,e)=>{if(!u)return;const n=i.length;if((e.downArrow||r==="j")&&t.current<n-1)h(t.current+1);else if((e.upArrow||r==="k")&&t.current>0)h(t.current-1);else if(e.return||r===" "){const o=i[t.current];o&&g(o.id)}},[u,i,g]),{isActive:!s&&u}),m(f,{flexDirection:"column",children:i.map((r,e)=>{const n=v.includes(r.id),o=u&&e===d,p=o?F:void 0;return x(f,{flexDirection:"column",children:[x(f,{children:[x(A,{color:p,dimColor:s,children:[o?"▸ ":" ",n?"▼ ":"▶ "]}),m(A,{bold:o,color:p,dimColor:s,children:r.title})]}),n?m(f,{flexDirection:"column",marginBottom:1,marginLeft:4,children:r.content}):void 0]},r.id)})})}export{q as Accordion,q as default};
package/dist/alert.js CHANGED
@@ -1 +1 @@
1
- import{jsxs as n,jsx as r}from"react/jsx-runtime";import o from"@visulima/tui/components/box";import i from"@visulima/tui/components/text";import{o as f}from"./packem_shared/variant-config-BJqpNo7H.js";function p({children:d,title:e,variant:t}){const{color:l,icon:c}=f[t];return n(o,{borderColor:l,borderStyle:"round",flexGrow:1,gap:1,paddingX:1,children:[r(o,{flexShrink:0,children:r(i,{color:l,children:c})}),n(o,{flexDirection:"column",flexGrow:1,flexShrink:1,gap:1,minWidth:0,children:[e?r(i,{bold:!0,children:e}):void 0,r(i,{children:d})]})]})}export{p as Alert,p as default};
1
+ import{jsxs as l,jsx as r}from"react/jsx-runtime";import o from"@visulima/tui/components/box";import e from"@visulima/tui/components/text";import{V as f}from"./packem_shared/variant-config-BnAmf1rP.js";function a({children:d,title:i,variant:t}){const{color:n,icon:c}=f[t];return l(o,{borderColor:n,borderStyle:"round",flexGrow:1,gap:1,paddingX:1,children:[r(o,{flexShrink:0,children:r(e,{color:n,children:c})}),l(o,{flexDirection:"column",flexGrow:1,flexShrink:1,gap:1,minWidth:0,children:[i?r(e,{bold:!0,children:i}):void 0,r(e,{children:d})]})]})}export{a as Alert,a as default};
@@ -1 +1 @@
1
- import{jsx as y}from"react/jsx-runtime";import k from"@visulima/tui/components/box";import{useState as w,Children as f,isValidElement as m,useEffect as d,useCallback as E,cloneElement as p}from"react";const a=s=>{const{key:r}=s;if(r!==null)return r},x=s=>s.type?.isAnimatable===!0?!0:typeof s.props=="object"&&s.props!==null&&"show"in s.props;function A({children:s}){const[r,c]=w(()=>{const e=[];return f.forEach(s,t=>{if(!m(t))return;const n=a(t);n!==void 0&&e.push({element:t,key:n,show:!0})}),e});d(()=>{const e=new Map;f.forEach(s,t=>{if(!m(t))return;const n=a(t);n!==void 0&&e.set(n,t)}),c(t=>{const n=[],i=new Set;let l=!1;for(const o of t)if(e.has(o.key)){const u=e.get(o.key);(!o.show||o.element!==u)&&(l=!0),n.push({element:u,key:o.key,show:!0}),i.add(o.key)}else o.show&&(l=!0),n.push({...o,show:!1});for(const[o,u]of e)i.has(o)||(l=!0,n.push({element:u,key:o,show:!0}));return l?n:t})},[s]);const h=E(e=>{c(t=>t.filter(n=>n.key!==e))},[]);return y(k,{flexDirection:"column",children:r.map(e=>{if(!x(e.element))return p(e.element,{key:e.key});const t=e.element.props.onExit;return p(e.element,{key:e.key,onExit:()=>{t?.(),h(e.key)},show:e.show})})})}export{A as AnimatePresence,A as default};
1
+ import{jsx as w}from"react/jsx-runtime";import h from"@visulima/tui/components/box";import{useState as x,Children as m,isValidElement as p,useEffect as E,useCallback as g,cloneElement as y}from"react";const l=r=>{const{key:s}=r;if(s!==null)return s},i=r=>r.type?.isAnimatable===!0?!0:typeof r.props=="object"&&r.props!==null&&"show"in r.props;function A({children:r}){const[s,a]=x(()=>{const e=[];return m.forEach(r,t=>{if(!p(t))return;const n=l(t);n!==void 0&&e.push({element:(i(t),t),key:n,show:!0})}),e});E(()=>{const e=new Map;m.forEach(r,t=>{if(!p(t))return;const n=l(t);n!==void 0&&e.set(n,(i(t),t))}),a(t=>{const n=[],c=new Set;let u=!1;for(const o of t)if(e.has(o.key)){const f=e.get(o.key);(!o.show||o.element!==f)&&(u=!0),n.push({element:f,key:o.key,show:!0}),c.add(o.key)}else o.show&&(u=!0),n.push({...o,show:!1});for(const[o,f]of e)c.has(o)||(u=!0,n.push({element:f,key:o,show:!0}));return u?n:t})},[r]);const k=g(e=>{a(t=>t.filter(n=>n.key!==e))},[]);return w(h,{flexDirection:"column",children:s.map(e=>{if(!i(e.element))return y(e.element,{key:e.key});const t=e.element.props.onExit;return y(e.element,{key:e.key,onExit:()=>{t?.(),k(e.key)},show:e.show})})})}export{A as AnimatePresence,A as default};
@@ -1 +1 @@
1
- import{jsxs as i,jsx as o}from"react/jsx-runtime";import n from"@visulima/tui/components/box";import e from"@visulima/tui/components/text";import v from"@visulima/tui/hooks/use-focus";import S from"@visulima/tui/hooks/use-input";import{useCallback as x}from"react";const C={high:"red",low:"green",medium:"yellow"},D={high:"HIGH RISK",low:"LOW RISK",medium:"MEDIUM RISK"},A=r=>{if(r===null)return"null";if(typeof r=="string")return r;if(typeof r=="number"||typeof r=="boolean")return String(r);try{return JSON.stringify(r)}catch{return String(r)}};function O({accentColor:r,autoFocus:b=!0,children:u,description:m,isDisabled:h=!1,onDecision:l,params:p,risk:f="medium",tool:y}){const d=C[f],a=r??d,{isFocused:w}=v({autoFocus:b,isActive:!h});S(x((t,c)=>{const s=t.toLowerCase();if(s==="y"||c.return){l("allow-once");return}if(s==="a"){l("allow-always");return}(s==="n"||c.escape)&&l("deny")},[l]),{isActive:!h&&w});const g=p===void 0?[]:Object.entries(p);return i(n,{borderColor:d,borderStyle:"round",flexDirection:"column",paddingX:1,children:[i(n,{children:[i(e,{backgroundColor:d,color:"black",children:[" ",D[f]," "]}),i(e,{children:[" ",o(e,{bold:!0,children:y})]})]}),m===void 0?void 0:o(n,{marginTop:1,children:o(e,{children:m})}),g.length===0?void 0:o(n,{flexDirection:"column",marginTop:1,children:g.map(([t,c])=>i(n,{children:[i(e,{color:"cyan",children:[t,"="]}),o(e,{wrap:"truncate-end",children:A(c)})]},t))}),u===void 0?void 0:o(n,{marginTop:1,children:u}),o(n,{marginTop:1,children:i(e,{children:["Allow? [",o(e,{bold:!0,color:a,children:"y"}),"es /"," ",o(e,{bold:!0,color:a,children:"a"}),"lways /"," ",o(e,{bold:!0,color:a,children:"n"}),"o ]"]})})]})}export{O as ApprovalPrompt,O as default};
1
+ import{jsxs as t,jsx as o}from"react/jsx-runtime";import n from"@visulima/tui/components/box";import e from"@visulima/tui/components/text";import S from"@visulima/tui/hooks/use-focus";import I from"@visulima/tui/hooks/use-input";import{useCallback as x}from"react";const C={high:"red",low:"green",medium:"yellow"},R={high:"HIGH RISK",low:"LOW RISK",medium:"MEDIUM RISK"},A=r=>{if(r===null)return"null";if(typeof r=="string")return r;if(typeof r=="number"||typeof r=="boolean")return String(r);try{return JSON.stringify(r)}catch{return String(r)}};function k({accentColor:r,autoFocus:y=!0,children:a,description:s,isDisabled:f=!1,onDecision:i,params:p,risk:h="medium",tool:b}){const d=C[h],m=r??d,{isFocused:w}=S({autoFocus:y,isActive:!f});I(x((l,c)=>{const u=l.toLowerCase();if(u==="y"||c.return){i("allow-once");return}if(u==="a"){i("allow-always");return}(u==="n"||c.escape)&&i("deny")},[i]),{isActive:!f&&w});const g=p===void 0?[]:Object.entries(p);return t(n,{borderColor:d,borderStyle:"round",flexDirection:"column",paddingX:1,children:[t(n,{children:[t(e,{backgroundColor:d,color:"black",children:[" ",R[h]," "]}),t(e,{children:[" ",o(e,{bold:!0,children:b})]})]}),s===void 0?void 0:o(n,{marginTop:1,children:o(e,{children:s})}),g.length===0?void 0:o(n,{flexDirection:"column",marginTop:1,children:g.map(([l,c])=>t(n,{children:[t(e,{color:"cyan",children:[l,"="]}),o(e,{wrap:"truncate-end",children:A(c)})]},l))}),a===void 0?void 0:o(n,{marginTop:1,children:a}),o(n,{marginTop:1,children:t(e,{children:["Allow? [",o(e,{bold:!0,color:m,children:"y"}),"es /"," ",o(e,{bold:!0,color:m,children:"a"}),"lways /"," ",o(e,{bold:!0,color:m,children:"n"}),"o ]"]})})]})}export{k as ApprovalPrompt,k as default};
@@ -1 +1 @@
1
- import{jsxs as b,jsx as m}from"react/jsx-runtime";import{createBrailleGrid as P}from"@visulima/tui/canvas";import M from"@visulima/tui/components/box";import Y from"@visulima/tui/components/canvas";import w from"@visulima/tui/components/text";import{useMemo as _}from"react";import{t as v,p as F,c as D,D as L,a as u}from"./packem_shared/line-chart-BbhMhcZg.js";const S=L,V={heavy:"▓",light:"░",medium:"▒"};function R({axisColor:I="gray",fillDensity:g="medium",height:y=10,maxY:p,minY:x,palette:d=S,series:f,showLegend:A=!0,width:N=40}){const n=_(()=>{const o=f.map((r,h)=>({color:F(r,h,d),points:v(r.data),series:r})),t=D(o);return{list:o,xMax:t.xMax===Number.NEGATIVE_INFINITY?1:t.xMax,xMin:t.xMin===Number.POSITIVE_INFINITY?0:t.xMin,yMax:p??(t.yMax===Number.NEGATIVE_INFINITY?1:t.yMax),yMin:x??(t.yMin===Number.POSITIVE_INFINITY?0:t.yMin)}},[f,d,x,p]),T=V[g];return b(M,{flexDirection:"column",children:[m(Y,{draw:o=>{o.clear();const t=o.width*2,r=o.height*4,h={xMax:n.xMax,xMin:n.xMin,yMax:n.yMax,yMin:n.yMin};for(const{color:s,points:a}of n.list)if(a.length!==0)for(let l=0;l<o.width;l+=1){let i;for(const e of a){const{px:c,py:C}=u(e,h,t,r);if(Math.floor(c/2)===l){const E=Math.floor(C/4);(i===void 0||E<i)&&(i=E)}}if(i!==void 0)for(let e=i+1;e<o.height;e+=1)o.setCell(l,e,T,{color:s,dim:!0})}for(let s=0;s<o.width;s+=2)o.setCell(s,o.height-1,"·",{color:I,dim:!0});for(const{color:s,points:a}of n.list){if(a.length===0)continue;const l=P(o.width,o.height);let i=u(a[0],h,t,r);l.plotPoint(i.px,i.py);for(let e=1;e<a.length;e+=1){const c=u(a[e],h,t,r);l.plotLine(i.px,i.py,c.px,c.py),i=c}l.flush(o,{bold:!0,color:s})}},height:y,version:[f,N,y,x,p,g,I,d],width:N}),A?m(M,{gap:2,marginTop:1,children:n.list.map(({color:o,series:t},r)=>b(M,{gap:1,children:[m(w,{color:o,children:T}),m(w,{children:t.label??`Series ${r+1}`})]},`${r}:${t.label??""}`))}):void 0]})}export{R as AreaChart,R as default};
1
+ import{jsxs as A,jsx as d}from"react/jsx-runtime";import{createBrailleGrid as _}from"@visulima/tui/canvas";import u from"@visulima/tui/components/box";import b from"@visulima/tui/components/canvas";import C from"@visulima/tui/components/text";import{useMemo as v}from"react";import{t as F,p as w,c as G,D as S,a as x}from"./packem_shared/line-chart-BqOUjZTt.js";const V=S,X={heavy:"▓",light:"░",medium:"▒"};function k({axisColor:I="gray",fillDensity:T="medium",height:y=10,maxY:f,minY:m,palette:h=V,series:M,showLegend:L=!0,width:g=40}){const n=v(()=>{const o=M.map((e,c)=>({color:w(e,c,h),points:F(e.data),series:e})),i=G(o);return{list:o,xMax:i.xMax===Number.NEGATIVE_INFINITY?1:i.xMax,xMin:i.xMin===Number.POSITIVE_INFINITY?0:i.xMin,yMax:f??(i.yMax===Number.NEGATIVE_INFINITY?1:i.yMax),yMin:m??(i.yMin===Number.POSITIVE_INFINITY?0:i.yMin)}},[M,h,m,f]),N=X[T];return A(u,{flexDirection:"column",children:[d(b,{draw:o=>{o.clear();const i=o.width*2,e=o.height*4,c={xMax:n.xMax,xMin:n.xMin,yMax:n.yMax,yMin:n.yMin};for(const{color:s,points:a}of n.list)if(a.length!==0)for(let l=0;l<o.width;l+=1){let r;for(const t of a){const{px:p,py:P}=x(t,c,i,e);if(Math.floor(p/2)===l){const E=Math.floor(P/4);(r===void 0||E<r)&&(r=E)}}if(r!==void 0)for(let t=r+1;t<o.height;t+=1)o.setCell(l,t,N,{color:s,dim:!0})}for(let s=0;s<o.width;s+=2)o.setCell(s,o.height-1,"·",{color:I,dim:!0});for(const{color:s,points:a}of n.list){if(a.length===0)continue;const l=_(o.width,o.height);let r=x(a[0],c,i,e);l.plotPoint(r.px,r.py);for(let t=1;t<a.length;t+=1){const p=x(a[t],c,i,e);l.plotLine(r.px,r.py,p.px,p.py),r=p}l.flush(o,{bold:!0,color:s})}},height:y,version:[M,g,y,m,f,T,I,h],width:g}),L?d(u,{gap:2,marginTop:1,children:n.list.map(({color:o,series:i},e)=>A(u,{gap:1,children:[d(C,{color:o,children:N}),d(C,{children:i.label??`Series ${e+1}`})]},`${e}:${i.label??""}`))}):void 0]})}export{k as AreaChart,k as default};
package/dist/badge.js CHANGED
@@ -1 +1 @@
1
- import{jsxs as n,jsx as a}from"react/jsx-runtime";import o from"@visulima/tui/components/text";function l({children:r,color:t="magenta"}){const e=typeof r=="string"?r.toUpperCase():r;return n(o,{backgroundColor:t,children:[" ",a(o,{color:"black",children:e})," "]})}export{l as Badge,l as default};
1
+ import{jsxs as a,jsx as n}from"react/jsx-runtime";import r from"@visulima/tui/components/text";function m({children:o,color:t="magenta"}){const e=typeof o=="string"?o.toUpperCase():o;return a(r,{backgroundColor:t,children:[" ",n(r,{color:"black",children:e})," "]})}export{m as Badge,m as default};
package/dist/bar-chart.js CHANGED
@@ -1 +1 @@
1
- import{jsx as e,jsxs as b}from"react/jsx-runtime";import o from"@visulima/tui/components/box";import k from"@visulima/tui/components/canvas";import p from"@visulima/tui/components/text";import{useMemo as E}from"react";const j=["cyan","magenta","yellow","green","blue","red"],D=(r,t)=>{if(t!==void 0)return t;if(r.length===0)return 0;let n=r[0].value;for(let u=1;u<r.length;u+=1){const{value:h}=r[u];h>n&&(n=h)}return n},B=(r,t,n)=>n.color??t[r%t.length]??"cyan";function A({data:r,height:t=10,max:n,orientation:u="vertical",palette:h=j,showLabels:g=!0,showValues:x=!1,width:S}){const c=E(()=>D(r,n),[r,n]);if(u==="horizontal"){const i=S??24;return e(o,{flexDirection:"column",children:r.map((l,m)=>{const v=c===0?0:l.value/c,s=B(m,h,l);return b(o,{gap:1,children:[g&&l.label!==void 0?e(o,{flexShrink:0,minWidth:8,children:e(p,{dimColor:!0,wrap:"truncate-end",children:l.label})}):void 0,e(o,{flexGrow:1,flexShrink:1,children:e(k,{draw:f=>{f.clear(),f.drawHBar(0,0,i,v,{color:s})},height:1,version:[l.value,c,s,i],width:i})}),x?e(o,{flexShrink:0,children:e(p,{children:String(l.value)})}):void 0]},m)})})}const a=2,d=1,C=S??Math.max(r.length*(a+d),1);return b(o,{flexDirection:"column",children:[e(k,{draw:i=>{i.clear(),r.forEach((l,m)=>{const v=c===0?0:l.value/c,s=B(m,h,l),f=m*(a+d);for(let w=0;w<a;w+=1)i.drawVBar(f+w,0,t,v,{color:s})})},height:t,version:[r,c,h,a,d,t],width:C}),x?e(o,{children:r.map((i,l)=>e(o,{width:a+d,children:e(p,{dimColor:!0,children:String(i.value).padEnd(a+d," ")})},l))}):void 0,g?e(o,{children:r.map((i,l)=>e(o,{width:a+d,children:e(p,{dimColor:!0,wrap:"truncate-end",children:(i.label??"").padEnd(a+d," ")})},l))}):void 0]})}export{A as BarChart,A as default};
1
+ import{jsx as o,jsxs as C}from"react/jsx-runtime";import e from"@visulima/tui/components/box";import S from"@visulima/tui/components/canvas";import p from"@visulima/tui/components/text";import{useMemo as T}from"react";const W=["cyan","magenta","yellow","green","blue","red"],k=(r,i)=>{if(i!==void 0)return i;if(r.length===0)return 0;let c=r[0].value;for(let a=1;a<r.length;a+=1){const{value:d}=r[a];d>c&&(c=d)}return c},b=(r,i,c)=>c.color??i[r%i.length]??"cyan";function F({data:r,height:i=10,max:c,orientation:a="vertical",palette:d=W,showLabels:w=!0,showValues:g=!1,width:E}){const f=T(()=>k(r,c),[r,c]);if(a==="horizontal"){const l=E??24;return o(e,{flexDirection:"column",children:r.map((n,m)=>{const v=f===0?0:n.value/f,u=b(m,d,n);return C(e,{gap:1,children:[w&&n.label!==void 0?o(e,{flexShrink:0,minWidth:8,children:o(p,{dimColor:!0,wrap:"truncate-end",children:n.label})}):void 0,o(e,{flexGrow:1,flexShrink:1,children:o(S,{draw:s=>{s.clear(),s.drawHBar(0,0,l,v,{color:u})},height:1,version:[n.value,f,u,l],width:l})}),g?o(e,{flexShrink:0,children:o(p,{children:String(n.value)})}):void 0]},m)})})}const t=2,h=1,B=E??Math.max(r.length*(t+h),1);return C(e,{flexDirection:"column",children:[o(S,{draw:l=>{l.clear(),r.forEach((n,m)=>{const v=f===0?0:n.value/f,u=b(m,d,n),s=m*(t+h);for(let x=0;x<t;x+=1)l.drawVBar(s+x,0,i,v,{color:u})})},height:i,version:[r,f,d,t,h,i],width:B}),g?o(e,{children:r.map((l,n)=>o(e,{width:t+h,children:o(p,{dimColor:!0,children:String(l.value).padEnd(t+h," ")})},n))}):void 0,w?o(e,{children:r.map((l,n)=>o(e,{width:t+h,children:o(p,{dimColor:!0,wrap:"truncate-end",children:(l.label??"").padEnd(t+h," ")})},n))}):void 0]})}export{F as BarChart,F as default};
package/dist/big-text.js CHANGED
@@ -1 +1 @@
1
- import{jsx as s}from"react/jsx-runtime";import m from"@visulima/tui/components/text";import p from"cfonts";import{useMemo as f}from"react";const u={align:"left",backgroundColor:"transparent",colors:["system"],font:"block",letterSpacing:1,lineHeight:1,maxLength:0,space:!0};function k({align:t,backgroundColor:e,colors:o,font:r,letterSpacing:n,lineHeight:i,maxLength:a,space:g,text:l}){const c=f(()=>p.render(l,{...u,align:t,backgroundColor:e,colors:o,font:r,letterSpacing:n,lineHeight:i,maxLength:a,space:g}),[l,t,e,o,r,n,i,a,g]);return s(m,{children:c&&c.string})}export{k as BigText,k as default};
1
+ import{jsx as p}from"react/jsx-runtime";import u from"@visulima/tui/components/text";import a from"cfonts";import{useMemo as c}from"react";const l={align:"left",backgroundColor:"transparent",colors:["system"],font:"block",letterSpacing:1,lineHeight:1,maxLength:0,space:!0};function h({align:r,backgroundColor:t,colors:e,font:o,letterSpacing:n,lineHeight:s,maxLength:m,space:f,text:i}){const d=c(()=>a.render(i,{...l,align:r,backgroundColor:t,colors:e,font:o,letterSpacing:n,lineHeight:s,maxLength:m,space:f}),[i,r,t,e,o,n,s,m,f]);return p(u,{children:d&&d.string})}export{h as BigText,h as default};
package/dist/blink-dot.js CHANGED
@@ -1 +1 @@
1
- import{jsx as c}from"react/jsx-runtime";import l from"@visulima/tui/components/text";import m from"@visulima/tui/hooks/use-animation";function p({character:t="●",color:o="red",interval:i=800,isActive:r=!0}){const{frame:e}=m({interval:Math.max(1,Math.floor(i/2)),isActive:r}),a=!r||e%2===0;return c(l,{color:o,children:a?t:" "})}export{p as BlinkDot,p as default};
1
+ import{jsx as m}from"react/jsx-runtime";import a from"@visulima/tui/components/text";import f from"@visulima/tui/hooks/use-animation";function p({character:t="●",color:o="red",interval:e=800,isActive:r=!0}){const{frame:n}=f({interval:Math.max(1,Math.floor(e/2)),isActive:r}),i=!r||n%2===0;return m(a,{color:o,children:i?t:" "})}export{p as BlinkDot,p as default};
@@ -1 +1 @@
1
- import{jsx as d,jsxs as o,Fragment as a}from"react/jsx-runtime";import c from"@visulima/tui/components/box";import t from"@visulima/tui/components/text";import{Fragment as s}from"react";function b({currentColor:m="blue",items:e,separator:n="›"}){return d(c,{children:e.map((r,l)=>{const i=l===e.length-1;return o(s,{children:[l>0?o(t,{dimColor:!0,children:[" ",n," "]}):void 0,o(t,{bold:i,color:i?m:void 0,dimColor:!i,children:[r.icon===void 0?void 0:o(a,{children:[r.icon," "]}),r.label]})]},r.key??r.label)})})}export{b as Breadcrumb,b as default};
1
+ import{jsx as a,jsxs as o,Fragment as c}from"react/jsx-runtime";import m from"@visulima/tui/components/box";import d from"@visulima/tui/components/text";import{Fragment as s}from"react";function b({currentColor:i="blue",items:n,separator:t="›"}){return a(m,{children:n.map((r,e)=>{const l=e===n.length-1;return o(s,{children:[e>0?o(d,{dimColor:!0,children:[" ",t," "]}):void 0,o(d,{bold:l,color:l?i:void 0,dimColor:!l,children:[r.icon===void 0?void 0:o(c,{children:[r.icon," "]}),r.label]})]},r.key??r.label)})})}export{b as Breadcrumb,b as default};
package/dist/button.js CHANGED
@@ -1 +1 @@
1
- import{jsx as s,jsxs as f}from"react/jsx-runtime";import c from"@visulima/tui/components/box";import e from"@visulima/tui/components/text";import p from"@visulima/tui/hooks/use-focus";import b from"@visulima/tui/hooks/use-input";import{useCallback as g}from"react";const h="round",y=(i,l,n,r)=>{if(!n){if(i==="primary"&&l)return"black";if(l)return r}};function A({accentColor:i="blue",autoFocus:l=!1,children:n,isDisabled:r=!1,onPress:t,variant:d="primary"}){const{isFocused:o}=p({autoFocus:l,isActive:!r});b(g((m,u)=>{o&&(u.return||m===" ")&&t?.()},[o,t]),{isActive:!r&&o});const a=y(d,o,r,i);return d==="ghost"?s(c,{paddingX:1,children:f(e,{bold:o,color:a,dimColor:r,children:[o?"▸ ":" ",n]})}):s(c,{backgroundColor:d==="primary"&&o?i:void 0,borderColor:d==="outline"?o?i:"gray":d==="secondary"||o?i:void 0,borderStyle:h,paddingX:1,children:s(e,{bold:o,color:a,dimColor:r,children:n})})}export{A as Button,A as default};
1
+ import{jsx as n,jsxs as s}from"react/jsx-runtime";import l from"@visulima/tui/components/box";import m from"@visulima/tui/components/text";import g from"@visulima/tui/hooks/use-focus";import x from"@visulima/tui/hooks/use-input";import{useCallback as y}from"react";const b="round",k=(o,u,i,t)=>{if(!i){if(o==="primary"&&u)return"black";if(u)return t}};function R({accentColor:o="blue",autoFocus:u=!1,children:i,isDisabled:t=!1,onPress:f,variant:e="primary"}){const{isFocused:r}=g({autoFocus:u,isActive:!t});x(y((p,c)=>{r&&(c.return||p===" ")&&f?.()},[r,f]),{isActive:!t&&r});const d=k(e,r,t,o);return e==="ghost"?n(l,{paddingX:1,children:s(m,{bold:r,color:d,dimColor:t,children:[r?"▸ ":" ",i]})}):n(l,{backgroundColor:e==="primary"&&r?o:void 0,borderColor:e==="outline"?r?o:"gray":e==="secondary"||r?o:void 0,borderStyle:b,paddingX:1,children:n(m,{bold:r,color:d,dimColor:t,children:i})})}export{R as Button,R as default};
package/dist/calendar.js CHANGED
@@ -1 +1 @@
1
- import{jsxs as y,jsx as u}from"react/jsx-runtime";import h from"@visulima/tui/components/box";import w from"@visulima/tui/components/text";import W from"@visulima/tui/hooks/use-focus";import I from"@visulima/tui/hooks/use-input";import{useMemo as F,useState as K,useRef as P,useCallback as S}from"react";const X=["January","February","March","April","May","June","July","August","September","October","November","December"],k=["Su","Mo","Tu","We","Th","Fr","Sa"],p=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),x=(e,r)=>{const i=e.getFullYear(),l=e.getMonth()+r,g=new Date(i,l+1,0).getDate(),a=Math.min(e.getDate(),g);return new Date(i,l,a)},J=(e,r)=>e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate(),T=(e,r,i)=>r!==void 0&&e<p(r)||i!==void 0&&e>p(i),$=(e,r,i)=>{const l=(new Date(e,r,1).getDay()-i+7)%7,g=new Date(e,r+1,0).getDate(),a=[];for(let o=0;o<l;o+=1)a.push(void 0);for(let o=1;o<=g;o+=1)a.push(new Date(e,r,o));for(;a.length%7!==0;)a.push(void 0);const D=[];for(let o=0;o<a.length;o+=7)D.push(a.slice(o,o+7));return D};function Z({accentColor:e="blue",autoFocus:r=!1,defaultValue:i,firstDayOfWeek:l=1,isDisabled:g=!1,maxDate:a,minDate:D,onChange:o,onSubmit:b,selectedColor:j="green",value:f}){const{isFocused:m}=W({autoFocus:r,isActive:!g}),M=F(()=>p(new Date),[]),O=p(f??i??M),[B,E]=K(O),c=f?p(f):B,v=P(c);v.current=c;const N=F(()=>[...k.slice(l),...k.slice(0,l)],[l]),R=F(()=>$(c.getFullYear(),c.getMonth(),l),[c,l]),d=S(s=>{const n=p(s);T(n,D,a)||(f===void 0&&E(n),o?.(n))},[f,o,D,a]);I(S((s,n)=>{if(!m)return;const{current:t}=v;n.leftArrow?d(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1)):n.rightArrow?d(new Date(t.getFullYear(),t.getMonth(),t.getDate()+1)):n.upArrow?d(new Date(t.getFullYear(),t.getMonth(),t.getDate()-7)):n.downArrow?d(new Date(t.getFullYear(),t.getMonth(),t.getDate()+7)):n.pageUp?d(x(t,-1)):n.pageDown?d(x(t,1)):n.return&&b?.(t)},[m,d,b]),{isActive:!g&&m});const U=`${X[c.getMonth()]} ${c.getFullYear()}`;return y(h,{borderColor:m?e:void 0,borderStyle:"round",flexDirection:"column",paddingX:1,children:[u(h,{justifyContent:"center",children:u(w,{bold:!0,color:e,children:U})}),u(h,{marginTop:1,children:N.map(s=>u(h,{width:3,children:u(w,{dimColor:!0,children:s.padEnd(2," ")})},s))}),R.map((s,n)=>u(h,{children:s.map((t,C)=>{if(t===void 0)return u(h,{width:3,children:u(w,{children:" "})},C);const Y=J(t,M),A=J(t,c),V=T(t,D,a);return u(h,{width:3,children:y(w,{backgroundColor:A&&m?e:void 0,bold:Y,color:A&&m?"black":Y?j:void 0,dimColor:V||g,children:[String(t.getDate()).padStart(2," ")," "]})},C)})},n))]})}export{Z as Calendar,Z as default};
1
+ import{jsxs as T,jsx as i}from"react/jsx-runtime";import h from"@visulima/tui/components/box";import F from"@visulima/tui/components/text";import y from"@visulima/tui/hooks/use-focus";import H from"@visulima/tui/hooks/use-input";import{useMemo as C,useState as K,useRef as U,useCallback as E}from"react";const X=["January","February","March","April","May","June","July","August","September","October","November","December"],O=["Su","Mo","Tu","We","Th","Fr","Sa"],p=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),R=(e,o)=>{const s=e.getFullYear(),l=e.getMonth()+o,f=new Date(s,l+1,0).getDate(),a=Math.min(e.getDate(),f);return new Date(s,l,a)},j=(e,o)=>e.getFullYear()===o.getFullYear()&&e.getMonth()===o.getMonth()&&e.getDate()===o.getDate(),x=(e,o,s)=>o!==void 0&&e<p(o)||s!==void 0&&e>p(s),q=(e,o,s)=>{const a=(new Date(e,o,1).getDay()-s+7)%7,M=new Date(e,o+1,0).getDate(),c=[];for(let r=0;r<a;r+=1)c.push(void 0);for(let r=1;r<=M;r+=1)c.push(new Date(e,o,r));for(;c.length%7!==0;)c.push(void 0);const D=[];for(let r=0;r<c.length;r+=7)D.push(c.slice(r,r+7));return D};function ee({accentColor:e="blue",autoFocus:o=!1,defaultValue:s,firstDayOfWeek:l=1,isDisabled:f=!1,maxDate:a,minDate:M,onChange:c,onSubmit:D,selectedColor:r="green",value:m}){const{isFocused:w}=y({autoFocus:o,isActive:!f}),Y=C(()=>p(new Date),[]),J=p(m??s??Y),[N,B]=K(J),u=m?p(m):N,b=U(u);b.current=u;const I=C(()=>[...O.slice(l),...O.slice(0,l)],[l]),L=C(()=>q(u.getFullYear(),u.getMonth(),l),[u,l]),g=E(d=>{const n=p(d);x(n,M,a)||(m===void 0&&B(n),c?.(n))},[m,c,M,a]);H(E((d,n)=>{if(!w)return;const{current:t}=b;n.leftArrow?g(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1)):n.rightArrow?g(new Date(t.getFullYear(),t.getMonth(),t.getDate()+1)):n.upArrow?g(new Date(t.getFullYear(),t.getMonth(),t.getDate()-7)):n.downArrow?g(new Date(t.getFullYear(),t.getMonth(),t.getDate()+7)):n.pageUp?g(R(t,-1)):n.pageDown?g(R(t,1)):n.return&&D?.(t)},[w,g,D]),{isActive:!f&&w});const _=`${X[u.getMonth()]} ${u.getFullYear()}`;return T(h,{borderColor:w?e:void 0,borderStyle:"round",flexDirection:"column",paddingX:1,children:[i(h,{justifyContent:"center",children:i(F,{bold:!0,color:e,children:_})}),i(h,{marginTop:1,children:I.map(d=>i(h,{width:3,children:i(F,{dimColor:!0,children:d.padEnd(2," ")})},d))}),L.map((d,n)=>i(h,{children:d.map((t,A)=>{if(t===void 0)return i(h,{width:3,children:i(F,{children:" "})},A);const v=j(t,Y),S=j(t,u),$=x(t,M,a);return i(h,{width:3,children:T(F,{backgroundColor:S&&w?e:void 0,bold:v,color:S&&w?"black":v?r:void 0,dimColor:$||f,children:[String(t.getDate()).padStart(2," ")," "]})},A)})},n))]})}export{ee as Calendar,ee as default};
package/dist/card.js CHANGED
@@ -1 +1 @@
1
- import{jsxs as r,jsx as i}from"react/jsx-runtime";import o from"@visulima/tui/components/box";import c from"@visulima/tui/components/text";import{Divider as v}from"./divider.js";function x({borderColor:m,borderStyle:h="round",children:f,footer:n,headerRight:e,subtitle:d,title:t,titleColor:u,width:l}){return r(o,{borderColor:m,borderStyle:h,flexDirection:"column",paddingX:1,width:l,children:[t!==void 0||d!==void 0||e!==void 0?r(o,{flexDirection:"column",marginBottom:1,children:[r(o,{justifyContent:"space-between",children:[i(o,{children:t===void 0?void 0:i(c,{bold:!0,color:u,children:t})}),e===void 0?void 0:i(o,{children:e})]}),d===void 0?void 0:i(c,{dimColor:!0,children:d})]}):void 0,i(o,{flexDirection:"column",children:f}),n===void 0?void 0:r(o,{flexDirection:"column",marginTop:1,children:[i(v,{dimColor:!0,length:typeof l=="number"?Math.max(1,l-4):void 0}),i(o,{marginTop:1,children:n})]})]})}export{x as Card,x as default};
1
+ import{jsxs as r,jsx as i}from"react/jsx-runtime";import o from"@visulima/tui/components/box";import l from"@visulima/tui/components/text";import{Divider as u}from"./divider.js";function C({borderColor:v,borderStyle:t="round",children:a,footer:m,headerRight:n,subtitle:d,title:e,titleColor:f,width:c}){return r(o,{borderColor:v,borderStyle:t,flexDirection:"column",paddingX:1,width:c,children:[e!==void 0||d!==void 0||n!==void 0?r(o,{flexDirection:"column",marginBottom:1,children:[r(o,{justifyContent:"space-between",children:[i(o,{children:e===void 0?void 0:i(l,{bold:!0,color:f,children:e})}),n===void 0?void 0:i(o,{children:n})]}),d===void 0?void 0:i(l,{dimColor:!0,children:d})]}):void 0,i(o,{flexDirection:"column",children:a}),m===void 0?void 0:r(o,{flexDirection:"column",marginTop:1,children:[i(u,{dimColor:!0,length:typeof c=="number"?Math.max(1,c-4):void 0}),i(o,{marginTop:1,children:m})]})]})}export{C as Card,C as default};
@@ -1 +1 @@
1
- import{jsx as c,jsxs as g}from"react/jsx-runtime";import v from"@visulima/tui/components/box";import h from"@visulima/tui/components/text";import R from"@visulima/tui/hooks/use-focus";import E from"@visulima/tui/hooks/use-input";import{useState as F,useMemo as G,useRef as I,useCallback as j}from"react";const M=[];function k(u,s){return s===0?0:(u%s+s)%s}function K({accentColor:u="blue",autoFocus:s=!1,defaultValue:y=M,isDisabled:p=!1,onChange:b,onSubmit:D,options:t,value:d}){const{isFocused:C}=R({autoFocus:s,isActive:!p}),w=d!==void 0,[x,B]=F(y),n=G(()=>new Set(d??x),[d,x]),[f,A]=F(0),S=I(b);S.current=b;const m=j(r=>{const o=t.map(e=>e.value).filter(e=>r.has(e));return w||B(o),S.current?.(o),o},[w,t]),L=j((r,o)=>{if(o.upArrow){A(e=>k(e-1,t.length));return}if(o.downArrow){A(e=>k(e+1,t.length));return}if(r===" "){const e=t[f];if(e===void 0||e.isDisabled)return;const a=new Set(n);a.has(e.value)?a.delete(e.value):a.add(e.value),m(a);return}if(r==="a"){const e=t.filter(i=>!i.isDisabled),a=e.every(i=>n.has(i.value)),l=new Set(t.filter(i=>i.isDisabled&&n.has(i.value)).map(i=>i.value));if(!a)for(const i of e)l.add(i.value);m(l);return}o.return&&D?.(t.map(e=>e.value).filter(e=>n.has(e)))},[n,f,m,D,t]);return E(L,{isActive:C&&!p}),c(v,{flexDirection:"column",children:t.map((r,o)=>{const e=C&&o===f,a=n.has(r.value),l=a?"◉":"◯",i=!r.isDisabled&&(a||e)?u:void 0;return g(v,{children:[c(h,{color:e?u:void 0,children:e?"❯ ":" "}),g(h,{color:i,dimColor:r.isDisabled,children:[l," ",r.label]}),r.description===void 0?void 0:c(v,{marginLeft:1,children:c(h,{dimColor:!0,children:r.description})})]},o)})})}export{K as CheckboxGroup,K as default};
1
+ import{jsx as o,jsxs as p}from"react/jsx-runtime";import m from"@visulima/tui/components/box";import v from"@visulima/tui/components/text";import M from"@visulima/tui/hooks/use-focus";import R from"@visulima/tui/hooks/use-input";import{useState as S,useMemo as T,useRef as B,useCallback as H}from"react";const G=[];function j(a,n){return n===0?0:(a%n+n)%n}function K({accentColor:a="blue",autoFocus:n=!1,defaultValue:E=G,isDisabled:b=!1,onChange:x,onSubmit:g,options:s,value:d}){const{isFocused:w}=M({autoFocus:n,isActive:!b}),C=d!==void 0,[A,F]=S(E),c=T(()=>new Set(d??A),[d,A]),[f,D]=S(0),k=B(x);k.current=x;const h=H(r=>{const i=s.map(e=>e.value).filter(e=>r.has(e));return C||F(i),k.current?.(i),i},[C,s]),I=H((r,i)=>{if(i.upArrow){D(e=>j(e-1,s.length));return}if(i.downArrow){D(e=>j(e+1,s.length));return}if(r===" "){const e=s[f];if(e===void 0||e.isDisabled)return;const l=new Set(c);l.has(e.value)?l.delete(e.value):l.add(e.value),h(l);return}if(r==="a"){const e=s.filter(t=>!t.isDisabled),l=e.every(t=>c.has(t.value)),u=new Set(s.filter(t=>t.isDisabled&&c.has(t.value)).map(t=>t.value));if(!l)for(const t of e)u.add(t.value);h(u);return}i.return&&g?.(s.map(e=>e.value).filter(e=>c.has(e)))},[c,f,h,g,s]);return R(I,{isActive:w&&!b}),o(m,{flexDirection:"column",children:s.map((r,i)=>{const e=w&&i===f,l=c.has(r.value),u=l?"◉":"◯",L=!r.isDisabled&&(l||e)?a:void 0;return p(m,{children:[o(v,{color:e?a:void 0,children:e?"❯ ":" "}),p(v,{color:L,dimColor:r.isDisabled,children:[u," ",r.label]}),r.description===void 0?void 0:o(m,{marginLeft:1,children:o(v,{dimColor:!0,children:r.description})})]},i)})})}export{K as CheckboxGroup,K as default};
package/dist/checkbox.js CHANGED
@@ -1 +1 @@
1
- import{jsxs as l,jsx as v}from"react/jsx-runtime";import C from"@visulima/tui/components/box";import a from"@visulima/tui/components/text";import b from"@visulima/tui/hooks/use-focus";import k from"@visulima/tui/hooks/use-input";import{useState as x,useCallback as F}from"react";const g="☒",j="☐";function w({accentColor:s="blue",autoFocus:m=!1,children:c,defaultChecked:u=!1,isChecked:e,isDisabled:i=!1,onChange:t}){const{isFocused:o}=b({autoFocus:m,isActive:!i}),[f,n]=x(u),r=e??f;return k(F((h,p)=>{if(o&&(p.return||h===" ")){const d=!r;e===void 0&&n(d),t?.(d)}},[o,r,e,t]),{isActive:!i&&o}),l(C,{gap:1,children:[l(a,{color:o?s:void 0,dimColor:i,children:[o?"▸ ":" ",r?g:j]}),c===void 0?void 0:v(a,{color:o?s:void 0,dimColor:i,children:c})]})}export{w as Checkbox,w as default};
1
+ import{jsxs as f,jsx as x}from"react/jsx-runtime";import a from"@visulima/tui/components/box";import m from"@visulima/tui/components/text";import E from"@visulima/tui/hooks/use-focus";import I from"@visulima/tui/hooks/use-input";import{useState as k,useCallback as N}from"react";const h="☒",j="☐";function B({accentColor:c="blue",autoFocus:u=!1,children:i,defaultChecked:l=!1,isChecked:r,isDisabled:t=!1,onChange:n}){const{isFocused:o}=E({autoFocus:u,isActive:!t}),[p,d]=k(l),e=r??p;return I(N((C,v)=>{if(o&&(v.return||C===" ")){const s=!e;r===void 0&&d(s),n?.(s)}},[o,e,r,n]),{isActive:!t&&o}),f(a,{gap:1,children:[f(m,{color:o?c:void 0,dimColor:t,children:[o?"▸ ":" ",e?h:j]}),i===void 0?void 0:x(m,{color:o?c:void 0,dimColor:t,children:i})]})}export{B as Checkbox,B as default};
package/dist/code.js CHANGED
@@ -1,2 +1,2 @@
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{resolveLanguage as S,isLanguageSupported as w,getHighlighter as b,getCachedTokens as v,tokenLinesToElements as y}from"@visulima/tui/highlighter";import{useState as C,useRef as T,useEffect as j}from"react";function q({code:o,highlightLines:c,language:i,showLineNumbers:s=!1,startLine:l=1,theme:u="github-dark-default"}){const[h,a]=C(null),t=T(!1);j(()=>{t.current=!1;const e=i?S(i):"text";if(e!=="text"&&!w(e)){a(null);return}return(async()=>{try{const r=await b(e==="text"?[]:[e],u),n=v(r,o,e,u);t.current||a(n.tokens)}catch{t.current||a(null)}})(),()=>{t.current=!0}},[o,i,u]);const x={highlightLines:c,showLineNumbers:s,startLine:l};if(h)return y(h,x);const f=o.split(`
2
- `),k=s?String(l+f.length-1).length:0;return m(p,{flexDirection:"column",children:f.map((e,r)=>{const n=l+r,g=c?.has(n)??!1;return d(p,{children:[s?d(L,{color:g?"yellow":void 0,dimColor:!g,children:[String(n).padStart(k)," "]}):void 0,m(L,{children:e})]},r)})})}export{q as Code,q as default};
1
+ import{jsx as p,jsxs as h}from"react/jsx-runtime";import m from"@visulima/tui/components/box";import x from"@visulima/tui/components/text";import{resolveLanguage as v,isLanguageSupported as T,getHighlighter as y,getCachedTokens as C,tokenLinesToElements as j}from"@visulima/tui/highlighter";import{useState as E,useRef as H,useEffect as R}from"react";function q({code:o,highlightLines:f,language:l,showLineNumbers:i=!1,startLine:s=1,theme:c="github-dark-default"}){const[a,u]=E(null),e=H(!1);R(()=>{e.current=!1;const t=l?v(l):"text";if(t!=="text"&&!T(t)){u(null);return}return(async()=>{try{const r=await y(t==="text"?[]:[t],c),n=C(r,o,t,c);e.current||u(n.tokens)}catch{e.current||u(null)}})(),()=>{e.current=!0}},[o,l,c]);const k={highlightLines:f,showLineNumbers:i,startLine:s};if(a)return j(a,k);const d=o.split(`
2
+ `),S=i?String(s+d.length-1).length:0;return p(m,{flexDirection:"column",children:d.map((t,r)=>{const n=s+r,g=f?.has(n)??!1;return h(m,{children:[i?h(x,{color:g?"yellow":void 0,dimColor:!g,children:[String(n).padStart(S)," "]}):void 0,p(x,{children:t})]},r)})})}export{q as Code,q as default};
@@ -1 +1 @@
1
- import{jsxs as d,jsx as l}from"react/jsx-runtime";import t from"@visulima/tui/components/box";import m from"@visulima/tui/components/text";import C from"@visulima/tui/hooks/use-focus";import D from"@visulima/tui/hooks/use-input";import{useState as g,useCallback as F}from"react";function S({accentColor:c="blue",autoFocus:f=!1,children:a,defaultOpen:u=!1,isDisabled:o=!1,isOpen:r,onToggle:s,title:p}){const{isFocused:i}=C({autoFocus:f,isActive:!o}),[b,h]=g(u),e=r??b;return D(F((v,x)=>{if(x.return||v===" "){const n=!e;r===void 0&&h(n),s?.(n)}},[e,r,s]),{isActive:!o&&i}),d(t,{flexDirection:"column",children:[d(t,{children:[l(m,{color:i?c:void 0,dimColor:o,children:e?"▼ ":"▶ "}),l(m,{bold:i,color:i?c:void 0,dimColor:o,children:p})]}),e?l(t,{flexDirection:"column",marginLeft:2,children:a}):void 0]})}export{S as Collapsible,S as default};
1
+ import{jsxs as f,jsx as i}from"react/jsx-runtime";import l from"@visulima/tui/components/box";import s from"@visulima/tui/components/text";import j from"@visulima/tui/hooks/use-focus";import A from"@visulima/tui/hooks/use-input";import{useState as F,useCallback as I}from"react";function w({accentColor:n="blue",autoFocus:u=!1,children:d,defaultOpen:a=!1,isDisabled:o=!1,isOpen:e,onToggle:c,title:p}){const{isFocused:r}=j({autoFocus:u,isActive:!o}),[x,v]=F(a),t=e??x;return A(I((h,C)=>{if(C.return||h===" "){const m=!t;e===void 0&&v(m),c?.(m)}},[t,e,c]),{isActive:!o&&r}),f(l,{flexDirection:"column",children:[f(l,{children:[i(s,{color:r?n:void 0,dimColor:o,children:t?"▼ ":"▶ "}),i(s,{bold:r,color:r?n:void 0,dimColor:o,children:p})]}),t?i(l,{flexDirection:"column",marginLeft:2,children:d}):void 0]})}export{w as Collapsible,w as default};
@@ -1 +1 @@
1
- import{jsxs as C,jsx as n}from"react/jsx-runtime";import s from"@visulima/tui/components/box";import h from"@visulima/tui/components/text";import E from"@visulima/tui/hooks/use-focus";import H from"@visulima/tui/hooks/use-input";import{useState as L,useRef as P,useCallback as b}from"react";const R=["black","red","green","yellow","blue","magenta","cyan","white","gray","redBright","greenBright","yellowBright","blueBright","magentaBright","cyanBright","whiteBright"];function T(a,i){return i===0?0:(a%i+i)%i}function K({accentColor:a="blue",autoFocus:i=!1,columns:y=8,defaultValue:A,isDisabled:m=!1,onChange:f,onSubmit:p,palette:e=R,showName:k=!0,swatch:F="██",value:d}){const{isFocused:w}=E({autoFocus:i,isActive:!m}),g=d!==void 0,o=Math.max(1,y),M=Math.max(0,e.indexOf(d??A)),[D,S]=L(M),l=g?Math.max(0,e.indexOf(d)):D,x=P(f);x.current=f;const c=b(t=>{if(e.length===0)return;const r=T(l+t,e.length);g||S(r),x.current?.(e[r])},[l,g,e]),j=b((t,r)=>{r.leftArrow?c(-1):r.rightArrow?c(1):r.upArrow?c(-o):r.downArrow?c(o):r.return&&p?.(e[l])},[o,l,c,p,e]);H(j,{isActive:w&&!m});const B=[];for(let t=0;t<e.length;t+=o)B.push(e.slice(t,t+o));return C(s,{flexDirection:"column",children:[B.map((t,r)=>n(s,{children:t.map((N,v)=>{const O=r*o+v,u=w&&O===l;return C(s,{children:[n(h,{color:u?a:void 0,children:u?"[":" "}),n(h,{color:N,dimColor:m,children:F}),n(h,{color:u?a:void 0,children:u?"]":" "})]},v)})},r)),k?n(s,{marginTop:1,children:n(h,{dimColor:!0,children:String(e[l]??"")})}):void 0]})}export{K as ColorPicker,K as default};
1
+ import{jsxs as C,jsx as c}from"react/jsx-runtime";import h from"@visulima/tui/components/box";import l from"@visulima/tui/components/text";import _ from"@visulima/tui/hooks/use-focus";import y from"@visulima/tui/hooks/use-input";import{useState as H,useRef as S,useCallback as p}from"react";const U=["black","red","green","yellow","blue","magenta","cyan","white","gray","redBright","greenBright","yellowBright","blueBright","magentaBright","cyanBright","whiteBright"];function q(u,i){return i===0?0:(u%i+i)%i}function Q({accentColor:u="blue",autoFocus:i=!1,columns:T=8,defaultValue:E,isDisabled:m=!1,onChange:a,onSubmit:x,palette:r=U,showName:F=!0,swatch:M="██",value:d}){const{isFocused:v}=_({autoFocus:i,isActive:!m}),g=d!==void 0,t=Math.max(1,T),b=Math.max(0,r.indexOf(d??E)),[j,L]=H(b),e=g?Math.max(0,r.indexOf(d)):j,w=S(a);w.current=a;const s=p(n=>{if(r.length===0)return;const o=q(e+n,r.length);g||L(o),w.current?.(r[o])},[e,g,r]),O=p((n,o)=>{o.leftArrow?s(-1):o.rightArrow?s(1):o.upArrow?s(-t):o.downArrow?s(t):o.return&&x?.(r[e])},[t,e,s,x,r]);y(O,{isActive:v&&!m});const A=[];for(let n=0;n<r.length;n+=t)A.push(r.slice(n,n+t));return C(h,{flexDirection:"column",children:[A.map((n,o)=>c(h,{children:n.map((P,B)=>{const R=o*t+B,f=v&&R===e;return C(h,{children:[c(l,{color:f?u:void 0,children:f?"[":" "}),c(l,{color:P,dimColor:m,children:M}),c(l,{color:f?u:void 0,children:f?"]":" "})]},B)})},o)),F?c(h,{marginTop:1,children:c(l,{dimColor:!0,children:String(r[e]??"")})}):void 0]})}export{Q as ColorPicker,Q as default};
@@ -1,4 +1,4 @@
1
- import{jsxs as d,jsx as e}from"react/jsx-runtime";import l from"@visulima/tui/components/box";import o from"@visulima/tui/components/text";import{Spinner as a}from"./spinner.js";const f={error:"red",idle:"gray",running:"cyan",success:"green"},g=r=>r<1e3?`${Math.round(r)}ms`:`${(r/1e3).toFixed(2)}s`,x=r=>r==="running"?e(a,{type:"dots"}):{error:"✖",idle:"$",success:"✔"}[r],v=(r,i)=>{if(!Number.isFinite(i))return r;const n=r.split(`
2
- `);if(n.length<=i)return r;const t=n.slice(0,i).join(`
3
- `),c=n.length-i;return`${t}
4
- … ${c} more line${c===1?"":"s"}`};function w({command:r,cwd:i,durationMs:n,exitCode:t,maxOutputRows:c=12,output:s,status:m="idle"}){const h=f[m],p=x(m),u=[];return n!==void 0&&u.push(d(o,{dimColor:!0,children:[" ",g(n)]},"duration")),t!==void 0&&m!=="running"&&u.push(d(o,{color:t===0?"green":"red",children:[" ","exit"," ",t]},"exit")),d(l,{borderColor:h,borderStyle:"round",flexDirection:"column",paddingX:1,children:[d(l,{children:[e(o,{color:h,children:p}),e(o,{children:" "}),e(l,{flexGrow:1,flexShrink:1,minWidth:0,children:e(o,{bold:!0,wrap:"truncate-end",children:r})}),i===void 0?void 0:d(o,{dimColor:!0,children:[" ","@",i]}),u.length===0?void 0:e(l,{flexShrink:0,children:u})]}),s===void 0?void 0:e(l,{flexDirection:"column",marginTop:1,children:typeof s=="string"?e(o,{children:v(s,c)}):s})]})}export{w as CommandBlock,w as default};
1
+ import{jsxs as c,jsx as e}from"react/jsx-runtime";import l from"@visulima/tui/components/box";import i from"@visulima/tui/components/text";import{Spinner as g}from"./spinner.js";const p={error:"red",idle:"gray",running:"cyan",success:"green"},a=r=>r<1e3?`${Math.round(r)}ms`:`${(r/1e3).toFixed(2)}s`,S=r=>r==="running"?e(g,{type:"dots"}):{error:"✖",idle:"$",success:"✔"}[r],v=(r,n)=>{if(!Number.isFinite(n))return r;const o=r.split(`
2
+ `);if(o.length<=n)return r;const t=o.slice(0,n).join(`
3
+ `),d=o.length-n;return`${t}
4
+ … ${d} more line${d===1?"":"s"}`};function O({command:r,cwd:n,durationMs:o,exitCode:t,maxOutputRows:d=12,output:s,status:f="idle"}){const u=p[f],m=S(f),h=[];return o!==void 0&&h.push(c(i,{dimColor:!0,children:[" ",a(o)]},"duration")),t!==void 0&&f!=="running"&&h.push(c(i,{color:t===0?"green":"red",children:[" ","exit"," ",t]},"exit")),c(l,{borderColor:u,borderStyle:"round",flexDirection:"column",paddingX:1,children:[c(l,{children:[e(i,{color:u,children:m}),e(i,{children:" "}),e(l,{flexGrow:1,flexShrink:1,minWidth:0,children:e(i,{bold:!0,wrap:"truncate-end",children:r})}),n===void 0?void 0:c(i,{dimColor:!0,children:[" ","@",n]}),h.length===0?void 0:e(l,{flexShrink:0,children:h})]}),s===void 0?void 0:e(l,{flexDirection:"column",marginTop:1,children:typeof s=="string"?e(i,{children:v(s,d)}):s})]})}export{O as CommandBlock,O as default};
@@ -1 +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};
1
+ import{jsxs as u,jsx as n}from"react/jsx-runtime";import s from"@visulima/tui/components/box";import o from"@visulima/tui/components/text";import k from"@visulima/tui/hooks/use-focus";import y from"@visulima/tui/hooks/use-input";import{isInsertableInput as F}from"@visulima/tui/input";import{useState as M,useRef as T,useMemo as A,useEffect as D,useCallback as L}from"react";const R=(h,p)=>{if(h.length===0)return 1;const x=[p.label,p.description??"",...p.keywords??[]].map(i=>i.toLowerCase()).filter(i=>i.length>0),a=h.toLowerCase();let d=0;for(const i of x){if(i.includes(a)){const f=i.indexOf(a);d=Math.max(d,100-f);continue}let m=0,g=0;for(const f of a){const c=i.indexOf(f,m);if(c===-1){g=0;break}g+=1,m=c+1}g===a.length&&(d=Math.max(d,20))}return d};function P({accentColor:h="cyan",autoFocus:p=!0,commands:x,emptyText:a="No results",limit:d=8,onCancel:i,onSelect:m,placeholder:g="Type a command or search..."}){const{isFocused:f}=k({autoFocus:p}),[c,I]=M(""),[v,b]=M(0),w=T(v);w.current=v;const l=A(()=>{const e=x.map(r=>({command:r,score:R(c,r)})).filter(({score:r})=>r>0);return e.sort((r,t)=>t.score-r.score),e.slice(0,d).map(({command:r})=>r)},[x,c,d]);return D(()=>{const e=Math.max(0,l.length-1);w.current>e&&(w.current=e,b(e))},[l]),y(L((e,r)=>{if(f){if(r.escape){i?.();return}if(r.downArrow){if(l.length===0)return;b(t=>Math.min(l.length-1,t+1));return}if(r.upArrow){b(t=>Math.max(0,t-1));return}if(r.return){const t=l[w.current];t&&m(t.id,c);return}if(r.backspace||r.delete){I(t=>t.slice(0,-1)),b(0);return}F(e,r)&&(I(t=>t+e),b(0))}},[f,l,c,m,i]),{isActive:f}),u(s,{borderColor:h,borderStyle:"round",flexDirection:"column",paddingX:1,children:[u(s,{children:[n(o,{color:h,children:"❯"}),u(o,{children:[" ",c.length===0?n(o,{dimColor:!0,children:g}):c]}),n(o,{inverse:!0,children:" "})]}),n(s,{marginTop:1,children:u(o,{dimColor:!0,children:[l.length," of ",x.length]})}),n(s,{flexDirection:"column",marginTop:1,children:l.length===0?n(o,{dimColor:!0,children:a}):l.map((e,r)=>{const t=r===v,C=t?h:void 0;return u(s,{flexDirection:"column",children:[u(s,{children:[n(o,{color:C,children:t?"▸ ":" "}),e.icon===void 0?void 0:u(o,{color:C,children:[e.icon," "]}),n(s,{flexGrow:1,flexShrink:1,minWidth:0,children:n(o,{bold:t,color:C,wrap:"truncate-end",children:e.label})}),e.hotkey===void 0?void 0:n(s,{flexShrink:0,children:u(o,{dimColor:!0,children:[" ",e.hotkey]})})]}),e.description===void 0?void 0:n(s,{marginLeft:2,children:n(o,{dimColor:!0,wrap:"truncate-end",children:e.description})})]},e.id)})})]})}export{P as CommandPalette,P as default};
@@ -1 +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};
1
+ import{jsxs as b,jsx as o}from"react/jsx-runtime";import t from"@visulima/tui/components/box";import s from"@visulima/tui/components/text";import A from"@visulima/tui/hooks/use-focus";import B from"@visulima/tui/hooks/use-input";import{useState as j,useCallback as y}from"react";const O={danger:"red",info:"blue",warning:"yellow"},g=({color:n,isFocused:r,label:e})=>o(t,{backgroundColor:r?n:void 0,borderColor:r?n:void 0,borderStyle:"round",paddingX:1,children:o(s,{bold:r,color:r?"black":void 0,children:e})});function E({autoFocus:n=!0,cancelLabel:r="Cancel",children:e,confirmLabel:p="Confirm",defaultFocus:v="confirm",isDisabled:u=!1,onCancel:f,onConfirm:m,title:a,tone:x="info",width:h}){const[i,C]=j(v),l=O[x],{isFocused:w}=A({autoFocus:n,isActive:!u});return B(y((c,d)=>{if(d.leftArrow||d.rightArrow||c==="h"||c==="l"){C(i==="confirm"?"cancel":"confirm");return}if(d.return){i==="confirm"?m():f();return}if(d.escape||c==="n"){f();return}c==="y"&&m()},[i,m,f]),{isActive:!u&&w}),b(t,{borderColor:l,borderStyle:"round",flexDirection:"column",paddingX:1,paddingY:1,width:h,children:[a===void 0?void 0:o(t,{marginBottom:1,children:o(s,{bold:!0,color:l,children:a})}),e===void 0?void 0:o(t,{flexDirection:"column",marginBottom:1,children:typeof e=="string"?o(s,{children:e}):e}),b(t,{gap:2,justifyContent:"flex-end",children:[o(g,{color:l,isFocused:i==="cancel",label:r}),o(g,{color:l,isFocused:i==="confirm",label:p})]})]})}export{E as ConfirmDialog,E as default};
@@ -1 +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};
1
+ import{jsx as i,jsxs as x}from"react/jsx-runtime";import p from"@visulima/tui/components/box";import l from"@visulima/tui/components/text";import T from"@visulima/tui/hooks/use-input";import{useRef as m,useCallback as a}from"react";function k({defaultChoice:r="confirm",isDisabled:n=!1,onCancel:o,onConfirm:c,submitOnEnter:f=!0}){const e=m(c);e.current=c;const t=m(o);return t.current=o,T(a((s,u)=>{if(s.toLowerCase()==="y"){e.current();return}if(s.toLowerCase()==="n"){t.current();return}u.return&&f&&(r==="confirm"?e.current():t.current())},[f,r]),{isActive:!n}),i(p,{children:x(l,{dimColor:n,children:[r==="confirm"?"Y":"y","/",r==="cancel"?"N":"n"]})})}export{k as ConfirmInput,k as default};
@@ -1 +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};
1
+ import{jsx as s,jsxs as d}from"react/jsx-runtime";import c from"@visulima/tui/components/box";import l from"@visulima/tui/components/text";import p from"@visulima/tui/hooks/use-console-capture";import{useMemo as g}from"react";const f={debug:"gray",error:"red",info:"blue",log:"white",warn:"yellow"},b={debug:"DBG",error:"ERR",info:"INF",log:"LOG",warn:"WRN"},v=t=>{const r=new Date(t),e=String(r.getHours()).padStart(2,"0"),i=String(r.getMinutes()).padStart(2,"0"),n=String(r.getSeconds()).padStart(2,"0");return`${e}:${i}:${n}`};function E({dock:t="bottom",filter:r,height:e=8,maxEntries:i=200,showLevel:n=!0,showTimestamp:u=!0}){const{entries:m}=p({filter:r,maxEntries:i}),a=g(()=>m.slice(-e),[m,e]);return s(c,{borderBottom:t==="top",borderBottomColor:"gray",borderTop:t==="bottom",borderTopColor:"gray",flexDirection:"column",height:e+1,children:a.length===0?s(l,{dimColor:!0,children:"Console output will appear here..."}):a.map(o=>d(c,{children:[u?d(l,{dimColor:!0,children:["[",v(o.timestamp),"]"," "]}):void 0,n?d(l,{color:f[o.level],children:[b[o.level]," "]}):void 0,s(l,{color:o.level==="error"?"red":o.level==="warn"?"yellow":void 0,children:o.message})]},o.id))})}export{E as ConsoleOverlay,E as default};
@@ -1 +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};
1
+ import{jsxs as f,jsx as x,Fragment as M}from"react/jsx-runtime";import s from"@visulima/tui/components/box";import w from"@visulima/tui/components/text";import C from"@visulima/tui/hooks/use-focus";import F from"@visulima/tui/hooks/use-input";import{useState as j,useMemo as S,useCallback as v}from"react";function H({accentColor:g="blue",autoFocus:I=!1,defaultValue:b,isDisabled:o=!1,onChange:a,options:e,value:i}){const{isFocused:d}=C({autoFocus:I,isActive:!o}),A=b??e[0]?.id,[l,k]=j(A),m=i??l,n=S(()=>{if(m===void 0)return 0;const r=e.findIndex(t=>t.id===m);return Math.max(r,0)},[e,m]),u=v(r=>{const t=e[r];if(!t)return;const c=i??l;t.id!==c&&(i===void 0&&k(t.id),a?.(t.id))},[e,i,l,a]);F(v((r,t)=>{d&&(t.leftArrow||r==="h"?u(Math.max(0,n-1)):(t.rightArrow||r==="l")&&u(Math.min(e.length-1,n+1)))},[d,n,e.length,u]),{isActive:!o&&d});const h=e[n];return f(s,{flexDirection:"column",children:[x(s,{children:e.map((r,t)=>{const c=t===n;return f(w,{backgroundColor:c?g:void 0,color:c?"black":void 0,dimColor:o&&!c,children:[" ",r.icon===void 0?void 0:f(M,{children:[r.icon," "]}),r.label," "]},r.id)})}),h===void 0?void 0:x(s,{flexDirection:"column",marginTop:1,children:h.content})]})}export{H as ContentSwitcher,H as default};
@@ -1,3 +1,43 @@
1
- export { C as ControlledScrollView, type a as ControlledScrollViewProps, type b as ControlledScrollViewRef } from "./packem_shared/controlled-scroll-view.d-D3kZZzjI.js";
2
- import '@visulima/tui/components/box';
3
- import 'react';
1
+ import { Props } from '@visulima/tui/components/box';
2
+ import React, { ReactNode, Ref } from 'react';
3
+ interface ControlledScrollViewProps extends Props {
4
+ children?: ReactNode;
5
+ debug?: boolean;
6
+ onContentHeightChange?: (height: number, previousHeight: number) => void;
7
+ onItemHeightChange?: (index: number, height: number, previousHeight: number) => void;
8
+ onViewportSizeChange?: (size: {
9
+ height: number;
10
+ width: number;
11
+ }, previousSize: {
12
+ height: number;
13
+ width: number;
14
+ }) => void;
15
+ /**
16
+ * Number of extra items to render above/below the viewport when virtualized.
17
+ * @default 3
18
+ */
19
+ overscan?: number;
20
+ scrollOffset: number;
21
+ /**
22
+ * Only render items visible in the viewport plus overscan.
23
+ * Items must be measured first (first render always renders all items).
24
+ * @default false
25
+ */
26
+ virtualize?: boolean;
27
+ }
28
+ interface ControlledScrollViewRef {
29
+ getBottomOffset: () => number;
30
+ getContentHeight: () => number;
31
+ getItemHeight: (index: number) => number;
32
+ getItemPosition: (index: number) => {
33
+ height: number;
34
+ top: number;
35
+ } | null;
36
+ getViewportHeight: () => number;
37
+ remeasure: () => void;
38
+ remeasureItem: (index: number) => void;
39
+ }
40
+ declare const ControlledScrollView: ({ children, debug, onContentHeightChange, onItemHeightChange, onViewportSizeChange, overscan, ref, scrollOffset, virtualize, ...boxProps }: ControlledScrollViewProps & {
41
+ ref?: Ref<ControlledScrollViewRef>;
42
+ }) => React.JSX.Element;
43
+ export { ControlledScrollView, type ControlledScrollViewProps, type ControlledScrollViewRef };
@@ -1 +1 @@
1
- import{C as r}from"./packem_shared/controlled-scroll-view-DerVKKv6.js";export{r as ControlledScrollView};
1
+ import{C as r}from"./packem_shared/controlled-scroll-view-BHCYjiKa.js";export{r as ControlledScrollView};
package/dist/data-grid.js CHANGED
@@ -1 +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};
1
+ import{jsxs as k,jsx as f}from"react/jsx-runtime";import h from"@visulima/tui/components/box";import a from"@visulima/tui/components/text";import B from"@visulima/tui/hooks/use-focus";import E from"@visulima/tui/hooks/use-input";import{useState as w,useMemo as j,useCallback as G}from"react";function g(i,o){return o===0?0:(i%o+o)%o}const p=(i,o)=>i.render?i.render(o):String(o[i.key]??""),D=(i,o,n)=>i.length>=o?i.slice(0,o):n==="right"?i.padStart(o):i.padEnd(o);function O({accentColor:i="blue",autoFocus:o=!1,columns:n,data:c,onSelect:y}){const{isFocused:m}=B({autoFocus:o}),[v,C]=w(0),[N,A]=w(0),[d,F]=w(void 0),S=j(()=>n.map(e=>{if(e.width!==void 0)return e.width;let t=e.header.length+2;for(const r of c)t=Math.max(t,p(e,r).length);return t}),[n,c]),l=j(()=>{if(d===void 0)return c;const e=n.find(r=>r.key===d.key);if(e===void 0)return c;const t=d.direction==="asc"?1:-1;return[...c].toSorted((r,s)=>{const u=p(e,r),b=p(e,s),x=Number(u),R=Number(b),$=u.length>0&&b.length>0&&!Number.isNaN(x)&&!Number.isNaN(R);return t*($?x-R:u.localeCompare(b))})},[n,c,d]),M=G((e,t)=>{if(t.upArrow)C(r=>g(r-1,l.length));else if(t.downArrow)C(r=>g(r+1,l.length));else if(t.leftArrow)A(r=>g(r-1,n.length));else if(t.rightArrow)A(r=>g(r+1,n.length));else if(e==="s"){const r=n[N];r!==void 0&&F(s=>s?.key===r.key&&s.direction==="asc"?{direction:"desc",key:r.key}:{direction:"asc",key:r.key})}else if(t.return){const r=l[v];r!==void 0&&y?.(r)}},[N,n,y,v,l]);E(M,{isActive:m});const T=e=>d?.key!==e?"":d.direction==="asc"?" ▲":" ▼";return k(h,{flexDirection:"column",children:[k(h,{children:[f(a,{children:" "}),n.map((e,t)=>f(h,{marginRight:1,children:f(a,{bold:!0,color:m&&t===N?i:void 0,children:D(`${e.header}${T(e.key)}`,S[t],e.align??"left")})},e.key))]}),l.map((e,t)=>{const r=m&&t===v;return k(h,{children:[f(a,{color:r?i:void 0,children:r?"❯":" "}),n.map((s,u)=>f(h,{marginRight:1,children:f(a,{color:r?i:void 0,dimColor:!r,children:D(p(s,e),S[u],s.align??"left")})},s.key))]},t)})]})}export{O as DataGrid,O as default};
@@ -1 +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};
1
+ import{jsxs as g,jsx as t}from"react/jsx-runtime";import n from"@visulima/tui/components/box";import s from"@visulima/tui/components/text";import I from"@visulima/tui/hooks/use-focus";import v from"@visulima/tui/hooks/use-input";import{useState as x,useCallback as h}from"react";import{Calendar as $}from"./calendar.js";const j=r=>{const l=r.getFullYear(),u=String(r.getMonth()+1).padStart(2,"0"),c=String(r.getDate()).padStart(2,"0");return`${l}-${u}-${c}`};function M({accentColor:r="blue",autoFocus:l=!1,defaultValue:u,formatValue:c=j,isDisabled:a=!1,maxDate:b,minDate:F,onChange:S,placeholder:k="Pick a date",value:d}){const{isFocused:e}=I({autoFocus:l,isActive:!a}),[o,m]=x(!1),[y,A]=x(u),f=d??y;v(h((i,p)=>{!e||o||(p.return||i===" ")&&m(!0)},[e,o]),{isActive:!a&&e&&!o}),v(h((i,p)=>{p.escape&&m(!1)},[]),{isActive:!a&&e&&o});const C=h(i=>{d===void 0&&A(i),m(!1),S?.(i)},[d,S]);return g(n,{flexDirection:"column",children:[g(n,{borderColor:e?r:void 0,borderStyle:"round",paddingX:1,children:[t(s,{color:r,children:"📅 "}),f===void 0?t(s,{dimColor:!0,children:k}):t(s,{bold:!0,children:c(f)}),e&&!o?t(n,{marginLeft:1,children:t(s,{dimColor:!0,children:"(Enter to open)"})}):void 0]}),o?t(n,{marginTop:1,children:t($,{accentColor:r,autoFocus:!0,defaultValue:f,maxDate:b,minDate:F,onSubmit:C})}):void 0]})}export{M as DatePicker,M as default};
@@ -1 +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};
1
+ import{jsx as r,jsxs as d}from"react/jsx-runtime";import n from"@visulima/tui/components/box";import e from"@visulima/tui/components/text";function u({columnGap:t=2,items:l,layout:f="inline",termColor:o="cyan",termWidth:h}){return f==="stacked"?r(n,{flexDirection:"column",gap:1,children:l.map((i,c)=>d(n,{flexDirection:"column",children:[r(e,{bold:!0,color:o,children:i.term}),r(e,{children:i.description})]},i.key??c))}):r(n,{flexDirection:"column",children:l.map((i,c)=>d(n,{gap:t,children:[r(n,{flexShrink:0,width:h,children:r(e,{color:o,children:i.term})}),r(n,{flexGrow:1,flexShrink:1,children:r(e,{children:i.description})})]},i.key??c))})}export{u as DefinitionList,u as default};
package/dist/dialog.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ReactNode, ReactElement } from 'react';
2
+ import { ScrollViewRef } from "./scroll-view.js";
2
3
  import '@visulima/tui/components/box';
3
- import { b as ScrollViewRef } from "./packem_shared/scroll-view.d-GZcgAHl4.js";
4
4
  type Props = {
5
5
  /**
6
6
  * Background color for the dialog. Defaults to the detected terminal
package/dist/dialog.js CHANGED
@@ -1 +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};
1
+ import{jsx as o,jsxs as C}from"react/jsx-runtime";import l from"@visulima/tui/components/box";import D from"@visulima/tui/components/text";import T from"@visulima/tui/hooks/use-terminal-palette";import z from"@visulima/tui/hooks/use-window-size";import{useRef as I}from"react";import{ScrollView as L}from"./packem_shared/ScrollView-Dt5E9Yl7.js";const A=({backgroundColor:f,borderColor:r="cyan",borderStyle:h="round",children:d,columns:g,footer:c,maxHeight:e=.8,paddingX:n=2,paddingY:b=1,rows:x,scrollbarStyle:w="block",scrollRef:k,title:t,visible:p=!0,width:S=60})=>{const s=z(),{isLoading:y,palette:R}=T(),M=I(null),j=k??M;if(!p)return null;const a=g??(s.columns||80),i=x??(s.rows||24),m=f??(y?"black":R?.background??"black"),B=e<=1?Math.floor(i*e):Math.min(e,i-2),u=typeof t=="string"?o(l,{marginBottom:1,children:o(D,{bold:!0,color:r,children:t})}):t??null;return o(l,{alignItems:"center",height:i,justifyContent:"center",position:"absolute",width:a,children:C(l,{backgroundColor:m,borderBackgroundColor:m,borderColor:r,borderStyle:h,flexDirection:"column",maxHeight:B,opaque:!0,paddingY:b,width:Math.min(S,a-4),children:[u!=null&&o(l,{flexShrink:0,paddingX:n,children:u}),o(L,{flexGrow:1,flexShrink:1,paddingX:n,ref:j,scrollbar:!0,scrollbarColor:r,scrollbarStyle:w,children:d}),c!=null&&o(l,{alignItems:"center",flexDirection:"column",flexShrink:0,marginTop:1,paddingX:n,children:c})]})})};export{A as Dialog,A as default};
package/dist/diff-view.js CHANGED
@@ -1 +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};
1
+ import{jsx as s,jsxs as p,Fragment as P}from"react/jsx-runtime";import g from"@visulima/tui/components/box";import h from"@visulima/tui/components/text";import{resolveLanguage as E,isLanguageSupported as W,getHighlighter as M,getCachedTokens as _,renderTokenLine as $}from"@visulima/tui/highlighter";import B from"@visulima/tui/hooks/use-window-size";import{createPatch as F,parsePatch as T,diffWords as V,diffChars as j}from"diff";import{useMemo as x,useState as A,useRef as R,useEffect as z}from"react";const v=(i,r,n,l)=>{if(!r||n===void 0||n<1||n>r.length)return l?s(h,{color:l,children:i}):s(h,{dimColor:!0,children:i});const o=r[n-1];return!o||o.length===0?l?s(h,{color:l,children:i}):s(h,{dimColor:!0,children:i}):$(o)},y=(i,r,n)=>{const[l,o]=A(null),u=R(!1);return z(()=>{if(u.current=!1,!r){o(null);return}const e=E(r);if(!W(e)){o(null);return}return(async()=>{try{const f=await M([e],n),c=_(f,i,e,n);u.current||o(c.tokens)}catch{u.current||o(null)}})(),()=>{u.current=!0}},[i,r,n]),l},G=(i,r,n="chars")=>{const l=T(i),o=[];for(const u of l)for(const e of u.hunks){const f=`@@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@`,c=[];let a=e.oldStart,d=e.newStart;for(const N of e.lines)N.startsWith("\\")||(N.startsWith("+")?c.push({content:N.slice(1),newLineNum:d++,type:"add"}):N.startsWith("-")?c.push({content:N.slice(1),oldLineNum:a++,type:"del"}):c.push({content:N.slice(1),newLineNum:d++,oldLineNum:a++,type:"context"}));if(r){const N=U(c);for(const[L,t]of N)if(c[L].type==="del"&&c[t].type==="add"){const m=H(c[L].content,c[t].content,n);c[L].inlineDiff=m??void 0,c[L].pairedIndex=t,c[t].inlineDiff=m??void 0,c[t].pairedIndex=L}}o.push({header:f,lines:c})}return o},I=500,H=(i,r,n="chars")=>{if(i.length>I||r.length>I)return null;const l=n==="words"?V(i,r):j(i,r),o=[],u=[];for(const e of l)e.removed?o.push({highlight:!0,value:e.value}):e.added?u.push({highlight:!0,value:e.value}):(o.push({highlight:!1,value:e.value}),u.push({highlight:!1,value:e.value}));return{addParts:u,delParts:o}},D=(i,r,n)=>s(P,{children:i.map((l,o)=>l.highlight?s(h,{backgroundColor:n,color:"white",children:l.value},o):s(h,{color:r,children:l.value},o))}),U=i=>{const r=new Map;let n=0;for(;n<i.length;){const l=n;for(;n<i.length&&i[n].type==="del";)n++;const o=n,u=n;for(;n<i.length&&i[n].type==="add";)n++;const e=n,f=o-l,c=e-u,a=Math.min(f,c);for(let d=0;d<a;d++)r.set(l+d,u+d),r.set(u+d,l+d);n===l&&n++}return r};function X({hunks:i,newHighlighted:r,oldHighlighted:n,showLineNumbers:l}){return s(g,{flexDirection:"column",children:i.map((o,u)=>p(g,{flexDirection:"column",children:[u>0?s(g,{marginBottom:0,marginTop:0,children:s(h,{dimColor:!0,children:"···"})}):void 0,s(h,{color:"cyan",dimColor:!0,children:o.header}),o.lines.map((e,f)=>{let c,a,d;switch(e.type){case"add":{a="+",d="green",c=e.inlineDiff?D(e.inlineDiff.addParts,"green","green"):v(e.content,r,e.newLineNum,"green");break}case"del":{a="-",d="red",c=e.inlineDiff?D(e.inlineDiff.delParts,"red","red"):v(e.content,n,e.oldLineNum,"red");break}default:{a=" ",d=void 0,c=v(e.content,n,e.oldLineNum);break}}return p(g,{children:[l?p(h,{color:d,dimColor:e.type==="context",children:[String(e.oldLineNum??"").padStart(4)," ",String(e.newLineNum??"").padStart(4)," "]}):void 0,s(h,{color:d,children:a}),c]},f)})]},u))})}function q({hunks:i,newHighlighted:r,oldHighlighted:n,showLineNumbers:l,width:o}){const u=Math.floor(o/2)-1;return s(g,{flexDirection:"column",children:i.map((e,f)=>{const c=f>0?s(g,{marginBottom:0,marginTop:0,children:s(h,{dimColor:!0,children:"···"})}):void 0,a=[],d=[];for(let L=0;L<e.lines.length;L++){const t=e.lines[L];switch(t.type){case"add":{t.pairedIndex===void 0&&(a.push({content:s(h,{dimColor:!0})}),d.push({content:v(t.content,r,t.newLineNum,"green"),lineNum:t.newLineNum}));break}case"context":{a.push({content:v(t.content,n,t.oldLineNum),lineNum:t.oldLineNum}),d.push({content:v(t.content,r,t.newLineNum),lineNum:t.newLineNum});break}case"del":{if(t.pairedIndex===void 0)a.push({content:v(t.content,n,t.oldLineNum,"red"),lineNum:t.oldLineNum}),d.push({content:s(h,{dimColor:!0})});else{const m=e.lines[t.pairedIndex];a.push({content:t.inlineDiff?D(t.inlineDiff.delParts,"red","red"):v(t.content,n,t.oldLineNum,"red"),lineNum:t.oldLineNum}),d.push({content:m.inlineDiff?D(m.inlineDiff.addParts,"green","green"):v(m.content,r,m.newLineNum,"green"),lineNum:m.newLineNum})}break}}}const N=Math.max(a.length,d.length);return p(g,{flexDirection:"column",children:[c,s(h,{color:"cyan",dimColor:!0,children:e.header}),Array.from({length:N},(L,t)=>{const m=a[t],w=d[t];return p(g,{flexDirection:"row",children:[p(g,{width:u,children:[l?p(h,{dimColor:!0,children:[String(m?.lineNum??"").padStart(4)," "]}):void 0,m?.content]}),s(h,{dimColor:!0,children:"│"}),p(g,{width:u,children:[l?p(h,{dimColor:!0,children:[String(w?.lineNum??"").padStart(4)," "]}):void 0,w?.content]})]},t)})]},f)})})}function ee({context:i=3,diff:r,inlineDiff:n=!0,inlineDiffMode:l="chars",language:o,mode:u="unified",newLabel:e="new",newText:f="",oldLabel:c="old",oldText:a="",showLineNumbers:d=!0,theme:N="github-dark-default"}){const{columns:L}=B(),t=y(a,o,N),m=y(f,o,N),w=x(()=>r||F("file",a,f,c,e,{context:i}),[r,a,f,c,e,i]),S=x(()=>G(w,n,l),[w,n,l]);if(S.every(k=>k.lines.length===0))return s(g,{children:s(h,{dimColor:!0,children:"No differences found."})});const C=p(g,{flexDirection:"column",children:[p(h,{color:"red",dimColor:!0,children:["---"," ",c]}),p(h,{color:"green",dimColor:!0,children:["+++"," ",e]})]});return u==="split"?p(g,{flexDirection:"column",children:[C,s(q,{hunks:S,newHighlighted:m,oldHighlighted:t,showLineNumbers:d,width:L??80})]}):p(g,{flexDirection:"column",children:[C,s(X,{hunks:S,newHighlighted:m,oldHighlighted:t,showLineNumbers:d})]})}export{ee as DiffView,ee as default};
package/dist/digits.js CHANGED
@@ -1 +1 @@
1
- import{jsx as n}from"react/jsx-runtime";import f from"@visulima/tui/components/box";import l from"@visulima/tui/components/text";const s={" ":[" "," "," "],0:[" ▄ ","█ █","▀▄▀"],1:[" ▄ "," █ "," ▪ "],2:["▄▄ "," ▄▀","▀▄▄"],3:["▄▄ "," ▄▀","▄▄▀"],4:[" ","█▄█"," █"],5:["▄▄▄","█▄ ","▄▄▀"],6:[" ▄ ","█▄ ","▀▄▀"],7:["▄▄▄"," █"," █ "],8:[" ▄ ","▄▀▄","▀▄▀"],9:[" ▄ ","▀▄█"," ▄▀"],"-":[" "," ─ "," "],".":[" "," "," ▪ "],":":[" "," ▪ "," ▪ "]},u=[" "," ? "," "];function g({color:a="cyan",gap:c=1,value:i}){const m=String(i),e=" ".repeat(Math.max(0,c)),t=[];for(const o of m)t.push(o);const p=[0,1,2].map(o=>t.map(r=>(s[r]??u)[o]).join(e));return n(f,{flexDirection:"column",children:p.map((o,r)=>n(l,{color:a,children:o},r))})}export{g as Digits,g as default};
1
+ import{jsx as n}from"react/jsx-runtime";import p from"@visulima/tui/components/box";import f from"@visulima/tui/components/text";const x={" ":[" "," "," "],0:[" ▄ ","█ █","▀▄▀"],1:[" ▄ "," █ "," ▪ "],2:["▄▄ "," ▄▀","▀▄▄"],3:["▄▄ "," ▄▀","▄▄▀"],4:[" ","█▄█"," █"],5:["▄▄▄","█▄ ","▄▄▀"],6:[" ▄ ","█▄ ","▀▄▀"],7:["▄▄▄"," █"," █ "],8:[" ▄ ","▄▀▄","▀▄▀"],9:[" ▄ ","▀▄█"," ▄▀"],"-":[" "," ─ "," "],".":[" "," "," ▪ "],":":[" "," ▪ "," ▪ "]},h=[" "," ? "," "];function g({color:c="cyan",gap:e=1,value:s}){const a=String(s),i=" ".repeat(Math.max(0,e)),r=[];for(const t of a)r.push(t);const m=[0,1,2].map(t=>r.map(o=>(x[o]??h)[t]).join(i));return n(p,{flexDirection:"column",children:m.map((t,o)=>n(f,{color:c,children:t},o))})}export{g as Digits,g as default};
@@ -1 +1 @@
1
- import{jsx as y,jsxs as x}from"react/jsx-runtime";import S from"@visulima/tui/components/box";import w from"@visulima/tui/components/text";import B from"@visulima/tui/hooks/use-focus";import k from"@visulima/tui/hooks/use-input";import{useState as g,useMemo as E,useCallback as $}from"react";function F(i,e){return e===0?0:(i%e+e)%e}function M(i,e){return i?e?"▾ 📁":"▸ 📁":" 📄"}const b=(i,e,u,l,s,f)=>{for(const d of i){const a=`${l}/${d.name}`,m=[...s,d.name];f.push({depth:u,id:a,node:d,path:m}),d.type==="directory"&&d.children!==void 0&&e.has(a)&&b(d.children,e,u+1,a,m,f)}},C=(i,e,u)=>{for(const l of i){const s=`${e}/${l.name}`;l.type==="directory"&&l.children!==void 0&&(u.add(s),C(l.children,s,u))}};function H({accentColor:i="blue",autoFocus:e=!1,defaultExpanded:u=!1,directoryColor:l="cyan",nodes:s,onSelect:f}){const{isFocused:d}=B({autoFocus:e}),[a,m]=g(()=>{if(!u)return new Set;const r=new Set;return C(s,"",r),r}),[p,v]=g(0),h=E(()=>{const r=[];return b(s,a,0,"",[],r),r},[a,s]),A=$((r,t)=>{m(o=>{const n=new Set(o);return t??!n.has(r)?n.add(r):n.delete(r),n})},[]),D=$((r,t)=>{const o=h[p];if(t.upArrow){v(c=>F(c-1,h.length));return}if(t.downArrow){v(c=>F(c+1,h.length));return}if(o===void 0)return;const n=o.node.type==="directory";if(n&&o.node.children!==void 0&&(r===" "||t.rightArrow||t.leftArrow)){let c;t.rightArrow?c=!0:t.leftArrow&&(c=!1),A(o.id,c);return}t.return&&!n&&f?.(o.path)},[p,f,h,A]);return k(D,{isActive:d}),y(S,{flexDirection:"column",children:h.map((r,t)=>{const o=d&&t===p,n=r.node.type==="directory",c=a.has(r.id),j=M(n,c);return x(S,{children:[y(w,{color:o?i:void 0,children:o?"❯":" "}),y(w,{children:" ".repeat(r.depth)}),x(w,{color:n?l:void 0,children:[j," ",r.node.name]})]},r.id)})})}export{H as DirectoryTree,H as default};
1
+ import{jsx as w,jsxs as A}from"react/jsx-runtime";import E from"@visulima/tui/components/box";import g from"@visulima/tui/components/text";import C from"@visulima/tui/hooks/use-focus";import T from"@visulima/tui/hooks/use-input";import{useState as b,useMemo as B,useCallback as D}from"react";function $(i,t){return t===0?0:(i%t+t)%t}function H(i,t){return i?t?"▾ 📁":"▸ 📁":" 📄"}const F=(i,t,u,d,l,f)=>{for(const c of i){const a=`${d}/${c.name}`,h=[...l,c.name];f.push({depth:u,id:a,node:c,path:h}),c.type==="directory"&&c.children!==void 0&&t.has(a)&&F(c.children,t,u+1,a,h,f)}},S=(i,t,u)=>{for(const d of i){const l=`${t}/${d.name}`;d.type==="directory"&&d.children!==void 0&&(u.add(l),S(d.children,l,u))}};function K({accentColor:i="blue",autoFocus:t=!1,defaultExpanded:u=!1,directoryColor:d="cyan",nodes:l,onSelect:f}){const{isFocused:c}=C({autoFocus:t}),[a,h]=b(()=>{if(!u)return new Set;const r=new Set;return S(l,"",r),r}),[m,v]=b(0),p=B(()=>{const r=[];return F(l,a,0,"",[],r),r},[a,l]),y=D((r,e)=>{h(n=>{const o=new Set(n);return e??!o.has(r)?o.add(r):o.delete(r),o})},[]),j=D((r,e)=>{const n=p[m];if(e.upArrow){v(s=>$(s-1,p.length));return}if(e.downArrow){v(s=>$(s+1,p.length));return}if(n===void 0)return;const o=n.node.type==="directory";if(o&&n.node.children!==void 0&&(r===" "||e.rightArrow||e.leftArrow)){let s;e.rightArrow?s=!0:e.leftArrow&&(s=!1),y(n.id,s);return}e.return&&!o&&f?.(n.path)},[m,f,p,y]);return T(j,{isActive:c}),w(E,{flexDirection:"column",children:p.map((r,e)=>{const n=c&&e===m,o=r.node.type==="directory",x=a.has(r.id),s=H(o,x);return A(E,{children:[w(g,{color:n?i:void 0,children:n?"❯":" "}),w(g,{children:" ".repeat(r.depth)}),A(g,{color:o?d:void 0,children:[s," ",r.node.name]})]},r.id)})})}export{K as DirectoryTree,K as default};