@copilotkit/react-ui 0.15.0-alpha.1 → 0.15.0-alpha.2

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 (315) hide show
  1. package/.turbo/turbo-build.log +192 -288
  2. package/CHANGELOG.md +16 -1
  3. package/dist/{chunk-ZVAH2Z2W.mjs → chunk-3M4HWSE7.mjs} +3 -3
  4. package/dist/chunk-3M4HWSE7.mjs.map +1 -0
  5. package/dist/{chunk-Y2RUG4B3.mjs → chunk-5O2MCJZ2.mjs} +2 -2
  6. package/dist/chunk-5O2MCJZ2.mjs.map +1 -0
  7. package/dist/{chunk-X3Z2EVFV.mjs → chunk-CKJXXQ2W.mjs} +5 -5
  8. package/dist/chunk-CKJXXQ2W.mjs.map +1 -0
  9. package/dist/{chunk-NXWVWC33.mjs → chunk-DPRH4HX3.mjs} +11 -24
  10. package/dist/chunk-DPRH4HX3.mjs.map +1 -0
  11. package/dist/{chunk-UIRFLYXI.mjs → chunk-GWGHQNRI.mjs} +14 -13
  12. package/dist/chunk-GWGHQNRI.mjs.map +1 -0
  13. package/dist/chunk-JD7BAH7U.mjs +3 -0
  14. package/dist/{chunk-X4T6ZUVM.mjs → chunk-KBGIPFXA.mjs} +5 -5
  15. package/dist/chunk-KBGIPFXA.mjs.map +1 -0
  16. package/dist/{chunk-DN3OI5WF.mjs → chunk-NNVWLSYK.mjs} +9 -9
  17. package/dist/chunk-NNVWLSYK.mjs.map +1 -0
  18. package/dist/{chunk-QFASQEFJ.mjs → chunk-NYLOXKYT.mjs} +2 -2
  19. package/dist/chunk-NYLOXKYT.mjs.map +1 -0
  20. package/dist/{chunk-6H3Y2XEI.mjs → chunk-OF66AL5Z.mjs} +1 -1
  21. package/dist/chunk-OF66AL5Z.mjs.map +1 -0
  22. package/dist/{chunk-DPUPEOGG.mjs → chunk-UWPFPWAW.mjs} +2 -2
  23. package/dist/chunk-UWPFPWAW.mjs.map +1 -0
  24. package/dist/{chunk-GPEJCUWA.mjs → chunk-Z34F3WLK.mjs} +2 -2
  25. package/dist/chunk-Z34F3WLK.mjs.map +1 -0
  26. package/dist/components/chat/Button.d.ts +2 -3
  27. package/dist/components/chat/Button.js +38 -0
  28. package/dist/components/chat/Button.js.map +1 -0
  29. package/dist/components/chat/Button.mjs +2 -2
  30. package/dist/components/chat/Chat.d.ts +15 -14
  31. package/dist/components/chat/Chat.js +800 -0
  32. package/dist/components/chat/Chat.js.map +1 -0
  33. package/dist/components/chat/Chat.mjs +9 -9
  34. package/dist/components/chat/ChatContext.d.ts +21 -21
  35. package/dist/components/chat/ChatContext.js +220 -0
  36. package/dist/components/chat/ChatContext.js.map +1 -0
  37. package/dist/components/chat/ChatContext.mjs +1 -1
  38. package/dist/components/chat/CodeBlock.js +221 -0
  39. package/dist/components/chat/CodeBlock.js.map +1 -0
  40. package/dist/components/chat/CodeBlock.mjs +1 -1
  41. package/dist/components/chat/Header.d.ts +2 -3
  42. package/dist/components/chat/Header.js +31 -0
  43. package/dist/components/chat/Header.js.map +1 -0
  44. package/dist/components/chat/Header.mjs +2 -2
  45. package/dist/components/chat/Icons.d.ts +4 -4
  46. package/dist/components/chat/Icons.js +233 -0
  47. package/dist/components/chat/Icons.js.map +1 -0
  48. package/dist/components/chat/Input.d.ts +2 -3
  49. package/dist/components/chat/Input.js +111 -0
  50. package/dist/components/chat/Input.js.map +1 -0
  51. package/dist/components/chat/Input.mjs +2 -2
  52. package/dist/components/chat/Markdown.d.ts +1 -3
  53. package/dist/components/chat/Markdown.js +269 -0
  54. package/dist/components/chat/Markdown.js.map +1 -0
  55. package/dist/components/chat/Markdown.mjs +2 -2
  56. package/dist/components/chat/Messages.d.ts +2 -3
  57. package/dist/components/chat/Messages.js +331 -0
  58. package/dist/components/chat/Messages.js.map +1 -0
  59. package/dist/components/chat/Messages.mjs +4 -4
  60. package/dist/components/chat/Popup.d.ts +5 -4
  61. package/dist/components/chat/Popup.js +806 -0
  62. package/dist/components/chat/Popup.js.map +1 -0
  63. package/dist/components/chat/Popup.mjs +10 -10
  64. package/dist/components/chat/Response.d.ts +2 -3
  65. package/dist/components/chat/Response.js +31 -0
  66. package/dist/components/chat/Response.js.map +1 -0
  67. package/dist/components/chat/Response.mjs +2 -2
  68. package/dist/components/chat/Sidebar.d.ts +7 -6
  69. package/dist/components/chat/Sidebar.js +817 -0
  70. package/dist/components/chat/Sidebar.js.map +1 -0
  71. package/dist/components/chat/Sidebar.mjs +10 -10
  72. package/dist/components/chat/Textarea.d.ts +4 -4
  73. package/dist/components/chat/Textarea.js +55 -0
  74. package/dist/components/chat/Textarea.js.map +1 -0
  75. package/dist/components/chat/Window.d.ts +1 -1
  76. package/dist/components/chat/Window.js +116 -0
  77. package/dist/components/chat/Window.js.map +1 -0
  78. package/dist/components/chat/index.d.ts +5 -4
  79. package/dist/components/chat/index.js +824 -0
  80. package/dist/components/chat/index.js.map +1 -0
  81. package/dist/components/chat/index.mjs +11 -11
  82. package/dist/components/chat/props.d.ts +1 -1
  83. package/dist/components/chat/props.js +4 -0
  84. package/dist/components/index.d.ts +5 -11
  85. package/dist/components/index.js +824 -0
  86. package/dist/components/index.js.map +1 -0
  87. package/dist/components/index.mjs +12 -33
  88. package/dist/context/index.js +4 -0
  89. package/dist/hooks/index.js +4 -0
  90. package/dist/hooks/use-copy-to-clipboard.js +47 -0
  91. package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
  92. package/dist/index.css +112 -916
  93. package/dist/index.css.map +1 -1
  94. package/dist/index.d.ts +5 -11
  95. package/dist/index.js +824 -0
  96. package/dist/index.js.map +1 -0
  97. package/dist/index.mjs +13 -34
  98. package/dist/lib/utils.js +64 -0
  99. package/dist/lib/utils.js.map +1 -0
  100. package/dist/lib/utils.mjs +38 -2
  101. package/dist/lib/utils.mjs.map +1 -1
  102. package/dist/lib/utils.test.js +10 -0
  103. package/dist/lib/utils.test.js.map +1 -0
  104. package/dist/types/index.js +4 -0
  105. package/dist/types/types.d.ts +1 -1
  106. package/dist/types/types.js +4 -0
  107. package/package.json +8 -7
  108. package/src/components/chat/Button.tsx +1 -2
  109. package/src/components/chat/Chat.tsx +7 -7
  110. package/src/components/chat/ChatContext.tsx +10 -10
  111. package/src/components/chat/CodeBlock.tsx +12 -36
  112. package/src/components/chat/Header.tsx +1 -2
  113. package/src/components/chat/Input.tsx +1 -1
  114. package/src/components/chat/Markdown.tsx +17 -11
  115. package/src/components/chat/Messages.tsx +2 -2
  116. package/src/components/chat/Popup.tsx +3 -4
  117. package/src/components/chat/Response.tsx +1 -2
  118. package/src/components/chat/Sidebar.tsx +4 -4
  119. package/src/components/chat/index.tsx +2 -2
  120. package/src/components/chat/props.ts +1 -1
  121. package/src/components/index.ts +0 -8
  122. package/src/css/animations.css +6 -0
  123. package/src/css/markdown.css +123 -0
  124. package/src/styles.css +1 -0
  125. package/src/types/types.ts +1 -1
  126. package/tsup.config.ts +1 -2
  127. package/dist/chunk-2KAF7NKC.mjs +0 -484
  128. package/dist/chunk-2KAF7NKC.mjs.map +0 -1
  129. package/dist/chunk-5KEDV5VC.mjs +0 -27
  130. package/dist/chunk-5KEDV5VC.mjs.map +0 -1
  131. package/dist/chunk-6H3Y2XEI.mjs.map +0 -1
  132. package/dist/chunk-6LAZQHEB.mjs +0 -129
  133. package/dist/chunk-6LAZQHEB.mjs.map +0 -1
  134. package/dist/chunk-C34L4AWW.mjs +0 -39
  135. package/dist/chunk-C34L4AWW.mjs.map +0 -1
  136. package/dist/chunk-CF3BK4OX.mjs +0 -53
  137. package/dist/chunk-CF3BK4OX.mjs.map +0 -1
  138. package/dist/chunk-CNQX2VY3.mjs +0 -66
  139. package/dist/chunk-CNQX2VY3.mjs.map +0 -1
  140. package/dist/chunk-DN3OI5WF.mjs.map +0 -1
  141. package/dist/chunk-DPUPEOGG.mjs.map +0 -1
  142. package/dist/chunk-FZRTAML3.mjs +0 -3
  143. package/dist/chunk-GCOPYGHH.mjs +0 -27
  144. package/dist/chunk-GCOPYGHH.mjs.map +0 -1
  145. package/dist/chunk-GPEJCUWA.mjs.map +0 -1
  146. package/dist/chunk-IJLMKBSZ.mjs +0 -25
  147. package/dist/chunk-IJLMKBSZ.mjs.map +0 -1
  148. package/dist/chunk-INCNMGJ7.mjs +0 -72
  149. package/dist/chunk-INCNMGJ7.mjs.map +0 -1
  150. package/dist/chunk-M3CZWJI3.mjs +0 -44
  151. package/dist/chunk-M3CZWJI3.mjs.map +0 -1
  152. package/dist/chunk-MC6KTH4X.mjs +0 -12
  153. package/dist/chunk-MC6KTH4X.mjs.map +0 -1
  154. package/dist/chunk-NXWVWC33.mjs.map +0 -1
  155. package/dist/chunk-OHWEJUCS.mjs +0 -18
  156. package/dist/chunk-OHWEJUCS.mjs.map +0 -1
  157. package/dist/chunk-OOBQC5H6.mjs +0 -34
  158. package/dist/chunk-OOBQC5H6.mjs.map +0 -1
  159. package/dist/chunk-Q6YO7LDK.mjs +0 -40
  160. package/dist/chunk-Q6YO7LDK.mjs.map +0 -1
  161. package/dist/chunk-QFASQEFJ.mjs.map +0 -1
  162. package/dist/chunk-RPTRCFSO.mjs +0 -42
  163. package/dist/chunk-RPTRCFSO.mjs.map +0 -1
  164. package/dist/chunk-SEH5PQVW.mjs +0 -52
  165. package/dist/chunk-SEH5PQVW.mjs.map +0 -1
  166. package/dist/chunk-SHOTWRKC.mjs +0 -18
  167. package/dist/chunk-SHOTWRKC.mjs.map +0 -1
  168. package/dist/chunk-SRBUGQTM.mjs +0 -109
  169. package/dist/chunk-SRBUGQTM.mjs.map +0 -1
  170. package/dist/chunk-TEYIQHMK.mjs +0 -12
  171. package/dist/chunk-TEYIQHMK.mjs.map +0 -1
  172. package/dist/chunk-UIRFLYXI.mjs.map +0 -1
  173. package/dist/chunk-VGX2W5ZB.mjs +0 -28
  174. package/dist/chunk-VGX2W5ZB.mjs.map +0 -1
  175. package/dist/chunk-X3Z2EVFV.mjs.map +0 -1
  176. package/dist/chunk-X4T6ZUVM.mjs.map +0 -1
  177. package/dist/chunk-XGUBRIUV.mjs +0 -72
  178. package/dist/chunk-XGUBRIUV.mjs.map +0 -1
  179. package/dist/chunk-Y2RUG4B3.mjs.map +0 -1
  180. package/dist/chunk-ZVAH2Z2W.mjs.map +0 -1
  181. package/dist/chunk-ZYC5YVDO.mjs +0 -21
  182. package/dist/chunk-ZYC5YVDO.mjs.map +0 -1
  183. package/dist/components/chat-components/chat-list.d.ts +0 -8
  184. package/dist/components/chat-components/chat-list.mjs +0 -13
  185. package/dist/components/chat-components/chat-message-actions.d.ts +0 -8
  186. package/dist/components/chat-components/chat-message-actions.mjs +0 -8
  187. package/dist/components/chat-components/chat-message.d.ts +0 -8
  188. package/dist/components/chat-components/chat-message.mjs +0 -11
  189. package/dist/components/chat-components/chat-panel.d.ts +0 -8
  190. package/dist/components/chat-components/chat-panel.mjs +0 -10
  191. package/dist/components/chat-components/chat-scroll-anchor.d.ts +0 -6
  192. package/dist/components/chat-components/chat-scroll-anchor.mjs +0 -5
  193. package/dist/components/chat-components/clear-history.d.ts +0 -9
  194. package/dist/components/chat-components/clear-history.mjs +0 -56
  195. package/dist/components/chat-components/clear-history.mjs.map +0 -1
  196. package/dist/components/chat-components/copilot-chat.d.ts +0 -12
  197. package/dist/components/chat-components/copilot-chat.mjs +0 -22
  198. package/dist/components/chat-components/copilot-chat.mjs.map +0 -1
  199. package/dist/components/chat-components/default-empty-screen.d.ts +0 -8
  200. package/dist/components/chat-components/default-empty-screen.mjs +0 -8
  201. package/dist/components/chat-components/default-empty-screen.mjs.map +0 -1
  202. package/dist/components/chat-components/external-link.d.ts +0 -6
  203. package/dist/components/chat-components/external-link.mjs +0 -4
  204. package/dist/components/chat-components/external-link.mjs.map +0 -1
  205. package/dist/components/chat-components/markdown.d.ts +0 -6
  206. package/dist/components/chat-components/markdown.mjs +0 -4
  207. package/dist/components/chat-components/markdown.mjs.map +0 -1
  208. package/dist/components/chat-components/prompt-form.d.ts +0 -9
  209. package/dist/components/chat-components/prompt-form.mjs +0 -9
  210. package/dist/components/chat-components/prompt-form.mjs.map +0 -1
  211. package/dist/components/chat-components/theme-toggle.d.ts +0 -3
  212. package/dist/components/chat-components/theme-toggle.mjs +0 -32
  213. package/dist/components/chat-components/theme-toggle.mjs.map +0 -1
  214. package/dist/components/chat-components/toaster.d.ts +0 -1
  215. package/dist/components/chat-components/toaster.mjs +0 -4
  216. package/dist/components/chat-components/toaster.mjs.map +0 -1
  217. package/dist/components/chat-components/ui/alert-dialog.d.ts +0 -20
  218. package/dist/components/chat-components/ui/alert-dialog.mjs +0 -6
  219. package/dist/components/chat-components/ui/alert-dialog.mjs.map +0 -1
  220. package/dist/components/chat-components/ui/badge.d.ts +0 -12
  221. package/dist/components/chat-components/ui/badge.mjs +0 -29
  222. package/dist/components/chat-components/ui/badge.mjs.map +0 -1
  223. package/dist/components/chat-components/ui/button.d.ts +0 -14
  224. package/dist/components/chat-components/ui/button.mjs +0 -5
  225. package/dist/components/chat-components/ui/button.mjs.map +0 -1
  226. package/dist/components/chat-components/ui/codeblock.d.ts +0 -14
  227. package/dist/components/chat-components/ui/codeblock.mjs +0 -8
  228. package/dist/components/chat-components/ui/codeblock.mjs.map +0 -1
  229. package/dist/components/chat-components/ui/dialog.d.ts +0 -18
  230. package/dist/components/chat-components/ui/dialog.mjs +0 -94
  231. package/dist/components/chat-components/ui/dialog.mjs.map +0 -1
  232. package/dist/components/chat-components/ui/dropdown-menu.d.ts +0 -24
  233. package/dist/components/chat-components/ui/dropdown-menu.mjs +0 -87
  234. package/dist/components/chat-components/ui/dropdown-menu.mjs.map +0 -1
  235. package/dist/components/chat-components/ui/icons.d.ts +0 -33
  236. package/dist/components/chat-components/ui/icons.mjs +0 -5
  237. package/dist/components/chat-components/ui/icons.mjs.map +0 -1
  238. package/dist/components/chat-components/ui/input.d.ts +0 -7
  239. package/dist/components/chat-components/ui/input.mjs +0 -26
  240. package/dist/components/chat-components/ui/input.mjs.map +0 -1
  241. package/dist/components/chat-components/ui/label.d.ts +0 -8
  242. package/dist/components/chat-components/ui/label.mjs +0 -19
  243. package/dist/components/chat-components/ui/label.mjs.map +0 -1
  244. package/dist/components/chat-components/ui/select.d.ts +0 -13
  245. package/dist/components/chat-components/ui/select.mjs +0 -101
  246. package/dist/components/chat-components/ui/select.mjs.map +0 -1
  247. package/dist/components/chat-components/ui/separator.d.ts +0 -6
  248. package/dist/components/chat-components/ui/separator.mjs +0 -5
  249. package/dist/components/chat-components/ui/separator.mjs.map +0 -1
  250. package/dist/components/chat-components/ui/sheet.d.ts +0 -19
  251. package/dist/components/chat-components/ui/sheet.mjs +0 -93
  252. package/dist/components/chat-components/ui/sheet.mjs.map +0 -1
  253. package/dist/components/chat-components/ui/switch.d.ts +0 -6
  254. package/dist/components/chat-components/ui/switch.mjs +0 -33
  255. package/dist/components/chat-components/ui/switch.mjs.map +0 -1
  256. package/dist/components/chat-components/ui/textarea.d.ts +0 -7
  257. package/dist/components/chat-components/ui/textarea.mjs +0 -25
  258. package/dist/components/chat-components/ui/textarea.mjs.map +0 -1
  259. package/dist/components/chat-components/ui/tooltip.d.ts +0 -9
  260. package/dist/components/chat-components/ui/tooltip.mjs +0 -5
  261. package/dist/components/chat-components/ui/tooltip.mjs.map +0 -1
  262. package/dist/components/sidebar/copilot-sidebar-ui-provider.d.ts +0 -8
  263. package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +0 -25
  264. package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs.map +0 -1
  265. package/dist/components/sidebar/copilot-sidebar.d.ts +0 -6
  266. package/dist/components/sidebar/copilot-sidebar.mjs +0 -23
  267. package/dist/components/sidebar/copilot-sidebar.mjs.map +0 -1
  268. package/dist/components/sidebar/sidebar-context.d.ts +0 -9
  269. package/dist/components/sidebar/sidebar-context.mjs +0 -4
  270. package/dist/components/sidebar/sidebar-context.mjs.map +0 -1
  271. package/dist/hooks/use-at-bottom.d.ts +0 -3
  272. package/dist/hooks/use-at-bottom.mjs +0 -4
  273. package/dist/hooks/use-at-bottom.mjs.map +0 -1
  274. package/dist/hooks/use-enter-submit.d.ts +0 -8
  275. package/dist/hooks/use-enter-submit.mjs +0 -4
  276. package/dist/hooks/use-enter-submit.mjs.map +0 -1
  277. package/src/components/chat-components/chat-list.tsx +0 -28
  278. package/src/components/chat-components/chat-message-actions.tsx +0 -36
  279. package/src/components/chat-components/chat-message.tsx +0 -70
  280. package/src/components/chat-components/chat-panel.tsx +0 -64
  281. package/src/components/chat-components/chat-scroll-anchor.tsx +0 -29
  282. package/src/components/chat-components/clear-history.tsx +0 -72
  283. package/src/components/chat-components/copilot-chat.tsx +0 -57
  284. package/src/components/chat-components/default-empty-screen.tsx +0 -57
  285. package/src/components/chat-components/external-link.tsx +0 -17
  286. package/src/components/chat-components/markdown.tsx +0 -8
  287. package/src/components/chat-components/prompt-form.tsx +0 -85
  288. package/src/components/chat-components/theme-toggle.tsx +0 -31
  289. package/src/components/chat-components/toaster.tsx +0 -3
  290. package/src/components/chat-components/ui/alert-dialog.tsx +0 -126
  291. package/src/components/chat-components/ui/badge.tsx +0 -33
  292. package/src/components/chat-components/ui/button.tsx +0 -49
  293. package/src/components/chat-components/ui/codeblock.tsx +0 -137
  294. package/src/components/chat-components/ui/dialog.tsx +0 -106
  295. package/src/components/chat-components/ui/dropdown-menu.tsx +0 -117
  296. package/src/components/chat-components/ui/icons.tsx +0 -484
  297. package/src/components/chat-components/ui/input.tsx +0 -24
  298. package/src/components/chat-components/ui/label.tsx +0 -21
  299. package/src/components/chat-components/ui/select.tsx +0 -119
  300. package/src/components/chat-components/ui/separator.tsx +0 -26
  301. package/src/components/chat-components/ui/sheet.tsx +0 -106
  302. package/src/components/chat-components/ui/switch.tsx +0 -29
  303. package/src/components/chat-components/ui/textarea.tsx +0 -23
  304. package/src/components/chat-components/ui/tooltip.tsx +0 -30
  305. package/src/components/sidebar/copilot-sidebar-ui-provider.tsx +0 -73
  306. package/src/components/sidebar/copilot-sidebar.tsx +0 -38
  307. package/src/components/sidebar/sidebar-context.tsx +0 -11
  308. package/src/hooks/use-at-bottom.tsx +0 -20
  309. package/src/hooks/use-enter-submit.tsx +0 -17
  310. /package/dist/{chunk-FZRTAML3.mjs.map → chunk-JD7BAH7U.mjs.map} +0 -0
  311. /package/dist/components/{chat-components/chat-list.mjs.map → chat/props.js.map} +0 -0
  312. /package/dist/{components/chat-components/chat-message-actions.mjs.map → context/index.js.map} +0 -0
  313. /package/dist/{components/chat-components/chat-message.mjs.map → hooks/index.js.map} +0 -0
  314. /package/dist/{components/chat-components/chat-panel.mjs.map → types/index.js.map} +0 -0
  315. /package/dist/{components/chat-components/chat-scroll-anchor.mjs.map → types/types.js.map} +0 -0
