@hanzo/ui 5.3.26 → 5.3.28

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 (326) hide show
  1. package/content/index.ts +26 -0
  2. package/docs/_registry/index.ts +426 -0
  3. package/docs/_registry/layout/docs-min.tsx +197 -0
  4. package/docs/_registry/layout/page-min.tsx +128 -0
  5. package/docs/components/accordion.tsx +118 -0
  6. package/docs/components/banner.tsx +144 -0
  7. package/docs/components/callout.tsx +112 -0
  8. package/docs/components/card.tsx +52 -0
  9. package/docs/components/codeblock.tsx +258 -0
  10. package/docs/components/dialog/search-algolia.tsx +132 -0
  11. package/docs/components/dialog/search-default.tsx +131 -0
  12. package/docs/components/dialog/search-orama.tsx +143 -0
  13. package/docs/components/dialog/search.tsx +529 -0
  14. package/docs/components/dynamic-codeblock.tsx +129 -0
  15. package/docs/components/files.tsx +81 -0
  16. package/docs/components/github-info.tsx +107 -0
  17. package/docs/components/heading.tsx +33 -0
  18. package/docs/components/image-zoom.css +77 -0
  19. package/docs/components/image-zoom.tsx +58 -0
  20. package/docs/components/index.ts +7 -0
  21. package/docs/components/inline-toc.tsx +48 -0
  22. package/docs/components/sidebar/base.tsx +451 -0
  23. package/docs/components/sidebar/link-item.tsx +65 -0
  24. package/docs/components/sidebar/page-tree.tsx +113 -0
  25. package/docs/components/sidebar/tabs/dropdown.tsx +109 -0
  26. package/docs/components/sidebar/tabs/index.tsx +89 -0
  27. package/docs/components/steps.tsx +9 -0
  28. package/docs/components/tabs.tsx +203 -0
  29. package/docs/components/toc/clerk.tsx +173 -0
  30. package/docs/components/toc/default.tsx +57 -0
  31. package/docs/components/toc/index.tsx +136 -0
  32. package/docs/components/type-table.tsx +174 -0
  33. package/docs/components/ui/accordion.tsx +88 -0
  34. package/docs/components/ui/button.tsx +28 -0
  35. package/docs/components/ui/collapsible.tsx +42 -0
  36. package/docs/components/ui/navigation-menu.tsx +83 -0
  37. package/docs/components/ui/popover.tsx +32 -0
  38. package/docs/components/ui/scroll-area.tsx +59 -0
  39. package/docs/components/ui/tabs.tsx +145 -0
  40. package/docs/contexts/i18n.tsx +56 -0
  41. package/docs/contexts/search.tsx +165 -0
  42. package/docs/contexts/tree.tsx +65 -0
  43. package/docs/css/black.css +39 -0
  44. package/docs/css/catppuccin.css +49 -0
  45. package/docs/css/colors/index.css +51 -0
  46. package/docs/css/dusk.css +47 -0
  47. package/docs/css/layouts/docs.css +1 -0
  48. package/docs/css/layouts/home.css +1 -0
  49. package/docs/css/layouts/notebook.css +1 -0
  50. package/docs/css/neutral.css +7 -0
  51. package/docs/css/ocean.css +48 -0
  52. package/docs/css/preset.css +305 -0
  53. package/docs/css/purple.css +39 -0
  54. package/docs/css/shadcn.css +36 -0
  55. package/docs/css/shiki.css +90 -0
  56. package/docs/css/solar.css +75 -0
  57. package/docs/css/style.css +9 -0
  58. package/docs/css/vitepress.css +77 -0
  59. package/docs/i18n.tsx +30 -0
  60. package/docs/icons.tsx +354 -0
  61. package/docs/layouts/docs/client.tsx +129 -0
  62. package/docs/layouts/docs/index.tsx +321 -0
  63. package/docs/layouts/docs/page/client.tsx +376 -0
  64. package/docs/layouts/docs/page/index.tsx +251 -0
  65. package/docs/layouts/docs/sidebar.tsx +265 -0
  66. package/docs/layouts/home/client.tsx +375 -0
  67. package/docs/layouts/home/index.tsx +51 -0
  68. package/docs/layouts/home/navbar.tsx +55 -0
  69. package/docs/layouts/notebook/client.tsx +281 -0
  70. package/docs/layouts/notebook/index.tsx +461 -0
  71. package/docs/layouts/notebook/page/client.tsx +375 -0
  72. package/docs/layouts/notebook/page/index.tsx +251 -0
  73. package/docs/layouts/notebook/sidebar.tsx +248 -0
  74. package/docs/layouts/shared/index.tsx +89 -0
  75. package/docs/layouts/shared/language-toggle.tsx +66 -0
  76. package/docs/layouts/shared/link-item.tsx +119 -0
  77. package/docs/layouts/shared/search-toggle.tsx +78 -0
  78. package/docs/layouts/shared/theme-toggle.tsx +86 -0
  79. package/docs/mdx.server.tsx +37 -0
  80. package/docs/mdx.tsx +97 -0
  81. package/docs/og.tsx +101 -0
  82. package/docs/page.tsx +85 -0
  83. package/docs/provider/base.tsx +173 -0
  84. package/docs/provider/next.tsx +23 -0
  85. package/docs/provider/react-router.tsx +23 -0
  86. package/docs/provider/tanstack.tsx +23 -0
  87. package/docs/provider/waku.tsx +23 -0
  88. package/docs/source.ts +3 -0
  89. package/docs/theme/typography/LICENSE +21 -0
  90. package/docs/theme/typography/index.ts +201 -0
  91. package/docs/theme/typography/styles.ts +449 -0
  92. package/docs/utils/cn.ts +1 -0
  93. package/docs/utils/is-active.ts +23 -0
  94. package/docs/utils/merge-refs.ts +15 -0
  95. package/docs/utils/use-copy-button.ts +39 -0
  96. package/docs/utils/use-footer-items.ts +27 -0
  97. package/docs/utils/use-is-scroll-top.ts +21 -0
  98. package/package.json +4 -2
  99. package/dist/3d/button.js +0 -298
  100. package/dist/3d/button.mjs +0 -273
  101. package/dist/3d/card.js +0 -234
  102. package/dist/3d/card.mjs +0 -207
  103. package/dist/3d/carousel.js +0 -371
  104. package/dist/3d/carousel.mjs +0 -344
  105. package/dist/3d/grid.js +0 -362
  106. package/dist/3d/grid.mjs +0 -337
  107. package/dist/3d/index.js +0 -1518
  108. package/dist/3d/index.mjs +0 -1472
  109. package/dist/3d/marquee.js +0 -352
  110. package/dist/3d/marquee.mjs +0 -327
  111. package/dist/3d/pin.js +0 -46
  112. package/dist/3d/pin.mjs +0 -24
  113. package/dist/accordion.js +0 -80
  114. package/dist/accordion.mjs +0 -55
  115. package/dist/alert-dialog.js +0 -220
  116. package/dist/alert-dialog.mjs +0 -187
  117. package/dist/alert.js +0 -68
  118. package/dist/alert.mjs +0 -64
  119. package/dist/animation/animated-background.js +0 -424
  120. package/dist/animation/animated-background.mjs +0 -418
  121. package/dist/animation/animated-beam.js +0 -119
  122. package/dist/animation/animated-beam.mjs +0 -97
  123. package/dist/animation/animated-cursor.js +0 -275
  124. package/dist/animation/animated-cursor.mjs +0 -270
  125. package/dist/animation/animated-icon.js +0 -357
  126. package/dist/animation/animated-icon.mjs +0 -351
  127. package/dist/animation/animated-list.js +0 -339
  128. package/dist/animation/animated-list.mjs +0 -333
  129. package/dist/animation/animated-number.js +0 -283
  130. package/dist/animation/animated-number.mjs +0 -277
  131. package/dist/animation/animated-testimonials.js +0 -97
  132. package/dist/animation/animated-testimonials.mjs +0 -75
  133. package/dist/animation/animated-tooltip.js +0 -67
  134. package/dist/animation/animated-tooltip.mjs +0 -45
  135. package/dist/animation/apple-cards-carousel.js +0 -308
  136. package/dist/animation/apple-cards-carousel.mjs +0 -285
  137. package/dist/animation/apple-hello-effect.js +0 -60
  138. package/dist/animation/apple-hello-effect.mjs +0 -38
  139. package/dist/animation/index.js +0 -1952
  140. package/dist/animation/index.mjs +0 -1921
  141. package/dist/avatar.js +0 -71
  142. package/dist/avatar.mjs +0 -47
  143. package/dist/badge.js +0 -66
  144. package/dist/badge.mjs +0 -40
  145. package/dist/blocks/index.js +0 -1665
  146. package/dist/blocks/index.mjs +0 -1626
  147. package/dist/breadcrumb.js +0 -107
  148. package/dist/breadcrumb.mjs +0 -99
  149. package/dist/calendar.js +0 -189
  150. package/dist/calendar.mjs +0 -164
  151. package/dist/carousel.js +0 -278
  152. package/dist/carousel.mjs +0 -249
  153. package/dist/checkbox.js +0 -60
  154. package/dist/checkbox.mjs +0 -35
  155. package/dist/code/block.js +0 -226
  156. package/dist/code/block.mjs +0 -203
  157. package/dist/code/compare.js +0 -446
  158. package/dist/code/compare.mjs +0 -423
  159. package/dist/code/diff.js +0 -430
  160. package/dist/code/diff.mjs +0 -407
  161. package/dist/code/editor.js +0 -243
  162. package/dist/code/editor.mjs +0 -218
  163. package/dist/code/explorer.js +0 -291
  164. package/dist/code/explorer.mjs +0 -268
  165. package/dist/code/index.js +0 -2551
  166. package/dist/code/index.mjs +0 -2510
  167. package/dist/code/preview.js +0 -400
  168. package/dist/code/preview.mjs +0 -377
  169. package/dist/code/snippet.js +0 -274
  170. package/dist/code/snippet.mjs +0 -250
  171. package/dist/code/tabs.js +0 -75
  172. package/dist/code/tabs.mjs +0 -53
  173. package/dist/code/terminal.js +0 -437
  174. package/dist/code/terminal.mjs +0 -414
  175. package/dist/collapsible.js +0 -33
  176. package/dist/collapsible.mjs +0 -9
  177. package/dist/command.js +0 -262
  178. package/dist/command.mjs +0 -232
  179. package/dist/context-menu.js +0 -207
  180. package/dist/context-menu.mjs +0 -171
  181. package/dist/device/index.js +0 -3
  182. package/dist/device/index.mjs +0 -2
  183. package/dist/dialog.js +0 -151
  184. package/dist/dialog.mjs +0 -121
  185. package/dist/dock/basic.js +0 -174
  186. package/dist/dock/basic.mjs +0 -151
  187. package/dist/dock/index.js +0 -628
  188. package/dist/dock/index.mjs +0 -601
  189. package/dist/dock/limelight-nav.js +0 -295
  190. package/dist/dock/limelight-nav.mjs +0 -274
  191. package/dist/dock/macos.js +0 -141
  192. package/dist/dock/macos.mjs +0 -118
  193. package/dist/dock/menu.js +0 -70
  194. package/dist/dock/menu.mjs +0 -48
  195. package/dist/dock/message.js +0 -144
  196. package/dist/dock/message.mjs +0 -122
  197. package/dist/drawer.js +0 -115
  198. package/dist/drawer.mjs +0 -103
  199. package/dist/dropdown-menu.js +0 -202
  200. package/dist/dropdown-menu.mjs +0 -166
  201. package/dist/finance/AdvancedChart.js +0 -48
  202. package/dist/finance/AdvancedChart.mjs +0 -46
  203. package/dist/finance/CompanyProfile.js +0 -48
  204. package/dist/finance/CompanyProfile.mjs +0 -46
  205. package/dist/finance/CryptoScreener.js +0 -45
  206. package/dist/finance/CryptoScreener.mjs +0 -43
  207. package/dist/finance/Financials.js +0 -52
  208. package/dist/finance/Financials.mjs +0 -50
  209. package/dist/finance/ForexScreener.js +0 -46
  210. package/dist/finance/ForexScreener.mjs +0 -44
  211. package/dist/finance/MarketOverview.js +0 -104
  212. package/dist/finance/MarketOverview.mjs +0 -102
  213. package/dist/finance/NewsTimeline.js +0 -44
  214. package/dist/finance/NewsTimeline.mjs +0 -42
  215. package/dist/finance/OrderEntry.js +0 -131
  216. package/dist/finance/OrderEntry.mjs +0 -129
  217. package/dist/finance/OrdersHistory.js +0 -64
  218. package/dist/finance/OrdersHistory.mjs +0 -62
  219. package/dist/finance/PositionsList.js +0 -80
  220. package/dist/finance/PositionsList.mjs +0 -78
  221. package/dist/finance/StockScreener.js +0 -46
  222. package/dist/finance/StockScreener.mjs +0 -44
  223. package/dist/finance/SymbolInfo.js +0 -46
  224. package/dist/finance/SymbolInfo.mjs +0 -44
  225. package/dist/finance/TechnicalAnalysis.js +0 -54
  226. package/dist/finance/TechnicalAnalysis.mjs +0 -52
  227. package/dist/finance/TickerTape.js +0 -56
  228. package/dist/finance/TickerTape.mjs +0 -54
  229. package/dist/finance/TradingPanel.js +0 -191
  230. package/dist/finance/TradingPanel.mjs +0 -189
  231. package/dist/finance/index.js +0 -930
  232. package/dist/finance/index.mjs +0 -914
  233. package/dist/form/index.js +0 -155
  234. package/dist/form/index.mjs +0 -125
  235. package/dist/form.js +0 -172
  236. package/dist/form.mjs +0 -142
  237. package/dist/hover-card.js +0 -58
  238. package/dist/hover-card.mjs +0 -34
  239. package/dist/index.js +0 -10179
  240. package/dist/index.mjs +0 -9785
  241. package/dist/input-otp.js +0 -79
  242. package/dist/input-otp.mjs +0 -54
  243. package/dist/lib/utils.js +0 -28
  244. package/dist/lib/utils.mjs +0 -24
  245. package/dist/navigation/index.js +0 -98
  246. package/dist/navigation/index.mjs +0 -79
  247. package/dist/navigation-menu.js +0 -149
  248. package/dist/navigation-menu.mjs +0 -116
  249. package/dist/pattern/grid-pattern.js +0 -333
  250. package/dist/pattern/grid-pattern.mjs +0 -310
  251. package/dist/pattern/index.js +0 -333
  252. package/dist/pattern/index.mjs +0 -310
  253. package/dist/popover.js +0 -63
  254. package/dist/popover.mjs +0 -37
  255. package/dist/primitives/index.js +0 -10179
  256. package/dist/primitives/index.mjs +0 -9785
  257. package/dist/primitives-export.js +0 -10179
  258. package/dist/primitives-export.mjs +0 -9785
  259. package/dist/progress.js +0 -62
  260. package/dist/progress.mjs +0 -37
  261. package/dist/project/gantt.js +0 -65
  262. package/dist/project/gantt.mjs +0 -43
  263. package/dist/project/index.js +0 -636
  264. package/dist/project/index.mjs +0 -611
  265. package/dist/project/kanban.js +0 -597
  266. package/dist/project/kanban.mjs +0 -572
  267. package/dist/project/list.js +0 -35
  268. package/dist/project/list.mjs +0 -12
  269. package/dist/radio-group.js +0 -68
  270. package/dist/radio-group.mjs +0 -45
  271. package/dist/resizable.js +0 -72
  272. package/dist/resizable.mjs +0 -48
  273. package/dist/scroll-area.js +0 -89
  274. package/dist/scroll-area.mjs +0 -66
  275. package/dist/select.js +0 -140
  276. package/dist/select.mjs +0 -111
  277. package/dist/separator.js +0 -59
  278. package/dist/separator.mjs +0 -34
  279. package/dist/sheet.js +0 -148
  280. package/dist/sheet.mjs +0 -117
  281. package/dist/skeleton.js +0 -32
  282. package/dist/skeleton.mjs +0 -27
  283. package/dist/slider.js +0 -99
  284. package/dist/slider.mjs +0 -73
  285. package/dist/sonner.js +0 -34
  286. package/dist/sonner.mjs +0 -29
  287. package/dist/switch.js +0 -62
  288. package/dist/switch.mjs +0 -37
  289. package/dist/table.js +0 -110
  290. package/dist/table.mjs +0 -101
  291. package/dist/tabs.js +0 -82
  292. package/dist/tabs.mjs +0 -57
  293. package/dist/tailwind/index.js +0 -2023
  294. package/dist/tailwind/index.mjs +0 -2011
  295. package/dist/textarea.js +0 -78
  296. package/dist/textarea.mjs +0 -56
  297. package/dist/toggle-group.js +0 -118
  298. package/dist/toggle-group.mjs +0 -93
  299. package/dist/toggle.js +0 -71
  300. package/dist/toggle.mjs +0 -48
  301. package/dist/tooltip.js +0 -67
  302. package/dist/tooltip.mjs +0 -40
  303. package/dist/types/index.js +0 -57
  304. package/dist/types/index.mjs +0 -51
  305. package/dist/ui/announcement.js +0 -129
  306. package/dist/ui/announcement.mjs +0 -107
  307. package/dist/ui/avatar-group.js +0 -88
  308. package/dist/ui/avatar-group.mjs +0 -65
  309. package/dist/ui/banner.js +0 -85
  310. package/dist/ui/banner.mjs +0 -62
  311. package/dist/ui/cursor.js +0 -78
  312. package/dist/ui/cursor.mjs +0 -56
  313. package/dist/ui/index.js +0 -475
  314. package/dist/ui/index.mjs +0 -442
  315. package/dist/ui/marquee.js +0 -74
  316. package/dist/ui/marquee.mjs +0 -52
  317. package/dist/ui/pill.js +0 -85
  318. package/dist/ui/pill.mjs +0 -62
  319. package/dist/ui/spinner.js +0 -28
  320. package/dist/ui/spinner.mjs +0 -26
  321. package/dist/ui/tags.js +0 -101
  322. package/dist/ui/tags.mjs +0 -79
  323. package/dist/ui/ticker.js +0 -73
  324. package/dist/ui/ticker.mjs +0 -51
  325. package/dist/util/index.js +0 -457
  326. package/dist/util/index.mjs +0 -399
