@hanzo/ui 5.3.18 → 5.3.21

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 (229) hide show
  1. package/dist/3d/button.js +298 -1
  2. package/dist/3d/button.mjs +273 -1
  3. package/dist/3d/card.js +234 -1
  4. package/dist/3d/card.mjs +207 -1
  5. package/dist/3d/carousel.js +371 -1
  6. package/dist/3d/carousel.mjs +344 -1
  7. package/dist/3d/grid.js +362 -1
  8. package/dist/3d/grid.mjs +337 -1
  9. package/dist/3d/index.js +1518 -1
  10. package/dist/3d/index.mjs +1472 -1
  11. package/dist/3d/marquee.js +352 -1
  12. package/dist/3d/marquee.mjs +327 -1
  13. package/dist/3d/pin.js +46 -1
  14. package/dist/3d/pin.mjs +24 -1
  15. package/dist/accordion.js +80 -1
  16. package/dist/accordion.mjs +55 -1
  17. package/dist/alert-dialog.js +220 -1
  18. package/dist/alert-dialog.mjs +187 -1
  19. package/dist/alert.js +68 -1
  20. package/dist/alert.mjs +64 -1
  21. package/dist/animation/animated-background.js +424 -1
  22. package/dist/animation/animated-background.mjs +418 -1
  23. package/dist/animation/animated-beam.js +119 -1
  24. package/dist/animation/animated-beam.mjs +97 -1
  25. package/dist/animation/animated-cursor.js +275 -1
  26. package/dist/animation/animated-cursor.mjs +270 -1
  27. package/dist/animation/animated-icon.js +357 -2
  28. package/dist/animation/animated-icon.mjs +351 -2
  29. package/dist/animation/animated-list.js +339 -1
  30. package/dist/animation/animated-list.mjs +333 -1
  31. package/dist/animation/animated-number.js +283 -1
  32. package/dist/animation/animated-number.mjs +277 -1
  33. package/dist/animation/animated-testimonials.js +97 -1
  34. package/dist/animation/animated-testimonials.mjs +75 -1
  35. package/dist/animation/animated-tooltip.js +67 -1
  36. package/dist/animation/animated-tooltip.mjs +45 -1
  37. package/dist/animation/apple-cards-carousel.js +308 -1
  38. package/dist/animation/apple-cards-carousel.mjs +285 -1
  39. package/dist/animation/apple-hello-effect.js +60 -1
  40. package/dist/animation/apple-hello-effect.mjs +38 -1
  41. package/dist/animation/index.js +1952 -2
  42. package/dist/animation/index.mjs +1921 -2
  43. package/dist/avatar.js +71 -1
  44. package/dist/avatar.mjs +47 -1
  45. package/dist/badge.js +66 -1
  46. package/dist/badge.mjs +40 -1
  47. package/dist/blocks/index.js +1665 -2
  48. package/dist/blocks/index.mjs +1626 -2
  49. package/dist/breadcrumb.js +107 -1
  50. package/dist/breadcrumb.mjs +99 -1
  51. package/dist/calendar.js +189 -1
  52. package/dist/calendar.mjs +164 -1
  53. package/dist/carousel.js +278 -1
  54. package/dist/carousel.mjs +249 -1
  55. package/dist/checkbox.js +60 -1
  56. package/dist/checkbox.mjs +35 -1
  57. package/dist/code/block.js +226 -2
  58. package/dist/code/block.mjs +203 -2
  59. package/dist/code/compare.js +445 -5
  60. package/dist/code/compare.mjs +422 -5
  61. package/dist/code/diff.js +430 -12
  62. package/dist/code/diff.mjs +406 -11
  63. package/dist/code/editor.js +243 -1
  64. package/dist/code/editor.mjs +218 -1
  65. package/dist/code/explorer.js +291 -1
  66. package/dist/code/explorer.mjs +268 -1
  67. package/dist/code/index.js +2515 -26
  68. package/dist/code/index.mjs +2472 -24
  69. package/dist/code/preview.js +364 -6
  70. package/dist/code/preview.mjs +341 -6
  71. package/dist/code/snippet.js +274 -2
  72. package/dist/code/snippet.mjs +250 -2
  73. package/dist/code/tabs.js +75 -1
  74. package/dist/code/tabs.mjs +53 -1
  75. package/dist/code/terminal.js +437 -3
  76. package/dist/code/terminal.mjs +414 -3
  77. package/dist/collapsible.js +33 -1
  78. package/dist/collapsible.mjs +9 -1
  79. package/dist/command.js +262 -1
  80. package/dist/command.mjs +232 -1
  81. package/dist/context-menu.js +207 -1
  82. package/dist/context-menu.mjs +171 -1
  83. package/dist/device/index.js +3 -1
  84. package/dist/device/index.mjs +2 -0
  85. package/dist/dialog.js +151 -1
  86. package/dist/dialog.mjs +121 -1
  87. package/dist/dock/basic.js +174 -1
  88. package/dist/dock/basic.mjs +151 -1
  89. package/dist/dock/index.js +628 -1
  90. package/dist/dock/index.mjs +601 -1
  91. package/dist/dock/limelight-nav.js +295 -1
  92. package/dist/dock/limelight-nav.mjs +274 -1
  93. package/dist/dock/macos.js +141 -1
  94. package/dist/dock/macos.mjs +118 -1
  95. package/dist/dock/menu.js +70 -1
  96. package/dist/dock/menu.mjs +48 -1
  97. package/dist/dock/message.js +144 -1
  98. package/dist/dock/message.mjs +122 -1
  99. package/dist/drawer.js +115 -1
  100. package/dist/drawer.mjs +103 -1
  101. package/dist/dropdown-menu.js +202 -1
  102. package/dist/dropdown-menu.mjs +166 -1
  103. package/dist/finance/AdvancedChart.js +48 -2
  104. package/dist/finance/AdvancedChart.mjs +46 -2
  105. package/dist/finance/CompanyProfile.js +48 -2
  106. package/dist/finance/CompanyProfile.mjs +46 -2
  107. package/dist/finance/CryptoScreener.js +45 -2
  108. package/dist/finance/CryptoScreener.mjs +43 -2
  109. package/dist/finance/Financials.js +52 -2
  110. package/dist/finance/Financials.mjs +50 -2
  111. package/dist/finance/ForexScreener.js +46 -2
  112. package/dist/finance/ForexScreener.mjs +44 -2
  113. package/dist/finance/MarketOverview.js +104 -2
  114. package/dist/finance/MarketOverview.mjs +102 -2
  115. package/dist/finance/NewsTimeline.js +44 -2
  116. package/dist/finance/NewsTimeline.mjs +42 -2
  117. package/dist/finance/OrderEntry.js +131 -1
  118. package/dist/finance/OrderEntry.mjs +129 -1
  119. package/dist/finance/OrdersHistory.js +64 -1
  120. package/dist/finance/OrdersHistory.mjs +62 -1
  121. package/dist/finance/PositionsList.js +80 -1
  122. package/dist/finance/PositionsList.mjs +78 -1
  123. package/dist/finance/StockScreener.js +46 -2
  124. package/dist/finance/StockScreener.mjs +44 -2
  125. package/dist/finance/SymbolInfo.js +46 -2
  126. package/dist/finance/SymbolInfo.mjs +44 -2
  127. package/dist/finance/TechnicalAnalysis.js +54 -2
  128. package/dist/finance/TechnicalAnalysis.mjs +52 -2
  129. package/dist/finance/TickerTape.js +56 -2
  130. package/dist/finance/TickerTape.mjs +54 -2
  131. package/dist/finance/TradingPanel.js +191 -1
  132. package/dist/finance/TradingPanel.mjs +189 -1
  133. package/dist/finance/index.js +930 -2
  134. package/dist/finance/index.mjs +914 -2
  135. package/dist/form/index.js +155 -1
  136. package/dist/form/index.mjs +125 -1
  137. package/dist/form.js +172 -1
  138. package/dist/form.mjs +142 -1
  139. package/dist/hover-card.js +58 -1
  140. package/dist/hover-card.mjs +34 -1
  141. package/dist/index.js +8467 -192
  142. package/dist/index.mjs +8087 -192
  143. package/dist/input-otp.js +79 -1
  144. package/dist/input-otp.mjs +54 -1
  145. package/dist/lib/utils.js +29 -1
  146. package/dist/lib/utils.mjs +25 -1
  147. package/dist/navigation/index.js +98 -1
  148. package/dist/navigation/index.mjs +79 -1
  149. package/dist/navigation-menu.js +149 -1
  150. package/dist/navigation-menu.mjs +116 -1
  151. package/dist/pattern/grid-pattern.js +326 -3
  152. package/dist/pattern/grid-pattern.mjs +303 -3
  153. package/dist/pattern/index.js +326 -3
  154. package/dist/pattern/index.mjs +303 -3
  155. package/dist/popover.js +63 -1
  156. package/dist/popover.mjs +37 -1
  157. package/dist/primitives/index.js +8467 -192
  158. package/dist/primitives/index.mjs +8087 -192
  159. package/dist/primitives-export.js +8467 -192
  160. package/dist/primitives-export.mjs +8087 -192
  161. package/dist/progress.js +62 -1
  162. package/dist/progress.mjs +37 -1
  163. package/dist/project/gantt.js +65 -1
  164. package/dist/project/gantt.mjs +43 -1
  165. package/dist/project/index.js +636 -1
  166. package/dist/project/index.mjs +611 -1
  167. package/dist/project/kanban.js +597 -1
  168. package/dist/project/kanban.mjs +572 -1
  169. package/dist/project/list.js +35 -1
  170. package/dist/project/list.mjs +12 -1
  171. package/dist/radio-group.js +68 -1
  172. package/dist/radio-group.mjs +45 -1
  173. package/dist/resizable.js +72 -1
  174. package/dist/resizable.mjs +48 -1
  175. package/dist/scroll-area.js +89 -1
  176. package/dist/scroll-area.mjs +66 -1
  177. package/dist/select.js +140 -1
  178. package/dist/select.mjs +111 -1
  179. package/dist/separator.js +59 -1
  180. package/dist/separator.mjs +34 -1
  181. package/dist/sheet.js +148 -1
  182. package/dist/sheet.mjs +117 -1
  183. package/dist/skeleton.js +32 -1
  184. package/dist/skeleton.mjs +27 -1
  185. package/dist/slider.js +99 -1
  186. package/dist/slider.mjs +73 -1
  187. package/dist/sonner.js +34 -1
  188. package/dist/sonner.mjs +29 -1
  189. package/dist/switch.js +62 -1
  190. package/dist/switch.mjs +37 -1
  191. package/dist/table.js +110 -1
  192. package/dist/table.mjs +101 -1
  193. package/dist/tabs.js +82 -1
  194. package/dist/tabs.mjs +57 -1
  195. package/dist/tailwind/index.js +2024 -1
  196. package/dist/tailwind/index.mjs +2012 -1
  197. package/dist/textarea.js +78 -1
  198. package/dist/textarea.mjs +56 -1
  199. package/dist/toggle-group.js +118 -1
  200. package/dist/toggle-group.mjs +93 -1
  201. package/dist/toggle.js +71 -1
  202. package/dist/toggle.mjs +48 -1
  203. package/dist/tooltip.js +67 -1
  204. package/dist/tooltip.mjs +40 -1
  205. package/dist/types/index.js +58 -1
  206. package/dist/types/index.mjs +52 -1
  207. package/dist/ui/announcement.js +129 -1
  208. package/dist/ui/announcement.mjs +107 -1
  209. package/dist/ui/avatar-group.js +88 -1
  210. package/dist/ui/avatar-group.mjs +65 -1
  211. package/dist/ui/banner.js +85 -1
  212. package/dist/ui/banner.mjs +62 -1
  213. package/dist/ui/cursor.js +78 -1
  214. package/dist/ui/cursor.mjs +56 -1
  215. package/dist/ui/index.js +475 -1
  216. package/dist/ui/index.mjs +442 -1
  217. package/dist/ui/marquee.js +74 -1
  218. package/dist/ui/marquee.mjs +52 -1
  219. package/dist/ui/pill.js +85 -1
  220. package/dist/ui/pill.mjs +62 -1
  221. package/dist/ui/spinner.js +28 -1
  222. package/dist/ui/spinner.mjs +26 -1
  223. package/dist/ui/tags.js +101 -1
  224. package/dist/ui/tags.mjs +79 -1
  225. package/dist/ui/ticker.js +73 -1
  226. package/dist/ui/ticker.mjs +51 -1
  227. package/dist/util/index.js +458 -1
  228. package/dist/util/index.mjs +400 -1
  229. package/package.json +1 -1