@@ -1,31 +0,0 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import { useTheme } from "next-themes";
5
-
6
- import { Button } from "./ui/button";
7
- import { IconMoon, IconSun } from "./ui/icons";
8
-
9
- export function ThemeToggle() {
10
- const { setTheme, theme } = useTheme();
11
- const [_, startTransition] = React.useTransition();
12
-
13
- return (
14
- <Button
15
- variant="ghost"
16
- size="icon"
17
- onClick={() => {
18
- startTransition(() => {
19
- setTheme(theme === "light" ? "dark" : "light");
20
- });
21
- }}
22
- >
23
- {!theme ? null : theme === "dark" ? (
24
- <IconMoon className="transition-all" />
25
- ) : (
26
- <IconSun className="transition-all" />
27
- )}
28
- <span className="sr-only">Toggle theme</span>
29
- </Button>
30
- );
31
- }
@@ -1,3 +0,0 @@
1
- "use client";
2
-
3
- export { Toaster } from "react-hot-toast";
@@ -1,126 +0,0 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
5
-
6
- import { cn } from "../../../lib/utils";
7
- import { buttonVariants } from "./button";
8
-
9
- const AlertDialog = AlertDialogPrimitive.Root;
10
-
11
- const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
12
-
13
- const AlertDialogPortal = ({
14
- className,
15
- children,
16
- ...props
17
- }: AlertDialogPrimitive.AlertDialogPortalProps) => (
18
- <AlertDialogPrimitive.Portal className={cn(className)} {...props}>
19
- <div className="fixed inset-0 z-50 flex items-end justify-center sm:items-center">
20
- {children}
21
- </div>
22
- </AlertDialogPrimitive.Portal>
23
- );
24
- AlertDialogPortal.displayName = AlertDialogPrimitive.Portal.displayName;
25
-
26
- const AlertDialogOverlay = React.forwardRef<
27
- React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
28
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
29
- >(({ className, children, ...props }, ref) => (
30
- <AlertDialogPrimitive.Overlay
31
- className={cn(
32
- "fixed inset-0 z-50 bg-background/80 backdrop-blur-sm transition-opacity animate-in fade-in",
33
- className,
34
- )}
35
- {...props}
36
- ref={ref}
37
- />
38
- ));
39
- AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
40
-
41
- const AlertDialogContent = React.forwardRef<
42
- React.ElementRef<typeof AlertDialogPrimitive.Content>,
43
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
44
- >(({ className, ...props }, ref) => (
45
- <AlertDialogPortal>
46
- <AlertDialogOverlay />
47
- <AlertDialogPrimitive.Content
48
- ref={ref}
49
- className={cn(
50
- "fixed z-50 grid w-full max-w-lg scale-100 gap-4 border bg-background p-6 opacity-100 shadow-lg animate-in fade-in-90 slide-in-from-bottom-10 sm:rounded-lg sm:zoom-in-90 sm:slide-in-from-bottom-0 md:w-full",
51
- className,
52
- )}
53
- {...props}
54
- />
55
- </AlertDialogPortal>
56
- ));
57
- AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
58
-
59
- const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
60
- <div className={cn("flex flex-col space-y-2 text-center sm:text-left", className)} {...props} />
61
- );
62
- AlertDialogHeader.displayName = "AlertDialogHeader";
63
-
64
- const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
65
- <div
66
- className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
67
- {...props}
68
- />
69
- );
70
- AlertDialogFooter.displayName = "AlertDialogFooter";
71
-
72
- const AlertDialogTitle = React.forwardRef<
73
- React.ElementRef<typeof AlertDialogPrimitive.Title>,
74
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
75
- >(({ className, ...props }, ref) => (
76
- <AlertDialogPrimitive.Title
77
- ref={ref}
78
- className={cn("text-lg font-semibold", className)}
79
- {...props}
80
- />
81
- ));
82
- AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
83
-
84
- const AlertDialogDescription = React.forwardRef<
85
- React.ElementRef<typeof AlertDialogPrimitive.Description>,
86
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
87
- >(({ className, ...props }, ref) => (
88
- <AlertDialogPrimitive.Description
89
- ref={ref}
90
- className={cn("text-sm text-muted-foreground", className)}
91
- {...props}
92
- />
93
- ));
94
- AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
95
-
96
- const AlertDialogAction = React.forwardRef<
97
- React.ElementRef<typeof AlertDialogPrimitive.Action>,
98
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
99
- >(({ className, ...props }, ref) => (
100
- <AlertDialogPrimitive.Action ref={ref} className={cn(buttonVariants(), className)} {...props} />
101
- ));
102
- AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
103
-
104
- const AlertDialogCancel = React.forwardRef<
105
- React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
106
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
107
- >(({ className, ...props }, ref) => (
108
- <AlertDialogPrimitive.Cancel
109
- ref={ref}
110
- className={cn(buttonVariants({ variant: "outline" }), "mt-2 sm:mt-0", className)}
111
- {...props}
112
- />
113
- ));
114
- AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
115
-
116
- export {
117
- AlertDialog,
118
- AlertDialogTrigger,
119
- AlertDialogContent,
120
- AlertDialogHeader,
121
- AlertDialogFooter,
122
- AlertDialogTitle,
123
- AlertDialogDescription,
124
- AlertDialogAction,
125
- AlertDialogCancel,
126
- };
@@ -1,33 +0,0 @@
1
- import * as React from "react";
2
- import { cva, type VariantProps } from "class-variance-authority";
3
-
4
- import { cn } from "../../../lib/utils";
5
-
6
- const badgeVariants = cva(
7
- "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
8
- {
9
- variants: {
10
- variant: {
11
- default: "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
12
- secondary:
13
- "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
14
- destructive:
15
- "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
16
- outline: "text-foreground",
17
- },
18
- },
19
- defaultVariants: {
20
- variant: "default",
21
- },
22
- },
23
- );
24
-
25
- export interface BadgeProps
26
- extends React.HTMLAttributes<HTMLDivElement>,
27
- VariantProps<typeof badgeVariants> {}
28
-
29
- function Badge({ className, variant, ...props }: BadgeProps) {
30
- return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
31
- }
32
-
33
- export { Badge, badgeVariants };
@@ -1,49 +0,0 @@
1
- import * as React from "react";
2
- import { Slot } from "@radix-ui/react-slot";
3
- import { cva, type VariantProps } from "class-variance-authority";
4
-
5
- import { cn } from "../../../lib/utils";
6
-
7
- const buttonVariants = cva(
8
- "inline-flex items-center justify-center rounded-md text-sm font-medium shadow ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
9
- {
10
- variants: {
11
- variant: {
12
- default: "bg-primary text-primary-foreground shadow-md hover:bg-primary/90",
13
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
14
- outline: "border border-input hover:bg-accent hover:text-accent-foreground",
15
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
16
- ghost: "shadow-none hover:bg-accent hover:text-accent-foreground",
17
- link: "text-primary underline-offset-4 shadow-none hover:underline",
18
- },
19
- size: {
20
- default: "h-8 px-4 py-2",
21
- sm: "h-8 rounded-md px-3",
22
- lg: "h-11 rounded-md px-8",
23
- icon: "h-8 w-8 p-0",
24
- },
25
- },
26
- defaultVariants: {
27
- variant: "default",
28
- size: "default",
29
- },
30
- },
31
- );
32
-
33
- export interface ButtonProps
34
- extends React.ButtonHTMLAttributes<HTMLButtonElement>,
35
- VariantProps<typeof buttonVariants> {
36
- asChild?: boolean;
37
- }
38
-
39
- const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
40
- ({ className, variant, size, asChild = false, ...props }, ref) => {
41
- const Comp = asChild ? Slot : "button";
42
- return (
43
- <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />
44
- );
45
- },
46
- );
47
- Button.displayName = "Button";
48
-
49
- export { Button, buttonVariants };
@@ -1,137 +0,0 @@
1
- "use client";
2
-
3
- import { FC, memo } from "react";
4
- import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
5
-
6
- import { useCopyToClipboard } from "../../../hooks/use-copy-to-clipboard";
7
- import { IconCheck, IconCopy, IconDownload } from "./icons";
8
- import { Button } from "./button";
9
-
10
- interface Props {
11
- language: string;
12
- value: string;
13
- }
14
-
15
- interface languageMap {
16
- [key: string]: string | undefined;
17
- }
18
-
19
- export const programmingLanguages: languageMap = {
20
- javascript: ".js",
21
- python: ".py",
22
- java: ".java",
23
- c: ".c",
24
- cpp: ".cpp",
25
- "c++": ".cpp",
26
- "c#": ".cs",
27
- ruby: ".rb",
28
- php: ".php",
29
- swift: ".swift",
30
- "objective-c": ".m",
31
- kotlin: ".kt",
32
- typescript: ".ts",
33
- go: ".go",
34
- perl: ".pl",
35
- rust: ".rs",
36
- scala: ".scala",
37
- haskell: ".hs",
38
- lua: ".lua",
39
- shell: ".sh",
40
- sql: ".sql",
41
- html: ".html",
42
- css: ".css",
43
- // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
44
- };
45
-
46
- export const generateRandomString = (length: number, lowercase = false) => {
47
- const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789"; // excluding similar looking characters like Z, 2, I, 1, O, 0
48
- let result = "";
49
- for (let i = 0; i < length; i++) {
50
- result += chars.charAt(Math.floor(Math.random() * chars.length));
51
- }
52
- return lowercase ? result.toLowerCase() : result;
53
- };
54
-
55
- const CodeBlock: FC<Props> = memo(({ language, value }) => {
56
- const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 });
57
-
58
- const downloadAsFile = () => {
59
- if (typeof window === "undefined") {
60
- return;
61
- }
62
- const fileExtension = programmingLanguages[language] || ".file";
63
- const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
64
- const fileName = window.prompt("Enter file name" || "", suggestedFileName);
65
-
66
- if (!fileName) {
67
- // User pressed cancel on prompt.
68
- return;
69
- }
70
-
71
- const blob = new Blob([value], { type: "text/plain" });
72
- const url = URL.createObjectURL(blob);
73
- const link = document.createElement("a");
74
- link.download = fileName;
75
- link.href = url;
76
- link.style.display = "none";
77
- document.body.appendChild(link);
78
- link.click();
79
- document.body.removeChild(link);
80
- URL.revokeObjectURL(url);
81
- };
82
-
83
- const onCopy = () => {
84
- if (isCopied) return;
85
- copyToClipboard(value);
86
- };
87
-
88
- return (
89
- <div className="codeblock relative w-full bg-zinc-950 font-sans">
90
- <div className="flex w-full items-center justify-between bg-zinc-800 px-6 py-2 pr-4 text-zinc-100">
91
- <span className="text-xs lowercase">{language}</span>
92
- <div className="flex items-center space-x-1">
93
- <Button
94
- variant="ghost"
95
- className="hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0"
96
- onClick={downloadAsFile}
97
- size="icon"
98
- >
99
- <IconDownload />
100
- <span className="sr-only">Download</span>
101
- </Button>
102
- <Button
103
- variant="ghost"
104
- size="icon"
105
- className="text-xs hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0"
106
- onClick={onCopy}
107
- >
108
- {isCopied ? <IconCheck /> : <IconCopy />}
109
- <span className="sr-only">Copy code</span>
110
- </Button>
111
- </div>
112
- </div>
113
- <SyntaxHighlighter
114
- language={language}
115
- PreTag="div"
116
- showLineNumbers
117
- customStyle={{
118
- margin: 0,
119
- width: "100%",
120
- background: "transparent",
121
- padding: "1.5rem 1rem",
122
- }}
123
- codeTagProps={{
124
- style: {
125
- fontSize: "0.9rem",
126
- fontFamily: "var(--font-mono)",
127
- },
128
- }}
129
- >
130
- {value}
131
- </SyntaxHighlighter>
132
- </div>
133
- );
134
- });
135
- CodeBlock.displayName = "CodeBlock";
136
-
137
- export { CodeBlock };
@@ -1,106 +0,0 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import * as DialogPrimitive from "@radix-ui/react-dialog";
5
-
6
- import { cn } from "../../../lib/utils";
7
- import { IconClose } from "./icons";
8
-
9
- const Dialog = DialogPrimitive.Root;
10
-
11
- const DialogTrigger = DialogPrimitive.Trigger;
12
-
13
- const DialogPortal = ({ className, children, ...props }: DialogPrimitive.DialogPortalProps) => (
14
- <DialogPrimitive.Portal className={cn(className)} {...props}>
15
- <div className="fixed inset-0 z-50 flex items-start justify-center sm:items-center">
16
- {children}
17
- </div>
18
- </DialogPrimitive.Portal>
19
- );
20
- DialogPortal.displayName = DialogPrimitive.Portal.displayName;
21
-
22
- const DialogOverlay = React.forwardRef<
23
- React.ElementRef<typeof DialogPrimitive.Overlay>,
24
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
25
- >(({ className, ...props }, ref) => (
26
- <DialogPrimitive.Overlay
27
- ref={ref}
28
- className={cn(
29
- "fixed inset-0 z-50 bg-background/80 backdrop-blur-sm transition-all duration-100 data-[state=closed]:animate-out data-[state=closed]:fade-out data-[state=open]:fade-in",
30
- className,
31
- )}
32
- {...props}
33
- />
34
- ));
35
- DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
36
-
37
- const DialogContent = React.forwardRef<
38
- React.ElementRef<typeof DialogPrimitive.Content>,
39
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
40
- >(({ className, children, ...props }, ref) => (
41
- <DialogPortal>
42
- <DialogOverlay />
43
- <DialogPrimitive.Content
44
- ref={ref}
45
- className={cn(
46
- "fixed z-50 grid w-full gap-4 rounded-b-lg border bg-background p-6 shadow-sm animate-in data-[state=open]:fade-in-90 data-[state=open]:slide-in-from-bottom-10 sm:max-w-lg sm:rounded-lg sm:zoom-in-90 data-[state=open]:sm:slide-in-from-bottom-0",
47
- className,
48
- )}
49
- {...props}
50
- >
51
- {children}
52
- <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
53
- <IconClose />
54
- <span className="sr-only">Close</span>
55
- </DialogPrimitive.Close>
56
- </DialogPrimitive.Content>
57
- </DialogPortal>
58
- ));
59
- DialogContent.displayName = DialogPrimitive.Content.displayName;
60
-
61
- const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
62
- <div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
63
- );
64
- DialogHeader.displayName = "DialogHeader";
65
-
66
- const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
67
- <div
68
- className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
69
- {...props}
70
- />
71
- );
72
- DialogFooter.displayName = "DialogFooter";
73
-
74
- const DialogTitle = React.forwardRef<
75
- React.ElementRef<typeof DialogPrimitive.Title>,
76
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
77
- >(({ className, ...props }, ref) => (
78
- <DialogPrimitive.Title
79
- ref={ref}
80
- className={cn("text-lg font-semibold leading-none tracking-tight", className)}
81
- {...props}
82
- />
83
- ));
84
- DialogTitle.displayName = DialogPrimitive.Title.displayName;
85
-
86
- const DialogDescription = React.forwardRef<
87
- React.ElementRef<typeof DialogPrimitive.Description>,
88
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
89
- >(({ className, ...props }, ref) => (
90
- <DialogPrimitive.Description
91
- ref={ref}
92
- className={cn("text-sm text-muted-foreground", className)}
93
- {...props}
94
- />
95
- ));
96
- DialogDescription.displayName = DialogPrimitive.Description.displayName;
97
-
98
- export {
99
- Dialog,
100
- DialogTrigger,
101
- DialogContent,
102
- DialogHeader,
103
- DialogFooter,
104
- DialogTitle,
105
- DialogDescription,
106
- };
@@ -1,117 +0,0 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
5
-
6
- import { cn } from "../../../lib/utils";
7
-
8
- const DropdownMenu = DropdownMenuPrimitive.Root;
9
-
10
- const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
11
-
12
- const DropdownMenuGroup = DropdownMenuPrimitive.Group;
13
-
14
- const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
15
-
16
- const DropdownMenuSub = DropdownMenuPrimitive.Sub;
17
-
18
- const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
19
-
20
- const DropdownMenuSubContent = React.forwardRef<
21
- React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
22
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
23
- >(({ className, ...props }, ref) => (
24
- <DropdownMenuPrimitive.SubContent
25
- ref={ref}
26
- className={cn(
27
- "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1",
28
- className,
29
- )}
30
- {...props}
31
- />
32
- ));
33
- DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
34
-
35
- const DropdownMenuContent = React.forwardRef<
36
- React.ElementRef<typeof DropdownMenuPrimitive.Content>,
37
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
38
- >(({ className, sideOffset = 4, ...props }, ref) => (
39
- <DropdownMenuPrimitive.Portal>
40
- <DropdownMenuPrimitive.Content
41
- ref={ref}
42
- sideOffset={sideOffset}
43
- className={cn(
44
- "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow animate-in data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
45
- className,
46
- )}
47
- {...props}
48
- />
49
- </DropdownMenuPrimitive.Portal>
50
- ));
51
- DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
52
-
53
- const DropdownMenuItem = React.forwardRef<
54
- React.ElementRef<typeof DropdownMenuPrimitive.Item>,
55
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
56
- inset?: boolean;
57
- }
58
- >(({ className, inset, ...props }, ref) => (
59
- <DropdownMenuPrimitive.Item
60
- ref={ref}
61
- className={cn(
62
- "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
63
- inset && "pl-8",
64
- className,
65
- )}
66
- {...props}
67
- />
68
- ));
69
- DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
70
-
71
- const DropdownMenuLabel = React.forwardRef<
72
- React.ElementRef<typeof DropdownMenuPrimitive.Label>,
73
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
74
- inset?: boolean;
75
- }
76
- >(({ className, inset, ...props }, ref) => (
77
- <DropdownMenuPrimitive.Label
78
- ref={ref}
79
- className={cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className)}
80
- {...props}
81
- />
82
- ));
83
- DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
84
-
85
- const DropdownMenuSeparator = React.forwardRef<
86
- React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
87
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
88
- >(({ className, ...props }, ref) => (
89
- <DropdownMenuPrimitive.Separator
90
- ref={ref}
91
- className={cn("-mx-1 my-1 h-px bg-muted", className)}
92
- {...props}
93
- />
94
- ));
95
- DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
96
-
97
- const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
98
- return (
99
- <span className={cn("ml-auto text-xs tracking-widest opacity-60", className)} {...props} />
100
- );
101
- };
102
- DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
103
-
104
- export {
105
- DropdownMenu,
106
- DropdownMenuTrigger,
107
- DropdownMenuContent,
108
- DropdownMenuItem,
109
- DropdownMenuLabel,
110
- DropdownMenuSeparator,
111
- DropdownMenuShortcut,
112
- DropdownMenuGroup,
113
- DropdownMenuPortal,
114
- DropdownMenuSub,
115
- DropdownMenuSubContent,
116
- DropdownMenuRadioGroup,
117
- };