@@ -1,377 +0,0 @@
1
- "use client";
2
- import * as React from 'react';
3
- import { cva } from 'class-variance-authority';
4
- import { Check, Copy, Eye, EyeOff, Terminal, RefreshCw, Play, Square, Settings, AlertTriangle, X } from 'lucide-react';
5
- import { cn } from '@hanzo/ui/lib/utils';
6
- import { Badge } from '@hanzo/ui/badge';
7
- import { Button } from '@hanzo/ui/button';
8
- import { CodeSnippet } from '@hanzo/ui/code/snippet';
9
- import { Separator } from '@hanzo/ui/separator';
10
- import { Tabs, TabsList, TabsTrigger, TabsContent } from '@hanzo/ui/tabs';
11
- import { Toggle } from '@hanzo/ui/toggle';
12
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
13
-
14
- var __defProp = Object.defineProperty;
15
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
16
- var codePreviewVariants = cva(
17
- "relative overflow-hidden rounded-lg border bg-background",
18
- {
19
- variants: {
20
- size: {
21
- sm: "text-xs",
22
- default: "text-sm",
23
- lg: "text-base"
24
- }
25
- },
26
- defaultVariants: {
27
- size: "default"
28
- }
29
- }
30
- );
31
- var runHTMLCode = /* @__PURE__ */ __name((files) => {
32
- const htmlFile = files.find((f) => f.type === "html");
33
- const cssFiles = files.filter((f) => f.type === "css");
34
- const jsFiles = files.filter((f) => f.type === "js");
35
- let html = htmlFile?.content || "<div>No HTML file provided</div>";
36
- if (cssFiles.length > 0) {
37
- const cssContent = cssFiles.map((f) => f.content).join("\n");
38
- html = `<style>${cssContent}</style>
39
- ${html}`;
40
- }
41
- if (jsFiles.length > 0) {
42
- const jsContent = jsFiles.map((f) => f.content).join("\n");
43
- html = `${html}
44
- <script>${jsContent}</script>`;
45
- }
46
- return html;
47
- }, "runHTMLCode");
48
- var consoleScript = `
49
- <script>
50
- const originalConsole = window.console;
51
- const logs = [];
52
-
53
- ['log', 'warn', 'error', 'info'].forEach(method => {
54
- window.console[method] = function(...args) {
55
- logs.push({
56
- type: method,
57
- content: args.map(arg =>
58
- typeof arg === 'object' ? JSON.stringify(arg, null, 2) : String(arg)
59
- ).join(' '),
60
- timestamp: Date.now()
61
- });
62
-
63
- // Also call original console method
64
- originalConsole[method].apply(originalConsole, arguments);
65
-
66
- // Send to parent
67
- window.parent.postMessage({
68
- type: 'console',
69
- data: logs[logs.length - 1]
70
- }, '*');
71
- };
72
- });
73
-
74
- window.addEventListener('error', (e) => {
75
- window.parent.postMessage({
76
- type: 'error',
77
- data: {
78
- type: 'error',
79
- content: e.message + ' at ' + e.filename + ':' + e.lineno,
80
- timestamp: Date.now()
81
- }
82
- }, '*');
83
- });
84
- </script>
85
- `;
86
- var CodePreview = React.forwardRef(
87
- ({
88
- className,
89
- size,
90
- files,
91
- defaultFile,
92
- showPreview = true,
93
- showConsole = true,
94
- autoRun = false,
95
- maxHeight = "600px",
96
- previewHeight = "300px",
97
- consoleHeight = "150px",
98
- allowFullscreen = true,
99
- customRunner,
100
- ...props
101
- }, ref) => {
102
- const [activeFile, setActiveFile] = React.useState(
103
- defaultFile || files[0]?.filename || ""
104
- );
105
- const [previewContent, setPreviewContent] = React.useState("");
106
- const [isRunning, setIsRunning] = React.useState(false);
107
- const [results, setResults] = React.useState([]);
108
- const [isPreviewVisible, setIsPreviewVisible] = React.useState(showPreview);
109
- const [isConsoleVisible, setIsConsoleVisible] = React.useState(showConsole);
110
- const [isFullscreen, setIsFullscreen] = React.useState(false);
111
- const [copied, setCopied] = React.useState({});
112
- const iframeRef = React.useRef(null);
113
- files.find((f) => f.filename === activeFile) || files[0];
114
- React.useEffect(() => {
115
- const handleMessage = /* @__PURE__ */ __name((event) => {
116
- if (event.data?.type === "console" || event.data?.type === "error") {
117
- setResults((prev) => [...prev, event.data.data]);
118
- }
119
- }, "handleMessage");
120
- window.addEventListener("message", handleMessage);
121
- return () => window.removeEventListener("message", handleMessage);
122
- }, []);
123
- const runCode = React.useCallback(async () => {
124
- setIsRunning(true);
125
- setResults([]);
126
- try {
127
- let output;
128
- if (customRunner) {
129
- output = await customRunner(files);
130
- } else {
131
- output = runHTMLCode(files);
132
- }
133
- output = consoleScript + output;
134
- setPreviewContent(output);
135
- if (iframeRef.current) {
136
- const doc = iframeRef.current.contentDocument;
137
- if (doc) {
138
- doc.open();
139
- doc.write(output);
140
- doc.close();
141
- }
142
- }
143
- } catch (error) {
144
- setResults([
145
- {
146
- type: "error",
147
- content: error instanceof Error ? error.message : String(error),
148
- timestamp: Date.now()
149
- }
150
- ]);
151
- } finally {
152
- setIsRunning(false);
153
- }
154
- }, [files, customRunner]);
155
- React.useEffect(() => {
156
- if (autoRun) {
157
- const timer = setTimeout(runCode, 1e3);
158
- return () => clearTimeout(timer);
159
- }
160
- }, [files, autoRun, runCode]);
161
- const copyFileContent = React.useCallback(
162
- async (filename) => {
163
- const file = files.find((f) => f.filename === filename);
164
- if (!file) return;
165
- try {
166
- await navigator.clipboard.writeText(file.content);
167
- setCopied((prev) => ({ ...prev, [filename]: true }));
168
- setTimeout(() => {
169
- setCopied((prev) => ({ ...prev, [filename]: false }));
170
- }, 2e3);
171
- } catch (error) {
172
- console.error("Failed to copy code:", error);
173
- }
174
- },
175
- [files]
176
- );
177
- const clearConsole = /* @__PURE__ */ __name(() => {
178
- setResults([]);
179
- }, "clearConsole");
180
- const renderConsole = /* @__PURE__ */ __name(() => /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
181
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b px-4 py-2 bg-muted/30", children: [
182
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
183
- /* @__PURE__ */ jsx(Terminal, { className: "h-4 w-4" }),
184
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Console" }),
185
- results.length > 0 && /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: results.length })
186
- ] }),
187
- /* @__PURE__ */ jsx(
188
- Button,
189
- {
190
- variant: "ghost",
191
- size: "sm",
192
- onClick: clearConsole,
193
- className: "h-8 w-8 p-0",
194
- children: /* @__PURE__ */ jsx(X, { className: "h-3.5 w-3.5" })
195
- }
196
- )
197
- ] }),
198
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-auto p-2 space-y-1 font-mono text-xs", children: results.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-muted-foreground italic", children: "No output" }) : results.map((result, index) => /* @__PURE__ */ jsxs(
199
- "div",
200
- {
201
- className: cn(
202
- "flex items-start gap-2 p-2 rounded",
203
- result.type === "error" && "bg-red-500/10 text-red-600 dark:text-red-400",
204
- result.type === "log" && "bg-blue-500/10 text-blue-600 dark:text-blue-400",
205
- result.type === "output" && "bg-green-500/10 text-green-600 dark:text-green-400"
206
- ),
207
- children: [
208
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: new Date(result.timestamp).toLocaleTimeString() }),
209
- /* @__PURE__ */ jsx("pre", { className: "flex-1 whitespace-pre-wrap break-words", children: result.content })
210
- ]
211
- },
212
- index
213
- )) })
214
- ] }), "renderConsole");
215
- const layout = isFullscreen ? "fixed inset-0 z-50 bg-background" : "";
216
- return /* @__PURE__ */ jsxs(
217
- "div",
218
- {
219
- ref,
220
- className: cn(codePreviewVariants({ size }), layout, className),
221
- style: { maxHeight: isFullscreen ? "100vh" : maxHeight },
222
- ...props,
223
- children: [
224
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b px-4 py-2", children: [
225
- /* @__PURE__ */ jsx(
226
- Tabs,
227
- {
228
- value: activeFile,
229
- onValueChange: setActiveFile,
230
- className: "flex-1",
231
- children: /* @__PURE__ */ jsx(TabsList, { className: "h-auto p-0 bg-transparent", children: files.map((file) => /* @__PURE__ */ jsxs(
232
- TabsTrigger,
233
- {
234
- value: file.filename,
235
- className: "relative flex items-center gap-2 data-[state=active]:bg-muted",
236
- children: [
237
- /* @__PURE__ */ jsx("span", { children: file.filename }),
238
- /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "text-xs", children: file.language }),
239
- /* @__PURE__ */ jsx(
240
- Button,
241
- {
242
- variant: "ghost",
243
- size: "sm",
244
- onClick: (e) => {
245
- e.stopPropagation();
246
- copyFileContent(file.filename);
247
- },
248
- className: "h-6 w-6 p-0 opacity-0 group-hover:opacity-100",
249
- children: copied[file.filename] ? /* @__PURE__ */ jsx(Check, { className: "h-3 w-3 text-green-500" }) : /* @__PURE__ */ jsx(Copy, { className: "h-3 w-3" })
250
- }
251
- )
252
- ]
253
- },
254
- file.filename
255
- )) })
256
- }
257
- ),
258
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
259
- /* @__PURE__ */ jsx(
260
- Toggle,
261
- {
262
- pressed: isPreviewVisible,
263
- onPressedChange: setIsPreviewVisible,
264
- "aria-label": "Toggle preview",
265
- size: "sm",
266
- children: isPreviewVisible ? /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(EyeOff, { className: "h-4 w-4" })
267
- }
268
- ),
269
- /* @__PURE__ */ jsx(
270
- Toggle,
271
- {
272
- pressed: isConsoleVisible,
273
- onPressedChange: setIsConsoleVisible,
274
- "aria-label": "Toggle console",
275
- size: "sm",
276
- children: /* @__PURE__ */ jsx(Terminal, { className: "h-4 w-4" })
277
- }
278
- ),
279
- /* @__PURE__ */ jsxs(
280
- Button,
281
- {
282
- variant: "outline",
283
- size: "sm",
284
- onClick: runCode,
285
- disabled: isRunning,
286
- className: "gap-2",
287
- children: [
288
- isRunning ? /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Play, { className: "h-4 w-4" }),
289
- "Run"
290
- ]
291
- }
292
- ),
293
- allowFullscreen && /* @__PURE__ */ jsx(
294
- Button,
295
- {
296
- variant: "ghost",
297
- size: "sm",
298
- onClick: () => setIsFullscreen(!isFullscreen),
299
- className: "h-8 w-8 p-0",
300
- children: isFullscreen ? /* @__PURE__ */ jsx(Square, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(Settings, { className: "h-4 w-4" })
301
- }
302
- )
303
- ] })
304
- ] }),
305
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
306
- /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0", children: /* @__PURE__ */ jsx(Tabs, { value: activeFile, onValueChange: setActiveFile, children: files.map((file) => /* @__PURE__ */ jsx(
307
- TabsContent,
308
- {
309
- value: file.filename,
310
- className: "m-0 h-full",
311
- children: /* @__PURE__ */ jsx(
312
- CodeSnippet,
313
- {
314
- code: file.content,
315
- language: file.language,
316
- showLineNumbers: true,
317
- showCopyButton: false,
318
- showHeader: false,
319
- maxHeight: "100%",
320
- className: "border-0 rounded-none"
321
- }
322
- )
323
- },
324
- file.filename
325
- )) }) }),
326
- (isPreviewVisible || isConsoleVisible) && /* @__PURE__ */ jsxs(Fragment, { children: [
327
- /* @__PURE__ */ jsx(Separator, {}),
328
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col lg:flex-row min-h-0", children: [
329
- isPreviewVisible && /* @__PURE__ */ jsxs(
330
- "div",
331
- {
332
- className: "flex-1 min-h-0 border-r last:border-r-0",
333
- style: { height: previewHeight },
334
- children: [
335
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border-b px-4 py-2 bg-muted/30", children: [
336
- /* @__PURE__ */ jsx(Eye, { className: "h-4 w-4" }),
337
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Preview" }),
338
- results.filter((r) => r.type === "error").length > 0 && /* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4 text-red-500" })
339
- ] }),
340
- /* @__PURE__ */ jsx(
341
- "iframe",
342
- {
343
- ref: iframeRef,
344
- className: "w-full h-full bg-white",
345
- sandbox: "allow-scripts allow-same-origin",
346
- srcDoc: previewContent
347
- }
348
- )
349
- ]
350
- }
351
- ),
352
- isConsoleVisible && /* @__PURE__ */ jsx(
353
- "div",
354
- {
355
- className: "flex-1 min-h-0",
356
- style: { height: consoleHeight },
357
- children: renderConsole()
358
- }
359
- )
360
- ] })
361
- ] })
362
- ] }),
363
- isFullscreen && /* @__PURE__ */ jsx(
364
- "div",
365
- {
366
- className: "absolute inset-0 bg-black/50",
367
- onClick: () => setIsFullscreen(false)
368
- }
369
- )
370
- ]
371
- }
372
- );
373
- }
374
- );
375
- CodePreview.displayName = "CodePreview";
376
-
377
- export { CodePreview, codePreviewVariants };
@@ -1,274 +0,0 @@
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 shiki = require('shiki');
8
- var utils = require('@hanzo/ui/lib/utils');
9
- var badge = require('@hanzo/ui/badge');
10
- var button = require('@hanzo/ui/button');
11
- var skeleton = require('@hanzo/ui/skeleton');
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 codeSnippetVariants = classVarianceAuthority.cva("relative group", {
37
- variants: {
38
- variant: {
39
- default: "rounded-lg border bg-muted/50",
40
- inline: "inline-block rounded-md bg-muted px-2 py-1",
41
- minimal: "bg-transparent"
42
- },
43
- theme: {
44
- dark: "bg-slate-950 border-slate-800",
45
- light: "bg-slate-50 border-slate-200",
46
- github: "bg-white border-slate-200",
47
- "github-dark": "bg-slate-900 border-slate-700",
48
- terminal: "bg-black border-green-500/30 text-green-400",
49
- retro: "bg-amber-50 border-amber-200 text-amber-900"
50
- },
51
- size: {
52
- xs: "text-xs",
53
- sm: "text-sm",
54
- default: "text-sm",
55
- lg: "text-base"
56
- }
57
- },
58
- defaultVariants: {
59
- variant: "default",
60
- theme: "dark",
61
- size: "default"
62
- }
63
- });
64
- var CodeSnippet = React__namespace.forwardRef(
65
- ({
66
- className,
67
- variant,
68
- theme,
69
- size,
70
- code,
71
- language = "text",
72
- filename,
73
- showLineNumbers = false,
74
- highlightLines = [],
75
- showCopyButton = true,
76
- showLanguageBadge = true,
77
- showHeader = true,
78
- maxHeight,
79
- expandable = false,
80
- collapsedHeight = "200px",
81
- wrapLines = false,
82
- startLineNumber = 1,
83
- ...props
84
- }, ref) => {
85
- const [highlightedCode, setHighlightedCode] = React__namespace.useState("");
86
- const [copied, setCopied] = React__namespace.useState(false);
87
- const [isLoading, setIsLoading] = React__namespace.useState(true);
88
- const [isExpanded, setIsExpanded] = React__namespace.useState(!expandable);
89
- const themeMap = {
90
- dark: "github-dark",
91
- light: "github-light",
92
- github: "github-light",
93
- "github-dark": "github-dark",
94
- terminal: "github-dark",
95
- retro: "github-light"
96
- };
97
- React__namespace.useEffect(() => {
98
- const highlightCode = /* @__PURE__ */ __name(async () => {
99
- setIsLoading(true);
100
- try {
101
- const supportedLang = Object.keys(shiki.bundledLanguages).includes(language);
102
- const highlighted = await shiki.codeToHtml(code, {
103
- lang: supportedLang ? language : "text",
104
- theme: themeMap[theme || "dark"]
105
- });
106
- const tempDiv = document.createElement("div");
107
- tempDiv.innerHTML = highlighted;
108
- const codeElement = tempDiv.querySelector("code");
109
- setHighlightedCode(codeElement?.innerHTML || highlighted);
110
- } catch (error) {
111
- console.error("Failed to highlight code:", error);
112
- const escaped = code.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
113
- setHighlightedCode(escaped);
114
- } finally {
115
- setIsLoading(false);
116
- }
117
- }, "highlightCode");
118
- highlightCode();
119
- }, [code, language, theme]);
120
- const copyToClipboard = React__namespace.useCallback(async () => {
121
- try {
122
- await navigator.clipboard.writeText(code);
123
- setCopied(true);
124
- setTimeout(() => setCopied(false), 2e3);
125
- } catch (error) {
126
- console.error("Failed to copy code:", error);
127
- }
128
- }, [code]);
129
- const lines = highlightedCode.split("\n").filter((line, index, array) => {
130
- return line.trim() !== "" || index < array.length - 1;
131
- });
132
- const renderInline = /* @__PURE__ */ __name(() => /* @__PURE__ */ jsxRuntime.jsx(
133
- "code",
134
- {
135
- className: utils.cn(
136
- codeSnippetVariants({ variant, theme, size }),
137
- "font-mono",
138
- className
139
- ),
140
- dangerouslySetInnerHTML: { __html: highlightedCode }
141
- }
142
- ), "renderInline");
143
- const renderBlock = /* @__PURE__ */ __name(() => /* @__PURE__ */ jsxRuntime.jsxs(
144
- "div",
145
- {
146
- ref,
147
- className: utils.cn(
148
- codeSnippetVariants({ variant, theme, size }),
149
- "overflow-hidden",
150
- className
151
- ),
152
- ...props,
153
- children: [
154
- showHeader && (filename || language || showCopyButton || expandable) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border-b px-4 py-2 bg-muted/30", children: [
155
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
156
- filename && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
157
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileText, { className: "h-3.5 w-3.5 text-muted-foreground" }),
158
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: filename })
159
- ] }),
160
- showLanguageBadge && language && /* @__PURE__ */ jsxRuntime.jsx(badge.Badge, { variant: "secondary", className: "text-xs", children: language })
161
- ] }),
162
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
163
- expandable && /* @__PURE__ */ jsxRuntime.jsxs(
164
- button.Button,
165
- {
166
- variant: "ghost",
167
- size: "sm",
168
- onClick: () => setIsExpanded(!isExpanded),
169
- className: "h-8 w-8 p-0",
170
- children: [
171
- isExpanded ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minimize2, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize2, { className: "h-3.5 w-3.5" }),
172
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: isExpanded ? "Collapse" : "Expand" })
173
- ]
174
- }
175
- ),
176
- showCopyButton && /* @__PURE__ */ jsxRuntime.jsxs(
177
- button.Button,
178
- {
179
- variant: "ghost",
180
- size: "sm",
181
- onClick: copyToClipboard,
182
- className: "h-8 w-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity",
183
- children: [
184
- copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3.5 w-3.5 text-green-500" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "h-3.5 w-3.5" }),
185
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: copied ? "Copied" : "Copy code" })
186
- ]
187
- }
188
- )
189
- ] })
190
- ] }),
191
- /* @__PURE__ */ jsxRuntime.jsx(
192
- "div",
193
- {
194
- className: utils.cn("overflow-auto", !wrapLines && "overflow-x-auto"),
195
- style: {
196
- maxHeight: isExpanded ? maxHeight : collapsedHeight
197
- },
198
- children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 space-y-2", children: Array.from({ length: Math.min(lines.length || 5, 10) }).map(
199
- (_, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
200
- showLineNumbers && /* @__PURE__ */ jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 w-8" }),
201
- /* @__PURE__ */ jsxRuntime.jsx(skeleton.Skeleton, { className: "h-4 flex-1" })
202
- ] }, i)
203
- ) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-mono", children: lines.map((line, index) => {
204
- const lineNumber = index + startLineNumber;
205
- const isHighlighted = highlightLines.includes(lineNumber);
206
- return /* @__PURE__ */ jsxRuntime.jsxs(
207
- "div",
208
- {
209
- className: utils.cn(
210
- "group relative flex min-h-[1.5rem] items-center px-4 py-0.5",
211
- isHighlighted && "bg-blue-500/10 border-l-2 border-l-blue-500",
212
- !wrapLines && "whitespace-nowrap"
213
- ),
214
- children: [
215
- showLineNumbers && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mr-4 inline-block w-8 select-none text-right text-xs text-muted-foreground", children: lineNumber }),
216
- /* @__PURE__ */ jsxRuntime.jsx(
217
- "div",
218
- {
219
- className: utils.cn(
220
- "flex-1",
221
- wrapLines ? "whitespace-pre-wrap break-words" : "overflow-x-auto"
222
- ),
223
- dangerouslySetInnerHTML: { __html: line }
224
- }
225
- )
226
- ]
227
- },
228
- index
229
- );
230
- }) })
231
- }
232
- ),
233
- expandable && !isExpanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute bottom-0 left-0 right-0 h-8 bg-gradient-to-t from-background to-transparent pointer-events-none" }),
234
- variant === "minimal" && showCopyButton && /* @__PURE__ */ jsxRuntime.jsx(
235
- button.Button,
236
- {
237
- variant: "ghost",
238
- size: "sm",
239
- onClick: copyToClipboard,
240
- className: "absolute top-2 right-2 h-8 w-8 p-0 opacity-0 group-hover:opacity-100 transition-opacity",
241
- children: copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3.5 w-3.5 text-green-500" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "h-3.5 w-3.5" })
242
- }
243
- )
244
- ]
245
- }
246
- ), "renderBlock");
247
- if (variant === "inline") {
248
- return renderInline();
249
- }
250
- return renderBlock();
251
- }
252
- );
253
- CodeSnippet.displayName = "CodeSnippet";
254
- var InlineCode = React__namespace.forwardRef(({ children, language, className, ...props }, ref) => {
255
- return /* @__PURE__ */ jsxRuntime.jsx(
256
- CodeSnippet,
257
- {
258
- ref,
259
- code: children,
260
- language,
261
- variant: "inline",
262
- showCopyButton: false,
263
- showLanguageBadge: false,
264
- showHeader: false,
265
- className,
266
- ...props
267
- }
268
- );
269
- });
270
- InlineCode.displayName = "InlineCode";
271
-
272
- exports.CodeSnippet = CodeSnippet;
273
- exports.InlineCode = InlineCode;
274
- exports.codeSnippetVariants = codeSnippetVariants;