@hanzo/ui 5.3.28 → 5.3.30

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 -0
  2. package/dist/3d/button.mjs +273 -0
  3. package/dist/3d/card.js +234 -0
  4. package/dist/3d/card.mjs +207 -0
  5. package/dist/3d/carousel.js +371 -0
  6. package/dist/3d/carousel.mjs +344 -0
  7. package/dist/3d/grid.js +362 -0
  8. package/dist/3d/grid.mjs +337 -0
  9. package/dist/3d/index.js +1518 -0
  10. package/dist/3d/index.mjs +1472 -0
  11. package/dist/3d/marquee.js +352 -0
  12. package/dist/3d/marquee.mjs +327 -0
  13. package/dist/3d/pin.js +46 -0
  14. package/dist/3d/pin.mjs +24 -0
  15. package/dist/accordion.js +80 -0
  16. package/dist/accordion.mjs +55 -0
  17. package/dist/alert-dialog.js +220 -0
  18. package/dist/alert-dialog.mjs +187 -0
  19. package/dist/alert.js +68 -0
  20. package/dist/alert.mjs +64 -0
  21. package/dist/animation/animated-background.js +424 -0
  22. package/dist/animation/animated-background.mjs +418 -0
  23. package/dist/animation/animated-beam.js +119 -0
  24. package/dist/animation/animated-beam.mjs +97 -0
  25. package/dist/animation/animated-cursor.js +275 -0
  26. package/dist/animation/animated-cursor.mjs +270 -0
  27. package/dist/animation/animated-icon.js +357 -0
  28. package/dist/animation/animated-icon.mjs +351 -0
  29. package/dist/animation/animated-list.js +339 -0
  30. package/dist/animation/animated-list.mjs +333 -0
  31. package/dist/animation/animated-number.js +283 -0
  32. package/dist/animation/animated-number.mjs +277 -0
  33. package/dist/animation/animated-testimonials.js +97 -0
  34. package/dist/animation/animated-testimonials.mjs +75 -0
  35. package/dist/animation/animated-tooltip.js +67 -0
  36. package/dist/animation/animated-tooltip.mjs +45 -0
  37. package/dist/animation/apple-cards-carousel.js +308 -0
  38. package/dist/animation/apple-cards-carousel.mjs +285 -0
  39. package/dist/animation/apple-hello-effect.js +60 -0
  40. package/dist/animation/apple-hello-effect.mjs +38 -0
  41. package/dist/animation/index.js +1952 -0
  42. package/dist/animation/index.mjs +1921 -0
  43. package/dist/avatar.js +71 -0
  44. package/dist/avatar.mjs +47 -0
  45. package/dist/badge.js +66 -0
  46. package/dist/badge.mjs +40 -0
  47. package/dist/blocks/index.js +1665 -0
  48. package/dist/blocks/index.mjs +1626 -0
  49. package/dist/breadcrumb.js +107 -0
  50. package/dist/breadcrumb.mjs +99 -0
  51. package/dist/calendar.js +189 -0
  52. package/dist/calendar.mjs +164 -0
  53. package/dist/carousel.js +278 -0
  54. package/dist/carousel.mjs +249 -0
  55. package/dist/checkbox.js +60 -0
  56. package/dist/checkbox.mjs +35 -0
  57. package/dist/code/block.js +226 -0
  58. package/dist/code/block.mjs +203 -0
  59. package/dist/code/compare.js +446 -0
  60. package/dist/code/compare.mjs +423 -0
  61. package/dist/code/diff.js +430 -0
  62. package/dist/code/diff.mjs +407 -0
  63. package/dist/code/editor.js +243 -0
  64. package/dist/code/editor.mjs +218 -0
  65. package/dist/code/explorer.js +291 -0
  66. package/dist/code/explorer.mjs +268 -0
  67. package/dist/code/index.js +2551 -0
  68. package/dist/code/index.mjs +2510 -0
  69. package/dist/code/preview.js +400 -0
  70. package/dist/code/preview.mjs +377 -0
  71. package/dist/code/snippet.js +274 -0
  72. package/dist/code/snippet.mjs +250 -0
  73. package/dist/code/tabs.js +75 -0
  74. package/dist/code/tabs.mjs +53 -0
  75. package/dist/code/terminal.js +437 -0
  76. package/dist/code/terminal.mjs +414 -0
  77. package/dist/collapsible.js +33 -0
  78. package/dist/collapsible.mjs +9 -0
  79. package/dist/command.js +262 -0
  80. package/dist/command.mjs +232 -0
  81. package/dist/context-menu.js +207 -0
  82. package/dist/context-menu.mjs +171 -0
  83. package/dist/device/index.js +3 -0
  84. package/dist/device/index.mjs +2 -0
  85. package/dist/dialog.js +151 -0
  86. package/dist/dialog.mjs +121 -0
  87. package/dist/dock/basic.js +174 -0
  88. package/dist/dock/basic.mjs +151 -0
  89. package/dist/dock/index.js +628 -0
  90. package/dist/dock/index.mjs +601 -0
  91. package/dist/dock/limelight-nav.js +295 -0
  92. package/dist/dock/limelight-nav.mjs +274 -0
  93. package/dist/dock/macos.js +141 -0
  94. package/dist/dock/macos.mjs +118 -0
  95. package/dist/dock/menu.js +70 -0
  96. package/dist/dock/menu.mjs +48 -0
  97. package/dist/dock/message.js +144 -0
  98. package/dist/dock/message.mjs +122 -0
  99. package/dist/drawer.js +115 -0
  100. package/dist/drawer.mjs +103 -0
  101. package/dist/dropdown-menu.js +202 -0
  102. package/dist/dropdown-menu.mjs +166 -0
  103. package/dist/finance/AdvancedChart.js +48 -0
  104. package/dist/finance/AdvancedChart.mjs +46 -0
  105. package/dist/finance/CompanyProfile.js +48 -0
  106. package/dist/finance/CompanyProfile.mjs +46 -0
  107. package/dist/finance/CryptoScreener.js +45 -0
  108. package/dist/finance/CryptoScreener.mjs +43 -0
  109. package/dist/finance/Financials.js +52 -0
  110. package/dist/finance/Financials.mjs +50 -0
  111. package/dist/finance/ForexScreener.js +46 -0
  112. package/dist/finance/ForexScreener.mjs +44 -0
  113. package/dist/finance/MarketOverview.js +104 -0
  114. package/dist/finance/MarketOverview.mjs +102 -0
  115. package/dist/finance/NewsTimeline.js +44 -0
  116. package/dist/finance/NewsTimeline.mjs +42 -0
  117. package/dist/finance/OrderEntry.js +131 -0
  118. package/dist/finance/OrderEntry.mjs +129 -0
  119. package/dist/finance/OrdersHistory.js +64 -0
  120. package/dist/finance/OrdersHistory.mjs +62 -0
  121. package/dist/finance/PositionsList.js +80 -0
  122. package/dist/finance/PositionsList.mjs +78 -0
  123. package/dist/finance/StockScreener.js +46 -0
  124. package/dist/finance/StockScreener.mjs +44 -0
  125. package/dist/finance/SymbolInfo.js +46 -0
  126. package/dist/finance/SymbolInfo.mjs +44 -0
  127. package/dist/finance/TechnicalAnalysis.js +54 -0
  128. package/dist/finance/TechnicalAnalysis.mjs +52 -0
  129. package/dist/finance/TickerTape.js +56 -0
  130. package/dist/finance/TickerTape.mjs +54 -0
  131. package/dist/finance/TradingPanel.js +191 -0
  132. package/dist/finance/TradingPanel.mjs +189 -0
  133. package/dist/finance/index.js +930 -0
  134. package/dist/finance/index.mjs +914 -0
  135. package/dist/form/index.js +155 -0
  136. package/dist/form/index.mjs +125 -0
  137. package/dist/form.js +172 -0
  138. package/dist/form.mjs +142 -0
  139. package/dist/hover-card.js +58 -0
  140. package/dist/hover-card.mjs +34 -0
  141. package/dist/index.js +8467 -0
  142. package/dist/index.mjs +8087 -0
  143. package/dist/input-otp.js +79 -0
  144. package/dist/input-otp.mjs +54 -0
  145. package/dist/lib/utils.js +28 -0
  146. package/dist/lib/utils.mjs +24 -0
  147. package/dist/navigation/index.js +98 -0
  148. package/dist/navigation/index.mjs +79 -0
  149. package/dist/navigation-menu.js +149 -0
  150. package/dist/navigation-menu.mjs +116 -0
  151. package/dist/pattern/grid-pattern.js +333 -0
  152. package/dist/pattern/grid-pattern.mjs +310 -0
  153. package/dist/pattern/index.js +333 -0
  154. package/dist/pattern/index.mjs +310 -0
  155. package/dist/popover.js +63 -0
  156. package/dist/popover.mjs +37 -0
  157. package/dist/primitives/index.js +8467 -0
  158. package/dist/primitives/index.mjs +8087 -0
  159. package/dist/primitives-export.js +8467 -0
  160. package/dist/primitives-export.mjs +8087 -0
  161. package/dist/progress.js +62 -0
  162. package/dist/progress.mjs +37 -0
  163. package/dist/project/gantt.js +65 -0
  164. package/dist/project/gantt.mjs +43 -0
  165. package/dist/project/index.js +636 -0
  166. package/dist/project/index.mjs +611 -0
  167. package/dist/project/kanban.js +597 -0
  168. package/dist/project/kanban.mjs +572 -0
  169. package/dist/project/list.js +35 -0
  170. package/dist/project/list.mjs +12 -0
  171. package/dist/radio-group.js +68 -0
  172. package/dist/radio-group.mjs +45 -0
  173. package/dist/resizable.js +72 -0
  174. package/dist/resizable.mjs +48 -0
  175. package/dist/scroll-area.js +89 -0
  176. package/dist/scroll-area.mjs +66 -0
  177. package/dist/select.js +140 -0
  178. package/dist/select.mjs +111 -0
  179. package/dist/separator.js +59 -0
  180. package/dist/separator.mjs +34 -0
  181. package/dist/sheet.js +148 -0
  182. package/dist/sheet.mjs +117 -0
  183. package/dist/skeleton.js +32 -0
  184. package/dist/skeleton.mjs +27 -0
  185. package/dist/slider.js +99 -0
  186. package/dist/slider.mjs +73 -0
  187. package/dist/sonner.js +34 -0
  188. package/dist/sonner.mjs +29 -0
  189. package/dist/switch.js +62 -0
  190. package/dist/switch.mjs +37 -0
  191. package/dist/table.js +110 -0
  192. package/dist/table.mjs +101 -0
  193. package/dist/tabs.js +82 -0
  194. package/dist/tabs.mjs +57 -0
  195. package/dist/tailwind/index.js +2023 -0
  196. package/dist/tailwind/index.mjs +2011 -0
  197. package/dist/textarea.js +78 -0
  198. package/dist/textarea.mjs +56 -0
  199. package/dist/toggle-group.js +118 -0
  200. package/dist/toggle-group.mjs +93 -0
  201. package/dist/toggle.js +71 -0
  202. package/dist/toggle.mjs +48 -0
  203. package/dist/tooltip.js +67 -0
  204. package/dist/tooltip.mjs +40 -0
  205. package/dist/types/index.js +57 -0
  206. package/dist/types/index.mjs +51 -0
  207. package/dist/ui/announcement.js +129 -0
  208. package/dist/ui/announcement.mjs +107 -0
  209. package/dist/ui/avatar-group.js +88 -0
  210. package/dist/ui/avatar-group.mjs +65 -0
  211. package/dist/ui/banner.js +85 -0
  212. package/dist/ui/banner.mjs +62 -0
  213. package/dist/ui/cursor.js +78 -0
  214. package/dist/ui/cursor.mjs +56 -0
  215. package/dist/ui/index.js +475 -0
  216. package/dist/ui/index.mjs +442 -0
  217. package/dist/ui/marquee.js +74 -0
  218. package/dist/ui/marquee.mjs +52 -0
  219. package/dist/ui/pill.js +85 -0
  220. package/dist/ui/pill.mjs +62 -0
  221. package/dist/ui/spinner.js +28 -0
  222. package/dist/ui/spinner.mjs +26 -0
  223. package/dist/ui/tags.js +101 -0
  224. package/dist/ui/tags.mjs +79 -0
  225. package/dist/ui/ticker.js +73 -0
  226. package/dist/ui/ticker.mjs +51 -0
  227. package/dist/util/index.js +463 -0
  228. package/dist/util/index.mjs +404 -0
  229. package/package.json +1 -1