@@ -1,3 +1,437 @@
1
- 'use strict';var r=require('react'),classVarianceAuthority=require('class-variance-authority'),lucideReact=require('lucide-react'),utils=require('@hanzo/ui/lib/utils'),button=require('@hanzo/ui/button'),input=require('@hanzo/ui/input'),scrollArea=require('@hanzo/ui/scroll-area'),separator=require('@hanzo/ui/separator'),jsxRuntime=require('react/jsx-runtime');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var r__namespace=/*#__PURE__*/_interopNamespace(r);var Z=Object.defineProperty;var b=(c,f)=>Z(c,"name",{value:f,configurable:true});var me=classVarianceAuthority.cva("relative flex flex-col overflow-hidden rounded-lg border",{variants:{theme:{dark:"bg-black border-gray-700 text-green-400",light:"bg-white border-gray-300 text-gray-900",matrix:"bg-black border-green-500 text-green-400",hacker:"bg-gray-900 border-yellow-500 text-yellow-400",retro:"bg-amber-900 border-amber-600 text-amber-100",modern:"bg-slate-900 border-slate-700 text-slate-100"},size:{sm:"text-xs",default:"text-sm",lg:"text-base"}},defaultVariants:{theme:"dark",size:"default"}}),n={black:"text-black",red:"text-red-500",green:"text-green-500",yellow:"text-yellow-500",blue:"text-blue-500",magenta:"text-magenta-500",cyan:"text-cyan-500",white:"text-white",gray:"text-gray-500",brightRed:"text-red-400",brightGreen:"text-green-400",brightYellow:"text-yellow-400",brightBlue:"text-blue-400",brightMagenta:"text-magenta-400",brightCyan:"text-cyan-400",brightWhite:"text-gray-100"},ue=b(c=>{let f=/\x1b\[([0-9;]*)m/g,x=[],d=0,a=[],o;for(;(o=f.exec(c))!==null;)o.index>d&&x.push({text:c.slice(d,o.index),classes:[...a]}),o[1].split(";").map(m=>parseInt(m)||0).forEach(m=>{switch(m){case 0:a=[];break;case 30:a.push(n.black);break;case 31:a.push(n.red);break;case 32:a.push(n.green);break;case 33:a.push(n.yellow);break;case 34:a.push(n.blue);break;case 35:a.push(n.magenta);break;case 36:a.push(n.cyan);break;case 37:a.push(n.white);break;case 90:a.push(n.gray);break;case 91:a.push(n.brightRed);break;case 92:a.push(n.brightGreen);break;case 93:a.push(n.brightYellow);break;case 94:a.push(n.brightBlue);break;case 95:a.push(n.brightMagenta);break;case 96:a.push(n.brightCyan);break;case 97:a.push(n.brightWhite);break}}),d=o.index+o[0].length;return d<c.length&&x.push({text:c.slice(d),classes:[...a]}),x.map((y,m)=>jsxRuntime.jsx("span",{className:utils.cn(y.classes),children:y.text},m))},"parseAnsiContent"),de=r__namespace.forwardRef(({className:c,theme:f,size:x,title:d="Terminal",prompt:a="$",maxLines:o=1e3,showLineNumbers:y=false,allowInput:m=true,allowClear:z=true,allowCopy:H=true,allowDownload:A=false,allowFullscreen:B=true,height:F="400px",autoScroll:M=true,history:P=[],onCommand:L,onClear:w,initialLines:U=[],...V},j)=>{let[u,D]=r__namespace.useState(U),[S,v]=r__namespace.useState(""),[k,N]=r__namespace.useState(-1),[R,O]=r__namespace.useState(false),[p,K]=r__namespace.useState(P),C=r__namespace.useRef(null),E=r__namespace.useRef(null);r__namespace.useEffect(()=>{M&&C.current&&(C.current.scrollTop=C.current.scrollHeight);},[u,M]);let h=r__namespace.useCallback(e=>{let s={...e,id:`line-${Date.now()}-${Math.random()}`,timestamp:Date.now()};D(g=>{let l=[...g,s];return l.length>o?l.slice(-o):l});},[o]),W=r__namespace.useCallback(async e=>{if(e.trim()){if(K(s=>[...s,e]),N(-1),h({type:"input",content:`${a} ${e}`,command:e}),e==="clear"){w?w():D([]);return}if(e==="history"){p.forEach((s,g)=>{h({type:"output",content:`${g+1} ${s}`});});return}if(e.startsWith("echo ")){h({type:"output",content:e.slice(5)});return}if(L)try{await L(e);}catch(s){h({type:"error",content:s instanceof Error?s.message:String(s),exitCode:1});}else h({type:"error",content:`Command not found: ${e}`,exitCode:127});}},[a,h,L,w,p]),G=b(e=>{e.preventDefault(),S.trim()&&(W(S),v(""));},"handleInputSubmit"),Y=b(e=>{if(e.key==="ArrowUp"){if(e.preventDefault(),k<p.length-1){let s=k+1;N(s),v(p[p.length-1-s]||"");}}else if(e.key==="ArrowDown")if(e.preventDefault(),k>0){let s=k-1;N(s),v(p[p.length-1-s]||"");}else k===0&&(N(-1),v(""));},"handleKeyDown"),q=r__namespace.useCallback(async()=>{let e=u.map(s=>s.content).join(`
2
- `);try{await navigator.clipboard.writeText(e);}catch(s){console.error("Failed to copy terminal content:",s);}},[u]),X=r__namespace.useCallback(()=>{let e=u.map($=>`[${new Date($.timestamp).toISOString()}] ${$.content}`).join(`
3
- `),s=new Blob([e],{type:"text/plain"}),g=URL.createObjectURL(s),l=document.createElement("a");l.href=g,l.download=`terminal-${Date.now()}.txt`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(g);},[u]),J=b(()=>{w?w():D([]);},"clearTerminal"),Q=b(()=>{m&&E.current&&E.current.focus();},"handleTerminalClick");return jsxRuntime.jsxs("div",{ref:j,className:utils.cn(me({theme:f,size:x}),R&&"fixed inset-0 z-50",c),style:{height:R?"100vh":F},onClick:Q,...V,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-2 bg-muted/30",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("div",{className:"flex gap-1",children:[jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-red-500"}),jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-yellow-500"}),jsxRuntime.jsx("div",{className:"w-3 h-3 rounded-full bg-green-500"})]}),jsxRuntime.jsx(lucideReact.Terminal,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{className:"text-sm font-medium",children:d}),u.length>0&&jsxRuntime.jsxs("span",{className:"text-xs text-muted-foreground",children:[u.length," lines"]})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[z&&jsxRuntime.jsx(button.Button,{variant:"ghost",size:"sm",onClick:J,className:"h-8 w-8 p-0",children:jsxRuntime.jsx(lucideReact.RefreshCw,{className:"h-3.5 w-3.5"})}),H&&jsxRuntime.jsx(button.Button,{variant:"ghost",size:"sm",onClick:q,className:"h-8 w-8 p-0",children:jsxRuntime.jsx(lucideReact.Copy,{className:"h-3.5 w-3.5"})}),A&&jsxRuntime.jsx(button.Button,{variant:"ghost",size:"sm",onClick:X,className:"h-8 w-8 p-0",children:jsxRuntime.jsx(lucideReact.Download,{className:"h-3.5 w-3.5"})}),B&&jsxRuntime.jsx(button.Button,{variant:"ghost",size:"sm",onClick:()=>O(!R),className:"h-8 w-8 p-0",children:R?jsxRuntime.jsx(lucideReact.Minimize2,{className:"h-3.5 w-3.5"}):jsxRuntime.jsx(lucideReact.Maximize2,{className:"h-3.5 w-3.5"})})]})]}),jsxRuntime.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[jsxRuntime.jsx(scrollArea.ScrollArea,{ref:C,className:"flex-1 p-4",children:jsxRuntime.jsx("div",{className:"space-y-1 font-mono",children:u.map((e,s)=>jsxRuntime.jsxs("div",{className:"flex items-start gap-2",children:[y&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground w-12 text-right flex-shrink-0",children:s+1}),jsxRuntime.jsx("div",{className:utils.cn("flex-1 whitespace-pre-wrap break-words",e.type==="input"&&"text-inherit",e.type==="output"&&"text-muted-foreground",e.type==="error"&&"text-red-400",e.type==="system"&&"text-blue-400"),children:typeof e.content=="string"&&e.content.includes("\x1B[")?ue(e.content):e.content})]},e.id))})}),m&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(separator.Separator,{}),jsxRuntime.jsx("form",{onSubmit:G,className:"p-4",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2 font-mono",children:[jsxRuntime.jsx(lucideReact.ChevronRight,{className:"h-4 w-4 flex-shrink-0"}),jsxRuntime.jsx("span",{className:"flex-shrink-0",children:a}),jsxRuntime.jsx(input.Input,{ref:E,value:S,onChange:e=>v(e.target.value),onKeyDown:Y,className:"flex-1 border-0 bg-transparent p-0 focus-visible:ring-0 font-mono",placeholder:"Enter command...",autoComplete:"off",autoFocus:true})]})})]})]})]})});de.displayName="CodeTerminal";exports.CodeTerminal=de;exports.codeTerminalVariants=me;
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var React = require('react');
5
+ var classVarianceAuthority = require('class-variance-authority');
6
+ var lucideReact = require('lucide-react');
7
+ var utils = require('@hanzo/ui/lib/utils');
8
+ var button = require('@hanzo/ui/button');
9
+ var input = require('@hanzo/ui/input');
10
+ var scrollArea = require('@hanzo/ui/scroll-area');
11
+ var separator = require('@hanzo/ui/separator');
12
+ var jsxRuntime = require('react/jsx-runtime');
13
+
14
+ function _interopNamespace(e) {
15
+ if (e && e.__esModule) return e;
16
+ var n = Object.create(null);
17
+ if (e) {
18
+ Object.keys(e).forEach(function (k) {
19
+ if (k !== 'default') {
20
+ var d = Object.getOwnPropertyDescriptor(e, k);
21
+ Object.defineProperty(n, k, d.get ? d : {
22
+ enumerable: true,
23
+ get: function () { return e[k]; }
24
+ });
25
+ }
26
+ });
27
+ }
28
+ n.default = e;
29
+ return Object.freeze(n);
30
+ }
31
+
32
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
33
+
34
+ var __defProp = Object.defineProperty;
35
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
36
+ var codeTerminalVariants = classVarianceAuthority.cva(
37
+ "relative flex flex-col overflow-hidden rounded-lg border",
38
+ {
39
+ variants: {
40
+ theme: {
41
+ dark: "bg-black border-gray-700 text-green-400",
42
+ light: "bg-white border-gray-300 text-gray-900",
43
+ matrix: "bg-black border-green-500 text-green-400",
44
+ hacker: "bg-gray-900 border-yellow-500 text-yellow-400",
45
+ retro: "bg-amber-900 border-amber-600 text-amber-100",
46
+ modern: "bg-slate-900 border-slate-700 text-slate-100"
47
+ },
48
+ size: {
49
+ sm: "text-xs",
50
+ default: "text-sm",
51
+ lg: "text-base"
52
+ }
53
+ },
54
+ defaultVariants: {
55
+ theme: "dark",
56
+ size: "default"
57
+ }
58
+ }
59
+ );
60
+ var ansiColors = {
61
+ black: "text-black",
62
+ red: "text-red-500",
63
+ green: "text-green-500",
64
+ yellow: "text-yellow-500",
65
+ blue: "text-blue-500",
66
+ magenta: "text-magenta-500",
67
+ cyan: "text-cyan-500",
68
+ white: "text-white",
69
+ gray: "text-gray-500",
70
+ brightRed: "text-red-400",
71
+ brightGreen: "text-green-400",
72
+ brightYellow: "text-yellow-400",
73
+ brightBlue: "text-blue-400",
74
+ brightMagenta: "text-magenta-400",
75
+ brightCyan: "text-cyan-400",
76
+ brightWhite: "text-gray-100"
77
+ };
78
+ var parseAnsiContent = /* @__PURE__ */ __name((content) => {
79
+ const ansiRegex = /\x1b\[([0-9;]*)m/g;
80
+ const parts = [];
81
+ let lastIndex = 0;
82
+ let currentClasses = [];
83
+ let match;
84
+ while ((match = ansiRegex.exec(content)) !== null) {
85
+ if (match.index > lastIndex) {
86
+ parts.push({
87
+ text: content.slice(lastIndex, match.index),
88
+ classes: [...currentClasses]
89
+ });
90
+ }
91
+ const codes = match[1].split(";").map((code) => parseInt(code) || 0);
92
+ codes.forEach((code) => {
93
+ switch (code) {
94
+ case 0:
95
+ currentClasses = [];
96
+ break;
97
+ // reset
98
+ case 30:
99
+ currentClasses.push(ansiColors.black);
100
+ break;
101
+ case 31:
102
+ currentClasses.push(ansiColors.red);
103
+ break;
104
+ case 32:
105
+ currentClasses.push(ansiColors.green);
106
+ break;
107
+ case 33:
108
+ currentClasses.push(ansiColors.yellow);
109
+ break;
110
+ case 34:
111
+ currentClasses.push(ansiColors.blue);
112
+ break;
113
+ case 35:
114
+ currentClasses.push(ansiColors.magenta);
115
+ break;
116
+ case 36:
117
+ currentClasses.push(ansiColors.cyan);
118
+ break;
119
+ case 37:
120
+ currentClasses.push(ansiColors.white);
121
+ break;
122
+ case 90:
123
+ currentClasses.push(ansiColors.gray);
124
+ break;
125
+ case 91:
126
+ currentClasses.push(ansiColors.brightRed);
127
+ break;
128
+ case 92:
129
+ currentClasses.push(ansiColors.brightGreen);
130
+ break;
131
+ case 93:
132
+ currentClasses.push(ansiColors.brightYellow);
133
+ break;
134
+ case 94:
135
+ currentClasses.push(ansiColors.brightBlue);
136
+ break;
137
+ case 95:
138
+ currentClasses.push(ansiColors.brightMagenta);
139
+ break;
140
+ case 96:
141
+ currentClasses.push(ansiColors.brightCyan);
142
+ break;
143
+ case 97:
144
+ currentClasses.push(ansiColors.brightWhite);
145
+ break;
146
+ }
147
+ });
148
+ lastIndex = match.index + match[0].length;
149
+ }
150
+ if (lastIndex < content.length) {
151
+ parts.push({
152
+ text: content.slice(lastIndex),
153
+ classes: [...currentClasses]
154
+ });
155
+ }
156
+ return parts.map((part, index) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: utils.cn(part.classes), children: part.text }, index));
157
+ }, "parseAnsiContent");
158
+ var CodeTerminal = React__namespace.forwardRef(
159
+ ({
160
+ className,
161
+ theme,
162
+ size,
163
+ title = "Terminal",
164
+ prompt = "$",
165
+ maxLines = 1e3,
166
+ showLineNumbers = false,
167
+ allowInput = true,
168
+ allowClear = true,
169
+ allowCopy = true,
170
+ allowDownload = false,
171
+ allowFullscreen = true,
172
+ height = "400px",
173
+ autoScroll = true,
174
+ history = [],
175
+ onCommand,
176
+ onClear,
177
+ initialLines = [],
178
+ ...props
179
+ }, ref) => {
180
+ const [lines, setLines] = React__namespace.useState(initialLines);
181
+ const [input$1, setInput] = React__namespace.useState("");
182
+ const [historyIndex, setHistoryIndex] = React__namespace.useState(-1);
183
+ const [isFullscreen, setIsFullscreen] = React__namespace.useState(false);
184
+ const [commandHistory, setCommandHistory] = React__namespace.useState(history);
185
+ const scrollAreaRef = React__namespace.useRef(null);
186
+ const inputRef = React__namespace.useRef(null);
187
+ React__namespace.useEffect(() => {
188
+ if (autoScroll && scrollAreaRef.current) {
189
+ scrollAreaRef.current.scrollTop = scrollAreaRef.current.scrollHeight;
190
+ }
191
+ }, [lines, autoScroll]);
192
+ const addLine = React__namespace.useCallback(
193
+ (line) => {
194
+ const newLine = {
195
+ ...line,
196
+ id: `line-${Date.now()}-${Math.random()}`,
197
+ timestamp: Date.now()
198
+ };
199
+ setLines((prev) => {
200
+ const updated = [...prev, newLine];
201
+ return updated.length > maxLines ? updated.slice(-maxLines) : updated;
202
+ });
203
+ },
204
+ [maxLines]
205
+ );
206
+ const handleCommand = React__namespace.useCallback(
207
+ async (command) => {
208
+ if (!command.trim()) return;
209
+ setCommandHistory((prev) => [...prev, command]);
210
+ setHistoryIndex(-1);
211
+ addLine({
212
+ type: "input",
213
+ content: `${prompt} ${command}`,
214
+ command
215
+ });
216
+ if (command === "clear") {
217
+ if (onClear) {
218
+ onClear();
219
+ } else {
220
+ setLines([]);
221
+ }
222
+ return;
223
+ }
224
+ if (command === "history") {
225
+ commandHistory.forEach((cmd, index) => {
226
+ addLine({
227
+ type: "output",
228
+ content: `${index + 1} ${cmd}`
229
+ });
230
+ });
231
+ return;
232
+ }
233
+ if (command.startsWith("echo ")) {
234
+ addLine({
235
+ type: "output",
236
+ content: command.slice(5)
237
+ });
238
+ return;
239
+ }
240
+ if (onCommand) {
241
+ try {
242
+ await onCommand(command);
243
+ } catch (error) {
244
+ addLine({
245
+ type: "error",
246
+ content: error instanceof Error ? error.message : String(error),
247
+ exitCode: 1
248
+ });
249
+ }
250
+ } else {
251
+ addLine({
252
+ type: "error",
253
+ content: `Command not found: ${command}`,
254
+ exitCode: 127
255
+ });
256
+ }
257
+ },
258
+ [prompt, addLine, onCommand, onClear, commandHistory]
259
+ );
260
+ const handleInputSubmit = /* @__PURE__ */ __name((e) => {
261
+ e.preventDefault();
262
+ if (input$1.trim()) {
263
+ handleCommand(input$1);
264
+ setInput("");
265
+ }
266
+ }, "handleInputSubmit");
267
+ const handleKeyDown = /* @__PURE__ */ __name((e) => {
268
+ if (e.key === "ArrowUp") {
269
+ e.preventDefault();
270
+ if (historyIndex < commandHistory.length - 1) {
271
+ const newIndex = historyIndex + 1;
272
+ setHistoryIndex(newIndex);
273
+ setInput(commandHistory[commandHistory.length - 1 - newIndex] || "");
274
+ }
275
+ } else if (e.key === "ArrowDown") {
276
+ e.preventDefault();
277
+ if (historyIndex > 0) {
278
+ const newIndex = historyIndex - 1;
279
+ setHistoryIndex(newIndex);
280
+ setInput(commandHistory[commandHistory.length - 1 - newIndex] || "");
281
+ } else if (historyIndex === 0) {
282
+ setHistoryIndex(-1);
283
+ setInput("");
284
+ }
285
+ }
286
+ }, "handleKeyDown");
287
+ const copyContent = React__namespace.useCallback(async () => {
288
+ const content = lines.map((line) => line.content).join("\n");
289
+ try {
290
+ await navigator.clipboard.writeText(content);
291
+ } catch (error) {
292
+ console.error("Failed to copy terminal content:", error);
293
+ }
294
+ }, [lines]);
295
+ const downloadContent = React__namespace.useCallback(() => {
296
+ const content = lines.map(
297
+ (line) => `[${new Date(line.timestamp).toISOString()}] ${line.content}`
298
+ ).join("\n");
299
+ const blob = new Blob([content], { type: "text/plain" });
300
+ const url = URL.createObjectURL(blob);
301
+ const a = document.createElement("a");
302
+ a.href = url;
303
+ a.download = `terminal-${Date.now()}.txt`;
304
+ document.body.appendChild(a);
305
+ a.click();
306
+ document.body.removeChild(a);
307
+ URL.revokeObjectURL(url);
308
+ }, [lines]);
309
+ const clearTerminal = /* @__PURE__ */ __name(() => {
310
+ if (onClear) {
311
+ onClear();
312
+ } else {
313
+ setLines([]);
314
+ }
315
+ }, "clearTerminal");
316
+ const handleTerminalClick = /* @__PURE__ */ __name(() => {
317
+ if (allowInput && inputRef.current) {
318
+ inputRef.current.focus();
319
+ }
320
+ }, "handleTerminalClick");
321
+ return /* @__PURE__ */ jsxRuntime.jsxs(
322
+ "div",
323
+ {
324
+ ref,
325
+ className: utils.cn(
326
+ codeTerminalVariants({ theme, size }),
327
+ isFullscreen && "fixed inset-0 z-50",
328
+ className
329
+ ),
330
+ style: { height: isFullscreen ? "100vh" : height },
331
+ onClick: handleTerminalClick,
332
+ ...props,
333
+ children: [
334
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border-b px-4 py-2 bg-muted/30", children: [
335
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
336
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-1", children: [
337
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-3 h-3 rounded-full bg-red-500" }),
338
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-3 h-3 rounded-full bg-yellow-500" }),
339
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-3 h-3 rounded-full bg-green-500" })
340
+ ] }),
341
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Terminal, { className: "h-4 w-4" }),
342
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: title }),
343
+ lines.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground", children: [
344
+ lines.length,
345
+ " lines"
346
+ ] })
347
+ ] }),
348
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
349
+ allowClear && /* @__PURE__ */ jsxRuntime.jsx(
350
+ button.Button,
351
+ {
352
+ variant: "ghost",
353
+ size: "sm",
354
+ onClick: clearTerminal,
355
+ className: "h-8 w-8 p-0",
356
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: "h-3.5 w-3.5" })
357
+ }
358
+ ),
359
+ allowCopy && /* @__PURE__ */ jsxRuntime.jsx(
360
+ button.Button,
361
+ {
362
+ variant: "ghost",
363
+ size: "sm",
364
+ onClick: copyContent,
365
+ className: "h-8 w-8 p-0",
366
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "h-3.5 w-3.5" })
367
+ }
368
+ ),
369
+ allowDownload && /* @__PURE__ */ jsxRuntime.jsx(
370
+ button.Button,
371
+ {
372
+ variant: "ghost",
373
+ size: "sm",
374
+ onClick: downloadContent,
375
+ className: "h-8 w-8 p-0",
376
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Download, { className: "h-3.5 w-3.5" })
377
+ }
378
+ ),
379
+ allowFullscreen && /* @__PURE__ */ jsxRuntime.jsx(
380
+ button.Button,
381
+ {
382
+ variant: "ghost",
383
+ size: "sm",
384
+ onClick: () => setIsFullscreen(!isFullscreen),
385
+ className: "h-8 w-8 p-0",
386
+ children: isFullscreen ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minimize2, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize2, { className: "h-3.5 w-3.5" })
387
+ }
388
+ )
389
+ ] })
390
+ ] }),
391
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col min-h-0", children: [
392
+ /* @__PURE__ */ jsxRuntime.jsx(scrollArea.ScrollArea, { ref: scrollAreaRef, className: "flex-1 p-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1 font-mono", children: lines.map((line, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2", children: [
393
+ showLineNumbers && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground w-12 text-right flex-shrink-0", children: index + 1 }),
394
+ /* @__PURE__ */ jsxRuntime.jsx(
395
+ "div",
396
+ {
397
+ className: utils.cn(
398
+ "flex-1 whitespace-pre-wrap break-words",
399
+ line.type === "input" && "text-inherit",
400
+ line.type === "output" && "text-muted-foreground",
401
+ line.type === "error" && "text-red-400",
402
+ line.type === "system" && "text-blue-400"
403
+ ),
404
+ children: typeof line.content === "string" && line.content.includes("\x1B[") ? parseAnsiContent(line.content) : line.content
405
+ }
406
+ )
407
+ ] }, line.id)) }) }),
408
+ allowInput && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
409
+ /* @__PURE__ */ jsxRuntime.jsx(separator.Separator, {}),
410
+ /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit: handleInputSubmit, className: "p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 font-mono", children: [
411
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 flex-shrink-0" }),
412
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0", children: prompt }),
413
+ /* @__PURE__ */ jsxRuntime.jsx(
414
+ input.Input,
415
+ {
416
+ ref: inputRef,
417
+ value: input$1,
418
+ onChange: (e) => setInput(e.target.value),
419
+ onKeyDown: handleKeyDown,
420
+ className: "flex-1 border-0 bg-transparent p-0 focus-visible:ring-0 font-mono",
421
+ placeholder: "Enter command...",
422
+ autoComplete: "off",
423
+ autoFocus: true
424
+ }
425
+ )
426
+ ] }) })
427
+ ] })
428
+ ] })
429
+ ]
430
+ }
431
+ );
432
+ }
433
+ );
434
+ CodeTerminal.displayName = "CodeTerminal";
435
+
436
+ exports.CodeTerminal = CodeTerminal;
437
+ exports.codeTerminalVariants = codeTerminalVariants;