@@ -0,0 +1,407 @@
1
+ "use client";
2
+ import * as React from 'react';
3
+ import { cva } from 'class-variance-authority';
4
+ import { GitCompare, Plus, Minus, Square, SplitSquareHorizontal, Check, Copy } from 'lucide-react';
5
+ import { codeToHtml } from 'shiki';
6
+ import { cn } from '@hanzo/ui/lib/utils';
7
+ import { Badge } from '@hanzo/ui/badge';
8
+ import { Button } from '@hanzo/ui/button';
9
+ import { Skeleton } from '@hanzo/ui/skeleton';
10
+ import { ToggleGroup, ToggleGroupItem } from '@hanzo/ui/toggle-group';
11
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
12
+
13
+ var __defProp = Object.defineProperty;
14
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
+ var codeDiffVariants = cva(
16
+ "relative overflow-hidden rounded-lg border bg-muted/50",
17
+ {
18
+ variants: {
19
+ theme: {
20
+ dark: "bg-slate-950 border-slate-800",
21
+ light: "bg-slate-50 border-slate-200",
22
+ github: "bg-white border-slate-200",
23
+ "github-dark": "bg-slate-900 border-slate-700"
24
+ },
25
+ size: {
26
+ sm: "text-xs",
27
+ default: "text-sm",
28
+ lg: "text-base"
29
+ }
30
+ },
31
+ defaultVariants: {
32
+ theme: "dark",
33
+ size: "default"
34
+ }
35
+ }
36
+ );
37
+ var DiffLine = React.memo(
38
+ ({
39
+ change,
40
+ showLineNumbers,
41
+ isUnified = false,
42
+ highlightedContent
43
+ }) => {
44
+ const getLineClasses = /* @__PURE__ */ __name(() => {
45
+ const base = "group relative flex min-h-[1.5rem] items-center py-0.5";
46
+ if (isUnified) {
47
+ switch (change.type) {
48
+ case "add":
49
+ return cn(base, "bg-green-500/10 border-l-2 border-l-green-500");
50
+ case "remove":
51
+ return cn(base, "bg-red-500/10 border-l-2 border-l-red-500");
52
+ default:
53
+ return cn(base, "hover:bg-muted/50");
54
+ }
55
+ }
56
+ return cn(base, "hover:bg-muted/50");
57
+ }, "getLineClasses");
58
+ const getLinePrefix = /* @__PURE__ */ __name(() => {
59
+ if (!isUnified) return null;
60
+ switch (change.type) {
61
+ case "add":
62
+ return /* @__PURE__ */ jsx(Plus, { className: "h-3 w-3 text-green-500 mr-2 flex-shrink-0" });
63
+ case "remove":
64
+ return /* @__PURE__ */ jsx(Minus, { className: "h-3 w-3 text-red-500 mr-2 flex-shrink-0" });
65
+ default:
66
+ return /* @__PURE__ */ jsx("span", { className: "w-3 mr-2 flex-shrink-0" });
67
+ }
68
+ }, "getLinePrefix");
69
+ return /* @__PURE__ */ jsx("div", { className: getLineClasses(), children: /* @__PURE__ */ jsxs("div", { className: "flex items-center px-4 w-full", children: [
70
+ showLineNumbers && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 mr-4", children: !isUnified ? /* @__PURE__ */ jsxs(Fragment, { children: [
71
+ /* @__PURE__ */ jsx("span", { className: "inline-block w-8 select-none text-right text-xs text-muted-foreground", children: change.oldLineNumber || "" }),
72
+ /* @__PURE__ */ jsx("span", { className: "inline-block w-8 select-none text-right text-xs text-muted-foreground", children: change.newLineNumber || "" })
73
+ ] }) : /* @__PURE__ */ jsx("span", { className: "inline-block w-8 select-none text-right text-xs text-muted-foreground", children: change.lineNumber }) }),
74
+ getLinePrefix(),
75
+ /* @__PURE__ */ jsx(
76
+ "div",
77
+ {
78
+ className: "flex-1 overflow-x-auto font-mono",
79
+ dangerouslySetInnerHTML: {
80
+ __html: highlightedContent || change.content
81
+ }
82
+ }
83
+ )
84
+ ] }) });
85
+ }
86
+ );
87
+ DiffLine.displayName = "DiffLine";
88
+ function generateDiff(oldCode, newCode) {
89
+ const oldLines = oldCode.split("\n");
90
+ const newLines = newCode.split("\n");
91
+ const changes = [];
92
+ let oldIndex = 0;
93
+ let newIndex = 0;
94
+ let lineNumber = 1;
95
+ while (oldIndex < oldLines.length || newIndex < newLines.length) {
96
+ const oldLine = oldLines[oldIndex];
97
+ const newLine = newLines[newIndex];
98
+ if (oldIndex >= oldLines.length) {
99
+ changes.push({
100
+ type: "add",
101
+ lineNumber: lineNumber++,
102
+ content: newLine,
103
+ newLineNumber: newIndex + 1
104
+ });
105
+ newIndex++;
106
+ } else if (newIndex >= newLines.length) {
107
+ changes.push({
108
+ type: "remove",
109
+ lineNumber: lineNumber++,
110
+ content: oldLine,
111
+ oldLineNumber: oldIndex + 1
112
+ });
113
+ oldIndex++;
114
+ } else if (oldLine === newLine) {
115
+ changes.push({
116
+ type: "unchanged",
117
+ lineNumber: lineNumber++,
118
+ content: oldLine,
119
+ oldLineNumber: oldIndex + 1,
120
+ newLineNumber: newIndex + 1
121
+ });
122
+ oldIndex++;
123
+ newIndex++;
124
+ } else {
125
+ changes.push({
126
+ type: "remove",
127
+ lineNumber: lineNumber++,
128
+ content: oldLine,
129
+ oldLineNumber: oldIndex + 1
130
+ });
131
+ changes.push({
132
+ type: "add",
133
+ lineNumber: lineNumber++,
134
+ content: newLine,
135
+ newLineNumber: newIndex + 1
136
+ });
137
+ oldIndex++;
138
+ newIndex++;
139
+ }
140
+ }
141
+ return changes;
142
+ }
143
+ __name(generateDiff, "generateDiff");
144
+ var CodeDiff = React.forwardRef(
145
+ ({
146
+ className,
147
+ theme,
148
+ size,
149
+ oldCode,
150
+ newCode,
151
+ language = "text",
152
+ filename,
153
+ oldFilename,
154
+ newFilename,
155
+ showLineNumbers = true,
156
+ showCopyButton = true,
157
+ maxHeight = "500px",
158
+ defaultView = "unified",
159
+ collapseUnchanged = false,
160
+ contextLines = 3,
161
+ ...props
162
+ }, ref) => {
163
+ const [view, setView] = React.useState(defaultView);
164
+ const [copied, setCopied] = React.useState(false);
165
+ const [isLoading, setIsLoading] = React.useState(true);
166
+ const [highlightedOldCode, setHighlightedOldCode] = React.useState("");
167
+ const [highlightedNewCode, setHighlightedNewCode] = React.useState("");
168
+ const [changes, setChanges] = React.useState([]);
169
+ const themeMap = {
170
+ dark: "github-dark",
171
+ light: "github-light",
172
+ github: "github-light",
173
+ "github-dark": "github-dark"
174
+ };
175
+ React.useEffect(() => {
176
+ const highlightCode = /* @__PURE__ */ __name(async () => {
177
+ setIsLoading(true);
178
+ try {
179
+ const [oldHighlighted, newHighlighted] = await Promise.all([
180
+ codeToHtml(oldCode, {
181
+ lang: language,
182
+ theme: themeMap[theme || "dark"]
183
+ }),
184
+ codeToHtml(newCode, {
185
+ lang: language,
186
+ theme: themeMap[theme || "dark"]
187
+ })
188
+ ]);
189
+ const extractContent = /* @__PURE__ */ __name((html) => {
190
+ const tempDiv = document.createElement("div");
191
+ tempDiv.innerHTML = html;
192
+ const codeElement = tempDiv.querySelector("code");
193
+ return codeElement?.innerHTML || html;
194
+ }, "extractContent");
195
+ setHighlightedOldCode(extractContent(oldHighlighted));
196
+ setHighlightedNewCode(extractContent(newHighlighted));
197
+ const diffChanges = generateDiff(oldCode, newCode);
198
+ setChanges(diffChanges);
199
+ } catch (error) {
200
+ console.error("Failed to highlight code:", error);
201
+ setHighlightedOldCode(oldCode);
202
+ setHighlightedNewCode(newCode);
203
+ setChanges(generateDiff(oldCode, newCode));
204
+ } finally {
205
+ setIsLoading(false);
206
+ }
207
+ }, "highlightCode");
208
+ highlightCode();
209
+ }, [oldCode, newCode, language, theme]);
210
+ const copyToClipboard = React.useCallback(async () => {
211
+ try {
212
+ const diffText = view === "unified" ? changes.map((change) => {
213
+ const prefix = change.type === "add" ? "+" : change.type === "remove" ? "-" : " ";
214
+ return `${prefix}${change.content}`;
215
+ }).join("\n") : `--- ${oldFilename || "old"}
216
+ +++ ${newFilename || "new"}
217
+ ${oldCode}
218
+
219
+ ${newCode}`;
220
+ await navigator.clipboard.writeText(diffText);
221
+ setCopied(true);
222
+ setTimeout(() => setCopied(false), 2e3);
223
+ } catch (error) {
224
+ console.error("Failed to copy diff:", error);
225
+ }
226
+ }, [changes, view, oldCode, newCode, oldFilename, newFilename]);
227
+ const filteredChanges = React.useMemo(() => {
228
+ if (!collapseUnchanged) return changes;
229
+ const result = [];
230
+ let i = 0;
231
+ while (i < changes.length) {
232
+ const change = changes[i];
233
+ if (change.type !== "unchanged") {
234
+ result.push(change);
235
+ i++;
236
+ continue;
237
+ }
238
+ const unchangedStart = i;
239
+ while (i < changes.length && changes[i].type === "unchanged") {
240
+ i++;
241
+ }
242
+ const unchangedCount = i - unchangedStart;
243
+ if (unchangedCount <= contextLines * 2) {
244
+ for (let j = unchangedStart; j < i; j++) {
245
+ result.push(changes[j]);
246
+ }
247
+ } else {
248
+ for (let j = unchangedStart; j < unchangedStart + contextLines; j++) {
249
+ result.push(changes[j]);
250
+ }
251
+ result.push({
252
+ type: "unchanged",
253
+ lineNumber: -1,
254
+ content: `... ${unchangedCount - contextLines * 2} unchanged lines ...`
255
+ });
256
+ for (let j = i - contextLines; j < i; j++) {
257
+ result.push(changes[j]);
258
+ }
259
+ }
260
+ }
261
+ return result;
262
+ }, [changes, collapseUnchanged, contextLines]);
263
+ const stats = React.useMemo(() => {
264
+ const additions = changes.filter((c) => c.type === "add").length;
265
+ const deletions = changes.filter((c) => c.type === "remove").length;
266
+ return { additions, deletions };
267
+ }, [changes]);
268
+ const renderUnifiedView = /* @__PURE__ */ __name(() => {
269
+ const oldLines = highlightedOldCode.split("\n");
270
+ const newLines = highlightedNewCode.split("\n");
271
+ return /* @__PURE__ */ jsx("div", { className: "font-mono", children: filteredChanges.map((change, index) => {
272
+ if (change.lineNumber === -1) {
273
+ return /* @__PURE__ */ jsx(
274
+ "div",
275
+ {
276
+ className: "flex items-center justify-center py-2 text-muted-foreground bg-muted/30",
277
+ children: /* @__PURE__ */ jsx("span", { className: "text-xs", children: change.content })
278
+ },
279
+ index
280
+ );
281
+ }
282
+ let highlightedContent = change.content;
283
+ if (change.type === "add" && change.newLineNumber) {
284
+ highlightedContent = newLines[change.newLineNumber - 1] || change.content;
285
+ } else if (change.type === "remove" && change.oldLineNumber) {
286
+ highlightedContent = oldLines[change.oldLineNumber - 1] || change.content;
287
+ } else if (change.type === "unchanged" && change.oldLineNumber) {
288
+ highlightedContent = oldLines[change.oldLineNumber - 1] || change.content;
289
+ }
290
+ return /* @__PURE__ */ jsx(
291
+ DiffLine,
292
+ {
293
+ change,
294
+ showLineNumbers,
295
+ isUnified: true,
296
+ highlightedContent
297
+ },
298
+ index
299
+ );
300
+ }) });
301
+ }, "renderUnifiedView");
302
+ const renderSplitView = /* @__PURE__ */ __name(() => {
303
+ const oldLines = highlightedOldCode.split("\n");
304
+ const newLines = highlightedNewCode.split("\n");
305
+ return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-0", children: [
306
+ /* @__PURE__ */ jsxs("div", { className: "border-r", children: [
307
+ /* @__PURE__ */ jsx("div", { className: "border-b px-4 py-2 bg-red-500/10", children: /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-red-600 dark:text-red-400", children: oldFilename || filename || "Old" }) }),
308
+ /* @__PURE__ */ jsx("div", { className: "font-mono", children: oldLines.map((line, index) => /* @__PURE__ */ jsx(
309
+ DiffLine,
310
+ {
311
+ change: {
312
+ type: "remove",
313
+ lineNumber: index + 1,
314
+ content: line,
315
+ oldLineNumber: index + 1
316
+ },
317
+ showLineNumbers,
318
+ highlightedContent: line
319
+ },
320
+ `old-${index}`
321
+ )) })
322
+ ] }),
323
+ /* @__PURE__ */ jsxs("div", { children: [
324
+ /* @__PURE__ */ jsx("div", { className: "border-b px-4 py-2 bg-green-500/10", children: /* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-green-600 dark:text-green-400", children: newFilename || filename || "New" }) }),
325
+ /* @__PURE__ */ jsx("div", { className: "font-mono", children: newLines.map((line, index) => /* @__PURE__ */ jsx(
326
+ DiffLine,
327
+ {
328
+ change: {
329
+ type: "add",
330
+ lineNumber: index + 1,
331
+ content: line,
332
+ newLineNumber: index + 1
333
+ },
334
+ showLineNumbers,
335
+ highlightedContent: line
336
+ },
337
+ `new-${index}`
338
+ )) })
339
+ ] })
340
+ ] });
341
+ }, "renderSplitView");
342
+ return /* @__PURE__ */ jsxs(
343
+ "div",
344
+ {
345
+ ref,
346
+ className: cn(codeDiffVariants({ theme, size, className })),
347
+ ...props,
348
+ children: [
349
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b px-4 py-2", children: [
350
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
351
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
352
+ /* @__PURE__ */ jsx(GitCompare, { className: "h-4 w-4 text-muted-foreground" }),
353
+ filename && /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: filename }),
354
+ language && /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: language })
355
+ ] }),
356
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
357
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
358
+ /* @__PURE__ */ jsx(Plus, { className: "h-3 w-3 text-green-500" }),
359
+ stats.additions
360
+ ] }),
361
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
362
+ /* @__PURE__ */ jsx(Minus, { className: "h-3 w-3 text-red-500" }),
363
+ stats.deletions
364
+ ] })
365
+ ] })
366
+ ] }),
367
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
368
+ /* @__PURE__ */ jsxs(
369
+ ToggleGroup,
370
+ {
371
+ type: "single",
372
+ value: view,
373
+ onValueChange: (value) => value && setView(value),
374
+ size: "sm",
375
+ children: [
376
+ /* @__PURE__ */ jsx(ToggleGroupItem, { value: "unified", "aria-label": "Unified view", children: /* @__PURE__ */ jsx(Square, { className: "h-3 w-3" }) }),
377
+ /* @__PURE__ */ jsx(ToggleGroupItem, { value: "split", "aria-label": "Split view", children: /* @__PURE__ */ jsx(SplitSquareHorizontal, { className: "h-3 w-3" }) })
378
+ ]
379
+ }
380
+ ),
381
+ showCopyButton && /* @__PURE__ */ jsxs(
382
+ Button,
383
+ {
384
+ variant: "ghost",
385
+ size: "sm",
386
+ onClick: copyToClipboard,
387
+ className: "h-8 w-8 p-0",
388
+ children: [
389
+ copied ? /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5 text-green-500" }) : /* @__PURE__ */ jsx(Copy, { className: "h-3.5 w-3.5" }),
390
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: copied ? "Copied" : "Copy diff" })
391
+ ]
392
+ }
393
+ )
394
+ ] })
395
+ ] }),
396
+ /* @__PURE__ */ jsx("div", { className: "overflow-auto", style: { maxHeight }, children: isLoading ? /* @__PURE__ */ jsx("div", { className: "p-4 space-y-2", children: Array.from({ length: 10 }).map((_, i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
397
+ showLineNumbers && /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-8" }),
398
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 flex-1" })
399
+ ] }, i)) }) : view === "unified" ? renderUnifiedView() : renderSplitView() })
400
+ ]
401
+ }
402
+ );
403
+ }
404
+ );
405
+ CodeDiff.displayName = "CodeDiff";
406
+
407
+ export { CodeDiff, codeDiffVariants };
@@ -0,0 +1,243 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var React = require('react');
5
+ var Editor = require('@monaco-editor/react');
6
+ var lucideReact = require('lucide-react');
7
+ var nextThemes = require('next-themes');
8
+ var utils = require('@hanzo/ui/lib/utils');
9
+ var button = require('@hanzo/ui/button');
10
+ var dropdownMenu = require('@hanzo/ui/dropdown-menu');
11
+ var jsxRuntime = require('react/jsx-runtime');
12
+
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
+
15
+ function _interopNamespace(e) {
16
+ if (e && e.__esModule) return e;
17
+ var n = Object.create(null);
18
+ if (e) {
19
+ Object.keys(e).forEach(function (k) {
20
+ if (k !== 'default') {
21
+ var d = Object.getOwnPropertyDescriptor(e, k);
22
+ Object.defineProperty(n, k, d.get ? d : {
23
+ enumerable: true,
24
+ get: function () { return e[k]; }
25
+ });
26
+ }
27
+ });
28
+ }
29
+ n.default = e;
30
+ return Object.freeze(n);
31
+ }
32
+
33
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
34
+ var Editor__default = /*#__PURE__*/_interopDefault(Editor);
35
+
36
+ var defaultLanguages = [
37
+ "javascript",
38
+ "typescript",
39
+ "python",
40
+ "java",
41
+ "csharp",
42
+ "cpp",
43
+ "c",
44
+ "go",
45
+ "rust",
46
+ "ruby",
47
+ "php",
48
+ "swift",
49
+ "kotlin",
50
+ "dart",
51
+ "html",
52
+ "css",
53
+ "scss",
54
+ "json",
55
+ "xml",
56
+ "yaml",
57
+ "sql",
58
+ "markdown",
59
+ "shell",
60
+ "plaintext"
61
+ ];
62
+ var languageDisplayNames = {
63
+ javascript: "JavaScript",
64
+ typescript: "TypeScript",
65
+ python: "Python",
66
+ java: "Java",
67
+ csharp: "C#",
68
+ cpp: "C++",
69
+ c: "C",
70
+ go: "Go",
71
+ rust: "Rust",
72
+ ruby: "Ruby",
73
+ php: "PHP",
74
+ swift: "Swift",
75
+ kotlin: "Kotlin",
76
+ dart: "Dart",
77
+ html: "HTML",
78
+ css: "CSS",
79
+ scss: "SCSS",
80
+ json: "JSON",
81
+ xml: "XML",
82
+ yaml: "YAML",
83
+ sql: "SQL",
84
+ markdown: "Markdown",
85
+ shell: "Shell",
86
+ plaintext: "Plain Text"
87
+ };
88
+ var CodeEditor = React__namespace.forwardRef(
89
+ ({
90
+ value,
91
+ defaultValue = "",
92
+ language = "javascript",
93
+ height = "400px",
94
+ theme: themeProp = "auto",
95
+ onChange,
96
+ onMount,
97
+ readOnly = false,
98
+ lineNumbers = true,
99
+ minimap = false,
100
+ wordWrap = "on",
101
+ fontSize = 14,
102
+ className,
103
+ showCopyButton = true,
104
+ showLanguageSelector = true,
105
+ availableLanguages = defaultLanguages
106
+ }, ref) => {
107
+ const { theme: systemTheme } = nextThemes.useTheme();
108
+ const [selectedLanguage, setSelectedLanguage] = React__namespace.useState(language);
109
+ const [copied, setCopied] = React__namespace.useState(false);
110
+ const [editorValue, setEditorValue] = React__namespace.useState(value || defaultValue);
111
+ React__namespace.useEffect(() => {
112
+ if (value !== void 0) {
113
+ setEditorValue(value);
114
+ }
115
+ }, [value]);
116
+ const handleCopy = React__namespace.useCallback(async () => {
117
+ try {
118
+ await navigator.clipboard.writeText(editorValue);
119
+ setCopied(true);
120
+ setTimeout(() => setCopied(false), 2e3);
121
+ } catch (err) {
122
+ console.error("Failed to copy:", err);
123
+ }
124
+ }, [editorValue]);
125
+ const handleChange = React__namespace.useCallback(
126
+ (newValue, ev) => {
127
+ setEditorValue(newValue || "");
128
+ if (onChange) {
129
+ onChange(newValue, ev);
130
+ }
131
+ },
132
+ [onChange]
133
+ );
134
+ const resolveTheme = React__namespace.useMemo(() => {
135
+ if (themeProp === "auto") {
136
+ return systemTheme === "dark" ? "vs-dark" : "light";
137
+ }
138
+ return themeProp === "dark" ? "vs-dark" : "light";
139
+ }, [themeProp, systemTheme]);
140
+ return /* @__PURE__ */ jsxRuntime.jsxs(
141
+ "div",
142
+ {
143
+ ref,
144
+ className: utils.cn(
145
+ "relative overflow-hidden rounded-md border bg-background",
146
+ className
147
+ ),
148
+ children: [
149
+ (showLanguageSelector || showCopyButton) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border-b bg-muted/50 px-3 py-2", children: [
150
+ showLanguageSelector && /* @__PURE__ */ jsxRuntime.jsxs(dropdownMenu.DropdownMenu, { children: [
151
+ /* @__PURE__ */ jsxRuntime.jsx(dropdownMenu.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
152
+ button.Button,
153
+ {
154
+ variant: "ghost",
155
+ size: "sm",
156
+ className: "h-8 gap-1 px-2 text-xs font-mono",
157
+ children: [
158
+ languageDisplayNames[selectedLanguage] || selectedLanguage,
159
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-3 w-3" })
160
+ ]
161
+ }
162
+ ) }),
163
+ /* @__PURE__ */ jsxRuntime.jsx(
164
+ dropdownMenu.DropdownMenuContent,
165
+ {
166
+ align: "start",
167
+ className: "max-h-80 overflow-auto",
168
+ children: availableLanguages.map((lang) => /* @__PURE__ */ jsxRuntime.jsx(
169
+ dropdownMenu.DropdownMenuItem,
170
+ {
171
+ onClick: () => setSelectedLanguage(lang),
172
+ className: "font-mono text-xs",
173
+ children: languageDisplayNames[lang] || lang
174
+ },
175
+ lang
176
+ ))
177
+ }
178
+ )
179
+ ] }),
180
+ showCopyButton && /* @__PURE__ */ jsxRuntime.jsx(
181
+ button.Button,
182
+ {
183
+ variant: "ghost",
184
+ size: "sm",
185
+ className: "h-8 gap-1.5 px-2 text-xs",
186
+ onClick: handleCopy,
187
+ disabled: !editorValue,
188
+ children: copied ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
189
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3 w-3" }),
190
+ "Copied!"
191
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
192
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { className: "h-3 w-3" }),
193
+ "Copy"
194
+ ] })
195
+ }
196
+ )
197
+ ] }),
198
+ /* @__PURE__ */ jsxRuntime.jsx(
199
+ Editor__default.default,
200
+ {
201
+ height,
202
+ defaultLanguage: language,
203
+ language: selectedLanguage,
204
+ value: editorValue,
205
+ defaultValue,
206
+ theme: resolveTheme,
207
+ onChange: handleChange,
208
+ onMount,
209
+ options: {
210
+ readOnly,
211
+ lineNumbers: lineNumbers ? "on" : "off",
212
+ minimap: {
213
+ enabled: minimap
214
+ },
215
+ wordWrap,
216
+ fontSize,
217
+ scrollBeyondLastLine: false,
218
+ automaticLayout: true,
219
+ tabSize: 2,
220
+ insertSpaces: true,
221
+ formatOnPaste: true,
222
+ formatOnType: true,
223
+ scrollbar: {
224
+ vertical: "auto",
225
+ horizontal: "auto",
226
+ verticalScrollbarSize: 10,
227
+ horizontalScrollbarSize: 10
228
+ },
229
+ padding: {
230
+ top: 16,
231
+ bottom: 16
232
+ }
233
+ }
234
+ }
235
+ )
236
+ ]
237
+ }
238
+ );
239
+ }
240
+ );
241
+ CodeEditor.displayName = "CodeEditor";
242
+
243
+ exports.CodeEditor = CodeEditor;